:root {
    color-scheme: dark;
    --background: #080808;
    --surface: #111111;
    --text: #f1f1ed;
    --muted: #888884;
    --line: #292927;
    --accent: #c7ff48;
    --error: #ff6b61;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--background); }

body {
    min-width: 320px;
    margin: 0;
    background: var(--background);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

.page-shell {
    --hero-top: max(26px, calc(env(safe-area-inset-top) + 16px));
    position: relative;
    width: min(100% - 20px, 1080px);
    min-height: 100vh;
    margin: 0 auto;
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
}

.operator-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    position: absolute;
    top: var(--hero-top);
    right: env(safe-area-inset-right);
    overflow: hidden;
    white-space: nowrap;
}

.operator-links a {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: clamp(10px, 3vw, 12px);
    letter-spacing: -.01em;
    line-height: 1;
    text-decoration: none;
    transition: border-color .15s ease, filter .15s ease, transform .15s ease;
}

.operator-links a:hover {
    filter: none;
}

.operator-links a:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

.operator-sehir-hatlari { border-color: #f2c94c !important; background: #f2c94c; color: #080808 !important; }
.operator-mavi-marmara { border-color: #4d9fff !important; background: #4d9fff; color: #080808 !important; }
.operator-prenstur { border-color: #ff5d5d !important; background: #ff5d5d; color: #080808 !important; }
.operator-turyol { border-color: #53c878 !important; background: #53c878; color: #080808 !important; }

.operator-sehir-hatlari:hover { background: #080808; box-shadow: inset 0 0 0 1px #f2c94c; color: #f2c94c !important; }
.operator-mavi-marmara:hover { background: #080808; box-shadow: inset 0 0 0 1px #4d9fff; color: #4d9fff !important; }
.operator-prenstur:hover { background: #080808; box-shadow: inset 0 0 0 1px #ff5d5d; color: #ff5d5d !important; }
.operator-turyol:hover { background: #080808; box-shadow: inset 0 0 0 1px #53c878; color: #53c878 !important; }

@media (max-width: 680px) {
    .operator-links a {
        min-width: 25px;
        padding: 3px 6px;
        font-size: 0;
        justify-content: center;
    }

    .operator-links a::after {
        font-size: 10px;
        font-weight: 700;
        content: attr(data-short);
    }
}

footer p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .02em;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.sync-status[data-state="ready"] { border-color: #35451a; }

.sync-status[data-state="error"],
.sync-status[data-state="structure_changed"] {
    border-color: #63312d;
    color: #d6a29f;
}

.sync-dot {
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent);
}

.sync-status[data-state="checking"] .sync-dot { animation: pulse 1.2s ease-in-out infinite; }
.sync-status[data-state="error"] .sync-dot,
.sync-status[data-state="structure_changed"] .sync-dot { background: var(--error); }

.hero { padding: var(--hero-top) 0 20px; }

.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .13em;
    text-transform: uppercase;
}

h1, h2 {
    margin: 0;
    font-weight: 400;
    letter-spacing: -.045em;
}

h1 {
    font-size: clamp(40px, 9.5vw, 52px);
    line-height: .88;
}

.title-ship {
    margin-right: .12em;
    color: #ffffff;
    font-size: .78em;
    vertical-align: .08em;
}

.title-version {
    color: var(--muted);
    font-size: .22em;
    letter-spacing: .02em;
    vertical-align: .16em;
}

h2 {
    font-size: clamp(32px, 9vw, 52px);
    line-height: 1;
}

.search-panel {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.route-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
    align-items: end;
}

.field {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 14px 0;
}

.route-fields .field:first-child {
    grid-column: 1;
}

.route-fields .field:last-child {
    grid-column: 3;
    grid-row: 1;
}

.field > span {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.field select, .field input {
    width: 100%;
    min-height: 44px;
    min-width: 0;
    padding: 0 28px 0 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: clamp(19px, 5.5vw, 26px);
    font-weight: 400;
    letter-spacing: -.035em;
}

.field select {
    color-scheme: dark;
}

.date-control {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23c9c9c4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5.5' width='17' height='15' rx='2'/%3E%3Cpath d='M8 3.5v4M16 3.5v4M3.5 10h17'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 3px center;
    background-size: 17px 17px;
    color: #c9c9c4;
    font-size: 14px;
    letter-spacing: 0;
}

.date-control:focus-within {
    outline: 1px solid var(--accent);
    outline-offset: 5px;
}

.date-control > span {
    display: block;
    line-height: 1;
}

.date-control input[type="date"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    color-scheme: dark;
}

.field select option,
.field select optgroup {
    background: #151515;
    color: var(--text);
    font-size: 16px;
}

.field select:focus-visible, .field input:focus-visible, .swap-button:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 5px;
}

.swap-button {
    display: grid;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: end;
    width: 36px;
    height: 36px;
    margin: 0 auto 18px;
    padding: 8px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transform: none;
}

.swap-button:active { border-color: var(--muted); color: var(--text); }

.swap-button svg {
    width: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.date-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    border-top: 1px solid var(--line);
}

.field-compact select, .field-compact input {
    padding-right: 0;
    color: #c9c9c4;
    font-size: 14px;
    letter-spacing: 0;
}

.results { padding: 22px 0 64px; }

.results-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.result-count { margin: 0 0 3px; color: var(--muted); font-size: 12px; }
.table-head { display: none; }

.trip-row {
    --company-color: var(--muted);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px 8px;
    min-height: 92px;
    padding: 11px 0 11px 10px;
    border-left: 3px solid var(--company-color);
    border-bottom: 1px solid var(--line);
}

.company { grid-column: 1 / -1; font-size: 16px; }

.company-sehir-hatlari { --company-color: #f2c94c; }
.company-mavi-marmara { --company-color: #4d9fff; }
.company-prenstur { --company-color: #ff5d5d; }
.company-turyol { --company-color: #53c878; }

.company-name {
    color: var(--company-color);
    font-weight: 500;
}

.company-name::before {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--company-color);
    content: "";
    vertical-align: 1px;
}

.next-label {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #101400;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    vertical-align: 2px;
}

.trip-row.is-past { opacity: .42; }

.company small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.time {
    font-size: clamp(30px, 9vw, 42px);
    font-weight: 400;
    letter-spacing: -.045em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.time::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: .1em;
    text-transform: uppercase;
    content: attr(data-label);
}

.time small { margin-left: 5px; color: var(--accent); font-size: 10px; letter-spacing: 0; }

.estimated {
    margin-right: 3px;
    color: var(--muted);
    font-size: .55em;
    vertical-align: .18em;
}

.empty-state {
    display: grid;
    min-height: 190px;
    padding: 42px 20px;
    place-content: center;
    text-align: center;
}

.empty-state p { margin: 16px 0 0; color: var(--muted); font-size: 14px; }

.loading-line {
    display: block;
    width: 44px;
    height: 1px;
    margin: auto;
    overflow: hidden;
    background: var(--line);
}

.loading-line::after {
    display: block;
    width: 50%;
    height: 100%;
    background: var(--accent);
    content: "";
    animation: loading 1s ease-in-out infinite alternate;
}

footer {
    display: grid;
    gap: 8px;
    padding: 20px 0 max(28px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
}

@keyframes pulse { 50% { opacity: .2; } }
@keyframes loading { to { transform: translateX(100%); } }

@media (min-width: 681px) {
    .page-shell {
        --hero-top: clamp(64px, 9vw, 118px);
        width: min(100% - 40px, 1080px);
    }
    .hero { padding: var(--hero-top) 0 clamp(36px, 6vw, 64px); }
    .route-fields { grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr); align-items: end; }
    .route-fields .field:first-child { grid-column: 1; border-bottom: 0; }
    .route-fields .field:last-child { grid-column: 3; grid-row: 1; }
    .swap-button { grid-column: 2; grid-row: 1; margin: 0 auto 18px; transform: none; }
    .field select { font-size: clamp(26px, 4vw, 42px); }
    #from-pier option,
    #from-pier optgroup,
    #to-pier option,
    #to-pier optgroup { font-size: 13px; }
    .date-fields { gap: 40px; }
    .field-compact select, .field-compact input { font-size: 16px; }
    .date-control { font-size: 16px; }
    .results { padding: clamp(56px, 8vw, 92px) 0; }
    .table-head, .trip-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) 1fr 1fr; gap: 24px; align-items: center; }
    .table-head { padding: 12px 20px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
    .trip-row { min-height: 94px; padding: 18px 20px; border-left-width: 3px; transition: background .15s ease; }
    .trip-row:hover { background: var(--surface); }
    .company { grid-column: auto; }
    .time::before { display: none; }
    footer { display: flex; justify-content: space-between; gap: 24px; }
}

@media (min-width: 1024px) {
    .page-shell {
        --hero-top: 40px;
        width: min(100% - 64px, 1360px);
    }

    main {
        display: grid;
        grid-template-columns: minmax(260px, .72fr) minmax(620px, 1.8fr);
        column-gap: clamp(48px, 6vw, 96px);
        align-items: end;
    }

    .hero { padding: var(--hero-top) 0 22px; }

    h1 {
        font-size: clamp(50px, 4.8vw, 70px);
        line-height: .88;
    }

    .search-panel {
        padding-top: 24px;
        border-top: 0;
    }

    .field {
        gap: 8px;
        padding: 12px 0;
    }

    .field select { font-size: clamp(25px, 2.3vw, 34px); }

    .field-compact select,
    .field-compact input {
        min-height: 34px;
        font-size: 14px;
    }

    .date-control {
        min-height: 34px;
        font-size: 14px;
    }

    .swap-button {
        width: 38px;
        height: 38px;
        margin-bottom: 16px;
        padding: 9px;
    }

    .results {
        grid-column: 1 / -1;
        padding: 26px 0 48px;
    }

    .results-heading { margin-bottom: 16px; }
    h2 { font-size: clamp(32px, 3.7vw, 48px); }

    .table-head,
    .trip-row {
        grid-template-columns: minmax(250px, 1.7fr) minmax(120px, .55fr) minmax(120px, .55fr);
        gap: 20px;
    }

    .table-head { padding: 9px 16px; }

    .trip-row {
        min-height: 56px;
        padding: 8px 16px;
    }

    .company { font-size: 15px; }

    .company small {
        display: inline;
        margin: 0 0 0 10px;
        font-size: 12px;
    }

    .time { font-size: clamp(27px, 2.5vw, 34px); }

    .next-label {
        padding: 2px 5px;
        font-size: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
