@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f4fa;
  --panel: #ffffff;
  --ink: #171a2b;
  --muted: #687089;
  --line: #e3e5ef;
  --accent: #e8590c;
  --accent-2: #8b3dff;
  --accent-ink: #ffffff;
  --grad: linear-gradient(135deg, #e8590c 0%, #e0245e 55%, #7c3aed 100%);
  --grad-soft: linear-gradient(135deg, rgba(255, 122, 24, 0.12), rgba(139, 61, 255, 0.12));
  --glow: rgba(224, 36, 94, 0.3);
  --ring: rgba(124, 58, 237, 0.18);
  --brand-2: #ffd2bd;
  --brand-3: #e2c8ff;
  --top: #12132a;
  --top-2: #2b1a5e;
  --top-ink: #eceaff;
  --warn: #c2570c;
  --err: #d0213c;
  --info: #2563eb;
  --input: #f7f8fc;
  --shadow: 0 1px 2px rgba(23, 26, 43, 0.04), 0 6px 24px rgba(23, 26, 43, 0.07);
  --radius: 16px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  /* drawing: paper */
  --d-paper: #ffffff;
  --d-ink: #111111;
  --d-thin: #444444;
  --d-dim: #e8481a;
  --d-prop: #1d6ff2;
  --prop: #1d6ff2;
  --d-feat: rgba(232, 89, 12, 0.16);
  --d-front: rgba(232, 89, 12, 0.05);
  --d-hatch: #555;
}
:root:not([data-theme='light']) {
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1020;
    --panel: #181a2e;
    --ink: #ecebfa;
    --muted: #a3a6c2;
    --line: #2b2e48;
    --accent: #ff7a3d;
    --accent-ink: #ffffff;
    --top: #0a0b18;
    --top-2: #221448;
    --input: #13152a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme='dark'] {
  --bg: #0f1020;
  --panel: #181a2e;
  --ink: #ecebfa;
  --muted: #a3a6c2;
  --line: #2b2e48;
  --accent: #ff7a3d;
  --accent-ink: #ffffff;
  --top: #0a0b18;
  --top-2: #221448;
  --input: #13152a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
}
h2 { font-size: 17px; margin: 22px 0 6px; }
h3 { font-size: 14px; margin: 0 0 6px; }
h4 { margin: 12px 0 6px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap;
  background: var(--top); color: var(--top-ink);
  padding: 8px 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .2px; }
.tabs { display: flex; gap: 2px; flex-wrap: nowrap; order: 3; flex: 1 0 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; margin: 0 -6px; }
.tabs button { white-space: nowrap; }
.tabs button {
  background: none; border: 0; color: var(--top-ink); opacity: .72;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font: inherit;
}
.tabs button:hover { opacity: 1; background: rgba(255,255,255,.06); }
.tabs button.on { opacity: 1; background: rgba(255,255,255,.12); box-shadow: inset 0 -2px 0 var(--accent); }
.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.design-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design-name { opacity: .75; font-size: 12.5px; }

main { padding: 16px; max-width: 1600px; margin: 0 auto; }
.tab { display: none; }
.tab.on { display: block; }

/* controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; font: inherit; font-weight: 550;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.mini { font-size: 11.5px; padding: 2px 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 4px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--panel); color: var(--ink); border: 0; border-right: 1px solid var(--line); padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--input);
  border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px;
}
input[type=number], .field input, .field select { width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
.sheet-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

/* design */
.design { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
.design-form { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 14px; max-height: calc(100vh - 110px); overflow: auto; }
.design-form fieldset { border: 0; border-top: 1px solid var(--line); margin: 10px 0 0; padding: 10px 0 0; }
.design-form fieldset:first-child { border-top: 0; }
.design-form legend { font-weight: 650; font-size: 13px; color: var(--accent); padding: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; }
.field small { opacity: .6; font-size: 10.5px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row; align-items: center; gap: 6px; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.quick-add { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: var(--bg); padding: 8px; border-radius: 8px; margin-bottom: 8px; }
.quick-add select { flex: 1 1 120px; }
.quick-add input { width: 70px; }
.qa-mm { font-size: 12px; color: var(--muted); }
.row-ed { display: grid; grid-template-columns: 18px minmax(78px, 1fr) 52px 74px 36px 24px auto; gap: 5px; align-items: center; font-size: 12.5px; }
.row-ed .tag { font-weight: 700; color: var(--accent); text-align: center; }
.row-ed .ops { display: flex; gap: 2px; }
.row-head { font-size: 11px; color: var(--muted); }
.design-preview { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; position: sticky; top: calc(var(--hdr, 86px) + 12px); }
.preview-svg { min-height: 300px; display: flex; justify-content: center; }
.preview-svg svg { max-width: 100%; height: auto; max-height: 62vh; }
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.stat b { display: block; font-size: 15px; }
.stat span { color: var(--muted); font-size: 11.5px; }
.warnings { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.w { padding: 6px 9px; border-radius: 6px; font-size: 12.5px; border-left: 3px solid; background: var(--bg); }
.w.warn { border-color: var(--warn); }
.w.error { border-color: var(--err); }
.w.info { border-color: var(--info); }
.tplbox { background: var(--bg); border-radius: 8px; padding: 8px; margin-top: 8px; }

/* 3D */
.v3d-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.v3d-controls { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; align-self: start; }
.v3d-controls label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); }
.v3d-controls .seg { flex-direction: column; }
.v3d-controls .seg button { border-right: 0; border-bottom: 1px solid var(--line); text-align: left; }
.layers { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.layers label { flex-direction: row; gap: 5px; align-items: center; color: var(--ink); }
.v3d-stage { background: radial-gradient(ellipse at center, var(--panel), var(--bg)); border: 1px solid var(--line); border-radius: 10px; height: calc(100vh - 120px); min-height: 420px; cursor: grab; touch-action: none; }
.v3d-stage svg { width: 100%; height: 100%; }
.v3d polygon { stroke: rgba(40, 30, 20, .55); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.v3d .part:hover polygon, .v3d .part.hl polygon { stroke: var(--accent); stroke-width: 2.2; filter: brightness(1.08); }
.part-info { font-size: 12.5px; }
.part-info table { width: 100%; }

/* drawings */
.sheets { display: flex; flex-direction: column; gap: 18px; }
.sheet-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow: auto; }
.sheet-wrap svg.sheet { width: 100%; height: auto; max-height: 78vh; display: block; }
svg.sheet { --sw: 10; }
svg.sheet .paper { fill: var(--d-paper); }
svg.sheet line, svg.sheet rect, svg.sheet polygon, svg.sheet circle, svg.sheet path { vector-effect: non-scaling-stroke; fill: none; stroke: var(--d-ink); }
svg.sheet .ol { stroke-width: 1.5; }
svg.sheet .hdl { fill: var(--d-front); }
svg.sheet .front { stroke-width: 1.5; fill: var(--d-front); }
svg.sheet .thin { stroke: var(--d-thin); stroke-width: .8; }
svg.sheet .hid { stroke: var(--d-thin); stroke-width: .8; stroke-dasharray: 5 3; }
svg.sheet .ctr { stroke: var(--d-dim); stroke-width: .8; stroke-dasharray: 10 3 2 3; }
svg.sheet .cut { stroke-width: 1.4; }
svg.sheet .hatchln { stroke: var(--d-hatch); stroke-width: .5; }
svg.sheet .feat { fill: var(--d-feat); stroke: var(--d-ink); stroke-width: .9; }
svg.sheet .shelf { fill: var(--d-front); stroke-width: 1.1; }
svg.sheet .pocket { fill: var(--d-feat); stroke-width: .8; }
svg.sheet .dimln, svg.sheet .dimx { stroke: var(--d-dim); stroke-width: .7; }
svg.sheet .tick { stroke: var(--d-dim); stroke-width: 1.3; }
svg.sheet .arrow { stroke: var(--d-dim); stroke-width: 1; stroke-dasharray: 3 2; }
svg.sheet .dot { fill: var(--d-dim); stroke: none; }
/* drawing text: a plain sans that prints clearly, with a paper-coloured halo so it reads over lines and hatching */
svg.sheet text { fill: var(--d-ink); font-family: Inter, 'Helvetica Neue', Arial, sans-serif; font-weight: 500; paint-order: stroke fill; stroke: var(--d-paper, #fff); stroke-width: 0.22em; stroke-linejoin: round; }
svg.sheet .dimtx { fill: var(--d-dim); font-weight: 600; }
svg.sheet .lb { fill: var(--d-ink); opacity: 0.85; }
svg.sheet .zl { fill: var(--d-ink); font-weight: 700; }
svg.sheet .tbline { stroke: var(--d-ink); stroke-width: 1.5; }
svg.sheet .tbtitle, svg.sheet .tbscale { font-weight: 700; }
svg.sheet .tbsub { fill: var(--d-thin); }
.bp {
  --d-paper: #13426e;
  --d-ink: #f2f7ff;
  --d-thin: #bcd3ee;
  --d-dim: #ffd479;
  --d-prop: #7fe0ff;
  --d-feat: rgba(255, 212, 121, 0.22);
  --d-front: rgba(255, 255, 255, 0.05);
  --d-hatch: #8fb4dd;
}

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; break-inside: avoid; }
.card svg.sheet { width: 100%; height: auto; }
.card .where { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0; }
.kv td { border-bottom: 1px solid var(--line); padding: 3px 4px; vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 42%; }
.card ol, .card ul { padding-left: 18px; margin: 6px 0; font-size: 12.5px; }

/* cut list */
table.cl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 13px; }
table.cl th, table.cl td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.cl th { background: var(--bg); font-weight: 600; font-size: 12px; color: var(--muted); }
table.cl td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.cl tr.grp td { background: var(--bg); font-weight: 650; color: var(--accent); }
.cutlist { overflow-x: auto; }

/* lab */
.lab { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.lab-form { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.lab-out .card svg.sheet { max-height: 60vh; }

/* library */
.tpl-cards, .saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tpl-cards .card .grid2 { margin: 8px 0; }
.saved .card { display: flex; flex-direction: column; gap: 6px; }
.saved .card .acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* hardware */
.hw textarea { width: 100%; min-height: 260px; font-family: ui-monospace, monospace; font-size: 12px; }
.hw .grid2 { max-width: 640px; }

/* plans */
.plans-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.plans-bar .btn.on { outline: 2px solid var(--ink); }
.plans-status { color: var(--muted); font-size: 12.5px; }
.plans-main { display: grid; grid-template-columns: 1fr 280px; gap: 12px; }
.plans canvas { width: 100%; height: calc(100vh - 170px); min-height: 380px; border-radius: 10px; border: 1px solid var(--line); touch-action: none; cursor: crosshair; }
.plans-side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.meas li { margin-bottom: 6px; }
.calib { background: var(--bg); padding: 8px; border-radius: 8px; }
.calib input { width: 110px; }

@media (max-width: 900px) {
  main { padding: 10px 16px; }
  .top { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .tabs { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs button { white-space: nowrap; }
  .top-actions { margin-left: auto; }
  .design-preview { order: -1; }
  .design { display: flex; flex-direction: column; }
  .design, .v3d-wrap, .lab, .plans-main { grid-template-columns: 1fr; }
  .design-form { max-height: none; }
  .design-preview { position: static; }
  .cards { grid-template-columns: 1fr; }
  .v3d-stage { height: 60vh; }
  .row-ed { grid-template-columns: 22px minmax(0, 1fr) 56px 72px 40px 40px; }
  .row-ed .ops { grid-column: 2 / -1; }
}

@media print {
  .top, .noprint, .tab:not(.on) { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .sheet-wrap, .card { border: 0; padding: 0; page-break-inside: avoid; break-inside: avoid; }
  .sheet-wrap { page-break-after: always; }
  .sheet-wrap svg.sheet { width: auto !important; height: auto !important; max-height: none !important; }
  .cards { display: block; }
  .card { page-break-after: always; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* unconfirmed changes */
svg.sheet .old { opacity: .35; }
svg.sheet .proposal line, svg.sheet .proposal rect, svg.sheet .proposal polygon, svg.sheet .proposal circle, svg.sheet .proposal path { stroke: var(--d-prop) !important; }
svg.sheet .proposal .ol, svg.sheet .proposal .cut, svg.sheet .proposal .front { stroke-width: 2; }
svg.sheet .proposal .cut, svg.sheet .proposal .feat, svg.sheet .proposal .front, svg.sheet .proposal .shelf, svg.sheet .proposal .pocket { fill: color-mix(in srgb, var(--d-prop) 14%, transparent) !important; }
svg.sheet .proposal text { fill: var(--d-prop) !important; font-weight: 700; }
svg.sheet .proposal .dot { fill: var(--d-prop); }
.v3d .ghost polygon { fill: color-mix(in srgb, var(--prop) 16%, transparent); stroke: var(--prop); stroke-width: 1.6; }
.v3d .old polygon { opacity: .4; }
.change-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; max-width: min(960px, calc(100vw - 32px)); background: color-mix(in srgb, var(--prop) 10%, var(--panel)); border: 2px solid var(--prop); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.change-bar[hidden] { display: none; }
.change-bar .lbl { font-weight: 650; color: var(--prop); }
.chip { background: var(--panel); border: 1px solid var(--prop); color: var(--ink); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; }
.chip s { color: var(--muted); }
.chip b { color: var(--prop); }
.change-bar .btn.confirm { background: var(--prop); color: #fff; }
.change-bar .spacer { flex: 1; }
.design-form .changed input, .design-form .changed select, .design-form input.changed, .design-form select.changed { border-color: var(--prop); box-shadow: 0 0 0 1px var(--prop); color: var(--prop); font-weight: 600; }
.stat.changed { border-color: var(--prop); }
.stat.changed b { color: var(--prop); }
.stat s { color: var(--muted); font-size: 11.5px; }
.was { color: var(--muted); text-decoration: line-through; margin-right: 4px; }
.new { color: var(--prop); font-weight: 650; }
tr.added td { color: var(--prop); }
tr.removed td { color: var(--muted); text-decoration: line-through; }
.top-actions .ico { background: transparent; color: var(--top-ink); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 3px 8px; cursor: pointer; font: inherit; }
.top-actions .ico:disabled { opacity: .35; cursor: default; }
.top-actions label { font-size: 12.5px; opacity: .85; display: flex; gap: 4px; align-items: center; }
.banner { padding: 7px 10px; border-left: 3px solid var(--prop); background: color-mix(in srgb, var(--prop) 8%, var(--panel)); border-radius: 6px; font-size: 12.5px; margin-bottom: 10px; }
@media (max-width: 900px) { .change-bar { bottom: 8px; } }
@media print { .change-bar { display: none !important; } }

.row-ed input[type=checkbox] { justify-self: center; box-shadow: none !important; }
.row-ed .ops .mini { padding: 2px 5px; }

/* layout */
.lay { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 16px; align-items: start; }
.lay-side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 14px; max-height: calc(100vh - var(--hdr, 86px) - 32px); overflow: auto; position: sticky; top: calc(var(--hdr, 86px) + 12px); }
.lay-side fieldset { border: 0; border-top: 1px solid var(--line); margin: 10px 0 0; padding: 10px 0 0; }
.lay-side fieldset:first-child { border-top: 0; }
.lay-side legend { font-weight: 650; font-size: 13px; color: var(--accent); }
.lay-side legend small { color: var(--muted); font-weight: 400; }
.track { background: var(--bg); border-radius: 8px; padding: 8px; margin-top: 8px; }
.track-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.rem { color: var(--muted); }
.rem.over { color: var(--err); font-weight: 600; }
.it { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; gap: 5px; align-items: center; margin-bottom: 4px; }
.it-name { min-width: 0; }
.it-kind { font-size: 12.5px; padding-left: 4px; }
.it .ops { display: flex; gap: 2px; }
.add { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.add select { flex: 1 1 140px; min-width: 0; }
.lay-main { min-width: 0; }
.lay-main .sheet-wrap svg.sheet { max-height: 72vh; }
.edit-banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 1px solid var(--accent); }
.edit-banner[hidden] { display: none; }
.edit-banner span { flex: 1; }
@media (max-width: 900px) { .lay { grid-template-columns: 1fr; } .lay-side { position: static; max-height: none; } }

.std-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 8px 0 2px; }
.std-bar span { flex: 1 1 160px; }

/* sheets */
.stock-tbl input { width: 100%; min-width: 50px; }
.stock-tbl td { padding: 3px 4px; }
.err { color: var(--err); }
.sheet-wrap details { font-size: 12.5px; margin-top: 6px; }

/* finishes & room 3D */
.finish-box { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.finish-box h4 { margin: 0; }
.v3d.rendered polygon { stroke: rgba(40, 30, 20, .25); }
.v3d .shade { stroke: none !important; pointer-events: none; }
.room3d { display: grid; grid-template-columns: 240px 1fr; gap: 12px; }
.room3d-ctl { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-self: start; }
.room3d-stage { background: radial-gradient(ellipse at center, var(--panel), var(--bg)); border: 1px solid var(--line); border-radius: 10px; height: 70vh; min-height: 380px; cursor: grab; touch-action: none; }
.room3d-stage svg { width: 100%; height: 100%; }
@media (max-width: 900px) { .room3d { grid-template-columns: 1fr; } }

.v3d-stage canvas, .room3d-stage canvas, .preview-gl canvas { width: 100%; height: 100%; display: block; border-radius: 10px; }
.preview-gl { height: 62vh; min-height: 320px; }

/* scrub a number by dragging its label */
.design-form .field:has(input[type=number]) > span { cursor: ew-resize; user-select: none; }
body.scrubbing, body.scrubbing * { cursor: ew-resize !important; user-select: none !important; }

/* drawing board */
.preview-svg:focus { outline: none; }
svg.sheet .board .hit { fill: transparent; stroke: none; cursor: pointer; vector-effect: non-scaling-stroke; }
svg.sheet .board .hit.ns { cursor: ns-resize; }
svg.sheet .board .hit.ew { cursor: ew-resize; }
svg.sheet .board .hit:hover { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: var(--accent); stroke-width: 1; }
svg.sheet .board .hit.open:hover { fill: color-mix(in srgb, var(--accent) 8%, transparent); }
svg.sheet .board .hit.sel { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 2; }
body.dragging, body.dragging * { user-select: none !important; }
.inspector { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; background: var(--bg); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.inspector .hint { margin: 0; }
.ins-head { display: flex; justify-content: space-between; align-items: center; }
.ins-row { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ins-row > span { min-width: 150px; color: var(--muted); }
.ins-row input { width: 80px; }
.ins-row select { min-width: 160px; }
.ins-row.acts { gap: 6px; }

/* design preview: views, zoom & pan */
.preview-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.zoom-bar button { min-width: 34px; }
.preview-svg svg.sheet { touch-action: none; cursor: grab; }
.preview-svg svg.sheet.panning { cursor: grabbing; }

/* shape tool */
#shape-btn.on, #draw-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
svg.sheet .shape-ed .pick { fill: transparent; stroke: none; cursor: pointer; }
svg.sheet .shape-ed .pick:hover { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: var(--accent); stroke-width: 1.5; }
svg.sheet .shape-ed .shape-fill { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 2; pointer-events: none; }
svg.sheet .shape-ed .shape-edge { stroke: transparent; stroke-width: 14; cursor: copy; }
svg.sheet .shape-ed .shape-edge:hover { stroke: color-mix(in srgb, var(--accent) 35%, transparent); }
svg.sheet .shape-ed .shape-pt { fill: #fff; stroke: var(--accent); stroke-width: 2; cursor: move; }
svg.sheet .shape-ed .shape-pt:hover { fill: var(--accent); }
svg.sheet .shape-ed .shape-len { fill: var(--accent); stroke: none; text-anchor: middle; pointer-events: none; font-family: system-ui, sans-serif; }
svg.sheet .shapes-overlay .shaped-outline { fill: none; stroke: #c0392b; stroke-width: 1.6; stroke-dasharray: 6 3; pointer-events: none; }
.shape-pop { position: fixed; z-index: 60; width: 260px; background: var(--panel, #fff); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 28px rgba(0,0,0,.2); display: grid; gap: 6px; font-size: 13px; }
.shape-pop[hidden] { display: none; }
.shape-pop .pop-head { display: flex; justify-content: space-between; align-items: center; }
.shape-pop label { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 6px; }
.shape-pop input, .shape-pop select { width: 100%; }
.shape-pop .mv { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.shape-pop .pop-acts { display: flex; gap: 6px; }
.shape-pop .pick-item { display: block; width: 100%; text-align: left; padding: 6px 8px; border: 1px solid var(--line, #ddd); border-radius: 6px; background: transparent; cursor: pointer; }
.shape-pop .pick-item:hover { border-color: var(--accent); }
.shape-table { max-height: 260px; overflow: auto; }
.shape-table table { border-collapse: collapse; width: 100%; font-size: 13px; }
.shape-table th, .shape-table td { padding: 2px 4px; text-align: left; }
.shape-table input { width: 76px; }
.shape-table td.len { color: var(--muted, #888); }

/* layout: move units */
.lay-move { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.lay-move .sel-it { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lay-move input[data-moveto] { width: 80px; }
.lay-wall:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); }

/* review fixes: keep the design preview inside the screen on phones; room for the floating change bar */
.design-preview { min-width: 0; }
.design-preview .inspector { max-width: 100%; overflow-x: auto; }
body:has(.change-bar:not([hidden])) main { padding-bottom: 120px; }
@media (max-width: 600px) {
  .shape-table input { width: 58px; }
  .shape-pop { width: min(260px, calc(100vw - 16px)); }
}

/* layout corners */
.corners .corner-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line, #ddd); }
.corners .corner-row.bad span:first-of-type { color: #b3261e; }
.corners .corner-fix { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.corners .corner-fix input { width: 70px; }

/* shape tool: see-through handles, guides, tools */
svg.sheet .shape-ed .shape-pt { fill: rgba(255, 255, 255, 0.15); stroke: var(--accent); stroke-width: 1.5; }
svg.sheet .shape-ed .shape-pt:hover { fill: color-mix(in srgb, var(--accent) 35%, transparent); }
svg.sheet .shape-ed .guide { pointer-events: none; stroke-width: 1; stroke-dasharray: 5 4; }
svg.sheet .shape-ed .guide.v { stroke: #1a73e8; }
svg.sheet .shape-ed .guide.h { stroke: #e8336d; }
svg.sheet .shape-ed .guide.pt { fill: none; stroke: #0b9d58; stroke-width: 2; }
.shape-tools { margin: 4px 0; }
.shape-pop .draw-on { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; }
.shape-pop .draw-on .dirs { display: flex; gap: 2px; }

/* room plan: drag & place */
.plan-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.plan-bar .place, .plan-bar .sel-it { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plan-bar select { max-width: 260px; }
svg.sheet .plan-board .plan-hit { fill: transparent; stroke: none; cursor: grab; }
svg.sheet .plan-board .plan-hit:hover { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: var(--accent); stroke-width: 1.5; }
svg.sheet .plan-board .plan-hit.sel { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 2; }
svg.sheet .plan-board .plan-hit.dragging { opacity: 0.35; }
svg.sheet .plan-board .plan-ghost { fill: color-mix(in srgb, #1a73e8 18%, transparent); stroke: #1a73e8; stroke-width: 2; stroke-dasharray: 6 3; pointer-events: none; }
svg.sheet .plan-board .plan-wall-hi { stroke: #1a73e8; stroke-width: 6; opacity: 0.5; pointer-events: none; }
svg.sheet.placing { cursor: crosshair; }
.lay-plan svg.sheet, .lay-wall svg.sheet { touch-action: none; }
.saved .hist-h { width: 100%; margin-top: 18px; }
.saved .card.old { opacity: 0.85; border-style: dashed; }
@media (max-width: 600px) {
  .top-actions { flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
  .lay-side fieldset { min-width: 0; max-width: 100%; }
  .lay-side .it, .lay-side .track-head { flex-wrap: wrap; }
  .plan-bar select { max-width: 100%; }
}
.saved .list-h { width: 100%; margin: 14px 0 4px; }
.saved .list-cards { display: flex; flex-wrap: wrap; gap: 12px; width: 100%; }
.saved .list-pick { display: flex; gap: 6px; align-items: center; font-size: 12px; margin: 4px 0; }
.saved .list-pick input { width: 140px; }
.plan-bar .plan-msg { width: 100%; padding: 6px 10px; border-left: 3px solid #e8a33d; background: color-mix(in srgb, #e8a33d 12%, transparent); font-size: 13px; }
.inspector .ins-row.stack { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.inspector .ins-row.stack input[type="number"] { width: 60px; }

/* joint sheet */
.joint-sheet { margin-bottom: 18px; }
.joint-sheet .table-wrap { overflow-x: auto; }
.joint-sheet .jtable { border-collapse: collapse; width: 100%; font-size: 14px; }
.joint-sheet .jtable th, .joint-sheet .jtable td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.joint-sheet .jtable td.hint { color: var(--muted); font-size: 12.5px; }
.joint-sheet select { max-width: 280px; }
svg.sheet .board .hit.mv { cursor: move; }
svg.sheet .board .hit.board-hit { fill: color-mix(in srgb, #0b9d58 10%, transparent); stroke: #0b9d58; stroke-width: 1.2; stroke-dasharray: 4 3; }
svg.sheet .board .hit.board-hit.sel { fill: color-mix(in srgb, #0b9d58 22%, transparent); stroke-width: 2; stroke-dasharray: none; }
.inspector .ins-sub { margin: 8px 0 2px; font-size: 13px; }
.track.openings .op-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.track.openings .op-row input { width: 64px; }
.track.openings .add { display: flex; flex-wrap: wrap; gap: 4px; }

/* review fixes: header ghost button on the dark bar; wide tables scroll in place */
.top .btn.ghost { color: var(--top-ink); border-color: rgba(255, 255, 255, 0.35); }
.table-wrap { overflow-x: auto; max-width: 100%; }
.inspector .ins-row.stack input[type="checkbox"] { width: auto; }

/* touch screens: the drawing stays put when you select something (the panel goes underneath),
   and buttons are big enough for a finger */
@media (pointer: coarse) {
  .design-preview { display: flex; flex-direction: column; }
  .design-preview .preview-head { order: 0; }
  .design-preview .preview-svg { order: 1; }
  .design-preview .inspector { order: 2; }
  .design-preview .summary { order: 3; }
  .design-preview .warnings { order: 4; }
  .mini, .btn.small, .top-actions .ico { min-height: 34px; min-width: 34px; }
  .inspector input, .inspector select { min-height: 34px; }
}
/* narrow screens: the plan / drawing / 3D first, the forms after */
@media (max-width: 900px) {
  .lay { display: flex; flex-direction: column; }
  .lay .lay-main { order: -1; }
  .v3d-wrap { display: flex; flex-direction: column; }
  .v3d-wrap .v3d-stage { order: -1; height: 60vh; min-height: 320px; }
}
@media (max-width: 900px) {
  .design { display: flex; flex-direction: column; }
  .design .design-preview { order: -1; position: static; }
}
.lay > *, .design > *, .v3d-wrap > * { min-width: 0; max-width: 100%; }
.summary .stat b { overflow-wrap: anywhere; }

/* structure check */
.struct-in { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 10px; }
.struct-in .chk { display: inline-flex; gap: 4px; align-items: center; margin-right: 10px; font-size: 13px; }
.ubar { display: inline-block; width: 70px; height: 9px; background: var(--line); border-radius: 5px; overflow: hidden; vertical-align: middle; }
.ubar i { display: block; height: 100%; background: #2e8b57; }
.ubar.warn i { background: #d9a400; }
.ubar.bad i { background: #b42318; }
table.cl tr.fail td { background: color-mix(in srgb, #b42318 8%, transparent); }
.struct-note { margin-top: 12px; }
svg.sheet .shape-ed .shape-hole { fill: none; stroke: #b42318; stroke-width: 1.5; stroke-dasharray: 4 2; pointer-events: none; }
.shape-table input[data-hole] { width: 60px; }

/* phone: a compact header, the Build panel folds */
details.build > summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: baseline; }
details.build > summary::-webkit-details-marker { display: none; }
details.build > summary::before { content: '▸'; color: var(--accent); }
details.build[open] > summary::before { content: '▾'; }
@media (max-width: 600px) {
  .top { padding: 6px 10px; gap: 4px 8px; }
  .brand span, .top .design-name { display: none; }
  .top-actions label { font-size: 12px; }
  /* a fade on the right of the tab bar says there are more tabs to scroll to */
  .tabs { mask-image: linear-gradient(90deg, #000 92%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); padding-right: 28px; }
}
.zoom-bar button.on { background: var(--accent); color: var(--accent-ink); }
svg.sheet.pan-ready, svg.sheet.pan-ready * { cursor: grab !important; }
svg.sheet.panning, svg.sheet.panning * { cursor: grabbing !important; }

/* ---------------------------------------------------------------- draw tool (sketch) */
.sketch { pointer-events: none; }
.sketch .sk-ent { fill: none; stroke: #1f6feb; stroke-width: 1.6px; vector-effect: non-scaling-stroke; }
.sketch.live .sk-ent, svg[class*="sk-tool-"] .sketch .sk-ent { stroke-width: 2px; }
.sketch .sk-ent.sel { stroke: var(--accent); stroke-width: 3px; }
svg:not([class*="sk-tool-"]) .sketch { opacity: 0.4; } /* not drawing: the sketch shows faintly */
.sketch .sk-dim line { stroke: currentColor; vector-effect: non-scaling-stroke; }
.sketch .sk-dim { color: #444; }
.sketch .sk-dim.sel { color: #f08c00; }
.sketch .sk-dim text, .sketch .sk-text { fill: currentColor; stroke: none; font-family: system-ui, sans-serif; }
.sketch .sk-text { fill: #1f6feb; }
.sketch .sk-text.sel { fill: #f08c00; }
.preview-svg.bp .sketch .sk-ent { stroke: #fff; }
.preview-svg.bp .sketch .sk-dim, .preview-svg.bp .sketch .sk-text { color: #dfe9ff; fill: #dfe9ff; }
.sketch-live { pointer-events: none; }
.sketch-live .sk-rubber { fill: none; stroke: #1f6feb; stroke-dasharray: 6 4; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.sketch-live .sk-guide { stroke-width: 1px; vector-effect: non-scaling-stroke; opacity: 0.8; }
.sketch-live .sk-guide.x { stroke: #e03131; }
.sketch-live .sk-guide.y { stroke: #2f9e44; }
.sketch-live .sk-guide.dotted { stroke-dasharray: 2 4; opacity: 0.55; }
.sketch-live .sk-snap { fill: none; stroke-width: 2px; vector-effect: non-scaling-stroke; }
.sketch-live .sk-snap.end { stroke: #2f9e44; }
.sketch-live .sk-snap.mid { stroke: #1098ad; }
.sketch-live .sk-snap.centre { stroke: #c2255c; }
svg[class*="sk-tool-"]:not(.sk-tool-select) { cursor: crosshair; touch-action: none; }
svg.sk-tool-select { cursor: default; }
.sk-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin: 6px 0; }
.sk-tools button { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; padding: 2px; border: 1px solid var(--line, #ccc); border-radius: 6px; background: var(--panel); color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.sk-tools button small { font-size: 10px; opacity: 0.6; margin-top: 2px; }
.sk-tools button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.sk-vcb { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 12px; }
.sk-vcb input { flex: 1; min-width: 0; font: 600 15px ui-monospace, monospace; padding: 6px 8px; }
.sk-vcb b { font: 12px ui-monospace, monospace; min-width: 6ch; text-align: right; opacity: 0.8; }
.sk-part { border: 1px solid var(--line, #ccc); border-radius: 6px; padding: 6px; margin: 6px 0; }
.inspector[hidden] { display: none; }


/* ================================================================ modern theme
   Gradient header, pill tabs, soft cards, Space Grotesk headings, bold colour. */
body { -webkit-font-smoothing: antialiased; letter-spacing: -0.005em; }
h1, h2, h3, h4, legend, .brand, .tabs button, .btn, .seg button, .stat b, .ins-head b, .lbl { font-family: var(--font-display); }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-weight: 650; letter-spacing: -0.01em; }

/* header */
.top {
  background: radial-gradient(120% 180% at 100% 0%, var(--top-2) 0%, transparent 55%), var(--top);
  padding: 10px 18px 6px;
  box-shadow: 0 6px 24px rgba(10, 8, 40, 0.25);
}
.top::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--grad); opacity: .9; }
.brand { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand svg { width: 30px; height: 30px; padding: 5px; border-radius: 9px; background: var(--grad); color: #fff; box-shadow: 0 4px 14px var(--glow); }
.brand span { background: linear-gradient(90deg, #fff 0%, var(--brand-2) 60%, var(--brand-3) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tabs { gap: 4px; padding: 4px 0 2px; }
.tabs button { opacity: .7; padding: 7px 13px; border-radius: 999px; font-weight: 500; font-size: 13.5px; transition: background .15s, opacity .15s; }
.tabs button:hover { background: rgba(255, 255, 255, 0.08); }
.tabs button.on { opacity: 1; background: var(--grad); color: #fff; box-shadow: 0 4px 14px var(--glow); font-weight: 600; }
.top-actions .ico { border-radius: 10px; border-color: rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.05); }
.top-actions .ico:not(:disabled):hover { background: rgba(255, 255, 255, 0.14); }
.top .btn.ghost { border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.06); }

/* buttons */
.btn { background: var(--grad); background-size: 140% 140%; border-radius: 10px; padding: 8px 14px; font-weight: 600; letter-spacing: -0.005em; box-shadow: 0 3px 12px var(--glow); transition: transform .12s, box-shadow .12s, background-position .3s; }
.btn:hover { background-position: 100% 50%; box-shadow: 0 5px 18px var(--glow); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--panel); box-shadow: none; border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent-2); color: var(--accent-2); }
.btn.small { padding: 5px 11px; border-radius: 9px; }
.btn:disabled { opacity: .45; box-shadow: none; cursor: default; }
.mini { border-radius: 7px; padding: 3px 8px; }
.mini:hover { border-color: var(--accent-2); color: var(--accent-2); }
#draw-btn, #shape-btn { border-radius: 999px; }
#shape-btn.on, #draw-btn.on { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 3px 12px var(--glow); }

/* segmented controls: a pill track */
.seg { border: 0; background: var(--bg); border-radius: 12px; padding: 3px; gap: 2px; box-shadow: inset 0 0 0 1px var(--line); }
.seg button { background: transparent; border: 0; border-radius: 9px; padding: 6px 11px; font-weight: 500; color: var(--muted); transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px var(--ring), inset 0 -2px 0 var(--accent); }
.zoom-bar button.on { background: var(--grad); color: #fff; box-shadow: none; }

/* inputs */
input, select, textarea { border-radius: 10px; padding: 7px 10px; border-color: var(--line); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--ring); background: var(--panel); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* cards and panels */
.design-form, .design-preview, .card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.design-form { padding: 6px 18px 18px; }
.design-preview { padding: 16px; }
.design-form legend { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.design-form fieldset { border-top-color: var(--line); padding-top: 14px; margin-top: 14px; }
.field { font-weight: 500; }
.inspector { border-radius: 14px; background: var(--grad-soft), var(--panel); border-color: var(--line); padding: 10px 12px; }
.stat { border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); border-color: var(--line); padding: 9px 12px; }
.stat b { font-size: 17px; letter-spacing: -0.02em; }
.w { border-radius: 10px; }
.chip { border-radius: 999px; }
.change-bar { border-radius: 16px; backdrop-filter: blur(10px); }
.sk-tools button { border-radius: 10px; transition: transform .1s; }
.sk-tools button:hover { transform: translateY(-1px); border-color: var(--accent-2); }
.sk-tools button.on { background: var(--grad); border-color: transparent; box-shadow: 0 3px 10px var(--glow); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent-2) 35%, transparent) transparent; }
::selection { background: var(--ring); }

.btn.small { font-weight: 650; }
/* printing always on white, whatever the screen's dark mode */
@media print {
  :root, :root:not([data-theme='light']), :root[data-theme='dark'] {
    --bg: #fff; --panel: #fff; --ink: #111; --muted: #555; --line: #ccc; --input: #fff;
    color-scheme: light;
  }
  .design-form legend { -webkit-text-fill-color: currentColor; color: #111; background: none; }
  .card, .design-form, .design-preview, .stat { box-shadow: none; }
}

/* ================================================================ design studio workspace
   tool rail | drawing | side panel, with a measurements bar under the drawing */
#tab-design.on { display: block; }
.studio {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(320px, 400px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "tools canvas side";
  gap: 10px 12px;
  height: calc(100vh - var(--hdr, 90px) - 28px);
  min-height: 520px;
}
.studio-bar { grid-area: bar; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.studio-file { display: flex; gap: 6px; }
.studio-tools {
  grid-area: tools; display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-y: auto; scrollbar-width: none;
}
.studio-tools button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 42px; min-height: 42px; flex: 0 0 auto; padding: 2px; border: 0; border-radius: 11px;
  background: transparent; color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer;
  transition: background .12s, transform .1s;
}
.studio-tools button small { font: 600 9.5px var(--font); opacity: .55; }
.studio-tools button:hover:not(:disabled) { background: var(--grad-soft); }
.studio-tools button.on { background: var(--grad); color: #fff; box-shadow: 0 3px 10px var(--glow); }
.studio-tools button.on small { opacity: .85; }
.studio-tools button:disabled { opacity: .3; cursor: default; }
.rail-sep { display: block; height: 1px; margin: 4px 6px; background: var(--line); flex: 0 0 auto; }
.studio-canvas {
  grid-area: canvas; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.studio-canvas .preview-svg { flex: 1 1 auto; min-height: 0; display: flex; align-items: stretch; justify-content: center; padding: 8px; }
.studio-canvas .preview-svg > svg { width: 100%; height: 100%; max-height: none; max-width: 100%; }
.studio-canvas .preview-gl, .studio-canvas .preview-gl canvas { width: 100%; height: 100%; }
.studio-status {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 12px;
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 60%, var(--panel)); font-size: 12px;
}
.studio-status .sk-vcb { margin: 0; flex: 0 1 300px; }
.studio-status .sk-vcb span { font-weight: 600; color: var(--muted); }
.studio-status .sk-vcb input:disabled { opacity: .5; }
.studio-hint { color: var(--muted); flex: 1 1 200px; min-width: 0; }
.studio-side {
  grid-area: side; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px;
}
.side-tabs { display: flex; flex-wrap: nowrap; }
.side-tabs button { flex: 1; }
.side-pane[hidden] { display: none; }
.studio-side .design-form { border: 0; box-shadow: none; padding: 0 4px; max-height: none; overflow: visible; background: transparent; }
.studio-side .inspector { margin: 0; }
.studio-side .summary { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.studio-side .warnings:empty { display: none; }
.edit-banner:not([hidden]) { margin-bottom: 10px; }

@media (max-width: 1100px) {
  .studio { grid-template-columns: 52px minmax(0, 1fr) minmax(280px, 330px); }
}
/* phones and narrow tablets: drawing on top, settings underneath, tools along the bottom of the screen */
@media (max-width: 760px) {
  .studio { display: flex; flex-direction: column; height: auto; min-height: 0; gap: 10px; padding-bottom: 64px; }
  .studio-bar { order: 0; }
  .studio-canvas { order: 1; height: 62vh; min-height: 320px; }
  .studio-side { order: 2; overflow: visible; }
  .studio-tools {
    position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 20;
    flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 5px; border-radius: 16px;
  }
  .studio-tools button { width: 44px; min-height: 44px; }
  .rail-sep { width: 1px; height: auto; margin: 6px 3px; }
  .studio-status { padding: 6px 8px; }
  .studio-status .sk-vcb { flex: 1 1 100%; }
  .change-bar { bottom: 74px; }
}
body:not(:has(#tab-design.on)) .studio-tools { display: none; }
@media print { .studio-tools, .studio-status, .studio-bar { display: none !important; } .studio { display: block; height: auto; } }
.room-file { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.room-file select { flex: 1 1 140px; }

/* New / Open picker */
.picker-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; background: rgba(12, 10, 30, 0.45); backdrop-filter: blur(4px); }
.picker-back[hidden] { display: none; }
.picker { width: min(920px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--panel); color: var(--ink); border-radius: 20px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); overflow: hidden; }
.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--grad); color: #fff; }
.picker-head h2 { margin: 0; color: #fff; }
.ico-close { border: 0; background: rgba(255, 255, 255, 0.18); color: #fff; width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer; }
.picker-body { padding: 8px 18px 18px; overflow-y: auto; }
.picker-body h3 { margin: 16px 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.picker-body .pick-sec { margin: 18px 0 0; font-size: 17px; }
#pick-search { width: 100%; margin-top: 12px; font-size: 15px; padding: 10px 12px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.pick-grid.big { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; transition: border-color .12s, transform .1s, box-shadow .12s; }
.pick:hover { border-color: var(--accent-2); box-shadow: 0 4px 16px var(--ring); transform: translateY(-1px); }
.pick b { font-family: var(--font-display); font-size: 14px; }
.pick small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.pick-grid.big .pick { padding: 14px; background: var(--grad-soft), var(--panel); }
.pick-ico { font-size: 22px; line-height: 1; margin-bottom: 4px; }
@media (max-width: 600px) { .picker-back { padding: 0; } .picker { max-height: 100vh; height: 100%; border-radius: 0; } .pick-grid { grid-template-columns: 1fr 1fr; } }
/* the unconfirmed-changes bar sits above the measurements bar on the design page */
body:has(#tab-design.on) .change-bar { bottom: 70px; }
@media (max-width: 760px) { body:has(#tab-design.on) .change-bar { bottom: 74px; } }
.studio-side .side-tabs { position: sticky; top: -10px; z-index: 3; box-shadow: 0 -10px 0 var(--panel), inset 0 0 0 1px var(--line); background: var(--bg); }

/* my jigs */
.myjig-new { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.myjig-new .acts, .myjig-head .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.myjig-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.myjig-head h3 { margin: 0; }
.myjig-head .acts { margin-left: auto; }
.myjig.open { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--ring), var(--shadow); }
.myjig-ed { margin: 10px 0; padding: 10px; border-radius: 12px; background: var(--grad-soft), var(--panel); }
.myjig-ed h4 { margin: 12px 0 6px; }
.jg-holes input { width: 72px; }
.jg-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; font-size: 12.5px; }
.jg-row input { width: 64px; }
.jg-set { display: flex; gap: 6px; margin-bottom: 4px; }
.jg-set input { flex: 1; min-width: 0; }
.mine-chip { margin: 6px 0; padding: 6px 10px; border-radius: 10px; background: var(--grad-soft); font-size: 12.5px; }
table.kv { border-collapse: collapse; font-size: 12.5px; margin: 6px 0; }
table.kv th { text-align: left; font-weight: 600; padding: 2px 12px 2px 0; color: var(--muted); }
@media print {
  body.printing-one .tab.on > :not(.myjigs), body.printing-one .myjig-new, body.printing-one .myjigs .card:not(.print-one) { display: none !important; }
}
.myjig-ed .table-wrap { max-height: 260px; overflow: auto; }

/* ================================================================ themes (palette) — 🎨 at the top right */
:root[data-palette='ocean'] {
  --accent: #0369a1; --accent-2: #4f46e5;
  --grad: linear-gradient(135deg, #0891b2 0%, #2563eb 55%, #4f46e5 100%);
  --grad-soft: linear-gradient(135deg, rgba(8, 145, 178, 0.12), rgba(79, 70, 229, 0.12));
  --glow: rgba(37, 99, 235, 0.3); --ring: rgba(79, 70, 229, 0.2);
  --top: #0a1630; --top-2: #12407a; --brand-2: #bde8ff; --brand-3: #c9cdff;
  --d-dim: #0369a1; --d-feat: rgba(3, 105, 161, 0.14); --d-front: rgba(3, 105, 161, 0.05);
}
:root[data-palette='forest'] {
  --accent: #15803d; --accent-2: #0f766e;
  --grad: linear-gradient(135deg, #65a30d 0%, #15803d 50%, #0f766e 100%);
  --grad-soft: linear-gradient(135deg, rgba(101, 163, 13, 0.12), rgba(15, 118, 110, 0.12));
  --glow: rgba(21, 128, 61, 0.3); --ring: rgba(15, 118, 110, 0.2);
  --top: #0c1d15; --top-2: #1d4a31; --brand-2: #d9f99d; --brand-3: #a7f3d0;
  --d-dim: #15803d; --d-feat: rgba(21, 128, 61, 0.14); --d-front: rgba(21, 128, 61, 0.05);
}
:root[data-palette='workshop'] {
  --accent: #a0632b; --accent-2: #7c2d12;
  --grad: linear-gradient(135deg, #b45309 0%, #a0632b 50%, #7c2d12 100%);
  --grad-soft: linear-gradient(135deg, rgba(180, 83, 9, 0.12), rgba(124, 45, 18, 0.1));
  --glow: rgba(160, 99, 43, 0.3); --ring: rgba(160, 99, 43, 0.22);
  --top: #23272e; --top-2: #4a3423; --brand-2: #f4d9b8; --brand-3: #e9c49a;
  --bg: #f4f1ec; --line: #ddd6cb;
  --d-dim: #c2410c; --d-feat: rgba(160, 99, 43, 0.18); --d-front: rgba(160, 99, 43, 0.06);
}
:root[data-palette='mono'] {
  --accent: #111827; --accent-2: #4b5563;
  --grad: linear-gradient(135deg, #111827 0%, #374151 60%, #4b5563 100%);
  --grad-soft: linear-gradient(135deg, rgba(17, 24, 39, 0.05), rgba(75, 85, 99, 0.08));
  --glow: rgba(17, 24, 39, 0.25); --ring: rgba(75, 85, 99, 0.25);
  --top: #0b0b0d; --top-2: #26272b; --brand-2: #e5e7eb; --brand-3: #9ca3af;
  --d-dim: #374151; --d-feat: rgba(17, 24, 39, 0.08); --d-front: rgba(17, 24, 39, 0.03);
}
:root[data-palette='neon'] {
  --accent: #c026d3; --accent-2: #0891b2;
  --grad: linear-gradient(135deg, #db2777 0%, #9333ea 50%, #0891b2 100%);
  --grad-soft: linear-gradient(135deg, rgba(219, 39, 119, 0.13), rgba(8, 145, 178, 0.13));
  --glow: rgba(192, 38, 211, 0.38); --ring: rgba(8, 145, 178, 0.25);
  --top: #0a0420; --top-2: #3b0b5c; --brand-2: #fbcfe8; --brand-3: #a5f3fc;
  --d-dim: #c026d3; --d-feat: rgba(192, 38, 211, 0.12); --d-front: rgba(192, 38, 211, 0.04);
}
/* mono in the dark: light buttons on dark */
@media (prefers-color-scheme: dark) {
  :root[data-palette='mono']:not([data-theme='light']) { --accent: #e5e7eb; --accent-2: #9ca3af; --grad: linear-gradient(135deg, #4b5563, #6b7280); }
  :root[data-palette='workshop']:not([data-theme='light']) { --bg: #1a1714; --line: #3a332b; --panel: #24201c; }
}
:root[data-palette='mono'][data-theme='dark'] { --accent: #e5e7eb; --accent-2: #9ca3af; --grad: linear-gradient(135deg, #4b5563, #6b7280); }
:root[data-palette='workshop'][data-theme='dark'] { --bg: #1a1714; --line: #3a332b; --panel: #24201c; }

.look-btn { font-size: 16px; }
.look-pop { position: fixed; z-index: 60; top: calc(var(--hdr, 90px) - 6px); right: 16px; width: min(320px, calc(100vw - 32px)); padding: 14px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3); }
.look-pop[hidden] { display: none; }
.look-pop h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px; border: 2px solid transparent; border-radius: 12px; background: var(--bg); color: var(--ink); font: 600 12px var(--font); cursor: pointer; }
.swatch i { display: block; width: 100%; height: 26px; border-radius: 8px; }
.swatch.on { border-color: var(--accent); }
.look-pop .seg { display: flex; }
.look-pop .seg button { flex: 1; }

.std-chip { margin: 6px 0; padding: 6px 10px; border-radius: 10px; border: 1px dashed var(--accent-2); font-size: 12.5px; }

/* setting-out rods */
.rods-head { margin-bottom: 10px; }
.rods-head .acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.rod { margin: 0 0 16px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow-x: auto; }
.rod figcaption { margin-bottom: 6px; font-size: 13px; }
.rod-svg { width: 100%; min-width: 640px; height: auto; display: block; background: #fff; border-radius: 8px; }
.rod-svg, .rod-page { font-family: ui-monospace, monospace; }
.rod-axis, .rod-tick { stroke: #111; stroke-width: 0.3; }
.rod-tick.big { stroke-width: 0.5; }
.rod-edge { stroke: #c2410c; stroke-width: 0.15; stroke-dasharray: 1 0.8; }
.rod-num { font-size: 2.6px; fill: #c2410c; }
.rod-lane { fill: #fafafa; stroke: #bbb; stroke-width: 0.2; }
.rod-band { stroke: #111; stroke-width: 0.25; }
.rod-part { fill: #e9d8c3; }
.rod-frame { fill: #d6b98f; }
.rod-open { fill: #fff; stroke-dasharray: 1.2 0.8; }
.rod-front { fill: #dbe7f5; }
.rod-shelf { fill: #cfe8d4; }
.rod-space { fill: #eee; stroke: #999; }
.rod-mark { stroke: #111; stroke-width: 0.35; }
.rod-lbl { font-size: 3px; fill: #111; }
.rod-lbl.small { font-size: 2.2px; }
.rod-name { font: 600 3.2px var(--font); fill: #444; }
.rod-name.inpage { font-size: 2.4px; fill: #777; }
.rod-head { font: 600 3.4px var(--font); fill: #111; }
.rod-check { fill: #111; }
.rod-join { stroke: #2563eb; stroke-width: 0.4; stroke-dasharray: 2 1; }
.rod-print { display: none; }
.motion-bar { align-items: center; gap: 6px; }
.kcheck-out { font-size: 13px; line-height: 1.45; }
.kcheck-out ul { margin: 4px 0 8px 18px; padding: 0; }
.kcheck-out .ok { color: #1f7a3f; font-weight: 600; }
.kcheck-out .bad { color: #b42318; }
.kcheck-out .warn { color: #a15c07; }
.motion-bar input[type="range"] { width: 120px; }
.motion-report.bad, .studio-hint.bad { color: #b42318; font-weight: 600; }
.comps { margin-top: 22px; }
.comps > h3 { margin: 0 0 4px; }
.comp-group { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.comp { margin: 0 0 8px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.comp > summary { cursor: pointer; padding: 2px 0; }
.comp[open] > summary { margin-bottom: 8px; }
.comp .rod { box-shadow: none; }
.comp-notes { margin: 0 0 8px 18px; padding: 0; font-size: 13px; }
.cut-wrap { overflow-x: auto; margin-bottom: 10px; }
table.cut { border-collapse: collapse; font-size: 13px; width: 100%; }
table.cut th, table.cut td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
table.cut td:nth-child(n+2):nth-child(-n+5) { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.cut td.small, .cut-sheet .small { font-size: 11px; }
.cut-sheet { font: 11px/1.35 system-ui, sans-serif; color: #000; }
.cut-sheet h2 { font-size: 15px; margin: 0 0 6px; }
.cut-sheet h3 { font-size: 12.5px; margin: 10px 0 3px; break-after: avoid; }
.cut-sheet table.cut { font-size: 10.5px; }
.cut-sheet table.cut th, .cut-sheet table.cut td { border-bottom: 0.3mm solid #999; padding: 1.2mm 1.5mm; }
#rods-btn.on { border-color: var(--accent); color: var(--accent); }
@page rods { size: A4 landscape; margin: 10mm; }
@media print {
  body.printing-rods > *:not(.rod-print) { display: none !important; }
  body.printing-rods .rod-print { display: block !important; }
  body.printing-rods .rod-sheet { page: rods; break-after: page; }
  body.printing-rods .rod-sheet:last-child { break-after: auto; }
  body.printing-rods { background: #fff !important; }
}
.sheets[hidden], .rods[hidden] { display: none !important; }
@media print { body.printing-rods .rod-sheet:not(.cut-sheet) { overflow: hidden; height: 185mm; } }

/* review fixes: side tabs keep their height; phone change bar full width; measurements above the tool strip */
.studio-side .side-tabs { flex: 0 0 auto; }
.studio-side .side-pane { flex-shrink: 0; }
@media (max-width: 760px) {
  .change-bar { left: 8px; right: 8px; transform: none; margin-inline: auto; width: auto; max-width: none; }
  body:has(#tab-design.on) .studio-status { position: fixed; left: 8px; right: 8px; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 62px); z-index: 19; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
  body:has(#tab-design.on) .studio { padding-bottom: 150px; }
  body:has(#tab-design.on) .change-bar { bottom: 132px; }
  .studio-tools { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); padding-right: 24px; }
  .top-actions #save-new-btn { white-space: nowrap; }
}
@media (max-width: 420px) { .top-actions .design-name { display: none; } .top-actions label { font-size: 0; } .top-actions label input { margin: 0; } }
/* short screens (iPad landscape): smaller rail buttons so Fit stays in view */
@media (min-width: 761px) and (max-height: 820px) { .studio-tools button { min-height: 34px; width: 38px; font-size: 16px; } .studio-tools button small { display: none; } .rail-sep { margin: 2px 6px; } }

/* A3 drawing sheets */
.a3-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.a3-head .hint { flex: 1 1 360px; margin: 0; }
.a3-pages { display: flex; flex-direction: column; gap: 16px; }
.a3-wrap { background: #fff; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.a3-wrap svg.a3-page { display: block; width: 100%; height: auto; }
.a3-page .sheet .paper { fill: none; stroke: none; }
.sheet .svc { fill: #fff; stroke: #e03131; stroke-width: calc(0.35px * var(--sw, 1)); }
.sheet .svc-t { fill: #e03131; font-weight: 700; }
.sheet .balloon { fill: #fff; stroke: #111; stroke-width: calc(0.3px * var(--sw, 1)); }
.sheet .balloon-t { fill: #111; font-weight: 700; }
.job-details { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.job-details summary { cursor: pointer; }
.op-row .op-note input { width: 180px; }
.a3-print { display: none; }
@page a3 { size: A3 landscape; margin: 0; }
@media print {
  body.printing-a3 > *:not(.a3-print) { display: none !important; }
  body.printing-a3 .a3-print { display: block !important; }
  body.printing-a3 .a3-sheet { page: a3; break-after: page; }
  body.printing-a3 .a3-sheet:last-child { break-after: auto; }
  body.printing-a3 .a3-sheet svg { display: block; width: 420mm; height: 297mm; }
}

.rod-hund { font-size: 2.4px; fill: #111; font-family: ui-monospace, monospace; }
.rod-tag { fill: #fff; opacity: 0.9; }
.rod-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rod-scroll .rod-svg { width: 100%; }
.rod-list { margin-top: 8px; font-size: 12.5px; }
.rod-list summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.rod-list td { font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.6; }

/* room drawings: worktops over the units on plan; a clean presentation style inside the units */
svg.sheet .wt { fill: rgba(176, 132, 74, 0.16); stroke: var(--d-ink); stroke-width: 1.3; }
.clean svg.sheet .art g .hid, svg.sheet.clean .art g .hid { display: none; }
.clean svg.sheet .front, svg.sheet.clean .front { fill: none; }
.clean svg.sheet .art g .lb, svg.sheet.clean .art g .lb { display: none; }

/* the drawing sheets reduced onto A4 landscape */
.a3-print-ctl { display: flex; gap: 10px; align-items: center; }
@page a4l { size: A4 landscape; margin: 0; }
@media print {
  body.printing-a3.print-a4 .a3-sheet { page: a4l; }
  body.printing-a3.print-a4 .a3-sheet svg { width: 297mm; height: 210mm; }
}

.field .pair { display: flex; gap: 6px; align-items: center; }
.field .pair input { min-width: 0; flex: 1; }

/* drop-downs never push the page wider than the screen (long library / stock names on a phone) */
select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
.place select, .add-oc select { max-width: min(100%, 260px); }
@media (max-width: 600px) {
  .table-wrap, table.cl { display: block; max-width: 100%; overflow-x: auto; }
}
.plan-bar .place, .plan-bar .sel-it { min-width: 0; max-width: 100%; }
.plan-bar .place .btn { white-space: normal; }
.it .it-no { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; font-size: 11px; margin-right: 4px; flex: none; }
@page a2l { size: 594mm 420mm; margin: 0; }
@page a1l { size: 841mm 594mm; margin: 0; }
@media print {
  body.printing-a3.print-a2 .a3-sheet { page: a2l; }
  body.printing-a3.print-a2 .a3-sheet svg { width: 594mm; height: 420mm; }
  body.printing-a3.print-a1 .a3-sheet { page: a1l; }
  body.printing-a3.print-a1 .a3-sheet svg { width: 841mm; height: 594mm; }
}

/* pricing: price entry and the client quote */
.quote h3 { margin: 16px 0 6px; display: flex; gap: 10px; align-items: baseline; }
.q-miss { color: var(--muted, #888); font-size: 12px; font-weight: 400; }
.q-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.q-table input.qp { width: 96px; text-align: right; }
.q-table input.q-desc { width: 100%; min-width: 200px; }
.q-table .q-no { font-weight: 700; }
.q-table .q-size { white-space: nowrap; font-family: ui-monospace, monospace; font-size: 12px; }
.q-table tfoot th { text-align: left; }
.q-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.q-totals .stat small { display: block; }
.q-vat { max-width: 140px; margin-top: 12px; }
.quote-sheet { font: 10.5pt/1.4 Inter, Arial, sans-serif; color: #111; background: #fff; }
.quote-sheet header { display: flex; justify-content: space-between; border-bottom: 0.6mm solid #111; padding-bottom: 3mm; }
.quote-sheet h1 { margin: 0; font-size: 20pt; }
.quote-sheet .q-co { text-align: right; }
.quote-sheet .q-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4mm; margin: 4mm 0; }
.quote-sheet h2 { display: flex; justify-content: space-between; font-size: 12pt; border-bottom: 0.3mm solid #999; margin: 5mm 0 2mm; }
.quote-sheet table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.quote-sheet td, .quote-sheet th { text-align: left; padding: 0.8mm 1.5mm; border-bottom: 0.2mm solid #ddd; }
.quote-sheet td:last-child, .quote-sheet th:last-child { text-align: right; }
.quote-sheet .q-sum { width: 45%; margin: 6mm 0 0 auto; font-size: 10.5pt; }
.quote-sheet .q-grand td { font-weight: 700; border-top: 0.5mm solid #111; }
.quote-sheet .q-foot { color: #666; font-size: 8.5pt; margin-top: 6mm; }
@page quote { size: A4 portrait; margin: 14mm; }
@media print { body.printing-quote .quote-sheet { page: quote; } }

/* the working plan: room tools, measuring an opening, the elevation under the plan */
.plan-room { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; width: 100%; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.plan-room .op-edit { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 4px 8px; }
.plan-room .op-edit input { width: 72px; }
.plan-room .moulds { display: flex; gap: 8px; margin-left: auto; }
.plan-room .moulds select { max-width: 170px; }
svg .op-hit { fill: transparent; stroke: none; cursor: pointer; pointer-events: all; }
svg .op-hit:hover { fill: rgba(28, 126, 214, 0.12); }
svg .op-hit.sel { fill: rgba(28, 126, 214, 0.22); stroke: #1c7ed6; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.plan-elev { margin-top: 10px; }
.plan-elev .pe-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 4px; }
.plan-elev .pe-bar .mini.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.plan-elev .pe-sheet { max-height: 46vh; overflow: auto; }
.plan-elev .pe-sheet svg { width: 100%; height: auto; max-height: 44vh; }
@media (max-width: 760px) { .plan-room .moulds { margin-left: 0; } }

/* designer: what's inside each door row */
.rows .row-ed.row-in { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 12px; padding: 0 0 6px 30px; border-bottom: 1px dashed var(--line); }
.rows .row-ed.row-in .in-label { font-weight: 600; color: var(--muted, #777); }
.rows .row-ed.row-in input[type='number'] { width: 58px; }
.room3d-stage.walking { cursor: crosshair; height: 78vh; }
.room3d.walking { grid-template-columns: 1fr; }
.room3d.walking .room3d-ctl { flex-direction: row; flex-wrap: wrap; align-items: center; }
.room3d.walking .room3d-ctl h4, .room3d.walking .room3d-ctl .hint { width: 100%; margin: 0; }

/* jobs: rooms grouped for one client */
.job-bar { margin-bottom: 8px; }
.job-bar .field { margin-bottom: 6px; }
.job-rooms { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.job-rooms .chip { border: 1px solid var(--line, #ccc); border-radius: 999px; padding: 4px 12px; background: transparent; color: inherit; font: inherit; font-size: 0.9em; cursor: pointer; }
.job-rooms .chip.on { background: var(--accent, #2a6); color: #fff; border-color: transparent; font-weight: 600; cursor: default; }
.job-rooms .chip.add { border-style: dashed; }
.job-rooms .chip.ghost { border-color: transparent; }
.q-job { margin-bottom: 16px; }
.q-job tr.on td { font-weight: 600; }
