

/* ══════════════════════════════════════════════════════════════
   REWRITER v3 — THE LIVING MANUSCRIPT
   Aesthetic: Dark Luxury Editorial — ancient manuscript reborn
   Fonts: Times New Roman (system serif)
   ══════════════════════════════════════════════════════════════ */

/* ── Times New Roman (system font, no external load) ── */

/* ══════════════════════
   DESIGN TOKENS
══════════════════════ */
:root {
  /* ─ Dark manuscript palette ─ */
  --void:         #0D0B08;        /* Near black — aged vellum dark */
  --void-2:       #141210;
  --void-3:       #1C1915;
  --void-4:       #252118;
  --void-5:       #2E2920;
  --parchment:    #E8E0CC;        /* Aged paper */
  --parchment-2:  #D4C9B0;
  --parchment-3:  #B8AD96;
  --gold:         #C9A84C;        /* Illuminated manuscript gold */
  --gold-2:       #DDB96A;
  --gold-dim:     rgba(201,168,76,0.12);
  --gold-glow:    rgba(201,168,76,0.25);
  --teal:         #2A6B6B;        /* Deep ink teal */
  --teal-2:       #3A8A8A;
  --teal-glow:    rgba(42,107,107,0.2);
  --crimson:      #8B3A3A;        /* Blood — for danger/distress */
  --sage:         #4A7A5A;        /* Healing green */
  --sage-glow:    rgba(74,122,90,0.15);

  /* ─ Semantic ─ */
  --text:         var(--parchment);
  --text-2:       var(--parchment-2);
  --text-3:       var(--parchment-3);
  --border:       rgba(232,224,204,0.08);
  --border-2:     rgba(232,224,204,0.14);
  --border-gold:  rgba(201,168,76,0.3);
  --surface:      var(--void-2);
  --surface-2:    var(--void-3);
  --surface-3:    var(--void-4);
  --surface-4:    var(--void-5);

  /* ─ Typography ─ */
  --display:   'Times New Roman', Times, Georgia, serif;
  --body:      'Times New Roman', Times, Georgia, serif;
  --fell:      'Times New Roman', Times, Georgia, serif;
  --mono:      'Courier New', Courier, monospace;
  --lh-title:  1.15;
  --lh-body:   1.75;
  --lh-loose:  2;
  --ls-caps:   0.12em;
  --ls-wide:   0.04em;

  /* ─ Motion ─ */
  --spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:   cubic-bezier(0.7, 0, 0.84, 0);
  --ease-ink:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --fast:      150ms;
  --normal:    280ms;
  --slow:      500ms;
  --cinematic: 900ms;

  /* ─ Shadows ─ */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg:  0 16px 64px rgba(0,0,0,0.6);
  --shadow-xl:  0 32px 96px rgba(0,0,0,0.7);
  --glow-gold:  0 0 32px rgba(201,168,76,0.15), 0 0 8px rgba(201,168,76,0.1);
  --glow-teal:  0 0 32px rgba(42,107,107,0.2);

  /* ─ Radii ─ */
  --r-sm:  4px;
  --r-md:  8px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-pill:100px;

  /* ─ Space ─ */
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem;
  --s5: 1.25rem; --s6: 1.5rem; --s8: 2rem; --s10: 2.5rem;
  --s12: 3rem; --s16: 4rem; --s20: 5rem; --s24: 6rem;

  /* ─ Layout ─ */
  --max-w: 700px;
  --hdr-h: 58px;
}

/* ── Light Theme Override ── */
[data-theme="light"] {
  --void:         #F5F0E8;
  --void-2:       #EDE7D9;
  --void-3:       #E4DDD0;
  --void-4:       #D8D1C4;
  --void-5:       #CCC4B6;
  --parchment:    #2A2520;
  --parchment-2:  #4A443C;
  --parchment-3:  #7A7268;
  --gold:         #8B5E14;
  --gold-2:       #A67418;
  --gold-dim:     rgba(139,94,20,0.1);
  --gold-glow:    rgba(139,94,20,0.2);
  --teal:         #1A5555;
  --teal-2:       #226666;
  --teal-glow:    rgba(26,85,85,0.15);
  --border:       rgba(42,37,32,0.1);
  --border-2:     rgba(42,37,32,0.18);
  --border-gold:  rgba(139,94,20,0.25);
  --surface:      var(--void-2);
  --surface-2:    var(--void-3);
  --surface-3:    var(--void-4);
  --surface-4:    var(--void-5);
  --glow-gold:    0 0 24px rgba(139,94,20,0.1);
  --glow-teal:    0 0 24px rgba(26,85,85,0.15);
}

/* ══════════════════════
   RESET & BASE
══════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 17px; }

body {
  font-family: var(--body);
  font-weight: 300;
  font-size: 1rem;
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--void);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: auto; /* custom cursor */
  transition: background 0.6s var(--ease-ink), color 0.4s;
}

