/* Cutter — Nocturne theme.
   Edit 1 of 5: the token block below is the only place colors live.
   Component rules underneath are unchanged in structure; only values moved. */

:root {
  /* Nocturne ground + ramps */
  --bench: #161826;          /* page ground        (--color-bg) */
  --paper: #232532;          /* pane surface       (--color-surface) */
  --sunken: #161826;         /* canvas / input ground */
  --ink: #e9e9ed;            /* text               (--color-text) */
  --muted: #9397ab;          /* muted text         (--color-neutral-500) */
  --faint: #75798c;          /* labels             (--color-neutral-600) */
  --line: #3f424d;           /* borders            (--color-neutral-800) */
  --hairline: #292b31;       /* pane rules         (--color-neutral-900) */
  --accent: #9184d9;         /* accent             (--color-accent) */
  --accent-soft: rgba(145, 132, 217, 0.14);
  --accent-light: #b5abfc;   /* pressed / warning  (--color-accent-400) */
  --accent-deep: #423a6a;    /* accent tint border (--color-accent-800) */
  --danger: #b5abfc;         /* mono palette: warnings read in the accent ramp */
  /* The imprint is the one thing on this canvas that is not a cut, so it is the one thing that
     is not in the accent ramp: a warm clay orange, the colour of the mark it leaves. */
  --imprint: #e0954f;
  --imprint-soft: rgba(224, 149, 79, 0.16);
  --imprint-deep: #6b4526;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0, 0, 0, 0.65);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bench);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16.8px;
  padding: 11.2px 16.8px;
}
.brand { display: flex; align-items: center; gap: 11.2px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--accent-deep); color: var(--accent);
  font-size: 17px;
}
.wordmark { font-size: 18px; font-weight: 500; letter-spacing: -0.015em; }
.tagline {
  color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 11.2px; border-left: 1px solid var(--line);
}
.top-actions { display: flex; align-items: center; gap: 11.2px; }
.top-actions .pair { display: flex; gap: 5.6px; }
.ready { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- workspace grid ---------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, var(--col-draw)) minmax(0, var(--col-view)) 316px;
  grid-template-rows: minmax(0, 1fr);
  position: relative;
  --col-draw: 1.15fr; --col-view: 1fr;   /* the split between canvas and 3D; app.js sets both while dragging */
  gap: 11.2px;
  padding: 0 16.8px 16.8px;
}
/* The drag handle between canvas and 3D. It sits over the grid gap; app.js places it. */
.splitter {
  position: absolute; z-index: 5; width: 14px; cursor: col-resize; touch-action: none;
  display: flex; justify-content: center;
}
.splitter[hidden] { display: none; }
.splitter::after {
  content: ''; width: 3px; height: 100%; border-radius: 2px; background: transparent; transition: background .12s;
}
.splitter:hover::after, .splitter.dragging::after { background: var(--accent); opacity: .55; }
body.splitting { cursor: col-resize; user-select: none; }
@media (max-width: 760px) { .splitter { display: none; } }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-draw, .pane-3d, .pane-settings {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--hairline);
  overflow: hidden;
}
.pane-settings { display: block; padding: 11.2px; overflow-y: auto; }
/* A panel switched off in the header leaves the grid altogether, so the ones that are left
   share the whole width. The column templates per combination live with the breakpoints below. */
.pane[hidden] { display: none; }

.toolbar {
  display: flex; align-items: center; gap: 8.4px;
  padding: 8.4px 11.2px;
  border-bottom: 1px solid var(--hairline);
}
.toolbar .spacer { margin-left: auto; }
.toolbar.bottom { border-bottom: 0; border-top: 1px solid var(--hairline); }
.toolbar-group { display: flex; align-items: center; gap: 5.6px; }
.group-label, .seg-label {
  color: var(--faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  align-self: center; white-space: nowrap;
}
.divider { width: 1px; height: 18px; background: var(--line); flex: none; }
.pane-title { color: var(--faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.canvas-wrap, .viewer-wrap { position: relative; flex: 1; min-height: 0; background: var(--sunken); }
/* How much room the drawing pane and its canvas have depends on which panels are switched on,
   not on the size of the window, so what sits inside them asks them rather than the screen.
   Named, because they are nested: a rule for one must never resolve against the other. Nothing
   inside either is position: fixed, which is the one thing a container would otherwise catch. */
.canvas-wrap { container: canvas / inline-size; }
.pane-draw { container: drawpane / inline-size; }
/* Sooner than clip a button off the end, the row of shape actions takes a second line — but it
   is the last resort, not the plan: the row grows by four buttons the moment the first corner
   goes down, and a toolbar that gains a line there shoves the canvas out from under the pointer
   mid-gesture. So the words the icons beside them already say come off well before it fills up. */
.toolbar.sub { flex-wrap: wrap; }
@container drawpane (max-width: 700px) {
  .toolbar.sub .seg-label { display: none; }
  #canvasSetupBtn span, #canvasSetupBtn .ph-caret-down,
  #patternMenuBtn span, #patternMenuBtn .ph-caret-down { display: none; }
}
@container drawpane (max-width: 620px) {
  .toolbar.sub .segmented.small .seg span { display: none; }
}
.canvas-wrap { min-height: 320px; }
#drawCanvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
#viewer { position: absolute; inset: 0; cursor: grab; }
#viewer canvas { display: block; }

/* ---------- hints ---------- */
.hint {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  color: var(--muted); pointer-events: none;
}
.hint p { max-width: 36ch; margin: 0; font-size: 13px; }
.hint strong { display: block; font-size: 20px; font-weight: 500; letter-spacing: -0.015em; color: var(--ink); margin-bottom: 8.4px; }
/* Sits centred along the bottom, lifted clear of the scale bar and the zoom / pan controls. */
.hint.corner { inset: auto 0 56px 0; padding: 0 16.8px; display: grid; place-items: center; text-align: center; }
.hint.corner strong { font-size: 14px; display: inline; margin: 0; }
.hint.corner p {
  max-width: 40ch; font-size: 12px; background: rgba(35, 37, 50, 0.92);
  box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); padding: 8.4px 11.2px;
}
/* Must come after .hint.corner: both are specificity 0-2-0, so the later rule wins.
   Listed first, the corner variant's display: block beat this and the hint stayed on
   screen with the hidden attribute set. */
.hint[hidden] { display: none; }
/* Top left of the canvas: the shapes on this plate. */
.canvas-tl {
  position: absolute; left: 11.2px; top: 11.2px; z-index: 5;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  max-width: calc(100% - 22.4px); max-height: calc(100% - 22.4px);
  pointer-events: none;   /* the canvas keeps every pixel the controls do not use */
}
/* How the current tool works. It shows itself for a few seconds after you pick a tool, then
   slides back behind its (i), which brings it out again on hover — the canvas is the thing
   people came for, so the explanation does not sit on top of it forever. The (i) lives in the
   toolbar, right beside the three tools it explains. */
.tool-tip { display: inline-flex; align-items: center; flex: none; }
/* No frame around it: the glyph already reads as an (i), and a second ring next to the tool
   buttons would look like a fourth one. It keeps a 32 px box so it is still a touch target. */
.tt-icon {
  flex: none; cursor: help;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  color: #b2b6ca; background: transparent; box-shadow: none;
}
.tt-icon i { font-size: 21px; }
.tool-tip:not(.collapsed) .tt-icon, .tt-icon:hover { color: var(--accent); }
/* The text floats under the icon and is placed by app.js, so opening it never moves the
   toolbar and it can never run off the side of a narrow window. */
.tt-text {
  position: fixed; z-index: 25; pointer-events: none;
  max-width: 34ch; padding: 7px 10px; border-radius: var(--radius);
  color: #b2b6ca; font-size: 12px; line-height: 1.45;
  background: var(--paper); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line);
  /* Clipped rather than resized, so the words never reflow while it slides. */
  transition: clip-path 0.3s ease, opacity 0.22s ease, transform 0.3s ease;
}
.tool-tip.collapsed .tt-text { clip-path: inset(0 100% 0 0); opacity: 0; transform: translateX(-10px); }
@media (prefers-reduced-motion: reduce) { .tt-text { transition: none; } }

.error {
  position: absolute; left: 11.2px; right: 11.2px; bottom: 11.2px;
  display: flex; align-items: flex-start; gap: 8.4px;
  background: var(--hairline); color: var(--ink); box-shadow: inset 0 0 0 1px #595d6c;
  padding: 8.4px 11.2px; border-radius: var(--radius); font-size: 13px;
}
.error::before { content: ""; width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent-light); flex: none; }
.error[hidden] { display: none; }

