/* MapBay — clean light design system (devbay family, sky accent) */
:root {
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --text: #0f172a;
    --text-dim: #64748b;
    --text-faint: #94a3b8;
    --card: #ffffff;
    --card-strong: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent-1: #0284c7;
    --accent-2: #0369a1;
    --accent-3: #38bdf8;
    --accent-soft: rgba(2, 132, 199, 0.08);
    --good: #10b981;
    --good-soft: rgba(16, 185, 129, 0.1);
    --warn: #d97706;
    --warn-soft: rgba(245, 158, 11, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.08);
    --radius: 0.625rem;
    --shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 4px 12px 0 rgba(15, 23, 42, 0.08);
    --map-sea: #eaf2f9;
    --map-sea-border: #c9d8e4;
    --map-land: #dfe7ee;
    --map-land-stroke: #b9c8d5;
    --map-graticule: rgba(15, 23, 42, 0.16);
    --map-tissot: rgba(2, 132, 199, 0.3);
    --map-tissot-stroke: #0284c7;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --card: #1e293b;
    --card-strong: #0f172a;
    --border: #334155;
    --border-strong: #475569;
    --accent-1: #38bdf8;
    --accent-2: #0ea5e9;
    --accent-3: #7dd3fc;
    --accent-soft: rgba(56, 189, 248, 0.14);
    --good: #34d399;
    --good-soft: rgba(52, 211, 153, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.1);
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
    --map-sea: #111c29;
    --map-sea-border: #33465c;
    --map-land: #233447;
    --map-land-stroke: #3d5269;
    --map-graticule: rgba(226, 232, 240, 0.14);
    --map-tissot: rgba(56, 189, 248, 0.32);
    --map-tissot-stroke: #38bdf8;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

:focus-visible { outline: 2px solid var(--accent-3); outline-offset: 2px; }

.tool-container { width: min(1280px, 94vw); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-logo { display: flex; }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent-1); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 0.5rem;
    background: var(--card); border: 1px solid var(--border);
    color: var(--text-dim); cursor: pointer; transition: all 0.15s ease;
    font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.lang-select {
    appearance: none; -webkit-appearance: none;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 0.5rem; color: var(--text-dim);
    font-family: inherit; font-size: 0.8rem; font-weight: 600;
    padding: 8px 28px 8px 12px; cursor: pointer; transition: all 0.15s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.lang-select:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- page head ---------- */
.page-head { padding: 36px 0 18px; max-width: 860px; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 900; letter-spacing: -0.025em; line-height: 1.2; }
.page-sub { color: var(--text-dim); margin-top: 8px; font-size: 0.98rem; }

/* ---------- explorer layout ---------- */
.explorer {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr) 316px;
    grid-template-areas: "rail stage info";
    gap: 16px;
    align-items: start;
    padding-bottom: 40px;
}
.rail { grid-area: rail; padding: 14px 12px; position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; }
.stage { grid-area: stage; padding: 14px 14px 12px; }
.info { grid-area: info; position: sticky; top: 80px; }

.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- rail (projection picker) ---------- */
.rail-title {
    font-size: 0.78rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-faint);
    padding: 2px 8px 8px;
}
.proj-list { display: flex; flex-direction: column; gap: 2px; }
.rail-fam {
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-faint);
    padding: 12px 8px 3px;
}
.rail-fam:first-child { padding-top: 4px; }
.rail-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%; border: 1px solid transparent; background: transparent;
    border-radius: 0.5rem; padding: 4px 8px; text-align: left;
    font-family: inherit; font-size: 0.86rem; font-weight: 600;
    color: var(--text-dim); cursor: pointer; transition: all 0.12s ease;
}
.rail-item:hover { background: var(--bg-soft); color: var(--text); }
.rail-item.active { background: var(--accent-soft); color: var(--accent-1); border-color: rgba(2, 132, 199, 0.18); }
[data-theme="dark"] .rail-item.active { border-color: rgba(56, 189, 248, 0.25); }
.rail-item svg { flex: 0 0 auto; border-radius: 3px; display: block; }
.rail-item svg .thumb-sphere { fill: none; stroke: currentColor; stroke-width: 0.9; opacity: 0.55; }
.rail-item svg .thumb-land { fill: currentColor; stroke: none; opacity: 0.9; }
.rail-item span { line-height: 1.25; }