/* Restore cursor on touch */
@media (hover: none) { body { cursor: auto; } #cursor { display: none; } }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 2px; }
button { cursor: auto; font-family: inherit; border: none; background: none; }
input, textarea { font-family: var(--body); }
h1,h2,h3 { font-family: var(--display); font-weight: 700; line-height: var(--lh-title); color: var(--text); }

/* ══════════════════════
   AMBIENT CANVAS
══════════════════════ */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

#app { position: relative; z-index: 1; will-change: transform; }

/* ══════════════════════
   SKIP LINK
══════════════════════ */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--s4);
  background: var(--gold);
  color: var(--void);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-sm);
  z-index: 9999;
  font-size: 0.85rem;
  font-weight: 600;
}
.skip-link:focus { top: var(--s2); }

/* ══════════════════════
   LOADER — CINEMATIC
══════════════════════ */
.loader {
  position: fixed;
  inset: 0;
  background: var(--void);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.8s var(--ease-in);
}

.loader.out { opacity: 0; pointer-events: none; }

.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s6);
}

.loader-quill {
  width: 60px;
  animation: quill-write 2.4s var(--ease-ink) infinite;
  transform-origin: bottom center;
  filter: drop-shadow(0 0 16px rgba(201,168,76,0.3));
}

@keyframes quill-write {
  0%   { transform: rotate(-8deg) translateY(0); }
  25%  { transform: rotate(0deg) translateY(-3px); }
  50%  { transform: rotate(8deg) translateY(0); }
  75%  { transform: rotate(0deg) translateY(-3px); }
  100% { transform: rotate(-8deg) translateY(0); }
}

.loader-lines {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: 120px;
}

.loader-lines span {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform-origin: left;
  animation: line-draw 2.4s var(--ease-ink) infinite;
}
.loader-lines span:nth-child(1) { animation-delay: 0s; }
.loader-lines span:nth-child(2) { animation-delay: 0.3s; width: 80%; }
.loader-lines span:nth-child(3) { animation-delay: 0.6s; width: 60%; }

@keyframes line-draw {
  0%,100% { transform: scaleX(0); opacity: 0; }
  30%,70%  { transform: scaleX(1); opacity: 1; }
}

.loader-word {
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
  animation: fade-pulse 2.4s ease-in-out infinite;
}

.loader-sub {
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-3);
  letter-spacing: var(--ls-wide);
  animation: fade-pulse 2.4s ease-in-out infinite 0.6s;
}

@keyframes fade-pulse {
  0%,100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ══════════════════════
   APP HEADER
══════════════════════ */
.header {
  position: sticky;
  top: 0;
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s6);
  background: linear-gradient(to bottom, var(--void) 0%, rgba(13,11,8,0.85) 100%);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border-bottom: 1px solid var(--border);
  z-index: 500;
  gap: var(--s4);
}

[data-theme="light"] .header {
  background: linear-gradient(to bottom, var(--void) 0%, rgba(245,240,232,0.88) 100%);
}

.header-mark {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--gold);
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: auto;
  padding: var(--s1) var(--s2);
  border-radius: var(--r-sm);
  transition: color var(--fast);
  flex-shrink: 0;
}
.header-mark:hover { color: var(--gold-2); }
.header-mark svg { flex-shrink: 0; }

.header-center { flex: 1; display: flex; justify-content: center; }

.phase-stamp {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--body);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px var(--s3);
  border-radius: var(--r-pill);
}

.header-nav { display: flex; align-items: center; gap: var(--s1); flex-shrink: 0; }

/* Pulsing save indicator */
.save-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  margin-right: var(--s2);
  transition: background var(--fast), box-shadow var(--fast);
}
.save-pulse.saving { background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: ring-pulse 0.8s ease-in-out infinite; }
.save-pulse.saved  { background: var(--sage); box-shadow: 0 0 6px var(--sage); }

@keyframes ring-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(201,168,76,0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(201,168,76,0); }
}

/* Header buttons */
.hdr-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--text-3);
  transition: all var(--fast);
  cursor: auto;
}
.hdr-btn:hover { background: var(--surface-2); color: var(--text); }

/* ══════════════════════
   PAGE TRANSITIONS
══════════════════════ */
#root { min-height: calc(100dvh - var(--hdr-h)); }

.page-enter {
  animation: page-reveal var(--slow) var(--ease-out) both;
}

@keyframes page-reveal {
  from { opacity: 0; transform: translateY(24px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

/* ══════════════════════
   MAIN LAYOUT
══════════════════════ */
.manuscript {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s12) var(--s6) var(--s20);
}

/* ══════════════════════
   WELCOME SCREEN
══════════════════════ */
.welcome {
  min-height: calc(100dvh - var(--hdr-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s16) var(--s6);
  gap: var(--s10);
  position: relative;
  overflow: hidden;
}

/* Ornamental border frame */
.welcome::before {
  content: '';
  position: absolute;
  inset: var(--s8);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-xl);
  pointer-events: none;
  opacity: 0.4;
}

.welcome::after {
  content: '';
  position: absolute;
  inset: calc(var(--s8) + 6px);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-xl) - 4px);
  pointer-events: none;
  opacity: 0.3;
}