/* ---------- stats strip ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--hairline);
}
.stats .stat { padding: 8.4px 11.2px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stats .stat + .stat { box-shadow: inset 1px 0 0 var(--hairline); }
.stats .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.stats .v { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  font: inherit; font-weight: 500; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); background: transparent;
  padding: 7px 11px; border-radius: var(--radius); cursor: pointer; line-height: 1.2;
  min-height: 36px;
}
.btn[hidden] { display: none; }
.btn i { font-size: 15px; line-height: 1; }
.btn:hover { background: rgba(233, 233, 237, 0.07); }
.btn:active { background: rgba(233, 233, 237, 0.14); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; }
.btn.primary { color: var(--accent); border-color: var(--accent); background: transparent; }
.btn.primary:hover { background: var(--accent-soft); }
.btn.primary:active { background: rgba(145, 132, 217, 0.22); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 9px; min-height: 30px; font-size: 12px; }
.btn.small i { font-size: 14px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.small { width: 30px; }
.btn.danger { color: var(--danger); }
.btn.file { display: inline-flex; align-items: center; }
.btn.toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: inherit; font-weight: 500; font-size: 13px; background: transparent; color: var(--ink); border: 0;
  padding: 7px 12px; cursor: pointer; min-height: 36px;
}
.seg i { font-size: 15px; line-height: 1; }
.seg:hover { background: rgba(233, 233, 237, 0.07); }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.active { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
/* the accent ring is an inset shadow, so it only looks right if the button itself is rounded;
   inner radius = container radius minus its 1px border */
.seg:first-child { border-top-left-radius: calc(var(--radius) - 1px); border-bottom-left-radius: calc(var(--radius) - 1px); }
.seg:last-child { border-top-right-radius: calc(var(--radius) - 1px); border-bottom-right-radius: calc(var(--radius) - 1px); }
/* an active segment draws its own edge; hide the divider that would double up beside it */
.seg.active + .seg, .seg.active { border-left-color: transparent; }
.seg:disabled { opacity: 0.45; cursor: not-allowed; }
.segmented.small .seg { padding: 5px 10px; min-height: 30px; font-size: 12px; }
/* The panel switches are on/off, not one-of-three, so they mark themselves with aria-pressed. */
.seg.toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg.toggle[aria-pressed="true"] + .seg { border-left-color: transparent; }
/* The last panel still showing something cannot be switched off; it is not broken, just stuck. */
.seg.toggle[aria-pressed="true"]:disabled { opacity: 1; cursor: default; }
/* The Imprint tab wears the imprint's own colour when it is the one being drawn on, so which
   mode you are in reads the same way the lines on the canvas do. */
.seg.imprint.active {
  color: var(--imprint); background: var(--imprint-soft); box-shadow: inset 0 0 0 1px var(--imprint);
}

.slider { display: flex; flex-direction: column; gap: 5.6px; color: var(--muted); font-size: 12px; }
.slider .row { display: flex; justify-content: space-between; }
.slider .row .val { color: var(--accent); }
.slider .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }
.slider input { width: 100%; accent-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(145, 132, 217, 0.3); }

/* ---------- edit 3: the Canvas setup flyout ---------- */
.flyout {
  position: absolute; right: 11.2px; top: 11.2px; z-index: 5; width: 300px;
  display: flex; flex-direction: column; gap: 11.2px;
  padding: 11.2px; border-radius: var(--radius-lg);
  background: var(--paper); box-shadow: var(--shadow-lg);
}
.flyout[hidden] { display: none; }
.flyout-head { display: flex; align-items: center; gap: 8.4px; }
.flyout-head .group-label { margin-right: auto; }
.flyout section { display: flex; flex-direction: column; gap: 5.6px; }
/* Must come after it: an author's display beats the hidden attribute whatever the specificity,
   so a section switched off in app.js would otherwise stay on screen. */
.flyout section[hidden] { display: none; }
.flyout .row-btns { display: flex; gap: 5.6px; flex-wrap: wrap; }
.sec-body .row-btns { display: flex; gap: 5.6px; flex-wrap: wrap; }
.flyout .note { margin: 0; }
.flyout hr { height: 1px; border: 0; background: var(--hairline); margin: 0; }

