/* ============================================================
   ATELIER DE LECTURĂ — sistem de design (light + dark)
   Estetică: cabinet esoteric, pergament & aur, serife eluminate.
   ============================================================ */

/* ---------- Tokens: temă LIGHT (pergament, ediția de zi) ---------- */
:root {
  --bg:        #F3EFE6;   /* pergament */
  --bg-2:      #ECE6D8;   /* secțiuni */
  --card:      #FBF8F1;   /* carduri */
  --card-cover:#26211B;   /* coperta cardului (închisă, contrast) */
  --cover-ink: #ECE3CF;   /* text pe copertă */
  --ink:       #2A2520;   /* cerneală */
  --ink-soft:  #6A6052;   /* secundar */
  --ink-faint: #9A8F7C;   /* terțiar */
  --gold:      #9C7A3C;   /* aur cald (light) */
  --gold-soft: #B79A63;
  --oxblood:   #6B2C1C;   /* roșu antic */
  --line:      rgba(42,37,32,.14);
  --line-soft: rgba(42,37,32,.08);
  --shadow:    0 18px 50px -28px rgba(42,37,32,.45);
  --halo:      rgba(156,122,60,.10);
  --sel:       rgba(156,122,60,.22);
  color-scheme: light;
}

/* ---------- Tokens: temă DARK (miez de noapte & aur, ediția de seară) ---------- */
:root[data-theme="dark"] {
  --bg:        #131210;   /* miez de noapte cald */
  --bg-2:      #191713;
  --card:      #1C1A15;
  --card-cover:#211E18;
  --cover-ink: #ECE3CF;
  --ink:       #ECE4D4;   /* fildeș cald */
  --ink-soft:  #B0A793;
  --ink-faint: #7C7361;
  --gold:      #C9A86A;   /* aur luminos */
  --gold-soft: #A98E57;
  --oxblood:   #7A3320;
  --line:      rgba(236,228,212,.13);
  --line-soft: rgba(236,228,212,.07);
  --shadow:    0 24px 60px -30px rgba(0,0,0,.7);
  --halo:      rgba(201,168,106,.10);
  --sel:       rgba(201,168,106,.26);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .5s ease, color .4s ease;
  overflow-x: clip; /* clip, NU hidden: taie la fel, dar nu creează scroll-container → nu rupe position:sticky al barei/cuprinsului */
}
::selection { background: var(--sel); }
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }

h1,h2,h3,h4 { font-family: "Cormorant", "EB Garamond", Georgia, serif; font-weight: 600; line-height: 1.12; }

/* aurorele de fundal — geometrie discretă */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(closest-side at 78% 8%, var(--halo), transparent 70%),
    radial-gradient(closest-side at 8% 92%, var(--halo), transparent 70%);
}

/* ---------- utilitare ---------- */
.wrap { width: min(1180px, 92vw); margin: 0 auto; }
.eyebrow {
  font-family: "EB Garamond", serif; font-size: .74rem; letter-spacing: .32em;
  text-transform: uppercase; color: var(--gold); font-weight: 600;
}
.serif-caps { font-family: "Cormorant", serif; text-transform: uppercase; letter-spacing: .14em; }
.muted { color: var(--ink-soft); }
.gold { color: var(--gold); }
.italic { font-style: italic; }
.divider { width: 46px; height: 1px; background: var(--gold); opacity: .7; border: 0; margin: 0; }

