:root {
    --blue: #D71E00;
    --blue-press: #A81600;
    --ink: #1c2434;
    --muted: #6d778a;
    --line: #e6eaf2;
    --field: #f7f8fb;
    --bg: #eef2f8;
    --card: #ffffff;
    --soft: #e7eef9;
    --danger: #c62828;
    --cheap: #1f8a4c;
    --shadow: 0 10px 32px rgba(215, 30, 0, 0.1);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f3f6fb;
        --muted: #a9b3c6;
        --line: rgba(255, 255, 255, 0.1);
        --field: #151c2b;
        --bg: #0d1422;
        --card: #171f30;
        --soft: rgba(215, 30, 0, 0.45);
        --cheap: #7ddea8;
        --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

button, input { font: inherit; color: inherit; }

.screen {
    width: min(1180px, calc(100vw - clamp(32px, 4vw, 64px) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    margin: 0 auto;
    padding: 18px 0 calc(28px + env(safe-area-inset-bottom));
}

.logo {
    display: flex;
    justify-content: center;
    margin: 0 0 clamp(14px, 2.2vw, 26px);
}

.logo-img {
    display: block;
    height: clamp(34px, 4.2vw, 52px);
    width: auto;
}

.logo-dark { display: none; }

.modes {
    display: flex;
    align-items: center;
    justify-content: safe center;
    gap: 8px;
    margin: 0 0 14px;
    overflow-x: auto;
    scrollbar-width: none;
}

.modes::-webkit-scrollbar { display: none; }

.mode {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    border: 0;
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    min-height: 36px;
    padding: 0 14px;
    font-weight: 650;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 1px 0 rgba(28, 36, 52, 0.04);
}

.mode.is-on { background: var(--blue); color: #fff; }

@media (prefers-color-scheme: dark) {
    .logo-light { display: none; }
    .logo-dark { display: block; }
}

.search {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
}

.plate {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.plate > .choice { width: 100%; }

.cities { position: relative; }

.field { position: relative; min-width: 0; }

.row {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1vw, 12px);
    width: 100%;
    min-height: clamp(56px, 6vw, 64px);
    margin: 0;
    padding: 8px clamp(10px, 1.2vw, 14px);
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.choice { cursor: pointer; border-radius: 18px; }
.cities .field:first-child .row {
    border-bottom: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
}
.cities .field:last-child .row { border-radius: 0 0 18px 18px; }
.choice:hover, .row:focus-within { background: var(--field); }

.icon {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    object-fit: contain;
    display: block;
}

.city-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 16px;
    padding: 8px 28px 8px 0;
    cursor: pointer;
    text-overflow: ellipsis;
}

.city-input:focus { cursor: text; }
.city-input::placeholder { color: var(--muted); }

.swap {
    position: absolute;
    z-index: 2;
    right: 10px;
    top: calc(clamp(56px, 6vw, 64px) - 16px);
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--card);
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 0 0 4px var(--card);
}

.swap img {
    width: 30px;
    height: 30px;
    display: block;
}

.swap:hover { transform: scale(1.04); }

.suggest {
    position: absolute;
    z-index: 8;
    left: 4px;
    right: 4px;
    top: calc(100% - 2px);
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-height: min(420px, 56vh);
    overflow: auto;
    animation: suggest-in 140ms ease-out;
}

.field:focus-within { z-index: 9; }

.suggest button {
    display: flex;
    width: 100%;
    gap: 10px;
    align-items: baseline;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
}

.suggest button[aria-selected="true"],
.suggest button:hover { background: var(--soft); }

.suggest .code {
    margin-left: auto;
    color: var(--blue);
    font-weight: 700;
    font-size: 13px;
}

.suggest .city {
    display: flex;
    align-items: center;
    min-width: 0;
    background: var(--card);
    border-radius: clamp(14px, 1.4vw, 18px);
    box-shadow: var(--shadow);
    padding: clamp(10px, 1.2vw, 14px) clamp(12px, 1.4vw, 18px);
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
}

.suggest .country { color: var(--muted); font-size: 13px; white-space: nowrap; }

.choice-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.choice-label { color: var(--muted); font-size: 12px; }

.choice-value {
    font-size: 16px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.choice-value.is-empty { color: var(--muted); font-weight: 500; }

.form-error {
    margin: 0;
    color: var(--danger);
    font-size: 14px;
}

.row.is-invalid { box-shadow: inset 0 0 0 1.5px var(--danger); border-radius: 14px; }

.find {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    height: 52px;
    text-align: center;
    text-decoration: none;
    background: var(--blue);
    color: #fff;
    border-radius: 18px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.find:hover { background: var(--blue-press); }

.find:focus-visible, .swap:focus-visible, .choice:focus-visible, .mode:focus-visible, .sheet button:focus-visible, .suggest button:focus-visible {
    outline: 3px solid rgba(215, 30, 0, 0.35);
    outline-offset: 2px;
}

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(13, 20, 34, 0.42);
}

.backdrop[hidden] { display: none; }

.sheet {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(13, 20, 34, 0.48);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sheet[hidden] { display: none; }

.sheet-card {
    width: min(480px, 100%);
    max-height: min(92vh, 760px);
    overflow: auto;
    background: var(--card);
    border-radius: 22px 22px 0 0;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    animation: sheet-up 200ms ease-out;
}

.sheet-card-wide { width: min(760px, 100%); }

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--card);
    padding-top: 8px;
    z-index: 1;
}

.sheet-head h2 { margin: 8px 0; font-size: 20px; }

.sheet-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--field);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.sheet-hint { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.months { display: grid; gap: 18px; }

.month-head {
    display: grid;
    grid-template-columns: 36px 1fr 36px;
    align-items: center;
    gap: 4px;
    font-weight: 750;
    margin-bottom: 8px;
}

.month-title { text-align: center; }

.month-head button, .stepper-controls button, .text-button, .done {
    border: 0;
    background: var(--field);
    cursor: pointer;
}

.month-head button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--blue);
    font-size: 18px;
}

.weekdays, .days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.weekdays { color: var(--muted); font-size: 12px; margin-bottom: 4px; }

.days button {
    min-height: 52px;
    height: 52px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px 0 3px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.day-num { font-size: 15px; line-height: 1.1; font-weight: 650; }

.day-price {
    font-size: 9px;
    line-height: 1.1;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: -0.03em;
    max-width: 100%;
    overflow: hidden;
}

.day-price.is-cheap { color: var(--cheap); }

.days button.is-past {
    min-height: 28px;
    height: 28px;
    opacity: 0.28;
    pointer-events: none;
}
.days button.is-past .day-num { font-size: 12px; font-weight: 500; }
.days button.is-past .day-price { display: none; }

.month-block + .month-block {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

@media (hover: hover) and (pointer: fine) {
    .days button:hover:not(:disabled):not(.is-start):not(.is-end) {
        background: var(--soft);
    }
}
.days button:active:not(:disabled):not(.is-start):not(.is-end) {
    background: var(--soft);
}
.days button:disabled { color: var(--muted); opacity: 0.38; cursor: default; }
.days button.is-range {
    background: var(--soft);
    border-radius: 0;
    color: var(--ink);
}
.days button.is-start,
.days button.is-end {
    background: var(--blue) !important;
    color: #fff !important;
    border-radius: 12px;
}
.days button.is-start .day-num,
.days button.is-end .day-num { color: #fff !important; }
.days button.is-start .day-price,
.days button.is-end .day-price { color: rgba(255, 255, 255, 0.92) !important; }

.sheet-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.text-button, .done {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 700;
}

.done { background: var(--blue); color: #fff; }
.text-button { color: var(--blue); }

.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.stepper-name { font-weight: 700; }
.stepper-note { color: var(--muted); font-size: 13px; margin-top: 2px; }

.stepper-controls { display: flex; align-items: center; gap: 8px; }
.stepper-controls button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--blue);
    font-size: 22px;
}
.stepper-controls button:disabled { opacity: 0.35; }
.stepper-controls span { min-width: 18px; text-align: center; font-weight: 750; }

.cabins {
    border: 0;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.cabins legend { font-weight: 750; margin-bottom: 8px; }

.cabins label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
}

@media (max-width: 919px) {
    .field:focus-within { z-index: auto; }
    .suggest {
        position: fixed;
        z-index: 40;
        left: 16px;
        right: 16px;
        bottom: auto;
        max-height: min(52vh, 380px);
        border-radius: 18px;
        animation: suggest-in 140ms ease-out;
    }
}

@media (min-width: 920px) {
    .search {
        flex-direction: row;
        align-items: stretch;
        flex-wrap: wrap;
        gap: 10px;
    }

    .cities {
        display: flex;
        flex-direction: row;
        flex: 2.6 1 0;
        align-items: stretch;
    }

    .when { flex: 1.2 1 0; }
    .who { flex: 1.05 1 0; }
    .when .choice,
    .who .choice { height: 100%; }

    .cities .field { flex: 1 1 0; }

    .cities .row,
    .choice {
        border-bottom: 0;
        min-height: clamp(52px, 4.4vw, 64px);
        height: 100%;
    }

    .cities .field:first-child .row {
        border-bottom: 0;
        border-radius: 18px 0 0 18px;
    }
    .cities .field:last-child .row {
        border-radius: 0 18px 18px 0;
        box-shadow: inset 1px 0 0 var(--line);
        padding-left: clamp(16px, 1.6vw, 22px);
    }

    .cities .field:first-child .city-input { padding-right: 18px; }

    .swap {
        right: auto;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .swap:hover { transform: translate(-50%, -50%) scale(1.04); }

    .city-input,
    .choice-value {
        font-size: clamp(13px, 0.35vw + 11px, 16px);
    }

    .choice-label { font-size: clamp(11px, 0.2vw + 10px, 12px); }

    .find {
        flex: 0 0 auto;
        align-self: stretch;
        height: auto;
        min-height: 52px;
        margin: 0;
        padding: 0 clamp(16px, 1.5vw, 28px);
        letter-spacing: 0.04em;
    }

    .form-error { flex: 1 0 100%; }

    .suggest {
        top: calc(100% + 6px);
        right: auto;
        width: max(100%, 360px);
        max-width: min(460px, 50vw);
    }

    .suggest .city,
    .suggest .country { white-space: nowrap; }
}

@media (min-width: 920px) and (max-width: 1080px) {
    .choice-label { display: none; }
}

@media (min-width: 760px) {
    .sheet { align-items: center; }
    .sheet-card, .sheet-card-wide {
        border-radius: 22px;
        margin: 24px;
        animation: sheet-pop 160ms ease-out;
    }
    .months { grid-template-columns: 1fr 1fr; }
}

.date-sheet-panel {
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    max-height: min(92dvh, 92vh, 760px);
    min-height: 0;
    background: var(--bg);
}

#date-sheet .sheet-card-wide {
    width: 100%;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 22px 22px 0 0;
    padding-bottom: 16px;
    background: var(--card);
}

#date-sheet .months { grid-template-columns: 1fr; }

#date-sheet .month-head {
    display: flex;
    justify-content: center;
}

#date-sheet .date-sheet-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 5;
    margin: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--card);
    box-shadow: 0 8px 28px rgba(215, 30, 0, 0.14);
}