/* ---------- edit 4: collapsible settings sections ---------- */
.sec-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8.4px 2.8px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.sec-head:hover { background: rgba(233, 233, 237, 0.05); }
.sec-head .caret { color: var(--faint); font-size: 12px; transition: transform 0.15s ease; }
.sec-head[aria-expanded="true"] .caret { transform: rotate(90deg); }
.sec-head .name { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.sec-head .summary { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.sec-body { display: flex; flex-direction: column; gap: 8.4px; padding: 0 2.8px 8.4px; }
.sec-body[hidden] { display: none; }
.sec + .sec { border-top: 1px solid var(--hairline); }
@media (prefers-reduced-motion: reduce) { .sec-head .caret { transition: none; } }

/* ---------- settings ---------- */
.note { color: var(--faint); font-size: 12px; margin: 0; }
/* Something that will print in pieces — said where the setting that fixes it is. */
.note.warn {
  color: var(--ink); background: var(--imprint-soft); border-radius: var(--radius);
  padding: 8px 10px; box-shadow: inset 0 0 0 1px var(--imprint-deep);
}
/* The imprint's own fields wear its colour where they would otherwise wear the accent. */
#secImprint .mini.toggle[aria-pressed="true"],
#lineBar .mini.toggle[aria-pressed="true"] { color: var(--imprint); border-color: var(--imprint); background: var(--imprint-soft); }
#secImprint input[type="checkbox"] { accent-color: var(--imprint); }
.note.boxed {
  display: flex; align-items: flex-start; gap: 8.4px; color: var(--muted);
  padding: 8.4px; border-radius: var(--radius); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline);
}
.note.boxed i { color: var(--accent); font-size: 15px; line-height: 1.4; flex: none; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--faint); min-width: 0; }
.field .unit {
  display: flex; align-items: center; background: var(--sunken);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0 8.4px 0 0;
}
.field .unit:hover { border-color: rgba(233, 233, 237, 0.45); }
.field .unit:focus-within { border-color: var(--accent); }
.field input {
  font: inherit; font-size: 14px; color: var(--ink); border: 0; background: transparent;
  caret-color: var(--accent); padding: 7px 4px 7px 10px; width: 100%; min-width: 0;
}
.field input:focus { outline: none; }
.field em { font-style: normal; color: var(--faint); font-size: 11px; }
.field-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 5.6px; align-items: end; }
.field-row.two { grid-template-columns: 1fr 1fr; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5.6px; }
.field-grid.three { grid-template-columns: 1fr 1fr 1fr; }
/* one option per row: label left, input right */
.field-grid.rows { grid-template-columns: 1fr; gap: 8.4px; }
.field-grid.rows .field { flex-direction: row; align-items: center; justify-content: space-between; gap: 11.2px; }
.field-grid.rows .field > span:first-child { display: flex; align-items: center; gap: 5.6px; }
.field-grid.rows .field .unit { flex: none; width: 116px; }
.field-grid[hidden] { display: none; }

/* A setting that is off the app's default carries a small undo arrow. It is a marker first and a
   button second: seeing which numbers are not the standard ones is most of what it is for. */
.reset-mark {
  font: inherit; line-height: 0; padding: 2px; margin-left: 4px; border: 0; border-radius: 5px;
  background: transparent; color: var(--accent); cursor: pointer; vertical-align: middle;
}
.reset-mark i { font-size: 13px; }
.reset-mark:hover { background: var(--accent-soft); }
.reset-mark[hidden] { display: none; }

.lock {
  height: 36px; width: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent;
  color: var(--faint); cursor: pointer; display: grid; place-items: center;
}
.lock[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.lock[aria-pressed="false"] .shackle { transform: translateX(4px) rotate(18deg); transform-origin: 14px 9px; }

.check { display: flex; gap: 8.4px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { margin: 3px 0 0; accent-color: var(--accent); flex: none; width: 15px; height: 15px; }
.check .aside { color: var(--faint); }

.profile-frame { background: var(--sunken); border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--hairline); padding: 5.6px; }
.profile { width: 100%; height: auto; display: block; }

/* ---------- mobile bar & toast ---------- */
.sticky-download { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(12px); z-index: 40;
  display: flex; align-items: center; gap: 8.4px;
  background: var(--hairline); color: var(--ink); box-shadow: var(--shadow-md);
  padding: 8.4px 16.8px; border-radius: var(--radius); font-size: 13px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: min(92vw, 480px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- responsive ---------- */
@media (min-width: 1181px) {
  body { height: 100dvh; }
  /* one template per combination of switched-off panels; at most one of draw / 3D can be off */
  body.panes-no-settings .workspace { grid-template-columns: minmax(0, var(--col-draw)) minmax(0, var(--col-view)); }
  body.panes-no-draw .workspace,
  body.panes-no-3d .workspace { grid-template-columns: minmax(0, 1fr) 316px; }
  body.panes-no-draw.panes-no-settings .workspace,
  body.panes-no-3d.panes-no-settings .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, var(--col-draw)) minmax(0, var(--col-view)); grid-template-rows: auto auto; overflow: visible; }
  body.panes-no-draw .workspace,
  body.panes-no-3d .workspace { grid-template-columns: minmax(0, 1fr); }
  .segmented.panels .seg span { display: none; }   /* icons only; the tooltip names them */
  .tagline { display: none; }                      /* the header is full; the strapline goes first */
  .pane-settings { grid-column: 1 / -1; }
  .pane-settings .sec-body { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22.4px; align-items: start; }
  .pane-settings .sec-body > .note, .pane-settings .sec-body > .check,
  .pane-settings .sec-body > .profile-frame, .pane-settings .sec-body > .field-grid { grid-column: 1 / -1; }
  .pane-settings .sec-body > .profile-frame { max-width: 320px; }
  .canvas-wrap { flex: none; width: 100%; aspect-ratio: 1 / 1; min-height: 0; height: auto; }
  .viewer-wrap { flex: 1; width: 100%; min-height: 360px; }
}
@media (max-width: 760px) {
  .top { padding: 8.4px 11.2px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8.4px; }
  .tagline, .ready { display: none; }
  .top-actions #downloadBtn { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 11.2px; padding: 0 11.2px 84px; }
  .pane-settings .sec-body { display: flex; }
  .toolbar { flex-wrap: wrap; }
  .flyout { left: 11.2px; right: 11.2px; width: auto; }
  .canvas-wrap { aspect-ratio: auto; height: 300px; }
  .viewer-wrap { flex: none; width: 100%; min-height: 0; height: 200px; }
  .seg span { display: none; }            /* tools go icon-only on phones */
  .seg { padding: 7px 14px; }
  .sticky-download {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; padding: 11.2px 11.2px calc(11.2px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bench) 70%, rgba(22, 24, 38, 0));
  }
  .sticky-download .btn { width: 100%; min-height: 46px; font-size: 15px; }
  .toast { bottom: 80px; }
}

/* ---------- point editing ---------- */
/* The canvas' top right holds the properties of what is selected, and more than one of them can
   be on screen at once — a corner of an imprint line is a point and a line at the same time — so
   they stack in a column instead of each being pinned to the corner. */
.canvas-tr {
  position: absolute; right: 11.2px; top: 11.2px; z-index: 4;
  display: flex; flex-direction: column; gap: 5.6px; align-items: flex-end; max-width: calc(100% - 22.4px);
}
.canvas-tr:empty { display: none; }
.point-bar {
  display: flex; flex-direction: column; gap: 5.6px; align-items: stretch;
  background: var(--paper); box-shadow: var(--shadow-md); border-radius: var(--radius);
  padding: 5.6px; font-size: 11px; color: var(--muted); max-width: calc(100% - 22.4px);
}
.point-bar-row { display: flex; gap: 5.6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
/* one line per group: label, x, y — so the boxes stay in two straight columns */
.point-fields { display: flex; flex-direction: column; gap: 4px; align-items: stretch; padding: 2px 4px 0; }
.point-fields .field-group { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.point-fields .field-group[hidden] { display: none; }
.point-fields .field-label {
  margin-right: auto; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint);
}
.point-fields label { display: inline-flex; align-items: center; gap: 3px; color: var(--faint); }
.point-fields input {
  font: inherit; font-size: 12px; color: var(--ink); border: 0; background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--hairline); border-radius: 6px;
  caret-color: var(--accent); padding: 4px 5px; width: 56px;
}
.point-fields input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
.point-bar #pointLabel {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 6px;
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
}
.point-bar[hidden] { display: none; }
/* the same bar for the shape the Move tool is holding: one row, whose shape it is then x and y */
#shapeBar .point-fields { padding: 2px 4px; }
/* The imprint line's own two numbers. `auto` is the same idiom as the connection thickness:
   pressed means this line simply follows the shape, and typing a value lifts it off. */