/* ===================== HEADER ===================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px) saturate(120%);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: 76px; }
.brand { display: flex; align-items: center; gap: .8rem; }
.brand .mark { width: 38px; height: 38px; flex: none; color: var(--gold); }
.brand .mark svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; justify-content: center; }
.brand-text .t { font-family: "Cormorant", serif; font-weight: 600; font-size: 1.28rem; letter-spacing: .2em; text-transform: uppercase; line-height: 1; }
.brand-text .s { font-size: .64rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-faint); margin-top: .28rem; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 1.8rem; }
.nav a {
  font-family: "EB Garamond", serif; font-size: .82rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); padding: .3rem 0; position: relative; transition: color .25s;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); }
.nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1.5px; background: var(--gold);
}
/* comutator temă */
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--ink-soft); cursor: pointer; display: grid; place-items: center;
  transition: .25s; flex: none;
}
.icon-btn:hover { color: var(--gold); border-color: var(--gold-soft); transform: rotate(15deg); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

/* meniu hamburger (mobil) */
.menu-btn { display: none; }

/* ===================== HERO (bibliotecă) ===================== */
.hero { position: relative; padding: 3.4rem 0 2rem; overflow: hidden; }
.hero .numeral {
  position: absolute; right: -1rem; top: 2rem; font-family: "Cormorant", serif; font-weight: 600;
  font-size: 26rem; line-height: .8; color: var(--gold); opacity: .07; pointer-events: none; user-select: none;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.9rem); margin: .9rem 0 1.1rem; max-width: 18ch; }
.hero h1 em { font-style: italic; color: var(--gold); }
.hero p.lead { font-size: 1.18rem; color: var(--ink-soft); max-width: 52ch; margin: 0; }

