:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #1d1b18;
  --ink-2: #5e5850;
  --ink-3: #8b847a;
  --line: #e4dfd7;
  --accent: #b5562b;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6dc;
  --good: #2f7a4b;
  --warn: #9a6a12;
  --warn-soft: #fbf0d9;
  --bad: #b03a2e;
  --bad-soft: #f8e1de;
  --viewer-top: #e9e6e0;
  --viewer-bottom: #d9d4cb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 25, 20, 0.06), 0 4px 16px rgba(30, 25, 20, 0.05);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513;
    --surface: #201e1b;
    --surface-2: #1b1917;
    --ink: #f1ede6;
    --ink-2: #b8b0a5;
    --ink-3: #8a8379;
    --line: #34302b;
    --accent: #e07a48;
    --accent-ink: #1a120d;
    --accent-soft: #3a261b;
    --good: #6cc08b;
    --warn: #e5b45a;
    --warn-soft: #3a2f19;
    --bad: #ef8a7d;
    --bad-soft: #3d2320;
    --viewer-top: #2a2824;
    --viewer-bottom: #1d1b18;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513;
  --surface: #201e1b;
  --surface-2: #1b1917;
  --ink: #f1ede6;
  --ink-2: #b8b0a5;
  --ink-3: #8a8379;
  --line: #34302b;
  --accent: #e07a48;
  --accent-ink: #1a120d;
  --accent-soft: #3a261b;
  --good: #6cc08b;
  --warn: #e5b45a;
  --warn-soft: #3a2f19;
  --bad: #ef8a7d;
  --bad-soft: #3d2320;
  --viewer-top: #2a2824;
  --viewer-bottom: #1d1b18;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Manrope, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.01em; font-size: 17px; }
.brand svg { width: 26px; height: 26px; fill: var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; }
.tier-badge {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}

/* Layout */
.layout {
  display: grid; gap: 16px; padding: 16px 20px 40px;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-areas: "controls viewer" "outputs outputs" "plans plans";
}
.controls { grid-area: controls; }
.viewer-wrap { grid-area: viewer; min-width: 0; }
.outputs { grid-area: outputs; min-width: 0; }
.plans { grid-area: plans; }
@media (max-width: 1100px) { .layout { grid-template-columns: 310px minmax(0, 1fr); gap: 12px; padding: 12px 12px 32px; } }
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "viewer" "controls" "outputs" "plans"; padding: 16px; }
  .top { padding: 12px 16px; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.controls { padding: 18px; display: flex; flex-direction: column; gap: 14px; align-self: start; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.field > span b { text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600; margin-left: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="number"] { font-family: var(--mono); }
input.invalid { border-color: var(--bad); }
.unit { position: relative; }
.unit input { padding-right: 38px; }
.unit em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12px; color: var(--ink-3); pointer-events: none; }
.hint { color: var(--ink-3); font-size: 12.5px; line-height: 1.4; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 7px; border-radius: 6px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); outline: 1px solid var(--line); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; padding: 0; background-size: cover; }
.swatch[aria-checked="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }

.messages:empty { display: none; }
.msg { padding: 9px 11px; border-radius: 8px; font-size: 13.5px; line-height: 1.4; }
.msg + .msg { margin-top: 6px; }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Viewer */
.viewer {
  position: relative; height: calc(100vh - 140px); min-height: 440px; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(var(--viewer-top), var(--viewer-bottom)); border: 1px solid var(--line);
}
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 2; }
.viewer-hint { position: absolute; left: 14px; bottom: 8px; margin: 0; font-size: 12px; color: var(--ink-3); pointer-events: none; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 12px 2px 0; font-size: 13px; }
.stats div { display: flex; gap: 6px; }
.stats dt { color: var(--ink-3); }
.stats dd { margin: 0; font-family: var(--mono); font-weight: 500; }

