/* ZET Vozni Red - Blue Color Scheme with Dark Mode Support */

:root {
    --primary-blue: #007BFF;
    --primary-dark: #0056B3;
    --primary-darker: #004494;
    --background-light: #E3F2FD;
    --background-white: #FFFFFF;
    --text-dark: #1A237E;
    --text-light: #FFFFFF;
    --row-even: #BBDEFB;
    --row-odd: #E3F2FD;
    --border-color: #90CAF9;
    --shadow-color: rgba(0, 123, 255, 0.2);
    --error-color: #D32F2F;
    --success-color: #1565C0;
    --realtime-bg: linear-gradient(135deg, #EEF5FF 0%, #F7FAFF 100%);
    --realtime-bg-hover: linear-gradient(135deg, #DCEBFF 0%, #ECF4FF 100%);
    --realtime-label-color: #1565C0;
    --subtle-text: #546E7A;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: #D6EAF8;
    --muted-bg: rgba(0, 0, 0, 0.05);
    --muted-text: #616161;
    --timestamp-text: #9E9E9E;
}

[data-theme="dark"] {
    --primary-blue: #5B9FE8;
    --primary-dark: #4A8CD4;
    --primary-darker: #1A2332;
    --background-light: #0F1419;
    --background-white: #161B22;
    --text-dark: #D4D8DD;
    --text-light: #ECEFF1;
    --row-even: #1C2530;
    --row-odd: #161B22;
    --border-color: #2A3544;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --error-color: #F28B82;
    --success-color: #8FBEFF;
    --realtime-bg: linear-gradient(135deg, #182233 0%, #1C2738 100%);
    --realtime-bg-hover: linear-gradient(135deg, #203049 0%, #24354F 100%);
    --realtime-label-color: #8FBEFF;
    --subtle-text: #8B949E;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: #2A3544;
    --muted-bg: rgba(255, 255, 255, 0.06);
    --muted-text: #8B949E;
    --timestamp-text: #6E7681;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--background-light) 0%, var(--background-white) 100%);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    padding: 0.85rem 1rem;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Header Top Row */
.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Theme toggle – lives in footer beside refresh btn */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    min-width: 38px;
    background: #0F6BD8;
    border: none;
    border-radius: 7px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    line-height: 1;
}

.theme-toggle-btn:focus {
    outline: none;
}

.theme-toggle-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.theme-toggle-btn:hover {
    background: #0B5FC2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.theme-toggle-btn:active {
    transform: scale(0.98);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.22);
}

/* Mode Toggle (bus/tram icon) */
.mode-toggle {
    cursor: pointer;
    transition: transform 0.3s ease;
    display: inline-grid;
    place-items: center;
}

.mode-toggle > .mode-icon {
    grid-area: 1 / 1;
    transition: opacity 0.2s ease;
}

.mode-toggle > .mode-icon.hidden {
    display: block !important;
    opacity: 0;
    pointer-events: none;
}

.mode-toggle:hover {
    transform: scale(1.1);
}

.mode-toggle:active {
    transform: scale(0.95);
}

.mode-icon {
    display: block;
    width: 36px;
    height: 36px;
}

header .header-icon {
    line-height: 0;
}

.settings-dial .mode-icon {
    width: 24px;
    height: 24px;
}

/* Main Content */
main {
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Info Bar */
.info-bar {
    display: flex;
    flex-direction: column;
    background: var(--background-white);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    gap: 0;
}

/* Info Bar Top Row: pill + time */
.info-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.5rem;
}

/* Day Type Pill */
.day-type-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.78rem;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: #E8F5E9;
    color: #2E7D32;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: background 0.2s ease, color 0.2s ease;
}

.day-type-pill.day-saturday {
    background: #FFF3E0;
    color: #E65100;
}

.day-type-pill.day-sunday {
    background: #FFEBEE;
    color: #C62828;
}

/* Time Display */
.info-time {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
    opacity: 0.85;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* Divider between info and controls */
.info-bar-divider {
    height: 2px;
    background: var(--border-color);
    margin: 0.75rem 0;
    opacity: 1;
}

/* Info Controls */
.info-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Direction Segmented Control */
/* ── Shared sliding-thumb segmented control ── */
.seg-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: var(--primary-blue);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform;
    z-index: 0;
    pointer-events: none;
}

.seg-thumb.no-transition {
    transition: none;
}

.direction-segmented {
    display: flex;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 0 0 2px var(--primary-blue);
    position: relative;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.dir-seg-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    min-height: 40px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    background: transparent;
    color: var(--primary-blue);
    position: relative;
    z-index: 1;
}

.dir-seg-btn.active {
    color: var(--text-light);
}

.dir-seg-btn:not(.active):hover {
    background: rgba(21, 101, 192, 0.06);
}

.dir-seg-btn:focus {
    outline: none;
}

.dir-seg-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.28);
}

