/* =========================================================================
 * notebook.css — the Engineer's Notebook design system
 *
 * Fraunces display / DM Sans UI / JetBrains Mono data, warm paper with a rust
 * accent. The :root block below is shared byte-for-byte with doka-platform-
 * manager, Doka Pocket CRM and TiplistToGo — never retune it per app. Add
 * app-local tokens below it, clearly marked.
 *
 * Copy to css/app.css and delete what this app does not use. Full rulebook:
 * ../engineers-notebook-style/DESIGN-SYSTEM.md
 * ========================================================================= */

:root {
  --paper: #F6F2E9;
  --card: #FFFDF7;
  --ink: #2B2A26;
  --ink-soft: #6B675C;
  --line: #DDD5C4;
  --line-soft: #EAE3D4;
  --rust: #B3502D;
  --rust-deep: #8F3E21;
  --amber: #E0A41B;
  --teal: #1F6F9C;
  --green: #4A7A43;
  --purple: #6E4FA3;
  --warn-bg: #F6E3DC;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --nav-h: 58px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 42, 38, .10), 0 4px 14px rgba(43, 42, 38, .06);
}

* { box-sizing: border-box; }

/* Load-bearing. View switching uses the hidden attribute; an author
 * display:flex on a hidden pane paints an empty overlay over the whole app. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--teal); }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 640; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.mono, code, kbd, pre, .kv dt, .kv dd { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.pad { padding: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* The signature small-caps label: field labels, section heads, KPI captions. */
.label, .ctl-label, .panel-sub {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft);
}

.hint { font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 0; }
.hint-warn { color: var(--rust-deep); }

/* ------------------------------------------------------------ buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--rust); border-color: var(--rust-deep); color: #fff; font-weight: 600; }
.btn-primary:hover, .btn-primary:active { background: var(--rust-deep); }
.btn-ghost { border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); background: var(--paper); border-color: var(--line); }
.btn-ghost.danger { color: var(--rust-deep); border-color: var(--rust); }
.btn-link { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.btn-tiny { font-size: 12px; padding: 3px 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  color: var(--ink-soft); font-size: 14px; line-height: 1;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn.danger:hover { color: var(--rust-deep); }

/* Touch targets. Apply to the whole app on a mobile-first build. */
.touch .btn { min-height: 42px; padding: 10px 16px; border-width: 1.5px; }
.touch .icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; }

/* ------------------------------------------------------------- inputs ---- */

.text-input, input[type=text], input[type=search], input[type=number],
input[type=email], select, textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink);
}
input[type=text], input[type=number], input[type=email], select { height: 36px; }
textarea { resize: vertical; min-height: 52px; line-height: 1.5; }
.text-input:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal);
}
.touch .text-input, .touch input, .touch select, .touch textarea {
  font: inherit; padding: 10px 12px; border-width: 1.5px; border-radius: var(--radius);
}
.touch .text-input:focus, .touch input:focus { outline: none; border-color: var(--rust); }

.search-input {
  flex: 1; min-width: 0; font: inherit;
  padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 22px;
  background: var(--card);
}
.search-input:focus { border-color: var(--rust); outline: none; }

/* Labelled control in a toolbar row. */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 3px; flex: 1 1 150px; }
.ctl-narrow { flex: 0 0 84px; }
.ctl-wide { flex: 2 1 320px; }
.ctl-actions { display: flex; gap: 7px; }
.controls.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 12px; align-items: end;
}
.controls.form-grid .ctl, .controls.form-grid .ctl-narrow { flex: none; min-width: 0; }
.controls.form-grid .ctl-wide { flex: none; grid-column: 1 / -1; }

/* -------------------------------------------------- chips & segments ---- */

