/* ChipBreaker v1 — warm dark shop-book theme. Vanilla CSS, no preprocessor. */

/* ---------- theme tokens ---------- */
:root {
  --bg:           #1f1c19;          /* dark warm gray, not pure black */
  --bg-elev-1:    #2a2622;          /* one step lighter (cards, headers) */
  --bg-elev-2:    #353029;          /* two steps lighter (inputs, buttons) */
  --bg-elev-3:    #443d33;          /* highlight / selected row */
  --line:         #54493d;          /* subtle borders */
  --text:         #f0e6d2;          /* warm off-white */
  --text-dim:     #b3a48a;          /* secondary text */
  --text-faint:   #786b58;          /* hints, formula text */
  --accent:       #d46030;          /* brand orange (Oryn's Simple Tools line) */
  --accent-dim:   #833c1e;          /* brand orange, dimmed for borders */
  --danger:       #c46a4a;
  --shadow:       0 2px 6px rgba(0,0,0,0.4);

  --tap-min:      60px;             /* minimum tappable size */
  --tap-primary:  80px;             /* primary action button */

  --font-stack:   -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* ---------- reset / base ----------
 *
 * Universal touch-action: manipulation
 * -----------------------------------
 * This rule disables iOS double-tap-to-zoom on EVERY element in the app —
 * not just on form controls or a hand-maintained list of tap targets. After
 * v1.3.3 → v1.4.2 each iteration of "selector list of interactive elements"
 * missed a new element class on the next round of testing (numpad buttons →
 * Converter unit-pill → Converter container divs). The pattern is: any
 * element the user might touch needs touch-action: manipulation, including
 * non-interactive container divs, spans, and section elements that catch
 * stray taps in padding / gaps / empty regions. The universal selector is
 * the only cover that closes the gap completely.
 *
 * Side effects: touch-action: manipulation only disables the non-standard
 * double-tap-to-zoom gesture. Single-tap, panning (all our scroll surfaces
 * — .tool-body, .conv-tabs, .wheel-track, .calc-display), and pinch-zoom
 * (the iOS accessibility hook) all continue to work. The app's design
 * doctrine explicitly disallows double-tap-to-zoom (viewport meta has
 * user-scalable=no, ignored on iOS Safari 10+, so this CSS is the only
 * lever iOS actually honors).
 *
 * Maintenance policy: this universal declaration is the single point of
 * edit for tap-target touch behavior. If a future tool needs a different
 * touch-action (e.g. pan-y only, or none), add the more-specific override
 * to that element's own rule — do NOT remove this universal rule.
 *
 * The existing per-rule declarations from v1.3.5 (html/body, .numpad
 * button, .overlay .modal .actions .btn) and the v1.4.2 broader selector
 * list (button, a, input, textarea, .wheel-item, .unit-tag, .conv-output
 * .row) STAY IN PLACE EXACTLY AS THEY ARE. They are redundant with this
 * rule, but redundant ≠ harmful, and the user wants them kept as
 * historical markers for the bug-fix audit trail. Do not remove them. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-stack);
  font-size: 18px;
  line-height: 1.3;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  /* Disable double-tap-to-zoom and other non-standard tap gestures so
   * iOS doesn't briefly re-interpret a tap as a gesture and shift the
   * page transform mid-tap. user-scalable=no in the viewport meta is
   * ignored on iOS Safari 10+ for accessibility, so this CSS hint is
   * the only thing iOS actually honors. Pinch-zoom (two-finger) is
   * still allowed; only the single-finger double-tap gesture is off. */
  touch-action: manipulation;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input { font-family: inherit; color: inherit; }

/* ---------- iOS gesture-suppression (broad coverage) ----------
 * Bug A in v1.4.2: iOS interprets a double-tap on any tappable element as the
 * start of a double-tap-to-zoom gesture, briefly shifts the page transform,
 * and decouples tap coordinates from layout. Same root cause as the v1.3.5
 * numpad bug — surfaced again in the Converter unit-pill ("inch (decimal)")
 * and would surface again every time a new tap target is introduced. Rather
 * than chase per-element fixes, declare touch-action: manipulation on every
 * interactive element app-wide so iOS never gets the chance.
 *
 * touch-action is NOT inherited, so each tappable element has to declare it.
 * This rule covers every <button>, <a>, <input>, and <textarea> in the app
 * (which catches segmented-control pills, category tabs, +/- steppers, list
 * items, menu tiles, calc grid keys, trig-cell clears, material-card heads,
 * and so on — they're all real <button> or <a> elements). The explicit class
 * selectors after that cover the few interactive elements that aren't a
 * standard form/anchor tag: scroll-wheel items (divs), the converter amber
 * unit-pill (span), and the tappable converter output rows (divs).
 *
 * The existing v1.3.5 per-rule declarations (html/body above, .numpad button
 * and .overlay .modal .actions .btn further down) stay in place. They're now
 * redundant with this rule, but the user wants them kept; that's fine —
 * touch-action: manipulation declared twice has no conflict.
 *
 * Adding a new tappable UI element: add its selector to the list below.
 * Don't strip declarations from this rule or the per-rule v1.3.5 ones.
 * Pinch-zoom (two-finger) is still allowed everywhere; only the single-
 * finger double-tap gesture is off. */
