/* Materia — a material on a bench in a real lab, read like an instrument. The photograph and the piece carry the colour;
 * the interface is graphite glass with hairlines, one accent (beryl) for the one thing to do next, numbers in tabular
 * figures with their ± and unit always beside them. Phone first: everything the thumb needs sits in the bottom third.
 * Layers: #stage → #title (left), #cutbar (the piece), #ask (the one entry: top on desktop, above the dock on a phone)
 * → #card → #dock (Properties · Make · Test · More) → #sheet / #cut-pop → #find (the entry, open). */
@font-face { font-family: "Bricolage"; src: url("../_engines/fonts/BricolageGrotesque-latin.woff2") format("woff2"); font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
:root {
  /* a light bench: the scene is a bright lab, so the interface is white glass with dark ink (4.5:1 or better on every surface) */
  --field: #eef1f3; --ink: #1b1f23; --ink-dim: rgba(27, 31, 35, 0.76); --ink-faint: rgba(27, 31, 35, 0.62);
  --glass: rgba(255, 255, 255, 0.82); --glass-strong: rgba(255, 255, 255, 0.96); --glass-light: rgba(20, 30, 40, 0.06);
  --edge: rgba(20, 30, 40, 0.10); --edge-strong: rgba(20, 30, 40, 0.22);
  --accent: #0b7a6d; --accent-ink: #ffffff; --accent-soft: rgba(11, 122, 109, 0.12); --accent-text: #0b6f63;
  --font: "Bricolage", "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
  --pad: 14px; --blur: blur(18px) saturate(1.2); --ease: cubic-bezier(0.2, 0.8, 0.2, 1); --shadow: 0 8px 28px -12px rgba(20, 30, 40, 0.35);
  --r: 14px; --dock-h: 60px; --ask-h: 46px;
  /* the shared design system (_engines/ui) in the same light key, for the sheets try.js, plan, measure and ask build */
  --ui-bg: #eef1f3; --ui-bg-deep: #dfe4e8; --ui-surface: rgba(255, 255, 255, 0.82); --ui-surface-solid: #ffffff; --ui-surface-strong: rgba(255, 255, 255, 0.97);
  --ui-raise: rgba(20, 30, 40, 0.06); --ui-raise-hover: rgba(20, 30, 40, 0.11); --ui-line: rgba(20, 30, 40, 0.10); --ui-line-strong: rgba(20, 30, 40, 0.22);
  --ui-ink: #1b1f23; --ui-ink-dim: rgba(27, 31, 35, 0.76); --ui-ink-faint: rgba(27, 31, 35, 0.62); --ui-scrim: rgba(30, 40, 50, 0.32);
  --ui-measured-text: #17703f; --ui-computed-text: #1d4fa8; --ui-approx-text: #8a5200; --ui-predicted-text: #5b2fb0; --ui-bad: #b3361b; --ui-warn: #8a5200;
  --ui-shadow: 0 10px 30px -14px rgba(20, 30, 40, 0.4); --ui-shadow-sheet: 0 -10px 40px -16px rgba(20, 30, 40, 0.4);
  color-scheme: light;
}
html[data-ui-accent="beryl"] { --ui-accent: #0b7a6d; --ui-accent-ink: #ffffff; --ui-accent-soft: rgba(11, 122, 109, 0.12); --ui-accent-glow: rgba(11, 122, 109, 0.25); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--field); color: var(--ink); font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "kern"; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
.glass { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: inset 0 0 0 1px var(--edge), var(--shadow); }
.glass-strong { background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: inset 0 0 0 1px var(--edge), var(--shadow); }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 5; color: var(--ink-dim); font-size: 14px; background: var(--field); transition: opacity 0.6s var(--ease); pointer-events: none; }
#loading.off { opacity: 0; }
#loading i { display: block; width: 10px; height: 10px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 18px 3px var(--accent-soft); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(0.6); opacity: 0.5; } }

#brand { position: fixed; top: calc(var(--pad) + env(safe-area-inset-top)); left: var(--pad); z-index: 8; }
body.lab-on #brand { display: none; }
/* the Simple/Pro switch (_engines/ui/mode.js) sits right of the product name: the right corner holds the measure and the sheet buttons */
.ui-mode--float { top: calc(var(--pad) + env(safe-area-inset-top)); left: calc(var(--pad) + 153px); right: auto; z-index: 8; }
#crumbs { display: none; }
.adv { display: none; }
body.advanced .adv { display: revert; }
body.advanced .adv.row { display: flex; }

/* ---------- the one entry ---------- */
#ask { position: fixed; z-index: 7; top: calc(var(--pad) + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 380px)); height: var(--ask-h);
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 14px; border: 0; border-radius: var(--r); color: var(--ink-dim); cursor: text; text-align: left; font-size: 15px; }
#ask svg { width: 18px; height: 18px; flex: none; color: var(--ink-faint); }
#ask .ph { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ask kbd { flex: none; font: 600 12px/1 var(--font); color: var(--ink-faint); padding: 6px 7px; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--edge-strong); }
#ask:hover { color: var(--ink); background: rgba(255, 255, 255, 0.96); }
body.find-on #ask { visibility: hidden; }
/* in the Lab the entry folds to a search button at the top right (the instrument strip has the top left) */
body.lab-on #ask { left: auto; right: var(--pad); transform: none; width: var(--ask-h); padding: 0; justify-content: center; border-radius: 50%; }
body.lab-on #ask .ph, body.lab-on #ask kbd { display: none; }
body.lab-on #ask svg { color: var(--ink); }