/* filtre */
.toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 3rem 0 1.6rem; border-bottom: 1px solid var(--line-soft); padding-bottom: 1.2rem; }
.chips { display: flex; gap: .6rem; flex-wrap: wrap; }
.chip {
  font-family: "EB Garamond", serif; font-size: .82rem; letter-spacing: .08em; padding: .42rem 1.05rem;
  border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); cursor: pointer; background: transparent;
  transition: .2s; white-space: nowrap;
}
.chip:hover { border-color: var(--gold-soft); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
:root[data-theme="dark"] .chip.active { background: var(--gold); color: #1b1813; border-color: var(--gold); }
@media (pointer: coarse) { .chip { min-height: 42px; display: inline-flex; align-items: center; } }  /* țintă de atingere pe touch */
.toolbar .count { margin-left: auto; font-size: .76rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); }

/* ===================== GRILĂ CĂRȚI ===================== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 1.2rem; padding: .5rem 0 4rem; }
.book {
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 6px; overflow: hidden; transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s, border-color .35s;
}
.book:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--line); }
.cover {
  position: relative; aspect-ratio: 3/3.1; background: var(--card-cover); color: var(--cover-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 1.05rem .95rem; text-align: center; overflow: hidden;
}
.cover.ox { background: linear-gradient(165deg, #5d2718, #3c1a11); }
.cover.ink2 { background: linear-gradient(165deg, #232a32, #161b21); }
.cover::after { /* fileu auriu interior */
  content: ""; position: absolute; inset: 10px; border: 1px solid rgba(201,168,106,.28); border-radius: 3px; pointer-events: none;
}
.cover .roman { position: relative; z-index: 1; font-family: "Cormorant", serif; font-size: .8rem; letter-spacing: .42em; color: var(--gold); opacity: .9; }
.cover .motif { position: absolute; inset: 0; z-index: 0; display: grid; place-items: center; color: rgba(201,168,106,.6); }
.cover .motif svg { position: absolute; width: 64%; height: 64%; opacity: .22; }
.cover .bignum { font-family: "Cormorant", serif; font-size: 5.4rem; line-height: 1; color: rgba(236,227,207,.13); font-weight: 600; }
.cover .ctitle-wrap { position: relative; z-index: 1; width: 100%; }
.cover .ctitle { position: relative; font-family: "Cormorant", serif; text-transform: uppercase; letter-spacing: .1em; font-size: .98rem; font-weight: 600; line-height: 1.16; }
.cover .cauthor { position: relative; font-size: .6rem; letter-spacing: .22em; text-transform: uppercase; color: rgba(236,227,207,.6); margin-top: .35rem; }
.book .body { padding: .85rem .95rem 1rem; display: flex; flex-direction: column; flex: 1; }
.series-badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .66rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: .5rem; border: 1px solid var(--line); border-radius: 999px; padding: .26rem .7rem; }
.series-badge svg { width: 13px; height: 13px; }
.book { content-visibility: auto; contain-intrinsic-size: auto 340px; }  /* grilă rapidă chiar și la sute de cărți */
.book .body h2, .book .body h3 { font-size: 1.1rem; margin: 0 0 .1rem; line-height: 1.18; }
.book .body .by { font-style: italic; color: var(--gold); font-size: .78rem; margin-bottom: .35rem; }
.book .body .desc { color: var(--ink-soft); font-size: .8rem; line-height: 1.45; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book .meta { display: flex; gap: .8rem; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); margin: .6rem 0; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.btn {
  font-family: "EB Garamond", serif; font-size: .8rem; letter-spacing: .04em; padding: .44rem .7rem; border-radius: 5px;
  border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; transition: .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; white-space: nowrap;
}
.btn:hover { border-color: var(--gold-soft); color: var(--gold); }
.btn svg { width: 14px; height: 14px; }
.actions .btn.primary { flex: 1 1 auto; }   /* „Citește" umple rândul, iconurile rămân compacte */
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--gold); border-color: var(--gold); color: #1b1813; }
:root[data-theme="dark"] .btn.primary { background: var(--gold); color: #1b1813; border-color: var(--gold); }
:root[data-theme="dark"] .btn.primary:hover { filter: brightness(1.08); }
.btn.icon-only { padding: .44rem .5rem; flex: 0 0 auto; }

/* ===================== FOOTER ===================== */
.site-footer { border-top: 1px solid var(--line-soft); padding: 3rem 0; margin-top: 2rem; color: var(--ink-faint); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; font-size: .82rem; }
.site-footer .dot { opacity: .5; }

/* ===================== READER (cititor) ===================== */
.reader-bar {
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 86%, transparent); border-bottom: 1px solid var(--line-soft);
}
.reader-bar .wrap { width: min(1320px, 95vw); display: flex; align-items: center; gap: 1rem; min-height: 64px; }
.reader-bar .rtitle { font-family: "Cormorant", serif; font-weight: 600; font-size: 1.15rem; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.reader-bar .spacer { margin-left: auto; }
.reader-bar .toc-btn { display: grid; }   /* vizibil și pe desktop: ascunde/arată cuprinsul */
.reader-bar .toc-btn[aria-pressed="true"] { color: var(--gold); }
@media (min-width: 861px) {
  .reader-layout.toc-collapsed { grid-template-columns: minmax(0, 1fr); }
  .reader-layout.toc-collapsed > .toc { display: none; }
  /* cu cuprinsul ascuns, textul folosește mai multă lățime (dar plafonat pt. lizibilitate) */
  .reader-layout.toc-collapsed .reading { max-width: min(1080px, 100%); }
}
#toTop {
  position: fixed; right: 1.4rem; bottom: 1.4rem; z-index: 55; width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(14px);
  color: var(--ink-soft); cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .25s, transform .25s, color .2s, border-color .2s;
}
#toTop.show { opacity: 1; transform: none; pointer-events: auto; }
#toTop:hover { color: var(--gold); border-color: var(--gold-soft); }
#toTop svg { width: 20px; height: 20px; }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--gold); width: 0; transition: width .1s linear; }

/* control redimensionare text */
.textsize { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.textsize button {
  font-family: "Cormorant", serif; background: transparent; border: 0; color: var(--ink-soft); cursor: pointer;
  padding: .3rem .6rem; line-height: 1; transition: .2s; border-right: 1px solid var(--line-soft);
}
.textsize button:last-child { border-right: 0; }
.textsize button:hover { color: var(--gold); background: var(--halo); }
.textsize .s1 { font-size: .8rem; } .textsize .s2 { font-size: 1rem; } .textsize .s3 { font-size: 1.25rem; }

.reader-layout { width: min(1320px, 95vw); display: grid; grid-template-columns: 264px minmax(0,1fr); gap: 2.5rem; align-items: start; }
.toc {
  position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; padding: 1.5rem 0;
  border-right: 1px solid var(--line-soft);
}
.toc h4 { font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 1rem; font-family: "EB Garamond", serif; }
.toc a { display: block; font-size: .92rem; color: var(--ink-soft); padding: .34rem 1rem .34rem 0; border-left: 2px solid transparent; padding-left: .9rem; margin-left: -.9rem; transition: .2s; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--gold); border-left-color: var(--gold); }