button, a, input, textarea,
.wheel-item,         /* scroll-wheel items (divs) */
.unit-tag,           /* converter amber unit-pill (span) */
.conv-output .row    /* tappable output rows in converter (divs) */
{
  touch-action: manipulation;
}

/* ---------- app shell ---------- */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 8px;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar .title {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.5px;
}
.topbar .icon-btn {
  width: var(--tap-min);
  height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--accent);
}
.topbar .icon-btn:active { background: var(--bg-elev-2); border-radius: 8px; }

/* ---------- main menu ---------- */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}
.menu-tile {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 12px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow);
}
.menu-tile:active { background: var(--bg-elev-2); }
.menu-tile .tile-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.menu-tile .tile-icon svg { width: 100%; height: 100%; }
.menu-tile .tile-label {
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.units-tip {
  margin: 12px 16px 4px;
  padding: 12px 14px;
  background: var(--bg-elev-1);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 15px;
  display: flex; align-items: center; gap: 10px;
}
.units-tip .dismiss {
  margin-left: auto;
  color: var(--accent);
  font-size: 22px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- tool body ----------
 * Block layout, not flex column. A flex column container clips children whose
 * overflow is not `visible` (their min-height: auto resolves to 0, so flex-shrink
 * squishes them below content). The Materials accordion hit this: an expanded
 * card stayed at its allocated flex space and the body content got clipped by
 * the card's own `overflow: hidden`, so the page never grew tall enough to need
 * scrolling. Block layout lets children take their full content height and
 * triggers overflow-y: auto correctly. */
.tool-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 24px;
}
.tool-body > * + * { margin-top: 12px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.label {
  font-size: 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.hint { font-size: 13px; color: var(--text-faint); }
.formula { font-family: var(--font-mono); font-size: 13px; color: var(--text-faint); }

/* ---------- segmented control ---------- */
.segmented {
  display: flex;
  background: var(--bg-elev-1);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.segmented button {
  flex: 1;
  height: 50px;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dim);
}
.segmented button.active {
  background: var(--accent);
  color: #1f1c19;
}

/* ---------- stepper / numeric input ---------- */
.numfield {
  display: flex;
  align-items: stretch;
  background: var(--bg-elev-2);
  border-radius: 12px;
  overflow: hidden;
  height: var(--tap-min);
}
.numfield .step {
  width: var(--tap-min);
  font-size: 32px;
  color: var(--accent);
  background: var(--bg-elev-2);
  display: flex; align-items: center; justify-content: center;
}
.numfield .step:active { background: var(--bg-elev-3); }
.numfield .val {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg-elev-1);
}
.numfield .val .unit {
  font-size: 16px;
  color: var(--text-dim);
  margin-left: 6px;
  font-weight: 400;
}

/* ---------- scroll wheel ---------- */
.wheel {
  position: relative;
  height: 220px;
  background: var(--bg-elev-1);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.4);
}
.wheel .wheel-track {
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.wheel .wheel-track::-webkit-scrollbar { display: none; }
.wheel .wheel-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-dim);
  scroll-snap-align: center;
  font-variant-numeric: tabular-nums;
}
.wheel .wheel-item.current {
  color: var(--text);
  font-weight: 700;
  font-size: 24px;
}
.wheel .wheel-mask-top, .wheel .wheel-mask-bot {
  position: absolute; left: 0; right: 0; height: 88px;
  pointer-events: none;
  z-index: 2;
}
.wheel .wheel-mask-top {
  top: 0;
  background: linear-gradient(to bottom, var(--bg-elev-1), transparent);
}
.wheel .wheel-mask-bot {
  bottom: 0;
  background: linear-gradient(to top, var(--bg-elev-1), transparent);
}
.wheel .wheel-line {
  position: absolute;
  left: 8px; right: 8px;
  height: 44px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 1px solid var(--accent-dim);
  border-bottom: 1px solid var(--accent-dim);
  pointer-events: none;
}

