/* ShotSize — styled with the Little Cine Tools design system (dark-first, anodized neutrals, Signal Blue).
   Tokens copied from the LCT design system (tokens/colors.css, typography.css, spacing.css, effects.css). */
:root {
  /* Anodized neutrals */
  --ink-1000: #0A0A0B; --ink-950: #111113; --ink-900: #18181B; --ink-850: #1F1F23; --ink-800: #2A2A2F; --ink-700: #3A3A40;
  --ink-600: #55555C; --ink-500: #7A7A82; --ink-400: #A1A1A8; --ink-300: #C6C6CB; --ink-200: #E2E2E5; --ink-100: #F1F1F2; --ink-50: #F8F8F8; --white: #FFFFFF;
  /* Signal Blue */
  --blue-300: #9AD3F7; --blue-400: #5BB6F0; --blue-500: #2E9BE6; --blue-600: #1F7FC4; --blue-900: #0B2A44;
  /* Semantic */
  --green-500: #3FBF7F; --amber-500: #F28A2E; --red-500: #E5484D;
  /* Machine Yellow: frame lines and the selected mode */
  --yellow-500: #FFC91F;
  --panel: rgba(17,17,19,.85); --panel-2: rgba(24,24,27,.85);

  --surface-page: var(--ink-1000); --surface-section: var(--ink-950); --surface-card: var(--ink-900); --surface-raised: var(--ink-850);
  --text-strong: var(--white); --text-body: var(--ink-200); --text-muted: var(--ink-400); --text-subtle: var(--ink-500); --text-on-accent: var(--ink-1000);
  --border-subtle: var(--ink-850); --border-default: var(--ink-800); --border-strong: var(--ink-600); --border-focus: var(--blue-500);
  --accent: var(--blue-500); --accent-hover: var(--blue-400); --accent-press: var(--blue-600); --accent-tint: var(--blue-900);
  --danger: var(--red-500); --warning: var(--amber-500);

  --font-sans: 'Barlow', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Big Shoulders Display', 'Barlow', ui-sans-serif, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --tracking-label: 0.08em; --tracking-button: 0.04em;

  --radius-1: 2px; --radius-2: 4px; --radius-3: 8px; --radius-full: 999px;
  --control-sm: 36px; --control-md: 44px; --control-lg: 52px;
  --shadow-2: 0 1px 0 rgba(255,255,255,.05) inset, 0 8px 24px rgba(0,0,0,.45);
  --shadow-3: 0 24px 64px rgba(0,0,0,.6);
  --edge-highlight: inset 0 1px 0 rgba(255,255,255,.06);
  --ring-focus: 0 0 0 2px var(--ink-1000), 0 0 0 4px var(--blue-500);
  --ease-out: cubic-bezier(.2,.7,.2,1); --dur-fast: 120ms; --dur-base: 200ms;
  --blur-header: saturate(140%) blur(14px);

  /* ShotSize-specific */
  --frame-line: var(--yellow-500); --pv-light: #d9dbde; --pv-dark: #55595e; --cmp: var(--ink-500);
  --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: #000; }
html, body { margin: 0; color: var(--text-body); overflow-x: hidden; }
body { background: transparent; min-height: 100dvh; }
body { font-family: var(--font-sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
body.modal-open { overflow: hidden; }
a { color: var(--blue-400); text-decoration: none; }
::selection { background: var(--blue-500); color: var(--ink-1000); }
button, input, select { font-family: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring-focus); }
svg { overflow: hidden; }
#app { position: relative; z-index: 1; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px calc(32px + var(--safe-b)); }
main.with-tabbar { padding-bottom: calc(96px + var(--safe-b)); }

/* ---------- Type helpers ---------- */
.muted { color: var(--text-muted); } .small { font-size: 13px; } .center { text-align: center; }
.mono { font-family: var(--font-mono); }
h2 { margin: 0 0 12px; font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
h2 small { font-size: 10px; color: var(--text-subtle); margin-left: 6px; }
h3 { margin: 18px 0 8px; font-size: 15px; font-weight: 600; color: var(--text-strong); }
.note { background: rgba(242,138,46,.12); color: var(--amber-500); padding: 8px 10px; border-radius: var(--radius-2); font-size: 13px; }
.badtxt { color: var(--danger); }
.hint, .tiny-note { color: var(--text-subtle); }
.tiny-note { font-size: 11px; margin: 6px 0 0; }

/* ---------- Cards / boxes (informational boxes: hairline, 4px radius) ---------- */
.card { background: var(--surface-section); border: 1px solid var(--border-subtle); border-radius: var(--radius-2); padding: 16px; margin: 12px 0; }

/* ---------- Forms (LCT Input / Select) ---------- */
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; margin-bottom: 6px; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.field small { display: block; margin-top: 6px; font-size: 12px; color: var(--text-subtle); }
input[type=text], select { width: 100%; height: var(--control-md); padding: 0 14px; font-size: 15px; color: var(--text-strong);
  background: var(--ink-950); border: 1px solid var(--border-strong); border-radius: var(--radius-2); outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
select { -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A1A1A8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
select option { background: var(--ink-900); }
input[type=text]::placeholder { color: var(--text-subtle); }
input[type=text]:focus, select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(46,155,230,.18); }
input.tiny { width: 76px; height: var(--control-sm); padding: 0 8px; font-family: var(--font-mono); font-size: 14px; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); white-space: nowrap; }
.check { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 15px; color: var(--text-body); cursor: pointer; }
.check input, .def-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; }
.add-row { margin: 12px 0; } .add-row input { flex: 1; }

/* ---------- Buttons (LCT Button: 4px radius, Barlow 700 uppercase) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-md); padding: 0 20px;
  font-weight: 700; font-size: 13px; letter-spacing: var(--tracking-button); text-transform: uppercase; white-space: nowrap; text-decoration: none; cursor: pointer;
  color: var(--text-strong); background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius-2);
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast), transform 60ms; }
.btn:hover { background: rgba(255,255,255,.06); border-color: var(--ink-400); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--text-on-accent); border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: var(--accent-press); }
.btn.danger { color: var(--danger); }
.btn.small { height: var(--control-sm); padding: 0 14px; font-size: 12px; }
.btn.block { display: flex; width: 100%; margin: 8px 0; }
.link { background: none; border: 0; color: var(--blue-400); padding: 4px; cursor: pointer; font-family: var(--font-mono); font-size: 14px; }
.link.muted { color: var(--text-subtle); }
.del { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; background: none; border: 0; border-radius: var(--radius-2); color: var(--danger); cursor: pointer; }
.del .ic { width: 18px; height: 18px; }
.chip-del { display: inline-grid; place-items: center; margin-left: 6px; padding: 0 2px; background: none; border: 0; color: var(--danger); cursor: pointer; }
.chip-del .ic { width: 14px; height: 14px; }
.sec[id] { scroll-margin-top: 12px; }
.dist-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.dist-conv { font-family: var(--font-display); font-weight: 900; font-size: 44px; line-height: .9; color: var(--ink-500); white-space: nowrap; }
.dist-conv small { font-size: 20px; }
.chip-row.view-switches { grid-template-columns: auto auto; justify-content: start; gap: 8px; margin-top: 10px; }
.x { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: none; border: 0; border-radius: var(--radius-2); color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; }
.x:hover { background: rgba(255,255,255,.08); color: var(--text-strong); }
.icon-sm { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: var(--radius-2); border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-strong); font-size: 11px; cursor: pointer; }
.icon-sm:disabled { opacity: .3; cursor: default; }

/* ---------- Segmented control + chips (LCT Tag: selected = white) ---------- */
.seg { display: flex; gap: 2px; padding: 2px; margin: 0 0 12px; border: 1px solid var(--border-default); border-radius: var(--radius-2); }
.seg button { flex: 1; min-height: 38px; padding: 0 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); background: none; border: 0; border-radius: var(--radius-1); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast); }
.seg button:hover { color: var(--text-strong); }
.seg button.on { background: var(--ink-50); color: var(--ink-1000); }
.seg.compact { margin: 0; }
.seg.compact button { min-height: 32px; font-size: 12px; }
.seg-lbl { flex: none; font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 44px; min-height: 32px; padding: 4px 12px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-body); background: transparent;
  border: 1px solid var(--border-default); border-radius: var(--radius-1); cursor: pointer; transition: background var(--dur-fast); }
