/* Inkwell design system — Gemini Step 1 (2026-11-19), retokened for the
   Screen 01 rebuild (Gemini share 2026-11-22, screens 01/16/31) to the
   brief's locked tokens.
   Light: --bg #F6F3EC, --surface #FDFBF7, --paper2 #EFEAE0,
   --border #E5DFD3, --text #1A1917, --muted #6B655D, --accent #C85A32.
   Dark: --bg #141311, --surface #1E1C19, --border #2D2A26,
   --text #F2EEE6, --muted #A69F95, --accent #D96B43.
   Serif (Newsreader) for the wordmark and reading body; Inter for UI
   chrome; JetBrains Mono for ⌘K / ESC / zoom % / timers. Hairline
   borders, 10–14px card radii, 999px pills. No paper texture, no heavy
   boxes, no gradients, no glassmorphism. One responsive section at the
   end of the file (1024px tablet, 768px mobile); 44px touch targets on
   coarse pointers. */

:root{
  --font-ui:"Inter","Instrument Sans",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --font-display:"Newsreader",Georgia,"Times New Roman",serif;
  --font-reading:"Newsreader",Georgia,"Times New Roman",serif;
  --font-hand:"Newsreader",Georgia,serif;
  --font-mono:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,monospace;
  --bg:#F6F3EC;
  --bg-deep:#EDEBE4;
  --surface:#FDFBF7;
  --paper:#FFFFFF;
  --paper2:#EFEAE0;
  --paper-dark:#17171A;
  --text:#1A1917;
  --text-soft:#3F3F46;
  --muted:#6B655D;
  --border:#E5DFD3;
  --border-strong:#D4D0C8;
  --accent:#C85A32;
  --accent-text:#FFFFFF;
  --accent-soft:#F2DED8;
  --danger:#A02E24;
  --success:#3F5C46;
  --shadow-sheet:0 2px 0 rgba(24,24,27,.04),0 24px 48px -28px rgba(24,24,27,.45);
  --shadow-cover:0 12px 24px -16px rgba(24,24,27,.55);
  --shadow-modal:0 30px 80px -30px rgba(24,24,27,.65);
  --shadow-nav:0 18px 40px -32px rgba(24,24,27,.65),0 1px 0 rgba(24,24,27,.03);
  --radius-xs:6px;
  --radius-sm:10px;
  --radius-md:12px;
  --radius-lg:14px;
  --radius-pill:999px;
  --target-size:24px;
  --reader-fs:19px;
  --max:1240px;
  color-scheme:light dark;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#141311;
    --bg-deep:#0C0C0E;
    --surface:#1E1C19;
    --paper:var(--paper-dark);
    --paper-dark:#17171A;
    --paper2:#222228;
    --text:#F2EEE6;
    --text-soft:#C6C6CC;
    --muted:#A69F95;
    --border:#2D2A26;
    --border-strong:#3A3A42;
    --accent:#D96B43;
    --accent-text:#15100E;
    --accent-soft:#3B2722;
    --danger:#E08072;
    --success:#8FB59A;
    --shadow-sheet:0 2px 0 rgba(0,0,0,.3),0 24px 48px -24px rgba(0,0,0,.8);
    --shadow-cover:0 14px 28px -14px rgba(0,0,0,.8);
    --shadow-modal:0 30px 80px -30px rgba(0,0,0,.9);
    --shadow-nav:0 18px 40px -28px rgba(0,0,0,.9),0 1px 0 rgba(255,255,255,.04);
    color-scheme:dark;
  }
}
:root[data-theme="light"]{
  --bg:#F6F3EC; --bg-deep:#EDEBE4; --surface:#FDFBF7; --paper:#FFFFFF; --paper2:#EFEAE0;
  --text:#1A1917; --text-soft:#3F3F46; --muted:#6B655D; --border:#E5DFD3; --border-strong:#D4D0C8;
  --accent:#C85A32; --accent-text:#FFFFFF; --accent-soft:#F2DED8; --danger:#A02E24; --success:#3F5C46;
  --shadow-sheet:0 2px 0 rgba(24,24,27,.04),0 24px 48px -28px rgba(24,24,27,.45);
  --shadow-cover:0 12px 24px -16px rgba(24,24,27,.55);
  --shadow-modal:0 30px 80px -30px rgba(24,24,27,.65);
  --shadow-nav:0 18px 40px -32px rgba(24,24,27,.65),0 1px 0 rgba(24,24,27,.03);
  color-scheme:light;
}
:root[data-theme="dark"]{
  --bg:#141311; --bg-deep:#0C0C0E; --surface:#1E1C19; --paper:var(--paper-dark); --paper-dark:#17171A; --paper2:#222228;
  --text:#F2EEE6; --text-soft:#C6C6CC; --muted:#A69F95; --border:#2D2A26; --border-strong:#3A3A42;
  --accent:#D96B43; --accent-text:#15100E; --accent-soft:#3B2722; --danger:#E08072; --success:#8FB59A;
  --shadow-sheet:0 2px 0 rgba(0,0,0,.3),0 24px 48px -24px rgba(0,0,0,.8);
  --shadow-cover:0 14px 28px -14px rgba(0,0,0,.8);
  --shadow-modal:0 30px 80px -30px rgba(0,0,0,.9);
  --shadow-nav:0 18px 40px -28px rgba(0,0,0,.9),0 1px 0 rgba(255,255,255,.04);
  color-scheme:dark;
}

*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-ui);font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;overflow-x:hidden}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
button:disabled{opacity:.45;cursor:default}
a{color:var(--accent);text-underline-offset:2px}
::selection{background:var(--accent-soft);color:var(--text)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
h1,h2,h3,h4,h5,p{margin-top:0}
svg{display:inline-block}

.hidden{display:none!important}
.srOnly{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.iconSprite{position:absolute;width:0;height:0;overflow:hidden}
.ic{width:18px;height:18px;flex:0 0 auto;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;vertical-align:-.16em}
.ic-sm{width:15px;height:15px;stroke-width:1.8}
.ic-lg{width:22px;height:22px;stroke-width:1.6}
.runningHead{font-size:10px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);margin:0 0 8px}
.tool-label{font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);white-space:nowrap}
.kbd{font-size:12px;line-height:1.55;color:var(--muted);margin:0}
.badge{font-size:10px;letter-spacing:.1em;text-transform:uppercase;background:transparent;border:1px solid var(--border);padding:4px 7px;border-radius:var(--radius-xs);display:inline-block;color:var(--muted)}

/* ---------- controls ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;padding:0 14px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text);font-family:var(--font-ui);font-size:13px;font-weight:600;line-height:1;text-decoration:none;transition:background .15s ease,border-color .15s ease,color .15s ease}
.btn:hover{border-color:var(--text-soft)}
.btn:active{background:var(--paper2)}
.btn.primary{background:var(--text);color:var(--surface);border-color:var(--text)}
.btn.primary:hover{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
.btn.dark{background:var(--text);color:var(--surface);border-color:var(--text)}
.btn.small{min-height:32px;padding:0 10px;font-size:12px;gap:6px}
.btn.danger{color:var(--danger);border-color:var(--danger)}
.btn.danger:hover{background:var(--danger);color:#fff;border-color:var(--danger)}
:root[data-theme="dark"] .btn.danger:hover{color:#17171A}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .btn.danger:hover{color:#17171A}}
.btn.marked{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
.btn.marked:hover{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
.btn:disabled{opacity:.45;cursor:default}
.iconBtn{width:40px;height:40px;min-width:40px;min-height:40px;padding:0;border:1px solid transparent;border-radius:var(--radius-sm);background:transparent;color:var(--text);display:grid;place-items:center;transition:background .15s ease,border-color .15s ease}
.iconBtn:hover{background:var(--paper2);border-color:var(--border)}
.iconBtn:active{background:var(--border)}
select{min-height:38px;border:1px solid var(--border);border-radius:var(--radius-xs);background:var(--surface);color:var(--text);padding:0 10px;font-size:13px;font-weight:500}
select:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
input[type=range]{accent-color:var(--accent);min-height:28px}
input[type=checkbox],input[type=radio]{width:17px;height:17px;min-height:0;accent-color:var(--accent);flex:0 0 auto}
progress{width:100%;height:6px;accent-color:var(--accent)}

/* ---------- library frame ---------- */
.layout{max-width:var(--max);margin:0 auto;padding:28px 32px 124px}
.layout.shelf{max-width:1180px}
/* Sticky chrome is borderless: a translucent bar with a hairline under it,
   not a boxed panel (the old bordered boxes read 90s). */
.masthead{position:sticky;top:12px;z-index:50;display:grid;grid-template-columns:minmax(150px,1fr) minmax(280px,560px) minmax(150px,1fr);align-items:center;gap:16px;padding:10px 14px;background:var(--surface);background:color-mix(in srgb,var(--surface) 86%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:0;border-bottom:1px solid var(--border);border-radius:0;box-shadow:none}
.wordmark{display:flex;align-items:baseline;gap:12px;justify-self:start;color:var(--text);text-decoration:none;min-width:0}
.wordmarkName{font-family:var(--font-display);font-size:26px;font-weight:600;letter-spacing:-.03em;line-height:1}
.mastheadTools{display:flex;align-items:center;justify-self:end;gap:8px;flex:0 0 auto}
.installBtn{min-height:34px;padding:0 10px;font-size:11px;border-color:var(--border-strong)}
.installBtn .ic{width:14px;height:14px}
.saveFlag{font-size:11px;line-height:1.4;color:var(--muted);max-width:210px;text-align:right;white-space:nowrap}
.searchWrap{position:relative;min-width:0}
.search{display:flex;align-items:center;gap:10px;min-height:50px;padding:0 12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-pill);transition:border-color .15s ease,box-shadow .15s ease}
.search:focus-within{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft)}
.searchIcon{color:var(--muted)}
.search input{flex:1;min-width:0;height:48px;border:0;background:transparent;color:var(--text);font-size:15px;outline:none}
.search input:focus-visible{outline:none}
.search input::placeholder{color:var(--muted)}
.searchKbd{flex:0 0 auto;min-width:24px;min-height:24px;display:grid;place-items:center;border:1px solid var(--border);border-radius:var(--radius-xs);font-size:11px;line-height:1;color:var(--muted);padding:0 5px}
.shelfBar{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;margin-bottom:28px}
.chipRow{display:flex;align-items:flex-end;gap:8px;flex-wrap:wrap}
.chip{min-height:44px;padding:8px 14px;border:1px solid var(--border);border-radius:var(--radius-pill);background:var(--surface);color:var(--muted);font-size:13px;font-weight:600;line-height:1}
.chip:hover{color:var(--text);border-color:var(--border-strong)}
.chip.active{color:var(--surface);background:var(--text);border-color:var(--text)}
/* Mockup 11 (Pass 1 audit): on desktop the active filter is a white
   pill with a border and dark text, not a dark fill; phones keep the
   dark fill (mockup 15). */
@media (min-width:1025px){.chip.active{background:var(--surface);color:var(--text);border-color:var(--border-strong)}}
.chip.dashed{border:1px dashed var(--border-strong);padding:8px 12px;color:var(--text)}
.libHint{font-size:11px;line-height:1.5;color:var(--muted);text-align:right;padding-bottom:12px;margin:0}

/* ---------- empty state ---------- */
.empty{padding:64px 24px;text-align:center;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);margin-bottom:28px}
.emptyIcon{width:54px;height:54px;margin:0 auto 18px;border:1px solid var(--border);border-radius:50%;display:grid;place-items:center;color:var(--accent)}
.emptyIcon .ic{width:24px;height:24px}
.empty h3{font-family:var(--font-ui);font-size:24px;font-weight:700;letter-spacing:-.02em;margin:0 0 8px}
.empty p{font-family:var(--font-ui);font-size:15px;line-height:1.6;color:var(--muted);max-width:44ch;margin:0 auto 20px}
.emptyActions{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-top:4px}

/* ---------- shelf ---------- */
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px 20px}
/* Mockups 11/15 (Pass 1 audit): the card is a white frame — 1px border,
   ~14px radius — with the coloured cover inside it and the progress bar
   + meta BELOW the cover, not on it. Desktop shows the title on the
   cover; at ≤1024px the title moves below the cover in serif, with the
   type label above the bar (mockup 15). Card guide: <article> root,
   regions in source order — media (the cover button), then the
   below-cover content; the ··· menu stays a sibling control, not
   nested inside the open button. */
.bookCard{position:relative;min-width:0;background:var(--surface);border:1px solid var(--border);border-radius:14px;overflow:hidden;transition:transform .16s ease,box-shadow .16s ease}
.bookCard:hover{transform:translateY(-2px);box-shadow:0 20px 34px -18px rgba(24,32,43,.35)}
.book{position:relative;display:flex;width:100%;min-height:0;aspect-ratio:4/3;padding:0;border:0;border-radius:0;overflow:hidden;text-align:left;box-shadow:inset 0 0 0 1px rgba(255,255,255,.09)}
.book:hover{transform:translateY(0);box-shadow:inset 0 0 0 1px rgba(255,255,255,.14)}
.book:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.bookSpine{width:11px;flex:0 0 auto;box-shadow:inset -1px 0 0 rgba(255,255,255,.18)}
.bookFace{flex:1;min-width:0;display:flex;flex-direction:column;justify-content:flex-end;padding:18px 42px 16px 16px}
.bookTitle{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;font-family:var(--font-ui);font-size:22px;font-weight:700;line-height:1.15;letter-spacing:-.02em;overflow-wrap:anywhere}
.bookTitleBelow{display:none}
.bookKindBelow{display:none}
.bookBelow{display:flex;flex-direction:column;gap:6px;padding:12px 14px 14px}
.bookMeta{margin:0;padding:0;font-size:11px;line-height:1.55;letter-spacing:.01em;color:var(--muted)}
.bookMeta span{display:block}
@media (max-width:1024px){
  .bookTitleCover{display:none}
  .bookTitleBelow{display:-webkit-box;font-family:var(--font-display);font-size:18px;font-weight:600;line-height:1.25;letter-spacing:0}
  .bookKindBelow{display:block;font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
  .bookMeta{display:none}
  .bookFace{padding:14px 34px 12px 12px}
}
.bookMenu{position:absolute;top:10px;right:10px;width:30px;height:30px;min-height:30px;padding:0;border:1px solid rgba(255,255,255,.28);border-radius:var(--radius-xs);background:rgba(0,0,0,.14);color:inherit;display:grid;place-items:center;z-index:2}
.bookMenu:hover{background:rgba(0,0,0,.3)}
.bookMenu::after{content:"";position:absolute;inset:-8px}
.bookMenu .ic{width:16px;height:16px}
.bookActions{position:absolute;top:46px;right:8px;width:190px;z-index:25;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);padding:4px;display:none;flex-direction:column}
.bookCard.menuOpen .bookActions{display:flex}
.bookActions button{display:flex;align-items:center;gap:8px;width:100%;min-height:38px;padding:9px 10px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--text);font-size:13px;font-weight:500;text-align:left}
.bookActions button:hover{background:var(--paper2)}
.bookActions button.danger{color:var(--danger)}
.bookActions .ic{width:15px;height:15px;color:var(--muted)}
.bookActions button.danger .ic{color:var(--danger)}

/* ---------- library utilities, about, footer ---------- */
.listRow{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:9px 0;border-bottom:1px solid var(--border);font-size:13px}
.listRow:last-child{border-bottom:0}
.listRow b{font-weight:600;white-space:nowrap}


/* ---------- editor frame ---------- */
.editorTop{position:sticky;top:10px;z-index:30;display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;background:var(--surface);background:color-mix(in srgb,var(--surface) 86%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:0;border-bottom:1px solid var(--border);border-radius:0}
.titleField{flex:1;min-width:180px}
#noteTitle{width:100%;padding:2px 4px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--text);font-family:var(--font-ui);font-size:19px;font-weight:700;line-height:1.25;letter-spacing:-.01em}
#backToReadingBtn .backShort{display:none}
#noteTitle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* ---------- writing rail ---------- */
/* Floating rounded toolbar (borderless, soft shadow) instead of a
   full-width bordered strip — the Notes-App reference. */
.toolbar{position:sticky;top:78px;z-index:25;display:flex;flex-direction:column;align-items:stretch;gap:0;margin-top:10px;padding:4px 6px 0;background:var(--surface);background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:0;border-bottom:1px solid var(--border);border-radius:0;box-shadow:none}
.tbRow{display:flex;align-items:center;gap:2px;width:100%;min-height:42px;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
.tbRow::-webkit-scrollbar{display:none}
.tbRowTools .tool{width:38px;height:38px;min-height:38px;padding:0;border:1px solid transparent;border-radius:var(--radius-xs);background:transparent;color:var(--text);display:grid;place-items:center;flex:0 0 auto}
.tbRowTools .tool .ic{width:19px;height:19px}
.tool:hover{background:var(--paper2)}
.tool.active{background:var(--text);border-color:var(--text);color:var(--surface)}
.tool.active:hover{background:var(--text)}
.tbDivider{width:1px;height:22px;background:var(--border);margin:0 5px;flex:0 0 auto}
.tbBoardBtn{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;min-height:34px;padding:0 10px;border:1px solid var(--border);border-radius:var(--radius-xs);background:transparent;color:var(--text);font-size:12px;font-weight:600;white-space:nowrap}
.tbBoardBtn:hover{background:var(--paper2)}
.tbBoardBtn[aria-pressed="true"]{background:var(--text);border-color:var(--text);color:var(--surface)}
.tbMenuBtn{display:inline-flex;align-items:center;gap:5px;flex:0 0 auto;min-height:34px;padding:0 8px;border:1px solid transparent;border-radius:var(--radius-xs);background:transparent;color:var(--text);font-size:12px;font-weight:600;white-space:nowrap}
.tbMenuBtn:hover{background:var(--paper2)}
.tbMenuBtn[aria-expanded="true"]{background:var(--text);border-color:var(--text);color:var(--surface)}
.tbRowTools .iconBtn{width:36px;height:36px;min-width:36px;min-height:36px;flex:0 0 auto}
.tbRowOpts{border-top:1px solid var(--border);margin-top:4px;padding:4px 0;gap:10px;min-height:42px}
.sizeGroup{display:inline-flex;align-items:center;gap:8px;flex:0 0 auto;white-space:nowrap;min-height:34px}
.sizeGroup input[type=range]{width:96px}
.sizeWord{font-size:11px;font-weight:600;white-space:nowrap;color:var(--text)}
.swatch{position:relative;width:24px;height:24px;min-height:24px;padding:0;border:1px solid rgba(0,0,0,.18);border-radius:50%;flex:0 0 auto;box-shadow:0 0 0 1px transparent}
.swatch::after{content:"";position:absolute;inset:-10px}
.swatch.active{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--text)}
input[type=color].colorPick{width:28px;height:28px;min-height:28px;flex:0 0 auto;padding:2px;border:1px solid var(--border);border-radius:50%;background:var(--surface);cursor:pointer}
.statusBar{display:flex;align-items:center;gap:14px;padding:5px 4px;border-top:1px solid var(--border);font-size:11px;line-height:1.3;color:var(--muted);flex-wrap:wrap;min-width:0}
.statusBar::-webkit-scrollbar{display:none}
.statusBar b{color:var(--text);font-weight:600}
.statusSpacer{flex:1}

/* ---------- tool popovers ---------- */
.toolPop{position:absolute;left:6px;right:6px;top:calc(100% + 6px);z-index:70;max-height:46vh;overflow:auto;padding:14px 16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);display:none}

.toolPop.open{display:block}
.toolPop h5{font-size:10px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);margin:0 0 8px}
.toolPop .popRow{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 0;border-top:1px solid var(--border)}
.toolPop .popRow:first-of-type{border-top:0}
.toolPop label{display:flex;align-items:center;gap:7px;font-size:13px;font-weight:500}
.toolPop .popRow input[type=range]{flex:1;min-width:110px}
.popChecks{gap:16px!important}
.toolOptSection{display:none}
.toolOptSection.show{display:block}
#toolOptsPop .kbd{display:block;font-size:12px;line-height:1.55;margin:6px 0 0}

/* ---------- editor workspace ---------- */
.editorWrap{display:grid;grid-template-columns:188px minmax(0,1fr) 252px;gap:24px;align-items:start;margin-top:18px}
/* The editor gets a wider frame than the shelf so the page takes more of
   a desktop screen (the 1240px cap left the stage at ~54% of 1280px). */
