:root {
  --mode-dark: 0;
  --bg: #e9edf2;
  --ocean: #eef1f5;
  --land-line: rgba(8, 18, 34, 0.8);
  --grid: rgba(40, 70, 110, 0.08);
  --night-fill: rgba(15, 30, 55, 0.14);
  --term: rgba(20, 40, 70, 0.3);
  --zone-op: 0.66;
  --text: #14202e;
  --text-dim: #4c5d72;
  --text-faint: #8090a2;
  --city-name: #243246;
  --card: #ffffff;
  --card-line: rgba(20, 45, 75, 0.16);
  --panel: #ffffff;
  --leader: rgba(20, 45, 75, 0.32);
  --boundary-casing: rgba(238, 241, 245, 0.58);
  --tool-bg: rgba(20, 45, 75, 0.06);
  --tool-line: rgba(20, 45, 75, 0.14);
  --dot-ring: #ffffff;
  --accent: #1763c8;
  --shadow: rgba(35, 55, 85, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Consolas", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --mode-dark: 1; --bg: #090e18; --ocean: #0c1726; --land-line: rgba(234, 245, 255, 0.62); --grid: rgba(150, 180, 210, 0.06);
  --night-fill: rgba(2, 6, 14, 0.32); --term: rgba(255, 255, 255, 0.16); --zone-op: 0.68;
  --text: #eef3f9; --text-dim: #a3b4c8; --text-faint: #6c7f94;
  --city-name: #dbe6f2;
  --card: #15202f; --card-line: rgba(150, 185, 215, 0.2); --panel: #131d2c; --leader: rgba(180, 205, 230, 0.3); --boundary-casing: rgba(12, 23, 38, 0.54);
  --tool-bg: rgba(255, 255, 255, 0.06); --tool-line: rgba(255, 255, 255, 0.11); --dot-ring: rgba(8, 14, 24, 0.9);
  --accent: #ffd27f; --shadow: rgba(0, 0, 0, 0.55);
} }
:root[data-theme="dark"] {
  --mode-dark: 1; --bg: #090e18; --ocean: #0c1726; --land-line: rgba(234, 245, 255, 0.62); --grid: rgba(150, 180, 210, 0.06);
  --night-fill: rgba(2, 6, 14, 0.32); --term: rgba(255, 255, 255, 0.16); --zone-op: 0.68;
  --text: #eef3f9; --text-dim: #a3b4c8; --text-faint: #6c7f94;
  --city-name: #dbe6f2;
  --card: #15202f; --card-line: rgba(150, 185, 215, 0.2); --panel: #131d2c; --leader: rgba(180, 205, 230, 0.3); --boundary-casing: rgba(12, 23, 38, 0.54);
  --tool-bg: rgba(255, 255, 255, 0.06); --tool-line: rgba(255, 255, 255, 0.11); --dot-ring: rgba(8, 14, 24, 0.9);
  --accent: #ffd27f; --shadow: rgba(0, 0, 0, 0.55);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.map .ocean { fill: var(--ocean); }
.map .grat { stroke: var(--grid); }
.map .land-casing { fill: none; stroke: var(--boundary-casing); }
.map .land { fill: none; stroke: var(--land-line); }
.map .zone { fill-opacity: var(--zone-op); stroke-linejoin: round; stroke-linecap: round; }
.map .night { fill: var(--night-fill); }
.map .term { stroke: var(--term); }
.map .zone, .map .land-casing, .map .land, .map .grat, .map .night, .map .term, #sun { pointer-events: none; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--tool-line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.clocks { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
.clock { display: flex; flex-direction: column; line-height: 1.15; }
.clock .lab { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); }
.clock .val { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.clock .sub { font-size: 10px; color: var(--text-dim); }
.tools { display: flex; gap: 8px; }
.tools button { background: var(--tool-bg); color: var(--text-dim); border: 1px solid var(--tool-line); border-radius: 8px; height: 32px; min-width: 36px; padding: 0 11px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tools button:hover { color: var(--text); }
.tools button.on { color: var(--accent); border-color: var(--accent); }

/* ---------- stage ---------- */
.stage-wrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.stage { position: relative; overflow: hidden; border-radius: 14px; background: var(--ocean); box-shadow: 0 10px 50px var(--shadow); cursor: grab; touch-action: none; }
.stage.grabbing { cursor: grabbing; }
.stage svg.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transform-origin: 0 0; }
.map .land-casing, .map .land, .map .term, .map .zone { vector-effect: non-scaling-stroke; shape-rendering: geometricPrecision; }
.leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.leaders path { fill: none; stroke: var(--leader); stroke-width: 1; }

/* ---------- top UTC ruler ---------- */
.ruler { position: absolute; top: 0; left: 0; right: 0; height: 22px; pointer-events: none; z-index: 6; }
.rlab { position: absolute; top: 3px; left: 0; font-family: var(--mono); font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: 4px; white-space: nowrap; background: var(--panel); border: 1px solid var(--card-line); }

/* ---------- cluster cards ---------- */
.cards { position: absolute; inset: 0; pointer-events: none; }
.card { position: absolute; left: 0; top: 0; background: var(--card); border: 1px solid var(--card-line); border-radius: 9px; padding: 5px 9px 6px; pointer-events: auto; cursor: pointer; min-width: 60px; }
.card:hover { border-color: var(--accent); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .time { font-family: var(--mono); font-size: 17px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.card .meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.card .off { font-family: var(--mono); font-size: 10px; font-weight: 700; }
.card .ph { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.card .lead { font-size: 11px; color: var(--city-name); font-weight: 600; margin-top: 2px; white-space: nowrap; }

.tip { position: absolute; left: 0; top: 0; background: var(--panel); border: 1px solid var(--card-line); color: var(--text); font-size: 11px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; display: none; z-index: 20; box-shadow: 0 4px 16px var(--shadow); }
.tip b { color: var(--city-name); font-weight: 700; } .tip .t { font-family: var(--mono); font-weight: 700; margin-left: 6px; }

.pop { position: absolute; left: 0; top: 0; z-index: 30; background: var(--panel); border: 1px solid var(--card-line); border-radius: 12px; padding: 11px 13px; min-width: 200px; max-width: 280px; box-shadow: 0 12px 40px var(--shadow); display: none; }
.pop .hd { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.pop .hd .t { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.pop .hd .o { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.pop .hd .d { font-size: 11px; color: var(--text-dim); margin-left: auto; }
.pop ul { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; }
.pop li { font-size: 12px; color: var(--city-name); background: var(--tool-bg); border-radius: 20px; padding: 2px 9px; }
.pop .delta { margin-top: 8px; font-size: 11px; color: var(--text-dim); }

.reset { position: absolute; right: 12px; bottom: 12px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px; background: var(--panel); color: var(--text); border: 1px solid var(--card-line); display: flex; align-items: center; justify-content: center; z-index: 15; }
.reset:hover { border-color: var(--accent); }
.hint { position: absolute; left: 12px; bottom: 12px; font-size: 11px; color: var(--text-faint); z-index: 15; }

/* ---------- drawer ---------- */
.drawer { position: absolute; top: 0; right: 0; height: 100%; width: 300px; max-width: 82vw; background: var(--panel); border-left: 1px solid var(--tool-line); transform: translateX(100%); transition: transform .2s ease; z-index: 40; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer h3 { font-size: 13px; padding: 14px 16px; border-bottom: 1px solid var(--tool-line); display: flex; align-items: center; }
.drawer h3 .x { margin-left: auto; cursor: pointer; color: var(--text-dim); }
.drawer .body { overflow-y: auto; padding: 8px; }
.lane { padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.lane:hover { background: var(--tool-bg); }
.lane .top { display: flex; align-items: center; gap: 8px; }
.lane .lt { font-family: var(--mono); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lane .lo { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.lane .pd { width: 9px; height: 9px; border-radius: 2px; }
.lane .ld { font-size: 11px; color: var(--text-dim); margin-left: auto; }
.lane .lc { font-size: 11px; color: var(--city-name); margin-top: 3px; line-height: 1.5; }

@media (max-width: 620px) {
  .topbar { position: relative; padding: 6px 8px 7px; gap: 6px 8px; flex-wrap: wrap; align-items: center; }
  .brand span.full { display: none; }
  .clocks { order: 2; flex: 0 0 100%; min-width: 0; gap: 28px; margin-left: 0; justify-content: flex-start; padding: 0 4px; }
  .clocks .clock:nth-child(2) { display: none; }
  .clock .val { font-size: 13px; }
  .clock .lab { font-size: 9px; letter-spacing: .45px; }
  .clock .sub { display: none; }
  .tools { position: absolute; top: 6px; left: 160px; width: 112px; height: 28px; display: block; margin-left: 0; }
  .tools button { position: absolute; top: 0; min-width: 30px; height: 28px; padding: 0 7px; font-size: 12px; border-radius: 7px; }
  #themeBtn { left: 0; }
  #fmtBtn { left: 36px; }
  #listBtn { left: 70px; }
  .stage-wrap { align-items: stretch; justify-content: stretch; }
  .stage { border-radius: 0; box-shadow: none; }
  .rlab { font-size: 9px; padding: 2px 4px; }
  .card { border-radius: 8px; min-width: 54px; padding: 4px 7px 5px; }
  .card .time { font-size: 15px; }
  .card .off { font-size: 9px; }
  .card .ph { width: 8px; height: 8px; }
  .card .lead { font-size: 10.5px; }
  .pop { max-width: calc(100vw - 24px); }
  .reset { right: 10px; bottom: calc(env(safe-area-inset-bottom) + 10px); }
  .hint { display: none; }
  .drawer { top: auto; bottom: 0; height: min(72vh, 560px); width: 100vw; max-width: 100vw; border-left: 0; border-top: 1px solid var(--tool-line); border-radius: 12px 12px 0 0; transform: translateY(100%); }
  .drawer.open { transform: translateY(0); }
}
