/* style.css — the studio's own layout, on the shared sheet's tokens
   (/permitude.css is linked first). No colour is defined here. */
:root {
  --topbar-h: 52px;
  --hint-h: 30px;
  --gizmo-px: 120px;
  --rightpanels-w: 250px;
  --sidebar-w: 320px;
}

html, body { height: 100%; }
body {
  display: flex; flex-direction: column;
  font-size: 13px; line-height: 1.45;
  background: var(--paper); color: var(--ink);
  overflow: hidden;
}
button { font: inherit; color: inherit; }
.grow { flex: 1; }
.count { font-size: 11px; color: var(--ink2); white-space: nowrap; }
.btn .icon { width: 1em; height: 1em; }
.btn-icon { width: 30px; padding: 0; }
button.x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: 0; background: none;
  color: var(--ink2); cursor: pointer;
}
button.x:hover { color: var(--ink); }
.hint-line { font-size: 11px; color: var(--ink3); line-height: 1.4; }
.row { display: flex; gap: 6px; align-items: center; }
.row > .btn { flex: 1; }
.row > .hint-line { flex: 1; }
.row.end { justify-content: flex-end; }
.row.end > .btn { flex: none; }
.side-empty { padding: 6px 4px; font-size: 12px; color: var(--ink3); }

/* ---- header ---- */
#topbar {
  flex: none; height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 16px 0 20px; border-bottom: 1px solid var(--ink);
  background: var(--paper);
}
#topbar .wordmark { flex: none; white-space: nowrap; }
#project { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; color: var(--ink2); }
#sitebrief { display: inline-flex; align-items: center; gap: 10px; min-width: 0; cursor: help; }
#site-address { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#project .sep { color: var(--rule); }
#meta { font-size: 12px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#outcome { flex: none; }
#modebtns { flex: none; display: flex; gap: 22px; align-self: stretch; align-items: stretch; }
#modebtns .tab {
  flex: none;
  border: 0; border-bottom: 2px solid transparent; background: none;
  padding: 0 4px; cursor: pointer;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em;
  font-size: 12px; font-weight: 700; color: var(--ink3);
}
#modebtns .tab:hover { color: var(--ink); }
#modebtns .tab.on { color: var(--ink); border-bottom-color: var(--ink); }
#modebtns .tab:disabled { color: var(--rule); cursor: default; }

/* ---- the main row: viewport + sidebar ---- */
#main { flex: 1; min-height: 0; display: flex; }
#viewport { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--paper); }
#gl { display: block; position: relative; width: 100%; height: 100%; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#map.hidden { display: none; }
#gl-dead {
  position: absolute; inset: 0 0 var(--hint-h) 0; display: grid; place-items: center;
  padding: 24px; text-align: center; color: var(--ink2); font-size: 14px;
}
#gl-dead p { max-width: 36em; }

#hint {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--hint-h);
  display: flex; align-items: center; padding: 0 14px;
  border-top: 1px solid var(--rule); background: var(--paper);
  font-family: var(--mono); font-size: 11px; color: var(--ink2); letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; pointer-events: none;
}
#hint b { color: var(--ink); }

#banner {
  position: absolute; top: 12px; left: 490px; right: 270px; width: fit-content; margin: 0 auto;
  max-width: calc(100% - 760px); padding: 6px 12px; z-index: 5;
  background: var(--orange-tint); border: 1px solid var(--orange); color: var(--ink);
  font-size: 12px;
}
#assumedbar {
  position: absolute; bottom: calc(var(--hint-h) + 12px); left: 0; right: 0; width: fit-content; margin: 0 auto;
  max-width: min(640px, calc(100% - 32px)); z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--paper); border: 2px solid var(--orange); color: var(--ink); font-size: 12px;
}
#banner.whatif {
  background: var(--blue-tint); border: 2px solid var(--blue); color: var(--blue);
  font-weight: 700; font-size: 13px; padding: 8px 16px;
}

/* ---- the pin: an earlier build, a shared design or a teaching model on the
   3D view. First in the right-hand panel stack, so the section and laser
   panels step down under it and nothing covers the toolbar ---- */
#pinbar {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--ink); font-size: 12px; line-height: 1.4;
}
#pinbar .btn { height: 26px; }

/* ---- a teaching model on screen: the pin bar, the viewport and the meta all turn blue ---- */
body.teaching #pinbar { background: var(--blue); border-color: var(--blue); color: var(--white); }
body.teaching #pinbar .btn { background: transparent; border-color: var(--white); color: var(--white); }
body.teaching #pinbar .btn:hover { background: var(--blue2); }
body.teaching[data-mode="model"] #viewport::after {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--blue);
}
body.teaching[data-mode="model"] #meta { color: var(--blue); font-weight: 700; }