.reading {
  --reading-size: 19px;
  max-width: min(820px, 100%); margin: 0 auto; padding: 2.5rem 0 6rem; font-size: var(--reading-size);
}
.reading .doc-head { text-align: center; margin-bottom: 3rem; padding-bottom: 2rem; border-bottom: 1px solid var(--line-soft); }
.reading .doc-head .eyebrow { display: block; margin-bottom: 1rem; }
.reading .doc-head h1 { font-size: clamp(2.2rem,5vw,3.4rem); margin: 0 0 .8rem; }
.reading .doc-head .by { font-style: italic; color: var(--gold); }
.doc-series { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: center; margin-top: 1.2rem; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); border-top: 1px solid var(--line-soft); padding-top: 1.2rem; }
.doc-series svg { width: 15px; height: 15px; color: var(--gold); }
.doc-series a { color: var(--gold); border: 1px solid var(--gold-soft); border-radius: 999px; padding: .25rem .8rem; transition: .2s; }
.doc-series a:hover { background: var(--halo); }
.reading h2.chapter {
  font-size: 1.7em; margin: 3.5rem 0 1.2rem; padding-top: 1.6rem; scroll-margin-top: 90px;
  border-top: 1px solid var(--line-soft); position: relative;
}
.reading h2.chapter::before { content: ""; position: absolute; top: -1px; left: 0; width: 46px; height: 2px; background: var(--gold); }
.reading h3.section { font-size: 1.32em; margin: 2.4rem 0 .8rem; color: var(--ink); }
.reading h4.subsection { font-size: 1.05em; margin: 1.8rem 0 .6rem; color: var(--gold); font-family: "EB Garamond", serif; font-weight: 600; letter-spacing: .02em; }
.reading p { margin: 0 0 1.1rem; }
.reading p strong, .reading li strong { font-weight: 600; }
.reading p em, .reading li em { font-style: italic; }
/* liste (enumerări puse în evidență la formatare) */
.reading ol, .reading ul { margin: 0 0 1.2rem; padding-left: 1.5rem; }
.reading li { margin: 0 0 .65rem; padding-left: .25rem; line-height: 1.62; }
.reading ol { list-style: none; counter-reset: li; padding-left: 0; }
.reading ol > li { position: relative; padding-left: 2.2rem; counter-increment: li; }
.reading ol > li::before {
  content: counter(li); position: absolute; left: 0; top: .05em;
  width: 1.55rem; height: 1.55rem; display: grid; place-items: center;
  font-family: "EB Garamond", serif; font-size: .82em; color: var(--gold);
  border: 1px solid var(--gold-soft); border-radius: 50%; background: var(--halo);
}
.reading ul { list-style: none; padding-left: 1.3rem; }
.reading ul > li { position: relative; }
.reading ul > li::before { content: "–"; position: absolute; left: -1.3rem; color: var(--gold); }
/* zonă „caiet de lucru" (pagini de însemnări cu spații de completat) */
.reading .worksheet {
  margin: 1.6rem 0; padding: 1.3rem 1.5rem; border: 1px solid var(--line-soft);
  border-left: 3px solid var(--gold-soft); border-radius: 8px; background: var(--card);
}
.reading .worksheet p { margin: 0 0 .9rem; color: var(--ink-soft); }
.reading .worksheet p:last-child { margin-bottom: 0; }
/* inițială (drop cap) la primul paragraf după capitol */
.reading h2.chapter + p::first-letter {
  font-family: "Cormorant", serif; font-size: 3.4em; line-height: .82; float: left; margin: .04em .12em 0 0; color: var(--gold); font-weight: 600;
}