/* Outputs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 8px 10px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab {
  border: 0; background: transparent; padding: 9px 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 6px; align-items: center;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab .lock { font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 99px; }
.tab-body { padding: 18px; }
.tab-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tab-head h3 { margin: 0; font-size: 17px; }
.tab-head p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.locked-note {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); margin-bottom: 14px; font-size: 14px;
}
.preview-fade { position: relative; max-height: 260px; overflow: hidden; }
.preview-fade::after { content: ""; position: absolute; inset: auto 0 0 0; height: 140px; background: linear-gradient(transparent, var(--surface)); }
.preview-fade .blur { filter: blur(4px); user-select: none; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-scroll { overflow-x: auto; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td.num { font-family: var(--mono); text-align: right; }
table.data th.num { text-align: right; }
table.data td.edge { text-align: center; color: var(--good); font-weight: 700; }
table.data th.edge { text-align: center; }

.sheet { background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.sheet svg { display: block; width: 100%; height: auto; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.steps h4 { margin: 2px 0 2px; font-size: 15px; }
.steps p { margin: 0; color: var(--ink-2); }
.steps ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; }

.dxf-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.dxf-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.dxf-item code { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }

/* Plans */
.plans h2 { margin: 12px 0 2px; font-size: 22px; letter-spacing: -0.01em; }
.lede { margin: 0 0 14px; color: var(--ink-2); }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .plan-grid { grid-template-columns: 1fr; } }
.plan { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.plan.current { outline: 2px solid var(--accent); }
.plan h3 { margin: 0; font-size: 17px; }
.plan .price { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.plan .price small { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 4px; }
.plan .uses { font-size: 13px; color: var(--accent); font-weight: 700; }
.plan ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; flex: 1; }
.plan li + li { margin-top: 3px; }

.foot { padding: 16px 24px 28px; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.test-tier select { width: auto; padding: 4px 8px; margin-left: 6px; }

/* Groups */
.group { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 12px 0 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.group legend { font-size: 13px; font-weight: 800; padding: 0 6px 0 0; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.seg3 { grid-template-columns: 1fr 1fr 1fr; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); line-height: 1.35; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--accent); }
.lock { font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; letter-spacing: 0; text-transform: none; }
.lock:empty { display: none; }
.is-locked { opacity: 0.55; }
.access { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.access .sub { font-size: 12.5px; font-weight: 700; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.access-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.access-list .ok { color: var(--good); font-weight: 700; }
.access-list .no { color: var(--bad); font-weight: 700; }
.access-list .tilt { color: var(--warn); font-weight: 700; }

/* Settings menu */
.settings { position: relative; }
.settings summary { list-style: none; }
.settings summary::-webkit-details-marker { display: none; }
.settings-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; padding: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 10; }

/* Multi-page previews */
.pages { display: flex; flex-direction: column; gap: 12px; }
.pages .sheet svg { width: 100%; height: auto; }
.page-note { font-size: 12.5px; color: var(--ink-3); margin: 0 0 8px; }
.busy { opacity: 0.6; pointer-events: none; }

.corner-list { display: flex; flex-direction: column; gap: 8px; }
.corner-list:empty { display: none; }
.corner-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: end; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.corner-row .field > span { font-size: 10.5px; }
.corner-row .remove { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 18px; line-height: 1; padding: 6px 4px; }
.corner-row .remove:hover { color: var(--bad); }
.corner-row .run-len { grid-column: 1 / 3; }
.corner-row .remove { grid-row: 1; grid-column: 3; align-self: start; }
.corner-row b { grid-column: 1 / 3; font-size: 12px; color: var(--ink-2); }
fieldset.is-locked .corner-list, fieldset.is-locked #addCorner { opacity: 0.5; }

/* Side menu: tabs on top, the open tab scrolls on its own and stays beside the 3D view. */
.controls { padding: 0; gap: 0; overflow: hidden; }
.side-tabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.side-tabs button {
  flex: 1; border: 0; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 13px;
  padding: 10px 4px; border-radius: 8px 8px 0 0; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent;
}
.side-tabs button:hover { color: var(--ink); }
.side-tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent); border-bottom-color: var(--accent); }
.side-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.side-tab { display: flex; flex-direction: column; gap: 14px; }
.side-tab[hidden] { display: none; }
.side-tab > .group:first-child { border-top: 0; padding-top: 0; }
@media (min-width: 721px) {
  /* Exactly as tall as the 3D view and the info under it: its own content doesn't stretch the row. */
  .controls { contain: size; align-self: stretch; display: flex; flex-direction: column; }
  .side-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-gutter: stable; }
}
.width-row { display: flex; gap: 6px; align-items: stretch; }
.width-row .unit { flex: 1; min-width: 0; }
.steppers { display: flex; flex-direction: column; gap: 2px; }
.steppers button {
  flex: 1; width: 30px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px;
  cursor: pointer; font-size: 10px; line-height: 1; padding: 0; color: var(--ink-2);
}
.steppers button:hover { border-color: var(--accent); color: var(--accent); }
.steppers[hidden] { display: none; }
.subgroup { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.subgroup[hidden] { display: none; }
.viewer-tools { flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 24px); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn[hidden] { display: none; }
.field .lock { margin-left: 4px; }

/* Licence, unlock bar, buying */
.notice { margin: 12px 20px 0; padding: 10px 24px; background: var(--accent-soft); color: var(--ink); font-size: 14px; border-radius: 8px; }
.notice[hidden] { display: none; }
.unlock-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 14px; border-radius: var(--radius) var(--radius) 0 0; }
.unlock-bar .actions { display: flex; gap: 8px; }
.unlock-bar code { font-family: var(--mono); font-size: 12.5px; }
.ok-dot { width: 9px; height: 9px; border-radius: 50%; background: #3a9a5b; flex: none; }
.plans-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.plans-head .currency { width: 120px; }
.dialog { width: min(480px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--line); color: var(--ink); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog h3 { margin: 0 0 12px; }
.dialog .field + .hint, .dialog p { margin: 10px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.dialog-actions #licenceRemove { margin-right: auto; }
.dialog-actions [hidden], .pay-buttons [hidden], .dialog [hidden] { display: none; }
.pay-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.xrp-details { display: grid; gap: 8px; margin: 12px 0; }
.xrp-details div { display: grid; grid-template-columns: 120px 1fr; gap: 8px; align-items: center; }
.xrp-details dt { color: var(--ink-3); font-size: 13px; }
.xrp-details dd { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.xrp-details code, .new-key code { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--surface-2); padding: 3px 6px; border-radius: 6px; }
.new-key { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.new-key code { font-size: 16px; padding: 8px 10px; }
#buyMsg:empty { display: none; }
.brand { color: inherit; text-decoration: none; }

/* Chained walls */
.corner-buttons { display: flex; gap: 8px; }
.corner-buttons .btn { flex: 1; }
.corner-row.is-wall { border-color: var(--accent); }
.wall-own { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.wall-own .hint { grid-column: 1 / -1; }

/* Projects */
.dialog.wide { width: min(620px, calc(100vw - 32px)); }
.project-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.project-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.project-list li.current { border-color: var(--accent); }
.project-list b { display: block; }
.project-list small { color: var(--ink-3); font-size: 12.5px; }
.project-list .actions { display: flex; gap: 6px; align-items: center; flex: none; }
@media (max-width: 700px) { #newProjectTop { display: none; } }

/* A design that can't be built: last good shape faded, problem in red on top. */
.viewer.stale canvas { opacity: 0.3; filter: grayscale(0.6); transition: opacity 0.2s; }
.viewer-problem { position: absolute; left: 14px; right: 14px; bottom: 34px; z-index: 3; max-height: 60%; overflow-y: auto;
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.45; box-shadow: var(--shadow); }
.viewer-problem[hidden] { display: none; }
.typed-box { position: absolute; z-index: 4; pointer-events: none; transform: translate(14px, -50%); padding: 6px 10px; border-radius: 8px;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow); font: 600 15px/1.2 var(--mono); color: var(--ink); white-space: nowrap; }
.typed-box small { display: block; font: 500 11px/1.3 Manrope, sans-serif; color: var(--ink-3); margin-top: 2px; }
.typed-box[hidden] { display: none; }
.scope-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.scope-bar[hidden] { display: none; }
.scope-bar .seg { width: auto; }
.scope-bar .seg button { padding: 5px 12px; }
.point-menu { position: absolute; z-index: 5; width: 220px; padding: 10px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.point-menu[hidden] { display: none; }
.viewer canvas { touch-action: none; }
.exact-chip { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 5; box-shadow: var(--shadow); border-color: var(--accent); }
.exact-chip[hidden] { display: none; }
.num-pad { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 240px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.num-pad[hidden] { display: none; }
.num-pad .np-show { font: 600 22px/1.3 var(--mono); text-align: right; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.num-pad .np-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.num-pad .np-keys .btn { padding: 12px 0; font-size: 18px; }
.num-pad .np-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
/* Fingers: bigger buttons and tabs. */
@media (pointer: coarse) {
  .btn.small { padding: 9px 14px; font-size: 14px; }
  .side-tabs button, .sub-tabs button { padding-top: 12px; padding-bottom: 12px; }
  .point-menu { width: 250px; }
  .point-menu .btn { padding: 11px 14px; }
  .wall-row .remove { font-size: 22px; padding: 8px 4px; }
}
.point-menu b { font-size: 13px; }
.point-menu .pm-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.point-menu .btn { justify-content: flex-start; }
.viewer-problem ul { margin: 6px 0 6px; padding-left: 18px; }
.viewer-problem small { color: var(--ink-2); }

/* Room layout */
.room-layout { grid-template-areas: "controls viewer" "plans plans"; }
.room-views { display: flex; flex-direction: column; gap: 14px; }
.plan-wrap { position: relative; padding: 0; overflow: hidden; }
.plan-tools { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 2; }
.plan-tools .btn { pointer-events: auto; }
.plan-svg { display: block; width: 100%; height: min(52vh, 520px); min-height: 320px; background: var(--surface-2); touch-action: none; cursor: grab; }
.room-viewer { height: min(42vh, 440px); min-height: 280px; }
.p-wall { fill: var(--plan-wall); stroke: var(--plan-wall-line); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.p-wall.sel { fill: var(--accent); }
.p-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: move; }
.p-part { fill: #c2b6a4; stroke: #3b352d; stroke-width: 1; vector-effect: non-scaling-stroke; }
.p-plate { fill: none; stroke: #7d756b; stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.p-screen { cursor: move; }
.p-screen.sel .p-part { fill: var(--accent); }
.p-hit { stroke: transparent; fill: none; }
.p-label { fill: var(--ink); font-family: Manrope, Arial, sans-serif; font-weight: 600; pointer-events: none; }
.p-label.wall { fill: var(--plan-wall-text); }
/* Plan colours: dark walls on a light plan, light walls on a dark plan. */
:root { --plan-wall: #6f6a63; --plan-wall-line: #3b352d; --plan-wall-text: #2b2620; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --plan-wall: #ece8e1; --plan-wall-line: #ffffff; --plan-wall-text: #f4f1ec; } }
:root[data-theme="dark"] { --plan-wall: #ece8e1; --plan-wall-line: #ffffff; --plan-wall-text: #f4f1ec; }
.p-joint { fill: var(--plan-wall); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.wall-chain { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.wall-row { display: grid; grid-template-columns: 22px 1fr 1fr 1fr 24px; gap: 6px; align-items: end; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.wall-row.sel { border-color: var(--accent); }
.wall-row .num { font-weight: 700; color: var(--ink-2); font-size: 13px; padding-bottom: 9px; }
.wall-row .field > span { font-size: 10.5px; }
.wall-row .remove { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 18px; padding: 6px 2px; }
.chain-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.grid-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.screen-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.screen-list li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.screen-list li.current { border-color: var(--accent); }
.screen-list b { display: block; font-size: 14px; }
.screen-list small { color: var(--ink-3); }
.sel-box { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1px solid var(--accent); border-radius: 8px; margin-top: 10px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.rect-room summary { cursor: pointer; font-size: 13px; color: var(--ink-2); margin: 6px 0; } .rect-room[open] { display: flex; flex-direction: column; gap: 8px; }
.wall-row { grid-template-columns: 16px 1.2fr 1fr 1fr 22px; gap: 4px; }
.wall-row .unit input { padding: 7px 22px 7px 6px; }
.wall-row .unit em { right: 6px; font-size: 11px; }

/* Room in the designer */
.room-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.room-body[hidden] { display: none; }
.room-body h4.sub { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.viewer.drawing canvas { cursor: crosshair; }
.viewer.grab canvas { cursor: grab; }
.chain-head .btn-row { flex-wrap: nowrap; } .chain-head b { white-space: nowrap; }
.sub-tabs { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.sub-tabs button { flex: 1; border: 0; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13px; padding: 7px 4px; border-radius: 6px; cursor: pointer; }
.sub-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); outline: 1px solid var(--line); }
.sub-tab { display: flex; flex-direction: column; gap: 14px; }
.sub-tab[hidden] { display: none; }
.sub-tab > .group:first-child, .sub-tab > .field:first-child { border-top: 0; padding-top: 0; }
.wall-row .row-acts { display: flex; flex-direction: column; align-items: center; }
.wall-row .row-acts .remove { padding: 0 2px; line-height: 1.2; }
.undo-redo { display: inline-flex; gap: 4px; margin-right: 6px; }
.dims-menu { position: relative; }
.dims-menu summary { list-style: none; }
.dims-menu summary::-webkit-details-marker { display: none; }
.dims-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 210px; padding: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.tab-head .actions .label-pick { flex-direction: row; align-items: center; gap: 6px; } .tab-head .actions .label-pick select { width: auto; }

/* Guide */
.dialog.guide { width: min(860px, calc(100vw - 32px)); height: min(640px, calc(100vh - 48px)); padding: 0; display: none; }
.dialog.guide[open] { display: flex; flex-direction: column; }
.guide-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.guide-head h3 { margin: 0; }
.guide-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px 1fr; }
.guide-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-right: 1px solid var(--line); overflow-y: auto; background: var(--surface-2); }
.guide-nav button { text-align: left; border: 0; background: transparent; color: var(--ink-2); padding: 9px 10px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.guide-nav button[aria-current="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.guide-pages { overflow-y: auto; padding: 16px 22px 22px; line-height: 1.5; }
.guide-pages h4 { margin: 0 0 10px; font-size: 17px; }
.guide-pages section[hidden] { display: none; }
.guide-pages li { margin-bottom: 7px; }
.guide-keys td { padding: 6px 12px 6px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.guide-keys td:first-child { font-family: var(--mono); white-space: nowrap; color: var(--ink); }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.room-tip { margin: 0; }
@media (max-width: 720px) { .guide-body { grid-template-columns: 1fr; } .guide-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); } }
.tabs .dl-all { margin-left: auto; align-self: center; margin-bottom: 6px; white-space: nowrap; }
.my-mats { margin-top: 10px; }
.my-mats .swatches { max-height: 196px; overflow-y: auto; padding: 3px; }
.my-mats .row-btns { margin-top: 8px; }
.my-mats.is-locked .swatches, .my-mats.is-locked .row-btns { display: none; }
.dialog-actions #matsWoodmatt { margin-right: auto; }
.mat-list { list-style: none; margin: 0; padding: 0; max-height: min(420px, 55vh); overflow-y: auto; border-top: 1px solid var(--line); }
.mat-list li { display: grid; grid-template-columns: 40px 32px 32px minmax(70px, 0.6fr) minmax(120px, 1.4fr) auto auto; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mat-list input[type="color"] { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.mat-list input[type="text"] { min-width: 0; width: 100%; }
.mat-list label { display: flex; gap: 4px; align-items: center; font-size: 12px; white-space: nowrap; }
@media (max-width: 560px) { .mat-list li { grid-template-columns: 40px 32px 32px 1fr auto; } .mat-list .mat-brand { display: none; } }
.btn.danger { background: #b3261e; border-color: #b3261e; color: #fff; }
.btn.danger:hover { background: #8f1d17; border-color: #8f1d17; }
.project-list li.confirming { border-color: #b3261e; }
.mat-photo { position: relative; width: 40px; height: 32px; padding: 0; border: 1px dashed var(--line); border-radius: 6px; background: var(--surface-2) center / cover no-repeat; color: var(--ink-3); font-size: 18px; cursor: pointer; }
.mat-photo-x { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 12px; line-height: 1; cursor: pointer; }
.brand-mod { font-weight: 600; font-size: 12px; color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }
