/* GRIMOIRE THEMES v6
   Drives the REAL palette variables the site uses (--bg/--text/--dim/
   --cyan/--violet/--grad ...), the same ones the built-in magic and
   grimdark themes override. The :root aliases below point the shelf /
   sort / switcher component colors at those same variables so the whole
   UI follows the active theme. */

:root{
  --bg-deep: var(--bg); --bg-elev: var(--bg-2); --bg-card: var(--bg-3);
  --ink-primary: var(--text); --ink-secondary: var(--dim); --ink-muted: var(--faint); --ink-faint: var(--faint);
  --accent-gold: var(--cyan); --accent-gold-bright: var(--text); --accent-blood: var(--violet);
  --border-subtle: var(--line);
}
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }

:root[data-theme="blood-gold"]{
  --bg:#0e0a06; --bg-2:#15100a; --bg-3:#1b140c;
  --glass:rgba(216,182,106,0.06); --glass-2:rgba(216,182,106,0.10); --line:rgba(216,182,106,0.16); --line-2:rgba(216,182,106,0.30);
  --text:#efe4cf; --dim:#cdbfa3; --faint:#8f8266; --cyan:#d8b66a; --violet:#a52a2a; --pink:#e08a4a;
  --glow-cyan:rgba(216,182,106,0.40); --glow-violet:rgba(165,42,42,0.40);
  --grad:linear-gradient(120deg,#e8d8a8 0%,#a52a2a 100%); --grad-soft:linear-gradient(120deg,rgba(216,182,106,0.18),rgba(165,42,42,0.16));
}
:root[data-theme="blood-gold"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(216,182,106,0.10),transparent 60%),radial-gradient(60% 60% at 100% 100%,rgba(165,42,42,0.12),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="pitch"]{
  --bg:#060607; --bg-2:#0c0d0f; --bg-3:#121316;
  --glass:rgba(255,255,255,0.04); --glass-2:rgba(255,255,255,0.07); --line:rgba(255,255,255,0.10); --line-2:rgba(255,255,255,0.20);
  --text:#e9eaec; --dim:#b6b9c0; --faint:#7e828b; --cyan:#cfd2d8; --violet:#8a8f99; --pink:#b23b3b;
  --glow-cyan:rgba(207,210,216,0.20); --glow-violet:rgba(138,143,153,0.20);
  --grad:linear-gradient(120deg,#e9eaec 0%,#8a8f99 100%); --grad-soft:linear-gradient(120deg,rgba(207,210,216,0.12),rgba(138,143,153,0.10));
}
:root[data-theme="pitch"] body{ background:var(--bg); background-attachment:fixed; }

:root[data-theme="crimson-mass"]{
  --bg:#0a0405; --bg-2:#150708; --bg-3:#1d090b;
  --glass:rgba(224,72,62,0.06); --glass-2:rgba(224,72,62,0.10); --line:rgba(224,72,62,0.16); --line-2:rgba(224,72,62,0.30);
  --text:#f1dcdc; --dim:#d2a9aa; --faint:#a07779; --cyan:#e0483e; --violet:#7a1410; --pink:#ff6a5e;
  --glow-cyan:rgba(224,72,62,0.45); --glow-violet:rgba(122,20,16,0.45);
  --grad:linear-gradient(120deg,#ff6a5e 0%,#7a1410 100%); --grad-soft:linear-gradient(120deg,rgba(224,72,62,0.18),rgba(122,20,16,0.16));
}
:root[data-theme="crimson-mass"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(224,72,62,0.12),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="sepulchre"]{
  --bg:#0a0c0f; --bg-2:#11151a; --bg-3:#171c23;
  --glass:rgba(159,180,204,0.06); --glass-2:rgba(159,180,204,0.10); --line:rgba(159,180,204,0.16); --line-2:rgba(159,180,204,0.30);
  --text:#dfe6ee; --dim:#b3becb; --faint:#7f8b99; --cyan:#9fb4cc; --violet:#5d6f86; --pink:#c98a8a;
  --glow-cyan:rgba(159,180,204,0.30); --glow-violet:rgba(93,111,134,0.30);
  --grad:linear-gradient(120deg,#cfe0f0 0%,#5d6f86 100%); --grad-soft:linear-gradient(120deg,rgba(159,180,204,0.16),rgba(93,111,134,0.12));
}
:root[data-theme="sepulchre"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(159,180,204,0.08),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="eldritch"]{
  --bg:#060a08; --bg-2:#0b1310; --bg-3:#101b16;
  --glass:rgba(70,217,160,0.06); --glass-2:rgba(70,217,160,0.10); --line:rgba(70,217,160,0.16); --line-2:rgba(70,217,160,0.30);
  --text:#d8f0e2; --dim:#a6cbb6; --faint:#74927f; --cyan:#46d9a0; --violet:#7a4fd0; --pink:#ff7ad1;
  --glow-cyan:rgba(70,217,160,0.40); --glow-violet:rgba(122,79,208,0.40);
  --grad:linear-gradient(120deg,#46d9a0 0%,#7a4fd0 100%); --grad-soft:linear-gradient(120deg,rgba(70,217,160,0.18),rgba(122,79,208,0.16));
}
:root[data-theme="eldritch"] body{ background:radial-gradient(80% 60% at 10% 0%,rgba(70,217,160,0.10),transparent 60%),radial-gradient(72% 60% at 100% 100%,rgba(122,79,208,0.14),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="witchlight"]{
  --bg:#0a0712; --bg-2:#120c1e; --bg-3:#181029;
  --glass:rgba(95,211,200,0.06); --glass-2:rgba(95,211,200,0.10); --line:rgba(176,79,208,0.18); --line-2:rgba(176,79,208,0.32);
  --text:#e9e2f5; --dim:#c0b4d8; --faint:#8b7fa6; --cyan:#5fd3c8; --violet:#b04fd0; --pink:#ff8ad8;
  --glow-cyan:rgba(95,211,200,0.40); --glow-violet:rgba(176,79,208,0.40);
  --grad:linear-gradient(120deg,#5fd3c8 0%,#b04fd0 100%); --grad-soft:linear-gradient(120deg,rgba(95,211,200,0.18),rgba(176,79,208,0.16));
}
:root[data-theme="witchlight"] body{ background:radial-gradient(80% 60% at 10% 0%,rgba(95,211,200,0.10),transparent 60%),radial-gradient(72% 60% at 100% 100%,rgba(176,79,208,0.16),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="ash-ember"]{
  --bg:#0c0a09; --bg-2:#141110; --bg-3:#1c1815;
  --glass:rgba(224,144,63,0.06); --glass-2:rgba(224,144,63,0.10); --line:rgba(224,144,63,0.16); --line-2:rgba(224,144,63,0.30);
  --text:#efe7df; --dim:#cbbcae; --faint:#988a7c; --cyan:#e0903f; --violet:#9a3b1d; --pink:#ff9a5a;
  --glow-cyan:rgba(224,144,63,0.40); --glow-violet:rgba(154,59,29,0.40);
  --grad:linear-gradient(120deg,#ffb56a 0%,#9a3b1d 100%); --grad-soft:linear-gradient(120deg,rgba(224,144,63,0.18),rgba(154,59,29,0.16));
}
:root[data-theme="ash-ember"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(224,144,63,0.10),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="verdigris"]{
  --bg:#07100e; --bg-2:#0d1916; --bg-3:#13221e;
  --glass:rgba(63,174,147,0.06); --glass-2:rgba(63,174,147,0.10); --line:rgba(63,174,147,0.16); --line-2:rgba(63,174,147,0.30);
  --text:#ddeee8; --dim:#b0ccc2; --faint:#7c958c; --cyan:#3fae93; --violet:#a07a3a; --pink:#7fe6c9;
  --glow-cyan:rgba(63,174,147,0.40); --glow-violet:rgba(160,122,58,0.40);
  --grad:linear-gradient(120deg,#3fae93 0%,#a07a3a 100%); --grad-soft:linear-gradient(120deg,rgba(63,174,147,0.18),rgba(160,122,58,0.14));
}
:root[data-theme="verdigris"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(63,174,147,0.10),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="wormwood"]{
  --bg:#0a0b06; --bg-2:#12140a; --bg-3:#191c0e;
  --glass:rgba(182,196,63,0.06); --glass-2:rgba(182,196,63,0.10); --line:rgba(182,196,63,0.16); --line-2:rgba(182,196,63,0.30);
  --text:#eef0d8; --dim:#cdd1a6; --faint:#979a74; --cyan:#b6c43f; --violet:#7a6a1d; --pink:#e6f06a;
  --glow-cyan:rgba(182,196,63,0.40); --glow-violet:rgba(122,106,29,0.40);
  --grad:linear-gradient(120deg,#b6c43f 0%,#7a6a1d 100%); --grad-soft:linear-gradient(120deg,rgba(182,196,63,0.18),rgba(122,106,29,0.14));
}
:root[data-theme="wormwood"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(182,196,63,0.10),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="obsidian-glass"]{
  --bg:#04060a; --bg-2:#0a0e16; --bg-3:#0f1622;
  --glass:rgba(79,182,211,0.06); --glass-2:rgba(79,182,211,0.10); --line:rgba(79,182,211,0.16); --line-2:rgba(79,182,211,0.30);
  --text:#e3ebf5; --dim:#b2c0d4; --faint:#7e8da3; --cyan:#4fb6d3; --violet:#3a6fae; --pink:#a6ecff;
  --glow-cyan:rgba(79,182,211,0.45); --glow-violet:rgba(58,111,174,0.45);
  --grad:linear-gradient(120deg,#4fb6d3 0%,#3a6fae 100%); --grad-soft:linear-gradient(120deg,rgba(79,182,211,0.18),rgba(58,111,174,0.16));
}
:root[data-theme="obsidian-glass"] body{ background:radial-gradient(80% 60% at 10% 0%,rgba(79,182,211,0.10),transparent 60%),radial-gradient(72% 60% at 100% 100%,rgba(58,111,174,0.16),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="tyrian"]{
  --bg:#0a060c; --bg-2:#120a16; --bg-3:#190f20;
  --glass:rgba(201,143,214,0.06); --glass-2:rgba(201,143,214,0.10); --line:rgba(201,143,214,0.16); --line-2:rgba(201,143,214,0.30);
  --text:#efe6f0; --dim:#cdb9d2; --faint:#977fa0; --cyan:#c98fd6; --violet:#7e1d5a; --pink:#ecd9f0;
  --glow-cyan:rgba(201,143,214,0.40); --glow-violet:rgba(126,29,90,0.40);
  --grad:linear-gradient(120deg,#c98fd6 0%,#7e1d5a 100%); --grad-soft:linear-gradient(120deg,rgba(201,143,214,0.18),rgba(126,29,90,0.16));
}
:root[data-theme="tyrian"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(201,143,214,0.10),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="inkblot"]{
  --bg:#000000; --bg-2:#0a0a0a; --bg-3:#141414;
  --glass:rgba(255,255,255,0.05); --glass-2:rgba(255,255,255,0.09); --line:rgba(255,255,255,0.14); --line-2:rgba(255,255,255,0.26);
  --text:#ffffff; --dim:#cfcfcf; --faint:#8f8f8f; --cyan:#ffffff; --violet:#d11111; --pink:#d11111;
  --glow-cyan:rgba(255,255,255,0.20); --glow-violet:rgba(209,17,17,0.40);
  --grad:linear-gradient(120deg,#ffffff 0%,#888888 100%); --grad-soft:linear-gradient(120deg,rgba(255,255,255,0.12),rgba(136,136,136,0.10));
}
:root[data-theme="inkblot"] body{ background:var(--bg); background-attachment:fixed; }

:root[data-theme="parchment"]{
  --bg:#efe6d2; --bg-2:#e6dcc4; --bg-3:#dccfb2;
  --glass:rgba(60,50,30,0.05); --glass-2:rgba(60,50,30,0.09); --line:rgba(60,50,30,0.18); --line-2:rgba(60,50,30,0.30);
  --text:#2a241a; --dim:#4a4234; --faint:#6e6450; --cyan:#9a7b3a; --violet:#8a2b1d; --pink:#8a2b1d;
  --glow-cyan:rgba(154,123,58,0.30); --glow-violet:rgba(138,43,29,0.25);
  --grad:linear-gradient(120deg,#9a7b3a 0%,#8a2b1d 100%); --grad-soft:linear-gradient(120deg,rgba(154,123,58,0.16),rgba(138,43,29,0.12));
}
:root[data-theme="parchment"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(154,123,58,0.10),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="foxed-pages"]{
  --bg:#e9dcc2; --bg-2:#ddcdac; --bg-3:#cfbc95;
  --glass:rgba(70,55,30,0.05); --glass-2:rgba(70,55,30,0.09); --line:rgba(70,55,30,0.20); --line-2:rgba(70,55,30,0.32);
  --text:#2e2418; --dim:#4e4230; --faint:#71634a; --cyan:#8a6a2e; --violet:#8f3a22; --pink:#8f3a22;
  --glow-cyan:rgba(138,106,46,0.30); --glow-violet:rgba(143,58,34,0.25);
  --grad:linear-gradient(120deg,#8a6a2e 0%,#8f3a22 100%); --grad-soft:linear-gradient(120deg,rgba(138,106,46,0.16),rgba(143,58,34,0.12));
}
:root[data-theme="foxed-pages"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(138,106,46,0.10),transparent 60%),var(--bg); background-attachment:fixed; }

:root[data-theme="bone"]{
  --bg:#ece9e3; --bg-2:#e2ded6; --bg-3:#d4cfc4;
  --glass:rgba(40,45,55,0.05); --glass-2:rgba(40,45,55,0.09); --line:rgba(40,45,55,0.16); --line-2:rgba(40,45,55,0.28);
  --text:#23252a; --dim:#43464d; --faint:#666a72; --cyan:#5d6f86; --violet:#7a2f2f; --pink:#7a2f2f;
  --glow-cyan:rgba(93,111,134,0.30); --glow-violet:rgba(122,47,47,0.25);
  --grad:linear-gradient(120deg,#5d6f86 0%,#7a2f2f 100%); --grad-soft:linear-gradient(120deg,rgba(93,111,134,0.16),rgba(122,47,47,0.12));
}
:root[data-theme="bone"] body{ background:radial-gradient(80% 60% at 50% 0%,rgba(93,111,134,0.08),transparent 60%),var(--bg); background-attachment:fixed; }

/* ===== floating theme picker ===== */
.theme-switcher{ position:fixed; left:16px; bottom:16px; z-index:1200; }
.theme-switcher-toggle{ width:46px; height:46px; border-radius:50%; background:var(--bg-3); color:var(--text); border:1px solid var(--line-2); cursor:pointer; font-size:20px; line-height:1; box-shadow:0 6px 24px rgba(0,0,0,0.45); display:flex; align-items:center; justify-content:center; transition:transform .15s ease, border-color .15s ease; }
.theme-switcher-toggle:hover{ transform:translateY(-2px); border-color:var(--cyan); }
.theme-switcher-panel{ display:none; position:absolute; left:0; bottom:56px; width:320px; max-width:84vw; max-height:70vh; overflow:auto; background:var(--bg-2); border:1px solid var(--line); border-radius:12px; padding:14px; box-shadow:0 18px 50px rgba(0,0,0,0.55); }
.theme-switcher.open .theme-switcher-panel{ display:block; }
.theme-switcher-head{ font-family:'Cinzel',serif; font-size:11px; letter-spacing:3px; text-transform:uppercase; color:var(--faint); margin-bottom:10px; }
.theme-group-label{ font-family:'Cinzel',serif; font-size:10px; letter-spacing:2px; text-transform:uppercase; color:var(--faint); margin:12px 0 8px; }
.theme-group-label:first-of-type{ margin-top:0; }
.theme-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:8px; }
.theme-swatch{ display:flex; align-items:center; gap:9px; text-align:left; background:var(--bg-3); border:1px solid var(--line); border-radius:9px; padding:8px 9px; cursor:pointer; color:var(--dim); transition:border-color .12s ease, color .12s ease; }
.theme-swatch:hover{ color:var(--text); border-color:var(--cyan); }
.theme-swatch.active{ border-color:var(--text); color:var(--text); }
.theme-swatch-chip{ width:24px; height:24px; border-radius:6px; flex:0 0 auto; border:1px solid rgba(127,127,127,0.25); }
.theme-swatch-name{ font-family:'Cormorant Garamond',serif; font-size:15px; line-height:1.15; }
.theme-swatch-chip[data-chip="modern"]{ background:linear-gradient(135deg,#11162a 40%,#43e6ff); }
.theme-swatch-chip[data-chip="magic"]{ background:linear-gradient(135deg,#1d1533 40%,#e9c97a); }
.theme-swatch-chip[data-chip="grimdark"]{ background:linear-gradient(135deg,#19191c 40%,#b51f2a); }
.theme-swatch-chip[data-chip="blood-gold"]{ background:linear-gradient(135deg,#1b140c 40%,#d8b66a); }
.theme-swatch-chip[data-chip="pitch"]{ background:linear-gradient(135deg,#0c0d0f 40%,#cfd2d8); }
.theme-swatch-chip[data-chip="crimson-mass"]{ background:linear-gradient(135deg,#1d090b 40%,#e0483e); }
.theme-swatch-chip[data-chip="sepulchre"]{ background:linear-gradient(135deg,#171c23 40%,#9fb4cc); }
.theme-swatch-chip[data-chip="eldritch"]{ background:linear-gradient(135deg,#101b16 40%,#46d9a0); }
.theme-swatch-chip[data-chip="witchlight"]{ background:linear-gradient(135deg,#181029 40%,#b04fd0); }
.theme-swatch-chip[data-chip="ash-ember"]{ background:linear-gradient(135deg,#1c1815 40%,#e0903f); }
.theme-swatch-chip[data-chip="verdigris"]{ background:linear-gradient(135deg,#13221e 40%,#3fae93); }
.theme-swatch-chip[data-chip="wormwood"]{ background:linear-gradient(135deg,#191c0e 40%,#b6c43f); }
.theme-swatch-chip[data-chip="obsidian-glass"]{ background:linear-gradient(135deg,#0f1622 40%,#4fb6d3); }
.theme-swatch-chip[data-chip="tyrian"]{ background:linear-gradient(135deg,#190f20 40%,#c98fd6); }
.theme-swatch-chip[data-chip="inkblot"]{ background:linear-gradient(135deg,#000 40%,#fff); }
.theme-swatch-chip[data-chip="parchment"]{ background:linear-gradient(135deg,#dccfb2 40%,#8a2b1d); }
.theme-swatch-chip[data-chip="foxed-pages"]{ background:linear-gradient(135deg,#cfbc95 40%,#8f3a22); }
.theme-swatch-chip[data-chip="bone"]{ background:linear-gradient(135deg,#d4cfc4 40%,#5d6f86); }

/* ===== library sort bar ===== */
.lib-sortbar{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:0 0 20px; }
.lib-sortbar-label{ font-family:'Cinzel',serif; font-size:11px; letter-spacing:2px; text-transform:uppercase; color:var(--faint); margin-right:4px; }
.lib-sort{ font-family:'Cormorant Garamond',serif; font-size:15px; color:var(--dim); text-decoration:none; padding:5px 12px; border:1px solid var(--line); border-radius:999px; transition:color .12s, border-color .12s, background .12s; }
.lib-sort:hover{ color:var(--text); border-color:var(--cyan); }
.lib-sort.active{ color:var(--bg); background:var(--cyan); border-color:var(--cyan); }

/* ===== book shelf controls ===== */
.shelf-controls{ margin-top:14px; display:flex; flex-direction:column; gap:12px; }
.shelf-status{ display:flex; gap:6px; }
.shelf-btn{ flex:1; font-family:'Cinzel',serif; font-size:11px; letter-spacing:1px; text-transform:uppercase; color:var(--dim); background:var(--bg-3); border:1px solid var(--line); border-radius:8px; padding:9px 6px; cursor:pointer; transition:all .12s; }
.shelf-btn:hover{ color:var(--text); border-color:var(--cyan); }
.shelf-btn.active{ color:var(--bg); background:var(--cyan); border-color:var(--cyan); }
.shelf-row{ display:flex; align-items:center; gap:14px; }
.fav-btn{ font-size:24px; line-height:1; color:var(--faint); background:none; border:none; cursor:pointer; transition:color .12s, transform .12s; }
.fav-btn:hover{ transform:scale(1.1); }
.fav-btn.active{ color:var(--violet); }
.rating-stars{ display:flex; gap:2px; }
.star{ font-size:22px; line-height:1; color:var(--faint); background:none; border:none; cursor:pointer; transition:color .12s; padding:0 1px; }
.star:hover, .star.on{ color:var(--cyan); }

/* ===== shelves page ===== */
.shelves-page{ display:flex; flex-direction:column; gap:8px; }
.shelf-section{ margin-bottom:30px; }
.shelf-empty{ font-family:'Cormorant Garamond',serif; font-style:italic; color:var(--faint); padding:6px 2px 0; }

/* ===== GRIMDARK: imperial-gothic type (v7) ===== */
:root[data-theme="grimdark"] .wordmark {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    text-shadow: 0 0 18px rgba(181, 31, 42, 0.55), 0 2px 0 rgba(0, 0, 0, 0.6);
    animation: none;
    filter: none;
}
:root[data-theme="grimdark"] .nf-row-title,
:root[data-theme="grimdark"] .row-title,
:root[data-theme="grimdark"] .hero-title,
:root[data-theme="grimdark"] .book-detail-title,
:root[data-theme="grimdark"] .summon-intro,
:root[data-theme="grimdark"] .modal-title,
:root[data-theme="grimdark"] .section-title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
:root[data-theme="grimdark"] .hero-title {
    text-shadow: 0 0 26px rgba(181, 31, 42, 0.4);
}
:root[data-theme="grimdark"] .topnav-search-btn,
:root[data-theme="grimdark"] .btn,
:root[data-theme="grimdark"] .summon-btn {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.12em;
    font-weight: 600;
    text-transform: uppercase;
}
:root[data-theme="grimdark"] .topnav {
    border-bottom: 1px solid rgba(181, 31, 42, 0.28);
}