.welcome-quill {
  width: 80px;
  filter: drop-shadow(var(--glow-gold));
  animation: float-quill 5s ease-in-out infinite;
}

@keyframes float-quill {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-10px) rotate(3deg); }
}

/* Chapter ornament */
.ornament {
  font-family: var(--fell);
  font-size: 1rem;
  color: var(--gold);
  opacity: 0.7;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.ornament::before, .ornament::after {
  content: '✦';
  margin: 0 var(--s3);
  font-size: 0.6rem;
  vertical-align: middle;
}

.welcome-title {
  font-family: var(--display);
  font-size: clamp(3.5rem, 12vw, 6rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--text);
  position: relative;
}

/* Gold underline stroke on title */
.welcome-title::after {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin-top: var(--s3);
  opacity: 0.6;
  animation: gold-line-expand 1.2s var(--ease-out) 0.5s both;
  transform-origin: center;
}

@keyframes gold-line-expand {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 0.6; }
}

.welcome-tagline {
  font-family: var(--fell);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-2);
  max-width: 380px;
  line-height: var(--lh-loose);
}

/* Illuminated quote block */
.illuminated-quote {
  max-width: 400px;
  position: relative;
  padding: var(--s6) var(--s8);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  text-align: left;
}

.illuminated-quote::before {
  content: '"';
  position: absolute;
  top: -20px;
  left: var(--s5);
  font-family: var(--display);
  font-size: 5rem;
  line-height: 1;
  color: var(--gold);
  opacity: 0.35;
}

/* Ornamental corner marks */
.illuminated-quote::after {
  content: '✦';
  position: absolute;
  bottom: var(--s3);
  right: var(--s4);
  color: var(--gold);
  font-size: 0.6rem;
  opacity: 0.4;
}

.illuminated-quote blockquote {
  font-family: var(--fell);
  font-style: italic;
  font-size: 1.05rem;
  line-height: var(--lh-loose);
  color: var(--text-2);
}

.illuminated-quote cite {
  display: block;
  margin-top: var(--s4);
  font-family: var(--body);
  font-style: normal;
  font-size: 0.75rem;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.8;
}

.welcome-ctas {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  width: 100%;
  max-width: 300px;
}

.welcome-private {
  font-size: 0.78rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--s1);
  letter-spacing: var(--ls-wide);
}

/* ══════════════════════
   BUTTONS
══════════════════════ */
.ink-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 0.7rem 1.6rem;
  border-radius: var(--r-pill);
  font-family: var(--body);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: var(--ls-wide);
  cursor: auto;
  transition: all var(--fast) var(--ease-out);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
}

/* Ink spread on hover */
.ink-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  transform: scale(0.8);
  transition: opacity var(--fast), transform var(--fast);
}
.ink-btn:hover::before { opacity: 0.06; transform: scale(1); }
.ink-btn:active::before { opacity: 0.1; }

.ink-btn:disabled { opacity: 0.35; pointer-events: none; }

/* Gold — primary */
.ink-btn.gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: var(--void);
  font-weight: 500;
  box-shadow: 0 4px 20px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}
.ink-btn.gold:hover {
  box-shadow: 0 6px 28px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

/* Ghost */
.ink-btn.ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.ink-btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-gold); }

/* Teal */
.ink-btn.teal {
  background: var(--teal);
  color: var(--parchment);
  border-color: var(--teal-2);
}
.ink-btn.teal:hover { background: var(--teal-2); box-shadow: var(--glow-teal); }

/* Danger */
.ink-btn.danger {
  background: transparent;
  color: var(--crimson);
  border-color: var(--crimson);
}
.ink-btn.danger:hover { background: rgba(139,58,58,0.1); }

/* Sizes */
.ink-btn.full { width: 100%; }
.ink-btn.lg   { padding: 0.85rem 2rem; font-size: 1rem; }
.ink-btn.sm   { padding: 0.45rem 1rem; font-size: 0.8rem; }

/* ══════════════════════
   PROGRESS QUILL
══════════════════════ */
.quill-progress {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-bottom: var(--s10);
}

.quill-track {
  flex: 1;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  position: relative;
  overflow: visible;
}

.quill-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  border-radius: 1px;
  transition: width 0.8s var(--ease-out);
  position: relative;
}

/* Quill nib at tip of progress */
.quill-fill::after {
  content: '✦';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 0.65rem;
  filter: drop-shadow(0 0 4px var(--gold));
}

.quill-fraction {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-3);
  letter-spacing: var(--ls-caps);
}