.chip-row {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1.5px solid var(--line); border-radius: 16px;
  background: var(--card);
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.st-a.on { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.chip.st-b.on { background: var(--teal); border-color: var(--teal); color: #FFF8F0; }
.chip.st-c.on { background: var(--green); border-color: var(--green); color: #FFF8F0; }

.status-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 2px 7px; border-radius: 4px;
  background: var(--ink-soft); color: #FFFDF7;
}
.status-badge.st-a { background: var(--amber); color: var(--ink); }
.status-badge.st-b { background: var(--teal); }
.status-badge.st-c { background: var(--green); }

.pill {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--teal); color: var(--teal);
  border-radius: 999px; padding: 1px 8px;
}
.pill-warn { border-color: var(--rust); color: var(--rust-deep); background: var(--warn-bg); }

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.segmented button {
  padding: 6px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.segmented button.active { background: var(--ink); color: var(--paper); }

.env-chip {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  cursor: pointer; flex-shrink: 0;
}
.env-chip.is-dev { background: var(--amber); border-color: var(--amber); color: var(--ink); }

/* ------------------------------------------------- cards & the spine ---- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; margin-bottom: 14px;
}
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 640; margin: 0 0 8px; }
.card-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* The record card: a filed ticket stub with a colored spine. */
.record-list { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 0; }
.record-card {
  position: relative; display: flex; overflow: hidden; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-spine { flex: 0 0 5px; background: var(--ink-soft); }
.record-card.st-a .card-spine { background: var(--amber); }
.record-card.st-b .card-spine { background: var(--teal); }
.record-card.st-c .card-spine { background: var(--green); }
.card-body { flex: 1; min-width: 0; padding: 10px 44px 10px 12px; }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); letter-spacing: .04em; }
.card-name {
  font-size: 16.5px; line-height: 1.2; margin: 4px 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-soft); }
.card-flag {
  font-size: 10.5px; font-weight: 700;
  background: var(--warn-bg); color: var(--rust-deep);
  border: 1px solid var(--rust); border-radius: 9px; padding: 1px 7px; white-space: nowrap;
}

/* The figure block: mono value over a small-caps caption. Used everywhere. */
.card-figures, .kpi-strip { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 7px; }
.kpi-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 14px; }
.kpi-strip::-webkit-scrollbar { display: none; }
.fig, .kpi { display: flex; flex-direction: column; line-height: 1.1; flex: 0 0 auto; }
.fig, .kpi-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.fig i, .kpi-label {
  font-style: normal; font-family: var(--font-body); font-weight: 400;
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft);
}
.fig.warn, .kpi.warn .kpi-value { color: var(--rust-deep); }

/* ------------------------------------------------------ key/value rows ---- */

.dgroup { margin-bottom: 20px; }
.dgroup h3 {
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--rust);
  border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 2px;
}
.dgroup-rows {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); overflow: hidden;
}
.drow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
}
.drow:last-child { border-bottom: 0; }
.drow.editable { cursor: pointer; }
.drow.editable:active, .drow.editable:hover { background: var(--paper); }
.drow-label { font-size: 13px; color: var(--ink-soft); flex: 0 1 46%; }
.drow-value {
  font-family: var(--font-mono); font-size: 13.5px; font-weight: 500;
  text-align: right; flex: 1; min-width: 0; overflow-wrap: anywhere;
}
.drow-value.warn { color: var(--rust-deep); }
.drow.has-pending { background: #FBF4E4; }
.q-old { font-family: var(--font-mono); text-decoration: line-through; color: var(--ink-soft); }
.q-arrow { color: var(--rust); }
.q-new { font-family: var(--font-mono); font-weight: 600; color: var(--rust-deep); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--ink-soft); font-size: 11.5px; white-space: nowrap; }
.kv dd { margin: 0; word-break: break-all; }
.kv dd.is-null { color: var(--ink-soft); font-style: italic; }

/* -------------------------------------------------------- data tables ---- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 7px; margin-top: 10px; }
table.data { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 12px; }
table.data th, table.data td {
  padding: 5px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap;
}
table.data th {
  position: sticky; top: 0; background: var(--paper); cursor: pointer; user-select: none;
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid var(--line);
}
table.data th:hover { color: var(--rust); }
table.data th.is-sorted { color: var(--rust-deep); }
table.data tbody tr:nth-child(even) { background: #FBF7EE; }
table.data td.is-null { color: var(--ink-soft); font-style: italic; }
table.data td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-clip { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

/* ----------------------------------------------------- result / tone ---- */

