:root {
  --bg: #0d1117;
  --bg2: #131922;
  --card: #161d27;
  --line: #243041;
  --text: #e6ebf2;
  --muted: #8b97a8;
  --accent: #e5484d;
  --accent2: #ff6b70;
  --ok: #4cd38a;
  --warn: #ffb347;
  --fail: #ff4d5e;
  --info: #7aa2ff;
  --steel: #9aa3ad;
  --radius: 12px;
  --panel-w: 400px;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; min-height: 100dvh; font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, select, input { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #121823, #0f141c); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; font-size: 18px; }
.brand svg { width: 26px; height: 26px; }
.file-name { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #1c2533; cursor: pointer; user-select: none; transition: background .15s, border-color .15s;
}
.btn:hover { background: #222d3e; border-color: #34445c; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn:disabled { opacity: .5; cursor: progress; }
:focus-visible { outline: 2px solid #6aa8ff; outline-offset: 2px; }

.layout { flex: 1; display: grid; grid-template-columns: 1fr var(--panel-w); min-height: 0; }
.viewport { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #151d2a, var(--bg) 70%); touch-action: none; }
.viewport canvas { display: block; width: 100%; height: 100%; }
.panel { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; background: var(--bg2); border-left: 1px solid var(--line); }

.view-tools { position: absolute; top: 10px; left: 10px; display: flex; flex-wrap: wrap; gap: 6px; z-index: 2; }
.view-tools button {
  min-height: 34px; min-width: 44px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(22, 29, 39, .85); backdrop-filter: blur(6px); cursor: pointer; font-size: 13px;
}
.view-tools button:hover { border-color: #3a4a63; }
.view-tools .toggle[aria-pressed="true"] { background: #2a3a55; border-color: #4c6a9a; }
.view-tools button:disabled { opacity: .4; cursor: default; }
.reshape { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.reshape #limbPick[aria-pressed="true"] { background: #2a3a55; border-color: #4c6a9a; }
.limb-list { display: flex; flex-direction: column; gap: 2px; }
.limb-row { display: flex; gap: 8px; align-items: center; }

.fit-pill {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 2;
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; white-space: nowrap;
  background: rgba(22, 29, 39, .9); border: 1px solid var(--line); backdrop-filter: blur(6px);
}
.fit-pill.pass { color: var(--ok); border-color: rgba(76, 211, 138, .4); }
.fit-pill.warn { color: var(--warn); border-color: rgba(255, 179, 71, .4); }
.fit-pill.fail { color: var(--fail); border-color: rgba(255, 77, 94, .5); }

.view-legend { position: absolute; left: 12px; bottom: 14px; z-index: 2; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); pointer-events: none; }
.view-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.lim { background: #ffe14d; }
.dot.pk { background: #ff3355; }
.dot.sp { background: rgba(55, 194, 255, .5); }
@media (max-width: 860px) { .view-legend { display: none; } }

.drop {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; padding: 24px; text-align: center;
  background: rgba(13, 17, 23, .72); border: 2px dashed transparent; transition: border-color .15s, background .15s;
}
.drop.hidden { display: none; }
.drop.over { border-color: var(--accent); background: rgba(229, 72, 77, .08); }
.drop-title { font-size: 20px; font-weight: 650; margin: 0 0 8px; }
.drop-sub { color: var(--muted); max-width: 440px; margin: 0 auto; line-height: 1.45; }

/* Fixed to the window, never to the page: it stays on screen however far the page or the panel is scrolled. Over the
   middle of the 3D view, just below the header; on a phone, at the top of the screen. */
.busy {
  position: fixed; top: max(66px, env(safe-area-inset-top)); left: calc((100vw - var(--panel-w)) / 2);
  transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 8px 12px; border-radius: 10px; background: rgba(22, 29, 39, .95); border: 1px solid var(--line); font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #3a4a63; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: .6px; text-transform: uppercase; color: #b7c2d3; }
/* Collapsible cards (collapse.ts): the heading is a toggle; collapsed, only the heading row shows. */
.card-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; margin: -6px 0; padding: 0 6px 0 0;
  background: none; border: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: pointer; text-align: left;
}
.card-toggle .chev {
  width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; flex: none;
}
.card.collapsed .card-toggle .chev { transform: rotate(-45deg); }
.card.collapsed > :not(h2):not(.h-row) { display: none !important; }
.h-row { display: flex; align-items: center; justify-content: space-between; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row label { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
select, input[type="number"], input[type="text"], input[type="url"], input[type="password"] {
  min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: #0f151e; color: var(--text); width: 100%;
}
.unit { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.row input[type="number"] { width: 90px; display: inline-block; }
.row label:has(input[type="number"]) { flex-direction: row; align-items: center; color: var(--text); }
.custom-steel label { flex-direction: column; color: var(--muted); }
.custom-steel input[type="number"] { width: 100%; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.grow-group { display: inline-flex; gap: 6px; }
/* Keyboard shortcuts mean nothing on a touch screen. */
@media (hover: none) { .hint.keys { display: none; } }
.muted { color: var(--muted); font-size: 13px; }

.summary { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 14px; align-items: center; }
.summary .big { font-size: 40px; font-weight: 750; line-height: 1; letter-spacing: -1px; grid-row: span 2; }
.summary .big small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.status-chip { grid-column: 2; justify-self: start; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; background: #222b39; }
.status-chip.pass { color: var(--ok); background: rgba(76, 211, 138, .12); }
.status-chip.warn { color: var(--warn); background: rgba(255, 179, 71, .12); }
.status-chip.fail { color: var(--fail); background: rgba(255, 77, 94, .14); }
.sum-lines { font-size: 14px; }

.slider-row { position: relative; padding: 6px 0 16px; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; touch-action: pan-y; }
.max-mark { position: absolute; bottom: 0; transform: translateX(-50%); font-size: 11px; color: var(--ok); pointer-events: none; }
.max-mark::before { content: ""; position: absolute; left: 50%; top: -22px; width: 2px; height: 18px; background: var(--ok); border-radius: 2px; }

.switch { position: relative; width: 46px; height: 26px; flex-direction: row; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2a3445; border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #dfe6f0; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }

.underside-host { background: #0f151e; border: 1px solid var(--line); border-radius: 10px; aspect-ratio: 1 / 1; max-height: 320px; display: grid; }
.underside { width: 100%; height: 100%; touch-action: none; }
.u-steel { fill: none; stroke: rgba(154, 163, 173, .55); stroke-width: .1; }
.u-base { fill: rgba(255, 179, 71, .42); stroke: #ffb347; stroke-width: .1; }
.u-hole { fill: none; stroke: rgba(154, 163, 173, .7); stroke-width: .12; stroke-dasharray: .5 .3; }
.u-band { fill: none; stroke: rgba(154, 163, 173, .28); }
.u-feet { fill: rgba(229, 72, 77, .12); stroke: #e5484d; stroke-width: .12; }
.u-height { image-rendering: auto; opacity: .95; }
.u-label { fill: #12151c; font-weight: 700; pointer-events: none; user-select: none; }
.u-valid { fill: rgba(76, 211, 138, .22); stroke: var(--ok); stroke-width: .08; stroke-dasharray: .4 .3; }
.u-centre { fill: var(--steel); }
.u-pocket { stroke-width: .25; cursor: grab; }
/* The fill circle: an outline (filled, it read as a shadow over the map); the transparent fill keeps it draggable. */
.u-fill { fill: rgba(255, 179, 71, 0); stroke: #ffb347; stroke-width: .25; stroke-dasharray: .8 .5; cursor: grab; }
.u-fill:focus { outline: none; stroke: #6aa8ff; }
.u-shape { cursor: default; pointer-events: none; }
.u-drawing { stroke: #6aa8ff; stroke-dasharray: none; fill: none; pointer-events: none; }
svg.underside.drawing { cursor: crosshair; touch-action: none; }
.u-pocket.ok { fill: rgba(255, 255, 255, .85); stroke: #fff; }
.u-pocket.bad { fill: rgba(255, 77, 94, .85); stroke: #fff; }
.u-pocket:focus { outline: none; stroke: #6aa8ff; stroke-width: .4; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg.feet { background: transparent; border: 1.5px solid #e5484d; }
.lg.base { background: rgba(255, 179, 71, .6); border: 1px solid #ffb347; }
.lg.height { width: 28px; background: linear-gradient(90deg, rgb(40, 50, 70), rgb(190, 200, 230)); }
.lg.valid { background: rgba(76, 211, 138, .6); }
.lg.steel { background: rgba(154, 163, 173, .6); }

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checks li {
  display: grid; grid-template-columns: 22px 1fr; gap: 2px 8px; padding: 8px 10px; border-radius: 10px;
  background: #121924; border: 1px solid transparent; cursor: pointer;
}
.checks li:hover, .checks li.focus { border-color: #34445c; }
.checks .ic { grid-row: span 2; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #0d1117; margin-top: 1px; }
.checks .pass .ic { background: var(--ok); }
.checks .warn .ic { background: var(--warn); }
.checks .fail .ic { background: var(--fail); }
.checks .info .ic { background: var(--info); }
.checks .t { font-weight: 600; font-size: 14px; }
.checks .m { color: var(--muted); font-size: 13px; line-height: 1.35; }

.parts { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.parts .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid #0006; }

.slice-out, .export-out { display: flex; flex-direction: column; gap: 8px; }
.verdict { font-size: 16px; font-weight: 650; }
.verdict.yes { color: var(--warn); }
.verdict.no { color: var(--ok); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid #1e2734; white-space: nowrap; }
.tbl td.muted { white-space: normal; font-size: 12px; }
.tbl tr.best td { color: var(--ok); }
.tbl tr.current td:first-child { font-weight: 700; }
.tbl button { min-height: 30px; padding: 0 10px; font-size: 12px; }
.export-out a { color: #8fbaff; word-break: break-all; }
.err { color: var(--fail); font-size: 13px; }
.foot { text-align: center; padding: 4px 0 12px; }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 560px); padding: 10px 16px; border-radius: 10px; background: #2a1418; border: 1px solid var(--fail); color: #ffd7da;
}

@media (max-width: 860px) {
  /* A column of flex items, not grid rows: a grid item cannot stick outside its own row (the paint dock keeps
     the view on screen while the page scrolls). */
  .layout { display: flex; flex-direction: column; flex: 1 0 auto; }
  .viewport { flex: none; height: 52dvh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  body { overflow-y: auto; }
  .top { gap: 10px; padding: 8px 12px; }
  .brand span { display: none; }
  .summary .big { font-size: 34px; }
  .busy { top: max(8px, env(safe-area-inset-top)); left: 50%; }
}

/* Figure picker for files holding several figures. */
.card.pick { border-color: var(--accent); }
.card.pick select { font-weight: 600; }

/* Segmented control (magnet count). */
.tex-cost { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tex-cost button { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; font: inherit; font-size: 12.5px; cursor: pointer; line-height: 1.3; text-align: left; }
.tex-cost button b { font-size: 14px; }
.tex-cost button[aria-current="true"] { border-color: var(--accent); background: rgba(229, 72, 77, .12); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; color: var(--text); border: 0; padding: 6px 12px; min-width: 40px; min-height: 34px; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; font-weight: 600; }
/* Paint modes: seven of them wrap to a second line on a phone instead of widening the page. */
#paintMode { display: flex; flex-wrap: wrap; max-width: 100%; }
#paintMode button { flex: 1 1 auto; border-bottom: 1px solid var(--line); margin-bottom: -1px; }

.pocket-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.pocket-list li { display: flex; gap: 8px; align-items: baseline; }
.pocket-list .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #dfe6f0; color: #12151c; font-weight: 700; font-size: 12px; flex: none; }
.pocket-list .warn { color: var(--warn); }
.seat-row { gap: 10px; flex-wrap: wrap; }
.seat-row .seg button { padding: 0 12px; }
.simplify { margin-top: 8px; }
.simplify-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.simplify-row input[type="range"] { flex: 1 1 180px; min-width: 0; }
.simplify-count { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.simplify-count input { width: 12ch; }
label.off { opacity: .45; }

/* Colorize */
.palette { display: flex; flex-wrap: wrap; gap: 12px 10px; margin: 4px 0 12px; }
.swatch {
  width: 36px; height: 36px; border-radius: 10px; border: 2px solid #ffffff22; cursor: pointer;
  font: 700 12px/1 inherit; display: grid; place-items: center; padding: 0;
}
.swatch[aria-checked="true"] { outline: 2px solid var(--accent); outline-offset: 2px; border-color: #fff; }
.swatch.erase { background: repeating-linear-gradient(45deg, #1b2230 0 6px, #232c3c 6px 12px); color: var(--muted); font-size: 16px; }
.swatch.add { background: transparent; border: 2px dashed var(--line); color: var(--muted); font-size: 20px; }
/* The slot a palette colour prints from: a labelled dot in the slot's colour on the swatch's corner. */
.swatch { position: relative; }
.slot-dot {
  position: absolute; right: -6px; bottom: -6px; min-width: 18px; height: 16px; padding: 0 3px; border-radius: 8px;
  border: 2px solid var(--card); font: 700 9px/12px inherit; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000;
  pointer-events: none; box-sizing: border-box;
}
.slot-dot.none { background: repeating-linear-gradient(45deg, #2a3446 0 3px, #1b2230 3px 6px); }

/* Colours card "Colours from a picture": the reference art, tap to pick a colour; its main colours as chips. */
.ref-box { margin: 0 0 10px; }
.ref-get { gap: 8px; flex-wrap: wrap; }
.ref-get input { flex: 1 1 160px; min-width: 0; }
.ref-picture { margin-top: 8px; }
.ref-canvas-wrap { position: relative; display: flex; justify-content: center; background: #0c1018; border-radius: 10px; padding: 6px; }
.ref-canvas-wrap canvas { max-width: 100%; max-height: 260px; cursor: crosshair; touch-action: manipulation; image-rendering: auto; }
.ref-hover { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 6px; font: 600 12px/18px ui-monospace, monospace; pointer-events: none; border: 1px solid #0006; }
.ref-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.ref-chip { width: 30px; height: 30px; border-radius: 8px; border: 2px solid #ffffff22; cursor: pointer; padding: 0; }
.ref-chip:focus-visible, .ref-chip:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Colours card "Prints from": figure colour -> slot picker rows. */
/* contain: inline-size: the slot names (no-wrap, ellipsis) must not set the card's minimum width on a phone. */
.slot-map-box { margin: 4px 0 10px; padding-top: 8px; border-top: 1px solid var(--line); contain: inline-size; }
label.seat-row { flex-direction: row; align-items: center; flex-wrap: nowrap; }
label.seat-row select { width: auto; flex: 1; min-width: 0; max-width: 220px; }
.h-row.sub h3 { margin: 0; font-size: 13px; font-weight: 600; }
.h-row.sub { margin-bottom: 6px; gap: 8px; }
.h-row.sub #slotMapSource { flex: 1; min-width: 0; }
.btn.small { padding: 4px 10px; font-size: 12px; min-height: 30px; }
.slot-map { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.slot-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot-row .arrow { color: var(--muted); }
.slot-row.sel .fig-sw { outline: 2px solid #fff; outline-offset: 1px; }
.slot-row.unused { opacity: .6; }
.fig-sw {
  flex: none; width: 32px; height: 32px; border-radius: 9px; border: 2px solid #ffffff22;
  display: grid; place-items: center; font: 700 12px/1 inherit;
}
.slot-picker, .slot-opt {
  display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; color: var(--text);
}
.slot-picker {
  flex: 1; min-height: 44px; padding: 4px 10px 4px 6px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); cursor: pointer; font: inherit;
}
.slot-row.manual .slot-picker { border-color: #3b4b63; }
.slot-picker:hover, .slot-picker[aria-expanded="true"] { border-color: var(--muted); }
.slot-picker:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.slot-list:focus { outline: none; }   /* the active option shows where the keyboard is */
.sp-sw {
  flex: none; width: 28px; height: 28px; border-radius: 7px; border: 1px solid #ffffff33;
}
.sp-sw.none { background: repeating-linear-gradient(45deg, #2a3446 0 5px, #1b2230 5px 10px); border-style: dashed; }
.sp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sp-label { font-size: 13px; font-weight: 600; }
.sp-label em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--muted); }
.sp-detail { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-match { flex: none; font-size: 11px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.sp-match.good { color: #7ee2a8; background: #1d3a2b; }
.sp-match.close { color: #f2c46d; background: #3a3020; }
.sp-match.far, .sp-match.new { color: #ff9a9d; background: #3d2224; }
.sp-match.new { color: var(--muted); background: #222b38; }
.sp-caret { flex: none; color: var(--muted); }
.slot-list {
  position: fixed; z-index: 50; overflow-y: auto; padding: 4px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); box-shadow: 0 12px 32px #0009; overscroll-behavior: contain;
}
.slot-opt { min-height: 44px; padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.slot-opt:hover, .slot-opt.active { background: #1f2836; }
.slot-opt[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
label.colour-edit { flex-direction: row; }
.colour-edit { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.colour-edit input[type="color"] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
label.range-row { flex-direction: row; }
.range-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin: 6px 0; }
.range-row input { flex: 1; }
.row.wrap { flex-wrap: wrap; gap: 8px; }
#paintToggle[aria-pressed="true"], #regionsBtn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
canvas.picking { cursor: crosshair; }
.pocket-list .fail { color: var(--fail); }

details.adv { margin-top: 8px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.grid3 input { width: 100%; min-width: 0; }
@media (max-width: 420px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Rotation inputs (degrees). */
.rot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.rot-grid input { width: 100%; min-width: 0; }
.shape-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 4px; }
.shape-grid input, .shape-grid select { width: 100%; min-width: 0; }

/* Engine status: where the analysis runs (browser / local) and its start-up progress. */
.engine-chip { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.engine-chip.ready { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.engine-chip.loading { color: var(--warn); }
.engine-chip.failed { color: var(--fail); }

/* About panel: a scrollable overlay of plain text (also what crawlers read). */
.about { position: fixed; inset: 0; z-index: 50; background: rgba(8, 11, 16, .82); backdrop-filter: blur(6px); overflow-y: auto; padding: 24px 16px; }
.about[hidden] { display: none !important; }
.photos-inner { max-width: 560px; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.photo-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.photo-grid input { min-width: 0; max-width: 100%; color: var(--muted); font-size: 13px; }
.photo-grid input::file-selector-button { background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; margin-right: 8px; cursor: pointer; }
.about-inner { position: relative; max-width: 760px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 28px 20px; line-height: 1.55; }
.about h1 { font-size: 24px; margin: 0 40px 12px 0; line-height: 1.25; }
.about h2 { font-size: 16px; margin: 22px 0 8px; color: var(--text); }
.about p, .about li, .about dd { color: #c9d2de; font-size: 14.5px; }
.about ol, .about ul { padding-left: 20px; }
.about li { margin: 4px 0; }
.about dt { font-weight: 600; margin-top: 10px; }
.about dd { margin: 2px 0 0; }
.about pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; }
.about a { color: var(--accent2); }
.about-close { position: absolute; top: 14px; right: 14px; }
@media (max-width: 520px) { .about-inner { padding: 20px 16px; } .about h1 { font-size: 20px; } }

/* Phone header: short engine label, buttons on one line. */
.engine-chip .short { display: none; }
@media (max-width: 520px) {
  .engine-chip .long { display: none; }
  .engine-chip .short { display: inline; }
  .top .btn { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
}

/* Printer card: the live camera (16:9 MJPEG from beambam camera) and its status line. */
.cam-view { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; margin-top: 8px;
  border-radius: 8px; background: #000; }
.printer-status { min-height: 1.2em; overflow-wrap: anywhere; }

/* Photos dialog: generation options (collapsed by default). */
.gen-opts { margin: 8px 0 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.gen-opts summary { cursor: pointer; font-size: 14px; min-height: 32px; display: flex; align-items: center; }
.gen-opts select, .gen-opts input[type="number"] { background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 14px; min-height: 36px; }
.gen-opts input[type="range"] { width: 100%; min-height: 32px; }

/* Send to printer: the confirm panel under the print file. */
.print-plan { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 8px; }
.print-plan .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px;
  border: 1px solid rgba(255, 255, 255, 0.25); }
.print-check { font-size: 13px; display: grid; gap: 4px; }
.print-check .warn-text { color: var(--warn); }
/* The live spool confirm (printconfirm.ts): one row per filament, beambam's verdict at the end. */
.pc-rows { display: grid; gap: 6px; }
.pc-item { display: grid; gap: 2px; }
.pc-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.pc-row .slot-picker { grid-column: 1 / -1; min-width: 0; }
.pc-fil { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.pc-verdict { width: 1.5em; text-align: center; font-weight: 700; color: var(--ok); align-self: center; }
.pc-row.warn .pc-verdict { color: var(--warn); }
.pc-row.bad .pc-verdict { color: var(--fail); }
.pc-row.bad .slot-picker { border-color: var(--fail); }
.pc-lines { display: grid; gap: 2px; font-size: 12px; padding-left: 4px; }
.pc-lines .warn-text { color: var(--warn); }
.pc-nozzle { display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; }
.pc-nozzle .seg button { min-height: 40px; min-width: 64px; }
.pc-nozzles { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
.print-settings { margin: 6px 0 10px; }
.project-sync { display: grid; gap: 6px; margin: 6px 0 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.project-sync .sync-rows > summary { cursor: pointer; min-height: 32px; padding: 4px 0; }
.sync-row { display: grid; grid-template-columns: 1.6em 18px minmax(0, 1fr) 1.2em 18px minmax(0, 1fr); align-items: center; gap: 6px; padding: 2px 0; }
.sync-row .sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.sync-row > span:not(.sw) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-row.differs { color: var(--warn); }
.print-settings > summary { cursor: pointer; padding: 6px 0; min-height: 32px; }
.print-settings .grid2 { margin-top: 6px; }
.print-settings select { width: 100%; }
.pc-sync { font-size: 12px; }
/* "Send with Bambu Connect" below Start: another way to print, no signing key. */
.pc-connect { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.btn.wide { width: 100%; }
.ok-text { color: var(--ok); font-size: 13px; }
/* Print card on the site: the link to beambam on this device. */
.beambam-row { display: grid; gap: 6px; margin-bottom: 8px; }
.beambam-row .row input { flex: 1 1 200px; min-width: 0; }
.cmd { display: block; padding: 6px 8px; border-radius: 8px; background: #0f151e; border: 1px solid var(--line);
  font-size: 12px; overflow-wrap: anywhere; user-select: all; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
/* Colorize stamp: the box being dragged, its ellipse shown inside. */
.stamp-box { position: absolute; pointer-events: none; border: 2px dashed #6aa8ff; border-radius: 50%; background: rgba(106, 168, 255, .12); z-index: 5; }

/* Paint dock (paintdock.ts): the painting controls on the 3D view while painting, at its bottom, scrolling inside
   itself; folded, only the palette shows. Its rows scroll sideways on a phone instead of wrapping tall. */
.view-tools .paint-view[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.paint-dock {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 4; width: min(760px, calc(100% - 20px));
  max-height: min(56%, 380px); display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px;
  border-radius: 12px; background: rgba(19, 25, 34, .93); border: 1px solid var(--line); backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45); touch-action: manipulation;
}
/* Fold and Done sit at the end of the palette's row (the palette scrolls under the space they take). */
.dock-head { position: absolute; top: 8px; right: 10px; z-index: 1; display: flex; align-items: center; gap: 6px; }
.dock-fold .chev {
  width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s;
}
.paint-dock.folded .dock-fold .chev { transform: rotate(-135deg) translate(-2px, -2px); }
.dock-body { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.paint-dock.folded .dock-body > :not(#palette) { display: none !important; }
.dock-body .palette { margin: 0; gap: 10px; flex-wrap: nowrap; overflow: auto hidden; padding: 3px 8px 8px 3px; flex: none;
  margin-right: 104px; }
.dock-body #paintModeRow > .muted { display: none; }   /* "Tap fills": the mode buttons say it */
.dock-body #paintInfo { font-size: 12px; }
.dock-body .swatch { flex: none; width: 34px; height: 34px; }
.dock-body .seat-row, .dock-body #paintTools { flex-wrap: nowrap; overflow-x: auto; gap: 6px; }
.dock-body #paintMode { flex-wrap: nowrap; flex: none; }
.dock-body #paintMode button { flex: none; white-space: nowrap; }
.dock-body .btn { flex: none; min-height: 36px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
.dock-body .range-row { margin: 0; }
.dock-body #paintSteps { gap: 6px; }
.dock-body #paintInfo { flex-basis: 100%; }
/* What the dock covers makes way: the fit pill and legend; on a phone the view stays on screen (sticky, taller). */
body.painting .fit-pill, body.painting .view-legend { display: none; }
@media (max-width: 860px) {
  body.painting .viewport { height: 64dvh; position: sticky; top: 0; z-index: 6; border-bottom: 1px solid var(--line); }
  .paint-dock { bottom: 6px; width: calc(100% - 12px); padding: 6px 8px 8px; }
  .dock-body .swatch { width: 32px; height: 32px; }
}

/* "Prints from" folded: a line of chips, figure colour -> the slot it prints from. */
.h-row.sub h3 .card-toggle { margin: 0; min-height: 30px; }
.slot-summary { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; text-align: left; font: inherit; }
.slot-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px 2px 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); font-size: 11px; }
.slot-chip.unused { opacity: .6; }
.slot-chip .arrow { color: var(--muted); }
.mini-sw { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 3px; border-radius: 5px; border: 1px solid #ffffff22; font: 700 10px/1 inherit; }
.mini-sw.none { background: repeating-linear-gradient(45deg, #2a3446 0 3px, #1b2230 3px 6px); color: var(--muted); }

/* "Changes to your model" (changes.ts): what is reshaping the figure now, with an Undo each. */
.changes { border: 1px solid rgba(255, 179, 71, .45); border-radius: 10px; padding: 8px 10px; background: rgba(255, 179, 71, .06);
  display: flex; flex-direction: column; gap: 6px; }
.changes-head { font-size: 13px; font-weight: 600; }
.change-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; }
.change-row .what { flex: 1 1 160px; min-width: 0; }
.change-row .origin { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: var(--muted); }
.change-row .origin.remembered { background: rgba(255, 179, 71, .18); color: var(--warn); }
/* A control whose setting is reshaping the figure. */
.changed-control { box-shadow: inset 3px 0 0 var(--warn); padding-left: 6px; border-radius: 4px; }

/* Weak points (weak.ts). */
.weak { display: flex; flex-direction: column; gap: 6px; }
.weak-list { display: flex; flex-direction: column; gap: 4px; }
.weak-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; padding: 4px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.weak-text { flex: 1 1 180px; min-width: 0; color: var(--muted); }
.weak-actions { display: flex; gap: 6px; align-items: center; }
.weak-actions select { min-height: 30px; }
.weak-done { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.grade { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-weight: 700; font-size: 13px; color: #111; }
.grade-A { background: #3fbf6f; }
.grade-B { background: #9bd14a; }
.grade-C { background: #f2c94c; }
.grade-D { background: #f2994a; }
.grade-F { background: #ff4d5e; color: #fff; }