.mid-stop-select-wrap {
    text-align: left;
    width: 100%;
}

/* Bus Line Select */
.bus-line-select-wrap {
    text-align: left;
    width: 100%;
}

.bus-line-select {
    width: 100%;
    padding: 0.55rem 1.85rem 0.55rem 0.75rem;
    min-height: 44px;
    border: 1px solid rgba(144, 202, 249, 0.65);
    border-radius: 10px;
    background: var(--background-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%231565C0' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 0.72rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    color: var(--text-dark);
    font-size: 0.95rem;
    transition: box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.bus-line-select:focus {
    outline: none;
}

.bus-line-select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.22), 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Tram Line Select */
.tram-line-select-wrap {
    text-align: left;
    width: 100%;
}

.tram-line-select {
    width: 100%;
    padding: 0.55rem 1.85rem 0.55rem 0.75rem;
    min-height: 44px;
    border: 1px solid rgba(144, 202, 249, 0.65);
    border-radius: 10px;
    background: var(--background-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%231565C0' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 0.72rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    color: var(--text-dark);
    font-size: 0.95rem;
    transition: box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.tram-line-select:focus {
    outline: none;
}

.tram-line-select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.22), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.mid-stop-select {
    width: 100%;
    padding: 0.55rem 1.85rem 0.55rem 0.75rem;
    min-height: 44px;
    border: 1px solid rgba(144, 202, 249, 0.65);
    border-radius: 10px;
    background: var(--background-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%231565C0' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 0.72rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    color: var(--text-dark);
    font-size: 0.95rem;
    transition: box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.mid-stop-select:focus {
    outline: none;
}

.mid-stop-select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.22), 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Schedule Section */
.schedule-section {
    background: var(--background-white);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    margin-bottom: 1rem;
}

.schedule-section h2 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.schedule-section h2 a {
    color: inherit;
    text-decoration: none;
}

.schedule-section h2 a:hover {
    text-decoration: underline;
}

.schedule-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.schedule-control-group {
    min-width: 0;
}

/* View Toggle - Segmented Control */
.view-toggle-wrap {
    margin-bottom: 0;
}

.view-toggle {
    display: flex;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 0 0 2px var(--primary-blue);
    position: relative;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.view-toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    min-height: 40px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    background: transparent;
    color: var(--primary-blue);
    position: relative;
    z-index: 1;
}

.view-toggle-btn.active {
    color: var(--text-light);
}

.view-toggle-btn:not(.active):hover {
    background: rgba(21, 101, 192, 0.06);
}

.view-toggle-btn:focus {
    outline: none;
}

.view-toggle-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.28);
}


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

/* Loading Indicator */
.loading {
    text-align: center;
    padding: 2rem;
    animation: stateFadeIn 0.2s ease both;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading p {
    color: var(--primary-dark);
    font-size: 0.95rem;
}

/* Error Message */
.error-message {
    text-align: center;
    padding: 2rem;
    color: var(--error-color);
    animation: stateFadeIn 0.2s ease both;
}

.error-message p {
    margin-bottom: 1rem;
}

.retry-btn {
    background: var(--primary-blue);
    color: var(--text-light);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.retry-btn:hover,
.retry-btn:active {
    background: var(--primary-dark);
}

/* No Schedule Message */
.no-schedule {
    text-align: center;
    padding: 2rem;
    color: var(--primary-dark);
    animation: stateFadeIn 0.2s ease both;
}

.next60-container {
    display: grid;
    gap: 0.9rem;
}

.next60-container.content-transitioning {
    opacity: 0;
    transform: translateY(6px);
}

/* Line Badge */
.line-badge {
    display: inline-block;
    background: var(--primary-dark);
    color: var(--text-light);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.line-badge.line-215 {
    background: #1565C0;
}

.line-badge.line-216 {
    background: #0277BD;
}

.line-badge.line-276 {
    background: #00838F;
}

.line-badge.line-badge-large {
    min-width: 82px;
    min-height: 82px;
    padding: 0.2rem 0.35rem;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.3rem;
    line-height: 0.84;
    letter-spacing: -0.07em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #E8F2FF;
    color: var(--primary-blue);
    cursor: default;
}

.next60-item {
    display: grid;
    gap: 0;
}

.next60-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.95rem;
    padding: 0.9rem 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px 12px 0 0;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    box-shadow: 0 18px 30px rgba(0, 68, 148, 0.22);
    cursor: pointer;
}

.next60-card:focus {
    outline: none;
}

.next60-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(144, 202, 249, 0.35), 0 18px 30px rgba(0, 68, 148, 0.22);
}

.next60-content {
    min-width: 0;
    display: grid;
    gap: 0.2rem;
}

.next60-route {
    margin: 0;
    color: var(--text-light);
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.next60-departure-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem;
}

.next60-time {
    font-size: 1.22rem;
    font-weight: 800;
    line-height: 1.1;
}

.next60-relative {
    font-size: 0.95rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.82);
}

.next60-relative.is-past,
.next60-relative.is-soon,
.next60-relative.is-now {
    color: #D7EBFF;
}

.next60-stop {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.25;
}

.next60-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0.2rem;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    flex: none;
}

