/* Thomas Tong — Property Investment Analysis.
   App shell: fixed 100vh frame, persistent toolbar + action bar, internally
   scrolling panels. Brand-grounded but restrained: ink + rice-paper cream,
   vermillion as a sharp accent, green/red strictly for profit/loss, mono for
   every figure. */

:root {
  --red-500: #C9261A; --red-600: #A81A14; --red-50: #FFF1EC;
  --ink-900: #141110; --ink-800: #231E1B; --ink-700: #3A322D; --ink-600: #5C514A; --ink-500: #7F746C;
  --ink-300: #CABFB5; --ink-200: #E4DAD1; --ink-100: #F2EBE3; --ink-50: #FAF6F0;
  --gold-500: #C79A3A; --jade: #2F6B5B; --jade-50: #ECF4F1;
  --profit: #1F7A4D; --loss: #C9261A;
  --paper: #FFFFFF;

  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Inter Tight", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --r: 10px; --shadow: 0 1px 2px rgba(20,17,16,.06), 0 8px 24px rgba(20,17,16,.06);
  --toolbar-h: 58px; --actionbar-h: 46px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
/* App feel: no double-tap-to-zoom on controls (still allows scroll + pinch). */
button, input, select, label.field, .swatch, .rail-item, .tab, .seg button { touch-action: manipulation; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans); color: var(--ink-900); background: var(--ink-100);
  font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  overflow: hidden; /* the app owns scrolling, not the page */
}

/* ── App shell ───────────────────────────────────────────────────────── */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

.toolbar {
  min-height: var(--toolbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 18px;
  /* safe-area: clear the notch / status bar in standalone iPad */
  padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  background: var(--ink-900); color: var(--ink-50); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--red-500); color: var(--ink-50); font-family: var(--font-serif); font-weight: 900; font-size: 22px; line-height: 1; }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--ink-300); }
@media (max-width: 640px) { .brand-text { display: none; } }

.scenario-tabs { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tab {
  appearance: none; border: 1px solid rgba(255,255,255,.18); background: transparent;
  color: var(--ink-100); font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; display: flex; align-items: center; gap: 7px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tab[data-active="true"] { background: var(--ink-50); color: var(--ink-900); border-color: var(--ink-50); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; }
.tab .x { opacity: .55; font-weight: 700; }
.tab .x:hover { opacity: 1; color: var(--red-500); }
.tab.add { border-style: dashed; }

.tool-toggle {
  appearance: none; border: 1px solid rgba(255,255,255,.22); background: transparent; color: var(--ink-50);
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 8px; cursor: pointer;
  transition: background .15s var(--ease);
}
.tool-toggle:hover { background: rgba(255,255,255,.10); }
.tool-toggle[data-active="true"] { background: var(--red-500); border-color: var(--red-500); }

/* ── Workspace ───────────────────────────────────────────────────────── */
.workspace {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 188px minmax(0, 1fr) 388px;
  background: var(--ink-100);
}

/* Step rail */
.rail {
  overflow-y: auto; min-height: 0; padding: 18px 10px; border-right: 1px solid var(--ink-200);
  background: var(--ink-50); display: flex; flex-direction: column; gap: 4px;
}
.rail-item {
  appearance: none; border: 0; background: transparent; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  font-family: inherit; color: var(--ink-600); transition: background .15s var(--ease), color .15s var(--ease);
}
.rail-item:hover { background: var(--ink-100); }
.rail-item[data-active="true"] { background: var(--ink-900); color: var(--ink-50); }
.rail-num { font-family: var(--font-mono); font-size: 12px; font-weight: 700; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--ink-200); color: var(--ink-700); flex: 0 0 auto; }
.rail-item[data-active="true"] .rail-num { background: var(--red-500); color: #fff; }
.rail-label { font-size: 13.5px; font-weight: 600; }

/* Flow (center, scrolls) */
.flow { overflow-y: auto; min-height: 0; padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }

.step { flex: 0 0 auto; background: var(--paper); border: 1px solid var(--ink-200); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 12px; }
.step-head { display: flex; align-items: baseline; gap: 10px; padding: 15px 18px 2px; }
.step-num { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--red-500); background: var(--red-50); border-radius: 6px; padding: 2px 7px; }
.step-title { font-family: var(--font-serif); font-size: 20px; line-height: 1; }
.step-hint { font-size: 12.5px; color: var(--ink-500); padding: 2px 18px 0; }
.step-body { padding: 12px 18px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 11px 16px; }
.field.full { grid-column: 1 / -1; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-700); }
.field .sub { font-weight: 500; color: var(--ink-600); font-size: 11.5px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .prefix { position: absolute; left: 11px; color: var(--ink-500); font-family: var(--font-mono); font-size: 13px; }
.input-wrap.has-prefix input { padding-left: 26px; }
input[type="number"], input[type="text"], input[type="date"], select {
  width: 100%; font-family: var(--font-mono); font-size: 14px; color: var(--ink-900);
  background: var(--ink-50); border: 1px solid var(--ink-200); border-radius: 8px; padding: 9px 11px; outline: none;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease), background .12s var(--ease);
}
input:focus, select:focus { border-color: var(--red-500); background: #fff; box-shadow: 0 0 0 3px var(--red-50); }
select { font-family: var(--font-sans); cursor: pointer; }

.seg { display: flex; gap: 4px; background: var(--ink-100); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; appearance: none; border: 0; background: transparent; font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; color: var(--ink-600); padding: 7px 8px; border-radius: 7px; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink-900); box-shadow: var(--shadow); }

