:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e4e2dc;
  --sea: #e9eef2;
  --a: #2563eb;
  --a-soft: #dbe6fd;
  --b: #e8590c;
  --b-soft: #fde4d4;
  --cut: #111;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --panel: #1c1d20;
    --ink: #ececee;
    --muted: #9a9aa2;
    --line: #2e2f33;
    --sea: #101418;
    --a: #6b9cff;
    --a-soft: #1d2a47;
    --b: #ff8a4c;
    --b-soft: #45261a;
    --cut: #fff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.layout { display: grid; grid-template-columns: 380px 1fr; height: 100vh; height: 100dvh; }

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: .02em; }
h2 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
.lede { margin: 0; color: var(--muted); font-size: 14px; }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side { border-radius: 12px; padding: 12px 14px; }
.side-a { background: var(--a-soft); }
.side-b { background: var(--b-soft); }
.side-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.side-a .swatch { background: var(--a); }
.side-b .swatch { background: var(--b); }
.big { font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.side-a .big { color: var(--a); }
.side-b .big { color: var(--b); }
.sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
dl { margin: 8px 0 0; display: grid; gap: 2px; font-size: 13px; }
dl div { display: flex; justify-content: space-between; gap: 6px; }
dt { color: var(--muted); white-space: nowrap; }
dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; font-size: 12px; color: var(--muted); }
.bar { height: 10px; border-radius: 5px; background: var(--b); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--a); transition: width .12s; }

.headline { margin: 0; font-size: 15px; padding: 10px 12px; border-left: 3px solid var(--ink); background: var(--bg); border-radius: 0 8px 8px 0; }
.headline:empty { display: none; }
.headline b.a { color: var(--a); }
.headline b.b { color: var(--b); }

.controls { display: grid; gap: 12px; }
.angle { display: grid; grid-template-columns: auto 1fr 48px; align-items: center; gap: 10px; font-size: 14px; }
.angle output { text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--ink); }
.buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
button {
  font: inherit; font-size: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 8px 6px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { grid-column: 1 / -1; background: var(--ink); color: var(--panel); border-color: var(--ink); font-weight: 500; }
button:disabled { opacity: .6; cursor: progress; }
.check { font-size: 14px; display: flex; gap: 6px; align-items: center; color: var(--muted); }

.crossed ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.crossed li { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; font-size: 13px; }
.crossed .mini { height: 6px; border-radius: 3px; background: var(--b); overflow: hidden; }
.crossed .mini i { display: block; height: 100%; background: var(--a); }
.crossed .none { color: var(--muted); display: block; }

footer { margin-top: auto; font-size: 12px; color: var(--muted); }
footer p { margin: 4px 0; }
footer a { color: inherit; }

.map { position: relative; overflow: hidden; background: var(--sea); touch-action: none; cursor: grab; }
.map.panning { cursor: grabbing; }
.map canvas, .map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map svg { pointer-events: none; }
.line { stroke: var(--cut); stroke-width: 2.5; stroke-dasharray: 10 6; }
.line-hit { stroke: transparent; stroke-width: 26; pointer-events: stroke; cursor: move; }
.knob { fill: var(--panel); stroke: var(--cut); stroke-width: 2.5; pointer-events: all; cursor: grab; }
.knob:hover { fill: var(--cut); }
.map-label { font-size: 15px; font-weight: 700; paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.map-label.a { fill: var(--a); }
.map-label.b { fill: var(--b); }

.zoom { position: absolute; right: 14px; top: 14px; display: grid; gap: 6px; }
.zoom button { width: 36px; height: 36px; padding: 0; font-size: 18px; box-shadow: var(--shadow); }

.tooltip {
  position: absolute; pointer-events: none; background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap;
  transform: translate(12px, 12px);
}
.tooltip b { display: block; }

.legend {
  position: absolute; left: 14px; bottom: 14px; background: var(--panel); border-radius: 8px;
  padding: 8px 10px; font-size: 11px; color: var(--muted); box-shadow: var(--shadow);
}
.legend .row { display: flex; gap: 2px; margin-top: 4px; }
.legend .cell { width: 26px; text-align: center; }
.legend .cell i { display: block; height: 8px; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--sea); }
.loading[hidden] { display: none; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 58vh auto; height: auto; }
  .map { order: -1; height: 58vh; }
  .panel { border-right: 0; padding: 18px 16px 28px; }
  .big { font-size: 26px; }
  .legend { display: none; }
}