/* ══════════════════════
   CHAPTER HEADER
══════════════════════ */
.chapter-header { margin-bottom: var(--s10); }

.chapter-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--fell);
  font-size: 0.78rem;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--s4);
  opacity: 0.9;
}

.chapter-mark::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--gold);
  opacity: 0.5;
}

.chapter-title {
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: var(--s5);
}

/* Drop cap on first word */
.chapter-title .drop {
  float: left;
  font-size: 3.8em;
  line-height: 0.75;
  margin: 0.08em 0.06em 0 0;
  color: var(--gold);
  font-weight: 900;
  text-shadow: 0 0 40px var(--gold-glow);
}

.chapter-lore {
  font-family: var(--fell);
  font-style: italic;
  font-size: 1.05rem;
  line-height: var(--lh-loose);
  color: var(--text-2);
  padding: var(--s5) var(--s6);
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border-left: 2px solid var(--gold);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  position: relative;
}

.chapter-lore::before {
  content: '§';
  position: absolute;
  top: var(--s3);
  right: var(--s4);
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--gold);
  opacity: 0.15;
}

.chapter-timing {
  margin-top: var(--s3);
  font-size: 0.75rem;
  color: var(--text-3);
  letter-spacing: var(--ls-wide);
}

/* ══════════════════════
   FORM — INK FIELDS
══════════════════════ */
.field-section { margin-bottom: var(--s10); }
.field-wrap    { margin-bottom: var(--s6); }

.field-label {
  display: block;
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--s2);
  opacity: 0.85;
}

.field-lore {
  display: block;
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.95rem;
  line-height: var(--lh-body);
  color: var(--text-2);
  margin-bottom: var(--s3);
}

.field-row { display: flex; gap: var(--s2); align-items: flex-start; }

/* Ink textarea/input */
.field-ink {
  width: 100%;
  padding: var(--s4) var(--s5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 300;
  color: var(--text);
  line-height: var(--lh-body);
  outline: none;
  resize: vertical;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
  -webkit-appearance: none;
  min-height: 48px;
}

.field-ink::placeholder { color: var(--text-3); font-style: italic; }

.field-ink:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 3px var(--gold-dim), inset 0 1px 3px rgba(0,0,0,0.2);
  background: var(--surface-3);
}

textarea.field-ink { min-height: 120px; }

.field-ink-wrap { position: relative; }
.field-ink-wrap .field-ink { padding-right: 3rem; }
.field-ink-wrap textarea.field-ink { padding-right: 3rem; }

/* Voice button */
.voice-glyph {
  position: absolute;
  right: var(--s2);
  top: var(--s2);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-4);
  border: 1px solid var(--border);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: auto;
  transition: all var(--fast);
}

.voice-glyph:hover, .voice-glyph.recording { background: var(--gold); color: var(--void); border-color: var(--gold); }
.voice-glyph.recording { animation: mic-breathe 0.9s ease-in-out infinite; }

@keyframes mic-breathe {
  0%,100% { box-shadow: 0 0 0 0 var(--gold-glow); }
  50%      { box-shadow: 0 0 0 8px transparent; }
}

.field-note { display: block; font-size: 0.72rem; color: var(--text-3); margin-top: var(--s1); font-style: italic; min-height: 1.2em; }

/* ══════════════════════
   TACTIC PILLS (rune style)
══════════════════════ */
.rune-set {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.rune {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-pill);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  font-family: var(--body);
  font-size: 0.875rem;
  color: var(--text-2);
  cursor: auto;
  user-select: none;
  transition: all var(--normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.rune::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  opacity: 0;
  transition: opacity var(--fast);
}

.rune span { position: relative; z-index: 1; }

.rune:hover { border-color: var(--border-gold); color: var(--text); }
.rune.lit   { border-color: var(--gold); color: var(--void); }
.rune.lit::before { opacity: 0.85; }

/* ══════════════════════
   VELLUM CARDS
══════════════════════ */
.vellum {
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s6);
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--fast), border-color var(--fast);
}

.vellum:hover { box-shadow: var(--shadow-md); }
.vellum:focus-within { border-color: var(--border-gold); }

/* Corner ornament */
.vellum::after {
  content: '✦';
  position: absolute;
  bottom: var(--s3);
  right: var(--s4);
  color: var(--gold);
  font-size: 0.5rem;
  opacity: 0.2;
}

.vellum-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}

@media (max-width: 560px) { .vellum-grid { grid-template-columns: 1fr; } }

.vellum-icon  { font-size: 1.2rem; margin-bottom: var(--s2); }
.vellum-label { font-family: var(--display); font-size: 0.95rem; font-weight: 500; color: var(--text); margin-bottom: var(--s3); }

/* ══════════════════════
   SPARKLING MOMENT SCROLLS
══════════════════════ */
.scroll-list { display: flex; flex-direction: column; gap: var(--s5); }