.derived { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 9px 12px; background: var(--jade-50); border: 1px solid #d7e7e1; border-radius: 8px; }
.derived.warn { background: #FFF7E8; border-color: #F0E0BA; }
.derived .k { color: var(--ink-700); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.derived .v { font-family: var(--font-mono); font-weight: 700; }
.pill { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--ink-900); color: #fff; }
.pill.jade { background: var(--jade); }

details.explain { grid-column: 1/-1; font-size: 12.5px; }
details.explain summary { cursor: pointer; color: var(--red-600); font-weight: 600; list-style: none; }
details.explain summary::before { content: "ⓘ "; }
details.explain .tiers { margin-top: 8px; border-top: 1px dashed var(--ink-200); }
.tier-row { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 12px; padding: 4px 0; color: var(--ink-600); }
.tier-row.total { border-top: 1px solid var(--ink-200); margin-top: 2px; color: var(--ink-900); font-weight: 700; }

.timeline { grid-column: 1/-1; }
.tl-bar { display: flex; height: 30px; border-radius: 7px; overflow: hidden; border: 1px solid var(--ink-200); }
.tl-seg { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; transition: width .3s var(--ease); }
.tl-seg.construct { background: var(--ink-500); }
.tl-seg.rent { background: var(--jade); }
.tl-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--ink-600); margin-top: 6px; flex-wrap: wrap; }
.tl-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Result pane (right, scrolls) */
.result-pane { overflow-y: auto; min-height: 0; padding: 20px 18px 40px; border-left: 1px solid var(--ink-200); background: var(--ink-50); display: flex; flex-direction: column; gap: 14px; }

/* Light card so black annotation ink stays legible on it (Thomas pitches in black). */
.result-card { background: var(--paper); color: var(--ink-900); border: 1px solid var(--ink-200); border-top: 3px solid var(--ink-900); border-radius: 14px; padding: 18px 20px 20px; box-shadow: var(--shadow); }
.result-card .label { font-size: 12px; color: var(--ink-500); text-transform: uppercase; letter-spacing: .6px; }
.headline { font-family: var(--font-mono); font-weight: 700; font-size: 33px; line-height: 1.05; margin: 4px 0 2px; transition: color .2s var(--ease); }
.headline.profit { color: var(--profit); } .headline.loss { color: var(--loss); }
.sub-metric { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--ink-100); font-size: 13.5px; color: var(--ink-700); }
.sub-metric .v { font-family: var(--font-mono); font-weight: 600; color: var(--ink-900); }
.sub-metric .v.profit { color: var(--profit); } .sub-metric .v.loss { color: var(--loss); }

.breakdown { background: var(--paper); border: 1px solid var(--ink-200); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.breakdown h3 { font-family: var(--font-serif); font-size: 18px; font-weight: 400; margin-bottom: 4px; }
.bd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.bd-head h3 { margin: 0; }
.line { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--ink-100); }
.line:last-child { border-bottom: 0; }
.line .k { color: var(--ink-600); } .line .v { font-family: var(--font-mono); font-weight: 600; }
.line.neg .v { color: var(--loss); } .line.pos .v { color: var(--profit); }
.line.subtotal { border-top: 1.5px solid var(--ink-900); border-bottom: 0; margin-top: 4px; font-weight: 700; }
.line.subtotal .k { color: var(--ink-900); font-weight: 700; }
.line.group-head { border-bottom: 0; padding: 12px 0 2px; }
.line.group-head .k { font-family: var(--font-serif); font-size: 15px; color: var(--ink-900); }
.line.group-head .note { font-size: 11px; color: var(--ink-500); font-family: var(--font-mono); }
.omitted-tag { font-size: 10.5px; font-weight: 700; color: var(--red-600); background: var(--red-50); padding: 1px 6px; border-radius: 999px; margin-left: 6px; }
.bd-note { font-size: 11px; color: var(--ink-500); line-height: 1.5; margin-top: 10px; }
.bd-note + .bd-note { margin-top: 6px; }
.bd-note .omitted-tag { margin-left: 0; margin-right: 5px; }