/* ---- full-page notice (no token / revoked link / nothing built yet) ---- */
#notice {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
.notice-box {
  width: min(440px, calc(100vw - 48px));
  background: var(--paper); border: 1px solid var(--ink);
  padding: 18px 22px; display: flex; flex-direction: column; gap: 10px;
  font-size: 14px;
}
.notice-box p { color: var(--ink2); }

/* ---- the floating columns (Model page): toolbar over selection on the left, tool panels on the right above the gizmo ---- */
#leftpanels, #rightpanels { position: absolute; top: 12px; z-index: 4; display: flex; flex-direction: column; gap: 8px; }
#leftpanels {
  left: 14px; bottom: calc(var(--hint-h) + 12px);
  align-items: flex-start; justify-content: space-between; pointer-events: none;
}
#leftpanels > * { pointer-events: auto; max-width: 100%; }
#viewport:has(#rightpanels > :not(.hidden)) #leftpanels { max-width: calc(100% - var(--rightpanels-w) - 36px); }
#rightpanels {
  right: 14px; width: var(--rightpanels-w); overflow-y: auto;
  max-height: calc(100% - var(--hint-h) - var(--gizmo-px) - 52px);
}
#rightpanels > * { flex: none; }

#toolbar {
  flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--ink);
}
.tbgroup { display: flex; align-items: center; gap: 6px; }
.tblabel { width: 44px; flex: none; }
.tbbtns { display: flex; gap: 4px; flex-wrap: wrap; }
#btn-help { margin-left: auto; }
.tbbtns .btn { gap: 6px; background: var(--white); border-color: var(--rule); }
.tbbtns .btn:hover { background: var(--paper2); }
.tbbtns .btn.btn-on, .tbbtns .btn.btn-on:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.panel { background: var(--paper); border: 1px solid var(--ink); display: flex; flex-direction: column; }
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--rule); background: var(--paper2);
}
.panel-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
#lvl-section:not(.hidden) + #plb-section:not(.hidden) { border-top: 1px solid var(--ink); }
#laserpanel > .redline { border-top: 1px solid var(--rule); }
.seg { display: flex; }
.seg .btn { flex: 1; background: var(--white); }
.seg .btn + .btn { border-left: 0; }
.seg .btn.btn-on { background: var(--ink); color: var(--paper); }
.lvl-row { display: flex; gap: 6px; align-items: center; }
.lvl-row .input { flex: 1; min-width: 0; text-align: center; padding: 5px; font-size: 13px; height: 30px; }
.readout { font-size: 11px; line-height: 1.6; color: var(--ink2); white-space: pre-line; }
.readout .lvl-main { color: var(--ink); }
.readout:empty { display: none; }
#sec-slider { width: 100%; margin: 4px 0; accent-color: var(--blue); }
.sec-row { display: flex; align-items: center; gap: 8px; }
.sec-row .readout { flex: 1; }
.redline { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--rule); padding-top: 8px; }
.redline .label { color: var(--red); }
.redline .input { border-color: var(--red); }
.redline .row > .btn { flex: none; }
.redline.not-yours > :not(.redline-off), .redline:not(.not-yours) > .redline-off { display: none; }

#selpanel { width: 330px; min-height: 0; }
#selpanel > .panel-body { min-height: 0; overflow-y: auto; }
#sel-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; overflow-y: auto; }
#sel-chips:empty { display: none; }
.selchip { font-size: 11px; letter-spacing: .04em; text-transform: none; gap: 6px; }
.selchip .sub { color: var(--ink3); }
.selchip .drop {
  display: inline-flex; padding: 0; border: 0; background: none; color: inherit; cursor: pointer;
}
.selchip .drop:hover { color: var(--red); }
.measure {
  font-size: 11.5px; line-height: 1.6; color: var(--ink2);
  background: var(--white); border: 1px solid var(--rule); padding: 6px 8px; white-space: pre-wrap;
}
.measure:empty { display: none; }
.measure .mdim { color: var(--ink); }
.measure .msub { color: var(--ink3); }

/* ---- a data provider's credit, styled to Google's text attribution (Solar API policies) ---- */
#credit {
  position: absolute; right: 0; bottom: 0; height: var(--hint-h); z-index: 1;
  display: flex; align-items: center; padding: 0 14px; background: var(--paper);
  font-family: Roboto, sans-serif; font-weight: 400; font-size: 12px; color: #5E5E5E;
  white-space: nowrap; pointer-events: none;
}

