:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1f1d1a;
  --muted: #6b665d;
  --line: #d9d3c6;
  --copper: #b5602a;
  --rev: #1f7a8c;
  --accent: #b5602a;
  --magnet: #2b2b2b;
  --arc: #7a5cc4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a;
    --panel: #1d1f24;
    --ink: #ece8df;
    --muted: #9a958b;
    --line: #34363d;
    --copper: #e08a4f;
    --rev: #4fb6c9;
    --accent: #e08a4f;
    --magnet: #f2f2f2;
    --arc: #a98bf0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15161a; --panel: #1d1f24; --ink: #ece8df; --muted: #9a958b; --line: #34363d;
  --copper: #e08a4f; --rev: #4fb6c9; --accent: #e08a4f; --magnet: #f2f2f2; --arc: #a98bf0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
header { padding: 18px 16px 4px; max-width: 1200px; margin: 0 auto; }
h1 { margin: 0; font-size: 26px; letter-spacing: 0.02em; font-weight: 700; }
.tag { margin: 2px 0 0; color: var(--muted); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) { main { grid-template-columns: minmax(0, 1fr); } }

.stage { position: sticky; top: 8px; }
@media (max-width: 860px) { .stage { position: static; } }
canvas#hoop {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  touch-action: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: grab;
}
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tools label {
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer;
  background: var(--panel); user-select: none;
}
.tools label:has(input:checked) { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tools input { position: absolute; opacity: 0; pointer-events: none; }
.hint { color: var(--muted); margin: 8px 0; font-size: 14px; }
.meters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px;
  font-variant-numeric: tabular-nums;
}
.meters div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.meters b { display: block; font-size: 17px; }
.meters span { color: var(--muted); font-size: 12px; }

.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
fieldset {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  padding: 10px 14px 12px; margin: 0; min-width: 0;
}
legend { font-weight: 700; padding: 0 6px; }
label { display: block; margin: 6px 0; font-size: 14px; }
label output { float: right; color: var(--muted); font-variant-numeric: tabular-nums; }
label.check { display: inline-flex; align-items: center; gap: 6px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
button {
  font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.on { border-color: var(--accent); color: var(--accent); }
.stats { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--ink); }
.arcs { display: flex; flex-direction: column; gap: 6px; }
.arc {
  display: grid; grid-template-columns: auto 64px 1fr auto; gap: 6px; align-items: center;
  font-size: 13px; border-left: 3px solid var(--arc); padding-left: 8px;
}
.arc input { padding: 3px 6px; }
.arc .res { color: var(--muted); font-variant-numeric: tabular-nums; }
.arc .res.bad { color: #c0392b; }
.arc button { padding: 2px 8px; }
.parts { font-size: 12px; overflow: auto; max-height: 280px; background: var(--bg); padding: 8px; border-radius: 8px; }
.status { color: var(--muted); font-size: 13px; min-height: 1.4em; margin: 0; }
.pad {
  position: relative; height: 120px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); overflow: hidden; touch-action: none; user-select: none; cursor: ns-resize;
  margin: 8px 0;
}
.pad:focus-visible { outline: 2px solid var(--accent); }
.padFill {
  position: absolute; left: 0; right: 0; top: 0; height: 0%;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--accent) 25%, transparent), var(--accent));
}
.padText { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.modebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--panel); }
.seg label { margin: 0; padding: 6px 16px; cursor: pointer; user-select: none; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; font-weight: 600; }
.badge { border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; border: 1px solid; }
.badge.ok { color: #2e7d4f; border-color: #2e7d4f; }
.badge.bad { color: #c0392b; border-color: #c0392b; }
.violations { margin: 0; padding: 8px 12px 8px 28px; border: 1px solid #c0392b55; border-radius: 10px; font-size: 13px; background: var(--panel); }
.violations li { margin: 2px 0; }
.wwit { font-size: 13px; }
.wwit h4 { margin: 8px 0 4px; font-size: 13px; }
.wwit table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.wwit td, .wwit th { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.wwit .yes { color: #2e7d4f; font-weight: 700; }
.wwit .no { color: var(--muted); }
.wwit .verdict { font-weight: 600; margin: 6px 0; }
.stats b.warn { color: #c0392b; }
button:disabled { opacity: 0.55; cursor: progress; }