.next60-arrow:hover {
    color: rgba(255, 255, 255, 0.78);
}

.next60-arrow:active {
    transform: scale(0.96);
}

.next60-arrow:focus {
    outline: none;
}

.next60-arrow:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.next60-arrow-icon {
    width: 1.4rem;
    height: 1.4rem;
    display: block;
    overflow: visible;
}

.next60-arrow-icon path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.next60-realtime-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.72rem 0.95rem 0.82rem;
    border: 1px solid var(--border-color);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: linear-gradient(180deg, rgba(246, 250, 255, 0.98) 0%, rgba(232, 242, 255, 0.98) 100%);
    box-shadow: 0 10px 22px rgba(0, 68, 148, 0.08);
}

.next60-realtime-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    min-width: 0;
}

.next60-realtime-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.next60-realtime-map {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    text-decoration: none;
    color: var(--primary-dark);
    line-height: 0;
    flex: none;
    overflow: visible;
    transition: color 0.2s ease, transform 0.2s ease;
}

.next60-realtime-map-icon {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    overflow: visible;
    flex: none;
}

.next60-realtime-map-icon path,
.next60-realtime-map-icon circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.next60-realtime-map:hover {
    color: #0B5FC2;
}

.next60-realtime-map:active {
    transform: scale(0.96);
}

.full-day-item {
    gap: 0;
}

.full-day-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 0.9rem;
    border-radius: 12px;
    cursor: default;
}

.full-day-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 1.4rem;
    gap: 0.5rem;
}

.full-day-line-wrap {
    align-self: center;
    display: flex;
}

.full-day-header-content {
    gap: 0.28rem;
    min-width: 0;
    align-self: center;
    padding-left: 0.2rem;
}

.full-day-stop {
    margin-top: -0.1rem;
}

.full-day-hour-list {
    display: grid;
    gap: 0.55rem;
    width: 100%;
    padding-top: 0.15rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.full-day-hour-row {
    display: grid;
    grid-template-columns: 2.9rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    padding-top: 0.55rem;
    padding-bottom: 0.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    width: 100%;
}

.full-day-hour-row:first-child {
    padding-top: 0.55rem;
}

.full-day-hour-label {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-light);
}

.full-day-hour-times {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(3.5rem, max-content));
    gap: 0.45rem 0.85rem;
    align-items: start;
    align-content: start;
    grid-auto-rows: minmax(1.2rem, auto);
    min-width: 0;
    width: 100%;
}

.full-day-time {
    display: flex;
    align-items: center;
    min-height: 1.2rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
}