.chip:hover { background: var(--ink-850); }
.chip.on { background: var(--ink-50); color: var(--ink-1000); border-color: var(--ink-50); }
.chip small { display: block; font-size: 9px; line-height: 1.1; opacity: .7; }
.chip-x { margin-left: 6px; padding: 0 2px; background: none; border: 0; color: inherit; font-size: 15px; cursor: pointer; }
span.chip { flex-direction: row; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--radius-full); background: var(--ink-800); color: var(--text-strong);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; }

/* ---------- Data readouts ---------- */
.readout { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--text-strong); }
.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-2); background: var(--ink-1000); }
.result span { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.result strong { font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--text-strong); }
.result small { font-size: 11px; color: var(--text-muted); }
.result + .result { margin-top: 8px; }
.result.compact { grid-template-columns: repeat(3, minmax(0, auto)); justify-content: space-between; gap: 4px 8px; padding: 8px 10px; }
.result.compact > div { min-width: 0; }
.result.compact span { font-size: 9px; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result.compact strong { display: block; font-size: 11px; white-space: nowrap; }

/* ---------- Lists, rows, tables ---------- */
table { border-collapse: collapse; width: 100%; }
.mini { margin: 8px 0; font-size: 14px; }
.mini th { text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.mini td, .mini th { padding: 4px; border-bottom: 1px solid var(--border-subtle); }
.mini td b { color: var(--text-strong); font-family: var(--font-mono); font-weight: 500; }
tr.grp td { padding: 12px 10px 6px; text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); background: var(--surface-section); }
.mini tr.grp td { padding: 12px 4px 4px; }
.cast-row, .lib-row, .fmt-row { border-bottom: 1px solid var(--border-subtle); }
.cast-row { padding: 10px 0; }
.cast-row > input { margin-bottom: 8px; }
.cast-row select { flex: 1; min-width: 0; }
.cast-row > select { width: 100%; margin-top: 8px; }
.lib-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; font-size: 14px; }
.lib-row b { color: var(--text-strong); font-weight: 600; }
.lib-row small { font-family: var(--font-mono); font-size: 11px; }


/* ---------- Sheets / dialogs (LCT Dialog) ---------- */
.modal { position: fixed; inset: 0; z-index: 20; height: 100dvh; background: rgba(10,10,11,.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal.sheet { display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 0 16px calc(16px + var(--safe-b));
  background: var(--surface-raised); border: 1px solid var(--border-default); border-bottom: 0; border-radius: var(--radius-3) var(--radius-3) 0 0; box-shadow: var(--shadow-3), var(--edge-highlight); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -16px 12px; padding: 14px 8px 14px 16px;
  background: var(--surface-raised); border-bottom: 1px solid var(--border-default); }
.sheet-head h2, .sheet-body > h2 { margin: 0; font-family: var(--font-sans); font-size: 18px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--text-strong); }
.pick-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pick { padding: 12px 14px; text-align: left; color: var(--text-body); background: transparent; border: 1px solid var(--border-default); border-radius: var(--radius-2); cursor: pointer;
  transition: background var(--dur-fast); }
.pick:hover { background: rgba(255,255,255,.04); }
.pick.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pick b, .pick small { display: block; } .pick b { color: var(--text-strong); font-weight: 600; } .pick small { font-family: var(--font-mono); font-size: 11px; }
.lens-grid, .aspect-grid { display: grid; gap: 8px; margin-bottom: 4px; }
.lens-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
.aspect-grid { grid-template-columns: repeat(4, 1fr); }
.aspect-grid .wide { grid-column: 1 / -1; }
.pick-lens { padding: 12px 4px; font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--text-strong); background: transparent;
  border: 1px solid var(--border-default); border-radius: var(--radius-2); cursor: pointer; transition: background var(--dur-fast); }
.aspect-grid .pick-lens { font-size: 14px; }
.pick-lens:hover { background: var(--ink-800); }
.pick-lens small { display: block; font-size: 10px; color: var(--text-muted); }
.pick-lens.on { background: var(--ink-50); color: var(--ink-1000); border-color: var(--ink-50); }
.pick-lens.on small { color: var(--ink-600); }

