/* ========== TransitLM — Refined Technical Demo ========== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --primary: #3b5bdb;
    --primary-light: #edf2ff;
    --primary-dim: rgba(59, 91, 219, 0.08);
    --accent: #f76707;
    --text: #212529;
    --text-secondary: #868e96;
    --border: #dee2e6;
    --border-light: #f1f3f5;
    --bg: #f8f9fa;
    --card: #ffffff;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.07), 0 2px 6px rgba(0, 0, 0, 0.03);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 14px;
}

/* ---- Header ---- */
.header {
    text-align: center;
    padding: 20px 24px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 10;
    max-width: 1100px;
    margin: 0 auto;
}

.title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

/* ---- Control Bar ---- */
.control-bar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    max-width: 1100px;
    margin: 0 auto;
}

.control-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.control-item.flex-2 {
    flex: 2;
}

.control-item label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.control-item input,
.control-item select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.control-item input:focus,
.control-item select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.control-btn-wrap {
    flex: 0 0 auto;
}

.input-with-btn {
    display: flex;
    gap: 4px;
    align-items: stretch;
}

.input-with-btn .coord-input-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}

.input-with-btn .coord-input-wrap input {
    width: 100%;
}

.poi-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 260px;
    overflow-y: auto;
    min-width: 260px;
    width: max-content;
}

.poi-dropdown.active {
    display: block;
}

.poi-item {
    padding: 7px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-light);
}

.poi-item:last-child {
    border-bottom: none;
}

.poi-item:hover {
    background: var(--primary-light);
}

.poi-item .poi-name {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.poi-item .poi-coord {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.random-btn {
    padding: 0 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.random-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: scale(1.05);
}

.submit-btn {
    padding: 8px 32px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    white-space: nowrap;
    font-family: var(--font);
    box-shadow: 0 2px 6px rgba(59, 91, 219, 0.25);
}

.submit-btn:hover:not(:disabled) {
    background: #364fc7;
    box-shadow: 0 4px 12px rgba(59, 91, 219, 0.35);
    transform: translateY(-1px);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---- Main Content ---- */
.main-content {
    display: flex;
    flex-direction: column;
    max-width: 1100px;
    margin: 24px auto 0;
    gap: 0;
    border-radius: var(--radius);
    overflow: visible;
}

.main-content.has-results {
    box-shadow: none;
    border: none;
}

.main-content.map-visible {
    /* reserved */
}

/* ---- Map Panel ---- */
.map-panel {
    display: flex;
    flex-direction: column;
    background: var(--card);
    min-width: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    background: var(--card);
}

.panel-header h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.map-container {
    flex: 1;
    min-height: 100%;
    background: #eef1f5;
}

.map-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 18px;
    height: 3px;
    border-radius: 2px;
}

.legend-transfer {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #ef4444;
}

/* ---- Result Panel ---- */
.result-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    background: transparent;
    padding: 0;
    gap: 16px;
}

.result-panel.has-content {
    padding: 0;
}

/* Show Route Button */
.show-route-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 12px 24px;
    background: var(--card);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
}

.show-route-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 91, 219, 0.3);
    transform: translateY(-1px);
}

.show-route-btn svg {
    flex-shrink: 0;
}

/* Route Detail Row (Map left + Lines right) */
.route-detail-row {
    display: grid;
    grid-template-columns: 1fr 380px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-height: 520px;
    max-height: 720px;
}

.route-info-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 18px 20px;
    gap: 14px;
    background: var(--card);
    border-left: 1px solid var(--border);
}

/* Route Tabs */
.route-tabs {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
    flex-shrink: 0;
}

.route-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.route-tab:hover {
    color: var(--text);
    background: var(--card);
}

.route-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: var(--card);
}