[data-theme="dark"] .next60-card {
    border-color: rgba(143, 190, 255, 0.16);
    background: linear-gradient(135deg, #2B5F9E 0%, #3E7FCA 100%);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.38);
}

[data-theme="dark"] .full-day-card {
    border-color: rgba(155, 199, 255, 0.14);
    background: linear-gradient(135deg, #2B5F9E 0%, #3E7FCA 100%);
    box-shadow: 0 20px 34px rgba(0, 0, 0, 0.34);
}

[data-theme="dark"] .line-badge-large {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .full-day-header-content .next60-route {
    color: #F2F7FD;
}

[data-theme="dark"] .full-day-stop {
    color: rgba(219, 232, 247, 0.72);
}

[data-theme="dark"] .full-day-hour-list {
    background: transparent;
    box-shadow: none;
}

[data-theme="dark"] .full-day-hour-list::before {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(206, 228, 255, 0.14) 8%, rgba(206, 228, 255, 0.14) 92%, rgba(255, 255, 255, 0) 100%);
}

[data-theme="dark"] .full-day-hour-row {
    border-top-color: rgba(218, 232, 250, 0.075);
}

[data-theme="dark"] .full-day-hour-label {
    color: rgba(221, 233, 248, 0.68);
}

[data-theme="dark"] .full-day-time {
    color: rgba(245, 249, 255, 0.94);
}

[data-theme="dark"] .next60-card:focus-visible {
    box-shadow: 0 0 0 3px rgba(143, 190, 255, 0.3), 0 18px 32px rgba(0, 0, 0, 0.38);
}

[data-theme="dark"] .next60-arrow {
    background: transparent;
}

[data-theme="dark"] .next60-arrow:hover {
    color: rgba(236, 239, 241, 0.78);
}

[data-theme="dark"] .next60-realtime-row {
    border-color: #274264;
    background: linear-gradient(180deg, rgba(18, 30, 46, 0.98) 0%, rgba(22, 36, 54, 0.98) 100%);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
}

[data-theme="dark"] .next60-realtime-label,
[data-theme="dark"] .next60-realtime-map {
    color: #A9D1FF;
}

[data-theme="dark"] .next60-realtime-map {
    color: #A9D1FF;
}

/* Realtime Sub-Row Styles */
.realtime-row {
    background: var(--realtime-bg) !important;
}

.realtime-row:hover {
    background: var(--realtime-bg-hover) !important;
}

.realtime-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--realtime-label-color);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.realtime-full-cell {
    padding: 0.5rem 0.5rem !important;
    display: table-cell;
    width: 100%;
    font-size: 0.85rem;
}

.realtime-full-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.realtime-info {
    display: none;
    width: auto;
    height: auto;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1;
    cursor: help;
    padding: 0;
}

.realtime-info-toast {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translate(-50%, 10px);
    max-width: min(92vw, 520px);
    background: rgba(33, 33, 33, 0.94);
    color: #fff;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    line-height: 1.3;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 9999;
}

.realtime-info-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.realtime-delay {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

.delay-ontime {
    background: #DCEBFF;
    color: #0B5FC2;
}

.delay-late {
    background: #FFCDD2;
    color: #C62828;
}

.delay-early {
    background: #DCEBFF;
    color: #0B5FC2;
}

.delay-unknown {
    background: #E0E0E0;
    color: #616161;
}

/* Line Details Panel */
.modal-open {
    overflow: hidden;
}

.line-details-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 37, 63, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.line-details-panel {
    margin-top: 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--row-odd) 0%, var(--background-white) 100%);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    padding: 0.85rem;
    width: min(960px, 96vw);
    max-height: min(94vh, 920px);
    overflow-y: auto;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}

.line-details-overlay.is-open,
.line-details-overlay.is-closing {
    display: flex;
}

.line-details-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.line-details-overlay.is-open .line-details-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.line-details-overlay.is-closing .line-details-panel {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.4, 0, 0.7, 0.2);
}

.line-details-overlay.is-closing {
    opacity: 0;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.line-details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.line-details-heading-wrap h3 {
    color: var(--primary-dark);
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.line-details-subtitle {
    font-size: 0.82rem;
    color: var(--subtle-text);
}

.line-details-close-btn {
    border: 1px solid var(--border-color);
    background: var(--background-white);
    color: var(--primary-dark);
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.line-details-close-btn:hover {
    background: var(--background-light);
}

.line-details-close-btn:active {
    transform: scale(0.96);
}

.line-details-meta {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    padding: 0;
}

.line-details-meta-item {
    display: flex;
    align-items: stretch;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.line-details-meta-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0.4rem 0.5rem;
}

.line-details-refresh-btn {
    border: none;
    border-left: 1px solid var(--border-color);
    background: var(--background-white);
    color: var(--primary-dark);
    font-size: 1rem;
    font-weight: 700;
    padding: 0 0.85rem;
    cursor: pointer;
    outline: none;
    transition: background 0.15s, opacity 0.15s;
}

.line-details-refresh-btn:focus,
.line-details-refresh-btn:focus-visible {
    outline: none;
}

.line-details-refresh-btn:hover {
    background: var(--background-light);
}

.line-details-refresh-btn:disabled {
    cursor: default;
    opacity: 0.5;
}

.line-details-refresh-btn.loading {
    animation: spin 0.8s linear infinite;
}

.line-details-meta-label {
    font-size: 0.68rem;
    color: var(--subtle-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.line-details-meta-value {
    font-size: 0.84rem;
    color: var(--text-dark);
    font-weight: 600;
}

.line-details-empty {
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 0.6rem;
    color: var(--subtle-text);
    background: var(--card-bg);
    margin-bottom: 0.65rem;
}

.line-details-content {
    display: grid;
    gap: 0.65rem;
}

.line-details-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--background-white);
    padding: 0.6rem;
}

.line-details-item-title {
    font-size: 0.9rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.line-details-item-grid {
    display: grid;
    gap: 0.35rem;
}

.line-details-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0;
    border-bottom: 1px dashed var(--card-border);
}

.line-details-field:last-child {
    border-bottom: 0;
}

.line-details-field-label {
    font-size: 0.78rem;
    color: var(--subtle-text);
}

.line-details-field-value {
    font-size: 0.8rem;
    color: var(--text-dark);
    font-weight: 600;
    text-align: right;
}

.realtime-vehicle {
    font-size: 0.75rem;
    color: var(--muted-text);
    padding: 0.15rem 0.4rem;
    background: var(--muted-bg);
    border-radius: 3px;
}

.realtime-timestamp {
    font-size: 0.7rem;
    color: var(--timestamp-text);
    font-style: italic;
}

.realtime-position-link {
    font-size: 0.95rem;
    line-height: 1;
    text-decoration: none;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.realtime-position-link:hover {
    background: rgba(0, 0, 0, 0.08);
}

.line-details-position-link {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s ease;
}

.line-details-position-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Footer */
footer {
    width: min(calc(100% - 2rem), 800px);
    margin: 0 auto 1rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(227, 242, 253, 0.88) 100%);
    color: var(--text-dark);
    padding: 0.85rem 1rem 0.95rem;
    border: 1px solid rgba(144, 202, 249, 0.65);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.2rem;
}

.footer-actions {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    margin-top: 0.5rem;
}

.footer-actions .refresh-btn {
    grid-column: 2;
}

.footer-actions .theme-toggle-btn {
    grid-column: 3;
    justify-self: end;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 38px;
    font-weight: 600;
    color: var(--text-light);
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: 7px;
    font-size: 0.85rem;
    background: #0F6BD8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.refresh-btn:hover {
    background: #0B5FC2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.refresh-btn:active {
    transform: scale(0.98);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.22);
}

.refresh-btn:focus {
    outline: none;
}

.refresh-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.refresh-btn-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.last-updated {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-dark);
    opacity: 0.88;
    margin: 0;
}

.data-source {
    font-size: 0.74rem;
    color: var(--subtle-text);
    opacity: 0.9;
    margin: 0;
}

.data-source a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.data-timestamp {
    font-size: 0.7rem;
    color: var(--subtle-text);
    opacity: 0.82;
    display: block;
    margin-top: 0.25rem;
}

.settings-dial {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.settings-dial-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    pointer-events: none;
}

.settings-toggle-btn,
.settings-dial .settings-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
    border: none;
    border-radius: 999px;
    color: var(--text-light);
    background: #0F6BD8;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
    -webkit-tap-highlight-color: transparent;
}

.settings-toggle-btn {
    width: 3.5rem;
    height: 3.5rem;
}