/* Side-by-side comparison table (compare mode) */
.cmp-table { background: var(--paper); border: 1px solid var(--ink-200); border-radius: 12px; padding: 14px 16px 14px; box-shadow: var(--shadow); }
.cmp-table h3 { font-family: var(--font-serif); font-size: 18px; font-weight: 400; margin-bottom: 6px; }
.cmp-row { display: grid; grid-template-columns: 1fr minmax(70px, auto) minmax(70px, auto); gap: 8px; align-items: baseline; font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--ink-100); }
.cmp-row:last-of-type { border-bottom: 0; }
.cmp-row .ci { color: var(--ink-600); }
.cmp-row .cv { font-family: var(--font-mono); font-weight: 600; text-align: right; white-space: nowrap; }
.cmp-row .cv.pos { color: var(--profit); } .cmp-row .cv.neg { color: var(--loss); }
.cmp-row.head { border-bottom: 1px solid var(--ink-200); }
.cmp-row.head .ci { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-500); }
.cmp-row.head .cv { font-family: var(--font-sans); font-weight: 700; color: var(--ink-900); }
.cmp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.cmp-row.grp { border-bottom: 0; padding: 10px 0 1px; }
.cmp-row.grp .ci { font-family: var(--font-serif); font-size: 14px; color: var(--ink-900); }
.cmp-row.sub { border-top: 1px solid var(--ink-300); border-bottom: 0; margin-top: 2px; }
.cmp-row.sub .ci { font-weight: 700; color: var(--ink-800); }
.cmp-row.total { border-top: 1.5px solid var(--ink-900); border-bottom: 0; margin-top: 4px; padding-top: 7px; }
.cmp-row.total .ci { font-weight: 800; color: var(--ink-900); font-size: 13px; }
.cmp-row.total .cv { font-weight: 800; font-size: 13.5px; }
.cmp-row .cv.win { background: var(--jade-50); border-radius: 5px; padding: 1px 5px; margin: -1px -5px; }
.cmp-omit { color: var(--red-600); font-weight: 700; margin-left: 2px; }
.cmp-table-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cmp-table-head h3 { margin: 0; }
.cmp-expand { appearance: none; border: 1px solid var(--ink-200); background: var(--ink-50); border-radius: 7px; font-family: var(--font-sans); font-size: 12px; font-weight: 600; padding: 5px 10px; cursor: pointer; color: var(--ink-700); }
.cmp-expand:hover { background: var(--ink-100); border-color: var(--ink-300); }
.cmp-type { display: block; font-family: var(--font-sans); font-size: 10px; font-weight: 600; color: var(--ink-500); text-transform: none; letter-spacing: 0; margin-top: 1px; }

/* Expand modal */
.cmp-modal { position: fixed; inset: 0; z-index: 1500; display: none; align-items: flex-start; justify-content: center; padding: 24px; background: rgba(20,17,16,.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); overflow: auto; }
.cmp-modal.show { display: flex; }
.cmp-modal-card { background: var(--paper); border-radius: 16px; width: 100%; max-width: 880px; box-shadow: 0 22px 60px rgba(0,0,0,.35); overflow: hidden; margin: auto; }
.cmp-modal-bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--ink-200); position: sticky; top: 0; background: var(--paper); }
.cmp-modal-title { font-family: var(--font-serif); font-size: 21px; }
.cmp-modal-close { appearance: none; border: 1px solid var(--ink-200); background: var(--ink-50); width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 16px; color: var(--ink-700); }
.cmp-modal-close:hover { background: var(--ink-100); }
.cmp-modal-body { padding: 20px 24px 26px; }
.cmp-modal-body .cmp-table { border: 0; box-shadow: none; padding: 0; }
.cmp-modal-body .cmp-row { grid-template-columns: 1fr minmax(140px, auto) minmax(140px, auto); font-size: 14.5px; padding: 8px 0; }
.cmp-modal-body .cmp-row.head .ci { font-size: 12px; }
.cmp-modal-body .cmp-row.grp .ci { font-size: 17px; }
.cmp-modal-body .cmp-row.total .ci { font-size: 16px; } .cmp-modal-body .cmp-row.total .cv { font-size: 17px; }
.cmp-modal-body .cmp-type { font-size: 11px; }
/* single-property breakdown, enlarged + centered in the modal */
.cmp-modal-body .breakdown { border: 0; box-shadow: none; padding: 0; max-width: 560px; margin: 0 auto; }
.cmp-modal-body .breakdown .bd-head { display: none; }
.cmp-modal-body .breakdown .line { font-size: 14.5px; padding: 8px 0; }
.cmp-modal-body .breakdown .line.group-head .k { font-size: 16px; }
.cmp-modal-body .breakdown .line.subtotal .k, .cmp-modal-body .breakdown .line.subtotal .v { font-size: 15px; }

