/* PLD study-tool UI — notebook, highlighting, selection popup, display controls */
.sidebar-toggle{display:none;position:fixed;top:.5rem;left:.5rem;z-index:200;background:var(--accent);
color:#fff;border:none;border-radius:4px;padding:.4rem .7rem;font-size:.9rem;cursor:pointer}
@media(max-width:900px){.sidebar-toggle{display:block}.sidebar.open{display:block;position:fixed;top:0;left:0;
z-index:150;width:85vw;max-width:350px}}

.display-controls{display:flex;gap:.4rem;align-items:center;padding:.4rem 0;margin-bottom:.8rem;
font:.8rem/1 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}
.display-controls label{color:var(--muted)}
.display-controls button{padding:.2rem .55rem;border:1px solid var(--border);border-radius:4px;
background:var(--card);cursor:pointer;font-family:inherit}
.display-controls button.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.font-sm{font-size:16px}.font-md{font-size:18px}.font-lg{font-size:20px}.font-xl{font-size:22px}

.trunc-note{margin:2rem 0;padding:1rem;background:var(--sidebar);border:1px solid var(--border);
border-radius:6px;color:var(--muted);font-size:.9rem}

/* user paragraph highlights */
.blk[data-hl=yellow],[data-pcol][data-hl=yellow]{background:#fff4cc}
.blk[data-hl=blue],[data-pcol][data-hl=blue]{background:#d6e8fb}
.blk[data-hl=green],[data-pcol][data-hl=green]{background:#d6efd6}
.blk[data-hl=pink],[data-pcol][data-hl=pink]{background:#fadbe6}
.blk[data-hl],[data-pcol][data-hl]{border-radius:4px;padding:.2rem .5rem}
.kb-focus{outline:2px solid var(--accent);outline-offset:2px;border-radius:3px}

/* selection popup */
.sel-popup{position:absolute;z-index:300;background:var(--card);border:1px solid var(--border);
border-radius:6px;box-shadow:0 4px 16px rgba(0,0,0,.15);padding:.4rem;display:none;gap:.3rem;align-items:center}
.sel-popup.show{display:flex}
/* page-view selections (no persistent block id): keep Save/Link/Cite, hide block-only actions */
.sel-popup.pv-sel #selTr{display:none}
/* R67c: highlight swatches persist per block id — on the id-less OCR/vision/EN lanes they
   silently did nothing, so they don't show there at all */
/* R76: highlights work in the reading lanes now — swatches stay visible */
.sel-popup button{background:none;border:1px solid var(--border);border-radius:4px;padding:.3rem .6rem;
cursor:pointer;font-family:inherit;font-size:.82rem;white-space:nowrap}
.sel-popup button.primary{background:var(--accent);color:#fff;border-color:var(--accent)}
.sel-ref{font-size:.74rem;color:var(--muted);font-variant-numeric:tabular-nums;padding:0 .3rem 0 .15rem;
max-width:16ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sel-ref:empty{display:none}
.qc-ref-clip{font-weight:600;font-size:.82rem}.qc-clip-ic{opacity:.7}
.qc-passage{margin:.4rem 0 .2rem;padding:.55rem .7rem;border-left:3px solid var(--accent);
background:var(--bg);border-radius:0 5px 5px 0;max-height:22rem;overflow-y:auto;font-size:.92rem;line-height:1.65}
.qc-pass-la{color:var(--text)}.qc-pass-empty{color:var(--muted);font-style:italic}
.sel-hl{display:inline-flex;gap:.25rem;align-items:center;padding-left:.3rem;border-left:1px solid var(--border)}
.hlsw{width:20px!important;height:20px;border-radius:50%!important;border:1px solid rgba(0,0,0,.15)!important;
cursor:pointer;padding:0!important;font-size:.7rem;color:var(--muted)}
.hlsw:hover{transform:scale(1.15)}.hlx{background:var(--card)!important}

/* notebook toggle + panel */
.nb-toggle{position:fixed;top:1rem;right:1rem;z-index:600;background:var(--accent);color:#fff;border:none;
border-radius:6px;padding:.45rem .9rem;font-family:-apple-system,sans-serif;font-size:.85rem;cursor:pointer;
box-shadow:0 2px 8px rgba(0,0,0,.15);display:flex;align-items:center;gap:.4rem}
.nb-badge{background:#fff;color:var(--accent);border-radius:10px;padding:0 .45rem;font-size:.75rem;font-weight:700}
.nb-overlay{position:fixed;inset:0;background:rgba(0,0,0,.2);z-index:650;opacity:0;pointer-events:none;transition:opacity .25s}.nb-overlay.open{opacity:1;pointer-events:auto}
.nb-panel{position:fixed;top:0;right:-420px;width:400px;max-width:90vw;height:100vh;background:var(--card);
border-left:1px solid var(--border);z-index:700;box-shadow:-4px 0 20px rgba(0,0,0,.1);display:flex;
flex-direction:column;transition:right .25s}.nb-panel.open{right:0}
.nb-header{padding:1rem 1.2rem;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center}
.nb-header h2{margin:0;font-size:1.1rem;color:var(--accent)}
.nb-full{font-size:.8rem;padding:.2rem .5rem;border:1px solid var(--border);border-radius:4px;margin-right:.4rem}
.nb-close{background:none;border:none;font-size:1.3rem;cursor:pointer;color:var(--muted)}
.nb-tools{padding:.5rem 1.2rem;border-bottom:1px solid var(--border);display:flex;gap:.5rem;flex-wrap:wrap}
.nb-tools input,.nb-tools select{padding:.25rem .5rem;border:1px solid var(--border);border-radius:4px;font-family:inherit;font-size:.8rem}
.nb-tools input{flex:1;min-width:120px}
.nb-tools button{background:var(--sidebar);border:1px solid var(--border);border-radius:4px;padding:.25rem .6rem;cursor:pointer;font-family:inherit;font-size:.8rem}
.nb-list{flex:1;overflow-y:auto;padding:.5rem 0}
.nb-empty{text-align:center;color:var(--muted);padding:3rem 1rem;font-size:.9rem}
.nb-item{padding:.6rem 1.2rem;border-bottom:1px solid var(--border);position:relative}
.nb-item:hover{background:var(--sidebar)}
.nb-item-ref{font-size:.74rem;color:var(--muted);margin-bottom:.2rem}.nb-item-ref a{color:var(--accent)}
.nb-item-text{font-size:.88rem;line-height:1.5}
.nb-item-note{margin-top:.3rem;padding:.3rem .5rem;background:var(--hl);border-radius:3px;font-size:.82rem;white-space:pre-wrap}
.nb-item-tag{display:inline-block;padding:.1rem .4rem;border-radius:3px;font-size:.72rem;background:var(--accent);color:#fff;margin:.2rem .15rem 0 0}
.nb-item-tag.coll{background:#5a7a3a}
.nb-item-actions{position:absolute;top:.4rem;right:.6rem;display:flex;gap:.3rem;opacity:0}
.nb-item:hover .nb-item-actions{opacity:1}
.nb-item-actions button{background:none;border:none;cursor:pointer;font-size:.78rem;color:var(--muted)}

/* modal */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:800;display:none;justify-content:center;align-items:center}
.modal-overlay.open{display:flex}
.modal-box{background:var(--card);border-radius:10px;padding:1.5rem;width:550px;max-width:92vw;max-height:85vh;overflow-y:auto;box-shadow:0 8px 32px rgba(0,0,0,.2)}
.modal-title{font-size:1.1rem;font-weight:600;color:var(--accent);margin-bottom:.75rem}
.modal-quote{font-size:.85rem;color:var(--muted);padding:.5rem .75rem;background:var(--sidebar);border-radius:4px;margin-bottom:.75rem;max-height:100px;overflow-y:auto}
.modal-ta{width:100%;min-height:120px;padding:.7rem;border:1px solid var(--border);border-radius:6px;font-family:inherit;font-size:.92rem;line-height:1.6;resize:vertical;background:var(--bg)}
.modal-field{margin-top:.6rem}.modal-field label{display:block;font-size:.82rem;color:var(--muted);margin-bottom:.2rem}
.modal-field input{width:100%;padding:.4rem .6rem;border:1px solid var(--border);border-radius:4px;font-family:inherit;font-size:.88rem}
.modal-actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1rem}
.modal-actions button{padding:.45rem 1rem;border:1px solid var(--border);border-radius:5px;font-family:inherit;font-size:.88rem;cursor:pointer}
.modal-cancel{background:var(--sidebar)}.modal-save.primary{background:var(--accent);color:#fff;border-color:var(--accent)}

@media print{.sidebar,.nb-toggle,.scroll-top,.sel-popup,.nb-panel,.nb-overlay,.modal-overlay,
.display-controls,.nav-strip,.sidebar-toggle,.col-marker{display:none!important}.main{padding:0;max-width:100%}}

/* auth bar */
#auth-bar{position:sticky;top:0;z-index:500;background:var(--card,#fffdfa);border-bottom:1px solid var(--border)}
.auth-in{max-width:1000px;margin:0 auto;display:flex;align-items:center;gap:.6rem;padding:.35rem 1.2rem;
font:.82rem/1 var(--font-ui,system-ui);color:var(--fg)}
.auth-av{width:24px;height:24px;border-radius:50%}
.auth-prompt{flex:1;color:var(--muted)}
.auth-sync{font-size:.72rem;padding:.15rem .45rem;border-radius:3px;background:var(--hl);color:var(--muted)}
.auth-btn{padding:.25rem .7rem;border:1px solid var(--border);border-radius:4px;background:transparent;color:var(--fg);cursor:pointer;font-size:.8rem;font-family:inherit}
.auth-btn:hover{border-color:var(--accent);color:var(--accent)}
/* sign-in is optional sync, not the page's primary action — a quiet tinted button */
.auth-g{background:var(--accent);border-color:var(--accent);color:#fff}
.auth-g:hover{background:var(--accent2);color:#fff}

/* R20: sign-in integrated into the page header (TFR-style) — compact control + popover.
   The old #auth-bar strip remains only as a fallback on pages with no header mount. */
.pg-auth{position:relative;display:inline-flex;align-items:center;margin-left:.4rem}
.pg-auth-btn{display:inline-flex;align-items:center;gap:.35rem;padding:.22rem .6rem;
  border:1px solid var(--border);border-radius:7px;background:transparent;color:var(--fg);
  cursor:pointer;font:.78rem/1 var(--font-ui,system-ui);white-space:nowrap}
.pg-auth-btn:hover,.pg-auth-btn:focus-visible{border-color:var(--accent);color:var(--accent)}
.pg-auth-user{padding:.14rem}
.pg-auth-av{width:22px;height:22px;border-radius:50%;display:block}
.pg-auth-init{width:22px;height:22px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  background:var(--accent);color:#fff;font:600 .72rem/1 var(--font-ui,system-ui)}
/* on the reader masthead (accent band, white text) the chrome inverts */
.pg-mast .pg-auth-btn{border-color:rgba(255,255,255,.35);color:#fff}
.pg-mast .pg-auth-btn:hover,.pg-mast .pg-auth-btn:focus-visible{border-color:#fff;color:#fff}
.pg-mast .pg-auth-init{background:rgba(255,255,255,.22)}
/* landing hero-nav: sits at the end of the link row */
.hero-nav .pg-auth{margin-left:.2rem}
.pg-auth-menu{position:absolute;right:0;top:calc(100% + 8px);min-width:240px;z-index:820;
  background:var(--card,#fffdfa);border:1px solid var(--border);border-radius:9px;
  box-shadow:0 10px 28px rgba(0,0,0,.16);padding:.45rem;color:var(--fg);text-align:left}
.pg-auth-name{font:600 .82rem/1.3 var(--font-ui,system-ui);padding:.3rem .5rem .1rem}
.pg-auth-state{font:.74rem/1.4 var(--font-ui,system-ui);color:var(--muted);padding:.15rem .5rem .35rem}
.pg-auth-item{display:block;width:100%;text-align:left;padding:.42rem .5rem;border:0;border-radius:6px;
  background:transparent;color:var(--fg);cursor:pointer;font:.8rem/1 var(--font-ui,system-ui)}
.pg-auth-item:hover,.pg-auth-item:focus-visible{background:var(--hl,rgba(0,0,0,.05))}
@media (max-width:640px){.pg-auth-menu{position:fixed;right:.6rem;left:auto;top:calc(var(--frmh,44px) + .4rem)}}

/* translation attribution label */
.tr-by{display:block;font:600 .68rem/1 -apple-system,sans-serif;text-transform:uppercase;
letter-spacing:.04em;color:var(--col,#9a7b4f);margin-bottom:.25rem}
/* R13: the Notebook pill aligns into the masthead band instead of straddling its edge.
   Audit fix: it used to sit AT the masthead's own top edge (z-index 600), which put it
   directly over the masthead's sign-in control at ~1400px and, whenever the research
   rail opened, over the rail's own × close button underneath (both fixed, both hugging
   the top-right corner) — drop it BELOW the sticky masthead entirely, and slide it
   further left while the rail is open (html.rr-open, toggled in pgrelated.js) so it
   never rides on top of the rail's header or body either. */
.nb-toggle{top:calc(var(--authh,0px) + var(--mast-h,48px) + .5rem)}
/* facsimile panel open: the pill's corner now belongs to the facs header (zoom slider,
   OCR/English buttons) — slide it left of the panel edge, same dodge as the rail's.
   --facs-w rides html (resizer) with the pgreader.css :root default as fallback. */
body:has(.app.with-facs) .nb-toggle{right:calc(var(--facs-w,min(40vw,600px)) + 1.4rem)}
@media (max-width:1100px){body:has(.app.with-facs) .nb-toggle{display:none}}  /* facs is a full-width overlay here */
html.rr-open .nb-toggle{right:calc(min(342px,94vw) + 1.5rem)}   /* facs rule above is more specific — its larger offset clears both panels when both are open */

/* ── R65 design pass: door-side interaction layer (landing · search · topics · ask) ── */
:root{--pg-ease:cubic-bezier(.16,1,.3,1)}
:focus-visible{outline:2px solid var(--accent,#8a6d3b);outline-offset:2px;border-radius:2px}
.omni-row{transition:background-color .12s var(--pg-ease),color .12s var(--pg-ease)}
.omni-row:hover{background:color-mix(in oklab,var(--accent,#8a6d3b) 8%,transparent)}
@media (prefers-reduced-motion:no-preference){
  .omni-row{animation:pgRowIn .18s var(--pg-ease) both}
  .omni-row:nth-child(2){animation-delay:.02s}
  .omni-row:nth-child(3){animation-delay:.04s}
  .omni-row:nth-child(4){animation-delay:.06s}
  .omni-row:nth-child(5){animation-delay:.08s}
  .omni-row:nth-child(n+6){animation-delay:.1s}
}
@keyframes pgRowIn{from{opacity:.001;transform:translateY(3px)}to{opacity:1;transform:none}}
.sr,.trad-hit,.tfr-row{transition:background-color .14s var(--pg-ease),border-color .14s var(--pg-ease)}
@media (prefers-reduced-motion:reduce){
  .omni-row{animation:none;transition:none}
  .sr,.trad-hit,.tfr-row{transition:none}
}