.scroll {
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-md);
  padding: var(--s6);
  position: relative;
  animation: scroll-unfurl var(--slow) var(--ease-out) both;
}

@keyframes scroll-unfurl {
  from { opacity: 0; transform: translateY(10px) scaleY(0.95); transform-origin: top; }
  to   { opacity: 1; transform: translateY(0) scaleY(1); }
}

.scroll-num {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--s3);
}

.scroll-del {
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--fast);
  cursor: auto;
}

.scroll:hover .scroll-del { opacity: 1; }
.scroll-del:hover { background: rgba(139,58,58,0.15); color: var(--crimson); }

.scroll-field { margin-bottom: var(--s3); }
.scroll-field-label { font-size: 0.68rem; letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--text-3); margin-bottom: var(--s1); }
.scroll-field-value { font-family: var(--fell); font-style: italic; font-size: 0.98rem; line-height: var(--lh-body); color: var(--text); }
.scroll-date { font-size: 0.7rem; color: var(--text-3); padding-top: var(--s3); border-top: 1px solid var(--border); margin-top: var(--s2); }

/* ══════════════════════
   IDENTITY CLAIMS — ILLUMINATED
══════════════════════ */
.claim-codex { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s3); }

.claim-verse {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  animation: scroll-unfurl var(--normal) var(--ease-out) both;
}

.claim-numeral {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: var(--void);
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.claim-text { flex: 1; font-family: var(--fell); font-style: italic; font-size: 1rem; line-height: var(--lh-body); color: var(--text); }

.claim-erase {
  color: var(--text-3);
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity var(--fast), color var(--fast);
  cursor: auto;
  padding: 2px;
}
.claim-verse:hover .claim-erase { opacity: 1; }
.claim-erase:hover { color: var(--crimson); }

/* ══════════════════════
   SUPPORT TEAM
══════════════════════ */
.guild-list { display: flex; flex-direction: column; }

.guild-member {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
}
.guild-member:last-child { border-bottom: none; }

.guild-crest {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--parchment);
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.guild-info { flex: 1; }
.guild-name { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.guild-role { font-size: 0.75rem; color: var(--text-3); }

.guild-dismiss { color: var(--text-3); font-size: 0.8rem; opacity: 0; transition: all var(--fast); cursor: auto; }
.guild-member:hover .guild-dismiss { opacity: 1; }
.guild-dismiss:hover { color: var(--crimson); }

/* ══════════════════════
   GUIDE QUESTIONS — ILLUMINATED
══════════════════════ */
.illumined-qs { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s10); }

.illumined-q {
  padding: var(--s4) var(--s5);
  background: linear-gradient(135deg, var(--gold-dim), transparent);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  font-family: var(--fell);
  font-style: italic;
  font-size: 1rem;
  line-height: var(--lh-body);
  color: var(--text-2);
  position: relative;
}

.illumined-q em { color: var(--gold-2); font-style: normal; }

/* ══════════════════════
   STORY LIST (DASHBOARD)
══════════════════════ */
.library {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s12) var(--s6) var(--s20);
}

.library-head { margin-bottom: var(--s10); }

.library-title {
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.library-sub {
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-3);
  margin-top: var(--s2);
}

.library-controls {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s6);
  flex-wrap: wrap;
}

.codex-list { display: flex; flex-direction: column; gap: var(--s3); }

.codex-entry {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: auto;
  transition: all var(--normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

/* Shimmer on hover */
.codex-entry::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--gold-dim) 50%, transparent 100%);
  opacity: 0;
  transform: translateX(-100%);
  transition: none;
}

.codex-entry:hover::before {
  opacity: 1;
  transform: translateX(100%);
  transition: transform 0.6s var(--ease-out), opacity 0.3s;
}

.codex-entry:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.codex-phase-icon {
  width: 44px;
  height: 44px;
  background: var(--surface-4);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.codex-body { flex: 1; min-width: 0; }

.codex-name {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: var(--s1);
}

.codex-meta {
  font-size: 0.75rem;
  color: var(--text-3);
  display: flex;
  gap: var(--s3);
  align-items: center;
  flex-wrap: wrap;
}

.codex-phase-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s2);
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-pill);
  font-size: 0.68rem;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.codex-del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--fast);
  cursor: auto;
}
.codex-entry:hover .codex-del { opacity: 1; }
.codex-del:hover { background: rgba(139,58,58,0.15); color: var(--crimson); }

/* Empty state */
.empty-tome { text-align: center; padding: var(--s20) var(--s6); }
.empty-tome-icon { font-size: 3rem; margin-bottom: var(--s5); opacity: 0.5; }
.empty-tome-title { font-family: var(--display); font-size: 1.5rem; color: var(--text-2); margin-bottom: var(--s3); }
.empty-tome-desc { font-family: var(--fell); font-style: italic; font-size: 0.95rem; color: var(--text-3); max-width: 320px; margin: 0 auto; line-height: var(--lh-body); }