#lineBar .point-fields { padding: 2px 4px; gap: 5px; }
#lineBar .field-group { gap: 5px; }
#lineBar label { gap: 4px; }
#lineBar label em { font-style: normal; font-size: 10px; color: var(--faint); }
#lineBar input { width: 52px; }
#lineBar #lineBarLabel { color: var(--imprint); }
#lineBar .mini { margin-left: auto; }
#lineDeleteBtn { margin-left: auto; }
/* On a narrow canvas there is no room for the name beside the boxes, so it takes a line of its
   own — the same thing the position bar does, and measured on the same container, because how
   much room there is depends on which panels are switched on and not on the window. */
@container canvas (max-width: 430px) {
  #lineBar .line-set { display: block; text-align: right; }
  #lineBar .line-set .field-label { display: block; margin: 0 0 3px; }
  #lineBar .mini { margin-left: 0; margin-right: 5px; }
}
#shapeBar .field-label { margin-right: 10px; color: var(--accent); }
.ctx-menu {
  position: fixed; z-index: 30; background: var(--paper); box-shadow: var(--shadow-md);
  border-radius: var(--radius); padding: 4px; min-width: 190px; display: flex; flex-direction: column;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button { font: inherit; font-size: 13px; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.ctx-menu button:hover { background: rgba(233, 233, 237, 0.07); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button[hidden] { display: none; }
.mini {
  font: inherit; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 1px 6px; border: 0; border-radius: 6px; background: var(--hairline); color: var(--muted);
  cursor: pointer; margin-left: 4px; vertical-align: middle;
}
.mini.toggle[aria-pressed="true"] { background: var(--accent-deep); color: #f5f4ff; }

/* ---------- dialog ---------- */
.dialog {
  border: 0; border-radius: var(--radius-lg); padding: 16.8px; width: min(92vw, 440px);
  font-family: var(--font); color: var(--ink); background: var(--paper); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(22, 24, 38, 0.7); }
.dialog form { display: flex; flex-direction: column; gap: 11.2px; }
.dialog h3 { display: flex; align-items: center; gap: 8.4px; margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.015em; }
.dialog h3 i { color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 5.6px; margin-top: 5.6px; }
/* Three answers instead of two: Cancel stays on the left, the two ways in sit together on the
   right. On a narrow window they stack rather than shrink to unreadable labels. */
.dialog-actions.spread { flex-wrap: wrap; }
.dialog-actions.spread .spacer { flex: 1 1 auto; }
@media (max-width: 460px) {
  .dialog-actions.spread { flex-direction: column-reverse; align-items: stretch; }
  .dialog-actions.spread .spacer { display: none; }
  .dialog-actions.spread .btn { justify-content: center; }
}

/* ---------- project manager ---------- */
#projectsBtn span { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog.projects { width: min(92vw, 480px); }
.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5.6px; max-height: 40vh; overflow: auto; }
.project-row { display: flex; align-items: center; gap: 5.6px; }
.project-row .project-pick {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  min-height: 40px; padding: 5px 11px; border: 1px solid var(--hairline); border-radius: var(--radius);
  background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.project-row.current .project-pick { border-color: var(--accent); }
.project-pick b { font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-pick small { color: var(--muted); font-size: 12px; }
.project-row input.rename { flex: 1; min-width: 0; min-height: 40px; font: inherit; padding: 0 11px; }
@media (max-width: 760px) { #projectsBtn span { display: none; } }

/* ---------- dropping a file in ---------- */
/* The veil covers the window so nothing is lost to the browser opening the file over the top of
   the drawing; the lit box is the canvas, which is where the file lands. */
.drop-layer {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(22, 24, 38, 0.72); backdrop-filter: blur(1px);
}
.drop-layer[hidden] { display: none; }
.drop-zone {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center; padding: 16.8px;
  border-radius: var(--radius-lg); border: 2px dashed var(--line);
  background: rgba(35, 37, 50, 0.85); color: var(--muted);
  transition: border-color .12s, color .12s, background .12s;
}
.drop-zone.hot { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.drop-zone i { font-size: 30px; color: var(--accent); }
.drop-zone strong { font-size: 17px; font-weight: 500; letter-spacing: -0.015em; color: var(--ink); }
.drop-zone span { font-size: 12.5px; }

/* ---------- the loader ---------- */
/* Reading an STL or a fat SVG blocks the main thread, so this goes up first and says so. */
.loader {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(22, 24, 38, 0.78);
}
.loader[hidden] { display: none; }
.loader-box {
  display: flex; flex-direction: column; align-items: center; gap: 12.6px;
  padding: 22.4px 28px; border-radius: var(--radius-lg);
  background: var(--paper); box-shadow: var(--shadow-lg); max-width: min(90vw, 320px);
}
.loader-box p { margin: 0; font-size: 13.5px; color: var(--muted); text-align: center; }
.loader-spin {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--accent-deep); border-top-color: var(--accent);
  animation: loader-spin .8s linear infinite;
}
@keyframes loader-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loader-spin { animation-duration: 2.4s; }
  .drop-zone { transition: none; }
}

/* ---------- cut-piece preview ---------- */
/* The stage is a dark worktop; the piece is painted onto it by app.js, so the only job here is
   to give the canvas a box with a fixed shape to measure itself against. */
.result-dialog { width: min(94vw, 520px); }
.result-stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border-radius: var(--radius); overflow: hidden;
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline);
}
.result-stage canvas { display: block; width: 100%; height: 100%; }
.result-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8.4px; }
.result-size { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-mirror { display: flex; align-items: center; gap: 8.4px; flex-wrap: wrap; }
.result-mirror > span { font-size: 12px; color: var(--faint); max-width: 40ch; }
.result-mirror[hidden] { display: none; }
.result-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.result-colors .group-label { margin-right: 2.8px; }
.swatch {
  width: 30px; height: 30px; flex: none; padding: 0; border: 0; border-radius: 50%;
  background: var(--sw, var(--line)); cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--hairline);
}
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 2px var(--accent); }
.swatch:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
/* The last swatch opens the browser's own colour picker; the ring says "any colour". */
.swatch.custom {
  position: relative; display: grid; place-items: center; overflow: hidden;
  background: conic-gradient(#f56c6c, #f5c26c, #b7f56c, #6cf5b0, #6cd0f5, #8a6cf5, #f56cd0, #f56c6c);
}
.swatch.custom input {
  position: absolute; inset: -20%; width: 140%; height: 140%;
  padding: 0; border: 0; opacity: 0; cursor: pointer;
}
.swatch.custom i { font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55); pointer-events: none; }

/* ---------- explanation tooltips ---------- */
/* Native title tooltips are slow, unstyled and never appear on touch. app.js moves every
   title= onto data-tip and renders it here instead; fixed position so the panes'
   overflow: hidden cannot clip it. */
.tip-bubble {
  position: fixed; z-index: 60; max-width: 260px; pointer-events: none;
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line);
  border-radius: var(--radius); padding: 7px 10px; font-size: 12px; line-height: 1.45;
  opacity: 0; transform: translateY(2px); transition: opacity 0.12s ease, transform 0.12s ease;
}
.tip-bubble.show { opacity: 1; transform: none; }
.tip-bubble b { font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .tip-bubble { transition: none; } }

