/*
 * app.css — components and layout for DesignClass FEA-StudioPRO.
 *
 * Built on the tokens in tokens.css (colours, type, radius, shadow, motion).
 * The look is the DesignClass "drawing office": pages styled like a technical drawing.
 *   Dark sections   = Drawing Ink with a faint blueprint grid.
 *   Light sections  = Tracing Paper with a faint paper grid.
 *   Section tags, mono eyebrows, crop corners, dimension lines and a title block.
 *
 * Contents
 *   1. Base & typography          6. Cards, choices, data
 *   2. Grids & drawing details    7. Feedback (notices, progress, toasts)
 *   3. Buttons                    8. Overlays (modal, drawer)
 *   4. Labels, tags, pills        9. Header, start screen
 *   5. Forms                     10. Work screen (sidebar, steps, viewport, title block)
 *                                11. Panels (part, material, supports, loads)
 *                                12. Responsive
 */

/* =========================================================================
   1. Base & typography
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--ink);     /* behind the translucent header; each section paints its own */
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.12; }
h1, h2 { font-weight: 800; letter-spacing: -0.025em; }
h1 { font-size: clamp(2.2rem, 4.6vw, 4.2rem); }
h2 { font-size: clamp(1.35rem, 2.2vw, 1.7rem); }
h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-d); }
b, strong { font-weight: 700; }
code, pre, .mono { font-family: var(--mono); }
[hidden], .hidden { display: none !important; }
::selection { background: rgba(36, 72, 255, .18); }

/* Focus is ALWAYS visible (brand rule). Blue on light, white on dark. */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
.on-dark :focus-visible, .ink :focus-visible, .app-header :focus-visible { outline-color: #fff; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--blue); color: #fff; padding: .6em 1em; border-radius: var(--r-pill);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--pencil); }
.small { font-size: .86rem; line-height: 1.5; }
.lede { font-size: 1.12rem; color: var(--pencil); }
.center { text-align: center; }

/* =========================================================================
   2. Grids & drawing details
   ========================================================================= */

/* Dark "ink" section with a blueprint grid (40px lines at ~7%). */
.ink {
  background-color: var(--ink);
  color: var(--body-dark);
  background-image:
    linear-gradient(var(--grid-dark) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-dark) 1px, transparent 1px);
  background-size: 40px 40px;
}
.ink h1, .ink h2, .ink h3 { color: #fff; }

/* Light "paper" section with a paper grid (32px lines at 5% Graphite). */
.paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-paper) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-paper) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Crop corners: blue 1.5px brackets offset 8px outside a key panel. */
.crop { position: relative; }
.crop::after {
  content: ""; position: absolute; inset: -8px; pointer-events: none;
  --c: var(--blue); --l: 16px; --w: 1.5px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top left / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--w) var(--l) no-repeat;
}
.ink .crop::after, .crop.crop-cyan::after { --c: var(--cyan); }

/* Dimension line: |<—— 120 mm ——>| — a 1px rule with arrow ticks and a mono label. */
.dimline {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: .78rem; font-weight: 500; color: var(--text);
  white-space: nowrap;
}
.dimline::before, .dimline::after {
  content: ""; flex: 1 1 auto; height: 9px; min-width: 14px;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
  opacity: .55;
}
.dimline::before { border-left: 1px solid currentColor; }
.dimline::after { border-right: 1px solid currentColor; }
.dimline .axis { color: var(--blue); font-weight: 700; margin-right: 2px; }
.ink .dimline, .on-dark .dimline { color: var(--dim-text); }
.ink .dimline .axis { color: var(--cyan); }