/* ══════════════════════
   PAGE NAV
══════════════════════ */
.page-folio {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--s16);
  padding-top: var(--s8);
  border-top: 1px solid var(--border);
  gap: var(--s4);
}

.folio-spacer { flex: 1; }

/* ══════════════════════
   SUMMARY — ILLUMINATED MANUSCRIPT PAGE
══════════════════════ */
.manuscript-complete {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s12) var(--s6) var(--s20);
}

.completion-crown {
  text-align: center;
  padding: var(--s10) 0 var(--s12);
  border-bottom: 1px solid var(--border-gold);
  margin-bottom: var(--s10);
  position: relative;
}

.completion-crown::before {
  content: '✦  ✦  ✦';
  display: block;
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: var(--s4);
  margin-bottom: var(--s4);
  opacity: 0.6;
}

.completion-crown::after {
  content: '✦  ✦  ✦';
  display: block;
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: var(--s4);
  margin-top: var(--s4);
  opacity: 0.6;
}

.completion-title {
  font-family: var(--display);
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 900;
  color: var(--text);
  margin-bottom: var(--s3);
}

.completion-sub {
  font-family: var(--fell);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-3);
}

.summary-chapter { margin-bottom: var(--s10); }

.summary-chapter-head {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--gold);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border-gold);
  margin-bottom: var(--s5);
  opacity: 0.8;
}

.summary-entry { margin-bottom: var(--s4); }
.summary-entry-label { font-size: 0.7rem; letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--text-3); margin-bottom: var(--s1); }
.summary-entry-value { font-family: var(--fell); font-size: 1rem; line-height: var(--lh-body); color: var(--text); }

.declaration-folio {
  padding: var(--s6);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border-gold);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  font-family: var(--fell);
  font-style: italic;
  font-size: 1.1rem;
  line-height: var(--lh-loose);
  color: var(--text);
  box-shadow: var(--glow-gold);
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding-top: var(--s10);
  border-top: 1px solid var(--border);
}

/* ══════════════════════
   SETTINGS
══════════════════════ */
.settings-tome { display: flex; flex-direction: column; gap: var(--s2); }

.settings-leaf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--fast);
}
.settings-leaf:focus-within { border-color: var(--border-gold); }

.settings-leaf-label { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.settings-leaf-desc  { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; font-style: italic; }

/* Toggle */
.rune-toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.rune-toggle input { opacity: 0; width: 0; height: 0; }

.rune-track {
  position: absolute;
  inset: 0;
  background: var(--surface-4);
  border: 1px solid var(--border-2);
  border-radius: 22px;
  cursor: auto;
  transition: background var(--fast), border-color var(--fast);
}

.rune-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-3);
  border-radius: 50%;
  transition: transform var(--normal) var(--spring), background var(--fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.rune-toggle input:checked + .rune-track { background: var(--teal); border-color: var(--teal-2); }
.rune-toggle input:checked + .rune-track::before { transform: translateX(18px); background: var(--parchment); }
.rune-toggle input:focus + .rune-track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ══════════════════════
   DIVIDER — ORNAMENTAL
══════════════════════ */
.ornamental-divide {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin: var(--s10) 0;
  color: var(--gold);
  opacity: 0.3;
}
.ornamental-divide::before, .ornamental-divide::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.ornamental-divide span { font-size: 0.6rem; white-space: nowrap; }

/* ══════════════════════
   ADD ROW
══════════════════════ */
.add-row { display: flex; gap: var(--s2); margin-top: var(--s3); }
.add-row .field-ink { flex: 1; }

/* ══════════════════════
   MODALS
══════════════════════ */
.modal-veil {
  position: fixed;
  inset: 0;
  background: rgba(8,7,5,0.75);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
  z-index: 1500;
  animation: veil-in var(--fast) ease both;
}

.modal-veil[hidden] { display: none; }

@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }

.modal-tome {
  background: linear-gradient(145deg, var(--void-3), var(--void-4));
  border: 1px solid var(--border-gold);
  border-radius: var(--r-xl);
  padding: var(--s10) var(--s8);
  width: 100%;
  max-width: 440px;
  position: relative;
  box-shadow: var(--shadow-xl), var(--glow-gold);
  animation: tome-rise var(--normal) var(--ease-out) both;
}

@keyframes tome-rise {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Ornamental corner on modal */
.modal-tome::before {
  content: '✦';
  position: absolute;
  top: var(--s4);
  left: var(--s5);
  color: var(--gold);
  font-size: 0.7rem;
  opacity: 0.4;
}

.tome-close {
  position: absolute;
  top: var(--s4);
  right: var(--s4);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: auto;
  transition: all var(--fast);
}
.tome-close:hover { background: var(--surface-4); color: var(--text); }

.tome-title {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s3);
}

.tome-body {
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.97rem;
  color: var(--text-2);
  line-height: var(--lh-body);
  margin-bottom: var(--s6);
}