body.inEditor #mainLayout{max-width:1440px}
.editorWrap>*{min-width:0}
.panel{background:transparent;border:0;border-top:1px solid var(--border);border-radius:0;padding:12px 0 0}
.panel h4{font-size:10px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);margin:0 0 10px}
.panel .panelSub{margin-top:20px}
.panel .kbd{font-size:12px;line-height:1.6}
.panelWide{width:100%;justify-content:center}
.addPageBtn{width:100%;justify-content:center;margin-top:8px}
.checkRow{display:flex;align-items:center;gap:8px;padding:7px 0;font-size:13px}
.panelBtnRow{display:flex;gap:6px;flex-wrap:wrap}
.helpBox{margin-top:14px;border-top:1px solid var(--border);padding-top:4px}
.helpBox summary{display:flex;align-items:center;gap:8px;min-height:40px;padding:8px 0;font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);cursor:pointer}
.helpBox p{font-size:12px;line-height:1.65;color:var(--muted);margin:4px 0 10px}
.helpBox b{color:var(--text);font-weight:600}
#pageList{display:block}
.pageThumb{margin-bottom:10px;padding:6px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xs);cursor:pointer}
.pageThumb.active{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.pageThumb canvas{display:block;width:100%;height:auto;background:#fff;border-radius:1px}
.pageThumb .ptRow{display:flex;justify-content:space-between;align-items:center;gap:4px;flex-wrap:wrap;margin-top:6px}
.pageThumb .ptRow .kbd{font-size:10px;white-space:nowrap}
.ptBtns{display:inline-flex;gap:2px;flex-wrap:nowrap}
.miniBtn{position:relative;display:grid;place-items:center;min-width:24px;min-height:24px;padding:0;border:1px solid transparent;border-radius:var(--radius-xs);background:transparent;color:var(--muted)}
.miniBtn:hover{background:var(--paper2);border-color:var(--border);color:var(--text)}
.miniBtn::after{content:"";position:absolute;inset:-10px}
.miniBtn .ic{width:14px;height:14px}
.stageWrap{display:grid;gap:16px}
/* minmax(0,1fr), not 1fr: a bare 1fr track's minimum is its content, and
   the notebook column's status bar (~600px of nowrap spans) forced the
   first track to ~602px at desktop, squeezing the split pane to ~110px.
   With a 0 minimum both halves share the stage equally at every width;
   the status bar scrolls internally, everything else wraps or is 100%. */
.stageWrap.split{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
.zoomScroll{overflow:auto;border-radius:var(--radius-xs)}
/* Clear of the floating pill toolbar: the pill sits 12px down from the
   stage top and is ~54px tall, so without this the page title hides
   underneath it at scroll position 0. The margin scrolls with the page. */
.canvasShell{position:relative;overflow:hidden;background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-sheet);margin-top:76px}
.canvasStack{position:relative;width:100%}
.canvasStack canvas{display:block;width:100%;height:auto}
#bgCanvas{position:relative}
#hiCanvas,#inkCanvas,#liveCanvas{position:absolute;inset:0;height:100%}
#liveCanvas{pointer-events:none}
#inkCanvas{touch-action:none;cursor:crosshair}
#penHoverRing{position:fixed;left:0;top:0;z-index:9999;pointer-events:none;border:2px solid var(--accent);border-radius:50%;opacity:0;transition:opacity 120ms ease-out;will-change:transform}
/* Pen-only toggle in the Parallel Read ink bar: same 44px tap area as the
   editor pill tools (38px visual + ::after), on coarse pointers. */
#prInkBar [data-pen-only-btn]{position:relative}
@media (pointer:coarse){ #prInkBar [data-pen-only-btn]::after{content:"";position:absolute;inset:-3px} }
.noteBlock{margin-top:16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);overflow:hidden}
.noteBlockHead{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:8px 14px;border-bottom:1px solid var(--border)}
.noteBlockHead .runningHead{margin:0}
.textArea{width:100%;min-height:120px;padding:14px 16px;border:0;background:var(--surface);color:var(--text);font-family:var(--font-display);font-size:18px;line-height:1.7;resize:vertical;outline:none}
.textArea:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.studioRow{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:12px;padding-top:12px;border-top:1px solid var(--border)}
.studioRow .runningHead{margin:0}
.studioRow .kbd{flex:1;min-width:200px}
#selBar{display:none;align-items:center;gap:6px;flex-wrap:wrap;margin-top:10px;padding:8px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xs)}
#selBar.open{display:flex}
#selBar .kbd{font-size:11px}
.splitPane{overflow:auto;max-height:640px;padding:20px;background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-sm);margin-top:76px;touch-action:pan-x pan-y}
/* Split View alignment: in split mode the pane is a column — the book
   fills the body and the controls sit in a footer UNDER it, so the page
   starts at the pane's top edge, level with the notebook page (both
   clear the pill with the same 76px). The pane's height is synced to
   the notebook page in JS; align-self:start keeps it from stretching
   to the whole notebook column. */
.stageWrap.split .splitPane{max-height:none;padding:0;display:flex;flex-direction:column;overflow:hidden;align-self:start}
.splitPaneBody{flex:1 1 auto;min-height:0;overflow:auto;padding:0 12px 12px}
.splitPaneFoot{flex:none;border-top:1px solid var(--border);background:var(--surface);padding:6px 8px;display:flex;flex-direction:column;gap:6px}
.splitPaneFoot .splitHead{margin-bottom:0;flex-wrap:nowrap}
.splitPaneFoot .splitPdfNav,.splitPaneFoot .splitEpubNav{margin-bottom:0;flex-wrap:nowrap}
.splitEpubNav{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 10px}
.splitEpubNav .kbd{flex:1;text-align:center}
.splitPaneFoot .btn{min-width:28px;padding:0 4px}
.splitPaneFoot .splitZoomGroup .btn{min-width:28px}
.splitHead .badge{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}

/* ---------- P3: Split View icon rail (mockup 13) ----------
   Desktop only (>=1025px): when Split View is on, both sidebars collapse
   into a 48px icon rail at the far left and the stage takes the rest, so
   notebook + reader share a clean 50/50 split. Explicit tracks per the
   css-layout guide (grid-template-areas, one 48px track + one flexible
   minmax(0,1fr) track so the stage can shrink below its content width).
   Each rail button opens its panel as an overlay drawer while split stays
   on. At <=1024px there is no rail: the stacked rails simply hide while
   split is on. */
.splitRail{display:none}
.railBackdrop{display:none}
@media (min-width:1025px){
  body.splitOn .editorWrap{grid-template-columns:48px minmax(0,1fr);grid-template-areas:"rail stage"}
  body.splitOn #splitRail{display:flex;grid-area:rail;flex-direction:column;align-items:center;gap:8px;padding-top:4px}
  body.splitOn #stageWrap{grid-area:stage}
  body.splitOn #pagesPanel,body.splitOn #linksPanel{display:none}
  body.splitOn #pagesPanel.railDrawer,body.splitOn #linksPanel.railDrawer{display:block;position:fixed;left:48px;top:0;bottom:0;z-index:70;width:300px;max-width:calc(100vw - 48px);overflow:auto;background:var(--surface);border-right:1px solid var(--border);padding:14px;overscroll-behavior:contain}
  .railBtn{display:grid;place-items:center;width:44px;height:44px;min-width:44px;min-height:44px;padding:0;border:1px solid transparent;border-radius:var(--radius-xs);background:transparent;color:var(--muted);cursor:pointer}
  .railBtn:hover{background:var(--paper2);color:var(--text)}
  .railBtn[aria-pressed="true"]{background:var(--surface);border-color:var(--border);color:var(--accent)}
  .railBtn .ic{width:20px;height:20px}
  .railBackdrop{display:block;position:fixed;inset:0;z-index:65;background:rgba(0,0,0,.18)}
  .railBackdrop.hidden{display:none}
}
@media (max-width:1024px){
  body.splitOn #pagesPanel,body.splitOn #linksPanel{display:none}
}

/* ---------- P3: Focus Mode (mockup 3) ----------
   A dark, chrome-free view over the same editor: only <- Exit Focus, the
   top-right Focus pill (time, session, Pause/Resume + progress ring), the
   centered canvas + Written Notes, and the audio pill while recording.
   No DOM moves and no second canvas — body.focusMode hides the chrome and
   re-grids the stage (canvas left, notes right >=1025px; stacked below on
   smaller widths), per content-first-noise-reduction: keep the frame small,
   move it out of the way, show secondary content only when asked. The page
   itself keeps the user's paper and ink so notes stay readable; only the
   frame around it goes dark, as in the mockup. */
.focusBar{display:none}
.focusAudioPill{display:none}
body.focusMode{background:#0d0d0f}
body.focusMode .editorTop,body.focusMode #pagesPanel,body.focusMode #linksPanel,body.focusMode #splitRail,body.focusMode #mainToolbar,body.focusMode #statusBar,body.focusMode #pageNavFab,body.focusMode #zoomFab,body.focusMode #layerChip,body.focusMode #selBar,body.focusMode #setSquare,body.focusMode #floatingBoard,body.focusMode #boardMini,body.focusMode #tableHost{display:none!important}
body.focusMode .editorWrap{grid-template-columns:minmax(0,1fr);max-width:1180px;margin-inline:auto}
body.focusMode .stageWrap{grid-template-columns:minmax(0,1fr) 320px;gap:24px;align-items:start}
body.focusMode #zoomScroll{grid-column:1;grid-row:1;min-width:0}
body.focusMode .notesAudioRow{grid-column:2;grid-row:1;flex-direction:column;gap:12px}
body.focusMode .notesAudioRow .noteBlock{margin-top:0}
body.focusMode .notesAudioRow .studioRow{flex:none;width:100%;margin-top:0}
body.focusMode .canvasShell{margin-top:0;background:#17171a}
body.focusMode .notesAudioRow .noteBlock,body.focusMode .notesAudioRow .studioRow{background:#17171a;border-color:#2a2a30;color:#ecebe6}
body.focusMode .notesAudioRow .noteBlock .runningHead,body.focusMode .notesAudioRow .studioRow .runningHead,body.focusMode .notesAudioRow .kbd,body.focusMode #noteText{color:#ecebe6}
body.focusMode #noteText{background:transparent}
body.focusMode .focusBar{display:flex;position:fixed;top:0;left:0;right:0;z-index:80;justify-content:space-between;align-items:center;gap:12px;padding:12px 16px;pointer-events:none}
body.focusMode .focusBar>*{pointer-events:auto}
.focusExit{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 14px;border:1px solid transparent;border-radius:var(--radius-xs);background:transparent;color:#9a9aa2;font-size:14px;font-weight:600;cursor:pointer}
.focusExit:hover{color:#ecebe6}
.focusPill{display:inline-flex;align-items:center;gap:10px;min-height:44px;padding:0 12px 0 16px;border:1px solid #2a2a30;border-radius:999px;background:#17171a;color:#ecebe6;font-size:13px;font-weight:600;cursor:pointer;box-shadow:var(--shadow-modal)}
.focusRing{flex:0 0 auto;transform:rotate(-90deg)}
.focusRingBg{fill:none;stroke:#2a2a30;stroke-width:2.5}
.focusRingFg{fill:none;stroke:#e06d44;stroke-width:2.5;stroke-linecap:round}
body.focusMode .focusAudioPill{position:fixed;left:50%;bottom:calc(18px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:80;display:inline-flex;align-items:center;gap:10px;min-height:44px;padding:0 16px;border:1px solid #2a2a30;border-radius:999px;background:#17171a;color:#ecebe6;font-size:13px;font-weight:600;box-shadow:var(--shadow-modal)}
.focusRecDot{width:10px;height:10px;border-radius:50%;background:#e06d44;flex:0 0 auto}
.focusWave{display:inline-flex;align-items:flex-end;gap:2px;height:16px}
.focusWave i{width:2px;background:#e06d44;border-radius:1px;animation:focusWave 1s ease-in-out infinite}
.focusWave i:nth-child(1){height:6px}
.focusWave i:nth-child(2){height:12px;animation-delay:.15s}
.focusWave i:nth-child(3){height:16px;animation-delay:.3s}
.focusWave i:nth-child(4){height:10px;animation-delay:.45s}
.focusWave i:nth-child(5){height:7px;animation-delay:.6s}
@keyframes focusWave{0%,100%{transform:scaleY(.5)}50%{transform:scaleY(1)}}
@media (max-width:1024px){
  body.focusMode .stageWrap{grid-template-columns:minmax(0,1fr)}
  body.focusMode #zoomScroll{grid-column:1;grid-row:1}
  body.focusMode .notesAudioRow{grid-column:1;grid-row:2}
}
/* Narrow panes: the title badge is dropped so Change + zoom fit on one
   row — with it, the footer wrapped to three rows at phone widths and
   the page shrank. The book is the one just picked; its title is also
   in the picker. */
@media (max-width:600px){ .splitPaneFoot .splitHead .badge{display:none} }
/* Same clearance as .canvasShell: the floating pill sits over the top of
   the stage, and without this it covers the pane's book badge and
   "Change book" button on narrow widths. */
.splitPane h3{font-family:var(--font-display);font-size:24px;font-weight:600;letter-spacing:-.02em;margin:0 0 8px}
.splitPane p{font-family:var(--font-display);font-size:15px;line-height:1.7}
.splitHead{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin-bottom:8px}
/* Split View PDF page: Prev / Page N of M / Next above the drawn page.
   The page itself reuses the reader's .pdfHolder, so it gets the same
   canvas sizing, text layer and density cap as the main reader. */
.splitPdfNav{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 10px}
.splitPdfNav .kbd{flex:1;text-align:center}
.splitZoomGroup{display:flex;align-items:center;gap:6px;margin-left:auto}
.splitZoomGroup .btn{min-width:36px}
#tableHost .panel{margin-top:14px;padding:14px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm)}
table.inkTable{width:100%;border-collapse:collapse}
table.inkTable td,table.inkTable th{border:1px solid var(--border);padding:8px;text-align:left;min-width:70px;font-size:13px}
table.inkTable td:focus{outline:2px solid var(--accent);outline-offset:-2px}
#tableHost .btn.small{margin-top:2px}

/* ---------- reader ---------- */
.readerTop{position:sticky;top:10px;z-index:30;display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;margin-bottom:10px;background:var(--surface);background:color-mix(in srgb,var(--surface) 86%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:0;border-bottom:1px solid var(--border);border-radius:0}
.readerResume{margin-left:auto;font-size:11px;line-height:1.5;color:var(--muted);text-align:right;max-width:390px}
.seg{display:flex;padding:2px;background:var(--paper2);border:1px solid var(--border);border-radius:var(--radius-pill)}
.seg button{min-height:30px;padding:5px 12px;border:0;border-radius:var(--radius-pill);background:transparent;color:var(--text);font-size:12px;font-weight:600}
.seg button.active{background:var(--text);color:var(--surface)}
.moreRow{display:none;position:static;margin-top:0;margin-bottom:10px}
.moreRow.open{display:flex}
.moreChevron{transition:transform .15s ease}
[aria-expanded="true"] .moreChevron{transform:rotate(180deg)}
#sideToggle{display:none}
#readerGrid{display:grid;grid-template-columns:300px minmax(0,1fr);gap:32px;align-items:start;max-width:1120px;margin:0 auto}
.readerColumn{min-width:0}
.reader{max-width:700px;margin:0 auto;padding:clamp(28px,4vw,56px);background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-sm);box-shadow:var(--shadow-sheet);color:var(--text)}
.reader.sepia{--paper:#FBF3D9;--text:#3B2F1A;--text-soft:#5A4B2E;--muted:#6E5E3B;--border:#D9C9A5;--border-strong:#C8B58C;background:#FBF3D9;color:#3B2F1A;box-shadow:none}
.reader.dark{--paper:var(--paper-dark);--text:#E8E6DF;--text-soft:#CFCCC3;--muted:#A8ADA0;--border:#3D443C;--border-strong:#556052;background:var(--paper-dark);color:#E8E6DF;box-shadow:none}
.readerBadge{display:inline-block;padding-bottom:6px;margin-bottom:16px;border-bottom:1px solid var(--border);font-size:10px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:var(--muted)}
#readerTitle{font-family:var(--font-display);font-size:clamp(2.2rem,4.5vw,3.4rem);font-weight:500;line-height:1.02;letter-spacing:-.035em;margin:0 0 22px}
.reader h1,.reader h3,.reader h4{font-family:var(--font-display);font-weight:600;letter-spacing:-.02em;color:var(--text)}
.reader h3{font-size:1.45em;line-height:1.2;margin:1.4em 0 .4em}
.reader p,.reader li{font-family:var(--font-reading);font-size:var(--reader-fs);line-height:1.8;color:var(--text-soft)}
.reader p{margin:0 0 1.1em}
.reader a{color:var(--accent);text-decoration-thickness:1px;text-underline-offset:2px}
.reader blockquote{margin:1.4em 0;padding:2px 0 2px 18px;border-left:2px solid var(--accent);color:var(--muted);font-style:italic}
.reader img{max-width:100%;height:auto;border-radius:var(--radius-xs)}
#readerBody > p:first-of-type::first-letter,#readerBody > div:first-child > p:first-of-type::first-letter{float:left;padding:.06em .09em 0 0;color:var(--accent);font-family:var(--font-display);font-size:4.2em;font-weight:500;line-height:.78}
mark{background:#F2D887;color:#1A1A1A;padding:0 2px;border-radius:2px}
.reader.dark mark{background:#FFE98A;color:#111}
#readerSide{position:sticky;top:76px;max-height:calc(100vh - 96px);max-height:calc(100dvh - 96px);overflow-y:auto}
#readerSide .sideClose{display:none}
.tocItem{padding:9px 2px;border-bottom:1px solid var(--border);color:var(--text-soft);font-size:13px;line-height:1.4;cursor:pointer}
.tocItem:hover{color:var(--accent)}
.thumbItem{margin-bottom:8px;padding:5px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xs);cursor:pointer}
.thumbItem.active{border-color:var(--accent)}
.thumbItem canvas{display:block;width:100%;height:auto;background:#fff;border-radius:1px}
#thumbList{display:grid;grid-template-columns:repeat(auto-fill,minmax(82px,1fr));gap:8px}
#thumbList .thumbItem{margin-bottom:0}
#thumbList .kbd{font-size:10px}
#pdfView{max-width:860px;overflow-x:auto;margin:0 auto;padding:18px;background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-sm);box-shadow:var(--shadow-sheet)}
.pdfHead{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap;margin-bottom:10px}
.pdfHead>div:first-child{display:flex;flex-direction:column;gap:3px;min-width:0}
#pdfName{font-family:var(--font-ui);font-size:18px;font-weight:700;letter-spacing:-.01em}
.pdfHeadActions{display:flex;gap:6px;flex-wrap:wrap}
#pdfPages{display:flex;flex-direction:column;gap:18px}
.pdfPage{width:100%;overflow:hidden;background:#fff;border:1px solid var(--border);border-radius:var(--radius-xs)}
.pdfPage canvas{display:block;width:100%;height:auto}
.pdfPageNum{padding:6px 0;background:var(--surface);color:var(--muted);font-size:10px;letter-spacing:.08em;text-align:center;text-transform:uppercase}
.pageHolder{position:relative}
.pdfInk{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:3}
.textLayer{position:absolute;inset:0;overflow:hidden}
.textLayer span{position:absolute;color:transparent;white-space:pre;cursor:text;line-height:1;transform-origin:0 0}
.textLayer span::selection{background:rgba(200,90,50,.28)}
.textLayer mark{background:rgba(255,220,90,.6);color:transparent;border-radius:2px;mix-blend-mode:multiply}
.readerPager{display:flex;justify-content:space-between;align-items:center;gap:12px;max-width:860px;margin:16px auto 0}
.resultBox{margin-top:14px;padding:14px;background:var(--paper2);border:1px solid var(--border);border-radius:var(--radius-sm)}
.resultBox p{font-family:var(--font-display);font-size:16px;line-height:1.65;white-space:pre-wrap}
.resultBox .kbd{font-family:var(--font-ui)}
.cardHead{display:flex;justify-content:space-between;align-items:center;gap:10px}
.cardClose{flex:0 0 auto}
.ocrControls{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:10px 0}
.cardBtnRow{display:flex;gap:8px;flex-wrap:wrap}
.reader.dark .resultBox{background:var(--paper2);border-color:var(--border)}
.reader.dark .resultBox a{color:#93C5FD}
.reader.dark .resultBox .cardClose{background:var(--paper2);color:var(--text);border-color:var(--border-strong)}
.ttsBar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;max-width:860px;margin:14px auto 0;padding:10px 12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm)}
.ttsBar select{max-width:100%;min-height:34px;font-size:12px}
.ttsBar input[type=range]{width:90px}
.ttsField{display:inline-flex;align-items:center;gap:6px;min-width:0}
.ttsField select{min-width:130px}
.ttsField.ttsSpeed input{width:90px}
.ttsField.ttsSpeed input[type=range]{width:90px}
.ttsHint{flex:1 1 220px;min-width:0}
.ttsClose{margin-left:auto}
.ttsTitle{display:inline-flex;align-items:center;gap:6px;font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.parallelBox{max-width:860px;margin:14px auto 0}
#parallelGrid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.parallelBox .panel{padding:16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm)}
.parallelText{font-family:var(--font-display);font-size:15px;line-height:1.7;color:var(--text-soft);margin:0}
.parallelControls{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}
.parallelNotes{width:100%;height:88px;padding:10px;background:var(--paper);color:var(--text);border:1px solid var(--border-strong);border-radius:var(--radius-xs);resize:vertical;font-family:var(--font-display);font-size:15px;line-height:1.6}
.annotateFab{position:fixed;right:16px;bottom:calc(18px + env(safe-area-inset-bottom));z-index:55;display:inline-flex;align-items:center;gap:8px;min-height:46px;padding:0 18px;border:1px solid var(--text);border-radius:var(--radius-sm);background:var(--text);color:var(--surface);font-size:13px;font-weight:600;box-shadow:var(--shadow-modal)}
.annotateFab.hidden{display:none!important}

/* ---------- floating board, stickies, set square ---------- */
.board{position:absolute;right:16px;top:84px;z-index:60;display:flex;flex-direction:column;width:min(380px,calc(100% - 32px));max-width:calc(100% - 32px);overflow:hidden;background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);color:var(--text)}
.boardHead{position:relative;z-index:12;display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;background:var(--surface);color:var(--text);border-bottom:1px solid var(--border);font-size:11px;font-weight:600;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}
.boardHead>span{display:inline-flex;align-items:center;gap:6px}
.boardHeadActions{display:inline-flex;gap:4px;flex-wrap:wrap}
/* P3: the board tools live in a compact bottom floating pill inside the
   board (mockup 10: Pen | Pan | 100% | Clear). Zoom in/out stays on
   pinch/wheel; tapping the % label resets to 100%. */
.boardTools{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);z-index:5;display:flex;align-items:center;gap:4px;max-width:calc(100% - 16px);padding:4px 6px;background:var(--surface);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal)}
.boardTools .btn{min-height:36px}
.boardColorSwatch{display:inline-block;width:14px;height:14px;border-radius:50%;border:1px solid rgba(0,0,0,.25);background:#fffdf6;vertical-align:-2px}
/* P3: board mini-map (mockup 6). Fixed bottom-right of the screen so it
   sits where the mockup shows it whatever the editor scroll; hidden unless
   the board is open (see syncBoardMini) and hidden in Focus Mode. */
.boardMini{position:fixed;right:16px;bottom:calc(16px + env(safe-area-inset-bottom));z-index:61;width:200px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);overflow:hidden}
.boardMiniHead{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid var(--border);font-size:12px;font-weight:600}
.boardMiniActions{display:inline-flex;gap:4px}
.boardMini canvas{display:block;width:200px;height:120px;background-image:radial-gradient(var(--border) 1px,transparent 1px);background-size:14px 14px}
.boardCanvasWrap{position:relative;display:flex;flex:1 1 auto;min-height:0}
#boardCanvas{display:block;flex:1 1 auto;width:100%;height:230px;min-height:0;background:transparent;cursor:crosshair;touch-action:none}
.boardGrip{position:absolute;right:0;bottom:0;z-index:10;width:28px;height:28px;cursor:nwse-resize;touch-action:none}
.boardGrip::after{content:"";position:absolute;right:4px;bottom:4px;width:10px;height:10px;border-right:2px solid rgba(0,0,0,.4);border-bottom:2px solid rgba(0,0,0,.4)}
.boardEdge,.boardCorner{position:absolute;z-index:9;touch-action:none}
.boardEdge.n{top:0;left:32px;right:32px;height:24px;cursor:ns-resize}
.boardEdge.s{bottom:0;left:32px;right:32px;height:24px;cursor:ns-resize}
.boardEdge.w{left:0;top:32px;bottom:32px;width:24px;cursor:ew-resize}
.boardEdge.e{right:0;top:32px;bottom:32px;width:24px;cursor:ew-resize}
.boardCorner{width:32px;height:32px;z-index:10}
.boardCorner.nw{top:0;left:0;cursor:nwse-resize}
.boardCorner.ne{top:0;right:0;cursor:nesw-resize}
.boardCorner.sw{bottom:0;left:0;cursor:nesw-resize}
.board.boardFull{position:fixed;inset:0!important;width:auto!important;height:auto!important;max-width:none!important;border-radius:0;z-index:45}
.board.boardFull .boardEdge,.board.boardFull .boardCorner,.board.boardFull .boardGrip{display:none}
.board.boardFull .boardHead{cursor:default}
.sticky{position:absolute;z-index:7;width:176px;padding:0;overflow:hidden;border-radius:3px 3px 6px 3px;box-shadow:0 10px 24px -12px rgba(0,0,0,.35);color:#1B1B1B}
.stickyHead{display:flex;justify-content:space-between;align-items:center;padding:3px 6px;background:rgba(0,0,0,.08);cursor:grab;touch-action:none}
.stickyHead>span:first-child{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}
.stickyHead button{display:grid;place-items:center;min-width:24px;min-height:24px;padding:0;border:0;border-radius:var(--radius-xs);background:transparent;color:#1B1B1B}
.stickyHead button:hover{background:rgba(0,0,0,.12)}
.stickyHead .ic{width:13px;height:13px}
.sticky textarea{width:100%;height:96px;padding:8px;border:0;background:transparent;color:#111;font-family:var(--font-ui);font-size:13px;line-height:1.5;resize:none;outline:none}
/* Minimised sticky: a small box in the sticky's own colour (background is
   set inline, same as the open note). Tap it to reveal the note. */
.sticky.stickyMin{width:48px;height:48px;border-radius:6px;cursor:pointer;touch-action:none}
.setSquare{position:absolute;left:24px;top:24px;z-index:6;width:300px;max-width:82%;aspect-ratio:300/212;pointer-events:none;filter:drop-shadow(0 6px 14px rgba(0,0,0,.25));transform-origin:20% 85%}
.setSquare .sqBody{position:absolute;inset:0;background:rgba(242,179,61,.34);border:1.5px solid rgba(146,104,20,.75);clip-path:polygon(0 100%,100% 100%,0 0);pointer-events:auto;touch-action:none;cursor:grab}
.setSquare .sqHole{position:absolute;left:16%;bottom:9%;width:46%;height:52%;background:rgba(255,255,255,.30);border:1px solid rgba(146,104,20,.55);clip-path:polygon(0 100%,100% 100%,0 0);pointer-events:none}
.setSquare .sqBtns{position:absolute;left:2px;bottom:2px;display:flex;gap:4px;pointer-events:auto}
.setSquare .sqBtns button{display:grid;place-items:center;min-width:26px;min-height:26px;padding:0 5px;border:1px solid rgba(146,104,20,.7);border-radius:var(--radius-xs);background:rgba(255,253,246,.92);color:#5A4632;font-size:12px}
.stickyHead button::after{content:"";position:absolute;inset:-10px}
.setSquare .sqBtns button::after{content:"";position:absolute;inset:-9px}
.stickyHead button,.setSquare .sqBtns button{position:relative}

/* ---------- page overlays ---------- */
#pageTextLayer,#pageImageLayer{position:absolute;inset:0;overflow:hidden;pointer-events:none}
#pageImageLayer{z-index:2}
#pageTextLayer{z-index:3}
#texLayer{position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:4}
#texLayer .texEl{pointer-events:auto}
.canvasTextWrap{position:absolute;pointer-events:auto;touch-action:none;cursor:grab}
.canvasTextWrap.sel{outline:1px dashed var(--accent);outline-offset:3px}
.canvasTextWrap .canvasText{position:static;touch-action:none}
.canvasText{position:absolute;min-width:90px;max-width:46%;padding:4px 6px;background:transparent;font-family:var(--font-display);line-height:1.35;outline:none;border:1px dashed transparent;cursor:text;pointer-events:auto;white-space:pre-wrap;overflow-wrap:anywhere}
.canvasText:focus,.canvasText:hover{border-color:var(--accent);background:color-mix(in srgb, var(--surface) 88%, transparent)}
/* Text-box handles: shown only while the box is selected. The grip is a
   22px dot with an 11px extended hit area (44px target); the delete
   button reuses .miniBtn, whose ::after already gives it a 44px target. */
.canvasTextGrip{position:absolute;right:-12px;bottom:-12px;z-index:4;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--accent);color:#fff;font-size:12px;cursor:nwse-resize;touch-action:none}
.canvasTextGrip::after{content:"";position:absolute;inset:-11px}
.canvasTextDel{position:absolute;top:-12px;left:-12px;z-index:3}
.canvasTextWrap:not(.sel) .canvasTextGrip,.canvasTextWrap:not(.sel) .canvasTextDel{display:none}
.canvasImgWrap{position:absolute;pointer-events:auto;touch-action:none;cursor:grab;border:1px solid transparent}
.canvasImgWrap:hover,.canvasImgWrap.sel{border-color:var(--accent)}
.canvasImgWrap img{display:block;width:100%;height:100%;object-fit:contain;pointer-events:none}
.canvasImgGrip{position:absolute;right:-10px;bottom:-10px;z-index:3;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:var(--accent);color:#fff;font-size:12px;cursor:nwse-resize;touch-action:none}
.canvasImgGrip::after{content:"";position:absolute;inset:-12px}
.texEl{position:absolute;padding:2px 4px;border:1px dashed transparent;line-height:1.3;pointer-events:auto;touch-action:none;cursor:grab}
.texEl:hover,.texEl:focus-within{border-color:var(--accent);background:color-mix(in srgb, var(--surface) 88%, transparent)}
.pdfLink{position:absolute;z-index:2;display:block;background:rgba(200,90,50,.08);border-bottom:1px solid rgba(200,90,50,.4);cursor:pointer}
.pdfLink:hover{background:rgba(200,90,50,.2)}
.toolbar.compact{gap:0;padding:3px 4px 0}
.toolbar.compact .tool{width:34px;height:34px;min-height:34px}
.toolbar.compact .tbRow{min-height:36px}
.toolbar.minimal .tbExtra{display:none!important}
.toolbar.minimal .tool-label{display:none}

/* ---------- modals and toast ---------- */
dialog.modal{border:0;padding:0;background:transparent;width:min(480px,calc(100vw - 24px));margin:auto}
dialog.modal::backdrop{background:rgba(12,15,20,.62);overflow:hidden}
dialog.modal:modal{overscroll-behavior:contain}
.modalCard{width:100%;max-width:460px;max-height:88vh;max-height:88dvh;overflow:auto;padding:26px;background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-modal)}
.modalCard h3{font-family:var(--font-ui);font-size:20px;font-weight:700;letter-spacing:-.01em;margin:0 0 12px}
.fieldLabel{display:block;margin:12px 0 6px;font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.modalCard input,.modalCard select{width:100%;min-height:42px;margin:0 0 8px;padding:0 12px;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:var(--radius-sm);font-size:14px}
.modalCard textarea{width:100%;padding:10px 12px;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:var(--radius-sm);font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;line-height:1.5;resize:vertical}
.modalCard .kbd{font-size:12px;line-height:1.6;margin:0 0 6px}
.modalActions{display:flex;gap:8px;margin-top:18px}
.modalActions .btn{flex:1;justify-content:center}
#texPreview{margin-top:10px;padding:12px;overflow:auto;background:#fff;color:#111;border:1px solid var(--border);border-radius:var(--radius-xs)}
#texPreview.texPreviewEmpty{background:var(--paper2);color:var(--muted);font-family:var(--font-ui);font-size:13px}
.sizeRow{display:flex;align-items:center;gap:10px;margin-top:8px}
.sizeRow input[type=range]{flex:1}
.toast{position:fixed;left:50%;bottom:96px;z-index:90;display:none;max-width:92vw;padding:10px 16px;transform:translateX(-50%);background:var(--text);color:var(--bg);border-radius:var(--radius-xs);font-size:12px;font-weight:600;text-align:center;box-shadow:var(--shadow-modal);pointer-events:none}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}
}

/* ---------- Parallel Read ----------
   Two reading sheets side by side, each with its own scroll pane, plus one
   page-number rail for the book in use. The layout borrows the same paper,
   hairlines and radii as the single-book reader. */
#parallelRead{display:flex;flex-direction:column;gap:10px}
#parallelRead.hidden{display:none!important}
body.prOn .layout{max-width:min(1800px,100%)}
.prBar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 10px;background:var(--surface);border:0;border-bottom:1px solid var(--border);border-radius:0}
.prBarTitle{font-family:var(--font-ui);font-size:16px;font-weight:700;letter-spacing:-.01em;margin:0}
.prBarLabel{font-size:11px;line-height:1.4;color:var(--muted)}
.prBar select,.prBar input{min-height:34px;max-width:100%;min-width:0;padding:0 10px;background:var(--paper);color:var(--text);border:1px solid var(--border);border-radius:var(--radius-xs);font-size:12px;font-weight:600}
#prRightBtn{max-width:240px}
#prRightLabel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
/* Parallel Read picker popup: one row per book — colour dot, title, meta. */
.pickList{display:flex;flex-direction:column}
.pickRow{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:10px 4px;border:0;border-bottom:1px solid var(--border);background:transparent;color:var(--text);text-align:left;cursor:pointer}
.pickRow:last-child{border-bottom:0}
.pickRow:hover{background:var(--paper2)}
.pickDot{width:12px;height:12px;border-radius:4px;flex:0 0 auto}
.pickMain{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.pickMain b{font-size:14px;font-weight:600;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pickGo{color:var(--muted);font-size:18px;line-height:1;flex:0 0 auto}
.prBar input[type=number]{width:72px}
.prSpacer{flex:1 1 0}
.prOffsetWrap{display:inline-flex;align-items:center;gap:6px}
.prOffsetWrap.hidden{display:none!important}
.prShort{display:none}
.prZoom{display:inline-flex;align-items:center;gap:4px;flex:0 0 auto}
.prZoom .btn{min-width:32px;min-height:34px;padding:0 8px;justify-content:center}
.prZoom .prZoomLabel{min-width:56px;font-size:11px;font-variant-numeric:tabular-nums}
.prGrid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
.prCol{display:flex;flex-direction:column;min-width:0;background:var(--paper);color:var(--text);border:1px solid var(--border);border-radius:var(--radius-sm);overflow:hidden}
.prCol.prActive{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.prHead{display:flex;justify-content:space-between;align-items:baseline;gap:8px;padding:8px 12px;border-bottom:1px solid var(--border);font-size:12px}
.prHead b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;font-weight:600}
.prHead .kbd{white-space:nowrap;flex:0 0 auto;font-size:11px}
.prBody{display:flex;min-width:0;height:calc(100vh - 260px);height:calc(100dvh - 260px);min-height:320px}

.prMain{display:flex;align-items:stretch;gap:0;min-width:0}
.prMain>.prGrid{flex:1 1 auto;min-width:0;padding-left:12px}
.prRailBox{display:flex;flex:0 0 76px;flex-direction:column;width:76px;background:var(--paper2);border-right:1px solid var(--border);border-radius:var(--radius-sm) 0 0 var(--radius-sm)}
.prRailLabel{flex:0 0 auto;padding:10px 12px 8px;border-bottom:1px solid var(--border);color:var(--muted);font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.prRailTrack{position:relative;flex:1 1 auto;min-height:0}
.prRail{position:absolute;inset:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none;outline:none}
.prRail::-webkit-scrollbar{display:none}
.prRailNum{display:flex;align-items:center;width:calc(100% - 12px);height:38px;min-height:38px;margin:0 6px 2px;padding:0 10px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--text-soft);font-size:12px;font-weight:400;font-variant-numeric:tabular-nums;text-align:left;cursor:pointer;transition:background-color .15s ease,color .15s ease}
.prRailNum:hover{background:var(--surface)}
.prRailNum.active{background:var(--surface);color:var(--text);font-weight:600}
.prRailNum:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.prPane{position:relative;flex:1 1 auto;min-width:0;height:100%;overflow:auto;overscroll-behavior:contain;overflow-anchor:none;-webkit-overflow-scrolling:touch;padding:12px 16px;background:var(--paper);outline:none;touch-action:pan-x pan-y}
.prEpub h3{font-family:var(--font-display);font-size:calc(var(--reader-fs) * var(--pr-zoom,1) * 1.16);font-weight:600;line-height:1.2;letter-spacing:-.02em;margin:18px 0 6px}
.prEpub section:first-child h3{margin-top:4px}
.prEpub p,.prEpub li{font-family:var(--font-reading);font-size:calc(var(--reader-fs) * var(--pr-zoom,1));line-height:1.75;overflow-wrap:anywhere}
.prEpub img{max-width:100%;height:auto;border-radius:var(--radius-xs)}
.prEpub blockquote{margin:14px 0;padding:4px 0 4px 14px;border-left:2px solid var(--accent);color:var(--muted);font-style:italic}
.prPdf{display:flex;flex-direction:column;gap:12px;margin:0 auto}
.prPage{overflow:hidden;background:var(--paper);border:1px solid var(--border);border-radius:var(--radius-xs)}
.pdfHolder{position:relative;width:100%;background:#fff}
.pdfHolder canvas{position:absolute;inset:0;display:block;width:100%;height:100%}
#parallelRead[data-theme=sepia] .prCol,#parallelRead[data-theme=sepia] .prPane{background:#FBF3D9;color:#3B2F1A}
#parallelRead[data-theme=sepia] .prHead{border-color:#D9C9A5}
#parallelRead[data-theme=dark] .prCol,#parallelRead[data-theme=dark] .prPane{background:var(--paper-dark);color:#E8E6DF;border-color:#3D443C}
#parallelRead[data-theme=dark] .prHead{border-color:#3D443C}
#parallelRead[data-theme=dark] .prPdf{filter:invert(.92) hue-rotate(180deg)}
.prEpub::after,.prPdf::after{content:"End";display:block;margin-top:18px;color:var(--muted);font-size:10px;letter-spacing:.12em;text-align:center;text-transform:uppercase}
#parallelBtn[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
.prHelp{margin:0;line-height:1.55}
.prCount{display:inline-grid;place-items:center;min-width:18px;height:18px;padding:0 5px;border-radius:var(--radius-xs);background:var(--paper2);color:var(--text);font-size:10px;font-weight:600}
.prCount:empty{display:none}
.prInkBar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:6px 10px;background:var(--surface);border:0;border-bottom:1px solid var(--border);border-radius:0;position:sticky;top:0;z-index:30}
.prInkBar.hidden{display:none!important}
.prInkWhoWrap{display:inline-flex;align-items:center;gap:6px;min-width:0;max-width:240px}
.prInkWho{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600}
.prInkTools{display:inline-flex;flex-wrap:wrap;align-items:center;gap:2px}
.prInkTools .tool{width:38px;height:38px;min-height:38px;border-radius:var(--radius-xs)}
.prInkTools .tool .ic{width:19px;height:19px}
.prInkTools .tool.active{background:var(--text);border-color:var(--text);color:var(--surface)}
.prInkSizeGroup{display:inline-flex;align-items:center;gap:6px;padding:2px 8px;background:var(--paper2);border:1px solid var(--border);border-radius:var(--radius-xs);min-height:34px}
.prInkSizeGroup input[type=range]{width:86px}
.prInkSwatches{display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px;min-height:32px}
.prInkSwatches .swatch.active{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--text)}
.prInkOpt{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600}
.prInkOpt.hidden{display:none!important}
#prInkSizePreview{background:var(--paper);border-radius:var(--radius-xs);box-shadow:inset 0 0 0 1px var(--border)}
.prCol{position:relative;overflow:clip}
.prInk{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.prCol.prInkOn .prInk{pointer-events:auto;cursor:crosshair;touch-action:none;z-index:3}
.prCol.prInkOn .pdfLink,.prCol.prInkOn .textLayer{pointer-events:none}
.prEpub section[data-unit]{position:relative}
.prCol.prInkOn .prEpub{-webkit-user-select:none;user-select:none;touch-action:none;cursor:crosshair}
.prCol.prInkOn .prEpub a{pointer-events:none}
.prMarksList{display:flex;flex-direction:column;gap:2px;padding-top:6px}
.prMarkRow{display:grid;grid-template-columns:10px minmax(0,1fr);gap:2px 10px;width:100%;min-height:40px;padding:8px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--text);font-size:12px;line-height:1.4;text-align:left;cursor:pointer}
.prMarkRow:hover{background:var(--paper2)}
.prMarkRow .kbd{grid-column:2;font-size:11px}
.prMarkText{overflow-wrap:anywhere}
.prMarkKind{width:10px;height:10px;margin-top:5px;border-radius:2px;background:#F2D887;box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.prMarkKind.underline{background:#2456C8}
.prMarkKind.strike{background:var(--accent)}
.prMarksFoot{padding-top:8px;margin-top:6px;border-top:1px solid var(--border)}
.prSelBar{position:fixed;left:0;top:0;z-index:70;display:flex;gap:2px;padding:4px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal)}
.prSelBar.hidden{display:none!important}
.prSelBar button{min-height:34px;padding:0 10px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--text);font-size:12px;font-weight:600;white-space:nowrap;cursor:pointer}
.prSelBar button:hover{background:var(--paper2)}
.prSelSample{padding:0 2px;border-radius:2px;background:#F2D887;color:#1A1A1A}
.prSelUnderline{text-decoration:underline;text-decoration-color:#2456C8;text-decoration-thickness:2px}
.prSelStrike{text-decoration:line-through;text-decoration-color:var(--accent);text-decoration-thickness:2px}
.selColorBtn{display:inline-flex;align-items:center;justify-content:center;padding:0 8px!important}
.selColorDot{display:inline-block;width:20px;height:20px;border-radius:50%;border:2px solid var(--surface);box-shadow:0 0 0 1px var(--border)}
.selColorPop{position:fixed;left:0;top:0;z-index:80;display:flex;flex-direction:column;gap:10px;padding:12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);max-width:calc(100vw - 16px)}
.selColorPop.hidden{display:none!important}
.selDots{display:flex;gap:6px;flex-wrap:wrap}
.selDot{width:40px;height:40px;min-height:40px;padding:0;border:0;border-radius:50%;background:transparent;display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.selDot span{width:28px;height:28px;border-radius:50%;background:var(--dot);box-shadow:0 0 0 1px rgba(0,0,0,.18)}
.selDot.sel span{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--accent)}
.selDotDefault span{background:linear-gradient(to top right,transparent 44%,var(--text) 44%,var(--text) 56%,transparent 56%),#E8E4DA}
.selSliderWrap{display:flex;align-items:center;gap:8px;font-size:12px;font-weight:600;color:var(--text);white-space:nowrap}
.selSlider{flex:1;min-width:120px;accent-color:var(--accent)}
.selSliderVal{min-width:36px;text-align:right;font-variant-numeric:tabular-nums}
.selColorRow{flex-wrap:wrap;align-items:center}
.annoSwatch{display:inline-block;width:10px;height:10px;border-radius:50%;flex:none;margin:2px 6px 0 0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
/* SCREEN 08: annotation card structure (layout only — colours live in
   the nightScroll block). The quote stacks above its chapter label, and
   each card carries a working delete button. */
.annoCard{align-items:stretch}
.annoCard .annoBody{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
.annoCard .annoQuote{font-size:13px;line-height:1.45}
.annoCard .annoWhere{overflow-wrap:anywhere}
.annoDel{flex:0 0 auto;align-self:flex-start;margin:4px 6px 0 0;min-height:28px;padding:0 8px;font-size:16px;line-height:1}
body.prOn #resumeLabel{display:none}




/* ============ Mobile redesign: native dialogs as bottom sheets ============
   Replaces the .toolPop absolute-positioned popover pattern, which failed
   on phones. Secondary actions live in <dialog class="sheet"> elements,
   opened with commandfor / command="show-modal" (native, top-layer,
   Esc and backdrop dismiss, focus handled by the platform). The sheet
   sections (.sheetSection) are reusable: on wide screens the same
   sections can move into a side panel without changing their markup.
   The .toolPop rules are retired screen by screen as each screen moves
   its popovers into a sheet. */

/* Retired: no .toolPop markup remains anywhere; if one ever reappears it must not show. */
.toolPop{display:none!important}

/* Bottom sheet dialog (native <dialog>, opened with showModal). */
dialog.sheet{
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  border-radius:18px 18px 0 0;
  padding:0;
  width:min(560px,100vw);
  max-width:100vw;
  max-height:min(84vh,84dvh);
  margin:auto auto 0;
  box-shadow:var(--shadow-modal);
}
dialog.sheet:modal{display:flex;flex-direction:column;overscroll-behavior:contain}
dialog.sheet::backdrop{background:rgba(0,0,0,.45);backdrop-filter:blur(2px);overflow:hidden}

.sheetHead{
  display:flex;align-items:center;gap:12px;flex:none;
  padding:14px 16px 10px;
  border-bottom:1px solid var(--border);
  background:var(--surface);
}
.sheetHead h2{font:600 17px/1.25 var(--font-ui);margin:0;flex:1}
.sheetBody{
  flex:1;min-height:0;overflow-y:auto;
  padding:6px 16px calc(16px + env(safe-area-inset-bottom,0px));
  -webkit-overflow-scrolling:touch;
}
.sheetSection{padding:12px 0;border-top:1px solid var(--border)}
/* Inspector option rows: same roomy flex row the old tool popover used,
   so a label and its slider sit on one line (the Smooth label was
   wrapping underneath its slider as a plain block). */
.sheetSection .popRow{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 0}
.sheetSection .popRow input[type=range]{flex:1;min-width:110px}
.sheetSection:first-child{border-top:0}
.sheetSection>h3{font:600 12px/1.3 var(--font-ui);letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin:0 0 8px}
.sheetRow{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.sheetRow .btn,.sheetRow .iconBtn{min-height:44px}
.sheetNote{font:400 13px/1.5 var(--font-ui);color:var(--muted);margin:6px 0 0}

/* Slim top bars, one row on mobile; the page fills the screen. */
.masthead,.editorTop,.readerTop{min-height:52px;padding-top:env(safe-area-inset-top,0px)}

/* 44px touch targets on coarse pointers. */


/* Reading progress: native <progress>, a thin line under the reader top bar. */
.readProgress{
  display:block;width:100%;height:3px;margin:0;
  -webkit-appearance:none;appearance:none;
  background:transparent;border:0;
}
.readProgress::-webkit-progress-bar{background:transparent}
.readProgress::-webkit-progress-value{background:var(--accent)}
.readProgress::-moz-progress-bar{background:var(--accent)}

/* ============ Responsive (Gemini Step 1) ============
   ONE consolidated responsive section. Breakpoints: 1024px (tablet)
   and 768px (mobile). The audit claimed four conflicting
   @media (max-width:860px) blocks; the file actually had one — the
   real mess was eleven scattered width breakpoints — so the rules
   were redistributed by intent: layout fixes that must hold on
   tablets live in the 1024px block, phone-only rules (tiny type,
   hidden chrome, stacked sheets) live in the 768px block. Width
   rules live here, at the end of the file, so they override the base
   rules above. Input-based rules (pointer:coarse) are separate,
   below. */

/* Shelf grid: 2 columns by default, 3 from tablet (721px), 4 from desktop (1025px). */
@media (min-width:721px){
  .grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media (min-width:1025px){
  .grid{grid-template-columns:repeat(4,minmax(0,1fr))}
}

@media (max-width:1024px){
  .saveFlag{display:none}
  .masthead{grid-template-columns:auto minmax(220px,1fr) auto;gap:12px}
  .editorWrap{grid-template-columns:1fr}
  .editorWrap .stageWrap{order:-1}
  #linksToggleBtn{display:inline-flex}
  #pageList{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:8px}
  #pageList .pageThumb{margin-bottom:0}
  .panel{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);padding:14px;margin-top:12px}
  .panel h4:first-child{margin-top:0}
  #readerSide{position:static;max-height:none}
  .layout{padding:16px 16px 108px}
  .installBtn{width:44px;min-width:44px;min-height:44px;padding:0;justify-content:center}
  .installBtn .installLabel{display:none}
  .iconBtn{width:44px;height:44px;min-width:44px;min-height:44px}
  .editorTop{position:sticky;top:0;z-index:30;padding:6px 8px;gap:4px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
  .editorTop::-webkit-scrollbar{display:none}
  .editorTop .edFocus{display:none}
  .editorTop:has(#backToReadingBtn:not(.hidden))>button.iconBtn[aria-label="Back to library"]{display:none}
  #backToReadingBtn{white-space:nowrap;flex:0 0 auto}
  #backToReadingBtn .backShort{display:inline}
  #backToReadingBtn .backLong{display:none}
  .titleField{flex:1 1 120px;min-width:0}
  #noteTitle{font-size:18px;text-overflow:ellipsis}
  .toolbar{position:static;top:auto;padding:4px 6px;margin-top:8px;scroll-margin-top:64px}
  .tbRowTools{flex-wrap:nowrap;overflow-x:auto;gap:2px}
  .tbRowTools .tbDivider{display:none}
  .statusBar{display:none}
  .tbRowOpts{flex-wrap:wrap;overflow:visible;gap:8px;padding:6px 0}
  .sizeGroup{flex:1 1 100%;justify-content:flex-start}
  .sizeGroup input[type=range]{flex:1;width:auto}
  .canvasShell{border-radius:var(--radius-xs)}
  /* Hand fix: .zoomScroll never had vertical scroll room — its height
     was its content (scrollHeight == clientHeight at every width and
     zoom) — so all vertical panning fell through to window.scrollBy and
     the page scrolled away under the toolbar. Capping the stage height
     on phones/tablets makes the page pan inside the stage, like a note
     app; the window fallback still takes any remainder. At zoom 1 the
     page fits the cap, so nothing changes; zoomed in, the stage gains
     real vertical room. Desktop keeps document scrolling. */
  .zoomScroll{max-height:max(300px,calc(100vh - 170px));max-height:max(300px,calc(100dvh - 170px))}
  .textArea{font-size:16px;min-height:96px}
  .readerTop{position:static;flex-wrap:nowrap;padding:6px 8px;gap:6px;overflow-x:auto;scrollbar-width:none}
  .readerTop::-webkit-scrollbar{display:none}
  .readerTop .btn,.readerTop .seg{flex:0 0 auto}
  .readerResume{display:none}
  .closePdfBtn{display:none}
  #readerGrid{grid-template-columns:1fr;gap:16px}
  #readerSide{display:none}
  #readerSide.open{display:block;position:fixed;top:0;left:0;bottom:0;width:min(320px,86vw);z-index:60;overflow-y:auto;margin-top:0;border-radius:0;border-right:1px solid var(--border);box-shadow:0 0 32px rgba(0,0,0,.28)}
  #readerSide.open h4{display:flex;justify-content:space-between;align-items:center}
  #readerSide.open .sideClose{display:inline-flex}
  #sideToggle{display:inline-flex}
  .reader{padding:24px 18px 32px;border-radius:var(--radius-xs)}
  #pdfView{padding:12px}
  #parallelGrid{grid-template-columns:1fr}
  .readerPager{flex-wrap:wrap}
  .ttsBar{align-items:stretch}
  .ttsField{flex:1 1 100%;justify-content:space-between;gap:10px}
  .ttsField select{flex:1;min-width:0}
  .ttsField.ttsSpeed input[type=range]{flex:1;width:auto}
  .ttsHint{flex:1 1 100%}
  .ttsClose{margin-left:auto}
  /* F5: the ink bar stays put while the user scrolls between the two
     books, and it stops eating the screen — the "Annotating …" label and
     the size preview go on small screens, and the tools run in one
     sideways-scrolling row, like the editor toolbar. The two books stay
     side by side from 769px up now; only phones stack them (see the
     max-width:768px block). */
  #prInkBar{gap:6px;padding:6px 8px}
  .prInkWhoWrap{display:none}
  #prInkSizePreview{display:none}
  /* the size group shares a row here (the editor's full-width size row
     does not apply inside this bar) */
  #prInkBar .sizeGroup{flex:0 1 auto;padding-top:0;padding-bottom:0}
  .prInkTools{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
  .prInkTools::-webkit-scrollbar{display:none}
  /* while annotating, the top bar keeps only what annotating needs —
     the sync / offset / marks controls come back when Done is tapped */
  #parallelRead.prInking .prBar .prSyncLabel,
  #parallelRead.prInking #prSyncSeg,
  #parallelRead.prInking #prOffsetWrap,
  #parallelRead.prInking #prMarksBtn{display:none}
  .chipRow{gap:20px}
}

@media (max-width:768px){
  .layout{padding:14px 12px 100px}
  /* Mockup 15 (Pass 1 audit): on phones the search is an icon-only
     magnifier in the header row, not a full-width second row. */
  .masthead{grid-template-columns:1fr auto auto;gap:8px;padding:8px 10px;top:8px}
  .wordmark{grid-column:1;grid-row:1;flex-direction:column;gap:3px}
  .wordmarkName{font-size:23px}
  .mastheadTools{grid-column:3;grid-row:1}
  .navSearch{grid-column:2;grid-row:1;max-width:none;justify-self:end}
  .masthead .navSearch .searchTrigger{width:44px;min-height:44px;padding:0;justify-content:center;border-radius:999px}
  .searchTriggerText{display:none}
  .shelfBar{flex-direction:column;align-items:stretch;gap:0}
  .chipRow{gap:16px}
  .chip{font-size:12px}
  .libHint{text-align:left;padding:0 0 12px}
  .grid{gap:16px 12px}
  .bookFace{padding:14px 34px 12px 12px}
  .bookTitleBelow{font-size:18px}
  .bookMenu{top:8px;right:8px;width:28px;height:28px;min-height:28px}
  .searchKbd{display:none}
  .search{min-height:48px}
  .tbRowTools .tool{width:44px;height:44px;min-height:44px}
  .tbRowTools .iconBtn{width:44px;height:44px;min-width:44px;min-height:44px}
  .sticky{width:150px}
  .sticky textarea{height:80px}
  .board{left:8px;right:8px;top:8px;width:auto;max-width:none}
  table.inkTable td,table.inkTable th{min-width:0;padding:6px;font-size:13px;overflow-wrap:anywhere}
  .modalActions{flex-direction:column}
  .modalCard input,.modalCard select,.modalCard textarea{font-size:16px}
  .modalCard{padding:20px}
  .toast{bottom:84px}
  .readerTop .btn{font-size:12px;padding:0 9px}
  .readerPager{gap:8px}
  body.prOn .layout{padding-bottom:16px}
  .prBar{gap:6px;padding:8px;flex-wrap:wrap}
  .prBarTitle,.prMarksText{display:none}
  .prBarLabel{display:inline}
  #prRightBtn{flex:1 1 180px;max-width:none}
  .prLong{display:none}
  .prShort{display:inline}
  .prOffsetWrap{flex:0 0 auto}
  .prZoom .prZoomLabel{min-width:48px}
  .prPane{padding:8px}
  .prMain>.prGrid{padding-left:8px}
  /* F5: only phones stack the two books (tablets keep them side by side);
     each pane gets half the room left after the bars. The ink bar gets
     one more squeeze here: the tools take a full sideways-scrolling row,
     the option labels go (the controls speak for themselves), and "Open
     in editor" hides — the editor is one tap away from the normal reader.
     That leaves three rows, so the second book's first page is on screen
     without scrolling. */
  .prGrid{grid-template-columns:minmax(0,1fr);gap:8px}
  .prBody{height:calc((100vh - 344px) / 2);height:calc((100dvh - 344px) / 2);min-height:200px}
  .prInkTools{flex:1 1 100%}
  #prInkBar .tool-label{display:none}
  #prOpenEditorBtn{display:none}
  .prRailBox{flex-basis:60px;width:60px}
  .prRailLabel{padding:9px 10px 7px;font-size:9px}
  .prRailNum{width:calc(100% - 8px);margin:0 4px 2px;padding:0 8px}
  .prHelp{display:none}
}

/* Parallel Read: taller body while inking (desktop only). */
@media (min-width:701px){
  #parallelRead.prInking .prBody{height:calc(100vh - 360px);height:calc(100dvh - 360px);min-height:260px}
}

/* Parallel Read on short landscape phones. */
@media (max-height:520px) and (orientation:landscape){
  body.prOn .readerTop{position:static}
  body.prOn #resumeLabel{display:none}
  .prBar{gap:6px;padding:4px 8px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
  .prBar::-webkit-scrollbar{display:none}
  .prBar>*{flex:0 0 auto}
  .prBar select{max-width:200px;min-height:44px}
  .prBar input{min-height:44px}
  .prBarTitle,.prLong{display:none}
  .prBarLabel{display:inline}
  .prShort{display:inline}
  .prBody{height:calc(100vh - 116px);height:calc(100dvh - 116px);min-height:200px}
  .prHelp{display:none}
}

/* Split View on short landscape screens (phone/tablet turned sideways):
   at these widths the pill is in normal flow above the stage, so the
   76px clearance both panes carry is empty space — cutting it to 12px
   pulls both panes up together (they stay aligned) and keeps the
   pane's footer — Prev / Next / zoom — near the fold instead of below
   it. The pane height itself is the scroller's visible window (see
   syncSplitPaneHeight), so the footer stays reachable. */
@media (max-height:520px) and (orientation:landscape){
  .stageWrap.split .canvasShell,.stageWrap.split .splitPane{margin-top:12px}
  .stageWrap.split .splitPaneFoot{padding:4px 6px;gap:4px}
}

/* Bottom sheets are centred dialogs on wider screens. */
@media (min-width:680px){
  dialog.sheet{margin:auto;border-radius:var(--radius-lg)}
}

/* 44px touch targets on coarse pointers (form-factor-adaptation:
   24px minimum everywhere, 44px where a fingertip is the pointer).
   Specificity matters here: the base rules set their own min-height
   (.tbRowTools .tool 38px, .tbBoardBtn/.tbMenuBtn 34px, .prZoom .btn
   34px, .seg button 30px, .bookActions button 38px, .btn 40px,
   .iconBtn 40px), so a :where() list — specificity zero — cannot lift
   them. Every control below is therefore written out at the
   specificity that ties its base rule; this block sits at the end of
   the file, so ties resolve in its favour. (Tablet probe, 1024px:
   .tool measured 38px and .tbBoardBtn 34px with the :where() list.)
   Icon-only controls keep their small visual size; their 44px hit
   area comes from an invisible ::after extension (see .swatch,
   .miniBtn, .bookMenu, .stickyHead button). */
@media (pointer:coarse){
  :root{--target-size:44px}
  .btn,.iconBtn,.chip,.tbBoardBtn,.tbMenuBtn,.prMarkRow{min-height:var(--target-size);min-width:var(--target-size)}
  .seg button,.bookActions button{min-height:var(--target-size);min-width:var(--target-size)}
  .prZoom .btn,.tbRowTools .tool,.prInkTools .tool{min-height:var(--target-size);min-width:var(--target-size)}
  .toolbar.compact .tool{min-height:var(--target-size);min-width:var(--target-size)}
  .btn.small{min-height:var(--target-size)}
  select,input[type="range"]{min-height:var(--target-size)}
  .prBar select,.prBar input{min-height:var(--target-size)}
  input[type=color].colorPick{width:44px;height:44px;min-height:var(--target-size)}
  label:has(input[type="checkbox"],input[type="radio"]){min-height:var(--target-size);display:inline-flex;align-items:center}
  .prRailNum{height:44px;min-height:44px}
  .prInkTools .tool{width:44px;height:44px;min-height:44px}
  .prInkSwatches .swatch{width:30px;height:30px;min-height:30px}
  .prSelBar button{min-height:44px;padding:0 8px}
  .searchKbd{display:none}
  .panel .checkRow{min-height:44px;align-items:center}
}

/* ============ Pass 1: Library, Shelf Options & Command Palette ============
   Gemini plan Pass 1. Header search is a trigger pill now; the search
   itself is a centred modal. The floating bottom dock is gone: its
   actions live in the + New menu (desktop, in the filter bar) and in
   the mobile tab bar + terracotta FAB. */

/* Header search trigger: looks like the old search pill, behaves as a
   button. The real input lives inside the palette dialog. */
.searchTrigger{width:100%;text-align:left;cursor:pointer;font:inherit;color:var(--text)}
.searchTriggerText{flex:1;min-width:0;color:var(--muted);font-size:15px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* + New menu in the filter bar (hidden on mobile: the FAB opens it). */
.newWrap{position:relative;margin-left:auto;flex:0 0 auto}
.newBtn{white-space:nowrap}
/* Mockup 11 (Pass 1 audit): the + New button is terracotta, not dark.
   Scoped to .btn.primary — the plain .newBtn rule loses to it. */
.btn.primary.newBtn{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
.btn.primary.newBtn:hover{background:var(--accent);border-color:var(--accent);color:var(--accent-text);filter:brightness(1.07)}

/* Command palette: native <dialog>, centred modal (dialog guide Rule 1).
   No role/aria-modal — the native modal provides them. */
dialog.palette{
  width:min(600px,calc(100vw - 32px));
  max-height:min(72vh,72dvh);
  margin:max(24px,10vh) auto auto;
  padding:0;border:1px solid var(--border);border-radius:var(--radius-md);
  background:var(--surface);color:var(--text);box-shadow:var(--shadow-modal);
}
dialog.palette:modal{display:flex;flex-direction:column;overscroll-behavior:contain}
dialog.palette::backdrop{background:rgba(20,16,12,.45);overflow:hidden}
.paletteSearch{display:flex;align-items:center;gap:10px;padding:4px 14px;border-bottom:1px solid var(--border)}
.paletteSearch input{flex:1;min-width:0;height:48px;border:0;background:transparent;color:var(--text);font-size:16px;outline:none}
.paletteSearch input::placeholder{color:var(--muted)}
.paletteResults{flex:1;min-height:0;overflow-y:auto;padding:6px 0 10px}
/* Mockup 1 (Pass 1 audit): group headers are normal case, not small
   caps; rows are a row — label + sub on the left, format/progress
   pills and a ⌘1..⌘9 shortcut chip on the right. */
.palGroup{padding:12px 16px 6px;font:600 13px/1.3 var(--font-ui);letter-spacing:0;text-transform:none;color:var(--text)}
.palItem{display:flex;align-items:center;gap:10px;padding:10px 16px;cursor:pointer;min-height:44px}
.palItem:hover,.palItem.sel{background:var(--paper2)}
.palItemMain{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.palItem b{display:block;font-size:14px;font-weight:600;line-height:1.35;overflow-wrap:anywhere}
.palItemMain span{display:block;font-size:12px;line-height:1.5;color:var(--muted);overflow-wrap:anywhere}
.palChips{display:flex;align-items:center;gap:6px;flex:0 0 auto}
.palPill{font-size:11px;font-weight:600;line-height:1;color:var(--muted);border:1px solid var(--border);border-radius:999px;padding:4px 8px;white-space:nowrap}
.palKbd{min-width:24px;min-height:24px;display:grid;place-items:center;border:1px solid var(--border);border-radius:var(--radius-xs);font-size:11px;line-height:1;color:var(--muted);padding:0 5px}
.palEmpty{padding:18px 16px;font-size:13px;color:var(--muted)}
.paletteHint{margin:0;padding:10px 16px;border-top:1px solid var(--border);font-size:11px;line-height:1.6;color:var(--muted)}
.paletteHint .searchKbd{display:inline-grid}

/* + New menu popover (menu guide): anchored under its trigger, flips
   at viewport edges. The JS anchor fallback covers browsers without
   position-area. */
.menuPop{
  min-width:220px;margin:0;padding:4px;
  border:1px solid var(--border);border-radius:var(--radius-md);
  background:var(--surface);color:var(--text);box-shadow:var(--shadow-modal);
}
.menuPop:popover-open{display:block}
/* No CSS anchor positioning for this menu: it broke for the corner-
   anchored mobile FAB (Chrome 158 computed a 0x0 placement for the
   bottom-right anchor — the menu opened but had no size, so its
   buttons were not clickable). The menu is positioned from script on
   open instead (see the toggle handler in app.js): below the trigger,
   flipping above it when there is no room, clamped to the viewport. */
[focusgroup~="menu"] button{
  display:flex;align-items:center;gap:8px;width:100%;min-height:44px;
  padding:9px 10px;border:0;border-radius:var(--radius-xs);
  background:transparent;color:var(--text);font-size:13px;font-weight:500;text-align:left;
}
[focusgroup~="menu"] button:hover,[focusgroup~="menu"] button:focus-visible{background:var(--paper2)}
[focusgroup~="menu"] button .ic{width:15px;height:15px;color:var(--muted);flex:0 0 auto}

/* Shelf Options drawer: right slide-over on desktop, full-height sheet
   on mobile (navigation-drawer guide: a modal <dialog> in the top
   layer, Esc + light dismiss + Close button). */
dialog.sheet.drawerRight{
  margin:0 0 0 auto;max-height:none;height:100vh;height:100dvh;
  width:min(420px,100vw);border-radius:0;border:0;border-left:1px solid var(--border);background:var(--surface);color:var(--text);
}
@media (prefers-reduced-motion:no-preference){
  dialog.sheet.drawerRight:modal{animation:drawerIn .18s ease}
  @keyframes drawerIn{from{transform:translateX(24px);opacity:0}to{transform:none;opacity:1}}
}

/* This Shelf stats: 2x2 metric cards + storage bar (real numbers). */
.statGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:12px}
.statCard{background:var(--paper2);border:1px solid var(--border);border-radius:var(--radius-sm);padding:12px 14px;min-width:0}
.statCard b{display:block;font-size:22px;font-weight:700;letter-spacing:-.02em;line-height:1.1}
.statCard span{font-size:12px;line-height:1.4;color:var(--muted)}
.storageBar{height:6px;border-radius:999px;background:var(--paper2);border:1px solid var(--border);overflow:hidden}
.storageFill{display:block;height:100%;background:var(--accent);border-radius:999px}

/* Shelf Options drawer restyle (Pass 1 audit, mockup 5): serif title +
   terracotta X close; stat cards are icon + label above, big value
   below; the storage bar lives in its own card; row groups are rounded
   cards with chevrons. */
#librarySheet .sheetHead h2{font-family:var(--font-display);font-size:19px;font-weight:600}
.drawerClose{display:grid;place-items:center;width:36px;height:36px;min-height:36px;padding:0;border:1px solid transparent;border-radius:999px;background:transparent;color:var(--accent);cursor:pointer}
.drawerClose:hover{background:var(--paper2)}
.drawerClose .ic{width:18px;height:18px}
.statCard{display:flex;flex-direction:column;gap:2px}
.statCard .statIcon{color:var(--accent)}
.statIcon .ic{width:18px;height:18px}
.storageCard{background:var(--paper2);border:1px solid var(--border);border-radius:var(--radius-sm);padding:12px 14px;margin-top:12px}
.storageCard .storageBar{background:var(--surface)}
.storageCard .sheetNote{margin:8px 0 0}
.drawerRows{display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);overflow:hidden}
.drawerRow{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:10px 12px;border:0;border-bottom:1px solid var(--border);background:transparent;color:var(--text);font:500 13px/1.3 var(--font-ui);text-align:left;cursor:pointer}
.drawerRow:last-child{border-bottom:0}
.drawerRow:hover{background:var(--paper2)}
.drawerRow>span{flex:1;min-width:0}
.drawerRow .ic{width:16px;height:16px;color:var(--muted);flex:0 0 auto}

/* Thin reading-progress bar on each shelf card, below the cover. The
   track is neutral on the white card; the fill is the terracotta
   accent. */
.bookProgress{display:block;height:3px;border-radius:999px;background:var(--paper2);border:1px solid var(--border);margin:0;overflow:hidden}
.bookProgress span{display:block;height:100%;background:var(--accent);border-radius:999px}

/* Mobile tab bar + terracotta FAB: phone only. The dock they replace
   is gone on desktop, so the library no longer reserves 124px at the
   bottom there. */
.tabBar,.libFab{display:none}
@media (min-width:769px){
  .layout.shelf{padding-bottom:48px}
}
@media (max-width:768px){
  dialog.sheet.drawerRight{width:100vw;height:100vh;height:100dvh;max-height:100dvh;border-left:0}
  .newWrap{display:none}
  .chipRow{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;padding-bottom:2px}
  .chipRow::-webkit-scrollbar{display:none}
  .chip{flex:0 0 auto}
  .tabBar{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:45;
    background:var(--surface);border-top:1px solid var(--border);
    padding:6px 8px calc(6px + env(safe-area-inset-bottom,0px));gap:4px;
  }
  .tabBtn{
    flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:3px;
    min-height:48px;padding:6px 0 4px;border:0;background:transparent;
    color:var(--muted);font-size:11px;font-weight:600;line-height:1.2;cursor:pointer;
  }
  .tabBtn .ic{width:22px;height:22px}
  .tabBtn.active{color:var(--accent)}
  .libFab{
    display:grid;place-items:center;position:fixed;right:16px;
    bottom:calc(78px + env(safe-area-inset-bottom,0px));z-index:46;
    width:56px;height:56px;border:0;border-radius:50%;
    background:var(--accent);color:var(--accent-text);box-shadow:var(--shadow-modal);cursor:pointer;
  }
  .libFab .ic{width:24px;height:24px}
  .layout.shelf{padding-bottom:160px}
}

/* ============ Pass 2: Notebook Studio, Floating Pill Toolbar & Insert Inspector ============
   Gemini plan Pass 2. The editor's stacked rows collapse into one top bar
   plus a floating pill over the canvas; the More tools sheet becomes a
   side inspector (drawerRight) on desktop and a 4-tab bottom sheet on
   mobile. Guides used: toolbar (role=toolbar, focusgroup roving stop,
   aria-pressed state, separators), navigation-drawer (modal <dialog>
   drawer, Esc/backdrop/Close dismiss), switch (native checkbox + switch
   attribute, styled fallback), dialog (native <dialog> sheets).
   No ids or data-* attributes were renamed; every control that lived in
   the old toolbars/modals is still reachable. */

/* --- top bar: one row; Board / Split / Export go icon-only on narrow screens --- */
.editorTop .tbBoardBtn{flex:0 0 auto}
#splitTopBtn{flex:0 0 auto;white-space:nowrap}
#addPageTopBtn{flex:0 0 auto;white-space:nowrap}
/* Pass 2 audit (mockup 12): the top bar's + Add page duplicates the
   rail's button on desktop — hide it there, keep it ≤1024px. */
@media (min-width:1025px){#addPageTopBtn{display:none}}
@media (max-width:1024px){
  .editorTop .tbLabel{display:none}
  .editorTop .tbBoardBtn,.editorTop #splitTopBtn,.editorTop #exportBtn,.editorTop #addPageTopBtn{min-width:44px;padding:0 10px;justify-content:center}
}

/* --- floating pill toolbar over the canvas (toolbar guide: single tab
   stop via focusgroup, groups + separators, toggled state from
   aria-pressed). The pill is anchored to .stageWrap so it stays put
   while the canvas scrolls/zooms; the floating board (z-index 8) still
   sits above it when open. --- */
.stageWrap{position:relative}
.toolbar{position:absolute;top:12px;left:50%;transform:translateX(-50%);z-index:6;display:flex;flex-direction:row;align-items:center;gap:4px;width:max-content;max-width:calc(100% - 16px);margin-top:0;padding:4px 6px;background:var(--surface);background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal)}
.toolbar .tbRow{flex:1 1 auto;min-width:0;min-height:0;width:auto;border:0}
.toolbar [role="group"]{display:flex;align-items:center;gap:2px;flex:0 0 auto}
.toolbar .tool[aria-pressed="true"]{background:var(--text);border-color:var(--text);color:var(--surface)}
.toolbar .tool[aria-pressed="true"]:hover{background:var(--text)}
.pillInsert{flex:0 0 auto;white-space:nowrap;border-radius:999px;background:var(--accent);border-color:transparent;color:var(--accent-text)}
.pillInsert:hover{background:var(--accent)}
/* Pass 2 audit (mockup 8): a Tools button on the pill (desktop only)
   opens the inspector; the Insert button gains a dropdown chevron. */
.pillTools{flex:0 0 auto;white-space:nowrap}
@media (max-width:768px){.pillTools{display:none}}
/* Floating layer chip (Pass 2 audit, mockup 7): top-right of the
   canvas, below the pill so it never overlaps it; pointer-events none
   so it never blocks drawing. */
.layerChip{position:absolute;top:68px;right:12px;z-index:6;display:inline-flex;align-items:center;min-height:32px;padding:4px 12px;background:var(--surface);background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal);font-size:12px;font-weight:600;color:var(--text);pointer-events:none}
.shapePop{position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);display:none;gap:2px;padding:6px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);z-index:70}
.shapePop.open{display:flex}
.shapePop .tool{width:38px;height:38px;min-height:38px;padding:0;border:1px solid transparent;border-radius:var(--radius-xs);background:transparent;color:var(--text);display:grid;place-items:center;flex:0 0 auto}
.shapePop .tool .ic{width:19px;height:19px}
.shapePop .tool:hover{background:var(--paper2)}
.shapePop .tool[aria-pressed="true"]{background:var(--text);border-color:var(--text);color:var(--surface)}
/* Colour-picker fix: the ink-colour dot on the pill. The button is only
   24px wide in the row (the pill cannot spare a full 44px slot at 390px),
   but the ::after extends its tap area to 44px, the same trick the sheet
   swatches use (.swatch::after). The dot itself shows the current ink
   colour, like the selection bar's .selColorDot. */
.tbRowTools .tool.pillColorBtn{position:relative;width:24px;min-width:24px;height:44px;min-height:44px;padding:0}
.pillColorBtn::after{content:"";position:absolute;inset:-10px}
.pillColorDot{display:block;width:20px;height:20px;border-radius:50%;background:#18202B;border:2px solid var(--surface);box-shadow:0 0 0 1px var(--border)}
/* Scoped under #mainToolbar on purpose: the generic
   `.toolbar [role="group"]{display:flex}` rule would otherwise beat the
   plain `.colorPop{display:none}` and the palette would never hide. */
#mainToolbar .colorPop{position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);display:none;flex-wrap:wrap;gap:8px;max-width:calc(100vw - 24px);padding:10px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);z-index:70}
#mainToolbar .colorPop.open{display:flex}
#mainToolbar .colorPop .swatch{width:24px;height:24px;min-height:24px}
#mainToolbar .sizePop{position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);display:none;flex-direction:column;gap:2px;min-width:180px;padding:6px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal);z-index:70}
#mainToolbar .sizePop.open{display:flex}
#mainToolbar .sizePop button{display:flex;align-items:center;gap:12px;min-height:44px;padding:6px 12px;background:none;border:0;border-radius:8px;color:var(--text);font:inherit;text-align:left;cursor:pointer}
#mainToolbar .sizePop button.active{background:var(--surface-muted)}
#mainToolbar .sizePop .sizeOptLine{display:block;width:28px;background:currentColor;border-radius:99px;flex:none}
.tbRowTools .tool.pillSizeBtn{display:flex;align-items:center;justify-content:center}
.pillSizeLine{display:block;width:20px;height:4px;background:currentColor;border-radius:99px}
/* Floating zoom control (separate − / % / +): fixed to the viewport's
   bottom-left while editing, so it never fights the pill or the top bar
   for place and never scrolls away with the page. Same floating-pill
   language as the toolbar (surface, blur, border, shadow). Hidden
   outside the editor (body.inEditor is set by showView). The page
   pill takes the bottom-right corner (Gemini mockup, image 12). */
.zoomFab{position:fixed;left:12px;bottom:12px;z-index:40;display:none;align-items:center;gap:2px;padding:4px 6px;background:var(--surface);background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal)}
body.inEditor .zoomFab{display:flex}
.zoomFabBtn{width:36px;height:36px;min-height:36px;display:grid;place-items:center;padding:0;border:1px solid transparent;border-radius:999px;background:transparent;color:var(--text)}
.zoomFabBtn:hover{background:var(--paper2)}
.zoomFabPct{min-width:44px;min-height:36px;padding:0 6px;border:0;border-radius:999px;background:transparent;color:var(--text);font-size:12px;font-weight:600}
.zoomFabPct:hover{background:var(--paper2)}
/* Floating page navigation (‹ n / N ›): same floating-pill language as
   .zoomFab, bottom-RIGHT per the Gemini editor mockup (image 12: the
   "Page 2 / 8" pill floats at the stage's bottom-right). The zoom pill
   moves to bottom-left so the two pills never overlap. Hidden outside
   the editor (body.inEditor) and on desktop, where the Pages panel is
   the navigation. 44px targets (form-factor-adaptation, WCAG 2.5.5);
   the bottom edge is padded by the safe-area inset so the pill clears
   the home indicator / gesture bar. */
.pageNavFab{position:fixed;right:12px;bottom:12px;bottom:calc(12px + env(safe-area-inset-bottom,0px));z-index:40;display:none;align-items:center;gap:2px;padding:4px 6px;background:var(--surface);background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal)}
body.inEditor .pageNavFab{display:flex}
@media (min-width:1025px){body.inEditor .pageNavFab{display:none}}
.pageNavBtn{width:44px;height:44px;min-height:44px;display:grid;place-items:center;padding:0;border:1px solid transparent;border-radius:999px;background:transparent;color:var(--text)}
.pageNavBtn:hover{background:var(--paper2)}
.pageNavBtn:disabled{opacity:.35;cursor:default}
.pageNavBtn:disabled:hover{background:transparent}
.pageNavLabel{min-width:64px;min-height:44px;padding:0 8px;border:0;border-radius:999px;background:transparent;color:var(--text);font-size:13px;font-weight:600;white-space:nowrap}
.pageNavLabel:hover{background:var(--paper2)}
.toolbar.compact{padding:2px 4px}
.toolbar.minimal .tbDivider{display:none}
.toolbar.minimal .pillInsert .tbLabel{display:none}
@media (pointer:coarse){
  .shapePop .tool{width:44px;height:44px;min-height:44px}
}
@media (max-width:1024px){
  .toolbar{top:8px;max-width:calc(100% - 4px)}
  .toolbar .tbDivider{display:none}
  .pillInsert .tbLabel{display:none}
  .pillInsert .pillInsertChev{display:none}
  .pillInsert{min-width:44px;padding:0 12px;justify-content:center}
  /* Hand fix: the pill gains the Hand tool, so its tools shrink from
     44px to 36px visual at <=1024px — the 44px tap area is kept via
     ::after (the same trick the colour dot and sheet swatches use), so
     Select/Hand/Pen/Highlighter/Eraser/dot/Lasso/Shapes all stay
     visible at 390px and only Undo/Redo sit in the row overflow, as
     before. The colour dot keeps its own 24px width and wider ::after. */
  #mainToolbar .tbRowTools .tool:not(.pillColorBtn){position:relative;width:36px;height:36px;min-height:36px}
  #mainToolbar .tbRowTools .tool:not(.pillColorBtn)::after{content:"";position:absolute;inset:-4px}
}
/* Hand discoverability: the pill's Hand button carries a visible label
   (the same .tbLabel pattern the Insert button uses) so one-finger
   scroll is findable on phones/tablets, where the status-bar hint is
   hidden. The button widens to fit the label; the pill row scrolls
   horizontally, so the row stays unbroken at 390px. Active state comes
   from .tool[aria-pressed="true"] exactly as before (form-factor-
   adaptation 44px targets via the ::after tap area; accessibility:
   visible text label, not tooltip-only). Placed after the 1024px block
   on purpose: equal specificity, so this width:auto must win over the
   36px width set there. */
#mainToolbar .tbRowTools .tool[data-tool="hand"]{width:auto;padding:0 10px;display:inline-flex;align-items:center;gap:6px}
#mainToolbar .tbRowTools .tool[data-tool="hand"] .tbLabel{font-size:12px;font-weight:600;white-space:nowrap}

/* --- tabbed left rail: Pages | Layers --- */
.railTabs{display:flex;gap:4px;border-bottom:1px solid var(--border);margin-bottom:12px}
.railTab{flex:1;min-height:44px;padding:8px 4px;border:0;border-bottom:2px solid transparent;background:transparent;color:var(--muted);font-size:12px;font-weight:600;cursor:pointer}
.railTab[aria-selected="true"]{color:var(--text);border-bottom-color:var(--accent)}

/* --- inspector: side drawer on desktop, bottom sheet on mobile --- */
#editorSheet .sheetGrip{display:none}
/* Screen 10: the header is visible at every width — "Tools & Paper"
   in Newsreader serif with the terracotta X close. (The Pass 2
   audit hid the title; the Screen 10 mockups show it.) */
/* Mockup 8 shows the canvas undimmed beside the panel: the drawer
   backdrop is transparent on desktop (the dialog stays modal — the
   canvas is visible but not clickable while the panel is open). */
@media (min-width:769px){#editorSheet::backdrop{background:transparent;backdrop-filter:none}}
@media (max-width:768px){
  dialog.sheet#editorSheet.drawerRight{width:min(560px,100vw);height:auto;max-height:92dvh;margin:auto auto 0;border:1px solid var(--border);border-left:1px solid var(--border);border-radius:18px 18px 0 0}
  #editorSheet .sheetGrip{display:block;width:40px;height:5px;border-radius:999px;background:var(--border-strong);margin:10px auto 0;cursor:grab;touch-action:none;flex:none}
}

/* --- switches (switch guide: native checkbox + switch attribute,
   custom track/knob fallback so Chrome renders the same switch) --- */
#editorSheet label.switchRow{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:28px;padding:0;font-size:13px;font-weight:500;cursor:pointer}
#editorSheet label.switchRow span{flex:1}
.switchRow input[type="checkbox"][switch]{appearance:none;-webkit-appearance:none;width:48px;height:28px;min-height:28px;margin:0;border:1px solid var(--border-strong);border-radius:999px;background:var(--paper2);position:relative;cursor:pointer;flex:0 0 auto;transition:background .15s ease}
.switchRow input[type="checkbox"][switch]::after{content:"";position:absolute;top:2px;left:2px;width:22px;height:22px;border-radius:50%;background:var(--surface);box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform .15s ease}
.switchRow input[type="checkbox"][switch]:checked{background:var(--accent);border-color:var(--accent)}
.switchRow input[type="checkbox"][switch]:checked::after{transform:translateX(20px)}
.switchRow input[type="checkbox"][switch]:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.popChecks{display:grid;gap:2px}

/* --- Insert 3x2 tile grid --- */
.insertGrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
/* Pass 2 audit (mockup 7): tiles are taller (~110px) with big dark
   icons, and the panel ends in an action row: Open Board (text),
   Written Notes [[Links]] (outlined pill), Record Audio (terracotta). */
.insertTile{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-height:110px;padding:16px 6px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text);font-size:12px;font-weight:600;line-height:1.25;text-align:center;cursor:pointer}
.insertTile:hover{background:var(--paper2)}
.insertTile .ic{width:28px;height:28px;color:var(--text)}
.insertTile span{overflow-wrap:anywhere}
.insertFoot{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}
.insertFoot .btn{flex:1;min-width:0;white-space:nowrap;border-radius:999px}
.insertFoot .btn.insertFootText{border-color:transparent;background:transparent}

/* --- Page colour swatches --- */
.pageSwatches{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.pageSwatch{width:24px;height:24px;min-height:24px}
.pageSwatch.active{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--text)}
/* Pass 2 audit (mockup 8): a visible label under each page swatch. */
.pageSwatchWrap{display:inline-flex;flex-direction:column;align-items:center;gap:4px}
.swatchLabel{font-size:10px;line-height:1.2;color:var(--muted)}

/* --- mobile: a side panel hidden by the mobileMoved class stays out of
   the layout entirely — the left rail (its content moved to the sheet
   tabs) and the links panel (closed by default, one tap away) both
   use it, so the page fills the screen. --- */
.panel.side.mobileMoved{display:none}
/* "This notebook" as Gemini's desktop mockup draws it: one compact row,
   big number over a small label, three across — the rail keeps its
   stats without the old full-width rows. */
.statRow3{display:flex;gap:6px;padding:4px 0 2px}
.statCell{flex:1;min-width:0;text-align:center}
.statNum{font-size:22px;font-weight:700;line-height:1.15}
.statLabel{font-size:12px;color:var(--muted);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* Pass 2 audit (mockup 17): on desktop the Written Notes block and the
   Audio block sit side by side, the audio restyled as a card; stacked
   on mobile, as before. */
@media (min-width:1025px){
  .notesAudioRow{display:flex;gap:16px;align-items:stretch}
  .notesAudioRow .noteBlock{flex:1 1 auto;min-width:0}
  .notesAudioRow .studioRow{flex:0 0 300px;margin-top:16px;padding:14px 16px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);flex-direction:column;align-items:flex-start}
  .notesAudioRow .studioRow .kbd{flex:none;min-width:0}
}
/* The Links toggle lives in the editor top bar but only matters where
   the panel can be closed (≤1024px); on wider screens the panel is
   always open, so the button stays hidden. (Scoped to min-width:1025px:
   a bare display:none here would beat the ≤1024px inline-flex rule
   below it in the cascade, hiding the toggle everywhere.) */
@media (min-width:1025px){#linksToggleBtn{display:none}}
#editorSheet .sheetGrip:active{cursor:grabbing}

/* --- Long-press fix: suppress the native copy/paste callout on reader
   prose (touch only). Selection itself is untouched (no user-select:none),
   and the app's own selection bar keeps working off selectionchange. --- */
@media (pointer:coarse){
  #readerArticle, #pdfView .textLayer, #parallelRead .textLayer, #parallelRead .prPane{-webkit-touch-callout:none}
}
/* --- Reader chrome is never selectable: only book text can be selected
   and highlighted. A drag starting on a chrome label (e.g. the "Quick
   Markup" button) used to select the word "Quick" and highlight it into
   the Annotations list. Book text is untouched: #readerArticle prose and
   the PDF text layers keep their default selection, and the selection
   bar still appears for book text. --- */
.readerTop, #readerMobileBar, #readerSide, #readerToolDock,
#readerSelBar, #readerSheet, .readerPager, #ttsBar, .pdfPageNum{
  -webkit-user-select:none; user-select:none;
}
.reader.dark .textLayer mark{mix-blend-mode:lighten}
.prSelBar{max-width:calc(100vw - 16px)}
.readerToolDock{position:fixed;right:16px;bottom:max(18px,env(safe-area-inset-bottom,18px));z-index:76;display:flex;flex-direction:column;align-items:flex-end;gap:10px;}
.readerToolPanel{background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:14px;padding:12px;box-shadow:var(--shadow-modal);max-width:calc(100vw - 32px);display:flex;flex-direction:column;gap:10px;}
.readerToolPanel.hidden{display:none}
.readerToolRow{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.readerToolBtn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:10px;border:1px solid var(--border);background:var(--paper2);color:var(--text);font:inherit;font-size:13px;cursor:pointer;}
.readerToolBtn.active,.readerToolBtn[aria-pressed="true"]{background:var(--accent-soft);border-color:var(--accent);color:var(--accent);}
.readerToolBtn:disabled{opacity:.45;cursor:not-allowed;}
.readerToolColors{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
/* Floating annotation panel: one stacked row per tool — name arms it, the
   round swatch beside it opens that tool's "<Tool> color" sheet. Rows are
   44px, thumb-first on a phone (reference video r06). */
.readerToolList{display:flex;flex-direction:column;gap:8px;}
.readerToolItem{display:flex;gap:8px;align-items:center;}
.readerToolItem .readerToolBtn{flex:1;justify-content:flex-start;min-height:44px;font-size:14px;}
.readerToolSwatch{width:44px;height:44px;min-width:44px;min-height:44px;border-radius:999px;border:1px solid var(--border-strong);cursor:pointer;padding:0;box-shadow:var(--shadow-modal);background-image:linear-gradient(var(--sw,transparent),var(--sw,transparent)),repeating-conic-gradient(#c9c9c9 0% 25%,#fff 0% 50%);background-size:auto,14px 14px;}
/* "<Tool> color" bottom sheet: colour grid + Opacity slider (reference r06) */
.toolColorSheet{max-height:min(76vh,76dvh);}
.toolColorGrid{display:grid;grid-template-columns:repeat(6,1fr);gap:10px;padding:14px 0 6px;}
.toolColorCell{aspect-ratio:1;min-width:44px;min-height:44px;border-radius:12px;border:1px solid var(--border-strong);background:var(--cell);cursor:pointer;display:grid;place-items:center;padding:0;}
.toolColorCell.sel{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--accent);}
.toolColorCell .toolColorCheck{font-size:22px;font-weight:700;opacity:0;line-height:1;}
.toolColorCell.sel .toolColorCheck{opacity:1;}
.toolOpacityWrap{padding:8px 0 4px;display:flex;flex-direction:column;gap:8px;}
.toolOpacityRow{display:flex;align-items:center;gap:10px;}
.toolOpacityTrack{position:relative;flex:1;height:44px;border-radius:10px;border:1px solid var(--border-strong);background:repeating-conic-gradient(#c9c9c9 0% 25%,#fff 0% 50%);background-size:16px 16px;overflow:hidden;}
.toolOpacityFill{position:absolute;left:0;top:0;bottom:0;width:60%;}
.toolOpacityTrack input[type=range]{position:absolute;inset:0;width:100%;height:100%;margin:0;-webkit-appearance:none;appearance:none;background:transparent;cursor:pointer;}
.toolOpacityTrack input[type=range]::-webkit-slider-runnable-track{background:transparent;}
.toolOpacityTrack input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:28px;height:28px;border-radius:999px;background:var(--surface);border:2px solid var(--text);box-shadow:0 1px 4px rgba(0,0,0,.3);margin-top:8px;}
.toolOpacityTrack input[type=range]::-moz-range-track{background:transparent;}
.toolOpacityTrack input[type=range]::-moz-range-thumb{width:28px;height:28px;border-radius:999px;background:var(--surface);border:2px solid var(--text);box-shadow:0 1px 4px rgba(0,0,0,.3);}
.toolOpacityVal{font-size:13px;font-weight:600;min-width:44px;text-align:right;}
.readerFabRow{display:flex;align-items:center;gap:8px;}
.readerFab{width:48px;height:48px;border-radius:999px;background:var(--surface);color:var(--text);border:1px solid var(--border-strong);box-shadow:var(--shadow-modal);position:relative;display:grid;place-items:center;cursor:pointer;}
.readerFab.armed{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent),var(--shadow-modal);}
.readerFabDot{position:absolute;top:2px;right:2px;width:12px;height:12px;border-radius:999px;border:2px solid var(--surface);background:var(--accent);pointer-events:none;}
.readerFabMini{width:40px;height:40px;border-radius:999px;background:var(--surface);color:var(--text);border:1px solid var(--border-strong);box-shadow:var(--shadow-modal);display:grid;place-items:center;cursor:pointer;}
.readerFabMini.hidden{display:none}
/* ============ Pass 4: Reader Studio, PDF OCR & Parallel Read ============
   Gemini plan Pass 4, mockups 2 / 4 / 9 / 14 / 16 / 18. Restyle only:
   no element id or data-* attribute is renamed, every restyled control
   already exists (Wiki / Lookup / Share / Listen-in-PR do not exist in
   the app and were NOT built — see the Pass 4 report). Guides used:
   "tabs" (4-tab rail: aria-selected + pseudo-element underline, initial
   state in HTML), "dialog" (bottom sheets stay native <dialog>),
   "form-factor-adaptation" (44px targets on coarse pointers, safe-area
   padding on the fixed mobile bar), "viewport-aware-dropdowns" (the
   floating selection bar keeps its existing JS positioning — anchor
   positioning was not used, it needs Chrome 125+). */

/* --- Reader top bar (mockup 18): title + Aa Options + OCR + Bookmark +
   Focus join the single top bar; the thin terracotta progress line
   (#readProgress) already exists. --- */
.readerTopTitle{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-display);font-size:17px;font-weight:600;letter-spacing:-.01em;color:var(--text)}
.readerTop .btn.marked{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
@media (max-width:1024px){.readerFocusBtn{display:none}}
@media (max-width:768px){.readerTopTitle{display:none}}

/* --- Reader left rail (mockup 18): 4-tab rail. Narrow icon rail on
   desktop, horizontal tab row in the mobile drawer. The lists keep their
   ids (tocList / bookmarkList / annoList / thumbList). --- */
#readerSide{display:flex;flex-direction:row;align-items:stretch;padding:0;overflow:hidden}
.sideTabs{flex:0 0 64px;display:flex;flex-direction:column;gap:2px;padding:8px 4px;border-right:1px solid var(--border);background:var(--paper2)}
.sideTab{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;min-height:56px;padding:8px 2px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--muted);font-size:10px;font-weight:600;line-height:1.2;cursor:pointer}
.sideTab .ic{width:18px;height:18px}
.sideTab:hover{color:var(--text);background:var(--surface)}
.sideTab[aria-selected="true"]{color:var(--accent);background:var(--surface)}
.sideTab[aria-selected="true"]::after{content:"";position:absolute;left:0;top:8px;bottom:8px;width:3px;border-radius:3px;background:var(--accent)}
.sidePanels{flex:1 1 auto;min-width:0;overflow-y:auto;padding:14px}
.sidePanel[hidden]{display:none}
.sidePanel h4{display:block;margin:0 0 10px}
#readerSide .sideClose{margin-top:auto;align-self:center}
@media (max-width:1024px){
  #readerSide.open{display:flex;flex-direction:column}
  #readerSide.open .sideTabs{flex:0 0 auto;flex-direction:row;align-items:stretch;padding:6px 8px;border-right:0;border-bottom:1px solid var(--border);overflow-x:auto;scrollbar-width:none}
  #readerSide.open .sideTabs::-webkit-scrollbar{display:none}
  #readerSide.open .sideTab{flex:1 0 auto;min-width:60px}
  #readerSide.open .sideTab[aria-selected="true"]::after{left:8px;right:8px;top:auto;bottom:0;width:auto;height:3px}
  #readerSide.open .sideClose{margin:0 0 0 auto;align-self:center;flex:0 0 auto}
}

/* --- Reading Options sheet (mockup 16): theme swatches, size slider,
   4-button action grid. The sheet is already a native bottom-sheet
   dialog; the grip drags it down to dismiss. --- */
.sheetGrip{display:none}
@media (max-width:768px){
  .sheetGrip{display:grid;place-items:center;padding:10px 0 2px;cursor:grab;touch-action:none;flex:none}
  .sheetGrip span{width:40px;height:5px;border-radius:999px;background:var(--border-strong)}
}
.themeSwatches{gap:8px}
.themeSwatch{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:6px 14px 6px 8px;border:1px solid var(--border);border-radius:999px;background:var(--surface);color:var(--text);font-size:13px;font-weight:600;cursor:pointer}
.themeSwatch[aria-pressed="true"]{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.themeSwatchDot{width:22px;height:22px;border-radius:50%;border:1px solid var(--border-strong);flex:0 0 auto}
.themePaper{background:#F7F5F0}
.themeSepia{background:#FBF3D9}
.themeObsidian{background:#121214}
.sizeRow input[type=range]{flex:1;min-width:110px}
.actionGrid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.actionTile{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-height:64px;padding:10px 4px;font-size:12px}
.actionTile .ic{width:20px;height:20px}

/* --- OCR (mockup 2): the result card becomes a floating popover card;
   the dashed terracotta box marks the page being recognised. --- */
#ocrBox{max-width:560px;margin:14px auto 0;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal)}
#ocrBox .cardHead b{font-family:var(--font-display);font-size:17px;font-weight:600}
#ocrBox #ocrText{font-family:var(--font-reading)}
.ocrRegion{position:absolute;inset:12px;z-index:4;pointer-events:none;border:2px dashed var(--accent);border-radius:var(--radius-xs);background:color-mix(in srgb,var(--accent) 6%,transparent)}
.ocrRegion span{position:absolute;top:-11px;left:12px;padding:2px 8px;background:var(--surface);color:var(--accent);border:1px solid var(--accent);border-radius:999px;font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap}
.ocrRegion.hidden{display:none!important}

/* --- Listen TTS bar (mockup 18): docked bottom player bar. --- */
.ttsBar{position:sticky;bottom:12px;z-index:40;max-width:860px;margin:14px auto 0;padding:8px 14px;border-radius:999px;box-shadow:var(--shadow-modal)}
.ttsWhere{color:var(--muted);max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media (max-width:1024px){.ttsBar{border-radius:var(--radius-md)}}

/* --- Parallel Read top bar (mockup 9): one row, nothing floating over
   prose. Sync is a segmented control (Chapter = by chapter/page,
   Page = by overall position, Off added so the old off-mode survives);
   the floating Annotate button is retired — the top-bar button and the
   mobile bottom bar call the same handler. --- */
@media (min-width:1025px){
  .prBar{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
  .prBar::-webkit-scrollbar{display:none}
  .prBar>*{flex:0 0 auto}
}
.prSyncSeg button.active{background:var(--text);color:var(--surface)}
.prAnnotateTop{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
.prAnnotateTop:hover{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
#prAnnotateFab{display:none!important}
/* Unclip the CHAPTERS / Pages rail heading (mockup 9): it was a
   one-line ellipsis in a 76px box. */
.prRailLabel{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.35;padding:10px 8px 8px}

/* --- Mobile Parallel Read (mockup 4): draggable horizontal divider
   between the stacked books + fixed 3-button bottom bar. Listen is
   NOT in the bar — no Listen function exists in Parallel Read (the
   TTS bar lives in the normal reader, which is hidden while PR is
   open). --- */
.prBottomBar{display:none}
.prDivider{display:none}
@media (max-width:768px){
  #parallelRead{--pr-split:0.5;padding-bottom:96px}
  .prCol:first-child .prBody{height:calc((100dvh - 372px) * var(--pr-split,0.5));min-height:120px}
  .prCol:last-child .prBody{height:calc((100dvh - 372px) * (1 - var(--pr-split,0.5)));min-height:120px}
  .prDivider{display:flex;align-items:center;justify-content:center;height:28px;flex:0 0 auto;cursor:ns-resize;touch-action:none}
  .prDivider span{width:72px;height:6px;border-radius:999px;background:var(--border-strong)}
  .prBottomBar{position:fixed;left:12px;right:12px;bottom:calc(12px + env(safe-area-inset-bottom,0px));z-index:45;display:grid;grid-template-columns:repeat(3,1fr);gap:4px;padding:6px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-modal)}
  .prBottomBtn{display:flex;flex-direction:column;align-items:center;gap:2px;min-height:52px;padding:6px 4px;border:0;border-radius:var(--radius-xs);background:transparent;color:var(--text);font-size:11px;font-weight:600;cursor:pointer}
  .prBottomBtn[aria-pressed="true"]{color:var(--accent)}
  .prBottomBtn .ic{width:20px;height:20px}
}

/* ============ Screen 01 — Library Shelf (Gemini share 2026-11-22, screens 01/16/31) ============
   User brief, followed literally. Light-mode mockups; dark tokens come
   from the brief's locked design system in :root.
   Guides used (modern-web-guidance, retrieved this turn):
   css-layout (explicit grid tracks; flexbox for the meta row and header),
   card (<article> root, regions in source order, subgrid not needed —
   cards here do not share row tracks), responsive-design (dvh units for
   the mobile FAB's safe-area offset), form-factor-adaptation (44px
   touch targets on coarse pointers; icon-only buttons labelled).
   No ids or data-* attributes were renamed. The mobile tab bar
   (#libraryBar) has no place in the new layout and is hidden — see
   the report for where its entries went. */

/* Header: 56px, opaque, 1px bottom border — no translucency, no blur
   (the brief bans glassmorphism). */
#view-library .masthead{position:sticky;top:0;min-height:56px;padding:0 14px;background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none;border-bottom:1px solid var(--border)}
#view-library .wordmarkName{font-size:28px}
/* Search pill: 40px on tablet/desktop; the ⌘K keycap is JetBrains Mono. */
@media (min-width:769px){#view-library .search{min-height:40px}}
#view-library .searchKbd{font-family:var(--font-mono)}
/* "Saved" stays visible on tablet (mockup 16); phones hide it (old rule). */
@media (min-width:769px) and (max-width:1024px){#view-library .saveFlag{display:block}}
#view-library .shelfBar{margin-bottom:24px}
/* Active filter: dark ink on desktop/tablet (mockups 01/16), terracotta
   on phones (mockup 31). Overrides the Pass 1 desktop inversion. */
@media (min-width:1025px){#chipRow .chip.active{background:var(--text);color:var(--surface);border-color:var(--text)}}
@media (max-width:768px){#chipRow .chip.active{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}}

/* Cards: white frame with the cover inset, portrait 4:5 covers, serif
   cover titles. Below the cover, in order: status + % read row, thin
   terracotta progress bar, serif title, type label. */
#view-library .bookCard{padding:12px 12px 0}
#view-library .book{aspect-ratio:4/5;border-radius:8px;box-shadow:var(--shadow-cover),inset 0 0 0 1px rgba(255,255,255,.09)}
#view-library .book .bookTitle{font-family:var(--font-display);font-weight:600}
#view-library .bookBelow{display:flex;flex-direction:column;gap:8px;padding:12px 2px 14px}
#view-library .bookMeta{display:flex;justify-content:space-between;gap:8px;margin:0;padding:0;font-size:11px;line-height:1.55;color:var(--muted)}
#view-library .bookMeta span{display:inline}
#view-library .bookProgress{height:4px;border:0}
#view-library .bookTitleBelow{display:-webkit-box}
#view-library .bookKindBelow{display:block;font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
/* Cover title stays on the cover on desktop/tablet (mockup 16); on
   phones the title lives below the cover only (mockup 31). */
@media (min-width:769px){#view-library .bookTitleCover{display:-webkit-box}}
@media (max-width:768px){#view-library .bookTitleCover{display:none}}
/* "···" is plain ink text on the card frame, not a dark chip. */
#view-library .bookMenu{background:transparent;border:0;color:var(--text)}
#view-library .bookMenu:hover{background:var(--paper2)}

/* No bottom tab bar on the library in the new design. */
#libraryBar{display:none}
@media (max-width:768px){
  .layout.shelf{padding-bottom:120px}
  /* Floating "+ New" pill, bottom-right (mockup 31). */
  #view-library .libFab{
    display:flex;align-items:center;justify-content:center;gap:8px;
    width:auto;min-width:56px;height:56px;padding:0 20px;border-radius:999px;
    font-family:var(--font-ui);font-size:15px;font-weight:600;
    position:fixed;right:16px;bottom:calc(20px + env(safe-area-inset-bottom,0px));z-index:46;
    border:0;background:var(--accent);color:var(--accent-text);box-shadow:var(--shadow-modal);cursor:pointer;
  }
  #view-library .libFab .ic{width:20px;height:20px}
}

/* ============ Screen 03: Shelf Options drawer/sheet ============
   Redesign of the existing #librarySheet (Pass 1) to match the Screen 03
   mockups (desktop/tablet/mobile) 1:1. Section order follows the brief
   on all devices (This shelf -> Library backup -> Quick launch ->
   Samples & app); the mobile mockup orders Focus before Backup, which
   is a mockup-vs-brief difference — the brief wins. All rules are
   scoped to #librarySheet so no earlier screen changes.
   Guides used: navigation-drawer (modal <dialog> in the top layer,
   Esc + light dismiss + Close button), dialog (aria-labelledby, no
   role/aria-modal on a native modal, overscroll-behavior:contain on
   dialog:modal + ::backdrop), light-dismiss-a-dialog (closedby="any"
   with the existing closedBy fallback in app.js). */

/* 340px right-hand slide-over on desktop/tablet; 100% opaque. */
dialog.sheet.drawerRight#librarySheet{width:min(340px,100vw)}
/* Subtle backdrop dim, no blur — the drawer itself is fully opaque. */
dialog.sheet.drawerRight#librarySheet::backdrop{background:rgba(20,16,12,.45);backdrop-filter:none;overflow:hidden}

/* Stat tiles: big number on top, label below (mockups); the icon only
   shows on mobile, top-right, as in the mobile mockup. Labels are set
   lowercase by renderLibrary (plural()), so capitalize for display. */
#librarySheet .statCard{position:relative}
#librarySheet .statCard b{order:-1}
#librarySheet .statCard>span:not(.statIcon){text-transform:capitalize;color:var(--text);font-weight:500}
#librarySheet .statCard .statIcon{display:none;position:absolute;top:10px;right:10px;color:var(--muted)}
@media (max-width:768px){
  #librarySheet .statCard .statIcon{display:block}
}

/* Storage: "Local Storage" row with the measured value, bar, then the
   "Local-first IndexedDB" caption — the desktop/mobile mockup layout.
   The bar fill is ink, not terracotta, as the mockups draw it. */
#librarySheet .storageCard{background:transparent;border:0;border-radius:0;padding:0;margin-top:4px}
#librarySheet .storageRow{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:6px}
#librarySheet .storageRow>span{font-size:12px;color:var(--muted)}
#librarySheet .storageRow>b{font-size:12px;font-weight:600}
#librarySheet .storageCard .storageBar{background:var(--paper2)}
#librarySheet .storageFill{background:var(--text)}
#librarySheet .storageCard .sheetNote{margin:6px 0 0}

/* Row groups: separate bordered buttons with gaps on desktop/tablet
   (mockups), the grouped rounded card on mobile (mobile mockup). */
#librarySheet .drawerRows{background:transparent;border:0;border-radius:0;gap:8px;overflow:visible}
#librarySheet .drawerRow{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface)}
#librarySheet .drawerRow:last-child{border-bottom:1px solid var(--border)}
@media (max-width:768px){
  #librarySheet .drawerRows{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);gap:0;overflow:hidden}
  #librarySheet .drawerRow{border:0;border-bottom:1px solid var(--border);border-radius:0;background:transparent}
  #librarySheet .drawerRow:last-child{border-bottom:0}
}

/* Quick launch: standalone full-width terracotta button, label centred.
   The timer label is JetBrains Mono; it is one span because
   setTimerLabel() rewrites the span's textContent on every tick
   (shared with the editor's Focus button), so the "Start Focus " prefix
   cannot live in a separate span. */
#librarySheet .focusBtn{background:var(--accent);border-color:var(--accent);color:var(--accent-text);font-weight:600}
#librarySheet .focusBtn:hover{background:var(--accent);filter:brightness(1.07)}
#librarySheet .focusBtn .ic{color:var(--accent-text)}
#librarySheet .focusBtn .drawerChev{display:none}
#librarySheet .focusBtn>span{flex:1;text-align:center}
#librarySheet .focusBtn #timerLabel{font-family:var(--font-mono);font-weight:600}

/* Mobile: rounded slide-up bottom sheet (not the full-height sheet the
   generic drawerRight rule gives). The grip shows on mobile only via
   the generic .sheetGrip rule. */
@media (max-width:768px){
  dialog.sheet.drawerRight#librarySheet{
    width:100vw;height:auto;max-height:92dvh;margin:auto auto 0;
    border:1px solid var(--border);border-radius:18px 18px 0 0;
  }
}
@keyframes sheetUp{from{transform:translateY(24px);opacity:0}to{transform:none;opacity:1}}
@media (prefers-reduced-motion:no-preference) and (max-width:768px){
  dialog.sheet.drawerRight#librarySheet:modal{animation:sheetUp .18s ease}
}

/* ============ Screen 05: PDF Reader view (mockups desktop/tablet/mobile)
   Redesign of the Pass 4 Reader Studio to match the mockups 1:1. Restyle
   only: no element id or data-* attribute is renamed, every restyled
   control already exists. Guides used: "tabs" (selected tab = accent
   border + bottom bar, not colour alone; the mockup's 2x2 tab grid is
   kept even though the guide prefers a single row — four labelled tabs
   cannot fit one row in 268px without scrolling), "navigation-drawer"
   (268px persistent sidebar on desktop, slide-over on tablet, bottom
   drawer on mobile; the existing class-toggle open/close is kept, not
   rebuilt as a popover, so the verified toggle/jump-to-close behaviour
   is unchanged), "toolbar" (single-row 56px top bar, one primary action
   per group). Deviations from the mockups are listed in
   files/screen05-pdf-reader/CHECKS.md. */

/* --- Single-row 56px top bar: Back, sidebar toggle, Scroll|Page,
   status readout (one line, ellipsis), Undo, Annotate, More. The
   terracotta progress line and the resume label are retired — the
   status readout now carries the page + %. Opaque surface, no blur
   (ban: no glassmorphism). --- */
.readerTop{position:sticky;top:0;z-index:30;height:56px;flex-wrap:nowrap;gap:8px;padding:0 10px;margin-bottom:12px;background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none;border:0;border-bottom:1px solid var(--border);border-radius:0}
#readProgress{display:none}
.readerResume{display:none}
.readerTopPage{display:none;font-family:var(--font-mono);font-size:13px;font-weight:600;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:0 1 auto;min-width:0}
/* Focus moved from the top bar into the More sheet (it is the 5th
   action tile there); the old <=1024px hide must not hide the tile. */
#readerSheet .readerFocusBtn{display:flex}
/* The brief's Annotate button is terracotta; .btn.primary is dark
   (var(--text)) everywhere else, so scope the terracotta to the
   reader's Annotate button only. */
#annotateFab{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}

/* --- Left sidebar: 268px persistent column on desktop. The Pass 4
   icon rail becomes a 2x2 tab grid; the panel headings are redundant
   with the tab labels and are hidden. Flat cream background (no card)
   so the tabs and thumbnails read as cards on the page surround. --- */
#readerGrid{grid-template-columns:268px minmax(0,1fr);gap:24px}
#readerSide{flex-direction:column;top:68px;max-height:calc(100dvh - 84px);background:transparent;border:0;box-shadow:none;border-radius:0}
.sideTabs{flex:0 0 auto;display:grid;grid-template-columns:1fr 1fr;gap:6px;padding:10px;border-right:0;border-bottom:1px solid var(--border);background:transparent}
.sideTab{flex-direction:row;justify-content:flex-start;align-items:center;min-height:44px;padding:8px 10px;border:1px solid var(--border);border-radius:8px;background:var(--surface);font-size:12px;line-height:1.2}
.sideTab .ic{width:18px;height:18px;flex:0 0 auto}
.sideTab[aria-selected="true"]{color:var(--text);border-color:var(--accent);background:var(--surface)}
.sideTab[aria-selected="true"]::after{left:8px;right:8px;top:auto;bottom:0;width:auto;height:3px}
.sidePanels{padding:12px 14px 0}
.sidePanel h4{display:none}
#readerSide.open h4{display:none}
#thumbList{grid-template-columns:1fr 1fr;gap:10px}
.thumbItem.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}

/* --- Center viewport: #F6F3EC surround, crisp white page sheet. The
   per-page header strip is retired; the page itself carries the shadow.
   Highlights already use mix-blend-mode:multiply (see .textLayer mark). --- */
#pdfView{background:var(--bg);border:0;border-radius:0;box-shadow:none;padding:18px}
.pdfHead{display:none}
.pdfPage{box-shadow:var(--shadow-sheet)}
/* Reader theme — Sepia: warm the PDF sheets only. A sepia filter on the
   whole #pdfView would also filter its #F6F3EC padding into a saturated
   yellow frame (measured (255,255,177) even at sepia(0.45) saturate(2.5)),
   so the tint lives here, on the white sheets. Measured on the Demo PDF:
   sheet renders (250,248,220) warm cream, black text stays pure black,
   so contrast is unchanged. Obsidian keeps the container invert in JS. */
#pdfView[data-reader-theme="sepia"] .pdfPage{filter:sepia(0.7) saturate(3) hue-rotate(-12deg) brightness(0.98)}
.readerColumn{padding-bottom:96px}

/* --- Bottom floating center pill: Prev / Page X of Y / Next. --- */
.readerPager{position:fixed;left:50%;transform:translateX(-50%);bottom:max(16px,env(safe-area-inset-bottom,16px));z-index:70;display:flex;align-items:center;gap:4px;flex-wrap:nowrap;max-width:calc(100vw - 32px);margin:0;padding:4px 6px;background:var(--surface);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal)}
.readerPager .btn{border:0;background:transparent;box-shadow:none}
.readerPager #pageLabel{font-family:var(--font-mono);font-size:13px;padding:0 6px}

/* --- Quick Markup pill: the annotation panel becomes a horizontal
   4-icon pill (Highlighter, Underliner, Strikethrough, Undo). The
   per-tool colour swatch shrinks to a 16px corner dot — colour picking
   is still available from the selection bar and the More sheet. The
   FAB toggle hides while the panel is open, so the open state matches
   the mockup (pill only, no FAB). --- */
.readerToolPanel{flex-direction:row;align-items:center;gap:4px;padding:6px;border-radius:999px;min-width:0}
.readerToolList{flex-direction:row;align-items:center;gap:4px}
.readerToolItem{position:relative;gap:0}
.readerToolPanel .readerToolBtn{width:44px;height:44px;min-width:44px;min-height:44px;padding:0;justify-content:center;border:1px solid transparent;border-radius:999px;background:transparent;font-size:13px}
.readerToolPanel .readerToolBtn .ic{width:20px;height:20px}
.readerToolItem .readerToolBtn{flex:none;font-size:13px}
.readerToolPanel .readerToolBtn.active,.readerToolPanel .readerToolBtn[aria-pressed="true"]{background:var(--accent-soft);border-color:var(--accent);color:var(--accent)}
.readerToolPanel .readerToolSwatch{position:absolute;right:1px;bottom:1px;width:16px;height:16px;min-width:16px;min-height:16px;border:2px solid var(--surface);box-shadow:none}
.readerToolPanel .readerUndoBtn{width:44px;height:44px;min-width:44px;min-height:44px;padding:0;justify-content:center;border:1px solid transparent;border-radius:999px;background:transparent}
.readerToolDock.panelOpen .readerFabRow{display:none}

/* --- Desktop: the sidebar toggle collapses the 268px column. The
   sidebar starts .open on desktop (openBook sets it), so the toggle
   genuinely collapses / reopens it; the grid collapses with it. --- */
@media (min-width:1025px){
  #readerSide:not(.open){display:none}
  #readerGrid:has(#readerSide:not(.open)){grid-template-columns:1fr}
}

/* --- Mobile bottom bar: hidden above 720px, and hidden in Parallel
   Read (which has its own bar). --- */
.readerMobileBar{display:none}
body.prOn #readerMobileBar{display:none}

/* --- Tablet (721-1024px): short status readout, sidebar becomes a
   slide-over below the top bar (top:56px, not covering it). --- */
@media (max-width:1024px){
  #readerTopTitle{display:none}
  #readerTopPage{display:block}
  #readerGrid{grid-template-columns:1fr;gap:16px}
  #readerSide{display:none}
  #readerSide.open{display:flex;flex-direction:column;position:fixed;top:56px;left:0;bottom:0;width:min(268px,86vw);z-index:80;background:var(--surface);border-right:1px solid var(--border);border-radius:0;box-shadow:0 0 32px rgba(0,0,0,.28)}
  #readerSide.open .sideClose{display:inline-flex}
  #readerSide.open .sideTabs{display:grid;grid-template-columns:1fr 1fr;gap:6px;flex:0 0 auto;padding:10px;border-right:0;border-bottom:1px solid var(--border);background:transparent;overflow:visible}
  #readerSide.open .sideTab{flex:none;min-width:0}
}

/* --- Mobile (<=720px): slim static top bar (Back, Page X / Y,
   Annotate, More), bottom bar with TOC, pagination, Undo, Quick
   Markup; sidebar becomes a bottom drawer. The center pagination pill
   is replaced by the bottom-bar pagination. --- */
@media (max-width:720px){
  .readerTop{position:static;height:56px;min-height:48px;padding:6px 8px;gap:6px;overflow-x:auto;scrollbar-width:none}
  .readerTop::-webkit-scrollbar{display:none}
  #readerTopPage{display:block}
  #readerSideToggle{display:none}
  .readerTop .seg{display:none}
  #readerTopUndo{display:none}
  .readerPager{display:none}
  .readerColumn{padding-bottom:84px}
  #readerMobileBar{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:90;align-items:center;gap:8px;padding:8px 12px calc(8px + env(safe-area-inset-bottom,0px));background:var(--surface);border-top:1px solid var(--border)}
  /* z-index 90, above the open drawer (80): the drawer must not cover
     the bottom bar, or its TOC toggle is untappable while the drawer is
     open and the drawer can only be closed with the ×. The bar stays
     visible over the drawer's bottom edge; drawer geometry is unchanged. */
  .readerMobilePager{flex:1 1 auto;display:flex;align-items:center;justify-content:center;gap:2px;min-width:0}
  .readerMobilePager .btn{border:0;background:transparent;box-shadow:none;padding:0 4px}
  #mobilePageLabel{font-family:var(--font-mono);font-size:12px;white-space:nowrap}
  .readerMobileMarkup{flex-direction:column;gap:2px;font-size:10px;padding:4px 8px;min-height:44px}
  .readerToolDock{bottom:calc(72px + env(safe-area-inset-bottom,0px))}
  .readerToolDock .readerFabRow{display:none}
  #readerSide.open{top:auto;left:0;right:0;bottom:0;width:auto;height:min(72dvh,560px);border-right:0;border-top:1px solid var(--border);border-radius:16px 16px 0 0;box-shadow:0 -12px 32px rgba(0,0,0,.28);overflow:hidden}
  #readerSide.open::before{content:"";display:block;width:40px;height:5px;margin:10px auto 0;border-radius:999px;background:var(--border-strong);flex:0 0 auto}
}

/* ============ SCREEN 07: EPUB Reader, Sepia Page Mode ============
   Every rule here is scoped under #view-reader.sepiaPage, a class JS
   adds only when the open book is an EPUB in Sepia theme AND Page
   mode — so the PDF reader (Screen 05), Library, palette and EPUB
   Paper/Obsidian/Scroll are untouched. Palette per the brief:
   surround #EFE6D5, book card #F7F1E3, ink #2B241D, terracotta #C85A32.
   (MWG css-layout guide, retrieved 2026-11-23: long prose that should
   split into balanced columns uses multi-column, newspaper-style.) */
#view-reader.sepiaPage{background:#EFE6D5}
#view-reader.sepiaPage .readerTop{background:#F7F1E3;border-bottom-color:#DDD2BC;margin-bottom:0}
#view-reader.sepiaPage .readerTop .iconBtn,#view-reader.sepiaPage .readerTop .btn{background:#F7F1E3;border-color:#DDD2BC}
#view-reader.sepiaPage .readerTop .seg{background:#EFE6D5;border-color:#DDD2BC}
#view-reader.sepiaPage .readerTopTitle{display:block;text-align:center}
#view-reader.sepiaPage #readerTopPage{display:none}
/* The 2.5px terracotta progress line, spanning the bottom edge of the
   top header: the native <progress> sits directly under the bar
   (margin-bottom:0 above) and sticks under it while scrolling. */
#view-reader.sepiaPage #readProgress{display:block;height:2.5px;position:sticky;top:56px;z-index:30}
#view-reader.sepiaPage #readProgress::-webkit-progress-value{background:#C85A32}
#view-reader.sepiaPage #readProgress::-moz-progress-bar{background:#C85A32}
/* Sepia palette for the book card (the base .reader.sepia stays as it
   was, so Sepia in Scroll mode is unchanged). The book title + badge
   are hidden in Page mode — the chapter heading carries the page, as
   in the mockups. Highlights are already translucent (0.6 opacity
   inline); multiply blends the wash into the cream paper. */
#view-reader.sepiaPage .reader.sepia{--paper:#F7F1E3;--text:#2B241D;--text-soft:#4A3E2E;--muted:#7A6C5C;--border:#DCCFB2;--border-strong:#C9B78F;background:#F7F1E3;color:#2B241D}
#view-reader.sepiaPage #readerTitle,#view-reader.sepiaPage #readerBadge{display:none}
#view-reader.sepiaPage #readerBody mark{mix-blend-mode:multiply}
/* Sidebar: flat cream card, opaque in every form (drawer / bottom
   sheet included — no translucency, per the ban). The active chapter
   gets the terracotta left indicator + pale wash from the mockups. */
#view-reader.sepiaPage #readerSide{background:#F7F1E3;border:1px solid #DDD2BC}
#view-reader.sepiaPage #readerSide.open{background:#F7F1E3}
#view-reader.sepiaPage .sideTab{background:#F7F1E3;border-color:#DDD2BC}
#view-reader.sepiaPage .sideTab[aria-selected="true"]{background:#F7F1E3;border-color:#C85A32}
#view-reader.sepiaPage .tocItem.active{color:#C85A32;background:rgba(200,90,50,.08);box-shadow:inset 3px 0 0 #C85A32}
/* Bottom bars keep the sepia card colour. */
#view-reader.sepiaPage .readerPager{background:#F7F1E3;border-color:#DDD2BC}
#view-reader.sepiaPage .readerMobileBar{background:#F7F1E3;border-top-color:#DDD2BC}
/* Desktop: the book card widens and the prose flows in two balanced
   columns, as in the desktop mockup; the chapter heading never strands
   at the bottom of a column. Tablet and phone stay single-column. */
@media (min-width:1025px){
  #view-reader.sepiaPage .reader{max-width:880px}
  #view-reader.sepiaPage #readerBody{columns:2;column-gap:48px}
  #view-reader.sepiaPage #readerBody h3{break-after:avoid}
}
/* Mobile: the top bar is static, so the progress line flows under it
   instead of sticking to the viewport. */
@media (max-width:720px){
  #view-reader.sepiaPage #readProgress{position:static}
}

/* ============ SCREEN 08: EPUB Reader, Night Theme Scroll Mode + Annotations ============
   Every rule here is scoped under #view-reader.nightScroll, a class JS
   adds only when the open book is an EPUB in Obsidian/Night theme AND
   Scroll mode — so the PDF reader (Screen 05), Library, palette and EPUB
   Paper/Sepia/Page are untouched. Palette per the brief: background
   #121110, reading column + sidebar #1B1917, soft warm ivory text
   #E6E0D6, dark accent #D96B43. (Border fix 2026-11-23: the brief's
   #2D2A26 borders read as pale/white outlines on the #1B1917 surfaces —
   #2D2A26 is LIGHTER than the background — so every night border now
   blends with its own background instead, and the dark theme variables
   are defined on this root so the sidebar can no longer inherit the
   light ones. The terracotta active-tab indicator and progress line
   stay — those are meant to be seen. Flat-cards fix 2026-11-23: the
   #221F1C card fill on the #1B1917 panel was itself a visible step that
   read as an outline around every card — in the mockups the cards are
   completely flat (colour bar + text only), so cards, the Export button
   and the active Scroll pill are now the panel colour too.)
   (MWG dark-mode guide, retrieved 2026-11-23: a subtree that must stay
   dark sets color-scheme on itself — "You can override the global theme
   for specific elements by setting color-scheme on them" — so scrollbars
   and form controls inside the reader adapt instead of staying light.) */
#view-reader.nightScroll{background:#121110;color:#E6E0D6;color-scheme:dark;--paper:#1B1917;--paper2:#221F1C;--surface:#1B1917;--text:#E6E0D6;--text-soft:#CFC8BA;--muted:#A69F95;--border:#1B1917;--border-strong:#221F1C;--accent:#D96B43}
#view-reader.nightScroll .readerTop{background:#1B1917;border-bottom-color:#1B1917}
#view-reader.nightScroll .readerTop .iconBtn,#view-reader.nightScroll .readerTop .btn{background:#1B1917;border-color:#1B1917;color:#E6E0D6}
#view-reader.nightScroll .readerTop .seg{background:#121110;border-color:#1B1917}
#view-reader.nightScroll .readerTop .seg button{color:#A69F95}
#view-reader.nightScroll .readerTop .seg button.active{background:#1B1917;border-color:#1B1917;color:#E6E0D6}
#view-reader.nightScroll .readerTopTitle{display:block;text-align:center;color:#E6E0D6}
#view-reader.nightScroll #readerTopPage{display:none}
#view-reader.nightScroll #readerMobileBar{background:#1B1917;border-top-color:#1B1917;color:#E6E0D6}
#view-reader.nightScroll #readerMobileBar .iconBtn,#view-reader.nightScroll #readerMobileBar .btn,#view-reader.nightScroll #readerSide .sideClose{background:#1B1917;border-color:#1B1917;color:#E6E0D6}
#view-reader.nightScroll .readerPager{background:#1B1917;border-color:#1B1917;color:#E6E0D6}
/* The 2.5px progress line, spanning the bottom edge of the top header:
   the native <progress> sits directly under the bar and sticks under it
   while scrolling (same pattern as Screen 07). */
#view-reader.nightScroll #readProgress{display:block;height:2.5px;position:sticky;top:56px;z-index:30}
#view-reader.nightScroll #readProgress::-webkit-progress-value{background:#D96B43}
#view-reader.nightScroll #readProgress::-moz-progress-bar{background:#D96B43}
/* Reading column: the brief's exact night palette overrides .reader.dark
   (whose paper is #17171A). The drop-cap takes the dark terracotta. */
#view-reader.nightScroll .reader.dark{--paper:#1B1917;--text:#E6E0D6;--text-soft:#CFC8BA;--muted:#A69F95;--border:#2D2A26;--border-strong:#3A362F;--accent:#D96B43;background:#1B1917;color:#E6E0D6}
#view-reader.nightScroll .reader.dark mark{background:rgba(232,197,120,.34);color:#E6E0D6}
/* The app-wide ::selection is the light theme's pale tint — over ivory
   text it washes the selected passage out to unreadable (seen in the
   first pill screenshots). Terracotta tint + ivory text, night scope only. */
#view-reader.nightScroll .reader.dark ::selection{background:rgba(217,107,67,.45);color:#E6E0D6}
/* Sidebar: flat dark card, opaque in every form (drawer / bottom sheet
   included — no translucency, per the ban). Tabs become a text row with
   a terracotta underline on the active one, as in the mockups. */
#view-reader.nightScroll #readerSide{background:#1B1917;border:1px solid #1B1917;color:#E6E0D6}
#view-reader.nightScroll #readerSide.open{background:#1B1917}
#view-reader.nightScroll #readerSide.open::before{background:#3A362F}
#view-reader.nightScroll .sideTabs{background:transparent;border-color:#1B1917}
#view-reader.nightScroll .sideTab{background:transparent;border-color:#1B1917;color:#A69F95}
#view-reader.nightScroll .sideTab .ic{display:none}
#view-reader.nightScroll .sideTab[aria-selected="true"]{color:#E6E0D6;border-color:#D96B43}
#view-reader.nightScroll .tocItem{color:#CFC8BA;border-color:#1B1917}
#view-reader.nightScroll .tocItem.active{color:#D96B43;background:rgba(217,107,67,.1);box-shadow:inset 3px 0 0 #D96B43}
#view-reader.nightScroll .thumbItem{background:#1B1917;border-color:#1B1917;color:#CFC8BA}
#view-reader.nightScroll .thumbItem.active{border-color:#D96B43}
/* Annotation cards: the round swatch becomes a coloured left bar, the
   quote stacks above its chapter label, and the Export button spans the
   panel width, as in the mockups. */
#view-reader.nightScroll #annoList .listRow.annoCard{display:flex;align-items:stretch;gap:0;padding:0;margin-bottom:10px;background:#1B1917;border:1px solid #1B1917;border-radius:8px;overflow:hidden}
#view-reader.nightScroll #annoList .annoSwatch{width:4px;height:auto;border-radius:0;margin:0;box-shadow:none;flex:0 0 4px}
#view-reader.nightScroll #annoList .annoBody{padding:10px 12px}
#view-reader.nightScroll #annoList .annoQuote{color:#E6E0D6}
#view-reader.nightScroll #annoList .annoWhere{color:#A69F95}
#view-reader.nightScroll #annoList .annoDel{background:transparent;border-color:transparent;color:#A69F95}
#view-reader.nightScroll #annoList .annoDel:hover{color:#E6E0D6}
#view-reader.nightScroll #annoList>.btn{display:block;width:100%;margin-top:12px;background:transparent;border:1px solid #1B1917;color:#E6E0D6}
/* Floating markup pill: compact and dark, with exactly the four mockup
   actions — the colour dot, Undo and OCR buttons are hidden here (they
   stay reachable in the top bar and the More sheet). */
#view-reader.nightScroll #readerSelBar{background:#1B1917;border-color:#1B1917;color:#E6E0D6;box-shadow:0 8px 24px rgba(0,0,0,.5)}
#view-reader.nightScroll #readerSelBar button{color:#E6E0D6}
#view-reader.nightScroll #readerSelBar button:hover{background:rgba(230,224,214,.1)}
#view-reader.nightScroll #readerSelBar mark{background:transparent;color:#E6E0D6}
#view-reader.nightScroll #readerSelBar .selColorBtn,
#view-reader.nightScroll #readerSelBar .selUndoBtn,
#view-reader.nightScroll #readerSelBar .selOcrBtn{display:none}
/* Annotation tool dock + FAB keep the night palette (the Quick Undo
   mini-FAB too — it uses the light --surface otherwise and stays white). */
#view-reader.nightScroll #readerToolPanel{background:#1B1917;border-color:#1B1917}
#view-reader.nightScroll .readerToolBtn{color:#E6E0D6}
#view-reader.nightScroll #readerToolFab{background:#1B1917;border-color:#1B1917;color:#E6E0D6}
#view-reader.nightScroll #readerQuickUndo{background:#1B1917;border-color:#1B1917;color:#E6E0D6}
/* Desktop: tabs become one text row (the mockups show ANNOTATIONS /
   CHAPTERS / BOOKMARKS across the top); the 2x2 grid is dropped here. */
@media (min-width:1025px){
  #view-reader.nightScroll .sideTabs{display:flex;flex-direction:row;gap:0;padding:0 8px;border-right:0;border-bottom:1px solid #1B1917;background:transparent}
  #view-reader.nightScroll .sideTab{flex:1 0 auto;flex-direction:column;justify-content:center;min-height:48px;padding:8px 2px;border:0;border-radius:0;background:transparent;font-size:11px}
  #view-reader.nightScroll .sideTab[aria-selected="true"]{color:#E6E0D6}
  #view-reader.nightScroll .sideTab[aria-selected="true"]::after{left:8px;right:8px;top:auto;bottom:0;width:auto;height:3px;background:#D96B43}
}
/* Mobile: the top bar is static, so the progress line flows under it
   instead of sticking to the viewport; the drawer tabs become one
   scrollable text row like the mockup. */
@media (max-width:720px){
  #view-reader.nightScroll #readProgress{position:static}
  #view-reader.nightScroll #readerSide.open .sideTabs{display:flex;flex-direction:row;gap:0;padding:0 8px;border-bottom:1px solid #1B1917;overflow-x:auto;scrollbar-width:none}
  #view-reader.nightScroll #readerSide.open .sideTabs::-webkit-scrollbar{display:none}
  #view-reader.nightScroll #readerSide.open .sideTab{flex:1 0 auto;min-width:60px;flex-direction:column;justify-content:center;min-height:44px;padding:8px 4px;border:0;border-radius:0;background:transparent}
}


/* ============ SCREEN 09: Notebook Editor Canvas & Toolbar ============
   Restyle of the editor workspace to the mockups. Scoped under
   #view-editor / .editorTop / #mainToolbar; earlier screens untouched.
   Design system: 100% opaque surfaces (no glassmorphism), terracotta
   accent for the active tool, Newsreader serif title. */

/* Slim 56px top bar, single row, opaque. */
#view-editor .editorTop{position:sticky;top:0;min-height:56px;padding:0 12px;flex-wrap:nowrap;background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none;border-bottom:1px solid var(--border)}
#view-editor .editorTop #noteTitle{font-family:var(--font-display);font-weight:600;font-size:20px}
#view-editor .titleField{display:flex;align-items:center;gap:6px}
#view-editor .titleField #noteTitle{flex:1;min-width:0}
#view-editor .titleField .titleEditIc{flex:0 0 auto;color:var(--muted);pointer-events:none}
/* Tablet quick path (user call 2026-11-23): the top-bar "+ Add page"
   is the one-tap way in at 769–1024px, where the rail is a slide-over.
   Desktop keeps the rail in place (base rule hides it ≥1025px);
   phones keep the slim bar (hidden ≤768px). */
@media (max-width:768px){ #view-editor .editorTop #addPageTopBtn{display:none} }
/* Tablet (user call 2026-11-23: "It's not even available on the
   tablet"): at 769–1024px the button was icon-only — a bare "+" next
   to Export that does not read as "Add page", so the user could not
   find it. The label shows for THIS button only; every other top-bar
   button keeps the icon-only tablet treatment from the <=1024px rule.
   The title input flexes (flex:1; min-width:0) and truncates, so the
   bar still fits — measured by the check, not assumed. */
@media (min-width:769px) and (max-width:1024px){
  #view-editor .editorTop #addPageTopBtn .tbLabel{display:inline}
}
/* Phone "Add page" pill (user call 2026-11-23: "It's not available on
   mobile also"): measured, not guessed — forcing the labeled top-bar
   button in overflows the phone bar by 48px at 390 (26px at 412) and
   crushes the title to 8px wide, and the middle gap between the zoom
   pill (right edge 146) and the page-nav pill (left edge 208) is only
   62px, so neither candidate spot fits a labeled button; widening the
   nav pill itself to hold it would overlap the zoom pill by 35px at
   390 (13px at 412). So the one-tap control is a labeled pill stacked
   above the page-navigation pill: the nav pill top sits at 76px + 54px
   = 130px from the bottom, so this sits at 140px (10px gap), same
   floating-pill styling, clear of the zoom pill, the nav pill and the
   bottom dock. Phones only (<=768px); the :not(.focusMode) guard hides
   it in Focus mode, like its sibling pills. */
#view-editor #pageAddFab{display:none}
@media (max-width:768px){
  body:not(.focusMode) #view-editor #pageAddFab{position:fixed;right:12px;bottom:calc(140px + env(safe-area-inset-bottom,0px));z-index:40;display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 12px;background:var(--surface);border:1px solid var(--border);border-radius:999px;box-shadow:var(--shadow-modal);color:var(--text);font-family:var(--font-ui);font-size:13px;font-weight:600;line-height:1;white-space:nowrap}
}
/* Counters removed (user call 2026-11-23): the "This notebook" stats
   block is not in the mockups. CSS-only hide, scoped to the editor's
   Links panel — the elements and their JS updates stay intact, and the
   "Links & backlinks" section above it is untouched. */
#view-editor #linksPanel .panelSub,
#view-editor #linksPanel .statRow3{display:none}
/* Links removed entirely (user call 2026-11-23: "Remove that link
   button", "It's another unnecessary thing" — linking already happens
   in the notebook text itself via [[Title]]). CSS-only hide, scoped to
   the editor view: the HTML elements and their app.js handlers stay
   intact (reversible; toggleLinksPanel / applyLinksPanel /
   openRailPanel simply become unreachable in the editor). The top-bar
   button, the whole panel (with the already-hidden counters inside it),
   and the split-rail Links button all go, at all widths. The [[...]]
   text behaviour itself is untouched. */
#view-editor .editorTop #linksToggleBtn{display:none}
#view-editor #linksPanel{display:none}
#view-editor #railBtnLinks{display:none}
/* Focus stays visible at tablet widths (mockup); icon-only on phones. */
@media (max-width:1024px){ #view-editor .editorTop .edFocus{display:inline-flex} }
@media (max-width:768px){ #view-editor .editorTop .edFocus .timerLabel{display:none} }

/* Left rail: 210px on desktop, collapsible via the top-bar toggle.
   Desktop-only: at <=1024px the base stylesheet stacks the editor
   into one column (stage first, rail below), and this rule must not
   override that collapse. */
/* The Links panel is gone (user call 2026-11-23) — see below — so the
   252px track is dropped: the paper fills the freed width. These grid
   rules are guarded to the normal editor state: split mode and Focus
   mode have their own grids, and the unguarded rule was overriding
   them (probe on this branch: split rail stretched to a 210px track,
   focus paper squeezed to 2px wide). */
@media (min-width:1025px){
  body:not(.splitOn):not(.focusMode) #view-editor .editorWrap{grid-template-columns:210px minmax(0,1fr)}
}
@media (min-width:1025px){
  body:not(.splitOn):not(.focusMode) #view-editor.railHidden #pagesPanel{display:none}
  body:not(.splitOn):not(.focusMode) #view-editor.railHidden .editorWrap{grid-template-columns:minmax(0,1fr)}
  /* Desktop rail closed (user call 2026-11-23: "You told me that you'll
     add a add page button without opening the toggle — where is it?"):
     the rail's own "+ Add page" is out of reach, so the top-bar button
     shows instead — the one-tap way in without opening the toggle.
     Rail open: stays hidden (the Pass 2 rule at line 1266 owns that
     state). Specificity (2,4,1) beats the (0,1,0) hide rule. */
  body:not(.splitOn):not(.focusMode) #view-editor.railHidden .editorTop #addPageTopBtn{display:inline-flex}
}
/* Pages | Layers as a segmented pill control. */
#view-editor .railTabs{display:flex;gap:0;background:var(--surface-muted);border:0;border-radius:999px;padding:3px;margin-bottom:12px}
#view-editor .railTab{flex:1;border-bottom:0;border-radius:999px;color:var(--muted)}
#view-editor .railTab[aria-selected="true"]{background:var(--surface);color:var(--text);border-bottom-color:transparent;box-shadow:0 1px 3px rgba(0,0,0,.14)}
/* Tablet slide-over drawer for the rail (toggleRailPanel adds
   .railDrawer; the positioning CSS previously existed only in split
   mode at >=1025px). The drawer and its backdrop start below the 56px
   top bar so the bar — including the toggle that opened the drawer —
   stays clickable while it is open. */
@media (max-width:1024px){
  #view-editor #pagesPanel.railDrawer{display:block;position:fixed;left:0;top:56px;bottom:0;z-index:70;width:300px;max-width:calc(100vw - 48px);overflow:auto;background:var(--surface);border-right:1px solid var(--border);padding:14px;overscroll-behavior:contain}
  #view-editor #railBackdrop{display:block;position:fixed;left:0;right:0;top:56px;bottom:0;z-index:65;background:rgba(0,0,0,.18)}
  #view-editor #railBackdrop.hidden{display:none}
}

/* Tool dock: opaque pill (no glass), active tool terracotta. */
#view-editor .toolbar{background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none}
#view-editor .toolbar .tool[aria-pressed="true"],#view-editor .toolbar .tool.active{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
#view-editor .toolbar .tool[aria-pressed="true"]:hover,#view-editor .toolbar .tool.active:hover{background:var(--accent)}
#view-editor #mainToolbar .shapePop .tool[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
/* Pen-only toggle is not in the mockup dock; element + handler kept. */
#view-editor .toolbar #penOnlyBtn{display:none}
#view-editor .layerChip{background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none}
#view-editor .zoomFab,#view-editor .pageNavFab{background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none}

/* Mobile <=720px: the dock becomes a fixed, horizontally scrollable
   bottom dock; the paper goes full-bleed and the zoom/page pills sit
   above the dock. */
@media (max-width:720px){
  #view-editor .toolbar{position:fixed;left:0;right:0;bottom:0;top:auto;transform:none;z-index:40;width:auto;max-width:none;margin-top:0;border:0;border-top:1px solid var(--border);border-radius:0;padding:6px 8px calc(6px + env(safe-area-inset-bottom,0px));overflow-x:auto;scrollbar-width:none}
  #view-editor .toolbar::-webkit-scrollbar{display:none}
  #view-editor .toolbar .pillTools{display:inline-flex}
  #view-editor .canvasShell{margin-top:0;border:0;border-radius:0;box-shadow:none}
  #view-editor .zoomFab{bottom:calc(76px + env(safe-area-inset-bottom,0px))}
  #view-editor .pageNavFab{bottom:calc(76px + env(safe-area-inset-bottom,0px))}
}

/* ============ Screen 10: Tools & Paper inspector ============
   Single-scroll panel: Pen options / Size & colour / Page /
   Toolbar density. Right slide-over drawer ~360px on desktop/tablet,
   slide-up bottom sheet on mobile. 100% opaque surface throughout —
   no glass, no backdrop blur on the sheet itself. */
@media (min-width:769px){ dialog.sheet.drawerRight#editorSheet{width:min(360px,100vw)} }
/* Header: visible at every width. Newsreader serif title (design
   system: headings in Newsreader); the small "Inkwell" wordmark
   shows on tablet only, per the mockup. */
#editorSheet .sheetHead{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
#editorSheet .sheetHead h2{display:block;font-family:var(--font-display);font-size:19px;font-weight:600}
#editorSheet .sheetWordmark{display:none}
@media (min-width:769px) and (max-width:834px){
  #editorSheet .sheetWordmark{display:block;flex:1 1 100%;font:600 11px/1 var(--font-ui);letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
  #editorSheet .sheetHead h2{flex:1}
}
@media (min-width:835px) and (max-width:1024px){
  /* Landscape tablet: the wordmark sits inline on the title row
     (the portrait mockup's two-row header would cost 19px of the
     768px-tall viewport — the fit budget needs it here; the
     wordmark still shows). */
  #editorSheet .sheetWordmark{display:block;flex:0 0 auto;font:600 11px/1 var(--font-ui);letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
  #editorSheet .sheetHead h2{flex:1}
}
@media (max-width:768px){
  /* Mobile bottom sheet: grip + centred title; the X stays hidden
     (mockup shows the title only — dismiss via grip, backdrop or Esc). */
  #editorSheet .sheetHead{padding:2px 16px 10px}
  #editorSheet .sheetHead h2{text-align:center}
  #editorSheet .sheetHead .drawerClose{display:none}
}
/* Segmented controls (Style, Toolbar density): grey
   track, the active segment a raised white pill — as the mockups
   draw it. */
#editorSheet .segCtl{display:flex;flex:1;min-width:0;padding:2px;gap:2px;border-radius:999px;background:var(--paper2)}
#editorSheet .segCtl button{flex:1;min-width:0;min-height:30px;padding:4px 8px;border:0;border-radius:999px;background:transparent;color:var(--muted);font:600 12px/1.2 var(--font-ui);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
#editorSheet .segCtl button[aria-pressed="true"]{background:var(--surface);color:var(--text);box-shadow:0 1px 3px rgba(0,0,0,.18)}
#editorSheet .segCtl button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
/* Smoothness slider end labels. */
#editorSheet .sliderRow{padding-bottom:0}
#editorSheet .sliderEnds{display:flex;justify-content:space-between;padding:0 0 2px;font-size:11px;color:var(--muted)}
/* Size preview: on desktop/tablet the live SVG stroke curve is a
   full-width box (as the mockup draws it) with the Size slider row
   beneath it; on phones it stays the compact box beside the slider
   (mobile mockup). */
#editorSheet .sizeTopRow{display:flex;gap:12px;align-items:center;padding:4px 0}
#editorSheet .sizePreviewBox{flex:0 0 120px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);padding:4px 8px}
#editorSheet .sizePreviewBox svg{display:block;width:100%;height:36px}
#editorSheet .sizeTopRow .sizeGroup{flex:1;min-width:0}
#editorSheet .sizeTopRow .sizeGroup input[type=range]{flex:1;min-width:60px}
@media (min-width:769px){
  #editorSheet .sizeTopRow{flex-direction:column;align-items:stretch;gap:6px}
  #editorSheet .sizePreviewBox{flex:1 1 auto;padding:2px 8px}
  #editorSheet .sizePreviewBox svg{height:36px}
  #editorSheet .sizeTopRow .sizeGroup{min-height:30px}
}
/* Template tiles: 4-across grid on desktop/tablet, scroll row on
   phones (see the mobile rule above). */
#editorSheet .templateTiles{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
#editorSheet .templateTile{display:flex;flex-direction:column;gap:4px;min-width:0;padding:4px 4px 2px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text);font:600 11px/1.2 var(--font-ui);text-align:center;cursor:pointer}
#editorSheet .templateTile.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
#editorSheet .templateTile span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#editorSheet .tplPrev{display:block;height:24px;border:1px solid var(--border);border-radius:4px;background:var(--surface)}
#editorSheet .tpl-lined{background-image:repeating-linear-gradient(to bottom,transparent 0 8px,var(--border-strong) 8px 9px)}
#editorSheet .tpl-grid{background-image:repeating-linear-gradient(to right,transparent 0 9px,var(--border-strong) 9px 10px),repeating-linear-gradient(to bottom,transparent 0 9px,var(--border-strong) 9px 10px)}
#editorSheet .tpl-dotted{background-image:radial-gradient(var(--border-strong) 1px,transparent 1.2px);background-size:10px 10px}
#editorSheet .tpl-music{background-image:repeating-linear-gradient(to bottom,var(--border-strong) 0 1px,transparent 1px 7px)}
#editorSheet .tpl-cornell{background-image:linear-gradient(to right,transparent 0 30%,var(--border-strong) 30% calc(30% + 1px),transparent calc(30% + 1px)),linear-gradient(to bottom,transparent 0 62%,var(--border-strong) 62% calc(62% + 1px),transparent calc(62% + 1px)),repeating-linear-gradient(to bottom,transparent 0 8px,var(--border-strong) 8px 9px)}
#editorSheet .tpl-checklist{background-image:linear-gradient(var(--border-strong),var(--border-strong)),linear-gradient(var(--border-strong),var(--border-strong));background-size:9px 9px,9px 9px;background-position:8px 8px,8px 24px;background-repeat:no-repeat}
/* Screen 10 fix round: the "Pen button" row is gone (the toolbar
   dock already has the Eraser tool) — no replacement control. The
   compact fit below is what makes all four sections + header fit
   without scrolling at 1280x900 / 1024x768 / 834x1112 (measured by
   scrollHeight vs clientHeight of the sheet body). */
#editorSheet .sheetSection{padding:6px 0}
#editorSheet .sheetSection>h3{margin-bottom:2px}
#editorSheet .sheetBody{padding:2px 16px calc(2px + env(safe-area-inset-bottom,0px))}
#editorSheet .sheetSection .popRow{padding:0}
#editorSheet .sheetHead{padding:8px 16px 6px;gap:8px}
#editorSheet .popChecks{gap:2px!important}
/* Small-caps sub-labels inside a section ("Template icons",
   "Page colour") — as the mockups draw them. */
#editorSheet .sheetSubLabel{font:600 10px/1.3 var(--font-ui);letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin:0 0 4px}
#editorSheet .pageColourRow{padding-top:0}

/* Screen 10: mobile template tiles scroll horizontally (mockup cuts
   off at "Checkl…"). Kept after the grid rule on purpose: same
   specificity, so this must come later to win at <=768px. */
@media (max-width:768px){
  #editorSheet .templateTiles{display:flex;overflow-x:auto;scrollbar-width:none;padding-bottom:2px}
  #editorSheet .templateTiles::-webkit-scrollbar{display:none}
  #editorSheet .templateTile{flex:0 0 76px}
}

/* ============ Screen 11 — Rich insertions ============ */
/* Mobile Insert sheet (phone mockup): the same #insertMenu popover
   becomes a dark bottom sheet — grip, "+ Insert" title, × close, 2×3
   grid of icon + label cells. Dark as drawn, in both app themes (see
   CHECKS.md). The toggle handler clears inline positioning at ≤720px
   so these rules place it. */
.insertSheetHead{display:none}
@media (max-width:720px){
  #insertMenu{
    inset:auto 0 0 0;left:0;right:0;bottom:0;top:auto;width:100%;max-width:100%;margin:0;
    border:0;border-radius:18px 18px 0 0;padding:8px 14px calc(16px + env(safe-area-inset-bottom,0px));
    background:#1E1C19;color:#F2EEE6;box-shadow:0 -12px 40px rgba(0,0,0,.45);
    max-height:72vh;overflow:auto;
  }
  .insertSheetHead{display:block}
  .insertSheetGrip{display:block;width:40px;height:4px;margin:2px auto 8px;border-radius:999px;background:rgba(242,238,230,.35)}
  .insertSheetHeadRow{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
  .insertSheetTitle{font-family:var(--font-display);font-size:17px;font-weight:600;color:#F2EEE6}
  .insertSheetClose{display:grid;place-items:center;width:36px;height:36px;min-height:36px;padding:0;border:0;border-radius:999px;background:transparent;color:#F2EEE6;cursor:pointer}
  .insertSheetClose:hover{background:rgba(242,238,230,.12)}
  .insertSheetClose .ic{width:16px;height:16px}
  #insertMenu [focusgroup~="menu"]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  #insertMenu [focusgroup~="menu"] button{flex-direction:column;justify-content:center;gap:6px;min-height:76px;padding:10px 4px;background:#2D2A26;border:1px solid #3A362F;border-radius:12px;color:#F2EEE6;font-size:12px;font-weight:500;text-align:center}
  #insertMenu [focusgroup~="menu"] button .ic{width:22px;height:22px;color:#F2EEE6}
  #insertMenu [focusgroup~="menu"] button:hover,#insertMenu [focusgroup~="menu"] button:focus-visible{background:#3A362F}
}
/* Uniform object chrome (brief): every on-canvas object gets a subtle
   terracotta hover outline. Image (.canvasImgWrap) and LaTeX (.texEl)
   already had it; sticky / set square / table gain it here. */
.sticky:hover,.sticky:focus-within{outline:2px solid var(--accent);outline-offset:-1px}
.setSquare:hover .sqBody{border-color:var(--accent)}
.setSquare:hover .sqHole{border-color:var(--accent)}
#tableHost .panel:hover{border-color:var(--accent)}
/* Set square: pale translucent ruler as drawn (was amber), with
   centimetre tick marks + numbers along the bottom and left edges. */
.setSquare .sqBody{background:rgba(228,226,220,.45);border-color:rgba(120,113,102,.8)}
.setSquare .sqHole{border-color:rgba(120,113,102,.55)}
.setSquare .sqBtns button{border-color:rgba(120,113,102,.7);color:#5A5348}
.sqTicks{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
/* Table as an on-canvas object: absolutely positioned inside the
   canvas shell, dragged by its header, deleted by the × in it. */
#tableHost{position:absolute;z-index:7;width:max-content;max-width:92%}
#tableHost .panel{margin-top:0}
.tablePanelHead{display:flex;align-items:center;justify-content:space-between;gap:8px;cursor:grab;touch-action:none}
.tablePanelHead h4{margin:0}