/* ---------- canvas view controls (zoom + pan) ---------- */
/* Bottom right: the point bar and the canvas setup flyout both own the top right corner. */
.canvas-view {
  position: absolute; right: 11.2px; bottom: 11.2px; z-index: 4;
  display: flex; align-items: flex-end; gap: 5.6px;
}
.view-zoom { position: relative; }
.view-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--ink); cursor: pointer;
  min-height: 32px; min-width: 32px; padding: 0 7px; line-height: 1;
  background: rgba(35, 37, 50, 0.92); border: 0; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line);
}
.view-btn i { font-size: 15px; }
.view-btn.wide { padding: 0 8px; }
.view-btn.wide span { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
.view-btn:hover { background: rgba(48, 51, 68, 0.95); }
.view-btn[aria-pressed="true"], .view-btn[aria-expanded="true"] {
  color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent);
}

.zoom-menu {
  position: absolute; right: 0; bottom: calc(100% + 5.6px); z-index: 6; width: 212px;
  display: flex; flex-direction: column; gap: 8.4px;
  background: var(--paper); box-shadow: var(--shadow-md); border-radius: var(--radius); padding: 8.4px;
}
.zoom-menu[hidden] { display: none; }
/* The menu opens over the bottom-centre hint; the hint is passive, so it yields. */
.canvas-wrap.zooming .hint.corner { opacity: 0; }
.hint.corner { transition: opacity 0.12s ease; }
@media (prefers-reduced-motion: reduce) { .hint.corner { transition: none; } }
.zoom-row { display: flex; align-items: center; gap: 5.6px; }
.zoom-row .zoom-now {
  flex: 1; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink);
}
.zoom-presets { display: flex; flex-wrap: wrap; gap: 5.6px; }
.zoom-presets .btn { flex: 1; min-width: 0; }
.zoom-presets .btn:last-child { flex-basis: 100%; }

/* The canvas setup flyout shares this corner — while it is open it sits on top. */
.flyout { z-index: 8; }

/* ---------- starter shapes picker ----------
   A drop-down list cannot show what a shape looks like, so the button opens a grid of
   previews instead. Every tile is drawn from the shape's own anchors (app.js), so a picture
   here can never drift away from the outline it inserts. */
.preset-picker { position: relative; display: inline-flex; }
/* Fixed, not absolute: the drawing pane clips what overflows it, and on a phone the grid is
   taller than the pane. app.js puts it under the button and keeps it inside the window. */
.preset-menu {
  position: fixed; z-index: 12;
  /* the grid is as wide as the columns it holds: two on a phone, one more per step up,
     and never more than five — past that the tiles are small and the grid reads as a list */
  --cols: 5; --tile: 84px;
  width: min(calc(var(--cols) * (var(--tile) + 5.6px) - 5.6px + 16.8px), calc(100vw - 22.4px));
  overflow: auto;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 5.6px;
  padding: 8.4px; border-radius: var(--radius-lg);
  background: var(--paper); box-shadow: var(--shadow-md);
}
.preset-menu[hidden] { display: none; }
.preset-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 7px 4px 5px; min-height: 36px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: transparent; color: var(--ink); font: inherit; font-size: 11px; cursor: pointer;
}
.preset-tile svg { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.preset-tile path {
  fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round;
}
/* the names run to two words, so they wrap rather than being cut off; the two lines are
   always reserved, which keeps every tile in the grid the same size */
.preset-tile span { text-align: center; line-height: 1.25; min-height: 2.5em; }
.preset-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.preset-tile:hover path { fill: rgba(145, 132, 217, 0.26); }
.preset-tile:active { background: rgba(145, 132, 217, 0.22); }
.preset-tile:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 1px; }
/* Phones: bigger tiles for thumbs, and enough height that the last row is not cut in half.
   This block has to come after the rules above, not with the other phone rules further up. */
@media (max-width: 1180px) { .preset-menu { --cols: 4; } }
@media (max-width: 900px) { .preset-menu { --cols: 3; } }
@media (max-width: 760px) {
  .preset-menu { --cols: 2; --tile: 130px; }
  .preset-tile { padding: 9px 4px 7px; }
}

/* the shape the size dialog is asking about, drawn the same way its tile is */
.preset-figure { display: flex; justify-content: center; }
.preset-figure svg { width: 92px; height: 92px; }
.preset-figure path {
  fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round;
}

/* ---------- the rounding tool's slider, bottom centre of the canvas ----------
   Only on screen while the mode is, so it takes a line of its own above the grid and zoom
   controls rather than squeezing between them: a bar floating over the drawing is what says
   a mode is open and waiting for Apply or Cancel. */
.canvas-smooth {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 56px; z-index: 6;
  display: flex; align-items: center; gap: 5.6px; max-width: calc(100% - 22.4px);
  background: var(--paper); box-shadow: var(--shadow-md); border-radius: var(--radius); padding: 5.6px;
}
.canvas-smooth[hidden] { display: none; }
.cs-slider {
  display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 10px;
  background: var(--sunken); border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--muted); font-size: 11px; cursor: pointer;
}
.cs-slider i { font-size: 14px; color: var(--faint); }
.cs-name { white-space: nowrap; }
.cs-slider input { width: 132px; accent-color: var(--accent); cursor: pointer; }
.cs-val { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--accent); }
.view-btn.primary {
  color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent);
}
.view-btn.primary:hover { background: var(--accent); color: var(--paper); }
/* The zoom menu opens upwards over this row; the bar yields to it the way the hint does. */
.canvas-wrap.zooming .canvas-smooth { opacity: 0; pointer-events: none; }
.canvas-smooth { transition: opacity 0.12s ease; }
@media (prefers-reduced-motion: reduce) { .canvas-smooth { transition: none; } }
/* With the bar on screen both hints move up, so neither sits on top of it. */
.canvas-wrap.with-smooth .hint.corner { inset: auto 0 108px 0; }
.canvas-wrap.with-smooth .hint:not(.corner) { padding-bottom: 100px; }
/* Its name is the first thing to go when the canvas is narrow: the toolbar button is pressed
   and the shape is bending under the slider, so what this is is not in doubt. */
