/* Thunder & Lightning Library — work body (scoped under .lib-doc)
   Site chrome (auth, theme, langs, nav) comes from app.py shell — not from here.
   Palette tokens live on .lib-doc and flip with :root[data-theme="dark"|"light"]. */

.lib-doc{
  /* light reading surface (default tokens; dark overrides below) */
  --void:#0B0A14;--void-2:#141126;
  --ivory:#F6F2E9;--ivory-2:#FCFAF4;--ivory-edge:#E9E2D2;
  --ink:#1A1620;--lib-ink:#1A1620;
  --ink-soft:#565060;--ink-faint:#8A8395;
  --gold:#D8A24A;--lib-gold:#D8A24A;--gold-deep:#B9852F;--gold-glow:#F0C878;
  --thread:#E4694E;--thread-glow:#F4977E;
  --sp-violet:#9A7BD0;
  --measure:39rem;--wide:66rem;
  --serif:"Spectral",Georgia,"Times New Roman",serif;
  --display:"Cormorant Garamond",Georgia,serif;
  --mono:"IBM Plex Mono",ui-monospace,Menlo,monospace;
  color:var(--ink);
  font-family:var(--serif);
  font-size:clamp(1.02rem,0.96rem + 0.34vw,1.2rem);
  line-height:1.78;letter-spacing:.002em;
  -webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;
  background:var(--ivory);
  border-radius:14px;
  border:1px solid var(--line, rgba(128,128,140,.22));
  margin:8px 0 18px;
  padding:0 0 1.5rem;
  overflow:hidden;
}

/* ── Dark mode: invert the reading surface to match the site chrome ── */
:root[data-theme="dark"] .lib-doc{
  --void:#08070e;--void-2:#12101a;
  --ivory:#16141f;--ivory-2:#1e1b2a;--ivory-edge:#3a3548;
  --ink:#EDE8DF;--lib-ink:#EDE8DF;
  --ink-soft:#b5ab98;--ink-faint:#8e879c;
  --gold:#E0B45C;--lib-gold:#E0B45C;--gold-deep:#C9A04A;--gold-glow:#F0C878;
  --thread:#E8846A;--thread-glow:#F4A78E;
  --sp-violet:#B39DDB;
  --sp-blue:#7BA3F5;--sp-white:#F3EFE4;--sp-yellow:#EAC15E;
  --sp-red:#E8846A;--sp-green:#6FCB9A;
  background:var(--ivory);
  color:var(--ink);
  border-color:var(--ivory-edge);
  box-shadow:0 12px 40px rgba(0,0,0,.45);
}