/* ---- the Google map's credit (Map Tiles API policies: logo 16-19dp with clear space; the data line whole, unobscured) ---- */
#mapcredit {
  position: absolute; left: 0; bottom: var(--hint-h); z-index: 1; max-width: 100%;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding: 5px 10px 5px 10px;
  background: var(--paper); font-family: Roboto, sans-serif; font-weight: 400; font-size: 12px; color: #1F1F1F;
  pointer-events: none;
}
#mapcredit.hidden { display: none; }
#mapcredit-ours { color: #5E5E5E; border-left: 1px solid var(--ink3); padding-left: 12px; }
.map-note { margin: 0; font-size: 12px; color: var(--ink2); }
.map-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.map-see { display: flex; align-items: center; gap: 6px; font-size: 12px; }

/* ---- the direction-frame caption under the gizmo (viewer-gizmo.js draws the gizmo into the canvas) ---- */
#compass {
  position: absolute; right: 12px; bottom: calc(var(--hint-h) + 8px); width: 120px;
  text-align: center; color: var(--ink); pointer-events: none; user-select: none;
}

/* ---- sidebar ---- */
#sidebar {
  position: relative; width: var(--sidebar-w); flex: none; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--paper); border-left: 1px solid var(--ink);
}
#sidebar-grip {
  position: absolute; top: 0; bottom: 0; left: -3px; width: 7px;
  cursor: col-resize; z-index: 7;
}
#sidebar-grip::after { content: ""; position: absolute; inset: 0 2px; }
#sidebar-grip:hover::after, body.resizing #sidebar-grip::after { background: var(--blue); }
body.resizing { cursor: col-resize; user-select: none; }

#sidebar > section { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--ink); }
#designlog, #objects { flex: 1; }
#notespanel, #sheetnotes { flex: none; max-height: 40%; }
#sheetladder { flex: none; }
#sheetnotes { flex: 1; max-height: none; }
.side-head {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: var(--paper2);
  text-align: left; cursor: pointer; user-select: none;
}
.side-head.static { cursor: default; }
.side-head .chev { transform: rotate(90deg); transition: transform .12s; color: var(--ink2); }
#sidebar section.collapsed .side-head .chev { transform: none; }
#sidebar section.collapsed { flex: none; }
#sidebar section.collapsed > :not(.side-head) { display: none; }
.side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
#obj-filter { margin: 8px 10px 0; width: calc(100% - 20px); padding: 5px 8px; font-size: 13px; }
#obj-list { gap: 0; padding-top: 6px; }