.settings-toggle-icon {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    transform-origin: center;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-dial .settings-action-btn {
    width: 2.9rem;
    height: 2.9rem;
    min-width: 2.9rem;
    min-height: 2.9rem;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(0.8rem) scale(0.9);
}

.settings-dial.open .settings-dial-actions {
    pointer-events: auto;
}

.settings-dial.open .settings-action-btn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.settings-dial.open .settings-action-btn:nth-child(1) {
    transition-delay: 0.14s;
}

.settings-dial.open .settings-action-btn:nth-child(2) {
    transition-delay: 0.1s;
}

.settings-dial.open .settings-action-btn:nth-child(3) {
    transition-delay: 0.06s;
}

.settings-dial.open .settings-action-btn:nth-child(4) {
    transition-delay: 0.02s;
}

.settings-toggle-btn:hover,
.settings-dial.open .settings-action-btn:hover {
    background: #0B5FC2;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.24);
}

.settings-dial .mode-toggle:hover {
    transform: translateY(0) scale(1);
}

.settings-toggle-btn:active {
    transform: scale(0.96);
}

.settings-dial.open .settings-action-btn:active,
.settings-dial.open .mode-toggle:active {
    transform: translateY(0) scale(0.96);
}

.settings-toggle-btn:focus,
.settings-dial .settings-action-btn:focus {
    outline: none;
}

.settings-toggle-btn:focus-visible,
.settings-dial .settings-action-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(21, 101, 192, 0.28), 0 12px 28px rgba(0, 0, 0, 0.22);
}

.settings-dial.open .settings-toggle-icon {
    transform: rotate(90deg);
}

.settings-dial .theme-icon,
.settings-dial .refresh-btn-icon {
    width: 20px;
    height: 20px;
    display: block;
    flex: none;
    transform-origin: center;
}

.settings-dial .theme-toggle-btn {
    display: inline-grid;
    place-items: center;
}

.settings-dial .theme-toggle-btn > .theme-icon {
    grid-area: 1 / 1;
    transition: opacity 0.2s ease;
}

.settings-dial .theme-toggle-btn > .theme-icon.hidden {
    display: block !important;
    opacity: 0;
    pointer-events: none;
}

.settings-dial .mode-toggle {
    display: inline-grid;
    place-items: center;
}

/* Multi-line secret toggle */
.multi-line-toggle .multi-line-icon {
    width: 20px;
    height: 20px;
    display: block;
    flex: none;
}

.multi-line-toggle.multi-line-active {
    background: #1A73E8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.35), 0 12px 28px rgba(0, 0, 0, 0.22);
}

.settings-dial .mode-icon {
    width: 22px;
    height: 22px;
    display: block;
    flex: none;
    transform-origin: center;
}

.settings-dial .refresh-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.refresh-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(9, 15, 27, 0.42);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.refresh-confirm-dialog {
    width: min(100%, 20rem);
    padding: 1.25rem;
    border-radius: 16px;
    background: var(--background-white);
    color: var(--text-dark);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
    text-align: center;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}

.refresh-confirm-overlay.is-open,
.refresh-confirm-overlay.is-closing {
    display: flex;
}

.refresh-confirm-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.refresh-confirm-overlay.is-open .refresh-confirm-dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.refresh-confirm-overlay.is-closing .refresh-confirm-dialog {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.4, 0, 0.7, 0.2);
}