#find { position: fixed; inset: 0; z-index: 30; background: rgba(30, 40, 50, 0.30); display: flex; justify-content: center; align-items: flex-start; padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
#find .panel { width: min(640px, 100%); max-height: min(78vh, 720px); margin-top: 0; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; }
#find .bar { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; height: 56px; border-bottom: 1px solid var(--edge); flex: none; }
#find .bar svg { width: 18px; height: 18px; color: var(--ink-faint); flex: none; }
#find input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--ink); font: 500 17px var(--font); outline: none; }
#find input::placeholder { color: var(--ink-faint); }
#find input::-webkit-search-cancel-button { display: none; }
#find .x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-dim); cursor: pointer; font-size: 18px; }
#find .x:hover { background: var(--glass-light); color: var(--ink); }
#find .out { overflow: auto; padding: 6px 8px 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#find h3 { margin: 12px 8px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-faint); letter-spacing: 0.01em; }
#find .do { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 52px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
#find .do:hover, #find .do:focus-visible, #find .pk-item:focus-visible { background: var(--glass-light); outline: none; }
#find .do .ic { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); font-size: 15px; }
#find .do .tx { display: flex; flex-direction: column; min-width: 0; }
#find .do b { font-weight: 600; font-size: 15px; }
#find .do small { color: var(--ink-dim); font-size: 13px; line-height: 1.3; }
#find .mats .pk-h { margin: 14px 8px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-faint); }
#find .mats .pk-h small { font-weight: 400; color: var(--ink-faint); margin-left: 4px; }
#find .mats .pk-more { margin: 8px; }
#find .mats .pk-bring { margin: 14px 8px 4px; }

/* ---------- the title: what it is, then its key numbers ---------- */
#title { position: fixed; top: calc(80px + env(safe-area-inset-top)); left: calc(var(--pad) + 6px); z-index: 5; width: min(380px, calc(100vw - 2 * var(--pad))); pointer-events: none; text-shadow: 0 0 14px rgba(255, 255, 255, 0.85), 0 0 3px rgba(255, 255, 255, 0.7); }
#title h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 680; letter-spacing: -0.022em; }
#title-why { margin: 6px 0 0; font-size: 14.5px; color: var(--ink-dim); }
#title-why .nw { white-space: nowrap; }
#title-why .mpf { display: block; margin-top: 4px; font-size: 13px; }
#title-why .mpf .nw { display: block; }   /* one MP-resolved number a line: a value with its DFT twin does not fit beside another */
#title-why .mpf a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#title-src { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-faint); }
#title-facts { margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border-radius: 12px; overflow: hidden; background: var(--edge); box-shadow: inset 0 0 0 1px var(--edge); text-shadow: none; }
#title-facts:empty { display: none; }
#title-facts > div { padding: 8px 12px 9px; background: rgba(255, 255, 255, 0.78); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); min-width: 0; }
#title-facts dt { font-size: 12px; color: var(--ink-faint); margin: 0 0 1px; }
#title-facts dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.v { font-weight: 650; color: var(--ink); }
.pm { margin-left: 4px; color: var(--ink-dim); font-weight: 450; }
.u { margin-left: 3px; color: var(--ink-dim); font-weight: 450; font-size: 0.92em; }
.unk { font-style: normal; color: var(--ink-faint); }
#title .ctas { display: flex; gap: 8px; margin-top: 14px; pointer-events: auto; flex-wrap: wrap; }
#title .cta { min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: 700 15px/1 var(--font); cursor: pointer; text-shadow: none; }
#title .cta:hover { filter: brightness(1.06); }
#title .cta2 { min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--glass); color: var(--ink); font: 600 14.5px/1 var(--font); cursor: pointer; text-shadow: none; box-shadow: inset 0 0 0 1px var(--edge-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
#title .cta2:hover { background: rgba(255, 255, 255, 0.98); }
body.lab-on #title { display: none; }
/* the reliability words (measured, calculated, estimated, unknown): .badge.word lives in _engines/ui/ui.css (lab-number.js badgeHTML) */
#title-facts .badge.word { font-size: 12px; padding: 0 6px; margin-left: 2px; }

