:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #14171c; --muted: #5d6673; --line: #e2e5ea;
  --accent: #0891b2; --accent-ink: #ffffff; --hot: #ea580c;
  --good: #15803d; --good-bg: #dcfce7; --warn: #a16207; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --frame: #334155; --wheel: #94a3b8; --rider: #0891b2; --ghost: #ea580c; --skin: #0e7490;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --panel: #151b23; --ink: #e6edf3; --muted: #8b96a5; --line: #262f3b;
    --accent: #22d3ee; --accent-ink: #062a33; --hot: #fb923c;
    --good: #4ade80; --good-bg: #0f2e1c; --warn: #facc15; --warn-bg: #2f2708; --bad: #f87171; --bad-bg: #3a1212;
    --frame: #cbd5e1; --wheel: #475569; --rider: #22d3ee; --ghost: #fb923c; --skin: #67e8f9;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --panel: #151b23; --ink: #e6edf3; --muted: #8b96a5; --line: #262f3b;
  --accent: #22d3ee; --accent-ink: #062a33; --hot: #fb923c;
  --good: #4ade80; --good-bg: #0f2e1c; --warn: #facc15; --warn-bg: #2f2708; --bad: #f87171; --bad-bg: #3a1212;
  --frame: #cbd5e1; --wheel: #475569; --rider: #22d3ee; --ghost: #fb923c; --skin: #67e8f9;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, system-ui, sans-serif; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }
h2 { font-size: 18px; margin: 0 0 6px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.hint { color: var(--muted); margin: 0 0 12px; }
a { color: var(--accent); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.logo { color: var(--hot); }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 500; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--bg); }
.tab.active { background: var(--accent); color: var(--accent-ink); }

.layout { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 20px; padding: 20px; max-width: 1600px; margin: 0 auto; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow-y: auto; }
.pane { display: none; } .pane.active { display: block; }
.stage { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.f.wide { grid-column: 1 / -1; }
input[type=number], input[type=text], select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.row select { flex: 1; width: auto; }
button, .filebtn { font: inherit; font-weight: 500; border-radius: 8px; padding: 7px 12px; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
button:hover, .filebtn:hover { border-color: var(--accent); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ghost { background: transparent; }

.sliders { display: flex; flex-direction: column; gap: 10px; }
.sl { display: grid; grid-template-columns: 1fr 86px; gap: 2px 10px; align-items: center; }
.sl > span { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.sl > span em { font-style: normal; color: var(--hot); font-family: "JetBrains Mono", monospace; font-size: 11px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.howto { margin-top: 14px; color: var(--muted); } .howto summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.howto li { margin: 6px 0; }
.refs li { margin: 8px 0; }
.warn { background: var(--warn-bg); color: var(--ink); border-left: 3px solid var(--warn); padding: 10px 12px; border-radius: 6px; }

.viewer { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
#svg { width: 100%; height: auto; max-height: 62vh; aspect-ratio: 2000 / 1250; display: block; }
.viewbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.viewbar input[type=range] { flex: 1; min-width: 120px; }
.chk { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px 18px 16px; box-shadow: var(--shadow); min-width: 0; }

.metrics { display: flex; flex-direction: column; }
.m { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.m:last-child { border-bottom: 0; }
.m .k { font-size: 13px; } .m .k small { display: block; color: var(--muted); font-size: 11px; }
.m .val { font-family: "JetBrains Mono", monospace; font-size: 14px; font-weight: 500; text-align: right; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; min-width: 64px; text-align: center; }
.good { background: var(--good-bg); color: var(--good); } .warnb { background: var(--warn-bg); color: var(--warn); } .bad { background: var(--bad-bg); color: var(--bad); } .na { background: var(--bg); color: var(--muted); }

.rec table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rec th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rec td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.rec td.n { font-family: "JetBrains Mono", monospace; text-align: right; white-space: nowrap; }
.rec td.d { font-family: "JetBrains Mono", monospace; text-align: right; color: var(--hot); white-space: nowrap; padding-left: 10px; }
.changes { margin: 10px 0 0; padding-left: 18px; } .changes li { margin: 4px 0; }
.note { color: var(--muted); font-size: 12px; margin: 8px 0; }
.opt { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px; font-size: 13px; }
.opt:nth-child(odd) { background: var(--bg); }

.status { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.videobox { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.videobox video, .videobox canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

/* SVG */
#svg .wheel { fill: none; stroke: var(--wheel); stroke-width: 26; }
#svg .rim { fill: none; stroke: var(--wheel); stroke-width: 3; opacity: .6; }
#svg .hub { fill: var(--wheel); }
#svg .tube { stroke: var(--frame); stroke-width: 22; stroke-linecap: round; }
#svg .tube.thin { stroke-width: 14; } #svg .tube.fat { stroke-width: 30; }
#svg .spacer { stroke: var(--wheel); stroke-linecap: butt; }
#svg .stemcol { stroke: var(--frame); }
#svg .stem { stroke: var(--frame); stroke-width: 22; stroke-linecap: round; }
#svg .bar { fill: none; stroke: var(--frame); stroke-width: 18; stroke-linecap: round; }
#svg .hood { fill: var(--frame); }
#svg .grip { fill: var(--frame); }
#svg .post { stroke: var(--wheel); stroke-width: 18; stroke-linecap: round; }
#svg .saddle { fill: var(--frame); }
#svg .ring { fill: none; stroke: var(--wheel); stroke-width: 8; }
#svg .crank { stroke: var(--frame); stroke-width: 16; stroke-linecap: round; } #svg .crank.far { opacity: .35; }
#svg .pedal { fill: var(--frame); }
#svg .seg { stroke: var(--rider); stroke-width: 34; stroke-linecap: round; stroke-linejoin: round; fill: none; opacity: .85; }
#svg .seg.torso { stroke-width: 60; } #svg .seg.leg { stroke-width: 44; } #svg .seg.foot { stroke-width: 22; }
#svg .head { fill: var(--rider); opacity: .85; }
#svg .joint { fill: var(--panel); stroke: var(--skin); stroke-width: 4; }
#svg .far .seg { opacity: .25; }
#svg .ghostr .seg, #svg .ghostr .head { stroke: var(--ghost); fill: none; opacity: .9; stroke-width: 6; stroke-dasharray: 18 12; }
#svg .ghostr .head { stroke-width: 6; }
#svg .ghostr .joint { display: none; }
#svg .lbl { font: 600 34px Inter, system-ui, sans-serif; fill: var(--ink); paint-order: stroke; stroke: var(--panel); stroke-width: 8px; }
#svg .tgt { fill: none; stroke: var(--ghost); stroke-width: 5; } #svg .tgtx { stroke: var(--ghost); stroke-width: 4; }
#svg .tgtl { fill: var(--ghost); font-size: 28px; }
#svg .ground { stroke: var(--line); stroke-width: 4; }
#svg .dim { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 8 8; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 20px 30px; }

@media (max-width: 1100px) { .cards { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .panel { position: static; max-height: none; order: 2; }
  .stage { order: 1; }
  .top { padding: 8px 16px; gap: 10px; }
  .brand { display: none; }
}
@media (max-width: 420px) { .fields { grid-template-columns: 1fr; } }