/* ── Touch devices (iPad, phone): comfortable ≥44px tap targets ───────── */
@media (pointer: coarse) {
  input[type="number"], input[type="text"], input[type="date"], select { min-height: 44px; }
  .seg button { min-height: 42px; }
  .tab { min-height: 40px; }
  .rail-item { min-height: 44px; }
  .act { min-height: 42px; }
  .swatch { width: 28px; height: 28px; }
  .atool { min-height: 40px; min-width: 40px; }
}

/* ── Polish ──────────────────────────────────────────────────────────── */
/* Typography: balanced serif headings, tabular figures so columns align. */
.step-title, .breakdown h3, .cmp-table h3, .cmp-modal-title, .onboard-title { text-wrap: balance; }
.headline, .sub-metric .v, .line .v, .cmp-row .cv, .derived .v, .cmp-card .big,
input[type="number"], input[type="text"], input[type="date"] { font-variant-numeric: tabular-nums; }

/* Keyboard focus: one consistent ring on every control (was inputs only). */
.seg button:focus-visible, .tab:focus-visible, .rail-item:focus-visible, .act:focus-visible,
.atool:focus-visible, .swatch:focus-visible, .cmp-expand:focus-visible, .cmp-modal-close:focus-visible,
.tab .x:focus-visible { outline: 2px solid var(--red-500); outline-offset: 2px; border-radius: 7px; }

/* The result figure "pops" when it changes — clearly visible, the number feels alive. */
@keyframes tick {
  0% { transform: scale(1); }
  28% { transform: scale(1.09); filter: brightness(1.35); }
  100% { transform: scale(1); filter: brightness(1); }
}
.headline.tick { animation: tick .34s var(--ease); transform-origin: left center; }

/* Overlays ease in rather than snapping. */
@keyframes overlayIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.cmp-modal.show .cmp-modal-card, .onboard.show .onboard-card { animation: overlayIn .2s var(--ease); }