#hint { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4; font-size: 13px; color: var(--ink-dim); text-shadow: 0 0 10px rgba(255, 255, 255, 0.9); pointer-events: none; transition: opacity 0.5s; white-space: nowrap; }
#hint.off, #hint.under-scale, body:has(#card:not([hidden])) #hint, body.sheet-open #hint { opacity: 0; }
#scale { position: fixed; left: 0; top: 0; z-index: 4; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--ink-dim); pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity 0.4s; }

/* ---------- the piece: as grown / wafer / cube, its face, and how close you look ---------- */
#cutbar { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h) + 26px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 12px; max-width: calc(100vw - 2 * var(--pad)); }
#cutbar .seg { display: flex; gap: 2px; }
#cutbar button { height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-dim); font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; }
#cutbar button:hover { color: var(--ink); background: var(--glass-light); }
#cutbar button.on { color: var(--ink); background: rgba(20, 30, 40, 0.10); box-shadow: inset 0 0 0 1px var(--edge-strong); }
#cutbar .face { color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent-soft); }
#cutbar .face span { color: var(--ink-faint); font-weight: 500; }
#cutbar .face b { font-variant-numeric: tabular-nums; color: var(--accent-text); }
#cutbar .div { width: 1px; height: 22px; background: var(--edge-strong); margin: 0 4px; }
body.lab-on #cutbar, body.lab-on #cut-pop, body.sheet-open #cutbar, body.tr-open #cutbar { display: none; }
#cut-pop { position: fixed; z-index: 9; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h) + 76px + env(safe-area-inset-bottom)); width: min(400px, calc(100vw - 2 * var(--pad))); max-height: 60vh; overflow: auto; padding: 12px 14px 12px; border-radius: 16px; }
#cut-pop header { display: flex; align-items: center; justify-content: space-between; }
#cut-pop h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
#cut-pop .x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-dim); cursor: pointer; font-size: 18px; }
#cut-pop .lede { margin: 2px 0 10px; font-size: 13px; color: var(--ink-dim); }
#cut-pop .chips { display: flex; flex-wrap: wrap; gap: 6px; }
#cut-pop .chip { min-height: 40px; padding: 4px 12px; border: 0; border-radius: 10px; background: var(--glass-light); color: var(--ink); font: 650 15px/1.1 var(--font); font-variant-numeric: tabular-nums; cursor: pointer; display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; }
#cut-pop .chip small { font-size: 12px; font-weight: 500; color: var(--ink-dim); }
#cut-pop .chip.on { background: var(--accent); color: var(--accent-ink); }
#cut-pop .chip.on small { color: var(--accent-ink); }
#cut-pop .hkl { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
#cut-pop .hkl label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-dim); font-style: italic; }
#cut-pop .hkl input { width: 44px; height: 40px; border-radius: 9px; border: 1px solid var(--edge-strong); background: var(--glass-light); color: var(--ink); font: 600 15px var(--font); text-align: center; font-style: normal; }
#cut-pop .hkl button { height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--glass-light); color: var(--ink); font: 600 13.5px var(--font); cursor: pointer; }
#cut-pop .err { flex-basis: 100%; font-size: 12.5px; color: #b3361b; }
#cut-pop .err:empty { display: none; }
#cut-pop .note { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-faint); }
dl.kv { display: grid; grid-template-columns: minmax(7em, 1fr) auto; gap: 0; margin: 10px 0 0; font-size: 14px; }
dl.kv dt { padding: 7px 10px 7px 0; color: var(--ink-dim); border-top: 1px solid var(--edge); }
dl.kv dd { margin: 0; padding: 7px 0; border-top: 1px solid var(--edge); text-align: right; font-variant-numeric: tabular-nums; }