/* ---------- Toast (LCT Toast) ---------- */
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); z-index: 50; max-width: calc(100% - 32px); padding: 12px 16px;
  font-size: 14px; font-weight: 600; color: var(--text-strong); background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: var(--radius-3);
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px); transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- Full-screen preview ---------- */
.modal.preview { display: flex; flex-direction: column; overflow-y: auto; padding: calc(8px + var(--safe-t)) 0 calc(8px + var(--safe-b)); background: #000; -webkit-backdrop-filter: none; backdrop-filter: none; }
.pv-frame { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
.pv-stage { position: relative; width: 100%; }
.pv-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pv-stage svg { position: relative; }
.pv-frame svg { display: block; width: 100%; max-height: 62vh; }
.pv-info { padding: 12px 16px; font-size: 14px; line-height: 1.7; color: var(--text-body); }
.pv-info b { font-family: var(--font-mono); font-weight: 500; color: var(--text-strong); }
.pv-dist { font-size: 18px; } .pv-dist b { color: var(--blue-400); }
.pv-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px; }
.pv-nav .primary { grid-column: 1 / -1; }
.pv-compact, .pv-close { display: none; }
.pv-fmt { color: rgba(255,255,255,.7); }
.pv-recenter { position: absolute; right: 8px; top: calc(8px + var(--safe-t)); z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-2);
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer; }
.pv-recenter .ic { width: 20px; height: 20px; }

@media (orientation: landscape) and (max-height: 500px) {
  .modal.preview { flex-direction: row; padding: 0; }
  .modal.preview .pv-frame { flex: 1 1 auto; height: 100%; min-height: 0; padding: 0; }
  .modal.preview .pv-frame .pv-stage, .modal.preview .pv-frame svg { width: 100%; height: 100%; max-height: 100%; }
  .modal.preview .pv-info, .modal.preview .pv-nav { display: none !important; }
  .modal.preview .pv-compact { position: fixed; left: calc(16px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 60%; display: block; padding: 8px 12px; border-radius: var(--radius-2); background: rgba(10,10,11,.6);
    font-family: var(--font-mono); font-size: 11px; line-height: 1.4; color: #fff; pointer-events: none; }
  .modal.preview .pv-compact b { color: var(--blue-400); font-weight: 500; }
  .modal.preview .pv-close { position: absolute; right: calc(14px + env(safe-area-inset-right)); top: 14px; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-2);
    background: rgba(10,10,11,.6); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
  .modal.preview .pv-recenter { top: 14px; right: calc(58px + env(safe-area-inset-right)); background: rgba(10,10,11,.6); }
}

/* ---------- Settings: shot size rows ---------- */
.framing-row { display: grid; grid-template-columns: 30px 70px minmax(0,1fr) 36px; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.framing-row .def-check { grid-column: 1; }
.framing-row .fr-abbr { grid-column: 2; width: 100%; font-family: var(--font-mono); }
.framing-row .fr-name { grid-column: 3; min-width: 0; }
.framing-row .x, .framing-row .del { grid-column: 4; }
.framing-row .fr-vals { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.framing-row .fr-vals .inline { gap: 4px; font-size: 13px; }
.framing-row .inline input.tiny { width: 58px; }

/* ---------- Icons ---------- */
.ic { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Blueprint background (fixed, behind everything) ---------- */
.bp-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: radial-gradient(ellipse 140% 50% at 50% 100%, #06202F 0%, #03121C 38%, #01060A 64%, #000 80%); }
.bp-bg > div { position: absolute; inset: 0; -webkit-mask-image: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.55) 70%, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.55) 70%, #000 100%); }
.bp-bg > div::before { content: ''; position: absolute; left: 50%; bottom: -420px; width: 1300px; height: 1300px; margin-left: -650px;
  background-image: linear-gradient(rgba(110,170,215,.10) 1px, transparent 1px), linear-gradient(90deg, rgba(110,170,215,.10) 1px, transparent 1px);
  background-size: 84px 84px; transform: perspective(760px) rotateX(58deg) rotateZ(36deg); }

/* ---------- App header: name + Settings, then the Quick View / Projects switch ---------- */
.app-head { max-width: 720px; margin: 0 auto; padding: calc(6px + var(--safe-t)) 12px 0; }
.brand-row { display: flex; align-items: center; justify-content: space-between; height: 50px; }
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; text-decoration: none; }
.wordmark { font-family: var(--font-display); font-weight: 900; font-size: 30px; line-height: 1; text-transform: uppercase; color: var(--white); }
.by { font-family: var(--font-mono); font-size: 9px; line-height: 1; letter-spacing: .12em; text-transform: uppercase; color: #6A6A72; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius-2); background: none; color: var(--text-strong); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out); }
.icon-btn.boxed { background: var(--panel-2); }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.ctx-row { display: flex; gap: 8px; padding: 4px 0 8px; }
.ctx-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; height: 52px; padding: 0 12px; background: var(--surface-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-3); color: var(--white); text-align: left; cursor: pointer; }
.ctx-chip > .ic:first-child { width: 18px; height: 18px; color: var(--yellow-500); }
.ctx-chip > .ic:last-child { width: 16px; height: 16px; margin-left: auto; color: var(--text-muted); }
.ctx-txt { display: flex; flex-direction: column; min-width: 0; }
.ctx-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.05; text-transform: uppercase; color: var(--yellow-500); }
.ctx-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.ctx-setup { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; flex: none; width: 60px; height: 52px; background: var(--surface-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-3); color: var(--ink-300); text-decoration: none; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; }
.ctx-setup .ic { width: 20px; height: 20px; }
.setup-row { margin: 0 0 12px; }

/* Home: every tool in one grid; the pin puts it in the bottom bar */
.home-main { padding-top: 10px; }
.tools-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 4px 10px; }
.tools-head .sec-lbl { margin: 0; }
.tools-head small { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tool-tile { position: relative; min-height: 128px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-3); }
.tool-open, .tool-tile.soon { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; height: 100%; min-height: 128px; padding: 14px; color: var(--white); text-decoration: none; }
.tool-tile > .ic, .tool-open > .ic { width: 28px; height: 28px; }
.tool-txt { display: flex; flex-direction: column; gap: 4px; }
.tool-txt b { font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1; text-transform: uppercase; }
.tool-txt small { font-family: var(--font-mono); font-size: 11px; line-height: 1.3; color: var(--text-muted); }
.tool-tile.soon { background: none; border-style: dashed; border-color: var(--ink-700); color: var(--ink-500); }
.tool-tile.soon .tool-txt small { color: var(--ink-500); }
.tool-pin { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; background: none; border: 0; color: var(--ink-600); cursor: pointer; }
.tool-pin .ic { width: 18px; height: 18px; }
.tool-pin.on { color: var(--accent); }
.tool-pin.on .pin-head { fill: currentColor; }

/* Detail screens (format, settings): back button + title */
.detail-head { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 6px; }
.detail-head .icon-btn { width: 48px; height: 48px; }
.h1-txt { display: flex; flex-direction: column; gap: 4px; }
.h1-txt small { font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--text-muted); }
.detail-head h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1; text-transform: uppercase; color: var(--white); }