/* Title block: mono cells divided by 1px rules, label above value. */
.title-block {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  border-top: 1px solid var(--line-dark);
  background: var(--ink); color: var(--tb-text);
  font-family: var(--mono);
}
.title-block > div { padding: 10px 16px 11px; border-left: 1px solid var(--line-dark); min-width: 0; }
.title-block > div:first-child { border-left: 0; }
.tb-label { display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--tb-label); font-weight: 500; }
.tb-value { display: block; font-size: .8rem; font-weight: 500; color: var(--tb-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-value a { color: var(--tb-text); }
.tb-value a:hover { color: #fff; }
.title-block.light { background: var(--white); color: var(--text); border-top-color: var(--line-light); }
.title-block.light > div { border-left-color: var(--line-light); }
.title-block.light .tb-label { color: var(--faint); }
.title-block.light .tb-value { color: var(--text); }

/* =========================================================================
   3. Buttons — pills, Poppins 600, ≥44px, quiet motion
   ========================================================================= */
.btn {
  --bh: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: var(--bh); padding: .8em 1.45em;
  border-radius: var(--r-pill); border: 1.5px solid transparent;
  font: 600 1rem/1.15 var(--font); letter-spacing: -0.005em;
  text-decoration: none; cursor: pointer; user-select: none; white-space: nowrap;
  background: transparent; color: var(--text);
  transition: background-color var(--t-btn) var(--ease), color var(--t-btn) var(--ease),
              border-color var(--t-btn) var(--ease), box-shadow var(--t-btn) var(--ease),
              transform var(--t-btn) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-lg { --bh: 52px; font-size: 1.05rem; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:hover:not(:disabled) { background: var(--blue-d); color: #fff; }
.btn-outline { border-color: var(--text); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--text); color: #fff; }
.btn-ghost { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .55); color: #fff; }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .14); border-color: #fff; color: #fff; }
.btn-text { padding-inline: .6em; color: var(--blue); }
.btn-text:hover:not(:disabled) { background: rgba(36, 72, 255, .08); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad); color: #fff; }
.btn-sm { --bh: 44px; padding: .55em 1.1em; font-size: .9rem; }
.btn-block { display: flex; width: 100%; }
.btn .arrow { transition: transform var(--t-btn) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line-light); background: var(--white); color: var(--text);
  cursor: pointer; font: 600 1.05rem/1 var(--font);
  transition: background-color var(--t-btn) var(--ease), border-color var(--t-btn) var(--ease), color var(--t-btn) var(--ease);
}
.icon-btn:hover { border-color: var(--text); background: var(--text); color: #fff; }
.icon-btn svg { width: 18px; height: 18px; }
.ink .icon-btn, .on-dark .icon-btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.35); color: #fff; }

/* =========================================================================
   4. Labels, tags, pills
   ========================================================================= */
.eyebrow {
  display: inline-block;
  font-family: var(--mono); font-weight: 500; font-size: .8rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--pencil);
}
.ink .eyebrow, .on-dark .eyebrow { color: var(--dim-text); }

/* Section tag: outlined 1.5px box, the number in a filled cell. */
.tag {
  display: inline-flex; align-items: center; align-self: flex-start; padding: 0 9px 0 0;
  border: 1.5px solid var(--text); border-radius: var(--r-tag); overflow: hidden;
  font-family: var(--mono); font-size: .74rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; line-height: 1; color: var(--text);
}
.tag > b { background: var(--blue); color: #fff; padding: 6px 8px; margin-right: 9px; border-right: 1.5px solid var(--text); }
.ink .tag, .on-dark .tag { border-color: var(--cyan); color: var(--cyan); }
.ink .tag > b, .on-dark .tag > b { background: var(--cyan); color: var(--ink); border-right-color: var(--cyan); }

.pill {
  display: inline-flex; align-items: center; gap: .35em;
  padding: .28em .75em; border-radius: var(--r-pill);
  background: var(--level-pill); color: var(--text);
  font-family: var(--mono); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  line-height: 1.3; white-space: nowrap;
}
.pill-ok { background: var(--ok-tint); color: #136B3D; }
.pill-warn { background: var(--warn-tint); color: #7A5100; }
.pill-bad { background: var(--bad-tint); color: #A31E21; }
.pill-blue { background: rgba(36,72,255,.1); color: var(--blue); }
.ink .pill, .on-dark .pill { background: rgba(255,255,255,.08); color: var(--tb-text); }

/* Big headline treatments (use sparingly) */
.accent { color: var(--blue); }
.ink .accent { color: var(--cyan); }
.scribble { position: relative; display: inline-block; white-space: nowrap; }
.scribble > svg {
  position: absolute; left: -4%; bottom: -.2em; width: 108%; height: .42em;
  overflow: visible; pointer-events: none;
}
.scribble > svg path { fill: none; stroke: var(--scribble); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.cad-outline { color: transparent; -webkit-text-stroke: 2px var(--cyan); paint-order: stroke; }
.solid-block { position: relative; display: inline-block; color: #fff; padding: 0 .16em; z-index: 0; white-space: nowrap; }
.solid-block::before {
  content: ""; position: absolute; inset: .06em -.02em .02em; background: var(--blue);
  transform: skewX(-6deg); z-index: -1; border-radius: 4px;
}

/* =========================================================================
   5. Forms
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label {
  font-family: var(--mono); font-size: .7rem; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--pencil);
}
input[type="text"], input:not([type]), input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 50px; padding: 0 14px;
  font: 500 1rem/1.3 var(--font); color: var(--text);
  background: var(--white); border: 1.5px solid var(--field-line); border-radius: var(--r-input);
  transition: border-color var(--t-btn) var(--ease), box-shadow var(--t-btn) var(--ease);
}
textarea { padding: 12px 14px; min-height: 120px; }
select {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23121726' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36, 72, 255, .15);
}
input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px rgba(229, 56, 59, .12); }
.field-error { color: #A31E21; font-size: .84rem; }
.input-unit { position: relative; }
.input-unit > input { padding-right: 52px; font-family: var(--mono); }
.input-unit > .unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: .85rem; color: var(--pencil); pointer-events: none;
}

/* Segmented control: div.seg > button[aria-pressed] */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--track); border-radius: var(--r-pill);
}
.seg > button {
  min-height: 40px; padding: .45em 1em; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--pencil); font: 600 .9rem/1.1 var(--font); cursor: pointer;
  transition: background-color var(--t-btn) var(--ease), color var(--t-btn) var(--ease);
}
.seg > button:hover { color: var(--text); }
.seg > button[aria-pressed="true"] { background: var(--white); color: var(--blue); box-shadow: 0 2px 8px -3px rgba(10,16,32,.3); }
.ink .seg, .on-dark .seg { background: rgba(255,255,255,.08); }
.ink .seg > button, .on-dark .seg > button { color: var(--body-dark); }
.ink .seg > button[aria-pressed="true"], .on-dark .seg > button[aria-pressed="true"] { background: var(--blue); color: #fff; }

/* =========================================================================
   6. Cards, choices, data
   ========================================================================= */
.card {
  --k: var(--blue);
  position: relative; background: var(--white); color: var(--text);
  border-radius: var(--r-card); padding: 22px 22px 20px;
  box-shadow: 0 1px 0 rgba(10,16,32,.04), 0 18px 40px -28px rgba(10, 16, 32, .35);
  overflow: hidden;
  transition: transform var(--t-card) var(--ease), box-shadow var(--t-card) var(--ease);
}
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--k); }
.card.lift:hover { transform: translateY(-6px); box-shadow: var(--shadow-card-hover); }
.card-dark { background: var(--ink2); color: var(--body-dark); box-shadow: none; border: 1px solid var(--line-dark); }
.card-dark h3 { color: #fff; }
.card-flat { box-shadow: none; border: 1px solid var(--line-light); }

/* Selectable card / tile. [aria-pressed=true] = selected. */
.choice {
  --k: transparent;
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  width: 100%; min-height: 44px; padding: 14px 14px 13px;
  background: var(--white); color: var(--text);
  border: 1.5px solid var(--field-line); border-radius: var(--r-fact);
  font: inherit; cursor: pointer; overflow: hidden;
  transition: border-color var(--t-btn) var(--ease), box-shadow var(--t-card) var(--ease), transform var(--t-card) var(--ease);
}
.choice::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--k); }
.choice:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--text); transform: translateY(-2px); box-shadow: 0 14px 28px -20px rgba(10,16,32,.45); }
.choice[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 72, 255, .16); --k: var(--blue); }
.choice:disabled, .choice[aria-disabled="true"] { cursor: not-allowed; background: rgba(255,255,255,.55); color: var(--pencil); }
.choice .choice-title { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.choice .choice-sub { font-size: .84rem; color: var(--pencil); line-height: 1.4; }
.choice-check {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  display: none; place-items: center; background: var(--blue); color: #fff;
}
.choice[aria-pressed="true"] .choice-check { display: grid; }
.choice-check svg { width: 12px; height: 12px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }

/* Key/value list */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: .9rem; }
.kv dt { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--pencil); padding-top: .2em; }
.kv dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

/* Big-number tile */
.stat { padding: 12px 14px; border: 1px solid var(--line-light); border-radius: var(--r-fact); background: var(--white); }
.stat-label { font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--pencil); }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
.stat-unit { font-family: var(--mono); font-size: .78rem; color: var(--pencil); margin-left: 4px; }
.on-dark .stat, .ink .stat { background: var(--ink2); border-color: var(--line-dark); }
.on-dark .stat-value, .ink .stat-value { color: #fff; }

/* Ratings: ●●●○○ */
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--text); }
.dots i.on { background: var(--text); }