.route-tab .tab-tag {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.route-tab.active .tab-tag {
    color: var(--primary);
}

/* Route Info */
.route-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Prompt + Output Row */
.prompt-output-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Prompt Display */
.prompt-display {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    min-width: 0;
    max-height: 320px;
    overflow-y: auto;
}

.prompt-display h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

/* Stream Display */
.stream-display {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    min-width: 0;
    display: flex;
    flex-direction: column;
    max-height: 320px;
}

.stream-display h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stream-display .stream-content {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    border: 1px solid var(--border-light);
}

.prompt-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prompt-msg {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.76rem;
    line-height: 1.7;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 180px;
    overflow-y: auto;
}

.prompt-msg-system {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.prompt-msg-user {
    background: var(--primary-light);
    border: 1px solid #bac8ff;
    color: #1c3a8a;
}

.prompt-msg-role {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    opacity: 0.65;
    font-family: var(--font);
}

.info-section {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--border-light);
}

.info-section h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.line-sequence {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.line-badge {
    display: inline-flex;
    align-items: center;
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.line-arrow {
    color: #d1d5db;
    font-size: 0.9rem;
    margin: 0 1px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.info-cell {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.info-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    opacity: 0.5;
}

.info-label {
    display: block;
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.info-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

/* First/Last-Mile Info */
.transfer-info {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--border-light);
}

.transfer-info h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.transfer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 0.88rem;
}

.transfer-label {
    font-weight: 600;
    color: var(--text);
    min-width: 75px;
    font-size: 0.8rem;
}

.transfer-mode {
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.transfer-dist {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
}

/* Route Timeline */
.route-timeline-section {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--border-light);
}

.route-timeline-section h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.timeline-content {
    padding: 4px 0;
}

.tl-node {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 3px 0;
}

.tl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2.5px solid #fff;
    box-shadow: 0 0 0 1.5px #d1d5db;
}

.tl-origin {
    background: #16a34a;
    box-shadow: 0 0 0 1.5px #16a34a;
}

.tl-dest {
    background: #dc2626;
    box-shadow: 0 0 0 1.5px #dc2626;
}

.tl-text {
    font-size: 0.85rem;
    color: var(--text);
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.tl-text strong {
    font-weight: 600;
}

.tl-stations {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 400;
    background: var(--bg);
    padding: 1px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.tl-edge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 0 5px;
    min-height: 30px;
}

.tl-vline {
    width: 3px;
    height: 24px;
    border-radius: 2px;
    flex-shrink: 0;
}

.tl-dashed {
    background: repeating-linear-gradient(to bottom,
            #9ca3af 0px,
            #9ca3af 4px,
            transparent 4px,
            transparent 8px);
}

.tl-transfer {
    background: #ef4444;
}

.tl-edge-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- Model Output (hidden for demo) ---- */
.model-output-section {
    display: none !important;
}

/* Status Badge */
.status-badge {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.status-badge.generating {
    background: #fff3bf;
    color: #e67700;
    border-color: #ffd43b;
    animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.status-badge.done {
    background: #d3f9d8;
    color: #2b8a3e;
    border-color: #69db7c;
}

/* ---- Map Markers ---- */
.custom-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.start-marker {
    background: #16a34a;
}

.end-marker {
    background: #dc2626;
}

/* Transfer label on map */
.transfer-map-label {
    background: rgba(255, 255, 255, 0.92);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    border: 1px solid #d1d5db;
    white-space: nowrap;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .main-content {
        max-width: 100%;
    }

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

    .route-detail-row {
        grid-template-columns: 1fr;
        height: auto;
    }

    .map-panel {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .map-container {
        min-height: 300px;
    }

    .control-row {
        flex-direction: column;
    }

    .control-item {
        width: 100%;
    }

    .result-panel {
        padding: 12px;
    }
}

/* ---- Result Placeholder (before first Plan) ---- */
.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--text-secondary);
    text-align: center;
}

.result-placeholder .placeholder-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.result-placeholder .placeholder-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.result-placeholder .placeholder-text {
    font-size: 0.82rem;
    line-height: 1.5;
}

.main-content.has-results .result-placeholder {
    display: none;
}

/* ---- Usage Guide ---- */
.usage-guide {
    max-width: 1100px;
    margin: 16px auto 40px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px 20px;
    box-shadow: var(--shadow-sm);
}

.guide-header {
    margin-bottom: 16px;
}

.usage-guide .guide-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
    letter-spacing: -0.01em;
}

.usage-guide .guide-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.guide-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.guide-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.guide-step:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(59, 91, 219, 0.08);
    transform: translateY(-1px);
}

.step-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 7px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-icon svg {
    width: 16px;
    height: 16px;
}

.step-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.step-content strong {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

.step-content span {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

@media (max-width: 900px) {
    .guide-steps {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 500px) {
    .guide-steps {
        grid-template-columns: 1fr;
    }
}

/* ---- AMap ContextMenu visual tweaks ---- */
.amap-menu,
.amap-context-menu {
    font-family: var(--font) !important;
    font-size: 13px !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14) !important;
    border: 1px solid var(--border) !important;
    overflow: hidden;
}

.amap-menu .amap-menu-outer,
.amap-menu-outer {
    padding: 4px 0 !important;
}

.amap-menu-outer div {
    padding: 6px 14px !important;
    color: var(--text) !important;
}

.amap-menu-outer div:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}