:root {
    --accent: #e73324;
    --accent-strong: #b82017;
    --accent-soft: rgba(231, 51, 36, 0.12);
    --ink: #17202a;
    --muted: #687383;
    --subtle: #8b96a6;
    --page: #f3f6f8;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-solid: #ffffff;
    --surface-raised: #ffffff;
    --border: rgba(23, 32, 42, 0.1);
    --shadow: 0 16px 45px rgba(30, 45, 65, 0.12);
    --shadow-soft: 0 8px 22px rgba(30, 45, 65, 0.08);
    --danger: #de3b35;
    --success: #1f9d68;
    --warning: #bd7a00;
    --nav-height: 78px;
    --topbar-height: 72px;
}

body[data-theme="dark"] {
    --ink: #f5f7fb;
    --muted: #aab4c0;
    --subtle: #7d8794;
    --page: #0f1318;
    --surface: rgba(25, 31, 38, 0.82);
    --surface-solid: #191f26;
    --surface-raised: #202832;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
    --shadow-soft: 0 8px 26px rgba(0, 0, 0, 0.28);
}

body[data-accent="blue"] {
    --accent: #0a84ff;
    --accent-strong: #0061bd;
    --accent-soft: rgba(10, 132, 255, 0.14);
}

body[data-accent="green"] {
    --accent: #1f9d68;
    --accent-strong: #147447;
    --accent-soft: rgba(31, 157, 104, 0.14);
}

body[data-accent="violet"] {
    --accent: #7c3aed;
    --accent-strong: #5b21b6;
    --accent-soft: rgba(124, 58, 237, 0.14);
}

body[data-accent="orange"] {
    --accent: #ff7a1a;
    --accent-strong: #c85000;
    --accent-soft: rgba(255, 122, 26, 0.15);
}

body[data-accent="cyan"] {
    --accent: #00a6c8;
    --accent-strong: #007891;
    --accent-soft: rgba(0, 166, 200, 0.14);
}

body[data-accent="pink"] {
    --accent: #e83e8c;
    --accent-strong: #b71962;
    --accent-soft: rgba(232, 62, 140, 0.14);
}

body[data-accent="slate"] {
    --accent: #475569;
    --accent-strong: #253244;
    --accent-soft: rgba(71, 85, 105, 0.14);
}

body[data-accent="gold"] {
    --accent: #c89200;
    --accent-strong: #936700;
    --accent-soft: rgba(200, 146, 0, 0.16);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(233, 240, 246, 0.72) 38%, rgba(231, 238, 244, 0.92)),
        var(--page);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.45;
    letter-spacing: 0;
    transition: background-color 240ms ease, color 240ms ease;
}

body[data-theme="dark"] {
    background:
        linear-gradient(145deg, rgba(35, 42, 51, 0.72), rgba(15, 19, 24, 0.92) 46%, rgba(12, 15, 20, 0.96)),
        var(--page);
}

button,
input,
select {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    width: min(100%, 760px);
    min-height: 100vh;
    margin: 0 auto;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
    padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(22px) saturate(1.35);
}

.brand-block,
.header-actions,
.toolbar,
.map-toolbar,
.map-status-row {
    display: flex;
    align-items: center;
}

.brand-block {
    gap: 10px;
    min-width: 0;
}

.brand-officials {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: 4px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 34%, transparent);
    font-size: 0.9rem;
    font-weight: 900;
}

.brand-app-glyph {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: center;
    gap: 2px;
    color: #ffffff;
    font-size: 0.92rem;
    line-height: 1;
    transform: translateY(1px);
}