/* the atom you touched */
#card { position: fixed; left: 50%; bottom: calc(var(--dock-h) + 80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9; width: min(560px, calc(100vw - 2 * var(--pad))); padding: 10px 12px 10px 16px; border-radius: 16px; display: flex; align-items: center; gap: 12px; }
#card .swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.25), 0 0 0 2px var(--edge-strong); }
#card .text { flex: 1; min-width: 0; }
#card .line { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
#card .sub { font-size: 13px; color: var(--ink-dim); margin-top: 2px; }
#card .act { display: flex; gap: 6px; flex: none; }
#card .act button { height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--glass-light); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
#card .act button.on { background: var(--accent); color: var(--accent-ink); }
#card .x { width: 44px; height: 44px; padding: 0; font-size: 17px; line-height: 1; }

/* ---------- the main menu ---------- */
#dock { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 16px; max-width: calc(100vw - 2 * var(--pad)); }
#dock button { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 52px; min-width: 84px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-dim); cursor: pointer; transition: background 0.15s, color 0.15s; }
#dock button[hidden] { display: none; }
#dock button:hover { color: var(--ink); background: var(--glass-light); }
#dock button.on { color: var(--ink); background: rgba(20, 30, 40, 0.10); box-shadow: inset 0 0 0 1px var(--edge-strong); }
#dock #lab-btn:not(.on) { color: var(--accent-text); }
#dock #lab-btn.on { color: var(--accent-ink); background: var(--accent); box-shadow: none; }
#dock button svg { width: 21px; height: 21px; flex: none; }
#dock button span { font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; }

