:root {
    color-scheme: dark;
    --bg: #060d14;
    --bg-soft: #0b1826;
    --panel: rgba(10, 18, 28, 0.92);
    --panel-strong: rgba(6, 12, 20, 0.98);
    --text: #eef4ff;
    --muted: #9db4cf;
    --line: rgba(137, 161, 191, 0.15);
    --line-strong: rgba(137, 161, 191, 0.25);
    --cyan: #00d8ff;
    --teal: #55efc4;
    --amber: #ffb74d;
    --red: #ff6b6b;
    --green: #69f0ae;
    --blue: #64b5f6;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(0, 216, 255, 0.08), transparent 28%),
        radial-gradient(circle at top right, rgba(100, 181, 246, 0.12), transparent 30%),
        linear-gradient(180deg, #02070d, #07111a 45%, #08121c);
    color: var(--text);
    font-family: "Space Grotesk", "Noto Sans TC", sans-serif;
}

body {
    padding: 24px;
}

button,
input,
select {
    font: inherit;
}

.page-shell {
    max-width: 1640px;
    margin: 0 auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.topbar h1,
.map-panel-head h2,
.timeline-header h3,
.panel-header h3 {
    margin: 0;
}

.topbar p,
.table-caption,
.overlay-subtext,
.mini-label,
.chat-label,
.timeline-meta,
.focus-meta,
.message-meta {
    color: var(--muted);
}

.eyebrow,
.mini-label,
.overlay-label,
.legend-title {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 12px;
}

.topbar-actions,
.timeline-actions,
.chip-row,
.tab-buttons,
.status-pills,
.suggestion-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.primary-button,
.ghost-button,
.chip,
.tab-button,
.suggestion-chip,
.plan-card,
.scenario-row-button {
    border: 0;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.primary-button,
.ghost-button {
    padding: 11px 16px;
    border-radius: 999px;
}

.primary-button {
    background: linear-gradient(135deg, #00d8ff, #55efc4);
    color: #04202a;
    font-weight: 700;
    box-shadow: 0 18px 30px -20px rgba(85, 239, 196, 0.9);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border: 1px solid var(--line);
    text-decoration: none;
}

.small {
    padding: 8px 12px;
}

.primary-button:hover,
.ghost-button:hover,
.chip:hover,
.tab-button:hover,
.suggestion-chip:hover,
.plan-card:hover,
.scenario-row-button:hover {
    transform: translateY(-1px);
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 460px;
    gap: 18px;
    min-height: calc(100vh - 140px);
}

.map-panel,
.side-panel {
    background: var(--panel);
    border-radius: 28px;
    border: 1px solid var(--line);
    overflow: hidden;
    box-shadow: 0 40px 80px -60px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(18px);
}

.map-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.map-panel-head,
.timeline-header,
.panel-header,
.focus-head,
.focus-footer,
.timeline-meta,
.chat-composer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.status-pill,
.chip {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.05);
}

.neutral {
    color: var(--cyan);
    border-color: rgba(0, 216, 255, 0.2);
}

.risk-mid {
    color: var(--amber);
    border-color: rgba(255, 183, 77, 0.22);
}

.risk-high {
    color: var(--red);
    border-color: rgba(255, 107, 107, 0.22);
}

.map-stage {
    position: relative;
    flex: 1;
    min-height: 620px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#map {
    height: 100%;
    width: 100%;
    background: #02060c;
}

.map-overlay {
    position: absolute;
    z-index: 500;
    display: flex;
    gap: 12px;
}

.overlay-stack {
    flex-direction: column;
}

.top-left {
    top: 16px;
    left: 16px;
}

.top-right {
    top: 16px;
    right: 16px;
}

.bottom-left {
    bottom: 16px;
    left: 16px;
}

.overlay-card,
.legend-card,
.timeline-card,
.panel-block,
.chat-form {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 22px;
}

.overlay-card,
.legend-card {
    padding: 14px 16px;
    min-width: 220px;
}

.overlay-card.compact {
    min-width: 210px;
}

.overlay-value {
    margin-top: 4px;
    font-size: 1.06rem;
    font-weight: 700;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    margin-top: 8px;
}

.legend-dot,
.legend-line {
    display: inline-block;
    flex: 0 0 auto;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.legend-dot.vessel {
    background: linear-gradient(135deg, #67e8f9, #60a5fa);
}

.legend-dot.typhoon {
    background: radial-gradient(circle at 30% 30%, #ffd4d1, #ff8a80 55%, #ef5350);
}

.legend-line {
    width: 28px;
    height: 0;
    border-top: 3px solid transparent;
}

.legend-line.observed {
    border-top-color: #ffffff;
}

.legend-line.forecast {
    border-top-color: #ff8a80;
    border-top-style: dashed;
}

.legend-line.route {
    border-top-color: #64b5f6;
}

.legend-line.detour {
    border-top-color: #55efc4;
}

.timeline-card {
    padding: 18px;
}

#timelineSlider {
    width: 100%;
    margin: 18px 0 12px;
    accent-color: var(--cyan);
}

.chip {
    color: var(--muted);
    border-color: rgba(255, 255, 255, 0.06);
}

.chip.active {
    background: rgba(0, 216, 255, 0.12);
    color: var(--cyan);
    border-color: rgba(0, 216, 255, 0.24);
}

.speed-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.speed-select select {
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 8px 10px;
}

.side-panel {
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    padding: 18px 18px 0;
}

.tab-button {
    flex: 1;
    padding: 12px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.tab-button.active {
    background: rgba(0, 216, 255, 0.12);
    color: var(--text);
    border-color: rgba(0, 216, 255, 0.24);
}

.tab-panel {
    display: none;
    padding: 18px;
    height: 100%;
    overflow: auto;
}

.tab-panel.active {
    display: block;
}

.stats-grid,
.plan-grid,
.focus-metrics,
.inline-metrics {
    display: grid;
    gap: 12px;
}

.stats-grid,
.focus-metrics,
.inline-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.metric-card,
.inline-metric,
.plan-card {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 6px 0 4px;
}

.panel-block {
    padding: 16px;
    margin-top: 14px;
}

.panel-block-tight {
    margin-top: 0;
}

.demo-intro {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(0, 216, 255, 0.08), rgba(100, 181, 246, 0.08));
    border: 1px solid rgba(0, 216, 255, 0.14);
}

.demo-intro p {
    margin: 0;
    color: var(--text);
    line-height: 1.65;
}

.demo-bullets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.demo-bullets span {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 12px;
}

.table-shell {
    margin-top: 12px;
    overflow: auto;
}

.data-table,
.inner-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td,
.inner-table th,
.inner-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
    font-size: 0.9rem;
    vertical-align: top;
}

.data-table th,
.inner-table th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.scenario-row-button {
    width: 100%;
    padding: 0;
    text-align: left;
    background: none;
    color: inherit;
}

.risk-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.risk-tag.low {
    color: var(--green);
    background: rgba(105, 240, 174, 0.12);
}

.risk-tag.medium {
    color: var(--amber);
    background: rgba(255, 183, 77, 0.12);
}

.risk-tag.high,
.risk-tag.extreme {
    color: var(--red);
    background: rgba(255, 107, 107, 0.12);
}

.focus-card {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.metric-card strong,
.inline-metric strong {
    display: block;
    margin-top: 6px;
    font-size: 1.02rem;
}

.focus-footer {
    color: var(--muted);
    font-size: 13px;
}

.plan-card {
    text-align: left;
    color: inherit;
}

.plan-card.active {
    border-color: rgba(0, 216, 255, 0.24);
    background: rgba(0, 216, 255, 0.1);
}

.plan-card h4 {
    margin: 0 0 8px;
}

.plan-card p {
    margin: 0 0 10px;
    color: var(--muted);
    line-height: 1.6;
}

.plan-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.html-block {
    margin-top: 14px;
    padding: 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #d5e6f8;
}

.html-block h3 {
    margin-top: 0;
}

.html-block ul {
    padding-left: 20px;
    margin: 12px 0 0;
}

.html-block li {
    margin-top: 8px;
    line-height: 1.6;
}

.suggestion-row {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.suggestion-chip {
    border-radius: 18px;
    padding: 12px 14px;
    min-height: 72px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text);
    text-align: left;
    line-height: 1.45;
}

.suggestion-chip strong {
    display: block;
    margin-bottom: 4px;
    color: var(--cyan);
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.suggestion-chip span {
    display: block;
}

.chat-shell {
    display: grid;
    gap: 12px;
    margin-top: 14px;
    margin-bottom: 14px;
    max-height: calc(100vh - 410px);
    overflow: auto;
    padding-right: 4px;
}

.chat-message {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-message.user {
    background: rgba(100, 181, 246, 0.12);
}

.chat-message.assistant {
    background: rgba(255, 255, 255, 0.04);
}

.chat-message p {
    margin: 0;
    line-height: 1.65;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    margin-bottom: 10px;
}

.chat-table,
.inline-metrics {
    margin-top: 12px;
}

.chat-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.chat-table th,
.chat-table td {
    padding: 8px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.chat-form {
    padding: 16px;
    position: sticky;
    bottom: 0;
}

.chat-composer {
    margin-top: 10px;
}

.chat-composer input {
    flex: 1;
    min-width: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 12px 14px;
}

.leaflet-control-zoom a {
    background: rgba(6, 12, 20, 0.94);
    color: var(--text);
    border-bottom-color: var(--line);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: rgba(8, 16, 26, 0.98);
    color: var(--text);
}

.leaflet-control-attribution {
    background: rgba(6, 12, 20, 0.88) !important;
    color: var(--muted);
}

.typhoon-marker,
.vessel-marker,
.waypoint-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.typhoon-marker {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: radial-gradient(circle at 30% 30%, #ffd4d1, #ff8a80 55%, #ef5350);
    box-shadow: 0 0 0 12px rgba(255, 107, 107, 0.08);
}

.vessel-marker {
    width: 26px;
    height: 26px;
}

.vessel-marker::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-bottom: 22px solid #6ee7ff;
    filter: drop-shadow(0 0 8px rgba(110, 231, 255, 0.5));
}

.waypoint-marker {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(100, 181, 246, 0.18);
    border: 1px solid rgba(100, 181, 246, 0.65);
    color: #dff3ff;
    font-size: 10px;
    font-weight: 700;
}

@media (max-width: 1360px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .chat-shell {
        max-height: 520px;
    }
}

@media (max-width: 900px) {
    body {
        padding: 16px;
    }

    .topbar,
    .map-panel-head,
    .timeline-header,
    .timeline-meta,
    .panel-header,
    .focus-head,
    .focus-footer,
    .chat-composer {
        flex-direction: column;
    }

    .stats-grid,
    .focus-metrics,
    .inline-metrics,
    .suggestion-row {
        grid-template-columns: 1fr;
    }

    .map-stage {
        min-height: 500px;
    }

    .top-right {
        right: auto;
        left: 16px;
        top: 160px;
    }
}