.logcard, .notecard {
  flex: none; border: 1px solid var(--rule); background: var(--white);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
}
.logcard.shown { border-color: var(--ink); }
.log-head, .note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.log-when, .note-when { font-size: 11px; color: var(--ink2); white-space: nowrap; }
.log-note, .note-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.log-gates { font-size: 11px; }
.log-view { height: 24px; padding: 0 8px; font-size: 10px; }
.notecard { border-left: 2px solid var(--red); }
.note-where { font-size: 12px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-waiting { font-size: 12px; color: var(--ink3); font-style: italic; }
.note-answer { font-size: 12px; color: var(--ink2); border-top: 1px solid var(--rule); padding-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.note-resend { width: 22px; height: 22px; font-size: 14px; }
.note-edit { display: flex; flex-direction: column; gap: 6px; }
.note-answer-text { white-space: pre-wrap; word-break: break-word; }

/* the Parts index: a group's chevron opens it to its members, its name selects them all */
.obj-group { display: flex; border-bottom: 1px solid var(--rule2); font-size: 13px; }
.obj-group > button { display: flex; align-items: center; border: 0; background: none; cursor: pointer; }
.obj-group > button:hover { background: var(--paper2); }
.obj-toggle { padding: 5px 4px 5px 6px; color: var(--ink2); }
.obj-toggle .icon { transition: transform .12s; }
.obj-group.open .obj-toggle .icon { transform: rotate(90deg); }
.obj-pick { flex: 1; min-width: 0; gap: 8px; padding: 5px 6px 5px 4px; text-align: left; }
.obj-group.sel .obj-pick, .obj-group.sel .obj-pick .obj-n { background: var(--blue-tint); color: var(--blue); }
.obj-group-name { flex: 1; }
.obj-n { font-size: 11px; color: var(--ink2); }
.obj-members { display: flex; flex-direction: column; padding: 2px 0 6px 14px; }
.obj-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 6px;
  cursor: pointer; border: 1px solid transparent; font-size: 12.5px;
}
.obj-row:hover { background: var(--paper2); }
.obj-row.sel { background: var(--blue-tint); border-color: var(--blue); color: var(--blue); }
.obj-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- the pages: body[data-mode] names the one on screen ---- */
.page { display: none; }
body[data-mode="sheets"] #sheetview,
body[data-mode="chat"] #chatview,
body[data-mode="sketch"] #sketchview,
body[data-mode="build"] #buildview,
body[data-mode="gallery"] #galleryview,
body[data-mode="learn"] #learnview {
  position: absolute; inset: 0; z-index: 3;
  display: flex; background: var(--paper);
}
body:not([data-mode="model"]) :is(#map, #mapcredit, #hint, #credit, #compass, #leftpanels, #rightpanels, #banner, #assumedbar, #pinbar, #notice) { display: none !important; }
#sidebar > section.sheetside { display: none; }

/* ---- design values: one row per declared value, nudged in place ---- */
#valuespanel { flex: none; max-height: 56%; }
.side-hint { flex: none; padding: 8px 14px 4px; }
#valuespanel .side-body { gap: 0; padding: 4px 10px 8px; }
#values-foot { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 6px 10px 8px; border-top: 1px solid var(--rule2); }
#values-foot .notefield { min-height: 0; }
.val-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-bottom: 1px solid var(--rule2); }
.val-row.edited { background: var(--blue-tint); }
.val-row.places { box-shadow: inset 3px 0 0 var(--blue); }
.val-row.places .val-name { color: var(--blue); }
.val-row.shown { background: var(--orange-tint); box-shadow: inset 3px 0 0 var(--orange); }
.val-row.assumed { flex-wrap: wrap; background: var(--orange-tint); box-shadow: inset 3px 0 0 var(--orange); }
.val-stamp { align-self: flex-start; margin-bottom: 2px; }
.val-guess { flex-basis: 100%; display: flex; align-items: center; gap: 6px; padding: 2px 0 3px 4px; font-size: 11px; }
.val-guess .val-field.val-bad { border-color: var(--red); }
#values-build { flex: none; }
.val-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; line-height: 1.25; }
.val-from { font-size: 10px; color: var(--ink3); text-decoration: line-through; }
.val-ctl { flex: none; display: flex; align-items: center; gap: 3px; }
.val-ctl .btn-icon { width: 24px; height: 24px; padding: 0; }
.val-field { flex: none; width: 82px; max-width: 82px; padding: 3px 5px; font-size: 12px; text-align: right; }
.val-row.edited .val-field { border-color: var(--blue); color: var(--blue); }
.val-grip { display: inline-flex; padding: 4px 2px; color: var(--ink3); cursor: ew-resize; touch-action: none; user-select: none; }
.val-grip:hover { color: var(--blue); }
.val-verdict:empty { display: none; }
.fin-hex { font-size: 11px; color: var(--ink2); }
.fin-more { font-size: 10px; color: var(--blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.val-row.edited .fin-hex { color: var(--blue); }
.fin-swatch { flex: none; width: 34px; height: 24px; padding: 1px; border: 1px solid var(--rule); background: none; cursor: pointer; }
.val-verdict.val-ok { color: var(--green); }
.val-verdict.val-bad { color: var(--red); }
body[data-mode="sheets"] #sidebar > section { display: none; }
body[data-mode="sheets"] #sidebar > section.sheetside { display: flex; }

#buildview, #galleryview, #learnview, #chatview { flex-direction: column; min-height: 0; }
.page-head {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--paper2);
}
.page-head .input { width: 320px; padding: 5px 8px; font-size: 13px; }

/* ---- the Sheets page: rail, stage, redline popup ---- */
#sheetside { width: 236px; flex: none; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--ink); }
#sheetrail { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.rail-row {
  flex: none; display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center;
  padding: 6px; border: 1px solid var(--rule2); background: transparent;
  text-align: left; cursor: pointer; color: inherit;
}
.rail-row:hover { border-color: var(--rule); }
.rail-row.on { border-color: var(--ink); background: var(--white); }
.rail-thumb { display: block; width: 44px; height: 34px; background: var(--white); border: 1px solid var(--rule); overflow: hidden; }
.rail-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rail-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rail-n { font-size: 11px; font-weight: 700; }
.rail-title { font-size: 11px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#sheetstory { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.story-lede { font-size: 15px; }
.sheet-gaps { margin: 0; padding-left: 18px; color: var(--ink2); }
.sheet-gaps li { margin: 2px 0; }
.rail-row.rail-block { border-color: var(--orange); background: var(--orange-tint); }
.rail-row.rail-block.on { border-color: var(--ink); }
.rail-block .rail-thumb { display: flex; align-items: center; justify-content: center; color: var(--orange); border-color: var(--orange); }
.rail-block .rail-n { color: var(--orange); }

/* ---- what holds the set back: the page in place of the stage ---- */
#sheetblock { flex: 1; min-width: 0; overflow-y: auto; padding: 28px 32px; }
#sheetblock-body { max-width: 760px; display: flex; flex-direction: column; gap: 14px; font-size: 14px; }
.block-head { display: flex; align-items: center; gap: 12px; }
.block-head h2 { font-size: 20px; margin: 0; }
.block-group { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.block-group-head { display: flex; align-items: center; gap: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--ink); }
.block-group > p { font-size: 13px; }
.block-row { display: flex; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--rule2); }
.block-what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.block-what .muted { font-size: 13px; }
.block-row .btn { flex: none; }