.result { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 14px; overflow: hidden; }
.result-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line-soft); }
.result-body { padding: 12px 15px; }
.result-headline { font-size: 14.5px; font-weight: 700; margin: 0 0 3px; }
.result-plain { font-size: 13px; margin: 0; }
.result-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; }

/* Tone drives every colour here. Nothing else sets them. */
.tone-ok     { border-left: 5px solid var(--green); }
.tone-empty  { border-left: 5px solid var(--teal); }
.tone-denied { border-left: 5px solid var(--rust); }
.tone-broken { border-left: 5px solid var(--amber); }
.tone-fatal  { border-left: 5px solid var(--rust-deep); }
.tone-denied .result-head, .tone-fatal .result-head { background: var(--warn-bg); }

.status-chip {
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  padding: 3px 10px; border-radius: 6px; color: #fff; white-space: nowrap;
  background: var(--ink-soft);
}
.tone-ok .status-chip { background: var(--green); }
.tone-empty .status-chip { background: var(--teal); }
.tone-denied .status-chip, .tone-fatal .status-chip { background: var(--rust-deep); }
.tone-broken .status-chip { background: var(--amber); color: var(--ink); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--green); }
.dot-empty { background: var(--teal); }
.dot-denied { background: var(--rust); }
.dot-broken { background: var(--amber); }
.dot-fatal { background: var(--rust-deep); }

.raw {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.45; margin: 0;
  background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.cmd {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  background: var(--ink); color: #F1EADC; border-radius: 7px;
  padding: 10px 12px; margin: 8px 0 4px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
details.raw-wrap { margin-top: 10px; }
details.raw-wrap > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft); padding: 4px 0; }
details.raw-wrap > summary:hover { color: var(--ink); }

/* --------------------------------------------- empty / loading / boot ---- */

.empty-state { text-align: center; padding: 56px 28px; color: var(--ink-soft); }
.empty-mark { font-size: 34px; color: var(--line); margin-bottom: 10px; }
.empty-state h2 { color: var(--ink); font-size: 21px; margin-bottom: 6px; }

.spinner {
  width: 22px; height: 22px; margin: 0 auto 10px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--rust);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.view { min-height: 100%; }
.view-center { display: flex; justify-content: center; padding: 32px 20px; }
.boot-card { text-align: center; color: var(--ink-soft); font-size: 13px; margin: auto; }
.fatal-card {
  max-width: 760px; margin: auto;
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--rust-deep); border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow);
}
.fatal-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 10px; color: var(--rust-deep); }

/* ---------------------------------------------------------- topbar ------ */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  height: var(--nav-h); padding: 0 18px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; flex-direction: column; line-height: 1.15; flex-shrink: 0; }
.topbar-name { font-family: var(--font-mono); font-size: 14px; font-weight: 600; margin: 0; }
.topbar-sub { font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--rust); }
.topbar-nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; min-width: 0; }
.topbar-right { margin-left: 10px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tabnav-btn {
  font-size: 13px; font-weight: 500; padding: 7px 13px;
  border: 1px solid transparent; border-radius: 7px; color: var(--ink-soft);
}
.tabnav-btn:hover { color: var(--ink); background: var(--paper); }
.tabnav-btn.is-active { color: var(--rust-deep); background: var(--paper); border-color: var(--line); font-weight: 700; }

.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 200px; display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px;
}

/* Mobile search/filter header (sticky, above the list). */
.mobile-topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
}

/* ------------------------------------------------------ bottom nav ------ */

.tab { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 11px; font-weight: 500; color: var(--ink-soft);
}
.nav-btn .nav-ico { font-size: 18px; line-height: 1; }
.nav-btn.active { color: var(--rust); }
.nav-btn.active::after {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%;
  height: 2.5px; background: var(--rust); border-radius: 0 0 3px 3px;
}
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 26px);
  min-width: 17px; height: 17px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--rust); color: #FFF8F0; border-radius: 9px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
}

/* ------------------------------------------------ overlays & toast ------
 * z-index ladder — keep every overlay inside it:
 *   map / canvas internals  <= 1000
 *   bottom nav                 1500
 *   full-screen detail         2000
 *   sheet / modal              2100
 *   toast                      2200
 */