.tome-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s6); }

/* Crisis modal */
.crisis-tome { max-width: 480px; }
.crisis-glyph { font-size: 2.5rem; text-align: center; margin-bottom: var(--s4); }

.crisis-links { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s5); }

.crisis-link {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  transition: all var(--fast);
  color: var(--text);
}

.crisis-link:hover { border-color: var(--sage); background: var(--sage-glow); text-decoration: none; }
.crisis-link > span:first-child { font-size: 1.4rem; }
.crisis-link strong { display: block; font-size: 0.88rem; color: var(--text); margin-bottom: 2px; }
.crisis-link span   { font-size: 0.75rem; color: var(--text-3); }
.crisis-note { font-size: 0.72rem; color: var(--text-3); text-align: center; font-style: italic; }

/* Distress */
.distress-tome { max-width: 380px; }
.distress-choices { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }
.distress-choice { padding: var(--s4) var(--s5); border-radius: var(--r-md); font-family: var(--body); font-size: 0.9rem; cursor: auto; transition: all var(--fast); border: 1px solid var(--border); text-align: left; color: var(--text); }
.distress-choice.crisis-choice   { background: var(--teal); border-color: var(--teal-2); font-weight: 500; }
.distress-choice.crisis-choice:hover { background: var(--teal-2); }
.distress-choice.pause-choice    { background: var(--surface-3); }
.distress-choice.pause-choice:hover { border-color: var(--border-gold); }
.distress-choice.continue-choice { background: transparent; color: var(--text-3); }
.distress-choice.continue-choice:hover { color: var(--text); }

/* ══════════════════════
   TOASTS
══════════════════════ */
.toast-stage {
  position: fixed;
  bottom: var(--s6);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - var(--s8));
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  z-index: 1800;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--void-4);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--r-md);
  font-family: var(--body);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-rise var(--normal) var(--ease-out) both;
  backdrop-filter: blur(8px);
}

.toast.success { border-color: var(--sage); }
.toast.error   { border-color: var(--crimson); }
.toast.warning { border-color: var(--gold); }

@keyframes toast-rise  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-fall  { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(6px); } }

/* ══════════════════════
   INSTALL BANNER
══════════════════════ */
.install-banner {
  position: fixed;
  bottom: var(--s5);
  left: var(--s5);
  right: var(--s5);
  max-width: 420px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--void-3), var(--void-4));
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  padding: var(--s4) var(--s5);
  box-shadow: var(--shadow-lg), var(--glow-gold);
  display: flex;
  align-items: center;
  gap: var(--s4);
  z-index: 700;
  animation: scroll-unfurl var(--slow) var(--ease-out) both;
}
.install-banner[hidden] { display: none; }
.install-icon  { font-size: 1.5rem; }
.install-text strong { display: block; font-size: 0.88rem; color: var(--text); }
.install-text span   { font-size: 0.75rem; color: var(--text-3); }
.install-actions { display: flex; gap: var(--s2); flex-shrink: 0; }



/* ══════════════════════
   SCROLLBAR
══════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); opacity: 0.5; }

/* ══════════════════════
   PRINT
══════════════════════ */


/* ══════════════════════
   HIDE DUPLICATE IN-APP FOOTER
══════════════════════ */
#app .folio-footer,
#root .folio-footer,
.library ~ .folio-footer,
.welcome ~ .folio-footer {
  display: none !important;
}

/* ══════════════════════
   FOOTER — PROFESSIONAL LYF MAIL
══════════════════════ */
.folio-footer {
  text-align: center;
  padding: var(--s10) var(--s6) var(--s8);
  border-top: 1px solid var(--border);
  margin-top: var(--s20);
  font-family: var(--fell);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}

.folio-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-2);
  text-decoration: none;
  transition: color var(--fast);
}
.folio-brand:hover {
  color: var(--gold);
  text-decoration: none;
}
.folio-brand svg {
  flex-shrink: 0;
}

.folio-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-3);
}

.folio-label {
  color: var(--text-3);
  font-style: italic;
}

.folio-links a {
  color: var(--text-2);
  text-decoration: none;
  transition: color var(--fast);
}
.folio-links a:hover {
  color: var(--gold);
}

.folio-sep {
  color: var(--border-2);
  margin: 0 var(--s1);
}

.folio-crisis-link {
  background: none;
  border: none;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: auto;
  padding: 0;
  transition: color var(--fast);
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-style: italic;
}
.folio-crisis-link:hover {
  color: var(--gold);
}
.folio-crisis-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}
@media print {
  .header, .page-folio, .install-banner, .toast-stage,
  .modal-veil, .ink-btn, .folio-footer, #bg-canvas, #cursor { display: none !important; }
  body { background: white; color: black; font-size: 11pt; cursor: auto; }
  .manuscript, .manuscript-complete { padding: 1rem; max-width: 100%; }
  .vellum, .scroll { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; background: white; }
  a { color: black; }
  @page { margin: 2cm; }
}