.brand-app-glyph i {
    display: block;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-copy strong {
    font-size: 1.02rem;
    line-height: 1.1;
}

.brand-kicker {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.header-actions {
    gap: 8px;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    color: var(--ink);
    background: var(--surface-solid);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 170ms ease, background 170ms ease, border-color 170ms ease, color 170ms ease, opacity 170ms ease;
}

.icon-button:hover,
.text-button:hover,
.tab-button:hover,
.selector-button:hover,
.metric-action:hover {
    transform: translateY(-1px);
}

.icon-button:active,
.text-button:active,
.tab-button:active,
.selector-button:active,
.metric-action:active {
    transform: scale(0.97);
}

.icon-button:disabled {
    opacity: 0.46;
    cursor: default;
    transform: none;
}

.icon-button.filled {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.icon-button.compact-action {
    width: 38px;
    height: 38px;
    box-shadow: none;
    color: var(--accent);
}

.compact-back {
    min-height: 38px;
    padding-inline: 11px;
    box-shadow: none;
}

.action-cluster {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
}

.detail-filter {
    width: fit-content;
    margin: 0 0 10px auto;
    box-shadow: none;
}

.detail-mode {
    width: fit-content;
    margin: 0 0 10px auto;
}

.schedule-filters {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.85fr) auto minmax(0, 1fr);
    gap: 8px;
    margin: 0 0 10px;
}

.schedule-filters.realtime-filters {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.schedule-filters .select-shell {
    min-width: 0;
}

.icon-button.favorite-on {
    color: #f5b700;
}

.main-content {
    padding: 18px 16px calc(var(--nav-height) + 28px + env(safe-area-inset-bottom));
}

.view-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin: 6px 0 18px;
}

.view-title h1 {
    max-width: 100%;
    margin: 2px 0 3px;
    color: var(--ink);
    font-size: clamp(1.75rem, 1.35rem + 1vw, 2.35rem);
    line-height: 1.06;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.view-title p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.live-chip {
    min-width: max-content;
    margin-top: 6px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    background: var(--surface);
    font-size: 0.78rem;
    font-weight: 750;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(31, 157, 104, 0.14);
}

.live-chip.warn .live-dot {
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(189, 122, 0, 0.14);
}

.live-chip.error .live-dot {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(222, 59, 53, 0.14);
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: viewIn 320ms cubic-bezier(0.2, 0.85, 0.25, 1);
}

@keyframes viewIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.hidden {
    display: none !important;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.metric-tile {
    min-height: 64px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    color: var(--ink);
}

.metric-action {
    align-items: flex-start;
    cursor: pointer;
}

.metric-action i {
    color: var(--accent);
    font-size: 1.05rem;
}

.metric-value {
    font-size: 1.18rem;
    font-weight: 900;
    line-height: 1;
}

.metric-label {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 750;
}

.content-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel,
.arrival-card,
.stop-group,
.empty-state,
.loading-card,
.settings-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.panel,
.settings-section {
    padding: 14px;
}

.search-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.search-field {
    height: 52px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-solid);
    color: var(--muted);
    transition: box-shadow 170ms ease, border-color 170ms ease;
}

.search-field:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-size: 1rem;
}

.recent-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.recent-row:empty {
    display: none;
}

.recent-row::-webkit-scrollbar {
    display: none;
}

.chip-button {
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    flex: 0 0 auto;
    color: var(--ink);
    background: var(--surface-solid);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 780;
}

.selector-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 310px);
    overflow: auto;
    padding-right: 2px;
}

.selector-button {
    width: 100%;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    color: var(--ink);
    background: var(--surface-solid);
    cursor: pointer;
    text-align: left;
    transition: transform 170ms ease, border-color 170ms ease, background 170ms ease;
}

.selector-button:hover {
    border-color: var(--accent);
}

.selector-title,
.stop-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 850;
}

.selector-meta,
.stop-code,
.subtle-status {
    color: var(--muted);
    font-size: 0.82rem;
}

.selector-code {
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 850;
}

.toolbar {
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.text-button,
.danger-button {
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--ink);
    background: var(--surface-solid);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 800;
    transition: transform 170ms ease, background 170ms ease, border-color 170ms ease, color 170ms ease;
}

.text-button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.text-button.ghost {
    color: var(--accent);
}

.danger-button {
    width: 100%;
    border-color: rgba(222, 59, 53, 0.22);
    color: #ffffff;
    background: var(--danger);
}

.subtle-status {
    margin: 0 0 12px;
}

.arrival-card {
    min-height: 84px;
    padding: 13px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
}

.arrival-card.clickable {
    cursor: pointer;
}

.arrival-card.clickable:active {
    transform: scale(0.985);
}

.arrival-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.line-badge {
    min-width: 42px;
    height: 34px;
    padding: 0 8px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-weight: 950;
    line-height: 1;
}

.arrival-destination {
    min-width: 0;
}

.arrival-destination strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
}

.arrival-destination span {
    color: var(--muted);
    font-size: 0.82rem;
}

.arrival-time {
    min-width: 76px;
    text-align: right;
}

.arrival-time strong {
    color: var(--accent);
    font-size: 2rem;
    font-weight: 950;
    line-height: 0.9;
}

.arrival-time span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 760;
}

.arrival-card.compact {
    min-height: 64px;
    padding: 9px 10px;
    box-shadow: none;
    background: color-mix(in srgb, var(--surface-solid) 72%, var(--accent-soft));
}

.arrival-card.compact .arrival-time strong {
    font-size: 1.38rem;
}

.arrival-card.compact .line-badge {
    min-width: 38px;
    height: 30px;
}

.scheduled-card {
    grid-template-columns: 1fr auto;
}

.scheduled-time {
    display: grid;
    justify-items: end;
    gap: 2px;
    min-width: 76px;
}

.scheduled-time strong {
    color: var(--ink);
    font-size: 1.42rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.scheduled-time span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.stop-group {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 11px;
    transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
}

.stop-group.clickable {
    cursor: pointer;
}

.stop-group.clickable:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    box-shadow: var(--shadow);
}

.stop-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.stop-top > div:first-child {
    min-width: 0;
}

.stop-name {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
}

.stop-code {
    margin-top: 2px;
}

.stop-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.mini-icon-button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    background: var(--surface-solid);
    cursor: pointer;
    text-decoration: none;
}

.mini-icon-button.favorite-on {
    color: #f5b700;
}

.mini-icon-button.map-link {
    color: var(--accent);
}

.mini-icon-button.note-on {
    color: var(--warning);
}

.mini-icon-button:disabled {
    opacity: 0.35;
    cursor: default;
}

.position-pill {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    background: var(--accent-soft);
    font-size: 0.78rem;
    font-weight: 950;
}

.position-button {
    border: 0;
    cursor: pointer;
}

.stop-note {
    margin: -2px 0 0;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--muted);
    background: color-mix(in srgb, var(--warning) 10%, transparent);
    font-size: 0.88rem;
    font-weight: 650;
}

.distance-link {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    background: var(--surface-solid);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 850;
}

.empty-state,
.loading-card {
    min-height: 210px;
    padding: 28px 22px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    color: var(--muted);
    text-align: center;
}

.empty-state i {
    color: var(--accent);
    font-size: 1.8rem;
}

.empty-state h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.05rem;
}

.empty-state p {
    max-width: 34rem;
    margin: 0;
    font-size: 0.92rem;
}

.empty-state.compact {
    min-height: 148px;
}

.loading-card {
    min-height: 120px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--accent-soft);
    border-top-color: var(--accent);
    border-radius: 999px;
    animation: spin 800ms linear infinite;
}

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

.location-panel {
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
}

.location-panel h2,
.settings-section h2 {
    margin: 0 0 3px;
    color: var(--ink);
    font-size: 1rem;
}

.location-panel p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.map-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.map-toolbar .select-shell {
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.map-toolbar .select-shell select,
.schedule-filters .select-shell select {
    min-width: 0;
    width: 100%;
}

.select-shell {
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-solid);
    color: var(--muted);
    box-shadow: var(--shadow-soft);
    font-size: 0.86rem;
    font-weight: 800;
}

.select-shell select {
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-weight: 850;
}

.map-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 22px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.map-refresh-button {
    margin-left: auto;
}

.map-container {
    height: min(62vh, 520px);
    min-height: 360px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-raised);
    box-shadow: var(--shadow-soft);
}

.vehicle-detail-panel {
    margin-top: 10px;
}

.vehicle-route-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-soft);
}

.vehicle-route-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.vehicle-route-head strong,
.vehicle-route-head span {
    display: block;
}

.vehicle-route-head span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 750;
}

.vehicle-route-icon {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--vehicle-line, var(--accent));
}

.vehicle-route-icon img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    object-fit: contain;
    transform: translate(-50%, -50%);
}

.vehicle-time-mode-button {
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 10px;
    color: var(--vehicle-line, var(--accent));
    background: var(--surface);
    font-size: 0.78rem;
    font-weight: 900;
    box-shadow: var(--shadow-soft);
}

.vehicle-route-body {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
}