/* siguranță reflow: la text mărit, nimic nu iese pe orizontală */
.reading { overflow-wrap: break-word; min-width: 0; }
.reading pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.reading table { display: block; max-width: 100%; overflow-x: auto; }
.reading img { max-width: 100%; height: auto; }
/* .chapter-block: content-visibility + contain-intrinsic-size se setează inline din reader.js,
   cu înălțimi reale măsurate, ca scroll-ul și ancorele #ch-N să rămână exacte. */
.textsize button:disabled { opacity: .32; cursor: default; }
.textsize button:disabled:hover { color: var(--ink-soft); background: transparent; }

/* ===================== CHAT (Întreabă cărțile) ===================== */
.chat-main { display: flex; flex-direction: column; min-height: calc(100vh - 76px); }
.chat-intro { padding: 3rem 0 1.5rem; text-align: center; }
.chat-intro h1 { font-size: clamp(2.4rem,5vw,3.8rem); margin: .6rem 0; }
.chat-intro h1 em { font-style: italic; color: var(--gold); }
.chat-intro p { color: var(--ink-soft); max-width: 56ch; margin: .5rem auto 0; }
.suggestions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; margin: 2rem auto 0; max-width: 760px; }
.suggestion {
  font-family: "EB Garamond", serif; font-size: .92rem; padding: .7rem 1.1rem; border: 1px solid var(--line);
  border-radius: 999px; color: var(--ink-soft); cursor: pointer; background: var(--card); transition: .2s;
}
.suggestion:hover { border-color: var(--gold-soft); color: var(--ink); transform: translateY(-2px); }

.thread { flex: 1; width: min(760px, 92vw); margin: 0 auto; padding: 1.5rem 0 1rem; display: flex; flex-direction: column; gap: 1.6rem; }
.msg { display: flex; flex-direction: column; gap: .5rem; }
.msg .who { font-size: .7rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); }
.msg.user .bubble {
  align-self: flex-end; background: var(--ink); color: var(--bg); padding: .9rem 1.2rem; border-radius: 14px 14px 4px 14px; max-width: 85%;
}
:root[data-theme="dark"] .msg.user .bubble { background: #2a2620; color: var(--ink); border: 1px solid var(--line); }
.msg.user { align-items: flex-end; }
.msg.bot .bubble { font-size: 1.05rem; line-height: 1.7; }
.msg.bot .bubble h2 { font-size: 1.5rem; margin: 1.2rem 0 .6rem; }
.msg.bot .bubble h3 { font-size: 1.2rem; margin: 1rem 0 .5rem; color: var(--gold); }
.msg.bot .bubble p { margin: 0 0 .8rem; }
.msg.bot .bubble ul, .msg.bot .bubble ol { margin: 0 0 .8rem; padding-left: 1.3rem; }
.msg.bot .bubble li { margin: .25rem 0; }
.msg.bot .bubble strong { color: var(--ink); font-weight: 600; }
.msg.bot .bubble hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.2rem 0; }
.msg.bot .bubble pre { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: .85rem 1.1rem; overflow-x: auto; margin: 0 0 .95rem; }
.msg.bot .bubble pre code { background: none; border: 0; padding: 0; font-size: .9em; line-height: 1.55; color: var(--ink); white-space: pre; }
.msg.bot .bubble table { width: 100%; border-collapse: collapse; margin: .2rem 0 1rem; font-size: .96em; }
.msg.bot .bubble th, .msg.bot .bubble td { border: 1px solid var(--line); padding: .5rem .75rem; text-align: left; vertical-align: top; }
.msg.bot .bubble th { background: var(--halo); font-weight: 600; color: var(--ink); font-family: "EB Garamond", serif; letter-spacing: .02em; }
.msg.bot .bubble blockquote { border-left: 3px solid var(--gold-soft); margin: 0 0 .95rem; padding: .35rem 0 .35rem 1rem; color: var(--ink-soft); font-style: italic; }
.cite { display: inline-grid; place-items: center; min-width: 1.25em; height: 1.25em; padding: 0 .35em; font-size: .72em;
  font-family: "EB Garamond", serif; background: var(--halo); color: var(--gold); border: 1px solid var(--gold-soft);
  border-radius: 4px; vertical-align: .15em; margin: 0 .12em; cursor: pointer; line-height: 1; }