#sheetstage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
#stage-stamps { position: absolute; top: 12px; left: 16px; display: flex; gap: 8px; align-items: center; z-index: 2; }
#stage-stamps .stamp { background: var(--paper); }
#stage-zoom { position: absolute; top: 12px; right: 16px; display: flex; gap: 4px; z-index: 2; }
#stage-zoom .btn { background: var(--paper); }
#sheetscroll {
  flex: 1; min-height: 0; overflow: auto; padding: 52px 28px calc(var(--hint-h) + 24px);
  display: flex; cursor: grab;
  justify-content: center; align-items: center;
  /* "safe" falls back to start-alignment once the sheet overflows: centred overflow
     puts the top and left of the sheet outside the scrollable area, unreachable. */
  justify-content: safe center; align-items: safe center;
}
#sheetframe { position: relative; flex: none; }
#sheetimg {
  display: block; background: var(--white);
  max-width: calc(100vw - var(--sidebar-w) - 236px - 56px);
  max-height: calc(100vh - var(--topbar-h) - var(--hint-h) - 76px);
  border: 1px solid var(--rule); box-shadow: 4px 4px 0 var(--paper3);
  cursor: crosshair;
}
#sheetimg:not([src]) { min-width: 200px; min-height: 140px; }
#sheetmarker {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid var(--red); border-radius: 50%;
  background: var(--red-tint); pointer-events: none;
}
#sheethint {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--hint-h);
  display: flex; align-items: center; padding: 0 14px;
  border-top: 1px solid var(--rule); background: var(--paper);
  font-family: var(--mono); font-size: 11px; color: var(--ink2); pointer-events: none;
}
#sheetnote {
  position: absolute; right: 16px; bottom: calc(var(--hint-h) + 16px); width: 290px; z-index: 4;
  background: var(--paper); border: 1px solid var(--red); display: flex; flex-direction: column;
}
#sheetnote .panel-head { background: var(--red-tint); color: var(--red); }
#sheetnote .panel-head .label { color: var(--red); }
#sheetnote .panel-head .x { color: var(--ink2); }

/* ---- the Sketch page: the plan on a canvas, the tools over it, the send panel ---- */
#sketchstage { position: relative; flex: 1; min-width: 0; }
#sketchcanvas {
  position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - var(--hint-h));
  display: block; touch-action: none; cursor: grab;
}
#sketchtools {
  position: absolute; top: 12px; left: 14px; z-index: 2; max-width: calc(100% - 180px);
  display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--ink);
}
#sketch-zoom { position: absolute; top: 12px; right: 16px; display: flex; gap: 4px; z-index: 2; }
#sketch-zoom .btn { background: var(--paper); }
#sketch-undo { margin-left: 10px; }
#sketch-zoom .btn.btn-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
#sketch-entry {
  position: absolute; z-index: 3; width: 220px; transform: translate(-50%, -50%);
  padding: 5px 8px; font-size: 13px; border-color: var(--red); resize: none;
}
#sketch-entry.caption { width: 320px; }
#sketch-entry.bad { outline: 2px solid var(--red); }
#sketchsend { position: absolute; left: 16px; bottom: calc(var(--hint-h) + 16px); width: 300px; z-index: 2; }
#sketchsend .redline { border-top: 0; }
#sketchcompass {
  position: absolute; right: 12px; bottom: calc(var(--hint-h) + 8px); width: 120px; z-index: 2;
  text-align: center; color: var(--ink); pointer-events: none; user-select: none;
}
#sketchcompass svg { display: block; }
#sketchcompass circle { fill: none; stroke: var(--ink3); stroke-width: 1.5; }
#sketchcompass #sketch-needle { fill: var(--red); }
#sketchcompass text {
  font-family: var(--mono); font-weight: 700; font-size: 15px; fill: var(--ink);
  text-anchor: middle; dominant-baseline: central;
}
#sketchcompass text.north { fill: var(--red); }
#sketchcompass text.south { fill: var(--ink2); }
#sketchhint {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--hint-h);
  display: flex; align-items: center; padding: 0 14px;
  border-top: 1px solid var(--rule); background: var(--paper);
  font-family: var(--mono); font-size: 11px; color: var(--ink2);
  white-space: nowrap; overflow: hidden; pointer-events: none;
}