/* ══════════════════════
   RESPONSIVE
══════════════════════ */
@media (max-width: 520px) {
  :root { --s6: 1.2rem; --s8: 1.6rem; --s10: 2rem; --s12: 2.4rem; --s16: 3rem; --s20: 4rem; }
  .manuscript, .library { padding: var(--s8) var(--s4) var(--s16); }
  .welcome { padding: var(--s10) var(--s4) var(--s12); gap: var(--s8); }
  .welcome::before, .welcome::after { inset: var(--s4); }
  .header { padding: 0 var(--s4); }
  .vellum-grid { grid-template-columns: 1fr; }
  .page-folio { flex-wrap: wrap; }
  body { cursor: auto; }
  }

/* ══════════════════════
   ROBUSTNESS PATCHES
══════════════════════ */
.summary-entry-value,
.claim-text,
.scroll-field-value,
.declaration-folio,
.codex-name,
.guild-name {
  overflow-wrap: break-word;
  word-break: break-word;
}


/* ══════════════════════════════════════════════════════════════
   FAQ SECTION — Illuminated Manuscript Accordion
   ══════════════════════════════════════════════════════════════ */

.faq-section {
  position: relative;
  z-index: 1;
}

.faq-header {
  text-align: center;
  margin-bottom: var(--s10);
  padding-top: var(--s6);
}

.faq-title {
  font-family: var(--display);
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--s3);
  line-height: var(--lh-title);
}

.faq-subtitle {
  font-family: var(--fell);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-3);
  max-width: 400px;
  margin: 0 auto;
  line-height: var(--lh-body);
}

.faq-codex {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin-bottom: var(--s10);
}

/* Individual FAQ item */
.faq-scroll {
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--fast), box-shadow var(--fast);
  animation: scroll-unfurl var(--slow) var(--ease-out) both;
}

.faq-scroll:nth-child(1) { animation-delay: 0s; }
.faq-scroll:nth-child(2) { animation-delay: 0.08s; }
.faq-scroll:nth-child(3) { animation-delay: 0.16s; }
.faq-scroll:nth-child(4) { animation-delay: 0.24s; }
.faq-scroll:nth-child(5) { animation-delay: 0.32s; }
.faq-scroll:nth-child(6) { animation-delay: 0.40s; }
.faq-scroll:nth-child(7) { animation-delay: 0.48s; }

.faq-scroll:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-sm);
}

.faq-scroll[open] {
  border-color: var(--border-gold);
  box-shadow: var(--glow-gold);
}

/* Question (summary) */
.faq-question {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  cursor: auto;
  list-style: none;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  line-height: var(--lh-title);
  transition: background var(--fast);
  position: relative;
}

.faq-question::-webkit-details-marker { display: none; }
.faq-question::marker { display: none; }

.faq-question:hover {
  background: var(--gold-dim);
}

.faq-q-icon {
  color: var(--gold);
  font-size: 0.9rem;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--fast), transform var(--fast);
}

.faq-scroll[open] .faq-q-icon {
  opacity: 1;
  transform: rotate(45deg);
}

/* Chevron indicator */
.faq-chevron {
  margin-left: auto;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  position: relative;
  opacity: 0.5;
  transition: opacity var(--fast), transform var(--fast);
}

.faq-chevron::before,
.faq-chevron::after {
  content: '';
  position: absolute;
  background: var(--gold);
  transition: transform var(--normal) var(--spring);
}

.faq-chevron::before {
  width: 8px;
  height: 1.5px;
  top: 50%;
  left: 4px;
  transform: rotate(45deg);
}

.faq-chevron::after {
  width: 8px;
  height: 1.5px;
  top: 50%;
  right: 4px;
  transform: rotate(-45deg);
}

.faq-scroll[open] .faq-chevron {
  opacity: 1;
  transform: rotate(180deg);
}

.faq-scroll[open] .faq-chevron::before {
  transform: rotate(-45deg);
}

.faq-scroll[open] .faq-chevron::after {
  transform: rotate(45deg);
}

/* Answer content */
.faq-answer {
  padding: 0 var(--s5) var(--s5) calc(var(--s5) + var(--s3) + 0.9rem);
  border-top: 1px solid var(--border);
  margin-top: 0;
  animation: answer-unfurl var(--normal) var(--ease-out) both;
}

@keyframes answer-unfurl {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.faq-answer p {
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.98rem;
  line-height: var(--lh-body);
  color: var(--text-2);
  margin: 0;
  padding-top: var(--s3);
}

/* Focus states for accessibility */
.faq-question:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  border-radius: var(--r-md);
}

/* Responsive */
@media (max-width: 520px) {
  .faq-answer {
    padding-left: var(--s4);
  }
  .faq-question {
    font-size: 0.95rem;
    padding: var(--s3) var(--s4);
  }
}