/* ---------- Bottom bar: Home + pinned tools ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 calc((100% - 720px) / 2) var(--safe-b);
  background: rgba(0,0,0,.88); -webkit-backdrop-filter: var(--blur-header); backdrop-filter: var(--blur-header); border-top: 1px solid var(--ink-850); }
@media (max-width: 720px) { .tabbar { padding-left: 0; padding-right: 0; } }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 58px; color: var(--ink-500); text-decoration: none;
  font-weight: 700; font-size: 11px; letter-spacing: var(--tracking-button); text-transform: uppercase; transition: color var(--dur-fast) var(--ease-out); }
.tabbar a .ic { width: 22px; height: 22px; }
.tabbar a.on { color: var(--yellow-500); box-shadow: inset 0 2px 0 var(--yellow-500); }

/* ---------- Shared bits ---------- */
.sec { margin: 0 0 18px; }
.sec-lbl { display: block; margin: 0 0 6px; font-family: var(--font-mono); font-size: 11px; font-weight: 400; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.sec-lbl.blue { color: var(--blue-400); }
.tile { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--radius-2); background: var(--ink-700);
  font-family: var(--font-display); font-weight: 900; font-size: 22px; line-height: 1; color: var(--white); }
.tile.on { background: var(--accent); color: var(--ink-1000); }
.tile .ic { width: 20px; height: 20px; }
.detail-head .tile { width: 32px; height: 32px; font-size: 22px; border-radius: var(--radius-1); }
.row-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.row-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; color: var(--white); }
.row-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.cam-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 20px; align-items: center; gap: 12px; width: 100%; min-height: 60px; margin: 0 0 6px; padding: 0 12px 0 0;
  background: var(--panel); border: 0; border-radius: var(--radius-2); color: var(--white); cursor: pointer; text-align: left; overflow: hidden; }
.cam-row .tile { width: 52px; height: 60px; border-radius: var(--radius-2) 0 0 var(--radius-2); font-size: 32px; }
.cam-row > .ic { color: var(--ink-500); }
.cam-row.slim { min-height: 44px; grid-template-columns: 44px minmax(0, 1fr) 20px; }
.cam-row.slim .tile { width: 44px; height: 44px; font-size: 24px; }
.cam-row.slim .row-txt b { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.set-pick { display: grid; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; width: 100%; min-height: 56px; margin: 0 0 6px; padding: 6px 14px;
  background: rgba(17,17,19,.9); border: 1px solid var(--accent); border-radius: var(--radius-2); color: var(--white); text-align: left; cursor: pointer; }
.set-pick > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-pick .sec-lbl { margin: 0; }
.set-pick b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 600; }
.set-pick small { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.set-pick > .ic, .cast-btn > .ic, .pill .ic, .hud-fmt .ic { width: 16px; height: 16px; color: var(--text-muted); }
.btn .ic { width: 18px; height: 18px; }
.btn.lg { height: var(--control-lg); font-size: 14px; }
.btn.dashed { border-style: dashed; border-color: var(--ink-600); }
.save-callout { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 16px 0 0; padding: 10px 12px; border: 1px dashed var(--ink-600); border-radius: var(--radius-2); }
.save-callout span { font-size: 13px; color: var(--text-muted); }
.save-callout .btn { padding: 0 14px; font-size: 12px; }
.tiny-note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-subtle); }
.warn-txt { color: var(--warning); }

/* ---------- View ---------- */
main.tab-fov { padding-top: 0; }
.pv-sticky { position: sticky; top: 0; z-index: 4; margin: 0 -16px; background: #000; box-shadow: 0 24px 64px rgba(0,0,0,.7); }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 0 12px; font-family: var(--font-mono); }
.hud-top { height: 36px; }
.hud-bot { height: 28px; padding-right: 12px; font-size: 11px; color: var(--white); }
.hud-bot .muted { text-align: right; }
.hud-fmt, .hud-calc { display: flex; align-items: center; gap: 6px; min-width: 0; height: 36px; padding: 0; background: none; border: 0; cursor: pointer; font-family: var(--font-mono); text-transform: uppercase; }
.hud-fmt { color: var(--white); font-size: 12px; }
.hud-fmt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-calc { flex: none; padding: 0 4px; color: var(--text-muted); font-size: 11px; letter-spacing: .04em; }
.hud-calc .ic { width: 12px; height: 12px; }
.pv-box { position: relative; display: block; width: 100%; padding: 0; border: 0; overflow: hidden; background: #000; cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none; }
.pv-box:active { cursor: grabbing; }
.pv-box svg { display: block; width: 100%; max-height: 42vh; }
.pv-box.empty { padding: 40px 16px; text-align: center; color: var(--text-muted); cursor: default; }
.pv-btn { position: absolute; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-2);
  background: rgba(0,0,0,.5); color: #fff; cursor: pointer; }
.pv-btn .ic { width: 18px; height: 18px; }
.pv-expand { right: 8px; bottom: 8px; }
.pv-reset { right: 54px; bottom: 8px; }

.dist-big { display: flex; flex-direction: column; width: 100%; padding: 12px 0 0; background: none; border: 0; text-align: left; color: var(--white); cursor: pointer; }
.dist-big .sec-lbl { display: flex; justify-content: space-between; gap: 8px; margin: 0; }
.dist-big em { display: inline-flex; align-items: center; gap: 4px; font-style: normal; color: var(--warning); }
.dist-big em .ic { width: 13px; height: 13px; }
.dist-val { font-family: var(--font-display); font-weight: 900; font-size: 76px; line-height: .9; letter-spacing: .005em; }
.dist-val small { font-size: 28px; color: var(--ink-500); }
.dist-big.under .dist-val { color: var(--warning); }

.ruler-live { margin: 8px 0 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: ew-resize; }
.ruler { position: relative; height: 52px; overflow: hidden; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default);
  background-image: linear-gradient(90deg, var(--ink-700) 1px, transparent 1px); background-size: 9px 10px; background-repeat: repeat-x; }
.ruler-mod { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(242,138,46,.55) 0 2px, transparent 2px 7px); }
.ruler-mod-lbl { position: absolute; top: 2px; padding: 0 3px; background: #000; font-family: var(--font-mono); font-size: 11px; line-height: 14px; color: var(--warning); }
.tick { position: absolute; top: 0; width: 1px; height: 20px; background: var(--ink-400); }
.tick-lbl { position: absolute; top: 24px; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; color: var(--ink-400); white-space: nowrap; }
.ruler-now { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--accent); }