@container canvas (max-width: 560px) {
  .cs-name { display: none; }
  .cs-slider input { width: 104px; }
  .canvas-smooth #roundApplyBtn span, .canvas-smooth #roundCancelBtn span { display: none; }
}

/* ---------- canvas grid control (bottom left, where the scale bar used to be painted) ---------- */
.canvas-grid {
  position: absolute; left: 11.2px; bottom: 11.2px; z-index: 4;
  display: flex; align-items: center; gap: 5.6px; flex-wrap: wrap; max-width: calc(100% - 22.4px);
}
/* The bar is the on-screen length of one grid square, so the number has something to measure. */
.scale-bar { display: inline-flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 11px; }
.scale-bar i { height: 2px; min-width: 12px; background: var(--muted); border-radius: 1px; }
.scale-bar em { font-style: normal; font-variant-numeric: tabular-nums; }
.view-btn.select {
  appearance: none; -webkit-appearance: none; padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 11px center, right 6px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.view-btn.select option { background: var(--paper); color: var(--ink); }

/* ---------- align the inner wall ---------- */
.align-wrap { position: relative; display: inline-flex; }
.align-menu {
  position: absolute; right: 0; top: calc(100% + 5.6px); z-index: 12;
  display: flex; flex-direction: column; gap: 6px; padding: 8.4px;
  background: var(--paper); box-shadow: var(--shadow-md); border-radius: var(--radius);
  /* app.js › placeAlignMenu() sets the side it hangs from and how tall it may be */
  overflow-y: auto; overscroll-behavior: contain;
}
.align-menu[hidden] { display: none; }
.align-grid { display: grid; grid-template-columns: repeat(3, 32px); gap: 4px; }
/* Each button is a little picture of the result: the outer wall as the frame, the inner wall
   as the dot, sitting where it would land. */
.align-grid button {
  position: relative; width: 32px; height: 32px; padding: 0; cursor: pointer;
  border: 0; border-radius: 6px; background: rgba(233, 233, 237, 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
}
.align-grid button::after {
  content: ''; position: absolute; width: 10px; height: 10px; border-radius: 3px; background: var(--accent);
}
.align-grid button[data-h="start"]::after { left: 4px; }
.align-grid button[data-h="center"]::after { left: 50%; transform: translateX(-50%); }
.align-grid button[data-h="end"]::after { right: 4px; }
.align-grid button[data-v="start"]::after { top: 4px; }
.align-grid button[data-v="center"]::after { top: 50%; }
.align-grid button[data-v="center"][data-h="center"]::after { transform: translate(-50%, -50%); }
.align-grid button[data-v="center"]:not([data-h="center"])::after { transform: translateY(-50%); }
.align-grid button[data-v="end"]::after { bottom: 4px; }
.align-grid button:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

@media (max-width: 760px) {
  /* On a phone the grid control and the zoom controls share the bottom edge; give the hint room. */
  .hint.corner { inset: auto 0 96px 0; }
}
.align-wrap[hidden] { display: none; }

/* ---------- the imprint patterns, in the canvas toolbar ---------- */
/* A menu of starting points rather than a mode: each item opens its dialog, draws lines and is
   done with. It is in the toolbar and not the settings panel because it is drawing, not a setting. */
.pattern-wrap { position: relative; display: inline-flex; }
.pattern-wrap[hidden] { display: none; }
.pattern-menu {
  position: absolute; right: 0; top: calc(100% + 5.6px); z-index: 12; width: 232px;
  display: flex; flex-direction: column; gap: 2px; padding: 5.6px;
  background: var(--paper); box-shadow: var(--shadow-md); border-radius: var(--radius);
  /* app.js › placePatternMenu() sets the side it hangs from and how tall it may be */
  overflow-y: auto; overscroll-behavior: contain;
}
.pattern-menu[hidden] { display: none; }
.pattern-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px;
  padding: 6px 8px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--ink); text-align: left;
}
.pattern-menu button i { font-size: 17px; color: var(--imprint); flex: none; }
.pattern-menu button span { display: flex; flex-direction: column; gap: 1px; }
.pattern-menu button em { font-style: normal; font-size: 11px; color: var(--faint); }
.pattern-menu button:hover, .pattern-menu button:focus-visible { background: var(--sunken); }
.pattern-sep { height: 1px; background: var(--hairline); margin: 3px 6px; }

/* ---------- the text dialog ---------- */
.field.wide { width: 100%; }
.field.wide textarea {
  font: inherit; font-size: 13px; color: var(--ink); border: 0; background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--hairline); border-radius: 8px;
  caret-color: var(--accent); padding: 7px 9px; width: 100%; resize: vertical; min-height: 42px;
}
.field.wide textarea:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
/* a select is not one of the app's own controls anywhere else, so it borrows the field's box */
.field select {
  font: inherit; font-size: 13px; color: var(--ink); border: 0; width: 100%;
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline); border-radius: 8px;
  padding: 7px 9px; cursor: pointer; min-width: 0;
}
.field select:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
.field select option { background: var(--paper); color: var(--ink); }
.seg-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.seg-row .group-label { margin-right: auto; }
#textDialog .seg[aria-selected="true"] { color: var(--imprint); }

/* Shape actions only appear once there is a shape; the divider in front of them goes too. */
.toolbar-group .divider[hidden] { display: none; }


/* ---------- the shapes on this plate ---------- */
/* One cutter per row. The one you pick is the one you can draw on and the one the settings
   panel belongs to; the others stay on the canvas in grey and are built along with it. */
.shapes-panel {
  pointer-events: auto; min-width: 0; max-width: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: rgba(35, 37, 50, 0.92); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--radius);
}
.shapes-head { display: flex; align-items: center; gap: 2px; padding: 3px; }
.shapes-toggle {
  display: inline-flex; align-items: center; gap: 5px; flex: 1; min-width: 0;
  font: inherit; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: none; border: 0; border-radius: 6px; cursor: pointer;
  padding: 4px 6px; min-height: 26px;
}
.shapes-toggle:hover { color: var(--ink); background: rgba(233, 233, 237, 0.06); }
.shapes-toggle .caret { font-size: 12px; margin-left: auto; transition: transform 0.15s ease; }
.shapes-toggle[aria-expanded="false"] .caret { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .shapes-toggle .caret { transition: none; } }
.shapes-list {
  display: flex; flex-direction: column; gap: 2px; padding: 0 3px 3px;
  max-height: 208px; overflow: auto; overscroll-behavior: contain;
}
.shapes-list[hidden] { display: none; }
.shape-row { display: flex; align-items: center; gap: 2px; }
.shape-pick {
  display: inline-flex; align-items: center; gap: 7px; flex: 1; min-width: 0;
  font: inherit; font-size: 12px; color: var(--muted); text-align: left;
  background: none; border: 0; border-radius: 6px; cursor: pointer; padding: 4px 6px; min-height: 32px;
}
.shape-pick:hover { background: rgba(233, 233, 237, 0.06); color: var(--ink); }
/* Held — one of the shapes Center, Align and Flip would act on. */
.shape-row[aria-selected="true"] .shape-pick { color: var(--accent); background: var(--accent-soft); }
/* And the one being edited on top of that: it is the only one the settings panel can show, so it
   carries a bar of its own. */