/* ---------- stage ---------- */
.stage-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
    padding: 2px 2px 10px;
}
.stage-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.current-chip {
    display: inline-block; padding: 3px 11px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent-1);
    font-size: 0.8rem; font-weight: 800; white-space: nowrap;
}
.stage-hint { font-size: 0.78rem; color: var(--text-faint); }
.stage-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-label { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }
.switch:hover .switch-label { color: var(--text); }
.track {
    position: relative; width: 32px; height: 18px; border-radius: 999px;
    background: var(--border-strong); transition: background 0.15s ease; flex: 0 0 auto;
}
.track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
    transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--accent-1); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-3); outline-offset: 2px; }

.btn {
    border: 1px solid var(--border); background: var(--card);
    border-radius: 0.5rem; padding: 6px 14px;
    font-family: inherit; font-size: 0.82rem; font-weight: 600;
    color: var(--text-dim); cursor: pointer; transition: all 0.15s ease;
}
.btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }

.map-stage {
    position: relative; height: clamp(400px, 58vh, 580px);
    border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px);
    background: var(--bg-soft); overflow: hidden;
}
.map-stage svg { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.map-stage.dragging svg { cursor: grabbing; }
.map-stage .map-land { fill: var(--map-land); stroke: var(--map-land-stroke); stroke-width: 0.5px; }
.map-stage .map-graticule { fill: none; stroke: var(--map-graticule); stroke-width: 1px; }
.map-stage .map-tissot { fill: var(--map-tissot); stroke: var(--map-tissot-stroke); stroke-width: 0.75px; }
.map-stage .map-sphere { fill: var(--map-sea); stroke: var(--map-sea-border); stroke-width: 1.5px; }
.map-stage .map-status {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    gap: 10px; color: var(--text-faint); font-size: 0.9rem; font-weight: 600;
}
.spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--accent-1);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-legend {
    font-size: 0.74rem; color: var(--text-faint); line-height: 1.6;
    padding: 8px 4px 0;
}

/* ---------- info panel ---------- */
.info { padding: 18px 18px 16px; }
.info-name { font-size: 1.18rem; font-weight: 800; letter-spacing: -0.015em; line-height: 1.3; }
.info-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.info-tags .tag {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    background: var(--bg-soft); border: 1px solid var(--border);
    font-size: 0.74rem; font-weight: 700; color: var(--text-dim);
}
.info-tags .tag.tag-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-1); }
.info-label {
    font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 8px;
}
.info-desc { font-size: 0.88rem; color: var(--text-dim); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 8px; background: var(--card); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 26px 0; }
.footer-tag { font-size: 0.85rem; color: var(--text-dim); margin-top: 4px; max-width: 560px; }
.footer-meta { font-size: 0.78rem; color: var(--text-faint); max-width: 420px; text-align: right; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
    .explorer {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "stage" "rail" "info";
        gap: 14px;
    }
    .rail { position: static; max-height: none; padding: 12px 12px 10px; }
    .proj-list {
        flex-direction: row; overflow-x: auto; gap: 6px;
        padding-bottom: 2px; scrollbar-width: thin;
    }
    .rail-fam, .rail-title { display: none; }
    .rail-item {
        flex: 0 0 auto; width: auto;
        border: 1px solid var(--border); background: var(--card);
        padding: 6px 12px;
    }
    .rail-item svg { display: none; }
    .info { position: static; }
}
@media (max-width: 720px) {
    .nav { height: auto; flex-wrap: wrap; padding: 10px 0; }
    .page-head { padding: 24px 0 14px; }
    .map-stage { height: 62vw; min-height: 320px; max-height: 480px; }
    .stage-bar { flex-direction: column; align-items: flex-start; }
    .stage-hint { display: none; }
    .footer-inner { flex-direction: column; text-align: center; }
    .footer-meta { text-align: center; }
}