.stepper { display: grid; grid-template-columns: 60px minmax(0, 1fr) 60px; gap: 6px; margin: 10px 0 0; }
.step-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 68px; padding: 0; background: var(--panel-2); border: 0; border-radius: var(--radius-2);
  color: var(--white); cursor: pointer; }
.step-btn .ic { width: 22px; height: 22px; }
.step-btn small { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.step-btn:disabled { opacity: .3; cursor: default; }
.step-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; height: 68px; padding: 0 8px; background: var(--panel);
  border: 1px solid var(--border-default); border-radius: var(--radius-2); color: var(--white); cursor: pointer; }
.zmid { position: relative; overflow: hidden; height: 76px; justify-content: flex-end; padding-bottom: 8px; touch-action: pan-y; cursor: ew-resize; }
.zmid .zruler { position: absolute; left: 0; right: 0; top: 0; border: 0; pointer-events: none; } /* the distance ruler's look, no lines */
.zmid .big, .zmid .sub { position: relative; z-index: 1; } /* the number always sits in front of the tape */
.zout { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(160,160,170,.35) 0 2px, transparent 2px 7px); }
.zoom-step .step-btn { height: 76px; }
.zoom-marks { margin: 4px 0 6px; }
.zoom-marks .sec-lbl { display: block; margin: 6px 0 4px; }
.chip small { margin-left: 4px; font-size: 10px; color: var(--text-muted); }
.step-mid .big { font-family: var(--font-display); font-weight: 900; font-size: 44px; line-height: .9; }
.step-mid .big small { font-size: 20px; color: var(--ink-500); }
.step-mid .sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
/* ---------- Depth of field ---------- */
.dof-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 2px; }
.tool-title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1; letter-spacing: 0; text-transform: uppercase; color: var(--white); }
.seg.dof-seg { flex: none; margin: 0; }
.dof-seg button { padding: 0 10px; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
.dof-read { display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; align-items: end; gap: 4px; margin: 8px 0; }
.dof-side { display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; }
.dof-side.r { align-items: flex-end; }
.dof-side .sec-lbl { margin: 0; color: var(--text-subtle); }
.dof-side b { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1; color: var(--ink-400); white-space: nowrap; }
.dof-focus { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 4px 0 0; background: none; border: 0; color: var(--white); cursor: pointer; }
.dof-focus .sec-lbl { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.dof-focus .sec-lbl .ic { width: 13px; height: 13px; }
.dof-focus .dist-val { font-size: 64px; white-space: nowrap; }
.dof-focus.under .dist-val, .dof-focus.under .sec-lbl { color: var(--warning); }
.dof-conv { font-family: var(--font-mono); font-size: 12px; color: var(--ink-500); }
.focus-live, .stop-ring-live { touch-action: none; user-select: none; -webkit-user-select: none; cursor: ew-resize; }
/* the turning scale under a fixed index ring, divided by a thin line */
.ring { position: relative; height: 70px; overflow: hidden; background: #141416; border-top: 1px solid var(--ink-700); border-bottom: 1px solid var(--ink-700); border-radius: var(--radius-2); }
.ring::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9px; background: #222226; border-bottom: 1px solid var(--ink-500); }
.ring .tick { top: 10px; height: 12px; background: var(--ink-300); }
.ring .tick.minor { height: 6px; background: var(--ink-500); }
.ring .tick-lbl { top: 26px; font-size: 13px; font-weight: 600; color: var(--ink-200); }
.ring .ruler-mod { top: 10px; }
.ring .ruler-mod-lbl { top: 48px; background: #141416; }
.stop-ring { height: 50px; }
.ring-dof { position: absolute; top: 50px; height: 10px; box-sizing: border-box; background: rgba(46,155,230,.45); border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.ring-h { position: absolute; top: 46px; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--ink-400); }
.ring-now { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--yellow-500); }
.ring-idx { position: absolute; left: 50%; top: 0; margin-left: -7px; border: 7px solid transparent; border-top: 8px solid var(--yellow-500); border-bottom: 0; }
.ring-out { position: absolute; top: 10px; bottom: 0; background: repeating-linear-gradient(135deg, rgba(160,160,170,.25) 0 2px, transparent 2px 7px); }
.dof-depth { position: relative; height: 18px; margin: 4px 0 10px; }
.dof-depth span { position: absolute; top: 0; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--blue-300); white-space: nowrap; }
.stop-live { display: flex; justify-content: center; margin: 0 0 8px; }
.stop-mid { width: 180px; }
.dof-extra { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border-default); }
.btn.hyper { flex: none; padding: 0 12px; border-color: var(--accent); color: var(--blue-400); font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; }
.coc-btn { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; min-width: 0; min-height: 44px; padding: 0; background: none; border: 0;
  color: var(--blue-400); font-family: var(--font-mono); font-size: 12px; text-align: right; cursor: pointer; }
.coc-btn small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-subtle); }
/* Deep focus */
.deep-in { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.deep-box { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; background: var(--surface-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-2); color: var(--white); cursor: pointer; }
.deep-box .sec-lbl { margin: 0; }
.deep-box b { font-family: var(--font-display); font-weight: 800; font-size: 32px; line-height: 1; white-space: nowrap; }
.deep-focus { display: flex; align-items: baseline; justify-content: space-between; margin: 12px 0; padding: 12px 14px; border: 1px solid var(--yellow-500); border-radius: var(--radius-2); }
.deep-focus .sec-lbl { margin: 0; color: var(--yellow-500); }
.deep-focus b { font-family: var(--font-display); font-weight: 900; font-size: 44px; line-height: 1; color: var(--white); }
.deep-focus b small { font-size: 22px; color: var(--ink-400); }
.deep-head { display: flex; justify-content: space-between; }
.deep-list { display: flex; flex-direction: column; gap: 4px; }
.deep-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 12px; background: var(--surface-card);
  border: 0; border-radius: var(--radius-2); color: var(--white); text-align: left; cursor: pointer; }