/* Light Inside (and similar) hardcodes a few light-page ink colors — force them onto tokens */
:root[data-theme="dark"] .lib-doc h2.section-title,
:root[data-theme="dark"] .lib-doc h2:not(.half-title h2),
:root[data-theme="dark"] .lib-doc .chap,
:root[data-theme="dark"] .lib-doc .v1,
:root[data-theme="dark"] .lib-doc .v2,
:root[data-theme="dark"] .lib-doc .v3{
  color:var(--ink);
}
:root[data-theme="dark"] .lib-doc .enote{
  background:linear-gradient(180deg,#221f30,#1a1826)!important;
  border-color:var(--ivory-edge)!important;
}
:root[data-theme="dark"] .lib-doc .enote p,
:root[data-theme="dark"] .lib-doc .enote .eh{
  color:var(--ink-soft)!important;
}
/* half-title / hero / threshold already use light-on-dark — keep them readable */
:root[data-theme="dark"] .lib-doc .half-title,
:root[data-theme="dark"] .lib-doc .hero,
:root[data-theme="dark"] .lib-doc .threshold,
:root[data-theme="dark"] .lib-doc .sources{
  color:var(--ivory);
}

/* index hub sits on the themed page bg — no cream card */
.lib-doc.index{
  min-height:auto;background:transparent;border:0;box-shadow:none;padding:0;
  color:var(--ink); /* site token when index; overridden by .lib-doc dark tokens when nested rules apply */
}
:root[data-theme="dark"] .lib-doc.index{
  background:transparent;border:0;box-shadow:none;
  /* use site chrome ink so titles match the rest of the app */
  color:var(--ink);
  --ink:var(--ink); /* no-op keep */
}

/* work-language strip (EN/DE/IT of the text) under the site header */
.lib-worklang{
  display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.55rem;
  padding:.65rem 1rem .15rem;font-family:var(--mono);font-size:.68rem;
  letter-spacing:.12em;text-transform:uppercase;
}
.lib-worklang a{
  color:var(--muted, #8a8395);text-decoration:none;padding:.2rem .45rem;border-radius:5px;
}
.lib-worklang a:hover{color:var(--gold)}
.lib-worklang a.on{color:var(--gold);background:rgba(216,162,74,.14)}
.lib-worklang .lbl{opacity:.65;margin-right:.2rem}

/* back to library hub (in-content, not a second site header) */
.lib-backrow{text-align:center;padding:.4rem 1rem 0}
.lib-backrow a{
  font-family:var(--mono);font-size:.7rem;letter-spacing:.12em;text-transform:uppercase;
  color:var(--muted,#8a8395);text-decoration:none;
}
.lib-backrow a:hover{color:var(--gold)}

/* half-title (classic works) */
.lib-doc .half-title{text-align:center;padding:clamp(2rem,5vw,3.5rem) 1.2rem 1.2rem}
.lib-doc .ht-title{font-family:var(--display);font-weight:500;font-size:clamp(2.2rem,6vw,4rem);line-height:1.02;
  letter-spacing:.04em;margin:0;color:var(--lib-ink);text-transform:uppercase}
.lib-doc .ht-amp{display:inline-block;font-style:italic;font-weight:500;color:var(--thread);padding:0 .12em;text-transform:none}
.lib-doc .ht-rule{width:min(12rem,40vw);height:1px;border:0;margin:1.1rem auto .9rem;
  background:linear-gradient(90deg,transparent,var(--lib-gold),var(--thread),var(--sp-violet),transparent)}
.lib-doc .ht-sub{font-family:var(--mono);font-size:.78rem;letter-spacing:.22em;text-transform:uppercase;color:var(--ink-soft);margin:0}

/* index hub */
.lib-hero{position:relative;text-align:center;padding:clamp(2rem,6vw,4rem) 1.2rem 1.5rem;overflow:hidden}
.lib-hero-glow{position:absolute;inset:-20% 20% auto;height:16rem;background:
  radial-gradient(ellipse at center,rgba(244,151,126,.18),transparent 62%),
  radial-gradient(ellipse at 30% 60%,rgba(216,162,74,.12),transparent 55%),
  radial-gradient(ellipse at 70% 40%,rgba(154,123,208,.12),transparent 55%);pointer-events:none}
.lib-hero-inner{position:relative}
.lib-name{font-family:var(--display);font-weight:500;font-size:clamp(2.4rem,7vw,4.2rem);letter-spacing:.28em;
  margin:0;color:var(--ink);text-transform:uppercase}
.lib-tagline{font-family:var(--mono);font-size:.72rem;letter-spacing:.2em;text-transform:uppercase;color:var(--muted);margin:1rem 0 0}
.lib-list{max-width:36rem;margin:0 auto;padding:.5rem 0 2rem;display:flex;flex-direction:column;gap:1rem}
.lib-item{display:block;text-decoration:none;color:inherit;padding:1.35rem 1.4rem 1.25rem;
  background:var(--panel);border:1px solid var(--line);border-radius:14px;
  box-shadow:0 10px 30px rgba(26,22,32,.04);transition:border-color .2s,transform .2s,box-shadow .2s}
:root[data-theme="dark"] .lib-item{box-shadow:0 10px 30px rgba(0,0,0,.25)}
.lib-item:hover{border-color:var(--gold);transform:translateY(-2px)}
.lib-title{display:block;font-family:var(--display);font-size:1.55rem;font-weight:600;letter-spacing:.02em;color:var(--ink);line-height:1.15}
.lib-sub{display:block;font-family:var(--mono);font-size:.66rem;letter-spacing:.14em;text-transform:uppercase;color:var(--gold);margin:.4rem 0 .55rem}
.lib-blurb{display:block;font-size:.98rem;line-height:1.55;color:var(--muted)}
.lib-arrow{display:inline-block;margin-top:.75rem;font-family:var(--mono);font-size:.68rem;letter-spacing:.14em;text-transform:uppercase;color:var(--gold)}
.lib-foot{text-align:center;padding:1rem 0 1rem;color:var(--muted)}
.lib-seal{font-size:1.2rem;opacity:.7}

/* classic work body (thunder / luminous) */
.work-body{max-width:var(--measure);margin:0 auto;padding:0 1.25rem 2.5rem}
.work-body .divider{margin:2.8rem 0 2rem;text-align:center;position:relative}
.work-body .div-num{display:block;font-family:var(--display);font-size:2rem;color:var(--thread);letter-spacing:.08em}
.work-body .div-title{display:block;font-family:var(--mono);font-size:.72rem;letter-spacing:.22em;text-transform:uppercase;color:var(--gold-deep);margin:.35rem 0}
.work-body .div-rule{width:5rem;height:1px;border:0;margin:.7rem auto;background:var(--lib-gold)}
.work-body .div-epi{font-style:italic;color:var(--ink-soft);margin:.4rem 0 0;font-size:1.05rem}
.work-body .stanza{margin:1.6rem 0}
.work-body .line{margin:.15rem 0;line-height:1.7;color:var(--lib-ink)}
.work-body .line.lead{font-weight:500}
.work-body article h2,.work-body h2{font-family:var(--display);font-weight:600;font-size:1.7rem;margin:2.4rem 0 .8rem;letter-spacing:.02em;color:var(--lib-ink)}
.work-body article h3,.work-body h3{font-family:var(--display);font-weight:600;font-size:1.25rem;margin:1.8rem 0 .6rem;color:var(--gold-deep)}
.work-body p{margin:0 0 1rem;color:var(--lib-ink)}
.work-body .intro,.work-body .lede{font-size:1.08rem;color:var(--ink-soft)}
.lib-doc .colophon{max-width:var(--measure);margin:2rem auto 0;padding:1.5rem 1.25rem 1rem;text-align:center;color:var(--ink-soft)}
.lib-doc .colo-end{font-family:var(--display);font-style:italic;font-size:1.25rem;color:var(--lib-ink);margin:0 0 1rem}
.lib-doc .colo-rule{width:4rem;height:1px;border:0;margin:0 auto 1.2rem;background:var(--lib-gold)}
.lib-doc .colo-item{font-size:.9rem;margin:.6rem 0;line-height:1.5}
.lib-doc .colo-seal{margin:1.4rem 0 .8rem;opacity:.7}
.lib-doc .back-foot{display:inline-block;margin-top:1rem;
  font-family:var(--mono);font-size:.7rem;letter-spacing:.12em;text-transform:uppercase;
  color:var(--gold-deep);text-decoration:none}
.lib-doc .back-foot:hover{color:var(--lib-ink)}

.work-body section{margin:0}
.work-body .chapter{margin:2rem 0}

/* Light Inside pages bring their own scoped CSS; soften fixed chrome so it sits under the site header */
.lib-doc.light-inside{padding:0;border-radius:14px}
.lib-doc.light-inside .progress{z-index:40}
.lib-doc.light-inside .spine{z-index:1}
/* hide any leftover mini-toolbar if a file still embeds one */
.lib-doc .toolbar{display:none!important}
