:root {
  color-scheme: light;
  --ground: #e7eaee;
  --sheet: #f6f8fa;
  --surface: #eef1f4;
  --panel: #f9fafb;
  --ink: #171b21;
  --muted: #58616d;
  --faint: #8b95a1;
  --hair: #ccd2d9;
  --hair-strong: #aeb6bf;
  --accent: #0f766e;
  --accent-ink: #0b5850;
  --accent-wash: #d7ebe8;
  --heater: #b3760f;
  --danger: #b23a34;
  --shadow: 0 1px 2px rgba(20,28,38,.10), 0 8px 30px rgba(20,28,38,.08);
  --drawn: #2a323b;
  --drawn-faint: #9aa3ad;
  --on-accent: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #101418;
    --sheet: #171c22;
    --surface: #1c222a;
    --panel: #1a2028;
    --ink: #e8ecf1;
    --muted: #97a1ad;
    --faint: #6d7885;
    --hair: #2b323c;
    --hair-strong: #3a4250;
    --accent: #2dd4bf;
    --accent-ink: #7ff0e2;
    --accent-wash: #123733;
    --heater: #d99a3a;
    --danger: #e0736b;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 40px rgba(0,0,0,.35);
    --drawn: #c7ced7;
    --drawn-faint: #5c6672;
    --on-accent: #04201d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #101418;
  --sheet: #171c22;
  --surface: #1c222a;
  --panel: #1a2028;
  --ink: #e8ecf1;
  --muted: #97a1ad;
  --faint: #6d7885;
  --hair: #2b323c;
  --hair-strong: #3a4250;
  --accent: #2dd4bf;
  --accent-ink: #7ff0e2;
  --accent-wash: #123733;
  --heater: #d99a3a;
  --danger: #e0736b;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 40px rgba(0,0,0,.35);
  --drawn: #c7ced7;
  --drawn-faint: #5c6672;
  --on-accent: #04201d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
button, input, select { font-family: inherit; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.cond { font-family: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif; }

/* ---------- shell ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
header.bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hair);
  background: var(--panel);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand .mark { font-family: "IBM Plex Sans Condensed", sans-serif; font-weight: 700; letter-spacing: .02em; font-size: 18px; }
.brand .sub { color: var(--faint); font-size: 12.5px; letter-spacing: .02em; }
.seg { display: inline-flex; border: 1px solid var(--hair-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; font-size: 13px; cursor: pointer; border-right: 1px solid var(--hair); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.icon-btn { border: 1px solid var(--hair-strong); background: transparent; color: var(--muted); width: 34px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }

.work { display: grid; grid-template-columns: minmax(0,1fr) 430px; flex: 1 1 auto; min-height: 0; }
@media (max-width: 940px) { .work { grid-template-columns: 1fr; overflow: auto; } .app { height: auto; min-height: 100%; } }

/* ---------- drawing sheet ---------- */
.stage { padding: 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.sheet-wrap { background: var(--sheet); border: 1px solid var(--hair); border-radius: 6px; box-shadow: var(--shadow); padding: 10px; flex: 1 1 auto; display: flex; min-height: 360px; }
svg.draw { width: 100%; height: 100%; display: block; }
.view3d { flex: 1 1 auto; align-self: stretch; min-height: 340px; min-width: 0; position: relative; }
.view3d canvas { width: 100% !important; height: 100% !important; display: block; border-radius: 4px; outline: none; touch-action: none; }
svg.draw[hidden], .view3d[hidden] { display: none; }
.stage .hint { color: var(--faint); font-size: 12.5px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.fixed { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.fixed b { color: var(--ink); font-weight: 500; font-family: "IBM Plex Mono", monospace; }

/* ---------- controls ---------- */
.panel { border-left: 1px solid var(--hair); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.controls { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 0 16px; }
fieldset { border: 0; margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--hair); }
legend { font-family: "IBM Plex Sans Condensed", sans-serif; text-transform: uppercase; letter-spacing: .12em; font-size: 11.5px; font-weight: 600; color: var(--accent-ink); padding: 0; margin-bottom: 12px; width: 100%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) legend { color: var(--accent); } }
:root[data-theme="dark"] legend { color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
label.lbl { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
label.lbl .val { color: var(--ink); font-family: "IBM Plex Mono", monospace; }
input[type="number"], select { width: 100%; padding: 7px 9px; font-size: 14px; font-family: "IBM Plex Mono", monospace; color: var(--ink); background: var(--sheet); border: 1px solid var(--hair-strong); border-radius: 7px; }
select { font-family: "IBM Plex Sans", sans-serif; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.choice { display: flex; gap: 6px; flex-wrap: wrap; }
.choice button { border: 1px solid var(--hair-strong); background: var(--sheet); color: var(--muted); border-radius: 7px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.choice button[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); background: var(--accent-wash); }
.radio { display: flex; gap: 14px; }
.radio label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.radio input, .check input { accent-color: var(--accent); width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.note { font-size: 12px; color: var(--faint); margin: 8px 0 0; line-height: 1.45; }
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.order-form textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 13.5px; padding: 8px 10px; border: 1px solid var(--hair-strong); border-radius: 6px; background: var(--sheet); color: var(--ink); resize: vertical; }
.order-summary { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 14px; font-size: 13px; }
.order-summary dt { color: var(--muted); } .order-summary dd { margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 12.5px; }
a.btn { text-decoration: none; display: inline-block; }
a.btn[hidden] { display: none; }
.row-inline input[type=file] { font-size: 12px; max-width: 100%; min-width: 0; flex: 1 1 160px; }
.note.callout { color: var(--muted); border-left: 3px solid var(--accent); padding: 6px 10px; background: var(--accent-wash); border-radius: 0 6px 6px 0; }
.subhead { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 6px; font-size: 12px; color: var(--muted); }
.link { border: 0; background: none; color: var(--accent-ink); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .link { color: var(--accent); } }
:root[data-theme="dark"] .link { color: var(--accent); }

/* XY tables */
table.xy { width: 100%; border-collapse: collapse; font-size: 13px; }
table.xy th { text-align: left; font-weight: 500; color: var(--faint); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 0 4px 4px; }
table.xy td { padding: 2px 4px; }
table.xy td.n { color: var(--faint); font-family: "IBM Plex Mono", monospace; width: 22px; }
table.xy input[type="number"] { padding: 5px 7px; font-size: 13px; }
table.xy td.rm { width: 28px; text-align: right; }
table.xy .rm button { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 14px; padding: 2px 4px; }
table.xy .rm button:hover { color: var(--danger); }

/* cards for mounts and pins */
.cards { display: flex; flex-direction: column; gap: 8px; }
.card { border: 1px solid var(--hair); border-radius: 8px; padding: 8px 10px; background: var(--sheet); }
.card:focus-within, .card:hover { border-color: var(--accent); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.card-head .n { font-family: "IBM Plex Sans Condensed", sans-serif; font-weight: 600; font-size: 12.5px; letter-spacing: .04em; color: var(--ink); }
.card-head .tiny { font-size: 11px; color: var(--faint); font-family: "IBM Plex Mono", monospace; }
.card-head .rm { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 13px; padding: 0 2px; }
.card-head .rm:hover { color: var(--danger); }
.card-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 8px; }
.card-grid.two { grid-template-columns: 1fr 1fr; }
.card-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--faint); }
.card-grid input[type="number"], .card-grid select { padding: 5px 7px; font-size: 13px; }
.big { font-size: 18px; font-weight: 500; color: var(--ink); padding-top: 4px; }

/* ---------- readout ---------- */
.readout { border-top: 1px solid var(--hair); background: var(--surface); padding: 14px 20px; flex: 0 0 auto; }
.specs { margin-bottom: 12px; }
.specs-title { font-family: "IBM Plex Sans Condensed", sans-serif; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 600; color: var(--faint); margin-bottom: 6px; }
.specs dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; color: var(--ink); font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
.price { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--hair-strong); border-radius: 8px; background: var(--sheet); }
.price .amt { font-family: "IBM Plex Mono", monospace; font-size: 22px; font-weight: 600; color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .price .amt { color: var(--accent); } }
:root[data-theme="dark"] .price .amt { color: var(--accent); }
.price .tag { font-size: 11px; color: var(--faint); }
.actions { display: flex; gap: 8px; }
.btn { flex: 0 0 auto; border: 1px solid var(--hair-strong); background: var(--sheet); color: var(--ink); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; cursor: pointer; font-weight: 500; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn:hover { border-color: var(--accent); }
.warn { margin-top: 10px; font-size: 12.5px; color: var(--danger); display: flex; flex-direction: column; gap: 3px; }
.warn:empty { display: none; }

dialog { border: 1px solid var(--hair-strong); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: min(560px, 92vw); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10,14,18,.5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--hair); }
.dlg-body { padding: 14px 18px; }
textarea.spec { width: 100%; height: 300px; resize: vertical; background: var(--sheet); color: var(--ink); border: 1px solid var(--hair); border-radius: 8px; padding: 12px; font-family: "IBM Plex Mono", monospace; font-size: 12px; line-height: 1.5; }