.deep-row.cur { background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); }
.deep-row b, .deep-row .st { font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1; }
.deep-row b small { font-size: 14px; color: var(--ink-500); }
.deep-row > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.deep-row.out { color: var(--ink-500); cursor: default; }
.deep-row.out > small { color: var(--ink-500); }

.cast-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; margin: 8px 0 0; padding: 0 14px; background: var(--panel); border: 0; border-radius: var(--radius-2);
  color: var(--white); text-align: left; cursor: pointer; }
.sec .cast-btn { margin: 0; }
.cast-btn .sec-lbl { margin: 0; }
.cast-btn b { font-size: 15px; font-weight: 600; }
.cast-btn > .ic { margin-left: auto; }

/* Keypad */
.grab { display: block; width: 40px; height: 4px; margin: 8px auto 2px; border-radius: var(--radius-full); background: var(--ink-600); }
.sheet-body > .grab { position: sticky; top: 0; z-index: 2; }
.keypad { display: flex; flex-direction: column; gap: 10px; padding: 0 12px calc(20px + var(--safe-b)); }
.kp-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 0 4px; }
.kp-head .sec-lbl { margin: 0; }
.kp-val { font-family: var(--font-display); font-weight: 900; font-size: 64px; line-height: .9; color: var(--white); white-space: nowrap; }
.kp-val .ph { color: var(--ink-600); }
.kp-val small { font-size: 26px; color: var(--ink-500); }
.caret { display: inline-block; width: 3px; height: 50px; margin-left: 3px; background: var(--accent); vertical-align: -4px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.kp-head .seg { width: 108px; }
.kp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.kp-grid button { display: grid; place-items: center; height: 60px; padding: 0; background: var(--ink-800); border: 0; border-radius: var(--radius-2); color: var(--white);
  font-family: var(--font-mono); font-size: 24px; cursor: pointer; }
.kp-grid button:active { background: var(--ink-700); }
.kp-grid .ic { width: 24px; height: 24px; }
.kp-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.seg.mono button { font-family: var(--font-mono); }

/* Projects sheet */
.proj-list { display: flex; flex-direction: column; margin: 0 0 6px; }
.proj-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 20px; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 0; background: none; border: 0;
  border-bottom: 1px solid var(--border-default); color: inherit; text-decoration: none; text-align: left; cursor: pointer; }
.proj-row.on .tile { background: var(--accent); color: var(--ink-1000); }
.proj-row > .ic { color: var(--ink-500); }

/* ---------- Chart ---------- */
.chip-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto; gap: 6px; margin: 0 0 4px; }
.pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; flex: 1 1 auto; justify-content: space-between; align-items: center; gap: 6px; height: 44px; padding: 0 12px; background: var(--panel); border: 0; border-radius: var(--radius-2);
  color: var(--white); font-family: var(--font-sans); font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; font-weight: 600; color: var(--text-strong); background: none; border: 0; cursor: pointer; }
.switch span { position: relative; flex: none; width: 40px; height: 22px; border-radius: var(--radius-full); background: var(--ink-700); transition: background var(--dur-fast); }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); transition: left var(--dur-fast) var(--ease-out); }
.switch.on span { background: var(--accent); }
.switch.on span::after { left: 21px; }
.unit-input { display: flex; align-items: center; gap: 4px; min-height: var(--control-md); padding: 0 12px; background: var(--ink-1000); border: 1px solid var(--border-strong); border-radius: var(--radius-2); }
.unit-input:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(46,155,230,.18); }
.unit-input input[type=text] { height: auto; padding: 8px 0; border: 0; background: none; box-shadow: none; font-family: var(--font-mono); font-size: 18px; min-width: 0; }
.unit-input span { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.pill.switch { gap: 8px; padding: 0 10px; background: var(--panel); }
.pill.switch { justify-content: flex-start; flex-grow: 0; }
.pill.switch span { width: 30px; height: 18px; }
.pill.switch span::after { top: 3px; left: 3px; width: 12px; height: 12px; }
.pill.switch.on span::after { left: 15px; }
.chart-meta { display: flex; justify-content: space-between; gap: 8px; padding: 10px 2px 0; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
.chart-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 4px 0 0; }
table.dist { border-collapse: separate; border-spacing: 0 4px; }
.dist thead th { padding: 4px 2px 0; font-family: var(--font-mono); font-size: 11px; font-weight: 400; letter-spacing: .06em; color: var(--text-muted); text-align: center; }
.dist thead th:first-child { text-align: left; padding-left: 10px; }
.dist thead th small { display: block; font-size: 10px; color: var(--ink-500); }
.dist td, .dist tbody th { padding: 0; background: var(--panel); text-align: center; }
.dist tbody th { width: 64px; border-radius: var(--radius-2) 0 0 var(--radius-2); text-align: left; }
.dist tbody tr > td:last-child { border-radius: 0 var(--radius-2) var(--radius-2) 0; }
.dist tr.cur > * { background: var(--blue-900); }
.dist tr.cur th { box-shadow: inset 3px 0 0 var(--accent); }
.dist tr.cur .lens-btn b { color: var(--blue-300); }
.set-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 8px; font-size: 12px; color: var(--text-muted); }
.set-legend b, .set-tag { font-family: var(--font-mono); font-style: normal; font-weight: 600; color: var(--text-strong); }
.set-tag { margin-left: 3px; font-size: 11px; vertical-align: top; color: var(--text-muted); }
.dist tr.grp td { padding: 10px 2px 0; background: none; text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.dist button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 100%; min-height: 46px; padding: 4px 2px; background: none; border: 0;
  color: var(--white); cursor: pointer; }
