@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');

:root {
    --bg-top: #f2efe9;
    --bg-bottom: #dbe9e2;
    --card: #fffdf8;
    --ink: #122126;
    --muted: #4b6066;
    --line: #d6e2df;
    --line-strong: #baccca;
    --accent: #0f766e;
    --accent-soft: #d6f0eb;
    --shadow: 0 20px 45px rgba(18, 33, 38, 0.14);
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: "Sora", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 12%, rgba(15, 118, 110, 0.2) 0, rgba(15, 118, 110, 0) 35%),
        radial-gradient(circle at 85% 90%, rgba(218, 119, 43, 0.15) 0, rgba(218, 119, 43, 0) 38%),
        linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    padding: 28px 16px;
}

.app-shell {
    width: min(1080px, 100%);
    margin: 0 auto;
}

.panel {
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.95) 0%, rgba(255, 253, 248, 0.88) 100%);
    border: 1px solid rgba(186, 204, 202, 0.6);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    backdrop-filter: blur(4px);
    animation: panel-rise 500ms ease-out;
}

.panel-header {
    padding: 28px 28px 18px;
    text-align: left;
}

.header-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.header-copy {
    min-width: 0;
    flex: 1;
}

.eyebrow {
    margin: 0;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-weight: 600;
}

#stop-title {
    margin: 8px 0 0;
    font-family: "Fraunces", Georgia, serif;
    font-size: clamp(1.45rem, 2.2vw, 2rem);
    line-height: 1.25;
    color: var(--ink);
}

.map-toggle {
    margin-top: 12px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 6px 11px;
    cursor: pointer;
    transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.map-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.map-toggle[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.stop-selector {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.stop-selector.is-visible {
    display: flex;
}

.stop-chip {
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 140ms ease;
}

.stop-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.stop-chip.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.mini-map-card {
    width: min(250px, 46%);
    flex-shrink: 0;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    padding: 10px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(235, 248, 244, 0.9));
}

.mini-map-card.is-hidden {
    display: none;
}

.mini-map-label {
    margin: 0;
    font-size: 0.68rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}

.mini-map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.mini-map-stage {
    position: relative;
}

.map-style-selector {
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--muted);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 6px;
    max-width: 108px;
}

.mini-map {
    position: relative;
    width: 100%;
    aspect-ratio: 1.4 / 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(186, 204, 202, 0.8);
    background:
        linear-gradient(45deg, rgba(255, 255, 255, 0.8) 25%, rgba(220, 238, 233, 0.8) 25%, rgba(220, 238, 233, 0.8) 50%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0.8) 75%, rgba(220, 238, 233, 0.8) 75%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(226, 244, 239, 0.85));
    background-size: 20px 20px, 100% 100%;
}

.map-attribution-toggle {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 16px;
    height: 16px;
    border: 1px solid rgba(18, 33, 38, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.5rem;
    font-weight: 700;
    line-height: 1;
    z-index: 1200;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(18, 33, 38, 0.12);
}

.map-attribution-toggle:hover {
    background: #ffffff;
    border-color: var(--accent);
    color: var(--accent);
}

.map-attribution-toggle[aria-expanded="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.map-attribution-panel {
    position: absolute;
    right: 10px;
    bottom: 34px;
    max-width: min(130px, calc(100% - 20px));
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid rgba(18, 33, 38, 0.14);
    background: rgba(255, 255, 255, 0.96);
    color: var(--muted);
    font-size: 0.46rem;
    line-height: 1.1;
    box-shadow: 0 4px 10px rgba(18, 33, 38, 0.14);
    backdrop-filter: blur(4px);
    z-index: 1200;
    overflow: hidden;
    white-space: normal;
}

.mini-map .leaflet-control-attribution {
    font-size: 0.52rem;
}

.mini-map .leaflet-control-zoom a {
    width: 24px;
    height: 24px;
    line-height: 24px;
}

.mini-map .leaflet-container {
    background: #dde7e4;
}

.mini-map-empty {
    margin: 0;
    display: grid;
    place-items: center;
    height: 100%;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.map-stop-dot {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: none;
    background: rgba(18, 33, 38, 0.6);
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.map-stop-dot:hover {
    transform: translate(-50%, -50%) scale(1.35);
    background: #24414b;
}

.map-stop-dot.is-nearest {
    background: #da772b;
}

.map-stop-dot.is-active {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.25);
    transform: translate(-50%, -50%) scale(1.45);
}

.table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    text-align: left;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    background: #f5faf8;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}

tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}

tbody tr {
    background: transparent;
    transition: background-color 150ms ease;
    animation: row-fade 360ms ease both;
}

tbody tr:hover {
    background: rgba(15, 118, 110, 0.05);
}

tbody td:first-child {
    font-weight: 700;
    color: var(--accent);
}

tbody td:last-child {
    font-weight: 600;
}

tbody tr:last-child td {
    border-bottom: none;
}

@keyframes panel-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes row-fade {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 720px) {
    body {
        padding: 14px;
    }

    .panel {
        border-radius: 18px;
    }

    .panel-header {
        padding: 20px 16px 14px;
    }

    .header-main {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(126px, 38%);
        gap: 10px;
        align-items: start;
    }

    .header-main:has(.mini-map-card.is-hidden) {
        grid-template-columns: minmax(0, 1fr);
    }

    .mini-map-card {
        width: 100%;
        padding: 9px;
    }

    .mini-map {
        aspect-ratio: 1.18 / 1;
    }

    .mini-map-toolbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .map-style-selector {
        max-width: 100%;
        width: 100%;
    }

    .map-attribution-toggle {
        right: 8px;
        bottom: 8px;
    }

    .map-attribution-panel {
        right: 8px;
        bottom: 30px;
        max-width: min(124px, calc(100% - 16px));
    }

    #stop-title {
        font-size: 1.28rem;
    }

    .stop-selector {
        margin-top: 12px;
        gap: 6px;
    }

    .stop-chip {
        font-size: 0.78rem;
        padding: 6px 10px;
    }

    .table-wrap {
        overflow-x: visible;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    tbody {
        display: block;
        padding: 8px 10px 12px;
    }

    tbody tr {
        display: block;
        background: #ffffff;
        border: 1px solid var(--line);
        border-radius: 14px;
        margin-bottom: 10px;
        padding: 8px 10px;
    }

    tbody tr:last-child {
        margin-bottom: 0;
    }

    tbody td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 10px;
        padding: 7px 2px;
        border-bottom: 1px dashed var(--line);
        font-size: 0.86rem;
        text-align: right;
    }

    tbody td::before {
        content: attr(data-label);
        font-size: 0.73rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: var(--muted);
        text-align: left;
        white-space: nowrap;
    }

    tbody td[colspan] {
        display: block;
        text-align: center;
        border-bottom: 0;
        padding: 10px 6px;
    }

    tbody td[colspan]::before {
        content: none;
    }
}
