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

body {
    overflow-x: hidden;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main,
section,
aside,
.panel {
    min-width: 0;
}

.panel {
    border: 1px solid rgba(30, 41, 59, 0.9);
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.82);
    padding: 18px;
    box-shadow: 0 18px 60px rgba(2, 6, 23, 0.28);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 700;
}

.input {
    min-width: 0;
    flex: 1;
    border: 1px solid #334155;
    border-radius: 16px;
    background: #020617;
    padding: 11px 14px;
    color: #f8fafc;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.primary-btn,
.secondary-btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.15s, border-color 0.2s, background 0.2s, color 0.2s;
}

.primary-btn:active,
.secondary-btn:active,
.icon-btn:active,
.line-card:active,
.station-item:active,
.diagram-node:active {
    transform: scale(0.98);
}

.primary-btn {
    background: #10b981;
    color: #022c22;
    padding: 0 16px;
}

.primary-btn:hover {
    background: #34d399;
}

.secondary-btn {
    border: 1px solid #334155;
    background: #020617;
    color: #cbd5e1;
    padding: 10px 14px;
}

.secondary-btn:hover,
.icon-btn:hover {
    border-color: #10b981;
    color: #34d399;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid #334155;
    background: #020617;
    color: #94a3b8;
}

.icon-btn.active {
    border-color: rgba(245, 158, 11, 0.45);
    color: #f59e0b;
}

.route-badge {
    min-width: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, #34d399, #10b981);
    color: #022c22;
    padding: 10px 14px;
    text-align: center;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
}

.line-card {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #1e293b;
    border-radius: 18px;
    background: #020617;
    padding: 13px;
    color: inherit;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.line-card:hover {
    border-color: #10b981;
    background: #0b1220;
}

.line-card .badge,
.fav-badge {
    min-width: 54px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
    padding: 7px 10px;
    text-align: center;
    font-weight: 900;
}

.line-card .info,
.favorite-main {
    min-width: 0;
    flex: 1;
}

.line-card .name,
.line-card .meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-card .name {
    color: #f8fafc;
    font-size: 14px;
    font-weight: 700;
}

.line-card .meta {
    margin-top: 2px;
    color: #64748b;
    font-size: 12px;
}

.line-card .service-badge {
    display: inline-block;
    margin-left: 6px;
    margin-top: 2px;
    border-radius: 8px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
}

.line-card .arrow {
    color: #475569;
}

.direction-pill {
    border: 1px solid #334155;
    border-radius: 999px;
    background: #020617;
    color: #94a3b8;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.2s;
}

.direction-pill:hover,
.direction-pill.active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
}

.favorite-card {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #1e293b;
    border-radius: 18px;
    background: #020617;
    padding: 10px;
}

