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

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f5f5f5;
        --muted: #a3a3a3;
        --line: rgba(255, 255, 255, 0.14);
        --field: #333333;
        --bg: #202020;
        --card: #2a2a2a;
        --soft: #333333;
        --price: #D71E00;
        --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; }
}

.page-title {
    margin: 0 0 16px;
    text-align: center;
    font-size: clamp(20px, 2.4vw, 26px);
    font-weight: 750;
    letter-spacing: -0.02em;
}

.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%; }

.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, .origin-field .row { cursor: pointer; border-radius: 18px; }
.choice:hover, .row:focus-within { background: var(--field); }

.icon {
    width: 28px;
    height: 28px;
    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 8px 8px 0;
    cursor: pointer;
    text-overflow: ellipsis;
}

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

.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; flex: 1 1 auto; }
.choice-label { color: var(--muted); font-size: 12px; }
.choice-value {
    font-size: 16px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.sorts {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

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

.sort-group {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.sort-split {
    width: 1px;
    height: 18px;
    flex: 0 0 auto;
    margin: 0 -4.5px;
    background: var(--line);
}

.sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    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;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(28, 36, 52, 0.04);
}

.sort-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
}

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

.kicker {
    margin: 2px 4px 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.kicker[hidden] { display: none; }

.status {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 8px 4px 0;
    color: var(--muted);
    font-size: 15px;
    text-align: center;
}

.status[hidden] { display: none; }
.status.is-error { color: var(--danger); }

.retry {
    display: inline-flex;
    margin-top: 10px;
    border: 0;
    background: var(--blue);
    color: #fff;
    border-radius: 999px;
    min-height: 36px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
}

.places {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.month-block {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
}

.month-block > .kicker { margin: 6px 4px 0; }

.month-block + .month-block > .kicker { margin-top: 16px; }

.month-note {
    margin: 0 4px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.4;
}

.place {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: clamp(10px, 1.4vw, 16px);
    text-decoration: none;
    color: inherit;
    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);
}

.place:hover { background: var(--field); }
.place:hover .place-go { background: var(--blue-press); }

.place-photo {
    width: clamp(72px, 9vw, 104px);
    height: clamp(72px, 9vw, 104px);
    flex: 0 0 auto;
    border-radius: 14px;
    object-fit: cover;
    background: var(--soft);
    display: block;
}

.place-photo-fallback {
    display: grid;
    place-items: center;
    color: var(--blue);
    font-size: clamp(22px, 2vw, 28px);
    font-weight: 750;
}

.place-body { min-width: 0; flex: 1 1 auto; }

.place-title {
    font-size: clamp(15px, 0.4vw + 13px, 18px);
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-country { color: var(--muted); font-weight: 500; }

.place-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.place-price {
    color: var(--price);
    font-size: clamp(20px, 0.7vw + 16px, 26px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.place-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-top: 4px;
    min-width: 0;
    color: var(--muted);
    font-size: clamp(13px, 0.25vw + 12px, 14px);
}

.place-leg {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
    line-height: 1.2;
}

.leg-icon {
    width: 1cap;
    height: 1cap;
    flex: 0 0 auto;
    display: block;
}

.place-leg span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.place-go {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    align-self: center;
    background: var(--blue);
    color: #fff;
    border-radius: 999px;
    min-height: clamp(34px, 3vw, 40px);
    min-width: clamp(84px, 8vw, 104px);
    padding: 0 clamp(14px, 1.4vw, 18px);
    font-size: clamp(14px, 0.25vw + 13px, 15px);
    font-weight: 700;
    line-height: 1;
    text-align: center;
}

.place:focus-visible,
.choice:focus-visible,
.mode:focus-visible,
.sort:focus-visible,
.month-option:focus-visible,
.sheet button:focus-visible,
.suggest button:focus-visible,
.retry:focus-visible {
    outline: 3px solid rgba(215, 30, 0, 0.35);
    outline-offset: 2px;
}

.sk {
    height: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--field), var(--soft), var(--field));
    background-size: 200% 100%;
    animation: shimmer 1.1s ease-in-out infinite;
}

.sk-photo { width: clamp(72px, 9vw, 104px); height: clamp(72px, 9vw, 104px); border-radius: 14px; }
.sk-line { width: 46%; margin-bottom: 10px; }
.sk-price { width: 28%; height: 22px; }

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

.backdrop[hidden], .sheet[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-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-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-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

.done {
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.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: 0;
    border-radius: 50%;
    background: var(--field);
    color: var(--blue);
    font-size: 22px;
    cursor: pointer;
}

.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; }

.month-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.month-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 64px;
    padding: 10px 12px;
    border: 0;
    border-radius: 14px;
    background: var(--field);
    text-align: left;
    cursor: pointer;
}

.month-option-name { font-weight: 750; font-size: 16px; }
.month-option-year { color: var(--muted); font-size: 13px; }
.month-option.is-on { background: var(--blue); color: #fff; }
.month-option.is-on .month-option-year { color: rgba(255, 255, 255, 0.82); }
.month-option:hover:not(.is-on) { background: var(--soft); }

@media (max-width: 919px) {
    .field:focus-within { z-index: auto; }
    .suggest {
        position: fixed;
        z-index: 40;
        left: 16px;
        right: 16px;
        border-radius: 18px;
    }
}

@media (max-width: 520px) {
    .modes, .sorts { gap: 6px; }
    .mode { padding: 0 12px; font-size: 13px; }
    .sort-group { gap: 6px; }
    .sort-split { margin: 0 -3.5px; }
    .sort { padding: 0 12px; font-size: 13px; }
}

@media (min-width: 760px) {
    .sheet { align-items: center; }
    .sheet-card {
        border-radius: 22px;
        margin: 24px;
        animation: sheet-pop 160ms ease-out;
    }
}

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

    .origin-field { flex: 2.2 1 0; }
    .when { flex: 1.15 1 0; }
    .who { flex: 1.05 1 0; }

    .origin-field .row,
    .choice {
        border-radius: 18px;
        min-height: clamp(52px, 4.4vw, 64px);
        height: 100%;
    }

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

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

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

    .month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

@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; }
}

@keyframes shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

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