/* the ladder: adopt → pay → print, in the sidebar */
#ladder-body { padding: 14px; gap: 14px; }
.ladder-intro { font-size: 13px; }
.step { display: grid; grid-template-columns: 24px 1fr; gap: 12px; }
.step.locked { opacity: .55; }
.step-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-body p { font-size: 13px; }
.step-head { display: flex; align-items: center; gap: 8px; }
.step-head b { font-size: 14px; }
.step-price { color: var(--ink); font-weight: 700; }
.step-controls { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.step-row { display: flex; gap: 6px; flex-wrap: wrap; }
.step-fail { font-size: 12px; color: var(--red); }
.step-fail:empty { display: none; }
.step-why { font-size: 12px; color: var(--ink2); font-style: italic; }
.step-confirm { font-size: 13px; }

/* ---- the /packet page (the paid surface's shell) ---- */
body.packet { display: block; overflow: auto; min-height: 100vh; }
.packet-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 56px; border-bottom: 1px solid var(--ink);
}
.packet-main {
  max-width: 960px; margin: 0 auto; padding: 44px 56px 56px;
  display: flex; flex-direction: column; gap: 32px;
}
.packet-title { display: flex; flex-direction: column; gap: 8px; }
.packet-title h1 { font-size: 30px; }
.packet-box {
  border: 1px solid var(--ink); background: var(--white); padding: 24px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.packet-line { display: flex; align-items: flex-start; gap: 10px; }
.packet-line .stamp { margin-top: 3px; }
.packet-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 13px; }
.packet-keep { font-size: 13px; color: var(--ink2); }
.packet-adopt {
  display: flex; flex-direction: column; gap: 18px;
  border-top: 1px solid var(--ink); padding-top: 32px;
}
.packet-adopt-head { display: flex; align-items: flex-start; gap: 12px; }
.packet-adopt-head .stamp { margin-top: 3px; }
.packet-adopt-copy { display: flex; flex-direction: column; gap: 6px; }
.packet-adopt-copy h2 { font-size: 18px; }
.packet-adopt-copy p { color: var(--ink2); max-width: 640px; text-wrap: pretty; }
.packet-pages {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px;
}
.packet-page { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.packet-thumb {
  border: 1px solid var(--rule); background: var(--white); aspect-ratio: 11 / 8.5;
  overflow: hidden;
}
.packet-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.packet-page figcaption { font-size: 11px; }
.packet-adopt-box {
  border: 1px solid var(--ink); background: var(--paper2); padding: 24px 28px;
  display: flex; flex-direction: column; gap: 14px; align-items: flex-start;
}
@media (max-width: 600px) {
  .packet-header { padding: 0 20px; }
  .packet-main { padding: 28px 20px 40px; gap: 24px; }
  .packet-title h1 { font-size: 24px; }
  .packet-box, .packet-adopt-box { padding: 18px 16px; }
  .packet-line, .packet-adopt-head { flex-direction: column; gap: 8px; }
  .packet-actions { flex-direction: column; }
  .packet-actions .btn, .packet-adopt-box .btn { width: 100%; white-space: normal; height: auto; min-height: 46px; padding: 10px 16px; }
  .packet-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}


/* ---- the /stringer page (one cut stringer, from the Build page) ---- */
.stringer-body { display: flex; flex-direction: column; gap: 16px; }
.sc-sheet { border: 1px solid var(--rule); background: var(--white); overflow-x: auto; }
.sc-svg { display: block; width: 100%; min-width: 720px; height: auto; padding: 8px; box-sizing: border-box; }
.sc-piece { fill: var(--orange-tint); stroke: var(--ink); stroke-linejoin: miter; }
.sc-waste { fill: url(#waste); stroke: none; }
.sc-hatch { stroke: var(--rule); }
.sc-blank { fill: none; stroke: var(--ink3); }
.sc-dim, .sc-ext { stroke: var(--blue); }
.sc-ext { opacity: .7; }
.sc-arrow { fill: var(--blue); }
.sc-dimt, .sc-mark { fill: var(--blue); font-family: var(--mono); font-weight: 700; }
.sc-note { fill: var(--ink2); font-family: var(--sans); }
.sc-pt { fill: var(--blue); }
.sc-throat { stroke: var(--green); }
.sc-throatt { fill: var(--green); font-family: var(--mono); font-weight: 700; }
.sc-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; }
.sc-legend span { display: inline-flex; align-items: center; gap: 8px; }
.sc-sw { width: 22px; height: 12px; display: inline-block; border: 1px solid var(--ink); }
.sc-sw-wood { background: var(--orange-tint); }
.sc-sw-waste { background: repeating-linear-gradient(45deg, var(--rule) 0 2px, transparent 2px 5px); border-color: var(--rule); }
.sc-sw-throat { height: 0; border: none; border-top: 2px solid var(--green); }
.sc-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sc-steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; }
.sc-n { white-space: nowrap; }
.sc-table td:last-child { white-space: nowrap; }
.cut-how { white-space: nowrap; }
@media (max-width: 760px) {
  .sc-cols { grid-template-columns: minmax(0, 1fr); }
}


/* ---- toast (dom.js): coloured by meaning ---- */
.toast {
  position: fixed; bottom: calc(var(--hint-h) + 16px); left: 50%; transform: translateX(-50%);
  padding: 8px 14px; z-index: 30; font-size: 13px;
  background: var(--paper); border: 1px solid var(--green); color: var(--green);
  box-shadow: 3px 3px 0 var(--paper3);
}
.toast-bad { border-color: var(--red); color: var(--red); }

/* ---- the design gallery: cards with a browser-drawn picture ---- */
#gallery-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px;
  display: grid; align-content: start; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
#gallery-list > :not(.gallerycard) { grid-column: 1 / -1; }
.gallerycard { margin: 0; background: var(--white); border: 1px solid var(--rule); overflow: hidden; }
.gallerycard.shown { border-color: var(--ink); }
.gallery-pic { display: block; width: 100%; aspect-ratio: 8 / 5; background: var(--paper); border-bottom: 1px solid var(--rule2); }
.gallery-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-nopic { display: flex; align-items: center; justify-content: center; font-size: 11px; }
.gallerycard figcaption { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.gallery-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gallery-name { font-weight: 600; }
.gallery-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.gallery-line { font-size: 11px; line-height: 1.35; }

/* ---- the Build page: the purchase list, then the cut list ---- */
#build-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; max-width: 1040px; }
#build-body > .notice-box { max-width: 640px; }
.buildgaps { margin-bottom: 16px; }
.buildtitle { font-size: 17px; margin: 20px 0 8px; }
.buildtitle:first-child { margin-top: 0; }
.buildsection { margin-bottom: 16px; }
.buildsection h3 { margin: 0 0 6px; }
.buildtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.buildtable th { text-align: left; font-weight: 600; color: var(--ink2);
  border-bottom: 1px solid var(--ink); padding: 4px 8px 4px 0; }
.buildtable td { border-bottom: 1px solid var(--rule); padding: 4px 8px 4px 0; vertical-align: top; }
.buildtable :is(th, td):first-child { padding-left: 6px; }
.buildtable .tickcell { width: 22px; padding-right: 0; }
.buildtable input[type="checkbox"] { margin: 2px 0 0; accent-color: var(--ink); cursor: pointer; }
.buildtable tr.bought td { color: var(--ink2); }
.pickrow { cursor: pointer; }
.pickrow:hover td { background: var(--paper2); }
.pickrow.picked td { background: var(--paper3); }
.pickrow.picked td:first-child { box-shadow: inset 3px 0 0 var(--ink); }
.builddrawings-lede { font-size: 13px; margin: -4px 0 10px; }
.builddrawings { display: flex; flex-direction: column; gap: 14px; }
.builddrawing { margin: 0; }
.builddrawing figcaption { font-size: 12px; color: var(--ink2); margin-bottom: 4px; }
.builddrawing svg { display: block; width: 100%; height: auto; background: var(--white);
  border: 1px solid var(--rule); box-shadow: 4px 4px 0 var(--paper3); }
.builddrawing.off svg { display: none; }
.builddrawing.off figcaption::after { content: " · nothing of this step"; }
.builddrawing svg .later { opacity: 0.12; }
.builddrawing svg [data-element].lit { stroke: var(--blue); }
.builddrawing svg text.lit { fill: var(--blue); }

.buildsteps { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.steprow { display: grid; grid-template-columns: 28px 1fr auto; gap: 2px 8px; padding: 6px 8px 6px 6px; border-bottom: 1px solid var(--rule); }
.steprow:hover { background: var(--paper2); }
.steprow.picked { background: var(--paper3); box-shadow: inset 3px 0 0 var(--ink); }
.steprow .stepno { color: var(--ink2); }
.steprow .steptitle { font-weight: 600; }
.steprow .stepwords { grid-column: 2 / span 2; }

/* the Build and Chat pages dock beside the model they talk about */
#viewport { --build-w: clamp(380px, 46%, 680px); }
body:is([data-mode="build"], [data-mode="chat"]) :is(#buildview, #chatview) { right: auto; width: var(--build-w); border-right: 1px solid var(--ink); }
body:is([data-mode="build"], [data-mode="chat"]) #gl {
  position: absolute; top: 0; left: var(--build-w);
  width: calc(100% - var(--build-w)); height: 100%;
}
#build-marks {
  flex: none; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px;
  padding: 8px 16px; border-bottom: 1px solid var(--rule); background: var(--white); font-size: 13px;
}
#build-marks .btn.btn-on, #build-marks .btn.btn-on:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
#build-marks-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.markline { display: flex; align-items: center; gap: 8px; }
.markswatch { flex: none; width: 12px; height: 12px; border: 1px solid var(--ink); }
.markswatch-body { background: var(--blue); }
.markswatch-join { background: var(--green); }

@media (max-width: 640px) {
  #build-body { padding: 12px 16px; }
  .buildtable { display: block; overflow-x: auto; }
  body:is([data-mode="build"], [data-mode="chat"]) :is(#buildview, #chatview) { width: auto; right: 0; bottom: 45%; border-right: 0; border-bottom: 1px solid var(--ink); }
  body:is([data-mode="build"], [data-mode="chat"]) #gl { left: 0; top: 55%; width: 100%; height: 45%; }
}

/* ---- the learn catalog ---- */
#learn-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 16px; }
.learn-group { margin: 16px 0 8px; }
.learn-row { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.learncard { margin: 0; background: var(--white); border: 1px solid var(--rule); transition: border-color .3s, box-shadow .3s; }
.learncard img { display: block; width: 100%; border-bottom: 1px solid var(--rule2); background: var(--white); }
.learn-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.learn-head { display: flex; align-items: center; gap: 6px; }
.learn-title { font-weight: 600; }
.learn-text { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ink2); }
.learncard.learn-flash { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-tint); }

/* ---- the tabs no longer fit beside the project line: they take a row of their own ---- */
@media (max-width: 900px) {
  :root { --topbar-h: 88px; }
  #topbar { flex-wrap: wrap; row-gap: 0; }
  #project { flex: 1 1 0; }
  #topbar .grow { display: none; }
  #topbar .wordmark, #project { height: 48px; display: flex; align-items: center; }
  #modebtns {
    order: 1; flex: 0 0 100%; height: 40px;
    border-top: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none;
  }
}

/* ---- narrow windows: nothing may break, nothing need be pretty ---- */
@media (max-width: 720px) {
  #topbar { column-gap: 12px; padding: 0 10px; }
  #modebtns { gap: 10px; }
  #sidebar { width: 200px; }
  :root { --rightpanels-w: 200px; }
}
@media (max-width: 560px) {
  #sitebrief { display: none; }
}

/* ---- the /try page: the hosted trial's sign-in ---- */
.try-said { border-left: 3px solid var(--orange); padding: 6px 12px; background: var(--orange-tint); }

/* ---- the studio's Chat page (the hosted trial) ---- */
#chat-body {
  flex: 1; min-height: 0; overflow-y: auto; width: 100%; max-width: 820px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 28px;
}
.chat-note { font-size: 13px; color: var(--ink2); border-left: 3px solid var(--orange); padding: 6px 12px; background: var(--orange-tint); text-wrap: pretty; }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.chat-log li { overflow-wrap: anywhere; }
.chat-log p { margin: 0 0 8px; text-wrap: pretty; }
.chat-log p:last-child { margin-bottom: 0; }
.chat-you { align-self: flex-end; max-width: 85%; background: var(--blue-tint); padding: 10px 14px; }
.chat-agent { background: var(--white); border: 1px solid var(--rule2); padding: 12px 16px; }
.chat-tool { font-family: var(--mono); font-size: 12px; color: var(--ink3); padding-left: 16px; }
.chat-status { font-size: 13px; color: var(--ink2); min-height: 1.2em; }
.chat-said { color: var(--red); font-size: 13px; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; }
.chat-over { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
@media (max-width: 600px) {
  .chat-form { flex-direction: column; align-items: stretch; }
  .chat-you { max-width: 100%; }
}
.chat-agent :is(p, ul, ol, pre, table, h1, h2, h3, h4) { margin: 0 0 8px; }
.chat-agent :is(p, ul, ol, pre, table, h1, h2, h3, h4):last-child { margin-bottom: 0; }
.chat-agent :is(ul, ol) { padding-left: 20px; }
.chat-agent :is(h1, h2, h3, h4) { font-size: 14px; font-weight: 700; }
.chat-agent code { font-family: var(--mono); font-size: 12px; background: var(--paper2); padding: 0 3px; }
.chat-agent pre { background: var(--paper2); padding: 8px 10px; overflow-x: auto; }
.chat-agent pre code { padding: 0; }
.chat-agent table { border-collapse: collapse; font-size: 13px; }
.chat-agent :is(th, td) { border: 1px solid var(--rule2); padding: 3px 8px; text-align: left; }
.chat-ask { display: flex; flex-direction: column; gap: 8px; background: var(--white); border: 1px solid var(--blue); padding: 12px 16px; }
.chat-ask.answered { border-color: var(--rule2); }
.chat-question p { margin: 0; }
.chat-options { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-options .btn.btn-on, .chat-options .btn.btn-on:disabled { background: var(--ink); border-color: var(--ink); color: var(--paper); opacity: 1; }