.favorite-main {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.favorite-text {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.favorite-direction {
    color: #64748b;
    font-size: 11px;
}

.favorite-remove {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 10px;
    color: #64748b;
}

.favorite-remove:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.route-diagram {
    display: flex;
    width: 100%;
    max-width: 100%;
    height: 120px;
    max-height: 33vh;
    min-width: 0;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 4px 12px;
    overscroll-behavior-x: contain;
}

.diagram-node {
    display: flex;
    min-width: 76px;
    max-width: 92px;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
}

.diagram-dot {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 2px solid #334155;
    border-radius: 50%;
    background: #020617;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 900;
}

.diagram-node:hover .diagram-dot {
    border-color: #10b981;
    color: #34d399;
}

.diagram-label {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
}

.diagram-segment {
    position: relative;
    min-width: 20px;
    height: 34px;
    flex: 0 0 28px;
}

.diagram-segment::before {
    position: absolute;
    top: 16px;
    left: -20px;
    right: -20px;
    height: 2px;
    background: #1e293b;
    content: "";
}

.diagram-bus {
    position: absolute;
    top: 3px;
    z-index: 2;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    transform: translateX(-50%);
    border-radius: 999px;
    font-size: 12px;
    transition: left 0.8s ease-out;
}

/* Arriving soon — cyan pulse */
.diagram-bus.arriving {
    background: #10b981;
    color: #022c22;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
    animation: busPulse 1.5s infinite;
}

/* Traveling between stops — amber */
.diagram-bus.traveling {
    background: #d97706;
    color: #451a03;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.10);
    animation: none;
}

/* ---------- Station Cards ---------- */
.station-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.station-card {
    border: 1px solid #1e293b;
    border-radius: 18px;
    background: #020617;
    overflow: hidden;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.station-card:hover {
    border-color: #334155;
}

.station-card.expanded {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.08);
}

.station-card.highlight-scroll {
    animation: cardPulse 1.2s ease-out;
}

@keyframes cardPulse {
    0% { border-color: #1e293b; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
    30% { border-color: rgba(16, 185, 129, 0.7); box-shadow: 0 0 20px rgba(16, 185, 129, 0.18); }
    100% { border-color: rgba(16, 185, 129, 0.5); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Header row — clickable */
.station-card-header {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.station-card-header:active {
    background: rgba(16, 185, 129, 0.04);
}

/* Sequence badge */
.station-seq {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    border-radius: 10px;
    background: #1e293b;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 900;
    transition: background 0.25s, color 0.25s;
}

.station-card.expanded .station-seq {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
}

/* Name block */
.station-card-info {
    min-width: 0;
    flex: 1;
}

.station-card-name {
    display: block;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.station-card-en {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: #64748b;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chevron arrow */
.station-card-chevron {
    color: #475569;
    font-size: 12px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.station-card.expanded .station-card-chevron {
    transform: rotate(180deg);
    color: #10b981;
}

/* Expandable body */
.station-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.station-card.expanded .station-card-body {
    max-height: 600px;
}

.station-card-body-inner {
    padding: 0 14px 14px 58px;
}

/* ETA item inside card body */
.station-eta-item {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    border-top: 1px solid #1e293b;
    padding-top: 10px;
}

.station-eta-item:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.station-eta-empty {
    padding: 8px 0;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

.eta-title {
    color: #f8fafc;
    font-size: 16px;
    font-weight: 800;
}

.eta-summary {
    margin-top: 6px;
    color: #64748b;
    font-size: 12px;
}

.eta-card {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    border: 1px solid #1e293b;
    border-radius: 18px;
    background: #020617;
    padding: 13px;
}

.eta-count {
    min-width: 78px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.95);
    color: #cbd5e1;
    padding: 9px 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 900;
}

.eta-count.primary {
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
}

.eta-detail {
    min-width: 0;
}

.eta-row {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.occupancy-badge {
    display: inline-block;
    border-radius: 8px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid;
}

.eta-remark {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
}

.empty-copy {
    padding: 20px 4px 4px;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 72px;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(16, 185, 129, 0.15);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.toast {
    position: fixed;
    top: 78px;
    left: 50%;
    z-index: 60;
    max-width: calc(100vw - 32px);
    transform: translate(-50%, -12px);
    border: 1px solid rgba(16, 185, 129, 0.45);
    border-radius: 16px;
    background: #020617;
    color: #e2e8f0;
    padding: 11px 16px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

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

.refresh-spin {
    animation: spin 0.7s linear;
}

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

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

@media (max-width: 640px) {
    .panel {
        border-radius: 20px;
        padding: 15px;
        overflow: hidden;
    }

    .route-badge {
        min-width: 58px;
        font-size: 19px;
    }

    .route-diagram {
        height: 100px;
        max-height: 28vh;
    }

    .diagram-node {
        min-width: 60px;
        max-width: 72px;
    }

    .diagram-dot {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }

    .diagram-label {
        font-size: 10px;
        -webkit-line-clamp: 1;
    }

    .diagram-segment {
        min-width: 24px;
    }

    .diagram-bus {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
}