.dist button:hover { background: rgba(255,255,255,.05); }
.dist .d { font-family: var(--font-mono); font-size: 15px; white-space: nowrap; }
.dist small { font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.dist td.under .d { color: var(--warning); }
.lens-btn { align-items: flex-start !important; padding-left: 10px !important; }
.lens-btn b { font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1; }
.lens-btn b sup { font-family: var(--font-mono); font-size: 10px; font-weight: 400; color: var(--blue-400); }
.lens-btn small { color: var(--text-muted); }
.legend { display: flex; justify-content: space-between; gap: 8px; margin: 6px 2px 0; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
.cmp { color: var(--cmp); }
.action-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 12px 0 0; }
.action-row .btn { padding: 0 8px; }

/* Chart title = chart picker */
.chart-title { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; margin: 0 0 6px; padding: 0; background: none; border: 0; color: var(--white); cursor: pointer; text-align: left; }
.chart-title > span { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1; text-transform: uppercase; }
.chart-title > .ic { width: 18px; height: 18px; color: var(--text-muted); }
.chart-title small { margin-left: auto; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--ink-500); }
.modal.menu { background: rgba(10,10,11,.72); -webkit-backdrop-filter: none; backdrop-filter: none; }
.menu-panel { position: absolute; left: 12px; right: 12px; top: 160px; max-width: 696px; margin: 0 auto; display: flex; flex-direction: column; padding: 6px;
  background: var(--ink-850); border: 1px solid var(--border-default); border-radius: var(--radius-3); box-shadow: var(--shadow-3); }
.menu-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) 20px; align-items: center; gap: 10px; min-height: 60px; padding: 0 10px; background: none; border: 0; border-radius: var(--radius-2);
  color: var(--white); text-align: left; cursor: pointer; }
.menu-item .ic { width: 24px; height: 24px; }
.menu-item > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-item b { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1; text-transform: uppercase; }
.menu-item small { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.menu-item.on { background: var(--blue-900); box-shadow: inset 3px 0 0 var(--accent); color: var(--blue-300); }
.menu-item.on .ic:last-child { width: 18px; height: 18px; }
.menu-item.off { min-height: 44px; color: var(--ink-500); cursor: default; }
.menu-item.off b { font-size: 18px; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border-default); }
.menu-panel .sec-lbl { margin: 4px 10px 0; color: var(--ink-500); }

/* Magnification ranking */
.chip-row.two { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.pill-note { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--ink-500); text-align: right; }
.dist.mag { width: 100%; }
.dist.mag td, .dist.mag tbody th { height: 56px; }
.dist.mag td.rk, .dist.mag th.rk { width: 26px; padding-left: 8px; text-align: left; font-family: var(--font-mono); font-size: 11px; color: var(--ink-500); }
.dist.mag tbody td.rk { border-radius: var(--radius-2) 0 0 var(--radius-2); }
.dist.mag tbody th { width: 72px; border-radius: 0; }
.dist.mag tr.cur td.rk { box-shadow: inset 3px 0 0 var(--accent); color: var(--blue-300); }
.dist.mag tr.cur th { box-shadow: none; }
.dist.mag .lens-btn { padding-left: 2px !important; }
.dist.mag .lens-btn small { max-width: 68px; overflow: hidden; text-overflow: ellipsis; font-size: 9px; text-transform: uppercase; color: var(--ink-500); }
.dist.mag td.mg { padding: 0 8px; text-align: left; }
.mg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.mg-x { font-family: var(--font-mono); font-size: 16px; font-weight: 500; color: var(--white); }
.mg-x.calc { color: var(--text-muted); }
.dist.mag tr.cur .mg-x { color: var(--blue-300); }
.src { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; color: var(--ink-500); }
.src.calc { padding: 0 4px; border: 1px dashed var(--ink-500); border-radius: var(--radius-1); color: var(--text-muted); }
.bar { display: block; height: 4px; margin-top: 6px; border-radius: 2px; background: var(--ink-800); }
.bar i { display: block; height: 4px; border-radius: 2px; background: var(--ink-400); }
.dist.mag tr.cur .bar i { background: var(--accent); }
.dist.mag td.fr, .dist.mag th.fr { padding-right: 10px; text-align: right; }
.dist.mag td.fr span { display: block; font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.dist.mag td.fr small { color: var(--ink-500); }
.dist.mag tr.nomod td.mg small { color: var(--text-muted); white-space: normal; }
.action-row.one { grid-template-columns: 1fr; }
.nomod-note { margin: 10px 2px 0; font-size: 13px; color: var(--text-muted); }

/* Format legend under the drawing: frame line (yellow), recording area (blue) */
.fmt-legend { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; column-gap: 10px; row-gap: 3px; padding: 0 10px 10px;
  font-family: var(--font-mono); font-size: 11px; line-height: 14px; white-space: nowrap; text-transform: uppercase; }
.fmt-legend .fl { color: var(--yellow-500); } .fmt-legend .ra { color: var(--blue-400); }
.fmt-legend span:nth-child(4n+2), .fmt-legend span:nth-child(4n) { text-transform: none; }
.fmt-legend .an { grid-column: 1 / -1; color: var(--text-muted); }

/* ---------- Setup ---------- */
.calc-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 6px; }
.calc-grid .seg { margin: 0; }
.calc-grid .seg button { min-height: 42px; font-size: 14px; }
.set-block { margin: 0 0 8px; padding: 12px; background: var(--panel); border: 0; border-radius: var(--radius-2); }
.set-head { display: flex; align-items: center; gap: 8px; }
.set-head b { flex: 1; color: var(--text-strong); font-weight: 600; }
.set-sum { margin: 10px 0 0; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
details.set-block summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; }
details.set-block summary::-webkit-details-marker { display: none; }
details.set-block summary b { color: var(--white); font-weight: 600; }
.sq-select { width: 92px; flex: none; }
.cast-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.cast-tile { display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 0 10px; background: var(--panel); border: 1px solid transparent; border-radius: var(--radius-2);
  color: var(--white); text-align: left; cursor: pointer; }