.overlay { position: fixed; inset: 0; z-index: 2100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(43, 42, 38, .42); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86dvh;
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: 16px 16px 0 0;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 38px; height: 4px; background: var(--line); border-radius: 2px; margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 4px; }
.sheet-scroll { overflow-y: auto; padding: 4px 16px 12px; }
.sheet-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .btn { width: 100%; }

.modal-panel {
  position: absolute; left: 14px; right: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 12px;
  max-width: 640px; margin: 0 auto; max-height: 80dvh; overflow-y: auto;
  background: var(--paper); border-radius: 14px; padding: 20px 16px;
  box-shadow: 0 12px 40px rgba(43, 42, 38, .3);
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.detail-view { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; background: var(--paper); }
.detail-head {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 10px 12px;
  background: var(--card); border-bottom: 4px solid var(--ink-soft);
}
.detail-head.st-a { border-bottom-color: var(--amber); }
.detail-head.st-b { border-bottom-color: var(--teal); }
.detail-head.st-c { border-bottom-color: var(--green); }
.detail-scroll { flex: 1; overflow-y: auto; padding: 12px 14px; }

.toast {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  z-index: 2200;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius); padding: 11px 14px; font-size: 13.5px;
  box-shadow: 0 6px 22px rgba(43, 42, 38, .32);
  opacity: 0; transform: translateY(8px);
  transition: opacity .22s, transform .22s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ------------------------------------------------ desktop tool layout ---- */

.workspace {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  gap: 16px; padding: 16px;
}
.panel {
  min-height: 0; overflow: auto;
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.panel-scroll { flex: 1; min-height: 0; overflow: auto; }
.page { padding: 18px; max-width: 1400px; margin: 0 auto; }

/* ------------------------------------------------------- credit tag ------
 * The maker's mark. Identical in every app in the family — do not reword it.
 * <a class="credit" href="https://josiahmdavidson.com" target="_blank"
 *    rel="noopener">Built by Claude + Josiah in Illinois 🌽</a>
 * Mobile: bottom of the More tab. Desktop: footer strip or the welcome state. */

.credit {
  display: block; text-align: center; margin-top: 14px; padding-bottom: 20px;
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600;
  color: var(--ink-soft); opacity: .6; text-decoration: none;
}
.credit:hover, .credit:active { opacity: .85; }

/* -------------------------------------------------------- a11y & motion -- */

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.tabnav-btn:focus-visible, .btn:focus-visible { outline-offset: 1px; }
table.data th:focus-visible { outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; border-top-color: var(--line); }
}

/* ------------------------------------------------------------ widths ----- */

/* Centre the reading column once there's room, with paper edges. */
@media (min-width: 740px) {
  .record-list, .mobile-topbar { max-width: 720px; margin-left: auto; margin-right: auto; }
  .mobile-topbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; gap: 8px; }
  .page { padding: 12px; }
  .cell-clip { max-width: 180px; }
}

@media (max-width: 600px) {
  .page { padding: 10px; }
  .card { padding: 12px; }
  .controls { gap: 8px; }
  .controls.form-grid { grid-template-columns: 1fr; }
  .ctl, .ctl-narrow, .ctl-wide { flex: 1 1 100%; }
  .ctl-actions, .ctl-actions .btn, .card-foot .btn { flex: 1 1 auto; width: 100%; }
  .result-head { flex-direction: column; gap: 8px; }
  .status-chip { align-self: flex-start; }
  .kv { grid-template-columns: 1fr; gap: 1px 0; }
  .kv dt { margin-top: 8px; }
}

/* =========================================================================
 * Doka Product Quiz — app-local rules. Everything above is notebook.css,
 * shared with the family; everything below is this app's.
 *
 * The one local rule: the image tile is the only pure-white surface in the
 * app. The drawings are black line art on white, and a paper tint behind them
 * reads as a scanning artefact, so the tile is #FFFFFF on purpose.
 * ========================================================================= */