/* ---------- big output ---------- */
.output-block {
  background: var(--bg-elev-1);
  border-radius: 14px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.output-huge {
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.output-huge .unit {
  font-size: 22px;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 6px;
}
.output-big {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.output-secondary {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.output-block .small {
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.info-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-style: italic;
  font-weight: 700;
  font-family: serif;
  font-size: 18px;
  margin-left: 8px;
}

/* ---------- buttons ---------- */
.btn {
  height: var(--tap-min);
  padding: 0 18px;
  border-radius: 12px;
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line);
}
.btn:active { background: var(--bg-elev-3); }
.btn.primary {
  height: var(--tap-primary);
  background: var(--accent);
  color: #1f1c19;
  border: none;
  font-size: 19px;
}
.btn.primary:active { background: #b88a30; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; }

/* ---------- list ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  min-height: var(--tap-min);
  padding: 12px 14px;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font: inherit;
}
.list-item:first-child { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.list-item:last-child { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; border-bottom: none; }
.list-item:active { background: var(--bg-elev-2); }
.list-item .chev { color: var(--text-faint); font-size: 22px; margin-left: auto; }

/* ---------- modal / overlay ----------
 * Sized via dynamic viewport units (100dvh / 100dvw), NOT inset:0.
 *
 * v1.3.3 added safe-area padding here to fix what looked like a static
 * one-row hit-test offset. That fix held only for the first few taps,
 * then the offset re-appeared mid-session. The intermittent drift
 * pointed to iOS Safari's URL-bar collapse/expand transitions: with
 * inset:0, the overlay's bottom is anchored to the *static* layout
 * viewport, which doesn't change as the URL bar shows/hides. Hit-
 * testing follows the *visible* viewport, which does. Once layout-space
 * and hit-test-space diverged by ~URL-bar height (~60px — basically one
 * numpad row), every tap inside the modal mapped to the button one row
 * above its visual position, Cancel/Done stopped closing the popup, and
 * the user had to force-quit the app.
 *
 * Fix: explicit position:fixed; top:0; left:0; sized by 100dvh /
 * 100dvw. The dynamic viewport units track the *visible* viewport at
 * every moment, so layout and hit-test stay in sync across URL-bar
 * transitions, status-bar style changes, and any other dynamic-chrome
 * shifts. The 100vh / 100vw lines provide a safe fallback for browsers
 * predating dvh support (none we target, but cheap belt-and-braces).
 *
 * Safe-area padding from v1.3.3 stays — still needed to keep the modal
 * out from behind the notch and home indicator. On Mac, env(...) = 0
 * and the dvh/dvw values match the document viewport, so behaviour is
 * unchanged there. */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding-top:    max(24px, env(safe-area-inset-top));
  padding-right:  max(24px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left:   max(24px, env(safe-area-inset-left));
  z-index: 100;
}
.overlay.active { display: flex; }
.overlay .modal {
  background: var(--bg-elev-1);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.overlay .modal h3 { margin: 0 0 8px; font-size: 20px; }
.overlay .modal p { margin: 0 0 14px; color: var(--text-dim); font-size: 15px; }
.overlay .modal .actions { display: flex; gap: 8px; }
.overlay .modal .actions .btn { flex: 1; touch-action: manipulation; }
/* About dialog body: each line is a block (same 14px rhythm as a paragraph),
   in the bright cream reading tone (matches Safebox's About body). */
.overlay .modal .about-line { display: block; margin: 0 0 14px; color: var(--text); }
/* Web address — clickable, underlined, in the bronze sub-label tone (matches
   Safebox). Colour set explicitly so it is bronze + underline, never the
   default browser blue (the Settings blue-link fix; do not let it regress). */
.overlay .modal a.about-url {
  display: block;
  color: var(--text-dim);
  text-decoration: underline;
  font-weight: 400;
}
/* About: the Gumroad link + a Share button on one row. The link stays the quiet
   bronze underlined address; Share sits beside it (wraps below on a narrow
   width). Mirrors the line reference's .about-share-row. */
.overlay .modal .about-share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.overlay .modal .about-share {
  width: auto;
  height: auto;
  min-height: 44px;
  padding: 8px 18px;
}

/* Tiny toast — the "Link copied" confirmation for Share's clipboard fallback
   (when the device has no share sheet). Mirrors the line reference's toast. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: var(--bg-elev-3);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  transition: opacity .2s;
  z-index: 950;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; }

/* ---------- Speeds & Feeds bottom-of-card actions (formula + chip-load picker) ---------- */
/* Two buttons clustered centered with 8px gap on Mill; when chip-load button hides
   (Drill/Turn), the formula button remains centered alone. width: 100% is required
   because the parent .output-block is a column-flex with align-items: center, which
   would otherwise shrink this container to single-button width and force the second
   button to wrap onto a new line. */
.sf-actions { display: flex; justify-content: center; gap: 8px; margin-top: 8px; width: 100%; }

/* ---------- Rough/Finish IPR toggle (Speeds & Feeds, Turn only) ---------- */
/* Single button whose label shows "Rough / Finish"; the active state is bold amber,
   the inactive state dim. Tapping the button swaps which one is active. Lives in
   .sf-actions next to the formula button on Turn, same placement pattern as the
   Mill chip-load picker. */
.rf-toggle .rf-state { color: var(--text-dim); font-weight: 500; }
.rf-toggle .rf-state.active { color: var(--accent); font-weight: 700; }
.rf-toggle .rf-sep { color: var(--text-faint); }

/* ---------- Chip-load picker modal (Speeds & Feeds, Mill only) ---------- */
.chip-picker-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.chip-picker-option {
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--text); text-align: left; font-size: 16px;
  touch-action: manipulation;
}
.chip-picker-option:active { background: var(--bg-elev-3); }
.chip-picker-option.active { border-color: var(--accent); background: rgba(212, 96, 48, 0.15); }
.chip-picker-option .name { font-weight: 600; }
.chip-picker-option .desc { display: block; font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ---------- numpad keypad (for typed numeric input) ---------- */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.numpad button {
  height: 60px;
  background: var(--bg-elev-2);
  border-radius: 12px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  /* Explicit reinforcement so even if a future change to the global
   * touch-action gets overridden somewhere, the numpad keys stay
   * gesture-free. touch-action is not inherited, so each interactive
   * element has to declare it. */
  touch-action: manipulation;
}
.numpad button.action { color: var(--accent); }
.numpad button:active { background: var(--bg-elev-3); }

/* ---------- calculator ---------- */
.calc-display {
  background: var(--bg-elev-1);
  border-radius: 14px;
  padding: 18px 16px;
  min-height: 90px;
  display: flex; align-items: flex-end; justify-content: flex-end;
  font-size: 44px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  text-align: right;
  border: 1px solid var(--line);
  overflow-x: auto;
}
.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.calc-grid button {
  height: 64px;
  background: var(--bg-elev-2);
  border-radius: 12px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.calc-grid button.op { color: var(--accent); }
.calc-grid button.eq { background: var(--accent); color: #1f1c19; }
.calc-grid button.util { color: var(--text-dim); font-size: 18px; }
.calc-grid button:active { background: var(--bg-elev-3); }
.calc-grid button.eq:active { background: #b88a30; }

/* ---------- triangle / trig ---------- */
.trig-diagram {
  background: var(--bg-elev-1);
  border-radius: 14px;
  padding: 14px;
  height: 220px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
}
.trig-diagram svg { width: 100%; height: 100%; }
.trig-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.trig-cell {
  background: var(--bg-elev-1);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
}
.trig-cell .var {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #1f1c19;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-style: italic;
  font-family: serif;
  font-size: 16px;
}
.trig-cell input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 0;
  width: 100%;
  font-weight: 600;
}
.trig-cell input:focus { outline: none; }
.trig-cell .clear {
  width: 28px; height: 28px;
  color: var(--text-faint);
  font-size: 18px;
}

.trig-error {
  min-height: 72px;
  box-sizing: border-box;
  background: var(--bg-elev-1);
  border-radius: 10px;
  padding: 14px;
  color: var(--danger);
  font-size: 15px;
  text-align: center;
  border: 1px solid var(--danger);
}
.trig-error:empty {
  background: transparent;
  border-color: transparent;
}

.trig-second {
  margin-top: 6px;
  font-size: 13px;
  color: var(--accent);
  text-align: center;
}

/* ---------- bolt circle list ---------- */
.bc-holes {
  background: var(--bg-elev-1);
  border-radius: 12px;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 15px;
  border: 1px solid var(--line);
}
.bc-hole-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  padding: 6px 8px;
  gap: 4px;
}
.bc-hole-row .hn { color: var(--accent); font-weight: 700; }
.bc-hole-row + .bc-hole-row { border-top: 1px solid var(--line); }
.bc-diagram {
  background: var(--bg-elev-1);
  border-radius: 12px;
  padding: 10px;
  height: 220px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
}
.bc-diagram svg { width: 100%; height: 100%; }

/* ---------- material card ---------- */
.mat-card {
  background: var(--bg-elev-1);
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.mat-card .mat-head {
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 600;
  display: flex; align-items: center;
}
.mat-card.expanded .mat-head { border-bottom: 1px solid var(--line); background: var(--bg-elev-2); }
.mat-card .mat-head .chev {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 22px;
  transition: transform 0.2s;
}
.mat-card.expanded .mat-head .chev { transform: rotate(90deg); }
.mat-card .mat-body {
  display: none;
  padding: 12px 16px 16px;
  font-size: 15px;
  line-height: 1.45;
}
.mat-card.expanded .mat-body { display: block; }
.mat-card .mat-row { display: flex; padding: 4px 0; gap: 10px; }
.mat-card .mat-row .k { color: var(--text-dim); min-width: 140px; }
.mat-card .mat-row .v { color: var(--text); font-variant-numeric: tabular-nums; }
.mat-card .mat-row.note { display: block; color: var(--text-dim); padding-top: 8px; }

/* ---------- onboarding ---------- */
.onboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
  align-items: center;
  text-align: center;
  gap: 18px;
  overflow-y: auto;
}
.onboard h1 {
  font-size: 32px;
  margin: 12px 0 4px;
  font-weight: 700;
  color: var(--accent);
}
.onboard p { font-size: 18px; color: var(--text); max-width: 360px; }
.onboard .spacer { flex: 1; }
/* v1.6.9: universal text-only install walkthrough. Numbered step list, no
   screenshots or tile cards. */
.onboard ol.walk-steps {
  width: 100%;
  max-width: 360px;
  margin: 0;
  padding: 0 0 0 24px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.onboard ol.walk-steps li {
  font-size: 16px;
  color: var(--text);
  line-height: 1.5;
}
/* iOS Safari share glyph, inline in install step 1. Inherits the accent via
   currentColor. (Only the first-run renderer injects it; the Settings
   Install-help dialog reuses the same wording without the glyph.) */
.ios-share-icon {
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.28em;
  margin: 0 .15em;
  color: var(--accent);
}

/* Bottom action group on the iOS install steps + the "Open in Safari first"
   screen — stacked full-width buttons (Done/Back, and continue+Back). */
.onboard .walk-actions {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

/* The "I'm already in Safari — continue" escape — an underlined accent link. */
.onboard .walk-link {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: underline;
  padding: 12px;
  cursor: pointer;
}

/* Glowing nut-orb on the welcome / first-launch screens. The orb's own charcoal
   tile matches --bg, so it sits seamlessly on the onboarding background — same
   treatment as the launch splash and the app icon. */
.onboard .welcome-orb {
  display: block;
  width: 128px; height: 128px;
}

/* ---------- launch splash ----------
   Full-screen overlay on the app background with the centred nut-orb mark (same
   artwork as the app icon). The orb beats once like a heartbeat, then the
   overlay fades out and hides. Driven by CSS so it can never gate the app:
   animation-fill-mode leaves it opacity:0 + visibility:hidden at the end (which
   also stops it receiving taps) even if no script runs; app.js removes the node
   as cleanup. Decorative only — nothing functional depends on it. */
#splash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  /* Hold ~1.1s, then fade out over 0.45s and stay hidden (forwards). */
  animation: splash-fade 0.45s ease 1.1s forwards;
}
.splash__orb {
  width: 240px; height: 240px;
  max-width: 70vmin; max-height: 70vmin;
  transform-origin: center;
  /* One heartbeat (lub-dub) over ~1s. */
  animation: splash-heartbeat 1s ease-in-out 0.15s 1 both;
}
@keyframes splash-fade {
  to { opacity: 0; visibility: hidden; }
}
@keyframes splash-heartbeat {
  0%   { transform: scale(1); }
  12%  { transform: scale(1.09); }
  24%  { transform: scale(1); }
  36%  { transform: scale(1.05); }
  60%  { transform: scale(1); }
  100% { transform: scale(1); }
}
/* Respect reduced motion: skip the heartbeat pulse. The overlay still appears
   briefly and fades. */
@media (prefers-reduced-motion: reduce) {
  .splash__orb { animation: none; }
}

/* ---------- settings ---------- */
.settings-section { margin-bottom: 20px; }
.settings-section .label { padding: 4px 6px 8px; }

/* ---------- surface finish ---------- */
.sf-equiv {
  background: var(--bg-elev-1);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--line);
}
.sf-equiv .row {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.sf-equiv .row:last-child { border-bottom: none; }
.sf-equiv .row .k { color: var(--text-dim); flex: 1; }
.sf-equiv .row .v { font-size: 22px; font-weight: 600; color: var(--text); }
.sf-equiv .note { margin-top: 10px; font-size: 14px; color: var(--text-dim); line-height: 1.5; }
.sf-equiv .approx { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ---------- converter ---------- */
.conv-tabs {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.conv-tabs::-webkit-scrollbar { display: none; }
.conv-tabs button {
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--bg-elev-1);
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line);
}
.conv-tabs button.active {
  background: var(--accent);
  color: #1f1c19;
  border-color: var(--accent);
}
.conv-input {
  background: var(--bg-elev-2);
  border-radius: 12px;
  padding: 14px;
  display: flex; align-items: center; gap: 10px;
}
.conv-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  width: 100%;
}
.conv-input input:focus { outline: none; }
.conv-input .unit-tag {
  background: var(--accent);
  color: #1f1c19;
  border: 0;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}

/* v1.6.8: Dec ↔ Frac fraction-input wheel. Lives inside .conv-input next to
   the hidden <input> in fraction mode; takes the input's flex slot so the
   amber pill stays anchored to the right. */
.conv-input .conv-frac-wheel { flex: 1; height: 220px; min-width: 0; }
.conv-output {
  background: var(--bg-elev-1);
  border-radius: 12px;
  padding: 6px 14px;
  border: 1px solid var(--line);
}
.conv-output .row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.conv-output .row:last-child { border-bottom: none; }
.conv-output .row .k { color: var(--text-dim); flex: 1; }
.conv-output .row .v { font-size: 22px; font-weight: 600; color: var(--text); text-align: right; }

/* ---------- tap & drill ---------- */
.td-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elev-1);
  border-radius: 12px;
  padding: 4px;
}
.td-tabs button {
  flex: 1;
  height: 46px;
  border-radius: 9px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 16px;
}
.td-tabs button.active { background: var(--accent); color: #1f1c19; }

.td-output {
  background: var(--bg-elev-1);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--line);
}
.td-drill-big {
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.td-equivs {
  margin-top: 8px;
  font-size: 18px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.td-equivs .sep { color: var(--text-faint); margin: 0 8px; }
.td-meta {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-dim);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.td-meta .pair .k { color: var(--text-faint); margin-right: 6px; }

/* ---------- search overlay (tap & drill) ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  display: none;
  flex-direction: column;
  padding-top: var(--safe-top);
}
.search-overlay.active { display: flex; }
.search-overlay .search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--line);
}
.search-overlay .search-bar input {
  flex: 1;
  height: 48px;
  background: var(--bg-elev-2);
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  font-size: 18px;
}
.search-overlay .search-bar input:focus { outline: 1px solid var(--accent); }
.search-overlay .search-results { flex: 1; overflow-y: auto; padding: 8px; }
.search-overlay .search-result {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}

/* ---------- rotate prompt ----------
 * The installed PWA is locked to portrait via the manifest. In-browser mobile
 * Safari ignores the manifest, so the app can still be rotated. The Materials
 * and Surface Finish layouts break in landscape and the product is built for
 * one-handed shop use, so landscape isn't a supported mode. Show a "rotate to
 * portrait" overlay when the viewport is landscape AND short — short rules out
 * desktop landscape (and tablet landscape), so only phone-sized landscape
 * viewports trigger it. */
.rotate-prompt {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
.rotate-prompt .icon {
  font-size: 64px;
  color: var(--accent);
  margin-bottom: 18px;
  line-height: 1;
}
.rotate-prompt h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}
.rotate-prompt p {
  font-size: 17px;
  color: var(--text-dim);
  max-width: 340px;
  line-height: 1.45;
  margin: 0;
}
@media (orientation: landscape) and (max-height: 500px) {
  .rotate-prompt { display: flex; }
}

/* ---------- utility ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--text-dim); }
.flex-grow { flex: 1; }