#date-sheet .date-sheet-bar .text-button,
#date-sheet .date-sheet-bar .done {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    max-width: 200px;
    min-height: 48px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

#date-sheet .date-sheet-bar .text-button {
    background: var(--field);
    color: var(--blue);
    border: 1px solid var(--line);
}

#date-sheet .date-sheet-bar .done {
    background: var(--blue);
    color: #fff;
    border: 1px solid transparent;
    box-shadow: 0 6px 16px rgba(215, 30, 0, 0.22);
}

#date-sheet .date-sheet-bar .text-button:active,
#date-sheet .date-sheet-bar .done:active { transform: scale(0.98); }

#date-sheet .date-sheet-bar .done:active { background: var(--blue-press); }

@media (hover: hover) and (pointer: fine) {
    #date-sheet .date-sheet-bar .text-button:hover {
        background: var(--soft);
        border-color: rgba(215, 30, 0, 0.22);
    }
    #date-sheet .date-sheet-bar .done:hover { background: var(--blue-press); }
}

@media (max-width: 759px) {
    #date-sheet {
        align-items: stretch;
        justify-content: flex-end;
        padding-top: max(8px, env(safe-area-inset-top, 0px));
    }
    #date-sheet .date-sheet-panel {
        width: 100%;
        max-height: calc(100dvh - max(8px, env(safe-area-inset-top, 0px)));
    }
    #date-sheet .sheet-card-wide {
        border-radius: 18px 18px 0 0;
        margin: 0;
        max-height: none;
        padding-top: 4px;
    }
    #date-sheet .sheet-hint { margin-bottom: 8px; font-size: 13px; }
    #date-sheet .months { gap: 14px; }
    #date-sheet .days button { min-height: 46px; height: 46px; }
    #date-sheet .days button.is-past { min-height: 22px; height: 22px; }
    #date-sheet .day-num { font-size: 14px; }
    #date-sheet .day-price { font-size: 8px; }
    #date-sheet .date-sheet-bar {
        margin: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        padding: 10px;
        gap: 10px;
        border-radius: 18px;
    }
    #date-sheet .date-sheet-bar .text-button,
    #date-sheet .date-sheet-bar .done { max-width: none; min-height: 50px; }
}

