@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #f3f7f1;
    --ink: #17372b;
    --primary: #1f4939;
    --accent: #72bb2c;
    --red: #d91525;
    --line: #d8e2d3;
    --card: #ffffff;
    --radius: 16px;
    --shadow: 0 4px 24px rgba(22, 61, 36, 0.06);
    --header-height: 64px;
    --nav-height: 72px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 Outfit, Arial, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Typography */
h1 { font-size: 32px; margin: 0 0 8px; font-weight: 700; line-height: 1.1; letter-spacing: -0.5px; }
h2 { font-size: 22px; margin: 0 0 12px; font-weight: 600; line-height: 1.2; }
.muted { color: #587164; }
.small { font-size: 14px; }
.bigtime { font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 1; display: flex; align-items: center; gap: 8px; }

/* Layout */
.top {
    background: var(--primary);
    color: #fff;
    padding: 0 max(16px, calc((100% - 920px) / 2));
    display: flex;
    align-items: center;
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.brand {
    color: #fff;
    text-decoration: none;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

.brand strong { font-weight: 600; }

.top nav { display: flex; gap: 8px; }

.top nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.top nav a svg { width: 18px; height: 18px; }
.top nav a.active { background: rgba(255,255,255,0.15); color: #fff; }
.top nav a:hover, .top nav a:focus { background: rgba(255,255,255,0.2); color: #fff; }

.wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: 32px 16px 40px;
    min-height: calc(100vh - var(--header-height));
}

.hero { margin-bottom: 24px; }

/* Cards & Containers */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin: 16px 0;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Forms & Inputs */
.field { display: flex; flex-direction: column; gap: 8px; }
label { font-weight: 600; font-size: 15px; color: var(--primary); }

input, select, textarea {
    font: inherit;
    font-size: 16px; /* Prevents iOS zoom */
    padding: 12px 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 73, 57, 0.15);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%231f4939' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

input[type="checkbox"] {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    appearance: auto;
    accent-color: var(--primary);
    cursor: pointer;
    flex: 0 0 auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* Buttons */
button, .button {
    font: inherit;
    font-weight: 600;
    font-size: 16px;
    border: 0;
    border-radius: 12px;
    padding: 14px 20px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.1s, filter 0.2s;
    min-height: 48px;
}

button:active, .button:active { transform: scale(0.98); }
button:hover, .button:hover { filter: brightness(1.1); }

button.secondary, .button.secondary {
    background: #e4efe9;
    color: var(--primary);
}
button.secondary:hover, .button.secondary:hover {
    background: #d1e2d8;
}
button:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.wide { width: 100%; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.actions > * { flex: 1 1 auto; }
.search-panel > button { justify-content: space-between; }
.search-panel > form { margin-top: 16px; }
.panel-chevron { transition: transform 0.2s ease; }
[aria-expanded="true"] .panel-chevron { transform: rotate(180deg); }

/* Alerts */
.error, .notice {
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}
.error { background: #ffe9eb; color: #b71322; border: 1px solid #ffc9cd; }
.notice { background: #e6f3e6; color: var(--primary); border: 1px solid #c9e6c9; }

/* Journey Results */
.journey { overflow: hidden; padding: 0; display: flex; flex-direction: column; border: none; }
.journey-head {
    background: var(--primary);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.journey-head .small { color: rgba(255,255,255,0.7); display: block; margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; font-size: 12px; }
.badge {
    border-radius: 24px;
    padding: 6px 12px;
    background: #e4efe9;
    color: var(--primary);
    display: inline-block;
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
.journey-head .badge { background: rgba(255,255,255,0.15); color: #fff; font-size: 14px; padding: 8px 14px; }

.legs { padding: 12px 24px 24px; }
.leg {
    padding: 16px 0 0 24px;
    position: relative;
}
.leg::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 24px;
    bottom: -16px;
    width: 2px;
    background: var(--line);
}
.leg:last-child::before { display: none; }
.leg::after {
    content: '';
    position: absolute;
    left: 0;
    top: 22px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mode-color, var(--primary));
    box-shadow: 0 0 0 4px var(--card);
}
.leg-bus { --mode-color: #2f7d4a; --mode-soft: #e4f3e8; }
.leg-train { --mode-color: #bd3d4b; --mode-soft: #fbe8eb; }
.leg-walk { --mode-color: #6b7280; --mode-soft: #eef1f0; }
.line-badge, .mode-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--mode-soft, #e4efe9);
    color: var(--mode-color, var(--primary));
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    vertical-align: middle;
    white-space: nowrap;
}
.transport-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.mode-label { margin-left: 0; font-weight: 600; }

.leg b { display: flex; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 6px; color: var(--ink); }
.leg-path { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.leg .muted { margin-top: 4px; font-size: 14px; }

/* Timeline */
.timeline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0 24px;
    background: var(--card);
    padding: 8px;
    border-radius: 100px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.timeline button { padding: 10px 16px; min-height: 40px; border-radius: 100px; font-size: 15px; }
.timeline b { font-size: 15px; }

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0; }
.table-wrap h2 { padding: 24px 24px 0; }
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { padding: 14px 24px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { font-weight: 600; color: var(--muted); background: #fafcf9; }
.table td.actions { display: flex; gap: 8px; }
.table button, .table .button { padding: 8px 12px; min-height: 36px; font-size: 14px; border-radius: 8px; }

.hidden { display: none; }

footer {
    text-align: center;
    color: #587164;
    font-size: 14px;
    padding: 24px;
}
footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* Mobile Optimizations */
@media (max-width: 640px) {
    .grid { grid-template-columns: 1fr; gap: 12px; }
    .wrap { padding: 20px 12px 32px; }
    
    .top { justify-content: center; position: relative; z-index: auto; height: 60px; }
    .brand { margin: 0 auto; font-size: 18px; }
    
    /* Bottom Navigation */
    .top nav {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: #ffffff;
        border-top: 1px solid var(--line);
        display: flex;
        justify-content: space-around;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        z-index: 1000;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
        height: auto;
    }
    .top nav a {
        flex-direction: column;
        gap: 4px;
        font-size: 11px;
        font-weight: 600;
        color: #587164;
        padding: 8px;
        background: transparent !important;
        flex: 1;
    }
    .top nav a svg { width: 22px; height: 22px; margin-bottom: 2px; opacity: 0.8; }
    .top nav a.active { color: var(--primary); }
    .top nav a.active svg { stroke-width: 2.5; opacity: 1; }
    
    footer { margin-bottom: var(--nav-height); }
    
    .journey-head { padding: 16px; align-items: flex-start; flex-direction: column; gap: 12px; }
    .bigtime { font-size: 28px; }
    .legs { padding: 8px 16px 20px; }
    
    .card { padding: 16px; border-radius: 16px; margin: 12px 0; }
    .table th, .table td { padding: 12px 16px; }
    
    .timeline { padding: 8px; flex-wrap: wrap; justify-content: center; gap: 12px; border-radius: 16px; }
    .timeline b { width: 100%; text-align: center; order: -1; }
    .timeline button { flex: 1; }

    /* Compact timeline for fast, experienced mobile users */
    .page-timeline .wrap { padding: 14px 10px 20px; }
    .page-timeline h1 { font-size: 26px; margin-bottom: 3px; }
    .page-timeline h1 + .muted { margin: 0 0 8px; font-size: 14px; }
    .page-timeline .timeline {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 6px;
        margin: 8px 0 12px;
        padding: 5px;
        border-radius: 12px;
    }
    .page-timeline .timeline b {
        width: auto;
        order: 0;
        flex: 0 0 auto;
        font-size: 12px;
        white-space: nowrap;
    }
    .page-timeline .timeline button {
        flex: 0 1 auto;
        min-height: 34px;
        padding: 6px 9px;
        border-radius: 9px;
        font-size: 12px;
        gap: 3px;
    }
    .page-timeline .timeline button svg { width: 15px; height: 15px; }
    .page-timeline .journey-head {
        padding: 12px 14px;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .page-timeline .journey-head .small { margin-bottom: 3px; font-size: 10px; }
    .page-timeline .journey-head .badge { padding: 6px 9px; font-size: 11px; }
    .page-timeline .bigtime { font-size: 25px; gap: 5px; }
    .page-timeline .legs { padding: 3px 12px 12px; }
    .page-timeline .leg { padding: 9px 0 0 20px; }
    .page-timeline .leg::before { left: 3px; top: 17px; bottom: -9px; }
    .page-timeline .leg::after { top: 15px; }
    .page-timeline .leg b { gap: 5px; margin-bottom: 2px; font-size: 15px; }
    .page-timeline .leg-path { gap: 0; font-size: 13px; line-height: 1.3; }
    .page-timeline .leg .muted { margin-top: 2px; font-size: 12px; line-height: 1.25; }
    .page-timeline .line-badge,
    .page-timeline .mode-label { margin-left: 4px; padding: 3px 6px; font-size: 10px; }
    .page-timeline .transport-icon { width: 13px; height: 13px; }
    .page-timeline #timeline-container + .card { margin-top: 12px !important; }
    .page-timeline #timeline-container + .card .wide { min-height: 40px; padding: 9px 12px; font-size: 14px; }
}