/* ---------- one sheet: Properties, More, Display, Lessons ---------- */
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; max-height: 80vh; display: flex; flex-direction: column; border-radius: 20px 20px 0 0; background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: inset 0 1px 0 var(--edge), var(--shadow); transform: translateY(105%); transition: transform 0.36s var(--ease); padding-bottom: calc(var(--dock-h) + 24px + env(safe-area-inset-bottom)); }
#sheet.on { transform: none; }
#sheet > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 8px 18px; flex: none; border-bottom: 1px solid var(--edge); }
#sheet > header h2 { margin: 2px 0 0; font-size: 19px; font-weight: 680; letter-spacing: -0.02em; }
#sheet > header p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-dim); }
#sheet > header p sub { font-size: 12px; }
#sheet .x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--glass-light); color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1; flex: none; }
#sheet .body { overflow: auto; padding: 8px 18px 14px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; overflow-wrap: break-word; word-break: normal; hyphens: manual; }
#sheet h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-faint); }
#sheet p { margin: 6px 0; font-size: 14.5px; line-height: 1.5; max-width: 62ch; }
#sheet p.muted { color: var(--ink-faint); font-size: 13px; }
#sheet p.legend { font-size: 12.5px; color: var(--ink-faint); line-height: 1.7; }
#sheet .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
#sheet .pill { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--glass-light); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); cursor: pointer; font-size: 14px; font-weight: 550; text-decoration: none; white-space: nowrap; }
#sheet .pill.on, #sheet .pill.go { background: var(--accent); color: var(--accent-ink); font-weight: 650; box-shadow: none; }
#sheet .pill:hover:not(.on):not(.go) { background: rgba(20, 30, 40, 0.10); }
#sheet .pill b { font-weight: 700; }
#sheet .pill.num { height: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; white-space: normal; flex-wrap: wrap; row-gap: 2px; max-width: 100%; cursor: default; }
#sheet .pill .badge:not(.word) { font-style: normal; font-size: 12px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; background: #e2efed; color: #0a5f55; margin-left: 2px; }
#sheet .sure { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
#sheet .sure .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--glass-light); position: relative; overflow: hidden; }
#sheet .sure .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }
#sheet .sure b { font-size: 13px; white-space: nowrap; }
#sheet table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 6px 0; }
#sheet th { text-align: left; font-weight: 500; color: var(--ink-faint); padding: 5px 8px 5px 0; }
#sheet td { padding: 5px 8px 5px 0; border-top: 1px solid var(--edge); }
#sheet td.num, #sheet th.num { text-align: right; }
#sheet .hash { font-size: 12.5px; color: var(--ink-dim); overflow-wrap: anywhere; }
#sheet p.why { font-size: 13.5px; color: var(--ink); margin: 4px 0 8px; }
/* the key numbers: label left, value ± unit and badge right, one hairline between rows */
#sheet table.keys { font-size: 15px; margin: 4px 0 6px; }
#sheet table.keys th { color: var(--ink-dim); font-weight: 450; padding: 9px 10px 9px 0; border-top: 1px solid var(--edge); vertical-align: baseline; }
#sheet table.keys td { padding: 9px 0; text-align: right; white-space: nowrap; vertical-align: baseline; }
#sheet table.keys tr:first-child th, #sheet table.keys tr:first-child td { border-top: 0; }
#sheet table.keys .w { font-weight: 600; }
/* the rest, one tap each */
#sheet details.fold { border-top: 1px solid var(--edge); }
#sheet details.fold:last-of-type { border-bottom: 1px solid var(--edge); }
#sheet details.fold > summary { list-style: none; display: flex; flex-direction: column; justify-content: center; min-height: 54px; padding: 8px 28px 8px 0; cursor: pointer; position: relative; }
#sheet details.fold > summary::-webkit-details-marker { display: none; }
#sheet details.fold > summary::after { content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid var(--ink-faint); border-bottom: 2px solid var(--ink-faint); transform: rotate(45deg); transition: transform 0.2s var(--ease); }
#sheet details.fold[open] > summary::after { transform: rotate(225deg); margin-top: -2px; }
#sheet details.fold > summary span { font-size: 15px; font-weight: 620; }
#sheet details.fold > summary small { font-size: 12.5px; color: var(--ink-faint); }
#sheet details.fold > .in { padding: 0 0 12px; }
#sheet details.fold .pp h3 { color: var(--ink-dim); }
#sheet .pp .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#sheet .pp td, #sheet .pp th { white-space: nowrap; }
#sheet .pp td:first-child { white-space: normal; min-width: 0; }
#sheet .pp td small { color: var(--ink-dim); font-size: 12.5px; white-space: nowrap; }
#sheet .pp .badge:not(.word) { font-style: normal; font-size: 12px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; background: #e2efed; color: #0a5f55; cursor: help; }
#sheet table.models td.num, #sheet table.models th { white-space: nowrap; }
/* More: the rest of the menu, rows big enough for a thumb */
#sheet .menu { display: grid; gap: 2px; margin: 4px 0 8px; }
#sheet .menu .mi { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
#sheet .menu button.mi:hover { background: var(--glass-light); }
#sheet .menu .ic { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--glass-light); color: var(--ink); font-size: 16px; }
#sheet .menu .tx { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#sheet .menu b { font-size: 15px; font-weight: 620; }
#sheet .menu small { font-size: 13px; color: var(--ink-dim); line-height: 1.3; }
#sheet .menu .chev { color: var(--ink-faint); font-size: 20px; }
#sheet .menu .sw { width: 42px; height: 26px; border-radius: 13px; background: var(--edge-strong); position: relative; flex: none; transition: background 0.2s; }
#sheet .menu .sw i { position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform 0.2s var(--ease); }
#sheet .menu .sw.on { background: var(--accent); }
#sheet .menu .sw.on i { transform: translateX(16px); background: var(--accent-ink); }
#sheet .menu .week .pill { min-width: 44px; justify-content: center; font-size: 18px; }
#sheet .list { list-style: none; margin: 0; padding: 0; }
#sheet .list button { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 6px; border: 0; border-top: 1px solid var(--edge); background: transparent; color: var(--ink); text-align: left; cursor: pointer; border-radius: 8px; }
#sheet .list button:hover { background: var(--glass-light); }
#sheet .list b { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; min-width: 92px; }
#sheet .list small { color: var(--ink-dim); font-size: 13px; }
#sheet .dots { display: inline-flex; gap: 3px; margin-left: auto; }
#sheet .dots i { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.5); }
body.sheet-open #card { display: none; }