.vehicle-route-line {
    position: relative;
    width: 4px;
    min-height: 100%;
    justify-self: center;
    border-radius: 999px;
    background: color-mix(in srgb, var(--vehicle-line, var(--accent)) 70%, transparent);
}

.vehicle-moving-dot {
    position: absolute;
    top: calc(10px + (var(--vehicle-row, 0) * 50px));
    left: 50%;
    width: 28px;
    height: 28px;
    border: 2px solid var(--surface-solid);
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--vehicle-line, var(--accent));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--vehicle-line, var(--accent)) 38%, transparent);
    transform: translateX(-50%);
    transition: top 420ms cubic-bezier(.2, .8, .2, 1);
    animation: vehiclePulse 2.8s ease-in-out infinite;
    transform-origin: 50% 50%;
}

.vehicle-moving-dot i {
    position: relative;
    z-index: 2;
    font-size: 0.72rem;
}

.vehicle-moving-arrow {
    position: absolute;
    bottom: -9px;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 14px solid var(--vehicle-line, var(--accent));
    transform: translateX(-50%);
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.25));
}

.vehicle-stop-list {
    display: grid;
    gap: 7px;
}

.vehicle-stop-row {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    background: var(--surface);
    text-align: left;
}

.vehicle-stop-row.next {
    border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
    background: var(--accent-soft);
}

.vehicle-stop-row.passed {
    opacity: 0.62;
}

.vehicle-stop-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--vehicle-line, var(--accent));
}

.vehicle-stop-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}

.vehicle-stop-row strong {
    color: var(--muted);
    font-size: 0.8rem;
}

@keyframes vehiclePulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.08);
    }
}

.leaflet-container {
    z-index: 0;
}

.bus-marker-wrap {
    position: relative;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    transform: rotate(var(--marker-angle, 0deg));
}

.bus-marker {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    color: #ffffff;
    background: var(--marker-color, var(--accent));
    border: 2px solid #ffffff;
    box-shadow: 0 7px 16px rgba(0, 0, 0, 0.24);
}

.bus-marker i {
    transform: rotate(calc(-1 * var(--marker-angle, 0deg)));
}

.bus-direction-arrow {
    position: absolute;
    top: -13px;
    left: 50%;
    z-index: 1;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid var(--marker-color, var(--accent));
    transform: translateX(-50%);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.28));
}

.metro-vehicle-wrap {
    position: relative;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    transform: rotate(var(--marker-angle, 0deg));
}

.metro-vehicle-marker {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    color: #ffffff;
    background: var(--metro-color, #111827);
    border: 2px solid #ffffff;
    box-shadow: 0 7px 16px rgba(0, 0, 0, 0.25);
}

.metro-vehicle-marker i {
    transform: rotate(calc(-1 * var(--marker-angle, 0deg)));
}

.metro-direction-arrow {
    position: absolute;
    top: -12px;
    left: 50%;
    z-index: 1;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 18px solid var(--metro-color, #111827);
    transform: translateX(-50%);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.24));
}

.leaflet-marker-icon {
    transition: transform 900ms linear;
}

.popup-action-button {
    min-height: 30px;
    margin-top: 8px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    color: #ffffff;
    background: var(--accent);
    font-weight: 850;
    cursor: pointer;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
}

.leaflet-popup-content {
    margin: 11px 13px !important;
    color: #17202a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.4;
}

body[data-theme="dark"] .leaflet-popup-content-wrapper {
    background: #202832 !important;
}

body[data-theme="dark"] .leaflet-popup-content {
    color: #f5f7fb;
}

.error-text {
    color: var(--danger);
    font-weight: 780;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.swatch-row,
.segmented-control {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.swatch-row {
    margin-top: 12px;
}

.swatch {
    width: 44px;
    height: 44px;
    border: 3px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
}

.swatch.red {
    background: #e73324;
}

.swatch.blue {
    background: #0a84ff;
}

.swatch.green {
    background: #1f9d68;
}

.swatch.violet {
    background: #7c3aed;
}

.swatch.orange {
    background: #ff7a1a;
}

.swatch.cyan {
    background: #00a6c8;
}

.swatch.pink {
    background: #e83e8c;
}

.swatch.slate {
    background: #475569;
}

.swatch.gold {
    background: #c89200;
}

.swatch.selected {
    border-color: var(--ink);
    outline: 3px solid var(--accent-soft);
}

.segmented-control {
    margin-top: 10px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-solid);
}

.segmented-control button {
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    flex: 1 1 88px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-weight: 850;
}

.segmented-control button.active {
    color: #ffffff;
    background: var(--accent);
}

.segmented-control.compact {
    min-width: 168px;
    margin-top: 0;
    flex-wrap: nowrap;
}

.segmented-control.compact button {
    flex-basis: 38px;
    padding-inline: 9px;
}

.settings-row,
.switch-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.settings-section > .settings-row:first-of-type,
.settings-section > .switch-row:first-of-type {
    border-top: 0;
}

.settings-row strong,
.switch-row strong {
    display: block;
    color: var(--ink);
    font-size: 0.95rem;
}

.settings-row span,
.switch-row small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.82rem;
}