/* Respect the user's reduced-motion preference — kill all motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp-card { background: var(--paper); border: 1px solid var(--ink-200); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); position: relative; }
.cmp-card.win { border-color: var(--jade); box-shadow: 0 0 0 2px var(--jade-50), var(--shadow); }
.cmp-card .badge { font-size: 11px; font-weight: 700; color: var(--ink-500); display: flex; align-items: center; gap: 6px; }
.cmp-card .win-flag { position: absolute; top: -9px; right: 12px; background: var(--jade); color: #fff; font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.cmp-card .big { font-family: var(--font-mono); font-weight: 700; font-size: 22px; margin: 6px 0 2px; }
.cmp-card .big.profit { color: var(--profit); } .cmp-card .big.loss { color: var(--loss); }
.cmp-card .row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; border-top: 1px solid var(--ink-100); }
.cmp-card .row .v { font-family: var(--font-mono); font-weight: 600; }
.delta { font-size: 12px; color: var(--ink-500); font-family: var(--font-mono); }

/* ── Action bar ──────────────────────────────────────────────────────── */
.actionbar {
  min-height: var(--actionbar-h); flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; background: var(--paper); border-top: 1px solid var(--ink-200); z-index: 15;
  /* safe-area: clear the home indicator, but keep top/bottom symmetric so the
     buttons stay vertically centered in the bar */
  padding: env(safe-area-inset-bottom) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
}
.actions-left, .actions-right { display: flex; align-items: center; gap: 10px; }
.act { appearance: none; border: 1px solid var(--ink-200); background: var(--ink-50); color: var(--ink-800); font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 8px; cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease); }
.act:hover { background: var(--ink-100); border-color: var(--ink-300); }
.act[data-active="true"] { background: var(--red-500); border-color: var(--red-500); color: #fff; }
.mini-disclaimer { font-size: 11px; color: var(--ink-500); }
@media (max-width: 760px) { .mini-disclaimer { display: none; } }

/* ── Mobile: stacked but CONTAINED ───────────────────────────────────────
   The app stays exactly one viewport tall (no page scroll); the workspace is
   the single internal scroller with rail → flow → result stacked inside it.
   This keeps the document == viewport so iOS standalone (home-screen) launch
   has nothing oversized to scale — fixes the "zoom into top-left then snap"
   flash on cold launch. */
@media (max-width: 900px) {
  .app { height: 100dvh; }
  .workspace { display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .rail { flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--ink-200); position: sticky; top: 0; z-index: 10; padding: 10px; gap: 6px; background: var(--ink-50); }
  .rail-item { flex: 0 0 auto; }
  .rail-item { padding: 8px 12px; } /* labels stay visible on tablet for wayfinding */
  .flow, .result-pane { flex: 0 0 auto; overflow: visible; }
  .result-pane { border-left: 0; border-top: 1px solid var(--ink-200); }
  .step-body { grid-template-columns: 1fr; }
  .compare-grid { grid-template-columns: 1fr; }
}

/* ── Annotation overlay ──────────────────────────────────────────────── */
/* Canvas covers only the content area — NOT the toolbar or action bar — so their
   buttons (incl. the docked annotation tools) stay tappable while annotating. */
.annotate-layer { position: fixed; top: calc(var(--toolbar-h) + env(safe-area-inset-top)); left: 0; right: 0; bottom: calc(var(--actionbar-h) + env(safe-area-inset-bottom)); z-index: 1000; pointer-events: none; display: none; }
.annotate-layer.on { display: block; }
.annotate-layer.on #annotateCanvas { pointer-events: auto; cursor: crosshair; touch-action: none; }
#annotateCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Annotation tools dock as a light pill inside the (dark) app toolbar, in the
   empty space between the brand and the scenario tabs. Hidden until annotate
   mode is on. Top placement = Notability-style + clear of the iPad bottom
   gesture zone. Light pill keeps the black swatch and active tool obvious. */
.annotate-bar { display: none; align-items: center; gap: 8px; margin: 0 auto; padding: 6px; border-radius: 12px; background: var(--paper); border: 1px solid var(--ink-200); box-shadow: 0 2px 10px rgba(20,17,16,.22); }
.annotate-bar.show { display: flex; }
.annotate-bar .grp { display: flex; align-items: center; gap: 4px; padding-right: 8px; border-right: 1px solid var(--ink-200); }
.annotate-bar .grp:last-of-type { border-right: 0; }
.atool { appearance: none; border: 0; background: transparent; color: var(--ink-700); font-family: var(--font-sans); font-size: 15px; font-weight: 600; height: 32px; min-width: 32px; padding: 0 6px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; transition: background .12s var(--ease), color .12s var(--ease); }
.atool:hover { background: var(--ink-100); }
.atool.active { background: var(--ink-900); color: #fff; }  /* fill change (not just colour) — colour-blind safe */
.atool.done { padding: 0 14px; background: var(--ink-900); color: #fff; }
.swatch { width: 23px; height: 23px; border-radius: 50%; border: 2px solid rgba(20,17,16,.18); cursor: pointer; padding: 0; }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--ink-900); }

/* ── Add-to-Home-Screen onboarding ───────────────────────────────────── */
.onboard { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(20,17,16,.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.onboard.show { display: flex; }
.onboard-card { background: var(--paper); border-radius: 18px; max-width: 384px; width: 100%; padding: 24px; box-shadow: 0 22px 60px rgba(0,0,0,.35); text-align: center; }
.onboard-icon { border-radius: 15px; box-shadow: var(--shadow); }
.onboard-title { font-family: var(--font-serif); font-size: 24px; font-weight: 400; margin: 12px 0 6px; }
.onboard-sub { font-size: 13.5px; color: var(--ink-600); margin-bottom: 18px; line-height: 1.5; }
.onboard-steps { text-align: left; font-size: 13.5px; color: var(--ink-800); margin: 0 0 20px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 11px; line-height: 1.45; }
p.onboard-steps { display: block; }
.onboard-steps li { display: flex; gap: 10px; align-items: flex-start; }
.onboard-steps .num { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-900); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; font-family: var(--font-mono); margin-top: 1px; }
.onboard-steps strong { font-weight: 700; }
.ios-share { display: inline-grid; place-items: center; width: 23px; height: 23px; border: 1px solid var(--ink-300); border-radius: 6px; color: var(--red-500); vertical-align: -6px; }
.onboard-actions { display: flex; gap: 10px; justify-content: center; }
.act.primary { background: var(--red-500); border-color: var(--red-500); color: #fff; }
.act.primary:hover { background: var(--red-600); border-color: var(--red-600); }
.act.ghost { background: transparent; }