/* desktop: the sheet is a column on the right, the entry stays on top */
@media (min-width: 760px) {
  #sheet { left: auto; right: var(--pad); top: calc(var(--pad) + var(--ask-h) + 12px + env(safe-area-inset-top)); bottom: calc(var(--dock-h) + 26px + env(safe-area-inset-bottom)); width: 420px; max-height: none; border-radius: 18px; padding-bottom: 6px; transform: translateX(110%); }
  #sheet.on { transform: none; }
  body.sheet-open #cutbar { display: flex; }
  #find { padding-top: calc(var(--pad) + env(safe-area-inset-top)); }
}
/* phone: everything the thumb needs is in the bottom third — the piece's bar, the entry, the menu */
@media (max-width: 759px) {
  :root { --dock-h: 58px; }
  #title { top: calc(66px + env(safe-area-inset-top)); left: var(--pad); width: calc(100vw - 2 * var(--pad)); }
  #title h1 { font-size: 23px; }
  #title-why { font-size: 13.5px; margin-top: 3px; }
  #title-src { display: none; }
  #title-facts { margin-top: 10px; }
  #title-facts > div { padding: 6px 10px 7px; }
  #title-facts dd { font-size: 14px; }
  #title-facts .badge.word { display: none; }
  #title .ctas { margin-top: 10px; }
  #title .cta, #title .cta2 { min-height: 42px; font-size: 14.5px; }
  #ask { top: auto; left: var(--pad); right: var(--pad); width: auto; transform: none; bottom: calc(var(--dock-h) + 20px + env(safe-area-inset-bottom)); height: 48px; }
  #ask kbd { display: none; }
  body.lab-on #ask { top: calc(var(--pad) + env(safe-area-inset-top)); bottom: auto; left: auto; right: var(--pad); width: 44px; height: 44px; }
  body.sheet-open #ask, body.tr-open #ask { display: none; }
  #cutbar { bottom: calc(var(--dock-h) + 78px + env(safe-area-inset-bottom)); left: var(--pad); right: var(--pad); transform: none; justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  #cutbar::-webkit-scrollbar { display: none; }
  #cutbar button { padding: 0 9px; font-size: 13px; height: 38px; }
  #cutbar .div { margin: 0 2px; }
  #cut-pop { left: 0; right: 0; transform: none; width: auto; bottom: 0; border-radius: 18px 18px 0 0; max-height: 70vh; z-index: 10; padding-bottom: calc(var(--dock-h) + 30px + env(safe-area-inset-bottom)); }
  #hint { bottom: calc(var(--dock-h) + 132px + env(safe-area-inset-bottom)); font-size: 12.5px; }
  #card { bottom: calc(var(--dock-h) + 130px + env(safe-area-inset-bottom)); }
  #dock { left: var(--pad); right: var(--pad); transform: none; bottom: calc(10px + env(safe-area-inset-bottom)); justify-content: space-between; }
  #dock button { flex: 1 1 0; min-width: 0; padding: 0 2px; }
  #find { padding: 0; background: var(--field); }
  #find .panel { width: 100%; max-height: none; height: 100%; border-radius: 0; padding-top: env(safe-area-inset-top); }
  body.sheet-open #title { opacity: 0; pointer-events: none; }
  body.sheet-open #title * { pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) { #sheet, #loading, #hint { transition: none; } #loading i { animation: none; } }
/* before app.js fills them (try.js is up first): the title's two buttons and the cut bar are skeletons, not empty frames */
@keyframes skel { from { background-position: 100% 0; } to { background-position: 0 0; } }
#title .ctas button:empty, #cutbar:has(#cut-form:empty) { color: transparent; box-shadow: none; pointer-events: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  background: linear-gradient(100deg, rgba(20, 30, 40, 0.07) 30%, rgba(20, 30, 40, 0.14) 50%, rgba(20, 30, 40, 0.07) 70%) 0 0 / 300% 100%; animation: skel 1.5s linear infinite; }
#title .cta:empty { width: 168px; } #title .cta2:empty { width: 120px; }
#cutbar:has(#cut-form:empty) { width: min(420px, calc(100vw - 2 * var(--pad))); height: 44px; }
#cutbar:has(#cut-form:empty) > * { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { #title .ctas button:empty, #cutbar:has(#cut-form:empty) { animation: none; background-position: 50% 0; } }
/* the first screen in plain HTML (first.js): the still of the material in the loading veil, under the title; the title's key
   numbers keep their badge word even on a phone until app.js owns them. No WebGL: the veil stays, says why, no skeletons */
#first { margin: 0 auto 10px; display: grid; justify-items: center; gap: 10px; }
#first img { display: block; width: min(300px, 62vw, 30vh); height: auto; max-height: min(300px, 30vh); object-fit: contain; filter: drop-shadow(0 10px 18px rgba(20, 30, 40, 0.16)); }
#first .why { max-width: min(320px, 84vw); text-align: center; font-size: 13.5px; line-height: 1.35; color: var(--ink-dim); }
body.first-on #loading i, body.first-on #loading > div > span, body[data-nogl="1"] #loading i, body[data-nogl="1"] #loading > div > span { display: none; }
body.first-on #title-facts .badge.word { display: inline-block; }
body.first-on #title-facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* three numbers: the third spans the row, no empty cell */
body[data-nogl="1"] #title .ctas, body[data-nogl="1"] #cutbar { display: none; }
@media (max-width: 759px) { body.first-on #loading > div, body[data-nogl="1"] #loading > div { margin-top: 26vh; } }
/* keyboard focus: the same ring on every dock and panel control, even where a rule set outline: none or a radius of its own */
#dock button:focus-visible, #cutbar button:focus-visible, #sheet :is(button, a, summary, input):focus-visible, #cut-pop :is(button, input):focus-visible, #card button:focus-visible, #title .ctas button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* a DFT number beside a measured one (keyNumbers in app.js): said next to it, quieter */
.key-alt { color: var(--ink-dim); font-size: 0.92em; white-space: nowrap; }
#title-facts .key-alt { display: none; }   /* the tile has room for one number; the MP line above it says both */
#sheet table.keys .key-alt { display: block; margin-top: 2px; }   /* its own line under the value: the td does not wrap */

/* first visit guide of the lessons (class-panel.js): a card, never a modal */
#guide { position: fixed; right: var(--pad); top: calc(68px + env(safe-area-inset-top)); z-index: 7; width: min(330px, calc(100vw - 2 * var(--pad))); padding: 14px 16px; border-radius: 16px; }
#guide .step { margin: 0; font-size: 13px; font-weight: 600; color: var(--accent-text); }
#guide .say { margin: 6px 0 12px; font-size: 14.5px; line-height: 1.45; }
#guide .act { display: flex; justify-content: flex-end; gap: 8px; }
#guide button { height: 40px; padding: 0 14px; border: 0; border-radius: 10px; font: 600 13px var(--font); cursor: pointer; background: var(--glass-light); color: var(--ink-dim); }
#guide button.go { background: var(--accent); color: var(--accent-ink); }
body.sheet-open #guide, body.lab-on #guide { display: none; }
@media (max-width: 640px) { #guide { top: auto; right: auto; left: var(--pad); bottom: calc(92px + env(safe-area-inset-bottom)); width: calc(100vw - 2 * var(--pad)); } }
body:has(#guide) #hint { opacity: 0; }

/* opaque, like .badge.word in _engines/ui/ui.css: ≥ 5:1 over any backdrop (M 5.00, C 6.35, S 6.47, D 6.93, I 8.67) */
.badge.b-M { background: #dfebe4; color: #17703f; }
.badge.b-C { background: #e4eaf5; color: #1d4fa8; }
.badge.b-S { background: #f6ebdb; color: #7a4800; }
.badge.b-D { background: #ebe6f6; color: #5b2fb0; }
.badge.b-I { background: #ecedee; color: #3d4246; }
#sheet ul.eq { margin: 4px 0 8px; padding-left: 18px; font-size: 13.5px; line-height: 1.45; }
#sheet ul.eq li { margin: 3px 0; }
#sheet .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#sheet td.src { color: var(--ink-dim); font-size: 13px; min-width: 140px; }

/* picker.js: the one list of materials (the Materials sheet, the Lab's Replace sample and Compare with…) */
.pk { display: block; }
.pk .pk-q { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--edge-strong); background: var(--glass-light); color: var(--ink); font: 500 15px var(--font); position: sticky; top: 0; z-index: 1; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
:is(#sheet, #lab-sheet) .pk .pk-h { margin: 16px 0 4px; font-size: 13px; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0; }
:is(#sheet, #lab-sheet) .pk .pk-h small { font-weight: 500; color: var(--ink-faint); margin-left: 4px; }
.pk .pk-list { display: grid; gap: 2px; }
.pk .pk-item { display: flex; width: 100%; min-height: 48px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.pk .pk-item:hover { background: var(--glass-light); }
.pk .pk-item.on { background: var(--accent-soft); }
.pk .pk-item:disabled { opacity: 0.45; cursor: default; }
.pk .pk-name b { font-weight: 600; font-size: 14.5px; }
.pk .pk-f { color: var(--ink-dim); font-size: 12.5px; }
.pk .pk-tag { color: var(--ink-faint); font-size: 12px; }
.pk .pk-tag em { font-style: normal; color: var(--accent-text); font-weight: 600; }
.pk .pk-more { margin: 10px 2px; font-size: 12.5px; color: var(--ink-dim); }
.pk .pk-bring { margin: 14px 0 6px; border-top: 1px solid var(--edge); padding-top: 8px; }
.pk .pk-bring summary { cursor: pointer; font-weight: 600; font-size: 13.5px; min-height: 36px; display: flex; align-items: center; }
.pk .pk-how, .pk .pk-msg { font-size: 12.5px; color: var(--ink-dim); margin: 4px 0; }
.pk .pk-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pk .pk-row input { flex: 1 1 140px; min-height: 40px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--edge-strong); background: var(--glass-light); color: var(--ink); font: 500 14px var(--font); }
.pk .pk-row button, .pk .pk-file { min-height: 40px; padding: 0 14px; border: 0; border-radius: 20px; background: var(--glass-light); color: var(--ink); font: 600 13px var(--font); cursor: pointer; display: inline-flex; align-items: center; }
.pk .pk-file input { display: none; }
/* touch: every control is at least 44 px */
@media (max-width: 520px), (pointer: coarse) {
  #sheet .x, #find .x, #cut-pop .x { width: 44px; height: 44px; }
  #sheet .pill, #cut-pop .chip, .pk .pk-row input, .pk .pk-row button, .pk .pk-file { min-height: 44px; }
}
sub, sup { font-size: max(12px, 0.72em); line-height: 0; }
small { font-size: max(12px, 0.83em); }
@media (max-width: 520px), (pointer: coarse) {
  #test-btn, #facts-more, #cutbar button, #cutbar .face, .ui-tabs > *, details > summary { min-height: 44px; }
  #title a, #title-src a { position: relative; }
  #title a::after, #title-src a::after { content: ""; position: absolute; inset: -14px -4px; }
}
/* Describe anything (substance-card.js) */
.sub-card { display: grid; gap: 10px; }
.sub-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr; gap: 2px 12px; align-items: baseline; }
.sub-k { font-weight: 600; }
.sub-v.unk { opacity: 0.7; font-style: italic; }
.sub-src { grid-column: 2; opacity: 0.7; font-size: 12px; line-height: 1.4; }
.sub-b { font-style: normal; display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent-text); white-space: nowrap; }
.sub-none { font-weight: 600; }

/* ---------- the render first (13/10): every panel overlays the canvas and never resizes it. A side panel is at most --panel-w
 * (≤ 30 % of a desktop), scrolls inside itself, and folds to a tab on its inner edge (panel-fold.js) to give the whole bench back;
 * on a phone a panel is a bottom sheet over at most the lower half, so the material stays in view above it. ---------- */
:root { --panel-w: clamp(300px, 28vw, 400px); --sheet-max: 46vh; }
.pf-tab { display: none; }
@media (min-width: 760px) {
  #sheet { width: var(--panel-w); }
  .pf { transition: transform 0.32s var(--ease); }
  .pf-tab { display: grid; place-items: center; position: absolute; top: 14px; width: 26px; height: 52px; padding: 0; border: 0; border-radius: 10px; color: var(--ink-dim); cursor: pointer; z-index: 2; }
  .pf-tab:hover { color: var(--ink); background: var(--glass-strong); }
  .pf-tab svg { width: 10px; height: 18px; transition: transform 0.32s var(--ease); }
  .pf-right > .pf-tab { left: -32px; }
  .pf-left > .pf-tab { right: -32px; }
  .pf-right > .pf-tab svg, .pf-left.pf-folded > .pf-tab svg { transform: rotate(180deg); }
  .pf-right.pf-folded > .pf-tab svg { transform: none; }
  .pf-right.pf-folded { transform: translateX(calc(100% + var(--pad) + 2px)) !important; }
  .pf-left.pf-folded { transform: translateX(calc(-100% - var(--pad) - 2px)) !important; }
}
@media (max-width: 759px) {
  #sheet { max-height: var(--sheet-max); }
}
@media (prefers-reduced-motion: reduce) { .pf, .pf-tab svg { transition: none; } }
/* the passport table: the unit is in the quantity's column, so the cells' <lab-number> keep it in their dialog and citation only */
#sheet .pp table lab-number .u { display: none; }
