/* ==========================================================================
   Ebook Library Manager V8.0 · "Aurora" layer (loads after nova-v7.css)
   Visitor accents, aurora light, 3D covers, page transitions, scroll reveal,
   AI librarian and AI insight. Everything degrades without JS or modern CSS.
   ========================================================================== */

/* ---------- Visitor accent (html[data-accent], chosen in the header) ---------- */
:root[data-accent="indigo"],:root[data-accent="indigo"] body.nova{--nv-accent:#4f46e5;--nv-accent-2:#06b6d4}
:root[data-accent="emerald"],:root[data-accent="emerald"] body.nova{--nv-accent:#059669;--nv-accent-2:#84cc16}
:root[data-accent="rose"],:root[data-accent="rose"] body.nova{--nv-accent:#e11d48;--nv-accent-2:#f59e0b}
:root[data-accent="amber"],:root[data-accent="amber"] body.nova{--nv-accent:#d97706;--nv-accent-2:#ef4444}
:root[data-accent="ocean"],:root[data-accent="ocean"] body.nova{--nv-accent:#0369a1;--nv-accent-2:#22d3ee}
:root[data-accent="violet"],:root[data-accent="violet"] body.nova{--nv-accent:#7c3aed;--nv-accent-2:#ec4899}
:root{--nv-accent-2:#06b6d4;--nv-glow:color-mix(in oklab,var(--nv-accent) 35%,transparent)}
:root[data-theme="dark"][data-accent="ocean"] body.nova{--nv-accent:#38bdf8;--nv-accent-ink:#04111d}
:root[data-theme="dark"][data-accent="amber"] body.nova{--nv-accent:#f59e0b;--nv-accent-ink:#1a1002}
body.nova :is(a,button,input,select,textarea):focus-visible{outline:2px solid var(--nv-accent);outline-offset:2px}
::selection{background:color-mix(in oklab,var(--nv-accent) 28%,transparent)}

/* ---------- Cross-document page transitions (Chrome/Edge/Safari 18+) ---------- */
@view-transition{navigation:auto}
::view-transition-old(root),::view-transition-new(root){animation-duration:.28s;animation-timing-function:var(--nv-ease)}
.nv-header{view-transition-name:nv-header}
@media (prefers-reduced-motion:reduce){@view-transition{navigation:none}}

/* ---------- Reading progress bar ---------- */
.nv-progress{position:fixed;inset-inline:0;top:0;height:3px;z-index:200;pointer-events:none;transform-origin:0 50%;transform:scaleX(0);
  background:linear-gradient(90deg,var(--nv-accent),var(--nv-accent-2))}
.nv-rtl .nv-progress{transform-origin:100% 50%}
@supports (animation-timeline:scroll()){
  .nv-progress{animation:nv-progress linear both;animation-timeline:scroll(root)}
  @keyframes nv-progress{to{transform:scaleX(1)}}
}

/* ---------- Aurora hero ---------- */
.nv-hero{isolation:isolate;overflow:clip}
.nv-aurora{position:absolute;inset:-20% -10% auto;height:120%;z-index:-1;pointer-events:none;filter:blur(60px) saturate(140%);opacity:.55}
.nv-aurora span{position:absolute;border-radius:50%;mix-blend-mode:multiply;animation:nv-drift 18s ease-in-out infinite alternate}
:root[data-theme="dark"] .nv-aurora{opacity:.42}
:root[data-theme="dark"] .nv-aurora span{mix-blend-mode:screen}
.nv-aurora span:nth-child(1){width:46vw;height:46vw;inset-inline-start:-6vw;top:-8vw;background:var(--nv-accent)}
.nv-aurora span:nth-child(2){width:38vw;height:38vw;inset-inline-end:-4vw;top:-4vw;background:var(--nv-accent-2);animation-duration:22s;animation-delay:-6s}
.nv-aurora span:nth-child(3){width:30vw;height:30vw;inset-inline-start:30vw;top:10vw;background:color-mix(in oklab,var(--nv-accent) 50%,#f472b6);animation-duration:26s;animation-delay:-12s}
@keyframes nv-drift{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(4vw,2vw,0) scale(1.12)}100%{transform:translate3d(-3vw,4vw,0) scale(.94)}}
.nv-hero h1{background:linear-gradient(100deg,var(--nv-ink) 30%,var(--nv-accent) 70%,var(--nv-accent-2));-webkit-background-clip:text;background-clip:text;color:transparent}
@supports not (background-clip:text){.nv-hero h1{color:var(--nv-ink)}}

/* ---------- Hero "ask the librarian" strip ---------- */
.nv-ask{display:flex;align-items:center;gap:.6rem;margin-top:1rem;padding:.55rem .6rem .55rem .9rem;border-radius:999px;max-width:560px;
  background:color-mix(in oklab,var(--nv-surface) 70%,transparent);border:1px solid color-mix(in oklab,var(--nv-accent) 30%,var(--nv-line));
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);color:var(--nv-ink-2);font-size:.92rem;cursor:pointer;width:100%;text-align:start;font:inherit}
.nv-ask:hover{border-color:var(--nv-accent)}
.nv-ask b{margin-inline-start:auto;flex:none;padding:.4rem .85rem;border-radius:999px;color:var(--nv-accent-ink);font-weight:600;font-size:.85rem;
  background:linear-gradient(120deg,var(--nv-accent),var(--nv-accent-2))}
.nv-spark{display:inline-grid;place-items:center;width:1.6rem;height:1.6rem;border-radius:50%;flex:none;color:#fff;font-size:.8rem;
  background:conic-gradient(from 0deg,var(--nv-accent),var(--nv-accent-2),var(--nv-accent));animation:nv-spin 6s linear infinite}
@keyframes nv-spin{to{rotate:360deg}}

/* ---------- 3D covers + spotlight cards (pointer devices only) ---------- */
@media (hover:hover) and (pointer:fine){
  .nova [data-nv-tilt].is-tilting,.nova .book-card:hover [data-nv-tilt].is-tilting{transform:perspective(800px) translateY(-6px) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg));transition-duration:.08s}
  [data-nv-tilt]::before{content:"";position:absolute;inset:0;z-index:2;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .3s;
    background:radial-gradient(220px circle at var(--mx,50%) var(--my,50%),rgba(255,255,255,.38),transparent 60%)}
  [data-nv-tilt].is-tilting::before{opacity:1}
}

/* ---------- Scroll reveal (CSS-only where supported) ---------- */
@supports (animation-timeline:view()){
  @media (prefers-reduced-motion:no-preference){
    .nv-reveal,.nv-shelf,.nv-section-head,.book-panel{animation:nv-rise linear both;animation-timeline:view();animation-range:entry 0% entry 40%}
    @keyframes nv-rise{from{opacity:0;translate:0 24px}to{opacity:1;translate:0 0}}
  }
}

/* ---------- Accent picker ---------- */
.nv-accent-menu{display:grid;grid-template-columns:repeat(3,2rem);gap:.5rem;padding:.75rem}
.nv-accent-menu button{width:2rem;height:2rem;border-radius:50%;border:2px solid var(--nv-surface);box-shadow:0 0 0 1px var(--nv-line-strong);cursor:pointer;padding:0;
  background:linear-gradient(135deg,var(--sw),var(--sw2))}
.nv-accent-menu button[aria-pressed="true"]{box-shadow:0 0 0 2px var(--nv-ink)}
.nv-accent-menu p{grid-column:1/-1;margin:0 0 .15rem;font-size:.78rem;color:var(--nv-muted)}

/* ---------- AI librarian (floating button + dialog) ---------- */
.nv-ai-fab{position:fixed;inset-inline-end:1.1rem;bottom:1.1rem;z-index:120;display:flex;align-items:center;gap:.5rem;padding:.7rem 1rem;border:0;border-radius:999px;cursor:pointer;
  color:#fff;font:600 .92rem var(--nv-font);background:linear-gradient(120deg,var(--nv-accent),var(--nv-accent-2));
  box-shadow:0 12px 30px -8px var(--nv-glow),0 0 0 1px rgba(255,255,255,.15) inset;transition:transform .2s var(--nv-ease),box-shadow .2s}
.nv-ai-fab:hover{transform:translateY(-2px);box-shadow:0 18px 40px -10px var(--nv-glow)}
.nv-ai-fab svg{flex:none}
@media (max-width:760px){.nv-ai-fab{bottom:calc(4.6rem + env(safe-area-inset-bottom));padding:.75rem}.nv-ai-fab span{display:none}}
.nv-ai{border:0;padding:0;margin:auto;margin-inline-end:1rem;margin-bottom:1rem;width:min(440px,calc(100vw - 2rem));max-height:min(680px,calc(100dvh - 2rem));
  border-radius:var(--nv-radius-lg);background:var(--nv-surface);color:var(--nv-ink);box-shadow:var(--nv-shadow-lg);overflow:hidden}
.nv-ai[open]{display:flex;flex-direction:column;animation:nv-ai-pop .26s var(--nv-ease)}
.nv-ai::backdrop{background:rgba(8,10,20,.35);backdrop-filter:blur(2px)}
@keyframes nv-ai-pop{from{opacity:0;transform:translateY(12px) scale(.98)}}
/* The back-to-top button moves above the librarian button. */
.nv-to-top{bottom:88px}
@media (max-width:760px){.nv-to-top{bottom:calc(140px + env(safe-area-inset-bottom))}}
@media (max-width:760px){.nv-ai{margin:auto 0 0;width:100vw;max-width:100vw;max-height:88dvh;border-end-start-radius:0;border-end-end-radius:0}}
.nv-ai-head{display:flex;align-items:center;gap:.7rem;padding:1rem 1.1rem;color:#fff;background:linear-gradient(120deg,var(--nv-accent),var(--nv-accent-2))}
.nv-ai-head h2{margin:0;font:600 1.05rem var(--nv-font)}
.nv-ai-head small{display:block;opacity:.85;font-size:.78rem}
.nv-ai-head button{margin-inline-start:auto;background:rgba(255,255,255,.18);border:0;color:#fff;width:2rem;height:2rem;border-radius:50%;cursor:pointer;font-size:1.1rem}
.nv-ai-log{flex:1;overflow:auto;padding:1rem;display:flex;flex-direction:column;gap:.75rem;overscroll-behavior:contain}
.nv-ai-msg{max-width:88%;padding:.65rem .85rem;border-radius:16px;line-height:1.5;font-size:.93rem}
.nv-ai-msg.me{align-self:flex-end;background:var(--nv-accent);color:var(--nv-accent-ink);border-end-end-radius:4px}
.nv-ai-msg.bot{align-self:flex-start;background:var(--nv-surface-2);border-end-start-radius:4px}
.nv-ai-ideas{display:flex;flex-wrap:wrap;gap:.4rem}
.nv-ai-ideas button{border:1px solid var(--nv-line-strong);background:var(--nv-surface);color:var(--nv-ink-2);border-radius:999px;padding:.35rem .75rem;font:inherit;font-size:.83rem;cursor:pointer}
.nv-ai-ideas button:hover{border-color:var(--nv-accent);color:var(--nv-accent)}
.nv-ai-cards{display:grid;gap:.5rem;width:100%}
.nv-ai-card{display:grid;grid-template-columns:46px 1fr;gap:.7rem;align-items:start;padding:.55rem;border-radius:12px;border:1px solid var(--nv-line);text-decoration:none;color:inherit;background:var(--nv-surface)}
.nv-ai-card:hover{border-color:var(--nv-accent);box-shadow:var(--nv-shadow-sm)}
.nv-ai-card img,.nv-ai-card i{width:46px;aspect-ratio:2/3;border-radius:6px;object-fit:cover;background:var(--nv-surface-3);display:block}
.nv-ai-card strong{display:block;font-size:.9rem;line-height:1.3}
.nv-ai-card small{color:var(--nv-muted);font-size:.78rem}
.nv-ai-card p{margin:.25rem 0 0;font-size:.8rem;color:var(--nv-ink-2);line-height:1.4}
.nv-ai-form{display:flex;gap:.5rem;padding:.75rem;border-top:1px solid var(--nv-line);background:var(--nv-surface)}
.nv-ai-form input{flex:1;min-width:0;border:1px solid var(--nv-line-strong);border-radius:999px;padding:.65rem 1rem;background:var(--nv-surface-2);color:var(--nv-ink);font:inherit;font-size:16px}
.nv-ai-form button{border:0;border-radius:999px;padding:0 1rem;cursor:pointer;color:var(--nv-accent-ink);background:var(--nv-accent);font:600 .9rem var(--nv-font)}
.nv-ai-typing{display:inline-flex;gap:4px}
.nv-ai-typing i{width:6px;height:6px;border-radius:50%;background:var(--nv-muted);animation:nv-blink 1s infinite}
.nv-ai-typing i:nth-child(2){animation-delay:.15s}.nv-ai-typing i:nth-child(3){animation-delay:.3s}
@keyframes nv-blink{0%,100%{opacity:.25}50%{opacity:1}}
.nv-ai-note{font-size:.75rem;color:var(--nv-muted);text-align:center;margin:0}

/* ---------- AI insight on the book page ---------- */
.nv-insight{position:relative;border-radius:var(--nv-radius);padding:1.1rem 1.2rem;margin-bottom:1.2rem;
  background:linear-gradient(var(--nv-surface),var(--nv-surface)) padding-box,linear-gradient(120deg,var(--nv-accent),var(--nv-accent-2)) border-box;border:1.5px solid transparent}
.nv-insight-head{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}
.nv-insight-head h2{margin:0;font-size:1.05rem}
.nv-insight-head button{margin-inline-start:auto}
.nv-insight-body{margin-top:.9rem;display:grid;gap:.8rem}
.nv-insight-body p{margin:0;line-height:1.65}
.nv-insight-body ul{margin:0;padding-inline-start:1.2rem;display:grid;gap:.3rem}
.nv-insight-tags{display:flex;flex-wrap:wrap;gap:.4rem}
.nv-insight-tags span{font-size:.8rem;padding:.25rem .65rem;border-radius:999px;background:var(--nv-surface-2);color:var(--nv-ink-2)}
.nv-shimmer{height:.9rem;border-radius:6px;background:linear-gradient(90deg,var(--nv-surface-2),var(--nv-surface-3),var(--nv-surface-2));background-size:200% 100%;animation:nv-shim 1.2s infinite}
@keyframes nv-shim{to{background-position:-200% 0}}

@media (prefers-reduced-motion:reduce){
  .nv-aurora span,.nv-spark,.nv-shimmer,.nv-ai-typing i{animation:none}
  [data-nv-tilt]{transform:none!important}
}
@media print{.nv-ai-fab,.nv-ai,.nv-progress,.nv-aurora{display:none!important}}
.nv-spark{font-style:normal}
@media (max-width:480px){.nv-actions .nv-accent{display:none}}

/* ==========================================================================
   V8.1 · One type and control scale for every public page.
   Before: page titles 32–58 px, buttons 34–103 px, inputs 44–48 px with 14–16 px text.
   ========================================================================== */
:root{
  --nv-fs-hero:clamp(34px,4.8vw,62px);
  --nv-fs-page:clamp(28px,3.2vw,42px);
  --nv-fs-book:clamp(28px,3.6vw,46px);
  --nv-fs-h2:clamp(21px,2.1vw,27px);
  --nv-fs-panel:clamp(18px,1.6vw,21px);
  --nv-fs-lead:clamp(15.5px,1.3vw,17px);
  --nv-fs-body:15.5px;
  --nv-control:46px;
  --nv-control-lg:52px;
}
/* Titles */
.nova .nv-hero h1{font-size:var(--nv-fs-hero)}
.nova .page-hero.small h1,.nova .cat-v643-hero h1,.nova .nv-page-intro h1,
.nova #nv-main>.section:first-child .section-head h1{font-family:var(--nv-display);font-weight:700;font-size:var(--nv-fs-page);line-height:1.12;letter-spacing:-.025em;margin:10px 0}
.nv-rtl .page-hero.small h1,.nv-rtl .cat-v643-hero h1,.nv-rtl .nv-page-intro h1,.nv-rtl #nv-main>.section:first-child .section-head h1{font-family:"Noto Kufi Arabic",var(--nv-font);letter-spacing:0;line-height:1.35}
.nova .book-main-col h1{font-size:var(--nv-fs-book);line-height:1.1}
.nova .section-head h2,.nova .cat-v643-head h2,.nova .nv-section h2,.nova .mobile-public-card h2,.nova .upload-panel h2,.nova .legal-document h2{font-size:var(--nv-fs-h2);line-height:1.25}
.nova .panel-heading h2,.nova .book-panel h2,.nova .book-panel h3{font-size:var(--nv-fs-panel);line-height:1.3}
.nova .auth-card h1{font-size:clamp(26px,2.6vw,32px)}
/* Intro text under titles */
.nova .page-hero.small p,.nova .cat-v643-hero p,.nova .nv-page-intro p,.nova #nv-main>.section:first-child .section-head p{font-size:var(--nv-fs-lead);line-height:1.6;color:var(--nv-ink-2);max-width:68ch}
.nova .nv-page-intro{margin-bottom:26px}
.nova #nv-main p{line-height:1.65}
.nova .book-description,.nova .legal-document p,.nova .rights-box p{font-size:var(--nv-fs-body)}
/* Controls: one height, one text size (16 px also stops iOS zooming into fields) */
.nv-btn,.nova .btn,.nova .book-btn{min-height:var(--nv-control);font-size:15px;line-height:1.2}
.nv-btn-lg,.nova .btn.large,.nova .auth-submit,.nova .book-actions .book-btn{min-height:var(--nv-control-lg)}
.nova .pub-buttons{display:flex;flex-wrap:wrap;gap:10px;align-items:center;align-content:center}
.nova .pub-buttons>.btn{height:auto;flex:0 0 auto}
.nova .pub-account{align-items:center}
.nova :is(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]),select){min-height:var(--nv-control);font-size:16px}
.nova textarea{font-size:16px}
.nova .nv-view-toggle button{min-height:38px;min-width:38px}
@media (max-width:760px){
  :root{--nv-control:44px;--nv-control-lg:48px}
  .nova .nv-search input{font-size:16px}
}
/* Search forms on catalogue and categories use the same control height as the rest. */
.nova .catalog-search :is(.nv-btn,button),.nova .cat-v643-search :is(input,button){min-height:var(--nv-control);height:var(--nv-control)}
.nova .book-content-main,.nova .book-side-col{min-width:0}
@media (max-width:760px){
  .nova .nv-ask{font-size:.86rem;padding:.5rem .55rem .5rem .7rem;border-radius:16px;line-height:1.3}
  .nova .nv-ask b{padding:.35rem .7rem}
}
@media (max-width:420px){.nova .nv-ask b{display:none}}

/* ==========================================================================
   V8.1.1 · Publish form (/publish). The V7 two-column ".upload-panel" grid was
   meant for the "you need an account" box; it squeezed every field of the
   signed-in form into one half of the card. Colours now follow the theme.
   ========================================================================== */
.nova .upload-panel.pub-upload-form{display:block;padding:clamp(18px,3vw,32px)}
.nova .pub-upload-form>h2{margin:0 0 18px;padding-bottom:14px;border-bottom:1px solid var(--nv-line);font-size:var(--nv-fs-h2)}
.nova .pub-fields{gap:18px 20px}
.nova .pub-fields>label,.nova .pub-fields .elib-category-picker{gap:7px;font-size:14px;color:var(--nv-ink-2)}
.nova .pub-fields>label>strong,.nova .pub-fields .elib-category-picker strong{color:var(--nv-ink);font-weight:600}
.nova .pub-fields :is(input:not([type=file]):not([type=checkbox]),textarea,select){background:var(--nv-surface);color:var(--nv-ink);border:1px solid var(--nv-line-strong);border-radius:12px;padding:11px 14px}
.nova .pub-fields input[type=file]{width:100%;background:var(--nv-surface);border:1.5px dashed var(--nv-line-strong);border-radius:12px;padding:10px;color:var(--nv-ink-2);cursor:pointer}
.nova .pub-fields input[type=file]::file-selector-button{border:0;border-radius:9px;padding:8px 14px;margin-inline-end:12px;background:var(--nv-accent);color:var(--nv-accent-ink);font:600 13px var(--nv-font);cursor:pointer}
.nova .pub-fields small{color:var(--nv-muted);font-size:12.5px}
.nova .pub-fields textarea{min-height:120px}
.nova .elib-category-picker select[multiple]{min-height:190px;padding:6px!important;margin-top:0!important;border:1px solid var(--nv-line-strong)!important;background:var(--nv-surface)!important}
.nova .elib-category-picker select[multiple] option{padding:7px 10px;border-radius:8px}
.nova .elib-category-picker select[multiple] option:checked{background:color-mix(in oklab,var(--nv-accent) 22%,var(--nv-surface));color:var(--nv-ink)}
.nova :is(.pub-cover-workshop,.pub-audio-box,.pub-file-note){background:var(--nv-surface-2);border:1px solid var(--nv-line);border-radius:16px}
.nova .pub-cover-head h3{font-size:var(--nv-fs-panel)}
.nova :is(.pub-cover-head p,.pub-audio-box p,.pub-post-note){color:var(--nv-muted)}
.nova .pub-cover-card{background:var(--nv-surface);border-color:var(--nv-line)}
.nova .pub-cover-card.is-selected{border-color:var(--nv-accent);box-shadow:0 0 0 3px color-mix(in oklab,var(--nv-accent) 25%,transparent)}
.nova .pub-cover-card img{background:var(--nv-surface-2)}
.nova .pub-cover-status{color:var(--nv-accent)}
.nova .pub-checkbox{padding:12px 14px;border:1px solid var(--nv-line);border-radius:12px;background:var(--nv-surface-2);color:var(--nv-ink)}
.nova .pub-form-actions{padding-top:20px;border-top:1px solid var(--nv-line)}
.nova .pub-form-actions .btn{flex:1 1 200px}
.nova .pub-quota-panel{background:color-mix(in oklab,var(--nv-accent) 7%,var(--nv-surface));border:1px solid color-mix(in oklab,var(--nv-accent) 25%,var(--nv-line));color:var(--nv-ink)}
.nova .pub-quota-panel small{color:var(--nv-muted)}
.nova .pub-quota-panel progress{accent-color:var(--nv-accent)}
.nova .pub-quota-panel--blocked{background:var(--nv-bad-soft);border-color:color-mix(in oklab,var(--nv-bad) 40%,transparent);color:var(--nv-bad)}
.nova .pub-alert--ok{background:var(--nv-ok-soft);color:var(--nv-ok)}
.nova .pub-alert--error{background:var(--nv-bad-soft);color:var(--nv-bad)}
.nova .pub-submit-draft{background:var(--nv-ok-soft);border-color:color-mix(in oklab,var(--nv-ok) 40%,transparent)}
/* Searchable category chips (built by nova-aurora.js; the native select stays as fallback). */
.nv-catpick{display:grid;gap:10px;padding:12px;border:1px solid var(--nv-line-strong);border-radius:12px;background:var(--nv-surface)}
.nv-catpick input[type=search]{min-height:40px!important;font-size:15px!important}
.nv-catpick-list{display:flex;flex-wrap:wrap;gap:8px;max-height:220px;overflow:auto;padding:2px}
.nv-catpick-list button{border:1px solid var(--nv-line-strong);background:var(--nv-surface-2);color:var(--nv-ink-2);border-radius:999px;padding:7px 12px;font:500 13.5px var(--nv-font);cursor:pointer;line-height:1.2;text-align:start}
.nv-catpick-list button small{color:var(--nv-muted);font-size:12px}
.nv-catpick-list button[aria-pressed="true"]{background:var(--nv-accent);border-color:var(--nv-accent);color:var(--nv-accent-ink)}
.nv-catpick-list button[aria-pressed="true"] small{color:inherit;opacity:.8}
.nv-catpick-list button[hidden]{display:none}
.nv-catpick-count{font-size:12.5px;color:var(--nv-muted)}
@media (max-width:760px){.nova .upload-panel.pub-upload-form{padding:16px}.nova .pub-cover-workshop{padding:14px}}