.refresh-confirm-overlay.is-closing {
    opacity: 0;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.refresh-confirm-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.refresh-confirm-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.refresh-confirm-btn {
    min-height: 44px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.refresh-confirm-btn-yes {
    background: var(--primary-blue);
    color: var(--text-light);
}

.refresh-confirm-btn-no {
    background: var(--background-light);
    color: var(--text-dark);
}

.refresh-confirm-btn:hover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.refresh-confirm-btn:active {
    transform: scale(0.98);
}

.refresh-confirm-btn:focus {
    outline: none;
}

.refresh-confirm-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.28), 0 8px 18px rgba(0, 0, 0, 0.16);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    header {
        padding: 1rem 0.75rem;
        gap: 0.4rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .info-bar {
        padding: 0.85rem;
    }

    .info-time {
        font-size: 1.2rem;
    }

    .day-type-pill {
        font-size: 1rem;
        padding: 0.25rem 0.7rem;
    }

    .dir-seg-btn {
        font-size: 0.85rem;
        min-height: 40px;
        padding: 0.45rem 0.5rem;
    }

    .bus-line-select,
    .tram-line-select,
    .mid-stop-select {
        min-height: 42px;
        font-size: 0.88rem;
    }

    .view-toggle {
        display: flex;
        width: 100%;
    }

    .schedule-controls {
        grid-template-columns: 1fr;
    }

    .view-toggle-btn {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.45rem 0.5rem;
    }

    .next60-card {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 0.75rem;
        padding: 0.82rem 0.82rem 0.78rem;
    }

    .next60-route {
        font-size: 0.98rem;
    }

    .next60-time {
        font-size: 1.08rem;
    }

    .next60-relative {
        font-size: 0.84rem;
    }

    .next60-stop {
        font-size: 0.82rem;
    }

    .next60-arrow-icon {
        width: 1.2rem;
        height: 1.2rem;
    }

    .next60-realtime-row {
        padding: 0.64rem 0.82rem 0.76rem;
    }

    .full-day-card {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
    }

    .full-day-header {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        column-gap: 1.15rem;
        gap: 0.4rem;
    }

    .full-day-header-content {
        gap: 0.2rem;
        padding-left: 0.12rem;
    }

    .full-day-hour-row {
        grid-template-columns: 2.7rem minmax(0, 1fr);
        gap: 0.6rem;
        padding-top: 0.48rem;
    }

    .full-day-hour-label,
    .full-day-time {
        font-size: 0.92rem;
    }

    .full-day-hour-times {
        grid-template-columns: repeat(auto-fit, minmax(3.2rem, max-content));
        gap: 0.35rem 0.55rem;
    }

    .line-badge:not(.line-badge-large) {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    .line-badge.line-badge-large {
        min-width: 60px;
        min-height: 60px;
        border-radius: 10px;
        font-size: 1.2rem;
        line-height: 1;
        letter-spacing: -0.07em;
        padding: 0.02rem 0.12rem 0.1rem 0.04rem;
    }

    /* Realtime row mobile adjustments */
    .realtime-full-content {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.4rem;
        overflow-x: auto;
        white-space: nowrap;
    }

    .realtime-label {
        font-size: 0.7rem;
    }

    .realtime-delay {
        font-size: 0.75rem;
        min-width: 0;
        width: fit-content;
        max-width: 100%;
        padding: 0.18rem 0.42rem;
        line-height: 1.2;
        text-align: center;
    }

    .realtime-vehicle,
    .realtime-timestamp {
        font-size: 0.65rem;
    }

    .realtime-timestamp {
        display: none;
    }

    .realtime-info {
        display: none;
    }

    .realtime-info-toast {
        bottom: 0.75rem;
        font-size: 0.74rem;
    }

    .line-details-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .line-details-panel {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: 0;
        padding: calc(0.7rem + env(safe-area-inset-top)) 0.7rem calc(0.7rem + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
    }

    .line-details-meta {
        grid-template-columns: 1fr;
    }

    .line-details-field {
        flex-direction: column;
        align-items: flex-start;
    }

    .line-details-field-value {
        text-align: left;
    }

    .settings-dial {
        right: max(0.75rem, env(safe-area-inset-right));
        bottom: max(0.75rem, env(safe-area-inset-bottom));
        gap: 0.6rem;
    }

    .settings-toggle-btn {
        width: 3.15rem;
        height: 3.15rem;
    }

    .settings-dial .settings-action-btn {
        width: 2.75rem;
        height: 2.75rem;
        min-width: 2.75rem;
        min-height: 2.75rem;
    }

    .refresh-confirm-dialog {
        width: min(100%, 18rem);
    }
}

/* Dark Mode overrides */
[data-theme="dark"] .mid-stop-select,
[data-theme="dark"] .bus-line-select,
[data-theme="dark"] .tram-line-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%235B9FE8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    border-color: var(--border-color);
}

/* Dark mode: day type pills */
[data-theme="dark"] .day-type-pill {
    background: #1A2E22;
    color: #81C995;
}

[data-theme="dark"] .day-type-pill.day-saturday {
    background: #2E2210;
    color: #FFB74D;
}

[data-theme="dark"] .day-type-pill.day-sunday {
    background: #3A1C1C;
    color: #F28B82;
}

/* Dark mode: segmented direction */
[data-theme="dark"] .direction-segmented {
    box-shadow: inset 0 0 0 2px var(--primary-blue);
}

[data-theme="dark"] .dir-seg-btn:not(.active):hover,
[data-theme="dark"] .view-toggle-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .multi-line-toggle.multi-line-active {
    background: linear-gradient(180deg, #3E7BCB 0%, #2F65AA 100%);
    box-shadow: 0 0 0 3px rgba(62, 123, 203, 0.35), 0 12px 28px rgba(0, 0, 0, 0.22);
}

[data-theme="dark"] .refresh-btn,
[data-theme="dark"] .theme-toggle-btn {
    background: linear-gradient(180deg, #3976C8 0%, #2E63AA 100%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

[data-theme="dark"] .refresh-btn:hover,
[data-theme="dark"] .theme-toggle-btn:hover {
    background: linear-gradient(180deg, #4380D1 0%, #346CB6 100%);
}

[data-theme="dark"] .settings-toggle-btn,
[data-theme="dark"] .settings-dial .settings-action-btn {
    background: linear-gradient(180deg, #376FBF 0%, #2C5A97 100%);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

[data-theme="dark"] .settings-toggle-btn:hover,
[data-theme="dark"] .settings-dial.open .settings-action-btn:hover {
    background: linear-gradient(180deg, #417BCD 0%, #3366AA 100%);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] footer {
    background: linear-gradient(180deg, rgba(26, 39, 56, 0.96) 0%, rgba(20, 31, 46, 0.98) 100%);
    color: var(--text-dark);
    border-color: rgba(103, 144, 194, 0.34);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.26);
}

[data-theme="dark"] .last-updated {
    color: #BBD6FF;
    opacity: 0.92;
}

[data-theme="dark"] .data-source,
[data-theme="dark"] .data-timestamp {
    color: #8FA2BA;
}

[data-theme="dark"] .refresh-confirm-overlay {
    background: rgba(0, 0, 0, 0.58);
}

[data-theme="dark"] .refresh-confirm-btn-no {
    background: #1C2530;
    color: var(--text-dark);
}

/* Dark mode: info bar divider */
[data-theme="dark"] .info-bar-divider {
    background: var(--border-color);
}

/* Dark Mode: delay badges — readable on dark backgrounds */
[data-theme="dark"] .delay-ontime {
    background: #1C3A28;
    color: #81C995;
}

[data-theme="dark"] .delay-late {
    background: #3A1C1C;
    color: #F28B82;
}

[data-theme="dark"] .delay-early {
    background: #1C2B3A;
    color: #8AB4F8;
}

[data-theme="dark"] .delay-unknown {
    background: #252A30;
    color: #8B949E;
}

/* ───── Bottom Sheet Select (mobile) ───── */
.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-overlay.open {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: var(--background-white);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    will-change: transform;
    transition: transform 0.45s cubic-bezier(0.32, 1.6, 0.5, 1);
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet.closing {
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.7, 0.2);
}

.bottom-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
    cursor: grab;
    flex-shrink: 0;
}

.bottom-sheet-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
}

.bottom-sheet-header {
    padding: 0.25rem 1.25rem 0.5rem;
    flex-shrink: 0;
}

.bottom-sheet-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.bottom-sheet-search-wrap {
    padding: 0 1.25rem 0.5rem;
    flex-shrink: 0;
    display: none;
}

.bottom-sheet-search-wrap.has-search {
    display: block;
}

.bottom-sheet-search {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--background-light);
    color: var(--text-dark);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bottom-sheet-search:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.bottom-sheet-search::placeholder {
    color: var(--subtle-text);
}

.bottom-sheet-options {
    list-style: none;
    margin: 0;
    padding: 0 0 env(safe-area-inset-bottom, 0.5rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.bottom-sheet-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--muted-bg);
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-option:last-child {
    border-bottom: none;
}

.bottom-sheet-option:active {
    background: var(--muted-bg);
}

.bottom-sheet-option-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.2s ease;
}

.bottom-sheet-option.selected .bottom-sheet-option-radio {
    border-color: var(--primary-blue);
}

.bottom-sheet-option.selected .bottom-sheet-option-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-blue);
}

.bottom-sheet-option-text {
    flex: 1;
    min-width: 0;
}

.bottom-sheet-no-results {
    padding: 1.5rem 1.25rem;
    text-align: center;
    color: var(--subtle-text);
    font-size: 0.9rem;
}

/* Dark mode overrides */
[data-theme="dark"] .bottom-sheet {
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .bottom-sheet-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus States for Accessibility */
button:focus,
select:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --primary-blue: #0000FF;
        --primary-dark: #000080;
        --text-dark: #000000;
        --border-color: #000000;
    }

}