/* =========================================================================
   7. Feedback
   ========================================================================= */
.notice {
  position: relative; padding: 12px 14px 12px 18px; border-radius: 12px;
  background: rgba(36, 72, 255, .06); color: var(--text); font-size: .9rem; line-height: 1.5;
}
.notice::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--blue); }
.notice-warn { background: var(--warn-tint); }
.notice-warn::before { background: var(--warn); }
.notice-bad { background: var(--bad-tint); }
.notice-bad::before { background: var(--bad); }
.notice-ok { background: var(--ok-tint); }
.notice-ok::before { background: var(--ok); }
.notice b { font-weight: 700; }
.notice .notice-title { display: block; font-weight: 700; margin-bottom: 2px; }
.on-dark .notice, .ink .notice { background: rgba(79, 227, 255, .08); color: var(--fact-text); }
.on-dark .notice::before, .ink .notice::before { background: var(--cyan); }

.progress { height: 8px; border-radius: var(--r-pill); background: var(--track); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--blue); border-radius: inherit; transition: width .25s var(--ease); }
.progress.indeterminate .progress-bar {
  width: 35% !important; animation: progress-slide 1.3s var(--ease) infinite;
}
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.disclaimer {
  font-size: .8rem; color: var(--pencil); line-height: 1.5;
  border-top: 1px dashed var(--line-light); padding-top: 10px;
}
.ink .disclaimer { color: var(--lens-label); border-top-color: var(--line-dark); }