/* secțiunea de surse — pliată implicit, discretă, ca să nu aglomereze conversația */
.sources-wrap { margin-top: 1rem; border-top: 1px solid var(--line-soft); padding-top: .55rem; }
.sources-wrap > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem;
  font-size: .76rem; letter-spacing: .02em; color: var(--ink-faint); font-style: italic;
  padding: .15rem 0; user-select: none; transition: color .15s;
}
.sources-wrap > summary:hover { color: var(--gold); }
.sources-wrap > summary::-webkit-details-marker { display: none; }
.sources-wrap > summary::before {
  content: ""; flex: none; width: 6px; height: 6px; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .18s;
  margin-left: .1rem; margin-right: .1rem;
}
.sources-wrap[open] > summary::before { transform: rotate(45deg); }
.sources-wrap[open] > summary { color: var(--ink-soft); margin-bottom: .2rem; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: .7rem; margin-top: .7rem; }
.source-card {
  display: flex; flex-direction: column; gap: .35rem; border: 1px solid var(--line-soft); border-radius: 6px; padding: .8rem .9rem;
  background: var(--card); transition: .2s; font-size: .82rem; min-width: 0;
}
.source-card:hover { border-color: var(--gold-soft); transform: translateY(-2px); }
.source-card.flash { border-color: var(--gold); box-shadow: 0 0 0 2px var(--halo); }
.source-card .sc-link { font-size: .74rem; letter-spacing: .04em; color: var(--gold); margin-top: .2rem; }
.source-card .sc-link:hover { text-decoration: underline; }
.msg.bot .bubble code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: var(--halo); padding: .08em .35em; border-radius: 4px; }
.chat-error { color: var(--oxblood); font-style: italic; }
:root[data-theme="dark"] .chat-error { color: #e0866c; }
.source-card .sc-head { display: flex; gap: .5rem; align-items: baseline; min-width: 0; }
.source-card .sc-n { font-family: "EB Garamond", serif; color: var(--gold); font-weight: 600; flex: none; }
.source-card .sc-book { font-family: "Cormorant", serif; font-weight: 600; font-size: 1rem; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.source-card .sc-chap { color: var(--ink-faint); font-size: .74rem; letter-spacing: .04em; }
.source-card .sc-snip { color: var(--ink-soft); font-size: .8rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thinking { display: inline-flex; gap: .35rem; align-items: center; color: var(--ink-soft); font-style: italic; }
.thinking .dots span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin: 0 1px; animation: blink 1.2s infinite both; }
.thinking .dots span:nth-child(2){ animation-delay: .2s; } .thinking .dots span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{ opacity:.25 } 40%{ opacity:1 } }

.composer { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-soft); padding: 1rem 0 1.4rem; }
.composer .box { width: min(760px,92vw); margin: 0 auto; display: flex; gap: .7rem; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .6rem .6rem .6rem 1.1rem; transition: border-color .2s; }
.composer .box:focus-within { border-color: var(--gold-soft); }
.composer textarea { flex: 1; border: 0; background: transparent; color: var(--ink); font-family: "EB Garamond", serif; font-size: 1.05rem;
  resize: none; outline: none; max-height: 180px; line-height: 1.5; padding: .45rem 0; }
.send-btn { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--gold); color: #1b1813; cursor: pointer;
  display: grid; place-items: center; transition: .2s; }
.send-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.send-btn:disabled { opacity: .4; cursor: default; transform: none; }
.composer .hint { width: min(760px,92vw); margin: .6rem auto 0; font-size: .74rem; color: var(--ink-faint); text-align: center; }
.linklike { display: none; background: none; border: 0; color: var(--gold); font-family: "EB Garamond", serif; font-size: .74rem; cursor: pointer; padding: 0; }
.linklike:hover { text-decoration: underline; }
.linklike.show { display: inline; }

