:root {
    --bg: #0b1220;
    --bg-elevated: #141d30;
    --card: #1a2438;
    --card-border: #263149;
    --text: #f4f6fb;
    --text-dim: #93a0bd;
    --accent: #3b82f6;
    --green: #34d399;
    --orange: #f59e0b;
    --red: #f87171;
    --radius: 18px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    padding-top: env(safe-area-inset-top);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 8px;
}

.topbar h1 {
    font-size: 23px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.2px;
}

.refresh-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    color: var(--text-dim);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.4s ease, color 0.2s ease;
}

.refresh-btn:active { transform: scale(0.9); }
.refresh-btn.spinning svg { animation: spin 0.7s linear; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px 4px;
}

.tab {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 700;
    padding: 15px 8px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab .arrow { opacity: 0.6; margin: 0 2px; }

.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

main {
    padding: 12px 16px 8px;
}

.departure-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.departure-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    animation: fadeIn 0.3s ease;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.departure-card:active {
    background: var(--bg-elevated);
    transform: scale(0.98);
}

.dep-share {
    flex-shrink: 0;
    align-self: center;
    font-size: 18px;
    opacity: 0.55;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.line-badge {
    flex-shrink: 0;
    min-width: 48px;
    height: 48px;
    padding: 0 6px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
}

.line-badge.long {
    font-size: 15px;
}

.dep-info {
    flex: 1;
    min-width: 0;
}

.dep-destination {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dep-meta {
    font-size: 13.5px;
    color: var(--text-dim);
    margin-top: 3px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.platform-chip {
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 1px 6px;
    font-weight: 600;
    color: var(--text);
}

.dep-time-block {
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

.dep-minutes {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
}

.dep-minutes.imminent { color: var(--green); }
.dep-minutes small { font-size: 13px; font-weight: 700; margin-left: 2px; color: var(--text-dim); }

.dep-clock {
    font-size: 12.5px;
    color: var(--text-dim);
    margin-top: 4px;
}

.status-pill {
    display: inline-block;
    margin-top: 5px;
    font-size: 12.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.status-onTime { color: var(--green); }
.status-delayed { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.status-cancelled { background: rgba(248, 113, 113, 0.15); color: var(--red); text-decoration: line-through; }

.departure-card.cancelled { opacity: 0.55; }

.empty-state, .error-state {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    padding: 40px 20px;
}

.error-state { color: var(--red); }

.skeleton {
    background: linear-gradient(90deg, var(--card) 25%, var(--card-border) 50%, var(--card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius);
    height: 68px;
}

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

.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--card-border);
    padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
