* {
    -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 .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%;
    min-height: 132px;
    min-width: 0;
    gap: 0;
    overflow-x: auto;
    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: 36px;
    height: 34px;
    flex: 0 0 44px;
}

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

.diagram-bus {
    position: absolute;
    top: 3px;
    left: 50%;
    z-index: 2;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    transform: translateX(-50%);
    border-radius: 999px;
    background: #f59e0b;
    color: #451a03;
    font-size: 12px;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
    animation: busPulse 1.8s infinite;
}

.station-list {
    position: relative;
}

.station-list::before {
    position: absolute;
    top: 18px;
    bottom: 18px;
    left: 14px;
    width: 2px;
    background: #1e293b;
    content: "";
}

.station-item {
    position: relative;
    width: 100%;
    border-radius: 18px;
    text-align: left;
    transition: background 0.2s;
}

.station-click {
    display: flex;
    width: 100%;
    gap: 12px;
    border-radius: 18px;
    padding: 10px 10px 10px 0;
    text-align: left;
}

.station-item:hover,
.station-item.selected {
    background: rgba(16, 185, 129, 0.08);
}

.station-dot {
    z-index: 1;
    margin-left: 7px;
    margin-top: 5px;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 2px solid #334155;
    border-radius: 999px;
    background: #020617;
}

.station-item.selected .station-dot {
    border-color: #10b981;
    background: #10b981;
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.12);
}

.station-body {
    min-width: 0;
    flex: 1;
}

.station-eta-inline {
    margin: 0 10px 12px 36px;
}

.station-eta-inline:empty {
    display: none;
}

.station-name,
.station-meta {
    display: block;
}

.station-name {
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 700;
}

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

.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;
}

.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 {
        display: block;
        min-height: 0;
        max-height: 360px;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 4px 0;
    }

    .diagram-node {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        width: 100%;
        max-width: none;
        min-width: 0;
        gap: 10px;
        align-items: center;
        padding: 4px 0;
        text-align: left;
    }

    .diagram-label {
        display: block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        text-align: left;
    }

    .diagram-segment {
        width: 34px;
        min-width: 34px;
        height: 22px;
        margin-left: 0;
    }

    .diagram-segment::before {
        top: -2px;
        bottom: -2px;
        left: 16px;
        right: auto;
        width: 2px;
        height: auto;
    }

    .diagram-bus {
        top: 50%;
        left: 16px;
        transform: translate(-50%, -50%);
        animation: none;
    }
}