body {
  --q-tile-bg: #FFFFFF;
  --q-ok-bg: #EEF3EA;
  --q-me-bg: #FBF4E4;
  --acc-0: var(--line);
  --acc-1: #9DC0D3;
  --acc-2: var(--teal);
  --acc-3: var(--green);
}

/* ---- shell ------------------------------------------------------------- */

.column { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 740px) {
  .column, .app-head, .quiz-body, .quiz-head { max-width: 720px; margin-left: auto; margin-right: auto; }
}
.app-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 6px; min-height: 52px;
}
.app-head-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.head-title { font-size: 21px; }
.head-date { font-size: 12px; color: var(--ink-soft); }
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-eyebrow { font-size: 9.5px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--rust); }
.brand-name { font-size: 26px; }
.btn-block { width: 100%; }
.label-gap { margin-top: 6px; }
.link-row { display: flex; gap: 10px; }
.link-row .btn { flex: 1; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.auth-line { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-line { min-height: 22px; font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
.status-line .spinner { margin: 0; width: 16px; height: 16px; }
.rules { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.rules li + li { margin-top: 4px; }
.about { margin: 6px 0 0; font-size: 14px; }
.card-static { cursor: default; }
.record-card .card-body { padding-right: 12px; }
.record-card.st-rust .card-spine { background: var(--rust); }
.record-card.st-amber .card-spine { background: var(--amber); }
.record-card.st-green .card-spine { background: var(--green); }
.seg-block { display: flex; }
.seg-block button { flex: 1; }
.chip-wrap { flex-wrap: wrap; overflow: visible; }
.chip-wrap .chip { min-height: 36px; }
.env-chip[hidden] { display: none; }

/* ---- quiz -------------------------------------------------------------- */

.quiz-view { display: flex; flex-direction: column; min-height: 100dvh; }
.quiz-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px calc(6px + env(safe-area-inset-top));
}
.quiz-head .mono { margin-left: auto; font-size: 12px; color: var(--ink-soft); }
.dots { display: flex; gap: 5px; list-style: none; margin: 0; padding: 0; }
.dot-q {
  width: 8px; height: 8px; border-radius: 50%; background: var(--line);
  transition: background .15s, box-shadow .15s;
}
.dot-q.current { box-shadow: 0 0 0 2px var(--rust); background: var(--card); }
.dot-q.correct { background: var(--green); }
.dot-q.incorrect { background: var(--rust); }
.quiz-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 14px calc(16px + env(safe-area-inset-bottom)); width: 100%; }
.quiz-system { text-align: center; min-height: 16px; }
.img-tile {
  position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 44dvh;
  background: var(--q-tile-bg); border: 1px solid var(--line-soft); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.img-tile img { width: 100%; height: 100%; object-fit: contain; padding: 14px; display: block; }
.img-tile img.is-loading { opacity: 0; }
.img-ph {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--line-soft); color: var(--ink-soft);
}
.img-ph .ph-num { font-family: var(--font-mono); font-size: 18px; letter-spacing: .06em; }
.img-ph .ph-note { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.options { display: grid; gap: 8px; }
.opt {
  min-height: 52px; padding: 10px 14px; text-align: left; white-space: normal; line-height: 1.3;
  justify-content: flex-start; font-size: 15px;
  transition: border-color .15s, background .15s, opacity .15s;
}
.opt .opt-key { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); margin-right: 10px; flex: 0 0 auto; }
.opt.is-correct { border-color: var(--green); background: var(--q-ok-bg); }
.opt.is-incorrect.is-chosen { border-color: var(--rust); background: var(--warn-bg); }
.options.is-locked .opt { pointer-events: none; }
.options.is-locked .opt:not(.is-correct):not(.is-chosen) { opacity: .5; }
.quiz-elapsed { text-align: center; font-size: 12px; color: var(--ink-soft); min-height: 16px; }

/* ---- results ----------------------------------------------------------- */

.score-card { text-align: center; }
.score-big { font-family: var(--font-display); font-size: 44px; line-height: 1; font-weight: 640; }
.score-big .mono { font-family: var(--font-mono); }
.score-of { font-size: 22px; color: var(--ink-soft); }
.score-meta { display: flex; justify-content: center; gap: 14px; margin-top: 8px; font-size: 14px; }
.score-card .status-line { justify-content: center; margin-top: 10px; }
.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.review-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 8px 10px;
}
.review-thumb {
  position: relative; flex: 0 0 56px; width: 56px; height: 56px; background: var(--q-tile-bg);
  border: 1px solid var(--line-soft); border-radius: 7px; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.review-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.review-thumb .img-ph .ph-num { font-size: 9px; }
.review-thumb .img-ph .ph-note { display: none; }
.review-text { min-width: 0; font-size: 14px; }
.review-name { font-weight: 500; }
.review-sub { font-size: 12.5px; color: var(--ink-soft); }
.review-sub .dot { margin-right: 5px; }

/* ---- leaderboard ------------------------------------------------------- */

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board-row {
  display: grid; grid-template-columns: 36px 1fr auto auto; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line-soft); border-left: 5px solid transparent;
  border-radius: var(--radius); padding: 9px 12px;
  font-size: 14px;
}
.board-row .rank { font-family: var(--font-mono); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.board-row .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .name .pill { margin-left: 8px; }
.board-row .score, .board-row .time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.board-row .time { color: var(--ink-soft); font-size: 12.5px; }
.board-row.is-me { background: var(--q-me-bg); border-left-color: var(--rust); }
.board-row.top-1 .rank { color: var(--rust); font-weight: 600; }
.board-mine {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  z-index: 1400; padding: 6px 14px; background: var(--paper); border-top: 1px solid var(--line);
}
.board-mine .board-row { margin: 0 auto; max-width: 720px; box-shadow: var(--shadow); }

/* ---- skills ------------------------------------------------------------ */

.skills { display: flex; flex-direction: column; gap: 8px; }
.skill-row {
  display: grid; grid-template-columns: 5px 1fr auto; align-items: center; gap: 0 12px; width: 100%; min-height: 60px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; text-align: left;
}
.skill-row .spine { align-self: stretch; background: var(--acc-0); }
.skill-row.acc-1 .spine { background: var(--acc-1); }
.skill-row.acc-2 .spine { background: var(--acc-2); }
.skill-row.acc-3 .spine { background: var(--acc-3); }
.skill-row .skill-main { padding: 9px 0; }
.skill-row .skill-name { font-size: 15px; font-weight: 500; }
.skill-row .skill-figs { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.skill-row .skill-acc { padding: 9px 12px 9px 0; text-align: right; font-family: var(--font-mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.skill-row .skill-acc small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-soft); }
.skill-row .skill-acc.is-null { font-family: var(--font-body); font-style: italic; font-weight: 400; font-size: 13px; color: var(--ink-soft); }
.skill-row:active { background: var(--paper); }

/* ---- sign-in sheet ----------------------------------------------------- */

.clerk-mount { display: flex; justify-content: center; margin: 6px 0 14px; min-height: 320px; }
.sheet-head h2 { font-size: 21px; }
.sheet-panel { max-height: 92dvh; }

/* ---- almost-there / denied cards --------------------------------------- */

.notice { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 14px 16px; }
.notice.tone-empty { border-left: 5px solid var(--teal); }
.notice.tone-denied { border-left: 5px solid var(--rust); background: var(--warn-bg); }
.notice.tone-broken { border-left: 5px solid var(--amber); }
.notice h2 { font-size: 19px; margin-bottom: 4px; }
.notice p { margin: 0 0 8px; font-size: 14px; color: var(--ink-soft); }
.notice .btn { margin-top: 4px; }

/* ---- report sheet + review queue --------------------------------------- */

.report-product { display: flex; align-items: center; gap: 12px; }
.report-product .review-thumb { flex: 0 0 56px; }
.report-product .mono { font-size: 12px; color: var(--ink-soft); }
#reportReasons .chip { white-space: normal; text-align: left; }
.review-row .btn-tiny { margin-left: auto; flex: 0 0 auto; }
.review-row .reported { margin-left: auto; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.queue { display: flex; flex-direction: column; gap: 12px; }
.queue-item { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--amber); border-radius: var(--radius); padding: 12px 14px; }
.queue-item.is-resolved { border-left-color: var(--line); }
.queue-item.is-excluded { border-left-color: var(--rust); }
.queue-item.is-dismissed { border-left-color: var(--teal); }
.queue-head { display: flex; gap: 12px; align-items: flex-start; }
.queue-head .img-tile { flex: 0 0 120px; width: 120px; aspect-ratio: 1; max-height: none; }
.queue-head .img-tile img { padding: 6px; }
.queue-title { font-weight: 500; font-size: 15px; }
.queue-meta { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.queue-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.queue-reports { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.queue-reports li { border-top: 1px solid var(--line-soft); padding-top: 6px; }
.queue-reports .who { color: var(--ink-soft); font-size: 12px; }
.queue-reports .ctx { font-size: 12px; color: var(--ink-soft); }
.queue-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.queue-actions input { flex: 1 1 160px; }
.queue-actions .btn { flex: 0 0 auto; }
.queue-build { font-size: 12px; margin-top: 8px; }
.queue-build.pending-build { color: var(--rust-deep); }
.queue-build.in-build { color: var(--green); }

/* ---- QA pass (2026-09-13) ---------------------------------------------- */

/* Touch: no 300 ms delay, no double-tap zoom on controls; 16 px inputs so
 * iOS Safari does not zoom the page when a field gains focus. */
button, .btn, .opt, .chip, .nav-btn, .skill-row { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.touch input, .touch textarea, .touch select { font-size: 16px; }
.chip-wrap .chip { min-height: 40px; }
#reportNote { width: 100%; }

/* Keyboard hint: only where there is a keyboard. */
.quiz-keys { display: none; text-align: center; font-size: 12px; color: var(--ink-soft); }
@media (hover: hover) and (pointer: fine) { .quiz-keys { display: block; } }

/* Landscape phone: drawing on the left, answers on the right, no scrolling
 * to reach the buttons. */
@media (orientation: landscape) and (max-height: 520px) {
  .quiz-body { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 8px 14px; padding-top: 0; }
  .quiz-system, .quiz-elapsed, .quiz-keys { flex: 1 1 100%; }
  .quiz-system { margin: 0; }
  .img-tile { flex: 1 1 42%; aspect-ratio: auto; max-height: calc(100dvh - 96px); min-height: 0; }
  .options { flex: 1 1 50%; align-content: center; }
  .opt { min-height: 44px; padding: 6px 12px; }
  .quiz-head { padding-top: 6px; padding-bottom: 2px; }
  .quiz-elapsed { min-height: 0; }
}

/* Wide screens: the tab bar stays at the bottom, like the other platform
 * apps; only the toast moves out of the way and content keeps its bottom
 * padding for the bar. */
@media (min-width: 900px) {
  .toast { left: auto; right: 24px; max-width: 420px; }
}

/* Sheets become centred dialogs once there is room. */
@media (min-width: 740px) {
  .sheet-panel {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(560px, 92vw); max-height: 88dvh;
    transform: translate(-50%, -50%);
    border-radius: 16px; border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(43, 42, 38, .3);
    animation: none;
  }
  .sheet-grip { display: none; }
  .sheet-foot { padding-bottom: 12px; }
}

/* ---- gate ---------------------------------------------------------------- */

.setup { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 18px; background: var(--paper); }
.setup-card { width: 100%; max-width: 440px; text-align: center; }
.gate-brand h1 { font-size: 34px; line-height: 1.1; margin: 4px 0 10px; }
.setup-sub { color: var(--ink-soft); margin: 0 0 22px; }
.gate-status { justify-content: center; }
.gate-notice { text-align: left; margin-bottom: 12px; }
.setup-choice { width: 100%; margin-top: 8px; }
.setup .credit { margin-top: 28px; }

/* ---- challenge code, join ------------------------------------------------- */

.record-card.st-code .card-spine { background: var(--purple); }
.code-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.code-row input { flex: 1; min-width: 0; letter-spacing: .12em; text-transform: uppercase; }
.code-row .btn { flex: 0 0 auto; }
.recent-row { padding-top: 10px; align-items: center; gap: 8px; }
.recent-row .label { margin-right: 2px; }
.join-title { font-size: 24px; margin: 4px 0 6px; }
.code-big { font-size: 34px; font-weight: 600; letter-spacing: .14em; margin: 10px 0 8px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.actions-row .btn { flex: 1 1 auto; }

/* ---- admin: lists, forms, picker ------------------------------------------ */

.row-btn { cursor: pointer; }
.row-btn:active { background: var(--paper); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.resume-strip { background: #FBF4E4; border: 1px solid var(--amber); border-radius: 8px; padding: 8px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.drop-zone { position: relative; }
.drop-zone.is-empty { border: 1.5px dashed var(--line); background: var(--card); }
.drop-zone.is-over { border: 2px dashed var(--teal); }
.drop-zone img.is-thumb { image-rendering: auto; }
.pick-field { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; white-space: normal; padding: 9px 12px; }
.pick-field.is-empty .pick-name { color: var(--ink-soft); font-weight: 400; }
.pick-field .pick-meta { font-size: 11px; color: var(--ink-soft); }
.wrong-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.wrong-row .opt-key { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); flex: 0 0 14px; }
.wrong-row .pick-field { flex: 1; }
.preview-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.preview-card .img-tile { max-height: 36dvh; }
.picker-results { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; min-height: 120px; }
.pick-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 9px 12px; background: var(--card); border: 1px solid var(--line-soft); border-radius: 8px; min-height: 48px; }
.pick-row:active, .pick-row:focus-visible { background: var(--paper); }
.pick-row .pick-meta { font-size: 11px; color: var(--ink-soft); }
.pick-typed { border-style: dashed; }
.citems { display: flex; flex-direction: column; gap: 10px; }
.citem { margin-bottom: 0; }
.citem-head { display: flex; align-items: center; gap: 10px; }
.citem-n { flex: 0 0 22px; color: var(--ink-soft); font-size: 12px; }
.citem-opts { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.citem-opt { display: flex; align-items: center; gap: 6px; }
.citem-opt-name { flex: 1; min-width: 0; }
.citem-opt.is-right .citem-opt-name { font-weight: 600; }
.citem-foot { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.citem-spacer { flex: 1; }
.cdetail .card-meta { margin-top: 6px; }
.dot-empty { background: var(--line); }

.review-thumb .img-ph .ph-num { font-size: 9px; letter-spacing: 0; }
.queue-head .img-tile { position: relative; }

.skill-sep { color: var(--line); margin: 0 2px; }

/* ---- admin: catalog review --------------------------------------------- */

.cat-tools { display: flex; flex-direction: column; gap: 8px; }
.cat-family { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cat-family-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.cat-family-name { font-weight: 600; flex: 1 1 auto; min-width: 0; }
.cat-family-count { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); }
.cat-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.cat-toggle .chip { min-height: 32px; padding: 4px 10px; }
.cat-rows { list-style: none; margin: 0; padding: 0; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line-soft); }
.cat-row:first-child { border-top: 0; }
.cat-row .review-thumb { flex: 0 0 64px; width: 64px; height: 64px; }
.cat-row .review-text { flex: 1; min-width: 0; }
.cat-row.is-excluded { opacity: .55; }
.cat-row.is-excluded .review-name { text-decoration: line-through; }
.cat-row .btn-tiny { flex: 0 0 auto; }
.cat-count { font-size: 12.5px; color: var(--ink-soft); }

/* ---- two-part credit line -------------------------------------------- */
/* Both credits inherit .credit's face, size and muted colour; the container
 * takes over the block spacing so the pair sits on one line. The separator
 * recedes to border tone and cannot be selected — punctuation, not content. */
.credits { text-align: center; margin-top: 14px; padding-bottom: 20px; }
.credits .credit { display: inline; margin: 0; padding: 0; }
.credit-sep { color: var(--line); margin: 0 8px; user-select: none; font-size: 11.5px; }
.setup .credits { margin-top: 28px; }

/* ---- lifetime stats strip (Skills) ------------------------------------ */
.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }
.stat { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px 8px; text-align: center; display: flex; flex-direction: column; line-height: 1.15; }
.stat-n { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
