*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0a0a0f;
    --surface:   #111118;
    --surface2:  #1a1a24;
    --border:    rgba(255,255,255,0.07);
    --accent:    #5b8fff;
    --accent2:   #ff6b6b;
    --green:     #3ddc84;
    --amber:     #ffb340;
    --text:      #f0f0f5;
    --muted:     #6b6b80;
    --card-h:    140px;
    --sheet-min: 100px;
    --sheet-mid: 52vh;
    --sheet-max: 88vh;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(text);
    font-family: 'Syne', sans-serif;
    -webkit-tap-highlight-color: transparent;
}
/* ── MAP ───────────────────────────────────────────── */
#map {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}

/* ── TOP BAR ───────────────────────────────────────── */
#topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    background: linear-gradient(to bottom, rgba(10,10,15,0.95) 70%, transparent);
    backdrop-filter: blur(0px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}

.logo-text {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
}

.logo-text span { color: var(--accent); }

#live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(61,220,132,0.1);
    border: 1px solid rgba(61,220,132,0.2);
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    font-family: 'DM Mono', monospace;
}

.live-dot {
    width: 6px; height: 6px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

/* ── BOTTOM SHEET ──────────────────────────────────── */
#sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: var(--sheet-max);
    display: flex;
    flex-direction: column;
    will-change: transform;
}

#sheet.snap-min  { transform: translateY(calc(100% - var(--sheet-min))); }
#sheet.snap-mid  { transform: translateY(calc(100% - var(--sheet-mid))); }
#sheet.snap-custom { transform: translateY(200px); }
#sheet.snap-full { transform: translateY(0); }

/* ── SHEET HANDLE ──────────────────────────────────── */
#sheet-handle {
    flex-shrink: 0;
    padding: 12px 16px 8px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

#sheet-handle:active { cursor: grabbing; }

.handle-bar {
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin: 0 auto 10px;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sheet-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.show-all-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}

.show-all-row input[type=checkbox] {
    width: 14px; height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── SHEET CONTENT ─────────────────────────────────── */
#sheet-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0 12px 12px;
}

#sheet-content::-webkit-scrollbar { display: none; }

/* ── LOCATION SECTION ──────────────────────────────── */
#location-section {
    background: var(--surface2);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.loc-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 8px;
}

#location-display {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

#location-display.set {
    color: var(--green);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
}

#calc-btn {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'Syne', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

#calc-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#calc-btn:not(:disabled):active {
    transform: scale(0.97);
    opacity: 0.85;
}

/* ── BUS LIST ──────────────────────────────────────── */
#bus-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.empty-state .emoji { font-size: 32px; display: block; margin-bottom: 10px; }

/* ── BUS CARD ──────────────────────────────────────── */
.bus-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.bus-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 3px 0 0 3px;
}

.bus-card.passed::before { background: var(--amber); }
.bus-card.passed { opacity: 0.65; }
.bus-card.active-card { border-color: var(--accent); }
.bus-card:active { transform: scale(0.98); }

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.bus-name {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-pill {
    font-size: 9px;
    font-weight: 700;
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}

.status-pill.moving {
    background: rgba(61,220,132,0.12);
    color: var(--green);
    border: 1px solid rgba(61,220,132,0.2);
}

.status-pill.idle {
    background: rgba(255,179,64,0.12);
    color: var(--amber);
    border: 1px solid rgba(255,179,64,0.2);
}

.card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.stat {
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 8px 10px;
}

.stat-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 3px;
}

.stat-value {
    font-size: 13px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    color: var(--text);
}

.eta-row {
    font-size: 12px;
    font-weight: 600;
    color: var(--green);
    font-family: 'DM Mono', monospace;
    margin-bottom: 10px;
    min-height: 18px;
}

.eta-row.loading { color: var(--muted); }
.eta-row.passed-note {
    color: var(--amber);
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 11px;
}

.route-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'Syne', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.route-btn.active {
    background: rgba(91,143,255,0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.route-btn:active { opacity: 0.7; }

/* ── PASSED DIVIDER ────────────────────────────────── */
.passed-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--amber);
}

.passed-divider::before, .passed-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,179,64,0.2);
}

/* ── ROUTE INFO BAR ────────────────────────────────── */
#route-bar {
    position: fixed;
    bottom: calc(var(--sheet-min) + 10px);
    left: 12px; right: 12px;
    z-index: 150;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s, opacity 0.3s;
}

#route-bar.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.route-bar-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}

.route-bus-tag {
    background: rgba(91,143,255,0.15);
    color: var(--accent);
    border-radius: 6px;
    padding: 3px 8px;
    font-weight: 700;
    font-size: 11px;
}

#route-bar-hide {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 8px;
    padding: 5px 10px;
    font-family: 'Syne', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ── TOAST ─────────────────────────────────────────── */
#toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 9px 18px;
    font-size: 12px;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    max-width: 90vw;
    white-space: normal;
    text-align: center;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.info    { border-color: rgba(91,143,255,0.3);  color: var(--accent); }
#toast.warning { border-color: rgba(255,179,64,0.3);  color: var(--amber); }
#toast.error   { border-color: rgba(255,107,107,0.3); color: var(--accent2); }

/* ── GOOGLE MAPS OVERRIDES ─────────────────────────── */
.gm-style .gm-style-iw-c {
    background: var(--surface) !important;
    border-radius: 12px !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
    border: 1px solid var(--border) !important;
    max-width: 200px !important;
}
.gm-style .gm-style-iw-d { overflow: hidden !important; max-width: 200px !important; }
.gm-style .gm-style-iw-t::after { display: none !important; }
.gm-ui-hover-effect { top: 4px !important; right: 4px !important; }
.gm-ui-hover-effect img { filter: invert(1) !important; }

/* ── DESKTOP LAYOUT ────────────────────────────────── */
@media (min-width: 768px) {
    #sheet {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 340px;
        border-radius: 0;
        border-right: 1px solid var(--border);
        border-top: none;
        transform: none !important;
        max-height: 100%;
    }

    #sheet-handle { display: none; }

    #map { left: 340px; width: calc(100% - 340px); }

    #topbar {
        left: 340px;
        background: linear-gradient(to bottom, rgba(10,10,15,0.9) 60%, transparent);
    }

    #route-bar {
        left: 352px;
        bottom: 20px;
        right: 20px;
    }
}


