:root {
  --bg: #eef3f9;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --navy: #0b1b33;
  --navy-2: #13294b;
  --accent: #2563eb;
  --accent-soft: #e0eaff;
  --ice: #38bdf8;
  --phi: #f97316;
  --ok: #059669;
  --ok-soft: #e7f8f1;
  --warn: #b45309;
  --warn-soft: #fff6e5;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
  --font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.45); outline-offset: 2px; }
.nowrap { white-space: nowrap; }

/* ---------- header & nav ---------- */
.app-header {
  background: radial-gradient(120% 140% at 100% 0%, #1d3d6e 0%, var(--navy) 55%);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; color: #fff; flex: none; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.04em; line-height: 1.2; }
.tagline { margin: 2px 0 0; font-size: 12.5px; color: #a9bddb; letter-spacing: 0.08em; }
.current-board {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-width: 0;
}
.cb-label { font-size: 12px; color: #a9bddb; flex: none; }
.cb-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(11, 27, 51, 0.94);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  padding: 6px 10px 8px;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.section-nav a {
  text-align: center;
  text-decoration: none;
  color: #a9bddb;
  font-weight: 600;
  font-size: 14px;
  padding: 7px 0;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
}
.section-nav a.active { background: rgba(56, 189, 248, 0.16); color: #fff; }

/* ---------- layout & cards ---------- */
.layout {
  display: grid;
  gap: 14px;
  padding: 14px 12px calc(24px + var(--safe-b));
  max-width: 1240px;
  margin: 0 auto;
}
.col { display: contents; }
#board { order: 1; }
#track { order: 2; }
#angles { order: 3; }
#boot { order: 4; }
#about { order: 5; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  min-width: 0;
}
.card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.step {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  background: var(--accent-soft);
}
.card h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- segmented ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: #eef2f7;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 9px 10px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented button[aria-selected="true"],
.segmented button[aria-checked="true"] {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}
.segmented.small { margin: 0; padding: 3px; }
.segmented.small button { padding: 5px 12px; font-size: 14px; }

/* ---------- search ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line-2);
  border-radius: 14px;
  padding: 0 12px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; padding: 13px 0; width: 100%; font-size: 16px; background: transparent; min-width: 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 2px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.quick { margin: 12px 0 4px; }
.chip {
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"], .chip.on {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.chip small { opacity: 0.7; font-weight: 500; margin-left: 2px; }

/* ---------- results ---------- */
.db-status {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #f6f8fb;
  color: var(--ink-2);
  font-size: 14px;
}
.db-status.error { background: var(--bad-soft); color: #7f1d1d; }
.db-status .btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #e9eef5 25%, #f6f8fb 50%, #e9eef5 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.results { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.results:empty { display: none; }
.result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s, background 0.15s;
}
.result:hover { border-color: var(--accent); background: #f8fbff; }
.result.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.result .r-name { font-weight: 600; }
.result .r-brand { color: var(--muted); font-weight: 500; margin-right: 4px; }
.result .r-meta { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.result .r-size { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.approx { font-size: 11.5px; color: var(--warn); font-weight: 600; }

/* ---------- board detail ---------- */
.board-detail { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.bd-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.bd-title { margin: 0; font-size: 20px; line-height: 1.25; }
.bd-title .brand-name { display: block; font-size: 12.5px; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
.bd-desc { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  background: #eef2f7;
  color: var(--ink-2);
}
.badge.jp { background: #fde8ec; color: #be123c; }
.badge.west { background: #e0eaff; color: #1d4ed8; }
.badge.unverified { background: #fff1d6; color: #92400e; }
.badge.official { background: var(--ok-soft); color: var(--ok); }
.badge.retail { background: #e0eaff; color: #1d4ed8; }
.badge.third { background: #f3e8ff; color: #7e22ce; }
.badge.manual { background: #eef2f7; color: var(--ink-2); }

.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.size-row { margin: 14px 0 4px; }
.size-row .label { display: block; margin-bottom: 8px; }
.size-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }

.specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.spec {
  background: #f6f8fb;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  min-width: 0;
}
.spec .k { display: block; font-size: 12px; color: var(--muted); }
.spec .v { display: block; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.35; }
.spec .v small { font-weight: 500; color: var(--muted); font-size: 12px; }
.spec.wide { grid-column: 1 / -1; }
.spec .v.text { font-size: 14px; font-weight: 600; }

.radius-pick { margin: 4px 0 12px; }
.radius-pick .label { display: block; margin-bottom: 8px; }
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

.sources { margin-top: 14px; }
.sources h4 { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.sources h4 span { font-weight: 500; color: var(--muted); }
.sources ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sources li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.sources a { overflow-wrap: anywhere; text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.sources .url { display: block; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }

details.raw { margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
details.raw summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details.raw code { display: block; white-space: pre-wrap; background: #f6f8fb; border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 12px; overflow-wrap: anywhere; }

/* ---------- manual form ---------- */
.manual-grid, .boot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 12px; }
.field small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.field small.assume { color: #92400e; background: #fff1d6; border-radius: 999px; padding: 1px 6px; }
.field input {
  width: 100%;
  border: 1.5px solid var(--line-2);
  border-radius: 11px;
  padding: 10px 11px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  background: #fff;
}
.field input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.field-hint { line-height: 1.4; }
.copy-board { width: 100%; margin-bottom: 12px; padding: 10px 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-error { margin: 4px 0 0; color: var(--bad); font-size: 13px; font-weight: 600; }

/* ---------- stage ---------- */
.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #eef4fb;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 5;
  max-height: 72vh;
  width: 100%;
}
.stage canvas { width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.stage canvas.grabbing { cursor: grabbing; }
.zoom-controls { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.icon-btn:disabled, .pill-btn:disabled { opacity: 0.45; cursor: default; }
.stage-hint { margin: 6px 2px 0; font-size: 12px; }
.hud {
  position: absolute;
  left: 10px;
  top: 10px;
  display: grid;
  gap: 5px;
  justify-items: start;
  pointer-events: none;
}
.hud > div {
  background: rgba(11, 27, 51, 0.82);
  color: #fff;
  border-radius: 10px;
  padding: 4px 9px;
  font-size: 13px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.hud span { color: #a9bddb; font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.hud b { font-weight: 700; }
.hud .hud-phase { background: rgba(249, 115, 22, 0.92); font-weight: 600; }
.hud .hud-edge { font-weight: 700; transition: background 0.15s; }
.hud .hud-edge.on { background: rgba(185, 28, 28, 0.92); }
.hud .hud-edge.grow { background: rgba(220, 38, 38, 0.72); }
.hud .hud-edge.fade { background: rgba(100, 116, 139, 0.9); }
.stage-controls { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.icon-btn, .pill-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
  border-radius: 999px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn { width: 36px; }
.icon-btn svg { width: 18px; height: 18px; fill: var(--navy); }
.icon-btn[aria-pressed="true"] .i-play, .icon-btn[aria-pressed="false"] .i-pause { display: none; }
.pill-btn { padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--navy); }
.pill-btn[aria-pressed="true"] { background: var(--navy); color: #fff; }

.legend { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 10px; margin: 12px 2px 14px; font-size: 12.5px; color: var(--muted); }
.legend-label { grid-row: span 2; }
.ramp { height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgb(14, 165, 233), rgb(99, 102, 241), rgb(249, 115, 22)); }
.legend-ends { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
#stance-seg button small { margin-left: 4px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
#stance-seg { margin-bottom: 10px; }

/* ---------- edge engagement ---------- */
.edge-panel { margin-top: 10px; padding: 10px 12px 4px; border-radius: 14px; background: #f8fafd; border: 1px solid var(--line); }
.edge-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.edge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13.5px;
  font-weight: 700;
  background: #eef2f7;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.edge-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.edge-chip.on { background: var(--bad-soft); color: #991b1b; }
.edge-chip.on::before { background: #b91c1c; }
.edge-chip.grow { background: #fff1f1; color: #b91c1c; }
.edge-chip.grow::before { background: linear-gradient(90deg, #b91c1c, #fca5a5); }
.edge-chip.fade { background: #eef2f7; color: var(--ink-2); }
.edge-chip.fade::before { background: linear-gradient(90deg, #fca5a5, #e2e8f0); }
.edge-turn { font-size: 12.5px; color: var(--muted); text-align: right; }
.edge-canvas { display: block; width: 100%; height: 150px; margin-top: 4px; border-radius: 10px; background: #f6f9fd; }
.edge-cap { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.edge-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 0; }
.edge-stats .wide { grid-column: span 2; }
.edge-stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 5px 6px; text-align: center; min-width: 0; }
.edge-stats dt { font-size: 11.5px; color: var(--muted); }
.edge-stats dd { margin: 0; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; min-height: 21px; display: grid; place-items: center; }
.es-bar { display: block; width: 100%; height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.es-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #fca5a5, #b91c1c); }
.slider.scrub { padding-top: 6px; }
.slider.scrub .hint { grid-column: 1 / -1; margin-top: 2px; }
.slider.scrub output { font-size: 14px; }
.edge-legend { list-style: none; margin: 12px 2px 4px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 12px; color: var(--ink-2); }
.edge-legend li { display: flex; align-items: center; gap: 6px; min-width: 0; line-height: 1.35; }
.edge-legend li:first-child, .edge-legend li:last-child, .edge-legend li.wide { grid-column: 1 / -1; }
.edge-legend i { flex: none; width: 22px; height: 5px; border-radius: 3px; }
.edge-legend .k-bite { height: 6px; background: linear-gradient(90deg, #fca5a5, #b91c1c); }
.edge-legend .k-idle { background: #38bdf8; height: 2px; }
.edge-legend .k-lean { background: var(--phi); height: 4px; }
.edge-legend .k-grow { height: 6px; background: linear-gradient(90deg, rgba(185, 28, 28, 0.95), rgba(252, 165, 165, 0.7) 70%, transparent); }
.edge-legend .k-fade { background: linear-gradient(90deg, #b91c1c, #e2e8f0 45%, #e2e8f0 55%, #b91c1c); }
.edge-legend .k-word { flex: none; color: #b91c1c; font-size: 12.5px; }

/* ---------- sliders ---------- */
.sliders { display: grid; gap: 4px; }
.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 10px 0 2px;
}
.slider label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.slider output {
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.slider input[type="range"] { grid-column: 1 / -1; }
.ticks { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: -2px; position: relative; }
.boot-mark { color: var(--bad); font-weight: 700; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
  margin: 2px 0;
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--p), #dbe3ee var(--p));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #dbe3ee; }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  margin-top: -10px;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}
input[type="range"].over::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--bad) var(--p), #dbe3ee var(--p)); }
input[type="range"].over::-webkit-slider-thumb { border-color: var(--bad); }

.shape-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 0;
}
.shape-stats div { background: #f6f8fb; border-radius: 10px; padding: 7px 8px; text-align: center; }
.shape-stats dt { font-size: 11.5px; color: var(--muted); }
.shape-stats dd { margin: 0; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- status & metrics ---------- */
.status {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  align-items: start;
  font-size: 13.5px;
}
.status .s-icon { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 15px; margin-top: 1px; }
.status strong { font-size: 15px; }
.status p { margin: 0; color: var(--ink-2); }
.status.ok { background: var(--ok-soft); }
.status.ok .s-icon { background: var(--ok); }
.status.ok strong { color: #065f46; }
.status.too-slow { background: var(--warn-soft); }
.status.too-slow .s-icon { background: #f59e0b; }
.status.too-slow strong { color: var(--warn); }
.status.skid, .status.boot { background: var(--bad-soft); }
.status.skid .s-icon, .status.boot .s-icon { background: var(--bad); }
.status.skid strong, .status.boot strong { color: #991b1b; }
.status .extra { grid-column: 2; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }

.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: grid;
  min-width: 0;
}
.metric .m-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.metric b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.3; white-space: nowrap; }
.metric b small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.metric .m-note { font-size: 11.5px; color: var(--muted); }
.metric.m-edge { border-color: #c7d7fe; background: #f5f8ff; }
.metric.m-edge b { color: var(--accent); }
.metric.m-phi { border-color: #fed7aa; background: #fff8f1; }
.metric.m-phi b { color: #ea580c; }

.gauge-wrap { display: grid; gap: 10px; margin: 14px 0 4px; padding: 12px; border-radius: 14px; background: #f8fafd; border: 1px solid var(--line); }
.gauge-box { max-width: 330px; width: 100%; margin: 0 auto; }
.gauge-box svg { width: 100%; height: auto; display: block; }
.gauge-legend { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-2); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; }
.gauge-legend i { display: inline-block; width: 16px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.k-edge { background: var(--accent); }
.k-phi { background: var(--phi); }
.k-range { background: rgba(249, 115, 22, 0.35); height: 6px !important; }
.k-band { background: rgba(5, 150, 105, 0.45); height: 6px !important; }
.k-boot { background: rgba(220, 38, 38, 0.35); height: 6px !important; }

.g-track { fill: none; stroke: #e2e8f0; stroke-width: 14; }
.g-band { fill: none; stroke: rgba(5, 150, 105, 0.45); stroke-width: 14; }
.g-boot { fill: none; stroke: rgba(220, 38, 38, 0.35); stroke-width: 14; }
.g-range { fill: none; stroke: rgba(249, 115, 22, 0.4); stroke-width: 8; stroke-linecap: round; }
.g-phi { stroke: var(--phi); stroke-width: 4; stroke-linecap: round; }
.g-edge { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.g-hub { fill: var(--navy); }
.g-tick { stroke: #94a3b8; stroke-width: 1.5; }
.g-num { fill: var(--muted); font-size: 13px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.g-tag { font-size: 17px; font-weight: 700; font-style: italic; font-family: Georgia, "Times New Roman", serif; paint-order: stroke; stroke: #f8fafd; stroke-width: 5px; stroke-linejoin: round; }
.g-tag-edge { fill: var(--accent); }
.g-tag-phi { fill: #ea580c; }

/* ---------- explanation ---------- */
details.explain {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fafcff;
}
details.explain summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.explain summary::-webkit-details-marker { display: none; }
details.explain summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.2s; margin-right: 4px; }
details.explain[open] summary::after { transform: rotate(-135deg); }
.prose { padding: 0 14px 14px; font-size: 13.5px; color: var(--ink-2); }
.prose h3 { font-size: 14px; margin: 14px 0 4px; color: var(--ink); }
.prose p { margin: 6px 0; }
.prose ul { padding-left: 20px; margin: 6px 0; }
.prose li { margin: 3px 0; }
.formula {
  font-family: "Cambria Math", "STIX Two Math", Georgia, "Times New Roman", serif;
  font-size: 15px;
  background: #eef3fb;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--navy);
  overflow-x: auto;
  white-space: nowrap;
}
.formula.inline { display: inline; padding: 2px 6px; font-size: 14px; }

/* ---------- boot-out ---------- */
.boot-summary { margin: 14px 0 10px; }
.figure { margin: 10px 0; }
.planform-box, .section-box { background: #f6f9fd; border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.planform-box svg, .section-box svg { display: block; width: 100%; height: auto; }
.section-box svg { max-height: 300px; margin: 0 auto; }
.caption { margin: 6px 2px 0; font-size: 12px; color: var(--muted); }
.planform .svg-label { fill: var(--ink); font-size: 40px; font-weight: 700; font-family: var(--font); }
.planform .svg-sub { fill: var(--muted); font-size: 34px; font-family: var(--font); }
.planform .svg-tick { stroke: var(--ice); stroke-width: 4; }
.planform .svg-axis { stroke: rgba(56, 189, 248, 0.35); stroke-width: 2; stroke-dasharray: 12 10; }
.planform .boot rect { fill: rgba(148, 163, 184, 0.55); stroke: #475569; stroke-width: 3; }
.planform .boot-over rect { fill: rgba(220, 38, 38, 0.75); stroke: none; }
.section .svg-label { fill: var(--ink); font-size: 17px; font-weight: 700; font-family: var(--font); }
.section .svg-label.danger { fill: var(--bad); }
.section .svg-sub { fill: var(--muted); font-size: 14px; font-family: var(--font); }
.section .snow { fill: #e3edf7; }
.section .snow-line { stroke: #94a3b8; stroke-width: 2; }
.section .ghost { fill: none; stroke: var(--bad); stroke-width: 2; stroke-dasharray: 6 5; opacity: 0.7; }
.section .sec-binding { fill: #94a3b8; }
.section .sec-boot { fill: #cbd5e1; stroke: #475569; stroke-width: 2; }
.section .sec-sole { stroke: #0f172a; stroke-width: 5; stroke-linecap: round; }
.section .sec-board { fill: var(--navy); stroke: var(--ice); stroke-width: 2; }
.section .angle-arc { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.section .toe-ok { fill: var(--ok); }
.section .toe-hit { fill: var(--bad); }

.boot-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; margin: 6px 0 4px; }
.boot-table th, .boot-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.boot-table th:first-child, .boot-table td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.boot-table thead th { font-size: 12.5px; color: var(--muted); }
.boot-table tr.key td { font-weight: 700; font-size: 15px; }
.boot-table td.limit { color: var(--bad); }

.boot-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
}
.boot-hero .bh-label { font-size: 12.5px; color: #a9bddb; }
.boot-hero .bh-value { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.boot-hero .bh-value small { font-size: 14px; color: #a9bddb; font-weight: 600; margin-left: 4px; }
.boot-hero .bh-side { text-align: right; font-size: 12.5px; color: #cfe0f7; }
.boot-hero .bh-side b { display: block; font-size: 15px; color: #fff; }
.boot-hero .bh-msg { grid-column: 1 / -1; font-size: 13px; margin-top: 4px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.boot-hero.hit .bh-msg { color: #fecaca; }
.boot-hero.clear .bh-msg { color: #a7f3d0; }

/* ---------- about & footer ---------- */
.about h2 { margin-bottom: 8px; }
.about p { color: var(--ink-2); font-size: 14px; margin: 6px 0; }
.policy { padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13.5px; color: var(--ink-2); margin: 10px 0; }
.policy li { display: flex; gap: 8px; align-items: baseline; }
.policy li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); transform: translateY(-2px); }
.policy li:has(.badge)::before { display: none; }
.offline-note { font-size: 12.5px !important; color: var(--muted) !important; }
.app-footer { text-align: center; font-size: 12px; color: var(--muted); padding: 0 16px calc(24px + var(--safe-b)); }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  background: var(--navy);
  color: #fff;
}
.link-btn {
  border: 0;
  background: none;
  padding: 0 2px;
  color: var(--accent);
  font-weight: 600;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.file-warning { display: none; }
.is-file .file-warning {
  display: block;
  margin: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bad-soft);
  color: #7f1d1d;
  font-size: 14px;
}
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line-2); }

/* ---------- wider screens ---------- */
@media (min-width: 560px) {
  .specs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .boot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .boot-grid .span-2 { grid-column: span 3; }
  .stage { aspect-ratio: 16 / 11; }
}
@media (min-width: 1024px) {
  body { font-size: 15.5px; }
  .app-header { flex-direction: row; justify-content: space-between; align-items: center; padding: 18px 28px; }
  .current-board { max-width: 46%; }
  .section-nav { grid-template-columns: repeat(4, 120px); justify-content: center; }
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    align-items: start;
    padding: 20px 24px 40px;
    gap: 18px;
  }
  .col { display: grid; gap: 18px; align-content: start; min-width: 0; }
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .boot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .boot-grid .span-2 { grid-column: 1 / -1; }
  .stage { aspect-ratio: 16 / 10; }
}