/* ===================== ECRAN DE PAROLĂ ===================== */
#pass-gate { position: fixed; inset: 0; z-index: 300; display: none; place-items: center; padding: 1rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); }
#pass-gate.show { display: grid; }
#pass-gate .pg-box { background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 2.6rem 2rem 2rem; width: min(94vw, 372px); text-align: center; box-shadow: var(--shadow); }
#pass-gate .pg-mark { width: 46px; height: 46px; margin: 0 auto 1.1rem; color: var(--gold); }
#pass-gate .pg-mark svg { width: 100%; height: 100%; }
#pass-gate h2 { font-family: "Cormorant", serif; font-size: 1.7rem; font-weight: 600; margin: 0 0 .3rem; letter-spacing: .04em; }
#pass-gate .pg-msg { color: var(--ink-soft); font-size: .92rem; margin: 0 0 1.3rem; line-height: 1.5; }
#pass-gate .pg-input { width: 100%; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-family: "EB Garamond", serif; font-size: 1.05rem; margin-bottom: .9rem; text-align: center; letter-spacing: .1em; }
#pass-gate .pg-input:focus { outline: none; border-color: var(--gold-soft); }
#pass-gate .pg-btn { width: 100%; padding: .75rem; border: 0; border-radius: 9px; background: var(--gold);
  color: #1b1813; font-family: "EB Garamond", serif; font-size: 1.05rem; letter-spacing: .04em; cursor: pointer; }
#pass-gate .pg-btn:hover { filter: brightness(1.08); }

/* ===================== MOBIL ===================== */
.backdrop { display: none; }
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .hero .numeral { font-size: 18rem; }
}
@media (max-width: 860px) {
  body { font-size: 18px; }
  .nav {
    position: fixed; top: 0; right: 0; bottom: 0; left: auto; height: 100dvh; width: min(78vw, 320px);
    flex-direction: column; align-items: flex-start;
    gap: 1.4rem; background: var(--bg); border-left: 1px solid var(--line); padding: 6rem 2rem 2rem; margin: 0;
    transform: translateX(100%); transition: transform .35s cubic-bezier(.2,.8,.2,1); z-index: 60; overflow-y: auto;
  }
  .nav.open { transform: translateX(0); }
  .nav a { font-size: 1rem; }
  .menu-btn { display: grid; margin-left: auto; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 45; }

  .reader-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .reading { max-width: 100%; }   /* pe mobil lățimea ecranului decide, nu 70ch (uriaș la text mărit) */
  .toc {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(82vw, 340px); background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .35s; z-index: 60; padding: 5rem 1.6rem 2rem; max-height: none;
  }
  .toc.open { transform: translateX(0); }
  .reader-bar .toc-btn { display: grid; }
  .reader-bar .dl-doc, .reader-bar .dl-share { display: none; }
  .reader-bar .rtitle { max-width: 38vw; font-size: 1rem; }

  .hero { padding: 3rem 0 1.5rem; }
  .hero .numeral { font-size: 12rem; opacity: .05; top: 0; }
  .toolbar .count { width: 100%; margin: .4rem 0 0; }
  .sources { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
  .book .body { padding: .7rem .75rem .85rem; }
  .book .body h2, .book .body h3 { font-size: .98rem; }
  .book .body .desc { display: none; }            /* pe telefon: prioritizăm vederea de ansamblu */
  .cover { padding: .8rem .7rem; }
  .cover .bignum { font-size: 4.2rem; }
  .brand-text .s { display: none; }
  .reader-bar .rtitle { display: none; }
  .book .body h2 { font-size: 1.35rem; }
}

/* tranziție lină între pagini (MPA) — un cross-fade discret; browserele fără suport o ignoră */
@view-transition { navigation: auto; }

/* sugestii dezactivate cât timp se generează un răspuns */
.suggestion:disabled { opacity: .5; cursor: default; transform: none; }

/* respectă reducerea de mișcare */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0s; }
}
