:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1d1f22; --muted: #5d636b; --line: #d9d8d2;
  --accent: #a23b12; --accent-ink: #fff; --warn-bg: #fff4dc; --warn-line: #d9a93c;
  --bad-bg: #fde8e4; --bad-ink: #8c1d0e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a; --panel: #212326; --ink: #eceae5; --muted: #a3a7ad; --line: #3a3d42;
    --accent: #e0733f; --accent-ink: #17181a; --warn-bg: #3a2f14; --warn-line: #8a6c1f;
    --bad-bg: #472019; --bad-ink: #ffb9ab;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, "Segoe UI", sans-serif; }
header, main, footer { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 28px; }
h1 { margin: 0 0 4px; font-size: 30px; }
h2 { margin: 0 0 12px; font-size: 18px; }
header p { margin: 0 0 20px; color: var(--muted); }
.tag { font-size: 13px; vertical-align: middle; padding: 3px 8px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 6px; padding: 14px 18px; margin-bottom: 20px; }
.warn h2 { margin-bottom: 4px; font-size: 16px; }
.warn ul { margin: 0; padding-left: 20px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
form, .layout > section, #result { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 18px; }
label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 15px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; font-size: 13px; }
button, .downloads a { display: inline-block; padding: 10px 16px; font: inherit; font-weight: 600; border-radius: 4px; text-decoration: none; cursor: pointer; }
button { width: 100%; background: var(--accent); color: var(--accent-ink); border: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }
.refusal { margin: 0 0 14px; padding: 10px 12px; background: var(--bad-bg); color: var(--bad-ink); border-radius: 4px; font-size: 15px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; padding: 9px 12px 9px 0; vertical-align: top; white-space: nowrap; }
td { padding: 9px 0; }
tr + tr th, tr + tr td { border-top: 1px solid var(--line); }
.status { margin: 18px 0 0; color: var(--muted); }
.status.bad { color: var(--bad-ink); }
#result { margin-top: 20px; }
.totals { margin: 0 0 14px; }
.downloads { display: flex; flex-wrap: wrap; gap: 10px; }
.downloads a { border: 1px solid var(--line); color: var(--ink); background: var(--bg); }
.downloads a.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.note { margin: 12px 0 14px; color: var(--muted); font-size: 14px; }
#preview { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
footer { padding-top: 22px; padding-bottom: 32px; color: var(--muted); font-size: 14px; }
footer a { color: inherit; }
[hidden] { display: none !important; }
@media (max-width: 720px) { .layout { grid-template-columns: minmax(0, 1fr); } }
fieldset { min-width: 0; margin: 0 0 20px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
legend { padding: 0 6px; font-size: 18px; font-weight: 700; }
form { background: none; border: 0; padding: 0; }
.layout fieldset { margin-bottom: 0; }
.choices { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.choice { display: flex; gap: 10px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 400; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input, .check input { width: auto; margin: 4px 0 0; flex: none; }
.choice b { display: block; }
.check { display: flex; gap: 10px; font-weight: 400; padding: 10px 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 4px; }
@media (max-width: 720px) { .choices { grid-template-columns: minmax(0, 1fr); } }
form > button { margin-top: 0; }
form > .refusal { margin-top: 0; }
.hinges { margin-top: 20px; }
.hinge-info { margin: 0; font-size: 14px; color: var(--muted); }
.hinge-info span { display: block; margin-bottom: 3px; }
.hinge-info a { color: inherit; }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check.plain { background: none; border: 0; padding: 0; font-weight: 600; }
.check.plain small { font-weight: 400; }
@media (max-width: 720px) { .choices.three { grid-template-columns: minmax(0, 1fr); } }
.check { align-items: flex-start; }
.field { display: block; margin-bottom: 14px; }
.field-title { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.boxes { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.box { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; cursor: pointer; }
.box input { width: auto; margin: 0; }
.off { opacity: 0.5; }
.sketch { display: block; width: 100%; max-width: 240px; margin-top: 8px; }
.sketch .line { fill: none; stroke: currentColor; stroke-width: 2; }
.sketch .hit { fill: var(--accent); stroke: currentColor; stroke-width: 1; }
.sketch text { fill: currentColor; font-size: 12px; }
.choice { align-items: flex-start; }
header, main, footer { max-width: 1240px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); gap: 20px; align-items: start; }
.side { position: sticky; top: 12px; display: grid; gap: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.side > section { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; }
.side table { font-size: 14px; }
.side th, .side td { padding: 5px 8px 5px 0; }
#viewer { position: relative; height: 340px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #eef0f2; }
#viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-status { position: absolute; top: 8px; left: 10px; margin: 0; padding: 2px 8px; font-size: 13px; color: #1d1f22; background: rgba(255, 255, 255, 0.8); border-radius: 4px; }
.viewer-status.bad { color: #8c1d0e; }
.viewer-hint { margin: -6px 0 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.person-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink, #1d1f22); cursor: pointer; }
.no-webgl { display: flex; align-items: center; padding: 16px; color: #1d1f22; }
#loads td.num { text-align: right; white-space: nowrap; }
#loads td.state { width: 56px; text-align: right; font-weight: 600; }
#loads .ok { color: #2f7a3d; }
#loads .watch { color: #a66a00; }
#loads .over { color: var(--bad-ink); }
#loads .none { color: var(--muted); font-weight: 400; }
#loads .why { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
@media (max-width: 1040px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: -1; max-height: none; }
  #viewer { height: 280px; }
}
.side { display: flex; flex-direction: column; overflow: hidden; height: calc(100vh - 24px); }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 12px; align-content: start; }
.side-scroll > section { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; }
#viewer { flex: none; }
@media (max-width: 1040px) { .side { height: auto; overflow: visible; } .side-scroll { overflow: visible; } }
.viewer-status { max-width: calc(100% - 20px); }
.viewer-status:empty { display: none; }
#fender-field { margin-top: 14px; }
.sketch.small { max-width: 170px; }