.shape-row.active .shape-pick { color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.shape-row.active:not([aria-selected="true"]) .shape-pick { background: rgba(145, 132, 217, 0.08); }
/* Out of reach: the row says so before the padlock is read. */
.shape-row.locked .shape-pick { opacity: 0.55; }
.shape-row.locked .shape-pick:hover { background: none; color: var(--muted); cursor: default; }
.shape-pick .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* This shape is not on the standard settings — the same arrow the settings panel uses, and a
   marker only: the row it sits in switches shapes. Right-aligned, so the flagged shapes read as
   a column rather than as a ragged edge behind the names. */
.shape-flag { flex: none; line-height: 0; color: var(--accent); }
.shape-flag i { font-size: 12px; }
.shape-flag[hidden] { display: none; }
.shape-pick .thumb { flex: none; width: 22px; height: 22px; display: block; }
.shape-pick .thumb path { fill: currentColor; fill-opacity: 0.22; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.shape-pick .thumb.blank { opacity: 0.45; }
/* The pattern inside the outline: thinner than the walls, and in the imprint's own colour, so a
   row with a pattern in it reads as one at a glance. */
.shape-pick .thumb .thumb-imprint { fill: none; stroke: var(--imprint); stroke-width: 1; stroke-linecap: round; }
.shape-del, .shape-lock { flex: none; opacity: 0; transition: opacity 0.12s ease; }
.shape-row:hover .shape-del, .shape-row[aria-selected="true"] .shape-del, .shape-del:focus-visible,
.shape-row:hover .shape-lock, .shape-row[aria-selected="true"] .shape-lock, .shape-lock:focus-visible { opacity: 1; }
/* A locked shape wears its padlock all the time — it is the reason the row cannot be used. */
.shape-row.locked .shape-lock { opacity: 1; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .shape-del, .shape-lock { transition: none; } }
.shape-del[hidden] { display: none; }
/* No hover on a touch screen, so neither button can hide behind one. */
@media (hover: none) { .shape-del, .shape-lock { opacity: 1; } }

/* How the shapes on this plate may sit — a setting for the plate, not for a shape, so it sits
   under the list behind a hairline rather than reading as one more row. */
.shapes-foot { padding: 3px; border-top: 1px solid var(--line); }
.shapes-foot[hidden] { display: none; }
.shapes-overlap {
  display: flex; align-items: center; gap: 7px; width: 100%; min-width: 0;
  font: inherit; font-size: 12px; color: var(--muted); text-align: left;
  background: none; border: 0; border-radius: 6px; cursor: pointer; padding: 4px 6px; min-height: 32px;
}
.shapes-overlap i { font-size: 16px; width: 22px; text-align: center; flex: none; }
.shapes-overlap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shapes-overlap:hover { background: rgba(233, 233, 237, 0.06); color: var(--ink); }
.shapes-overlap[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
/* display:flex beats the browser's own [hidden] rule, so the rows have to say it themselves. */
.shapes-overlap[hidden] { display: none; }
.shapes-overlap:disabled { opacity: 0.45; cursor: default; }
.shapes-overlap:disabled:hover { background: none; color: var(--muted); }
.sel-count { margin-left: auto; flex: none; font-style: normal; font-size: 11px; color: var(--faint); }

/* Which shape the settings below belong to. */
.settings-scope {
  display: flex; align-items: center; gap: 6px; margin-bottom: 2px;
  padding: 7px 9px; border-radius: var(--radius); font-size: 12px; color: var(--muted);
  background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(145, 132, 217, 0.35);
}
.settings-scope[hidden] { display: none; }
.settings-scope i { font-size: 14px; color: var(--accent); }
.settings-scope b { color: var(--ink); font-weight: 600; }

/* Says that this shape is not on the standard settings, and offers to put it back. */
.settings-reset {
  display: flex; align-items: center; gap: 8.4px; margin-bottom: 2px;
  padding: 6px 6px 6px 9px; border-radius: var(--radius); font-size: 12px; color: var(--muted);
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline);
}
.settings-reset[hidden] { display: none; }
.settings-reset > i { font-size: 14px; color: var(--accent); flex: none; }
.settings-reset > span { min-width: 0; }
.settings-reset .btn { margin-left: auto; flex: none; }

/* Before and after, one row per setting that changes. */
.reset-table {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 2px 8.4px; align-items: baseline;
  max-height: 46vh; overflow-y: auto; padding: 8.4px; border-radius: var(--radius);
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline); font-size: 13px;
}
.reset-table .rt-name { color: var(--faint); font-size: 12px; min-width: 0; }
.reset-table .rt-from { color: var(--ink); text-align: right; white-space: nowrap; }
.reset-table .rt-arrow { color: var(--faint); font-size: 11px; }
.reset-table .rt-to { color: var(--accent); text-align: right; white-space: nowrap; }
/* Which shape the rows under it belong to, when more than one is being put back at once. */
.reset-table .rt-shape {
  grid-column: 1 / -1; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--hairline);
  color: var(--ink); font-size: 12px; font-weight: 600;
}
.reset-table .rt-shape:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

@media (max-width: 760px) {
  /* On a phone the list would eat the canvas; it starts folded and the header stays. */
  .shapes-list { max-height: 148px; }
  .shape-pick { font-size: 11px; }
  .canvas-tl { gap: 4px; }
  /* The position bar shares the top of the canvas with that folded list, so it puts the shape's
     name on a line of its own rather than squeezing the two boxes. */
  #shapeBar .point-fields .field-group { display: block; text-align: right; }
  #lineBar input { width: 46px; }
  #shapeBar .field-label { display: block; margin: 0 0 4px; }
  #shapeBar .point-fields label + label { margin-left: 6px; }
}

/* ---- turning, copies and stacking order ---- */
.mini-select {
  font: inherit; font-size: 12px; color: var(--ink); border: 0; border-radius: 6px; cursor: pointer;
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline); padding: 4px 6px; min-width: 0; height: 28px;
}
.mini-select:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
.mini-select option { background: var(--paper); color: var(--ink); }
.field .mini-select { width: 100%; height: auto; padding: 7px 9px; font-size: 13px; border-radius: 8px; }
#turnGroup { flex-wrap: wrap; }
#turnGroup .btn { min-height: 28px; height: 28px; padding: 0 9px; font-size: 12px; }
#turnGroup input { width: 52px; }
.shapes-order { display: flex; gap: 2px; }
.shapes-order[hidden] { display: none; }
.preset-mode { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; font-size: 13px; }
.preset-mode[hidden] { display: none; }
.preset-mode label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.shapes-mode select { flex: 1; min-width: 0; }
.shapes-mode:hover { background: none; }