.cast-tile b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.cast-tile small { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.cast-tile.on { border-color: var(--accent); }
.cast-tile.add { align-items: center; background: none; border: 1px dashed var(--ink-600); }

/* Box fields: label inside a panel, native control borderless */
.box-field { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; min-height: 56px; margin: 0 0 8px; padding: 6px 12px;
  background: rgba(17,17,19,.9); border: 1px solid var(--border-default); border-radius: var(--radius-2); }
.box-btn { position: relative; width: 100%; text-align: left; color: var(--white); cursor: pointer; }
.box-btn b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 22px; }
.box-btn > .ic { position: absolute; right: 10px; bottom: 12px; width: 16px; height: 16px; color: var(--text-muted); }
.lib-q { width: 100%; height: 44px; margin: 0 0 12px; padding: 0 12px; font-size: 16px; color: var(--white); background: var(--panel); border: 1px solid var(--border-default); border-radius: var(--radius-2); }
.lib-q:focus { outline: none; border-color: var(--border-focus); }
.lib-recent { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.lib-recent[hidden], .pick[hidden] { display: none !important; }
.box-field:focus-within { border-color: var(--border-focus); }
.box-field > span { font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.box-field select, .box-field input[type=text] { height: 28px; padding: 0 22px 0 0; border: 0; background-color: transparent; box-shadow: none !important;
  font-size: 15px; font-weight: 600; color: var(--white); text-overflow: ellipsis; }
.box-field input[type=text] { padding: 0; }
.box-field select { background-position: right 0 center; }
.grid2.tight { gap: 0 6px; }

/* Format detail: Detail A drawing with architectural dimension lines */
.fmt-main { padding-top: 4px; }
.detail-a { margin: 0 0 10px; border: 1px solid var(--blue-600); background: rgba(0,0,0,.6); }
.detail-svg { display: block; width: 100%; height: auto; font-family: var(--font-mono); font-size: 11px; }
.detail-svg .cap { fill: var(--blue-400); letter-spacing: .08em; }
.detail-svg text:not(.cap):not(.frame-lbl) { fill: var(--ink-400); }
.detail-svg .sensor { fill: url(#dgrid); stroke: var(--ink-300); stroke-width: 1; }
.detail-svg .frame { fill: none; stroke: var(--yellow-500); stroke-width: 2; stroke-dasharray: 6 4; }
.detail-svg .frame-lbl { fill: var(--yellow-500); font-size: 14px; }
.detail-svg .dim path { fill: none; stroke: var(--blue-400); stroke-width: 1; shape-rendering: crispEdges; }
.detail-svg .dim.fl path { stroke: var(--yellow-500); }
.detail-svg .dim.fl text { fill: var(--yellow-500) !important; }
.detail-svg .lbl-bg { fill: #050607; }
.detail-svg .ext { fill: none; stroke: var(--ink-600); stroke-dasharray: 2 2; }
.fmt-main .stepper { margin: 0 0 8px; }
.fmt-main .btn.primary.block { margin: 4px 0 8px; }
.fmt-more { margin: 4px 0 0; }

.brand-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 28px 0 8px; }
.brand-foot img { display: block; width: auto; height: 12px; opacity: .55; }
.brand-foot span { font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-subtle); }
/* Settings */
.settings-main { padding-top: 4px; }

/* ---------- Print ---------- */
@media print {
  :root { --panel: #f2f2f2; --white: #000; --surface-page: #fff; --surface-section: #fff; --ink-900: #f2f2f2; --border-subtle: #bbb; --border-default: #bbb; --text-strong: #000; --text-body: #000; --text-muted: #555; }
  .no-print, .modal, #toast, .tabbar, .bp-bg { display: none !important; }
  html, body { background: #fff; }
  @page { margin: 10mm; }
  main { padding: 0; max-width: none; } .table-wrap { overflow: visible; margin: 0; }
  /* Small pocket card: easy to read, nothing bigger. */
  .print-head { display: block !important; margin: 0 0 2mm; font-family: var(--font-mono); font-size: 7pt; line-height: 1.35; color: #000; }
  .print-head b { font-family: var(--font-sans); font-size: 9pt; }
  .chart-meta, .legend > span:last-child { display: none; }
  .legend .warn-txt { color: #000; }
  table.dist { width: auto; border-collapse: collapse; border-spacing: 0; }
  .dist th, .dist td, .dist tbody th { padding: 0; background: none !important; border: .5pt solid #888; border-radius: 0 !important; box-shadow: none !important; }
  .dist thead th { padding: .6mm 1.2mm; font-size: 7pt; color: #000; }
  .dist thead th small { font-size: 6pt; }
  .dist tr.grp td { padding: 1.2mm 0 .4mm; border: 0; font-size: 6.5pt; color: #000; }
  .dist button { min-height: 0; padding: .7mm 1.6mm; color: #000; }
  .dist .d { font-size: 8.5pt; }
  .lens-btn { padding-left: 1.6mm !important; }
  .lens-btn b { font-size: 10pt; color: #000 !important; }
  .dist tbody th { width: auto; }
  .dist td.under .d { color: #000; font-weight: 700; text-decoration: underline; }
  .legend { display: block; margin: 1.5mm 0 0; font-size: 6.5pt; color: #000; }
  .bar { display: none; }
  .dist.mag { width: auto; }
  .dist.mag td, .dist.mag tbody th { height: auto; padding: .7mm 1.6mm !important; }
  .mg-x, .dist.mag td.fr span { font-size: 8.5pt; color: #000 !important; }
  .src { font-size: 6pt; color: #000; }
}
.print-head, .print-only { display: none; }
@media print { .scr-only { display: none; } .print-only { display: inline; } }

.unit { text-transform: none; letter-spacing: 0; }