.switch-row {
    cursor: pointer;
}

.switch-row input {
    appearance: none;
    width: 52px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 20%, transparent);
    cursor: pointer;
    position: relative;
    transition: background 180ms ease, border-color 180ms ease;
}

.switch-row input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
    transition: transform 180ms cubic-bezier(0.2, 0.85, 0.25, 1);
}

.switch-row input:checked {
    border-color: var(--accent);
    background: var(--accent);
}

.switch-row input:checked::after {
    transform: translateX(20px);
}

body[data-density="compact"] .main-content {
    padding-top: 12px;
}

body[data-density="compact"] .content-stack {
    gap: 8px;
}

body[data-density="compact"] .arrival-card {
    min-height: 66px;
    padding: 9px 10px;
}

body[data-density="compact"] .arrival-card:not(.compact) .arrival-time strong {
    font-size: 1.62rem;
}

body[data-density="compact"] .stop-group,
body[data-density="compact"] .panel,
body[data-density="compact"] .settings-section {
    padding: 10px;
}

body[data-motion="reduced"] *,
body[data-motion="reduced"] *::before,
body[data-motion="reduced"] *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
}

.global-message {
    margin-bottom: 12px;
    padding: 11px 12px;
    border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent);
    border-radius: 8px;
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    font-weight: 740;
}

.tabbar {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 1000;
    width: min(100%, 760px);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    display: flex;
    align-items: stretch;
    justify-content: space-evenly;
    gap: 4px;
    transform: translateX(-50%);
    background: var(--surface);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(24px) saturate(1.4);
}

.tab-button {
    min-width: 0;
    flex: 1 1 0;
    max-width: 96px;
    border: 0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--subtle);
    background: transparent;
    cursor: pointer;
    font-size: 0.61rem;
    font-weight: 800;
    transition: transform 170ms ease, color 170ms ease, background 170ms ease;
}

.tab-button i {
    font-size: 1rem;
}

.planner-panel {
    display: grid;
    gap: 12px;
}