/* Toasts (aria-live region in index.html) */
.toasts {
  position: fixed; z-index: 150; right: 16px; bottom: 76px;   /* bottom-right, above the title block */
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  width: min(92vw, 420px); pointer-events: none;
}
@media (max-width: 900px) { .toasts { right: auto; left: 50%; transform: translateX(-50%); bottom: 84px; align-items: center; } }
/* While a dialog is open (older toasts are dismissed when it opens), new toasts sit in the
   strip under it, centred, so they cover neither its header (close button, first row) nor
   its buttons (UX-16). */
body:has(.modal-backdrop:not([hidden])) .toasts { top: auto; bottom: 6px; right: auto; left: 50%; transform: translateX(-50%); align-items: center; z-index: 160; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px 14px 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: .92rem; line-height: 1.45;
  box-shadow: var(--shadow-window); border-left: 4px solid var(--cyan);
  animation: toast-in .25s var(--ease);
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
.toast .toast-text { flex: 1; }
.toast button { position: relative; background: none; border: 0; color: var(--body-dark); cursor: pointer; font-size: 1.2rem; line-height: 1; min-width: 32px; min-height: 32px; border-radius: 50%; }
/* Invisible 42 px hit area around the 32 px dismiss button (tap-target rule). */
.toast button::before, .face-chip button::before { content: ''; position: absolute; inset: -5px; border-radius: 50%; }
.toast button:hover { color: #fff; background: rgba(255,255,255,.1); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .25s var(--ease), transform .25s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Developer error box (only shown when a module fails to load) */
.dev-error { font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; word-break: break-word; }

/* =========================================================================
   8. Overlays
   ========================================================================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 16, 32, .55); backdrop-filter: blur(4px);
  animation: fade-in .2s var(--ease);
}
.modal {
  width: min(680px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column;
  background: var(--paper); border-radius: var(--r-card); box-shadow: var(--shadow-window); overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-light); background: var(--white); }
.modal-head h2 { font-size: 1.25rem; flex: 1; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line-light); background: var(--white); }
.modal pre { margin: 0; padding: 14px; background: var(--ink); color: var(--fact-text); border-radius: 12px; font-size: .78rem; line-height: 1.5; overflow: auto; max-height: 50vh; }
.drawer {
  position: fixed; z-index: 120; top: var(--header-h); right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--paper); box-shadow: var(--shadow-window); display: flex; flex-direction: column;
  animation: drawer-in .25s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } }

/* =========================================================================
   9. Header & start screen
   ========================================================================= */
.app-header {
  position: fixed; z-index: 100; top: 0; left: 0; right: 0; height: var(--header-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--ink);   /* opaque Drawing Ink (82 % over paper looked grey) */
  border-bottom: 1px solid var(--line-dark); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { width: 42px; height: 42px; flex: none; }
.brand-name { font-weight: 800; font-size: 1.18rem; letter-spacing: -0.025em; color: #fff; white-space: nowrap; }
.brand-name b { color: var(--cyan); font-weight: 800; }
.brand-by { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim-text); text-decoration: none; white-space: nowrap; padding: 12px 0; }
.brand-by:hover { color: #fff; text-decoration: underline; }
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-level { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tb-text); }

.screen { padding-top: var(--header-h); }
#screen-start { background: var(--paper); }

/* --- Start hero --- */
.hero {
  position: relative; overflow: hidden; color: var(--body-dark);
  background-color: var(--ink);
  background-image:
    radial-gradient(ellipse 60% 70% at 72% 40%, rgba(36, 72, 255, .38), transparent 70%),
    linear-gradient(rgba(120,170,255,.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,170,255,.13) 1px, transparent 1px),
    linear-gradient(rgba(120,170,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,170,255,.05) 1px, transparent 1px);
  background-size: 100% 100%, 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: 0 0, -1px -1px, -1px -1px, -1px -1px, -1px -1px;
}
.hero-inner {
  max-width: 1240px; margin: 0 auto; padding: clamp(24px, 4.5vh, 56px) 24px clamp(28px, 5vh, 60px);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 32px; align-items: center;
}
.hero h1 { color: #fff; margin: 12px 0 16px; line-height: 1.14; font-size: clamp(2.2rem, 4.2vw, 4rem); }
.hero h1 > span { display: inline-block; margin-right: .22em; }
.hero .lede { color: var(--body-dark); max-width: 34ch; font-size: clamp(1.02rem, 1.4vw, 1.2rem); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 22px; }
.hero-meta .dimline { color: var(--dim-text); min-width: 180px; }

/* Mark inside a protractor / orbit ring */
.dial { position: relative; width: min(100%, 300px, 42vh); aspect-ratio: 1; margin: 0 auto; }
.dial > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dial > img {
  position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; transform: translate(-50%, -50%);
}
.dial .orbit { transform-origin: 50% 50%; animation: orbit 60s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }

/* Paper sections on the start screen */
.section { padding: clamp(24px, 4.5vh, 52px) 24px; }
.section-inner { max-width: 1240px; margin: 0 auto; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 16px; margin-bottom: 20px; }
.section-head h2 { flex: 1 1 auto; }
/* Start screen: "Made by: Solid part — change it below ↓" next to the level cards. */
.process-pointer { flex: 1 1 100%; margin: 0; color: var(--pencil); }
.process-pointer a { color: var(--blue); font-weight: 600; }

.level-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.level-card { display: flex; flex-direction: column; gap: 10px; padding: 26px 24px 22px; text-align: left; border: 0; font: inherit; cursor: pointer; }
.level-card[aria-disabled="true"] { cursor: not-allowed; background: rgba(255,255,255,.6); }
.level-card[aria-disabled="true"]:hover { transform: none; box-shadow: none; }
.level-card h3 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.025em; }
.level-card .level-desc { color: var(--pencil); font-size: .95rem; }
.level-card ul { margin: 2px 0 6px; padding: 0; list-style: none; display: grid; gap: 4px; font-size: .9rem; }
.level-card li { display: flex; gap: 8px; align-items: baseline; }
.level-card li::before { content: ""; flex: none; width: 10px; height: 1.5px; background: var(--blue); transform: translateY(-4px); }
.level-card .level-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.level-card .fake-btn { pointer-events: none; }

.process-grid { display: grid; grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr)); gap: 14px; }
.process-card { min-height: 128px; padding: 18px 18px 16px; }
.process-card .row-between { align-items: flex-start; }
.process-card .process-icon { width: 34px; height: 34px; color: var(--text); flex: none; }
.process-card[aria-disabled="true"] .process-icon { color: var(--faint); }
.process-note { margin-top: 14px; max-width: 72ch; }
button.process-card { font: inherit; }
.process-card[aria-disabled="true"] { pointer-events: auto; }

.start-foot { margin-top: 0; }
.start-foot .tb-logo { display: flex; align-items: center; padding: 10px 16px; }
.start-foot .tb-logo img { height: 40px; width: auto; }

/* =========================================================================
   10. Work screen
   ========================================================================= */
#screen-work { height: 100vh; display: flex; flex-direction: column; }
#screen-work[hidden] { display: none; }
.work {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 380px minmax(0, 1fr);
}

/* Sidebar */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line-light);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-paper) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-paper) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Process picker above the step list ("Made by [CNC machined ▾]"), every level. */
.process-bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--white); border-bottom: 1px solid var(--line-light);
}
.process-bar .process-bar-label { color: var(--faint); white-space: nowrap; }
.process-select {
  flex: 1 1 auto; min-width: 0; min-height: 42px; padding: 6px 34px 6px 12px;
  font: 600 .9rem var(--font); color: var(--text); background-color: var(--white);
  border: 1.5px solid var(--field-line); border-radius: 999px; cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.process-select:hover:not(:disabled) { border-color: var(--text); }
.process-select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.process-select:disabled { cursor: progress; opacity: .6; }

/* Sheet bar: the step list, styled like the sheet tabs of a drawing set. */
.sheet-bar {
  flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--white); border-bottom: 1px solid var(--line-light);
  position: sticky; top: 0; z-index: 2;
}
.sheet-bar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; padding: 8px 2px 9px; border: 0; border-left: 1px solid var(--line-light);
  background: transparent; color: var(--faint); cursor: pointer; font-family: var(--mono);
  transition: color var(--t-btn) var(--ease), background-color var(--t-btn) var(--ease);
}
.sheet-bar button:first-child { border-left: 0; }
.sheet-bar button:hover { color: var(--text); background: rgba(36,72,255,.04); }
.sheet-bar .sb-num { font-size: .88rem; font-weight: 700; line-height: 1; }
.sheet-bar .sb-label { font-size: .64rem; font-weight: 500; letter-spacing: 0; text-transform: uppercase; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Eight or more steps (e.g. CNC adds Tool): tighter letters so "MATERIAL" still fits — but
   never below 10px (low-DPI Chromebook screens); the full name is in the title / aria-label. */
.sheet-bar[data-count="8"] .sb-label, .sheet-bar[data-count="9"] .sb-label { font-size: .625rem; letter-spacing: -.05em; }
.sheet-bar[data-count="8"] button, .sheet-bar[data-count="9"] button { padding-inline: 1px; }
.sheet-bar button::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.sheet-bar button[aria-current="step"] { color: var(--blue); }
.sheet-bar button[aria-current="step"]::after { background: var(--blue); }
.sheet-bar .sb-tick {
  position: absolute; top: 5px; right: 5px; width: 14px; height: 14px; border-radius: 50%;
  display: none; place-items: center; background: var(--ok); color: #fff;
}
.sheet-bar .sb-tick svg { width: 8px; height: 8px; }
.sheet-bar button.done .sb-tick { display: grid; }
.sheet-bar button.stale .sb-tick { display: grid; background: var(--warn); }

.panel-scroll { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.panel { padding: 20px 20px 28px; }
.panel-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.panel-head h2 { font-size: 1.5rem; }
.panel-body { display: flex; flex-direction: column; gap: 16px; }
.panel-body h3 { font-size: 1rem; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.sub-head .eyebrow { font-size: .72rem; }

.sidebar-nav {
  flex: none; display: flex; gap: 10px; padding: 12px 16px;
  background: var(--white); border-top: 1px solid var(--line-light);
}
.sidebar-nav .btn { flex: 1; }
.sidebar-nav .btn-back { flex: 0 0 auto; }

/* Viewport column */
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--ink); }
.viewport-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
#viewport { position: absolute; inset: 0; }
.viewport.ink { background-size: 24px 24px; }

.vp-toolbar {
  position: absolute; z-index: 5; top: 12px; left: 12px; right: 12px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; pointer-events: none;
}
.vp-toolbar > * { pointer-events: auto; }
.vp-group {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: rgba(10, 16, 32, .78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-dark); border-radius: var(--r-pill);
}
.vp-btn {
  min-width: 42px; min-height: 42px; padding: 0 12px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--tb-text); cursor: pointer;
  font-family: var(--mono); font-size: .72rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  transition: background-color var(--t-btn) var(--ease), color var(--t-btn) var(--ease);
}
.vp-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.vp-btn[aria-pressed="true"] { background: var(--blue); color: #fff; }
.vp-btn:focus-visible { outline: 3px solid #fff; outline-offset: 1px; }
.vp-level { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 3px 3px 3px 14px; }
.vp-level .header-level { white-space: nowrap; }
.vp-level .vp-btn { color: var(--cyan); }

.vp-hint {
  position: absolute; z-index: 4; left: 50%; bottom: 18px; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 8px 14px; border-radius: var(--r-pill);
  background: rgba(10,16,32,.82); border: 1px solid var(--line-dark); color: var(--fact-text);
  font-size: .86rem; text-align: center; pointer-events: none;
}
.vp-status {
  position: absolute; z-index: 4; right: 12px; top: 58px; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: var(--r-pill); background: rgba(10,16,32,.82); border: 1px solid var(--line-dark);
  color: var(--fact-text); font-size: .8rem; pointer-events: none; max-width: calc(100% - 24px);
}
.vp-status[hidden] { display: none; }
.vp-status .tool-spinner { border-color: rgba(79,227,255,.3); border-top-color: var(--cyan); }
.vp-empty {
  position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; padding: 24px; pointer-events: none;
}
.vp-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: var(--dim-text); max-width: 340px; }
.vp-empty-inner svg { width: 140px; height: auto; color: var(--cyan); opacity: .75; }
.vp-empty-inner p { font-size: .95rem; }

.vp-drop {
  position: absolute; z-index: 6; inset: 12px; display: grid; place-items: center;
  border: 2px dashed var(--cyan); border-radius: 20px; background: rgba(10, 16, 32, .8);
  color: #fff; font-weight: 700; font-size: 1.2rem; pointer-events: none;
}
.vp-dev-error { position: absolute; z-index: 7; left: 16px; right: 16px; bottom: 16px; }

.stage .title-block { flex: none; }
/* Work-screen title block: Part / Material / Process / Level / Units / Sheet — the text cells get the room.
   Process ("CNC · small cutter · router") and Level ("Designer · National 5") need the most room;
   Units and Sheet are short. Every cell also has title = its full text (main.js drawTitleBlock). */
#work-title-block { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.1fr) max-content max-content; grid-auto-columns: auto; }
#work-title-block > div { padding-inline: 12px; }
/* Smaller laptop screens: drop the Units and Sheet cells so the four text cells stay readable. */
@media (max-width: 1299px) {
  #work-title-block { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.1fr); }
  #work-title-block .tb-hide-sm { display: none; }
}

/* =========================================================================
   11. Panels
   ========================================================================= */

/* Part gallery */
.preset-card { padding: 10px 12px 12px; gap: 4px; }
.preset-card .sketch { display: block; width: 100%; height: 84px; margin-bottom: 4px; }
.preset-card .sketch .face-top { fill: #fff; }
.preset-card .sketch .face-x { fill: #E6EBF7; }
.preset-card .sketch .face-z { fill: #D3DBEF; }
.preset-card .sketch polygon { stroke: var(--text); stroke-width: 1.1; stroke-linejoin: round; }
.preset-card[aria-pressed="true"] .sketch polygon { stroke: var(--blue); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 18px 16px; border: 1.5px dashed var(--field-line); border-radius: var(--r-fact);
  background: rgba(255,255,255,.6);
  transition: border-color var(--t-btn) var(--ease), background-color var(--t-btn) var(--ease);
}
.dropzone.over { border-color: var(--blue); background: rgba(36,72,255,.06); }
.dropzone svg { width: 30px; height: 30px; color: var(--blue); }

.part-summary { padding: 18px 18px 16px; }
.part-summary .part-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.dims { display: grid; gap: 6px; margin: 12px 0 10px; }
.part-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--mono); font-size: .76rem; color: var(--pencil); }

/* Material cards */
.mat-card { padding: 12px 12px 12px 14px; flex-direction: row; align-items: center; gap: 12px; }
.mat-swatch { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid rgba(10,16,32,.25); box-shadow: inset 0 -6px 0 rgba(10,16,32,.08); }
.mat-card .choice-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.mat-card .mat-off-pill { flex: none; white-space: nowrap; }
.mat-ratings { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 2px 10px; font-size: .78rem; color: var(--pencil); align-items: center; }
.mat-detail { padding: 18px; }
.mat-detail .row-between h3 { font-size: 1.1rem; }

/* Supports & loads */
.face-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.face-list li {
  display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; min-height: 52px;
  background: var(--white); border: 1px solid var(--line-light); border-radius: 12px;
}
.face-list li:hover { border-color: var(--text); }
.face-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.face-swatch.support { background: repeating-linear-gradient(45deg, #7186BB 0 2px, #DCE3F5 2px 5px); border: 1px solid #7186BB; }
.face-swatch.load { background: #5C78FF; }
.face-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 2px 2px 10px; min-height: 36px;
  border-radius: var(--r-pill); background: rgba(36,72,255,.08); color: var(--text); font-size: .85rem; font-weight: 500;
}
.face-chip button { position: relative; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--pencil); font-size: 1rem; }
.face-chip button:hover { background: var(--text); color: #fff; }
.pick-status { font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; color: var(--pencil); min-height: 1.4em; }
.illustration { display: flex; gap: 14px; align-items: center; }
.illustration > span:first-child { flex: none; width: 96px; }
.illustration svg { display: block; width: 96px; height: auto; color: var(--text); }

.load-card { padding: 16px 16px 14px; border: 1.5px solid transparent; }
.load-card.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,72,255,.12), 0 18px 40px -28px rgba(10,16,32,.35); }
.load-card .load-head { display: flex; align-items: center; gap: 10px; }
.load-card .load-head h3 { flex: 1; font-size: 1rem; }
.load-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.load-tile { flex-direction: row; align-items: center; gap: 10px; padding: 10px 10px; }
.load-tile .load-icon { font-size: 1.6rem; line-height: 1; flex: none; width: 34px; text-align: center; }
.load-tile .choice-title { font-size: .9rem; }
.dir-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dir-btn { flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; min-height: 52px; }
.dir-btn svg { width: 26px; height: 26px; flex: none; color: var(--blue); }
.dir-btn .choice-title { font-size: .88rem; }
.load-numeric { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 10px; }
.load-numeric select { padding-left: 12px; padding-right: 34px; background-position: right 12px center; }

/* =========================================================================
   12. Responsive
   ========================================================================= */
@media (max-width: 1100px) {
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .process-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  /* Work screen: viewport on top (50vh), panel below, the page scrolls. */
  #screen-work { height: auto; min-height: 100vh; }
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
  .stage { order: -1; height: 40vh; min-height: 260px; }
  .sidebar { border-right: 0; }
  .panel-scroll { overflow: visible; }
  .sheet-bar { top: var(--header-h); }
  .sidebar-nav { position: sticky; bottom: 0; z-index: 2; }
  .stage .title-block .tb-hide-sm { display: none; }
  #work-title-block { display: none; }   /* phone/tablet: the panel heading appears sooner */
  .hero-inner { grid-template-columns: minmax(0, 1fr); }
  .dial { width: 200px; order: -1; margin: 0; }
}
@media (max-width: 640px) {
  .app-header { padding: 0 12px; gap: 10px; }
  .brand-by { display: none; }
  .brand-name { font-size: 1.05rem; }
  .header-actions .btn { --bh: 42px; padding: .4em .9em; font-size: .85rem; }
  .section, .hero-inner { padding-left: 16px; padding-right: 16px; }
  .level-grid, .process-grid { grid-template-columns: minmax(0, 1fr); }
  .title-block { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-columns: auto; }
  .title-block > div { border-left: 0; border-top: 1px solid var(--line-dark); }
  .title-block > div:nth-child(2n) { border-left: 1px solid var(--line-dark); }
  .start-foot .tb-logo { grid-column: 1 / -1; }
  .vp-btn { padding: 0 9px; }
  .vp-level .header-level { display: none; }
  .panel { padding: 16px 16px 24px; }
  .dial { width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  .dial .orbit { animation: none; }
  .card.lift:hover, .choice:hover:not(:disabled) { transform: none; }
}
@media (min-width: 1600px) { .work { grid-template-columns: 420px minmax(0, 1fr); } }

/* Phone: "Change" keeps its context for screen readers ("Change level"). */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* No WebGL: the friendly notice replaces the empty-viewport hint, and the panels say why. */
.vp-nowebgl-note { margin-bottom: 4px; }

/* ---- Process checks (CNC Tool step): spinner, warning list, summary on Results ---------- */
.tool-spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; flex: none;
  border: 2px solid var(--line-light); border-top-color: var(--blue); border-radius: 50%;
  animation: tool-spin .8s linear infinite;
}
@keyframes tool-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tool-spinner { animation: none; border-top-color: var(--line-light); } }
.tool-check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tool-check-item {
  width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-light); border-left: 5px solid var(--warn);
  background: var(--warn-tint); color: var(--ink); font: inherit; font-size: .86rem; line-height: 1.4;
}
.tool-check-item.tool-check-bad { border-left-color: var(--bad); background: var(--bad-tint); }
.tool-check-item.tool-check-info { border-left-color: var(--cyan); background: var(--paper, #F4F2EC); }
.tool-check-item:hover { border-color: var(--ink); }
.tool-check-item:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.tool-check-item[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--blue) inset; }
.tool-check-badge {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font: 700 .72rem/1 var(--mono, "JetBrains Mono", monospace); background: var(--warn); color: var(--ink);
}
.tool-check-bad .tool-check-badge { background: var(--bad); color: #fff; }
.tool-check-info .tool-check-badge { background: var(--cyan); }
.tool-check-text { display: grid; gap: 2px; min-width: 0; }
.tool-check-title { font-weight: 600; }
.tool-check-value { font-size: .74rem; color: var(--pencil); letter-spacing: .01em; }
.fx-making { display: grid; gap: 6px; }
.fx-making-note { font-size: .76rem; }
/* UX-8: the checks' answer at the top of the Tool panel. */
.tool-status-line:empty { display: none; }
.tool-status { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 0; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line-light); background: var(--paper, #F4F2EC); }
.tool-status.is-ok { background: var(--ok-tint); border-color: var(--ok); }
.tool-status.is-warn { background: var(--warn-tint); border-color: var(--warn); }
.tool-status.is-bad { background: var(--bad-tint); border-color: var(--bad); }
.tool-status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--warn); }
.tool-status.is-ok .tool-status-dot { background: var(--ok); }
.tool-status.is-bad .tool-status-dot { background: var(--bad); }
.tool-status-go { font-weight: 600; color: var(--blue); }
/* UX-1: on a phone the list is far below the 3D view; this takes the pupil back to it. */
.vp-back-to-list { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 6; box-shadow: 0 2px 10px rgba(10,16,32,.25); }
.vp-back-to-list[hidden] { display: none; }
@media (min-width: 901px) { .vp-back-to-list { display: none; } }
@media (max-width: 900px) { #viewport-wrap { scroll-margin-top: calc(var(--header-h, 64px) + 8px); } }
.fx-making-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-making-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .76rem; font-weight: 600; background: var(--warn-tint); border: 1px solid var(--warn); color: var(--ink);
}
.fx-making-chip.is-bad { background: var(--bad-tint); border-color: var(--bad); }

/* =====================================================================================
   Laser cutting (Phase 2 Stage 3c): Profile step, slot fit, 3D option, results notes
   ===================================================================================== */
.pf-sketch { display: block; width: 100%; height: 76px; }
.pf-sketch path { fill: #E6EBF7; stroke: var(--text); stroke-width: 1.2px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.preset-card[aria-pressed="true"] .pf-sketch path { stroke: var(--blue); fill: #DCE3FF; }
.pf-summary-pic .pf-sketch { height: 120px; margin: 6px 0; }
.pf-preview-wrap { background: #fff; border-radius: 10px; padding: 8px; margin-top: 8px; }
.pf-preview { display: block; width: 100%; height: 180px; }
.pf-preview path { fill: none; stroke: var(--text); stroke-width: 1.4px; vector-effect: non-scaling-stroke; }
.pf-marker { fill: var(--bad); }
.pf-marker-ring { fill: none; stroke: var(--bad); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.pf-unit { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 2px 8px; text-align: left; white-space: normal; height: auto; min-height: 42px; line-height: 1.3; padding-top: 8px; padding-bottom: 8px; }
.pf-unit .pf-unit-size { font-weight: 400; opacity: .85; }
.pf-unit-row { gap: 6px; flex-wrap: wrap; }
.pf-slot-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.pf-slot { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; border-left: 4px solid var(--ok); background: var(--ok-tint); }
.pf-slot.pf-fit-tight, .pf-slot.pf-fit-loose { border-left-color: var(--warn); background: var(--warn-tint, #FFF4DC); }
.pf-fit-icon { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-weight: 700; min-width: 2.2em; text-align: center; }
.pf-slot-nums { display: block; }
.ld-step-note { margin: 0 0 4px; }
.ld-solid3d-card { margin-top: 6px; }
.ld-solid3d-card.is-pulse { animation: ld-pulse 1.2s ease-out 2; }
@keyframes ld-pulse { 0% { box-shadow: 0 0 0 0 rgba(36, 72, 255, .55); } 100% { box-shadow: 0 0 0 14px rgba(36, 72, 255, 0); } }
@media (prefers-reduced-motion: reduce) { .ld-solid3d-card.is-pulse { animation: none; outline: 3px solid var(--blue); } }
.fx-solver-line { margin: 0; }
.fx-solver-line .eyebrow { margin-right: 4px; }