/* ---- groups ---- */
.shape-grp {
  flex: none; font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  border-radius: 4px; padding: 1px 5px; margin-left: 4px;
}
#groupSizeRow input { width: 58px; }
#groupSizeRow .lock { width: 24px; height: 24px; }

/* ---- grouped rows in the shapes list ---- */
.group-head .group-caret { flex: none; width: 22px; height: 28px; display: grid; place-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 6px; }
.group-head .group-caret:hover { color: var(--ink); background: rgba(233, 233, 237, 0.06); }
.group-head[aria-selected="true"] .shape-pick { color: var(--accent); background: var(--accent-soft); }
.group-head.active .shape-pick { color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.group-head.active:not([aria-selected="true"]) .shape-pick { background: rgba(145, 132, 217, 0.08); }
.grp-count { flex: none; font-style: normal; font-size: 10px; color: var(--faint); margin-left: 4px; }
.group-ungroup { flex: none; opacity: 0; transition: opacity 0.12s ease; }
.group-head:hover .group-ungroup, .group-head[aria-selected="true"] .group-ungroup, .group-ungroup:focus-visible,
.group-head:hover .shape-lock, .group-head[aria-selected="true"] .shape-lock { opacity: 1; }
@media (hover: none) { .group-ungroup { opacity: 1; } }
.shape-row.in-group { padding-left: 22px; }
.shape-row.in-group .shape-grp { display: none; }

/* a field is display:flex, which beats the browser's own [hidden] — and the back support section hides
   the fields its style does not use */
.field[hidden], .field-grid[hidden] { display: none; }

/* ---------- download formats & print setup ---------- */
.split { display: inline-flex; }
.split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .split-caret {
  border-top-left-radius: 0; border-bottom-left-radius: 0; padding-inline: 8px; min-width: 32px; justify-content: center;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}
.sticky-download .split { display: flex; width: 100%; }
.sticky-download .split .btn:first-child { flex: 1; }
.sticky-download .split .split-caret { flex: none; width: 52px; }
.dl-menu {
  position: fixed; z-index: 60; width: min(92vw, 340px); display: flex; flex-direction: column; gap: 2px; padding: 5px;
  background: var(--paper); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--hairline);
}
.dl-menu[hidden] { display: none; }
.dl-menu button {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; font: inherit; color: var(--ink); background: transparent;
  border: 0; border-radius: 10px; padding: 9px 10px; cursor: pointer; min-height: 44px;
}
.dl-menu button:hover, .dl-menu button:focus-visible { background: var(--accent-soft); outline: none; }
.dl-menu button[aria-checked="true"] i { color: var(--accent); }
.dl-menu i { font-size: 18px; margin-top: 1px; color: var(--muted); flex: none; }
.dl-menu span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dl-menu b { font-weight: 500; }
.dl-menu em { font-style: normal; font-size: 10px; font-weight: 500; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.dl-menu small { color: var(--muted); font-size: 12px; line-height: 1.35; }

.print-card {
  display: flex; align-items: center; gap: 8px; padding: 8.4px 8.4px 8.4px 10px; border-radius: var(--radius);
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline);
}
.print-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.print-card-text b { font-weight: 500; font-size: 13px; }
.print-card-text span { color: var(--muted); line-height: 1.35; }
.note.warn { color: var(--danger); }
.note.warn[hidden] { display: none; }

.print-dialog { width: min(94vw, 520px); }
.print-dialog .segmented { align-self: flex-start; }
.print-dialog .segmented .seg span { display: inline; }
.print-pane { display: flex; flex-direction: column; gap: 9px; min-height: 150px; }
.print-pane[hidden] { display: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatches button, .swatches label {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.45);
}
.swatches button[aria-pressed="true"], .swatches label.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.swatches label input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.swatches label { display: grid; place-items: center; background: conic-gradient(#f66, #fd6, #6d6, #6df, #96f, #f66); }
.print-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.print-checks li { display: flex; gap: 7px; align-items: flex-start; color: var(--muted); line-height: 1.4; }
.print-checks li.warn { color: var(--danger); }
.print-checks li i { flex: none; margin-top: 1px; }
.print-checks li.ok i { color: var(--accent); }

/* ---------- print setup: advanced and profiles ---------- */
.print-dialog .segmented { flex-wrap: wrap; }
.print-pane { max-height: 52vh; overflow: auto; padding-right: 2px; }
.adv-grid { display: flex; flex-direction: column; gap: 7px; }
.adv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 150px) 26px; gap: 8px; align-items: center; font-size: 12px; }
.adv-row .lbl { display: flex; flex-direction: column; gap: 1px; min-width: 0; color: var(--ink); }
.adv-row .lbl small { color: var(--muted); line-height: 1.3; }
.adv-row .lbl.off b::after { content: ' ●'; color: var(--accent); font-size: 8px; vertical-align: 2px; }
.adv-row .unit, .adv-row select, .adv-add input {
  font: inherit; font-size: 13px; color: var(--ink); border: 0; background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--hairline); border-radius: 8px; padding: 6px 9px; min-width: 0; width: 100%;
}
.adv-row .unit { display: flex; align-items: center; gap: 4px; padding: 0 9px; }
.adv-row .unit input { flex: 1; min-width: 0; font: inherit; color: inherit; background: transparent; border: 0; padding: 6px 0; }
.adv-row .unit input:focus { outline: none; }
.adv-row .unit em { font-style: normal; color: var(--faint); font-size: 11px; }
.adv-row .unit:focus-within, .adv-add input:focus, .adv-row select:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
.adv-row select option { background: var(--paper); color: var(--ink); }
.adv-row .reset { width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--accent); cursor: pointer; display: grid; place-items: center; }
.adv-row .reset:hover { background: var(--accent-soft); }
.adv-row .reset[hidden] { display: none; }
.adv-row input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; justify-self: start; }
.adv-raw summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0; }
.adv-add { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-top: 6px; }
.adv-list, .profile-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.adv-list li, .profile-list li { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: var(--radius); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--hairline); }
.adv-list code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.profile-list li > span { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.profile-list li small { color: var(--muted); line-height: 1.3; }
.profile-list li.current { box-shadow: inset 0 0 0 1px var(--accent); }
.adv-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.print-pane .row-btns { display: flex; gap: 5.6px; flex-wrap: wrap; }
.print-checks li.info i { color: var(--muted); }
@media (max-width: 460px) { .adv-row { grid-template-columns: 1fr 120px 26px; } .adv-add { grid-template-columns: 1fr 1fr auto; } }
.note.warn .btn { margin: 6px 0 0; display: flex; }