.planner-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metro-panel-actions,
.brand-pair {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.theme-logo {
    height: 22px;
    width: auto;
    object-fit: contain;
}

.theme-logo-dark,
body[data-theme="dark"] .theme-logo-light {
    display: none;
}

body[data-theme="dark"] .theme-logo-dark {
    display: inline-block;
}

.metro-favorites-panel {
    display: grid;
    gap: 10px;
}

.metro-board-card {
    padding: 12px;
    border: 1px solid #202020;
    border-radius: 8px;
    display: grid;
    gap: 10px;
    color: #ffbf27;
    background: linear-gradient(180deg, #0a0a08, #17120a);
    box-shadow: inset 0 0 0 1px rgba(255, 191, 39, 0.08), var(--shadow-soft);
    font-family: "SF Mono", "Cascadia Mono", Consolas, monospace;
}

.metro-board-title {
    border: 0;
    padding: 0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: inherit;
    background: transparent;
    text-align: left;
    font-weight: 900;
}

.metro-board-title small {
    color: rgba(255, 191, 39, 0.72);
}

.metro-board-rows {
    display: grid;
    gap: 7px;
}

.metro-board-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.metro-board-line {
    min-width: 26px;
    padding: 2px 5px;
    border-radius: 5px;
    color: #111;
    text-align: center;
    font-weight: 950;
}

.metro-board-headsign {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feedback-box {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.feedback-box textarea {
    width: 100%;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: var(--ink);
    background: var(--surface-solid);
    font: inherit;
}

#send-feedback-btn {
    margin-top: 10px;
}

.ai-panel {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.ai-panel.compact {
    margin-top: 12px;
    padding: 10px;
}

.planner-suggestion-panel {
    display: grid;
    gap: 6px;
    margin-top: -6px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.planner-suggestion-item {
    min-height: 42px;
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink);
    text-align: left;
}

.planner-suggestion-item:hover,
.planner-suggestion-item:focus-visible {
    background: var(--accent-soft);
    outline: 0;
}

.planner-suggestion-item span {
    min-width: 0;
}

.planner-suggestion-item strong,
.planner-suggestion-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planner-suggestion-item small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.74rem;
}

.line-search-header {
    display: grid;
    gap: 3px;
    padding: 8px 2px;
    color: var(--ink);
}

.line-search-header span {
    color: var(--muted);
    font-size: 0.82rem;
}

.plan-live-panel {
    display: grid;
    gap: 9px;
    margin-top: 10px;
}

.plan-live-block {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
}

.content-stack.tight {
    gap: 6px;
}

.planner-map-picker {
    display: grid;
    gap: 10px;
}

.picker-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.82rem;
}

.picker-header strong {
    color: var(--ink);
    font-size: 0.92rem;
}

.planner-map-container {
    min-height: 220px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-raised);
}

.plan-card {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.plan-card.best {
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    background: color-mix(in srgb, var(--accent-soft) 32%, var(--surface));
}

.plan-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.plan-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 900;
}

.plan-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.plan-metric {
    padding: 6px 8px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-solid);
    font-size: 0.8rem;
    font-weight: 800;
}

.plan-route {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.plan-steps {
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    list-style: none;
}

.plan-details summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 900;
}

.plan-details[open] summary {
    margin-bottom: 8px;
}

.plan-steps li {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 8px;
    align-items: start;
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.35;
}

.plan-steps i {
    margin-top: 2px;
    color: var(--accent);
    text-align: center;
}

.tab-button.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.skeleton {
    position: relative;
    overflow: hidden;
    min-height: 110px;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
    animation: shimmer 1300ms infinite;
}

@keyframes shimmer {
    to {
        transform: translateX(100%);
    }
}

@media (max-width: 560px) {
    .main-content {
        padding-inline: 12px;
        padding-bottom: calc(var(--nav-height) + 34px + env(safe-area-inset-bottom));
    }

    .topbar {
        padding-inline: 12px;
    }

    .brand-officials {
        display: none;
    }

    .view-title {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .live-chip {
        align-self: flex-start;
    }

    .overview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
    }

    .metric-tile {
        min-height: 58px;
        padding: 8px;
    }

    .metric-value {
        font-size: 1rem;
    }

    .metric-label {
        font-size: 0.62rem;
    }

    .arrival-card {
        grid-template-columns: 1fr;
    }

    .stop-top {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stop-actions {
        justify-content: flex-start;
    }

    .arrival-time {
        min-width: 0;
        text-align: left;
        display: flex;
        align-items: baseline;
        gap: 8px;
    }

    .arrival-time span {
        display: inline;
    }

    .tab-button span {
        font-size: 0.66rem;
    }

    .map-container {
        height: min(48vh, 390px);
        min-height: 270px;
        margin-bottom: 10px;
    }

    .planner-map-container {
        min-height: 190px;
        max-height: 34vh;
    }

    .schedule-filters {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.8fr) 40px minmax(0, 0.95fr);
        gap: 6px;
    }

    .schedule-filters .select-shell:last-child {
        grid-column: auto;
    }

    .schedule-filters.realtime-filters {
        grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
    }

    .schedule-filters.realtime-filters .select-shell:last-child {
        grid-column: auto;
    }

    .schedule-filters .select-shell {
        padding: 0 8px;
        gap: 5px;
    }

    .schedule-filters .select-shell span {
        display: none;
    }

    .schedule-filters .select-shell select {
        font-size: 0.82rem;
    }

    .map-toolbar {
        grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
        gap: 6px;
    }

    .map-toolbar .select-shell {
        padding: 0 8px;
        gap: 5px;
    }

    .map-toolbar .select-shell span {
        display: none;
    }

    .settings-row {
        grid-template-columns: 1fr;
    }

    .segmented-control.compact {
        width: 100%;
    }
}

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