@media (min-width: 760px) {
    #date-sheet .date-sheet-panel {
        margin: 24px;
        border-radius: 22px;
        overflow: hidden;
        box-shadow: var(--shadow);
        background: var(--card);
    }
    #date-sheet .sheet-card-wide {
        border-radius: 22px 22px 0 0;
        margin: 0;
        animation: none;
    }
    #date-sheet .date-sheet-bar {
        margin: 0 18px 18px;
        background: var(--field);
        border-color: transparent;
        box-shadow: none;
    }
}

@media (max-width: 520px) {
    .modes { gap: 6px; }
    .mode { padding: 0 12px; font-size: 13px; }
}

.popular-block {
    margin-top: 22px;
}

.popular-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
}

.popular-title {
    margin: 0;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.route-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 4px 6px 6px;
    color: var(--blue);
    font-size: 14px;
    font-weight: 650;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.route-link:hover { opacity: 0.86; }

.route-link-icon {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
    flex: 0 0 auto;
}

.route-link-label { white-space: nowrap; }

@media (prefers-color-scheme: dark) {
    .route-link { color: #9db6ef; }
    .route-link-icon {
        filter: brightness(0) invert(1);
        opacity: 0.92;
    }
}

.populars {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    justify-items: stretch;
    gap: 12px;
    /* Six server-rendered cards reserve their space before the photos arrive. */
    min-height: calc(6 * 240px + 5 * 12px);
}

.popular {
    position: relative;
    display: block;
    width: 100%;
    height: 240px;
    min-height: 240px;
    text-decoration: none;
    padding: 0;
    border: 0;
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
    background: var(--blue);
    color: #fff;
    text-align: left;
    box-shadow: var(--shadow);
    -webkit-appearance: none;
    appearance: none;
}

a.popular,
a.popular:hover,
a.popular:visited {
    color: #fff;
    text-decoration: none;
}

.popular img,
.popular-letter,
.popular-copy {
    pointer-events: none;
}

.popular img,
.popular-letter {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.popular img {
    object-fit: cover;
}

.popular-letter {
    display: grid;
    place-items: center;
    font-size: 42px;
    font-weight: 750;
}

.popular-copy {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 36px 14px 12px;
    background: linear-gradient(transparent, rgba(13, 20, 34, 0.78));
}

.popular-name {
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.popular-country {
    font-size: 13px;
    opacity: 0.9;
}

.popular:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
}

@media (min-width: 920px) {
    .populars {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        min-height: calc(2 * 210px + 12px);
    }
    .popular { height: 210px; min-height: 210px; }
}

@keyframes suggest-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes sheet-pop {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.story {
    margin-top: 28px;
}

.story h1,
.story h2 {
    margin: 22px 0 8px;
    font-size: clamp(22px, 2.4vw, 28px);
    letter-spacing: -0.03em;
}

.story h1 { margin-top: 0; }

.story p {
    margin: 0 0 12px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
}

.story p a {
    color: var(--blue);
    font-weight: 700;
}

.store-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 8px;
}

.store-row a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    font-weight: 750;
}

.site-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-links a {
    color: var(--blue);
    font-weight: 750;
    text-decoration: none;
}

.site-links a:hover { text-decoration: underline; text-underline-offset: 3px; }

.feature-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.feature-list article {
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 14px 16px;
}

.feature-list h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.feature-list p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

@media (min-width: 920px) {
    .feature-list { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .suggest, .sheet-card, .swap { animation: none; transition: none; }
}
