/* ═══════════════════════════════════════════════════════════
   TWISTED FABLES - Dark Eerie Fairy Tale Theme
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://raw.githubusercontent.com/antijingoist/opendyslexic/master/compiled/OpenDyslexic-Regular.otf') format('opentype');
  font-weight: normal;
  font-display: swap;
}
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://raw.githubusercontent.com/antijingoist/opendyslexic/master/compiled/OpenDyslexic-Bold.otf') format('opentype');
  font-weight: bold;
  font-display: swap;
}
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://raw.githubusercontent.com/antijingoist/opendyslexic/master/compiled/OpenDyslexic-Italic.otf') format('opentype');
  font-style: italic;
  font-display: swap;
}

:root {
  --ink:         #0a0608;
  --parchment:   #f5ead8;
  --parchment-dark: #e8d5b5;
  --crimson:     #8b1a2b;
  --crimson-light: #c0394e;
  --bone:        #d4c5a0;
  --shadow:      #1a0f12;
  --mist:        #2d1f25;
  --gold:        #c9a84c;
  --gold-dim:    #8a6f2e;
  --thorn:       #4a2040;
  --moss:        #2a3d2f;
  --ghostwhite:  #e8e0f0;
  --slate:       #3d3545;

  --font-display: 'Cinzel Decorative', serif;
  --font-body: 'Crimson Text', serif;
  --font-text: 'IM Fell English', serif;

  --border-ornate: 1px solid rgba(201,168,76,0.3);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.6), 0 0 0 1px rgba(201,168,76,0.1);
  --shadow-glow: 0 0 20px rgba(139,26,43,0.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

/* Accessibility: font size preference. Since nearly every font-size in
   this stylesheet (and inline throughout templates) uses rem, adjusting
   the root size scales the whole site proportionally -- no need to
   touch individual rules. Default (no class) matches the browser's
   normal 16px root, i.e. "medium". */
html.font-small   { font-size: 14px; }
html.font-medium  { font-size: 16px; }
html.font-large   { font-size: 18px; }
html.font-x-large { font-size: 20px; }

/* Accessibility: dyslexia-friendly font. OpenDyslexic has heavier
   bottoms on each letter, which many dyslexic readers find easier to
   track -- applied across headers and body text alike so the whole
   site is consistent, not just the reading-heavy sections. */
body.dyslexia-font {
  --font-display: 'OpenDyslexic', 'Comic Sans MS', sans-serif;
  --font-body: 'OpenDyslexic', 'Comic Sans MS', sans-serif;
  --font-text: 'OpenDyslexic', 'Comic Sans MS', sans-serif;
}

/* Light mode: same variable names, so every rule in this file that
   already references them (headers, borders, cards, nav, text) re-themes
   automatically. Only the body's background gradient is hardcoded hex
   rather than variable-driven, so it needs its own override below. */
body.light-mode {
  --ink:         #f3ead9;
  --parchment:   #2a1f1a;
  --parchment-dark: #3a2b22;
  --crimson:     #8b1a2b;
  --crimson-light: #a3283a;
  --bone:        #5a4a3c;
  --shadow:      #ece0c8;
  --mist:        #e4d6ba;
  --gold:        #8a6a1e;
  --gold-dim:    #6b5218;
  --thorn:       #6a3f5e;
  --moss:        #3f5a45;
  --ghostwhite:  #3a3548;
  --slate:       #d8cdb8;

  --shadow-card: 0 4px 18px rgba(90,70,50,0.15), 0 0 0 1px rgba(138,106,30,0.15);
  --shadow-glow: 0 0 16px rgba(139,26,43,0.08);
}
body.light-mode {
  background-color: var(--ink);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 20% 0%, rgba(202,180,140,0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(190,205,175,0.3) 0%, transparent 50%),
    linear-gradient(180deg, #f6efe0 0%, #f1e7d4 40%, #eee2cc 100%);
}
body.light-mode .vignette-overlay {
  background: radial-gradient(ellipse at center, transparent 50%, rgba(120,100,70,0.18) 100%);
}
body.light-mode .particle-field { opacity: 0.4; }
body.light-mode .grimoire-nav {
  background: linear-gradient(180deg, rgba(246,239,224,0.98) 0%, rgba(241,231,212,0.96) 100%);
  border-bottom: 1px solid rgba(138,106,30,0.25);
  box-shadow: 0 2px 20px rgba(90,70,40,0.12);
}
body.light-mode .grimoire-card {
  background: linear-gradient(135deg, rgba(255,251,242,0.92) 0%, rgba(247,240,224,0.9) 100%);
}

/* Form fields -- this covers the search bar and every text/password/
   number/textarea/select site-wide, since they all share one rule. */
body.light-mode input[type="text"],
body.light-mode input[type="email"],
body.light-mode input[type="password"],
body.light-mode input[type="number"],
body.light-mode input[type="date"],
body.light-mode input[type="file"],
body.light-mode textarea,
body.light-mode select {
  background: rgba(255,255,255,0.6);
  color: var(--parchment);
  border-color: rgba(138,106,30,0.3);
}
body.light-mode .search-input {
  background: rgba(255,255,255,0.7);
}
body.light-mode select option { background: #f6efe0; color: var(--parchment); }

/* Tables, cards, and listing surfaces */
body.light-mode .grimoire-table th { background: rgba(138,106,30,0.08); }
body.light-mode .page-card { background: rgba(255,255,255,0.4); }

/* Threads */
body.light-mode .thread-card { background: rgba(255,255,255,0.5); }

/* Handouts */
body.light-mode .handout-item { background: rgba(255,255,255,0.5); }

/* Rich text editor */
body.light-mode .ql-toolbar { background: rgba(255,255,255,0.7) !important; border-color: rgba(138,106,30,0.25) !important; }
body.light-mode .ql-container { background: rgba(255,255,255,0.6) !important; border-color: rgba(138,106,30,0.25) !important; color: var(--parchment) !important; }
body.light-mode .ql-snow .ql-picker-options { background: #f6efe0 !important; }
body.light-mode .ql-snow .ql-stroke { stroke: var(--bone) !important; }
body.light-mode .ql-snow .ql-fill { fill: var(--bone) !important; }
body.light-mode .ql-snow .ql-picker { color: var(--bone) !important; }

/* Character/wiki infobox */
body.light-mode .wiki-infobox {
  background: linear-gradient(160deg, rgba(255,251,242,0.95) 0%, rgba(247,240,224,0.92) 100%);
}
body.light-mode .infobox-image { background: rgba(200,185,155,0.2); }
body.light-mode .img-tabs { background: rgba(200,185,155,0.15); }

/* Map */
body.light-mode #map-container,
body.light-mode .leaflet-container {
  background: #e4d6ba !important;
}
body.light-mode .leaflet-bar a {
  background: rgba(255,251,242,0.9) !important;
  color: var(--parchment) !important;
}
body.light-mode .leaflet-bar a:hover { background: rgba(255,251,242,1) !important; }
body.light-mode .control-box { background: rgba(255,251,242,0.92); }

/* Hardcoded muted-text color (the literal RGB of --bone) used directly
   instead of via var(--bone) in a number of places -- each needs its
   own override since CSS can't remap a literal color function's hue
   globally while preserving each rule's individual opacity. */
body.light-mode .search-input::placeholder { color: rgba(90,74,60,0.5); }
body.light-mode .logout-link { color: rgba(90,74,60,0.6) !important; }
body.light-mode .page-header .page-meta { color: rgba(90,74,60,0.65); }
body.light-mode .btn-ghost { border-color: rgba(138,106,30,0.3); }
body.light-mode .btn-ghost:hover { border-color: rgba(138,106,30,0.5); }
body.light-mode .form-hint { color: rgba(90,74,60,0.55); }
body.light-mode .wiki-field-value.empty { color: rgba(90,74,60,0.45); }
body.light-mode .home-subtitle { color: rgba(90,74,60,0.65); }
body.light-mode .thread-desc { color: rgba(90,74,60,0.75); }
body.light-mode .handout-sealed .handout-title { color: rgba(90,74,60,0.55); }
body.light-mode .auth-subtitle { color: rgba(90,74,60,0.65); }
body.light-mode .rich-content blockquote { color: rgba(90,74,60,0.85); }
body.light-mode .footer-text { color: rgba(90,74,60,0.5); }
body.light-mode .footer-sub { color: rgba(90,74,60,0.4); }
body.light-mode .text-muted { color: rgba(90,74,60,0.55); }
body.light-mode .infobox-empty { color: rgba(90,74,60,0.45) !important; }
body.light-mode .img-tab { color: rgba(90,74,60,0.65); }
body.light-mode .infobox-header { color: #e0bc5e; }
body.light-mode .pin-label { color: #d4c5a0 !important; }
body.light-mode .region-label { color: #d4c5a0 !important; }
body.light-mode .thread-post { background: rgba(255,255,255,0.45) !important; }
body.light-mode .thread-post-pronouns { color: rgba(90,74,60,0.6) !important; }
body.light-mode .thread-post-account { color: rgba(90,74,60,0.5) !important; }
body.light-mode .thread-post-date { color: rgba(90,74,60,0.5) !important; }
body.light-mode .thread-post-content { color: rgba(60,48,38,0.9) !important; }


/* Broad catch-all: dozens of templates set these exact literal colors
   inline (not via var()), so stylesheet variable overrides can't reach
   them. Attribute selectors + !important catch them regardless of
   which page they're on. Exact per-element opacity isn't preserved
   here (CSS can't extract it from the attribute value), but legibility
   is the point -- a slightly-off shade beats unreadable light-on-light
   or dark-on-light text. */
body.light-mode [style*="color:rgba(212,197,160"],
body.light-mode [style*="color: rgba(212,197,160"] {
  color: rgba(90,74,60,0.8) !important;
}
body.light-mode [style*="background:rgba(26,15,18"],
body.light-mode [style*="background: rgba(26,15,18"],
body.light-mode [style*="background:rgba(10,6,8"],
body.light-mode [style*="background: rgba(10,6,8"] {
  background: rgba(255,255,255,0.5) !important;
}




body {
  background-color: var(--ink);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 20% 0%, rgba(74,32,64,0.4) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(42,61,47,0.3) 0%, transparent 50%),
    linear-gradient(180deg, #0a0608 0%, #120a0e 40%, #0e0b10 100%);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
}

/* ── Vignette ── */
.vignette-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.7) 100%);
}

/* ── Particles ── */
.particle-field {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  overflow: hidden;
}
.particle {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: drift var(--dur, 8s) ease-in infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes drift {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-10vh) translateX(var(--drift, 30px)); opacity: 0; }
}

/* ══════════════════════════════════════════════
   NAVIGATION
═══════════════════════════════════════════════ */
.grimoire-nav {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(180deg, rgba(10,6,8,0.98) 0%, rgba(18,10,14,0.95) 100%);
  border-bottom: 1px solid rgba(201,168,76,0.2);
  box-shadow: 0 2px 20px rgba(0,0,0,0.8);
}
.nav-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 2rem;
  flex-wrap: nowrap;
}
.nav-brand {
  display: flex; align-items: center; gap: 0.5rem;
  text-decoration: none; color: var(--gold);
  min-width: 0; max-width: 320px; overflow: hidden;
}
.brand-title {
  font-family: var(--font-display);
  font-size: 1.1rem; letter-spacing: 0.05em;
  color : var(--gold);
  text-shadow: 0 0 12px rgba(201,168,76,0.5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.brand-sigil { font-size: 0.7rem; opacity: 0.6; }

.nav-scroll-wrap { display: flex; align-items: center; gap: 0.35rem; min-width: 0; flex: 1 1 auto; }
.nav-scroll-btn {
  flex-shrink: 0; background: none; border: 1px solid rgba(201,168,76,0.25);
  color: var(--gold); font-family: var(--font-display); font-size: 0.85rem;
  width: 22px; height: 22px; border-radius: 2px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.nav-scroll-btn:hover, .nav-scroll-btn:active { background: rgba(201,168,76,0.12); border-color: rgba(201,168,76,0.5); }
.nav-links {
  display: flex; gap: 0.25rem; flex-wrap: nowrap; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  color: var(--bone); text-decoration: none;
  font-family: var(--font-text); font-size: 0.95rem;
  padding: 0.3rem 0.8rem; border-radius: 2px;
  transition: color 0.2s, background 0.2s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--gold); background: rgba(201,168,76,0.08);
  border-color: rgba(201,168,76,0.2);
}
.nav-admin { color: var(--crimson-light) !important; }

.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--shadow); border: 1px solid rgba(201,168,76,0.3);
  border-radius: 2px; min-width: 160px; z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.nav-dropdown-menu.open { display: block; }
.nav-dropdown-menu.align-right { left: auto; right: 0; }
.nav-dropdown-menu a {
  display: block; padding: 0.6rem 1rem; font-family: var(--font-text);
  font-size: 0.85rem; color: var(--bone); text-decoration: none;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: rgba(201,168,76,0.1); color: var(--gold); }
.nav-admin:hover { color: var(--gold) !important; }

.nav-search { flex: 0 0 auto; min-width: 140px; max-width: 260px; }
.search-form { display: flex; gap: 0; }
.search-input {
  flex: 1; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(201,168,76,0.25); border-right: none;
  color: var(--parchment); font-family: var(--font-body); font-size: 0.9rem;
  padding: 0.3rem 0.7rem; border-radius: 2px 0 0 2px; outline: none;
}
.search-input::placeholder { color: rgba(212,197,160,0.4); font-style: italic; }
.search-input:focus { border-color: rgba(201,168,76,0.5); background: rgba(255,255,255,0.08); }
.search-btn {
  background: rgba(201,168,76,0.15); border: 1px solid rgba(201,168,76,0.25);
  color: var(--gold); padding: 0.3rem 0.7rem; cursor: pointer;
  border-radius: 0 2px 2px 0; transition: background 0.2s;
}
.search-btn:hover { background: rgba(201,168,76,0.25); }

.nav-user { display: flex; gap: 0.5rem; align-items: center; margin-left: auto; min-width: 0; flex-shrink: 0; }
.user-link { color: var(--gold) !important; font-style: italic; }
.logout-link { font-size: 0.85rem; color: rgba(212,197,160,0.5) !important; }
.logout-link:hover { color: var(--crimson-light) !important; }

/* ══════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════ */
.site-main {
  position: relative; z-index: 10;
  max-width: 1400px; margin: 0 auto;
  padding: 2rem;
}

/* ══════════════════════════════════════════════
   FLASH MESSAGES
═══════════════════════════════════════════════ */
.flash-container { margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1rem; border-radius: 2px;
  font-family: var(--font-text); font-size: 0.95rem;
  border-left: 3px solid;
}
.flash-success { background: rgba(42,61,47,0.5); border-color: #4a8a5a; color: #a0d4a8; }
.flash-error   { background: rgba(139,26,43,0.3); border-color: var(--crimson); color: #f4a0aa; }
.flash-info    { background: rgba(61,53,69,0.5); border-color: var(--slate); color: var(--ghostwhite); }
.flash-warning { background: rgba(138,111,46,0.3); border-color: var(--gold); color: #e8c870; }
.flash-close { margin-left: auto; background: none; border: none; color: inherit; cursor: pointer; font-size: 1.1rem; opacity: 0.6; }
.flash-close:hover { opacity: 1; }

/* ══════════════════════════════════════════════
   CARDS & PANELS
═══════════════════════════════════════════════ */
.grimoire-card {
  background: linear-gradient(135deg, rgba(26,15,18,0.95) 0%, rgba(18,10,14,0.9) 100%);
  border: var(--border-ornate);
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  padding: 2rem;
  position: relative;
}
/* Party/character card -- shared by the campaign homepage's Party
   section and the profile page's Showcase/View All Characters, so it
   always looks and sizes the same wherever it's reused. */
.rpg-party-card {
  display: flex; gap: 0.75rem; align-items: center; text-decoration: none;
  padding: 0.75rem; position: relative;
}
.rpg-party-portrait {
  width: 64px; height: 64px; object-fit: contain; background: rgba(0,0,0,0.35);
  border-radius: 2px; border: 1px solid rgba(201,168,76,0.2); flex-shrink: 0;
}
/* Smaller variant for dense grids (View All Characters modal) */
.rpg-party-card.compact { padding: 0.5rem; gap: 0.5rem; }
.rpg-party-card.compact .rpg-party-portrait { width: 44px; height: 44px; }

.grimoire-card::before {
  content: '';
  position: absolute; inset: 4px;
  border: 1px solid rgba(201,168,76,0.05);
  border-radius: 2px; pointer-events: none;
}

.card-corner {
  position: absolute;
  width: 20px; height: 20px;
  border-color: rgba(201,168,76,0.4);
  border-style: solid;
}
.card-corner.tl { top: 6px; left: 6px; border-width: 1px 0 0 1px; }
.card-corner.tr { top: 6px; right: 6px; border-width: 1px 1px 0 0; }
.card-corner.bl { bottom: 6px; left: 6px; border-width: 0 0 1px 1px; }
.card-corner.br { bottom: 6px; right: 6px; border-width: 0 1px 1px 0; }

/* ══════════════════════════════════════════════
   TYPOGRAPHY
═══════════════════════════════════════════════ */
h1, h2, h3 { font-family: var(--font-display); color: var(--gold); letter-spacing: 0.03em; }
h1 { font-size: 2rem; margin-bottom: 1rem; text-shadow: 0 0 20px rgba(201,168,76,0.3); }
h2 { font-size: 1.4rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; color: var(--bone); }
h4 { font-family: var(--font-text); color: var(--gold); font-size: 1rem; }

p { margin-bottom: 0.75rem; }
a { color: var(--gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold); }

.section-divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 1.5rem 0; color: rgba(201,168,76,0.4);
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1;
  height: 1px; background: linear-gradient(90deg, transparent, rgba(201,168,76,0.3), transparent);
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(201,168,76,0.15);
}
.page-header h1 { margin-bottom: 0.25rem; }
.page-header .page-meta {
  font-family: var(--font-text); font-size: 0.85rem;
  color: rgba(212,197,160,0.5); font-style: italic;
}

/* ══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-text); font-size: 0.95rem;
  padding: 0.5rem 1.25rem; border-radius: 2px; cursor: pointer;
  text-decoration: none; border: 1px solid;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary {
  background: rgba(139,26,43,0.6); border-color: var(--crimson);
  color: var(--parchment);
}
.btn-primary:hover {
  background: rgba(192,57,78,0.5); border-color: var(--crimson-light);
  color: var(--parchment); box-shadow: 0 0 12px rgba(139,26,43,0.4);
}
.btn-gold {
  background: rgba(201,168,76,0.15); border-color: var(--gold);
  color: var(--gold);
}
.btn-gold:hover {
  background: rgba(201,168,76,0.25); border-color: var(--gold); color: var(--gold);
  box-shadow: 0 0 10px rgba(201,168,76,0.2);
}
.btn-ghost {
  background: transparent; border-color: rgba(212,197,160,0.25);
  color: var(--bone);
}
.btn-ghost:hover { border-color: rgba(212,197,160,0.5); color: var(--parchment); }
.btn-danger {
  background: rgba(100,20,30,0.4); border-color: rgba(139,26,43,0.5);
  color: #f4a0aa;
}
.btn-danger:hover { background: rgba(139,26,43,0.5); border-color: var(--crimson); }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1.1rem; }

/* ══════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════ */
.form-group { margin-bottom: 1.25rem; }
label {
  display: block; margin-bottom: 0.35rem;
  font-family: var(--font-text); font-size: 0.9rem;
  color: var(--bone); letter-spacing: 0.02em;
}
label .required { color: var(--crimson-light); margin-left: 2px; }
label .editor-badge {
  font-size: 0.75rem; background: rgba(139,26,43,0.3);
  border: 1px solid rgba(139,26,43,0.4); color: #f4a0aa;
  padding: 1px 6px; border-radius: 2px; margin-left: 6px;
}
label .private-badge {
  font-size: 0.75rem; background: rgba(61,53,69,0.5);
  border: 1px solid rgba(61,53,69,0.7); color: var(--ghostwhite);
  padding: 1px 6px; border-radius: 2px; margin-left: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: rgba(10,6,8,0.8);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 2px;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.6rem 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(201,168,76,0.5);
  box-shadow: 0 0 8px rgba(201,168,76,0.1);
}
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--shadow); color: var(--parchment); }

.form-hint { font-size: 0.82rem; color: rgba(212,197,160,0.4); margin-top: 0.25rem; font-style: italic; }

/* ══════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════ */
.grimoire-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-body); font-size: 0.95rem;
}
.grimoire-table th {
  font-family: var(--font-text); font-size: 0.85rem; letter-spacing: 0.05em;
  color: var(--gold); text-align: left;
  padding: 0.6rem 1rem; border-bottom: 1px solid rgba(201,168,76,0.2);
  background: rgba(26,15,18,0.5);
}
.grimoire-table td {
  padding: 0.6rem 1rem; border-bottom: 1px solid rgba(201,168,76,0.08);
  color: var(--bone);
  vertical-align: top;
}
.grimoire-table tr:hover td { background: rgba(201,168,76,0.04); }

/* ══════════════════════════════════════════════
   WIKI PAGE DISPLAY
═══════════════════════════════════════════════ */
.wiki-field-section {
  margin-bottom: 1.5rem;
}
.wiki-field-label {
  font-family: var(--font-text); font-size: 0.8rem; letter-spacing: 0.08em;
  color: var(--gold); text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.wiki-field-value {
  color: var(--parchment); line-height: 1.8;
}
.wiki-field-value.empty { color: rgba(212,197,160,0.3); font-style: italic; font-size: 0.9rem; }

.field-editor-only {
  background: rgba(139,26,43,0.08);
  border-left: 2px solid rgba(139,26,43,0.3);
  padding-left: 0.75rem;
}
.field-player-private {
  background: rgba(61,53,69,0.15);
  border-left: 2px solid rgba(61,53,69,0.4);
  padding-left: 0.75rem;
}

.template-badge {
  display: inline-block;
  font-family: var(--font-text); font-size: 0.75rem; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 2px;
  border: 1px solid rgba(201,168,76,0.25); color: var(--gold);
  background: rgba(201,168,76,0.06);
}

/* ══════════════════════════════════════════════
   HOME PAGE
═══════════════════════════════════════════════ */
.home-hero {
  text-align: center; padding: 3rem 0 2rem;
}
.home-hero h1 {
  font-size: 3rem; margin-bottom: 0.5rem;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dim) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.home-subtitle {
  font-family: var(--font-text); font-size: 1.1rem;
  color: rgba(212,197,160,0.5); font-style: italic;
  margin-bottom: 2rem;
}
.home-grid {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 2rem; margin-top: 1rem;
}
.home-random {
  padding: 2rem;
}
.home-sidebar { display: flex; flex-direction: column; gap: 1.5rem; }

.recent-list { list-style: none; }
.recent-list li {
  padding: 0.5rem 0; border-bottom: 1px solid rgba(201,168,76,0.08);
  font-family: var(--font-text);
}
.recent-list li:last-child { border-bottom: none; }
.recent-list a { color: var(--bone); }
.recent-list a:hover { color: var(--gold); }
.recent-type { font-size: 0.75rem; color: var(--gold); margin-left: 0.5rem; }

/* ══════════════════════════════════════════════
   WIKI INDEX
═══════════════════════════════════════════════ */
.wiki-category {
  margin-bottom: 2rem;
}
.wiki-category h2 {
  font-size: 1.2rem; color: var(--gold);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(201,168,76,0.15);
  margin-bottom: 1rem;
}
.page-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.page-card {
  background: rgba(26,15,18,0.6);
  border: 1px solid rgba(201,168,76,0.12);
  border-radius: 2px; padding: 0.75rem 1rem;
  transition: border-color 0.2s, background 0.2s;
  text-decoration: none; color: var(--bone);
  display: block;
}
.page-card:hover {
  border-color: rgba(201,168,76,0.3);
  background: rgba(201,168,76,0.06);
  color: var(--parchment);
}
.page-card-title { font-family: var(--font-text); font-size: 0.95rem; }

/* ══════════════════════════════════════════════
   PLOT THREADS (KANBAN)
═══════════════════════════════════════════════ */
.kanban-board {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem; margin-top: 1rem;
}
.kanban-column { }
.kanban-header {
  font-family: var(--font-display); font-size: 0.9rem; letter-spacing: 0.05em;
  padding: 0.6rem 1rem; border-radius: 2px 2px 0 0;
  margin-bottom: 0.75rem;
}
.kanban-planted .kanban-header { background: rgba(61,53,69,0.6); color: #c8b8e8; }
.kanban-active  .kanban-header { background: rgba(139,26,43,0.4); color: #f4c0a0; }
.kanban-resolved .kanban-header { background: rgba(42,61,47,0.5); color: #a0d4a8; }

.thread-card {
  background: rgba(26,15,18,0.8);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 2px; padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.thread-title { font-family: var(--font-text); font-size: 0.95rem; color: var(--parchment); margin-bottom: 0.35rem; }
.thread-desc { font-size: 0.85rem; color: rgba(212,197,160,0.6); }
.thread-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* ══════════════════════════════════════════════
   HANDOUTS
═══════════════════════════════════════════════ */
.handouts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}
.handout-item {
  background: rgba(26,15,18,0.8);
  border: 1px solid rgba(201,168,76,0.12);
  border-radius: 3px; padding: 1rem;
  text-align: center; transition: border-color 0.2s;
}
.handout-item:hover { border-color: rgba(201,168,76,0.3); }
.handout-title {
  font-family: var(--font-text); font-size: 1.05rem; color: var(--parchment);
  display: inline-block; border-bottom: 2px solid var(--gold); padding-bottom: 0.25rem;
  margin-bottom: 0.4rem;
}
.handout-sealed .handout-title { color: rgba(212,197,160,0.4); font-style: italic; border-bottom-color: rgba(201,168,76,0.3); }
.handout-actions {
  margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem;
}

/* ══════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════ */
.auth-wrap {
  min-height: 80vh; display: flex; align-items: center; justify-content: center;
}
.auth-card {
  width: 100%; max-width: 440px;
}
.auth-logo {
  text-align: center; margin-bottom: 2rem;
}
.auth-logo h1 { font-size: 2rem; }
.auth-subtitle {
  font-family: var(--font-text); color: rgba(212,197,160,0.5);
  font-style: italic; font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ══════════════════════════════════════════════
   ADMIN PANEL
═══════════════════════════════════════════════ */
.admin-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.admin-section h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.permission-select {
  background: rgba(10,6,8,0.8);
  border: 1px solid rgba(201,168,76,0.2);
  color: var(--parchment); padding: 0.25rem 0.5rem;
  font-size: 0.85rem; border-radius: 2px;
}

/* ══════════════════════════════════════════════
   RICH TEXT DISPLAY
═══════════════════════════════════════════════ */
.rich-content { line-height: 1.85; }
.rich-content h2, .rich-content h3 { margin: 1rem 0 0.5rem; }
.rich-content p { margin-bottom: 0.6rem; }
.rich-content ul, .rich-content ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.rich-content blockquote {
  border-left: 2px solid var(--gold-dim);
  padding-left: 1rem; color: rgba(212,197,160,0.8);
  font-style: italic; margin: 0.75rem 0;
}
.rich-content strong { color: var(--gold); }
.rich-content em { color: var(--parchment-dark); }

/* ══════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════ */
.grimoire-footer {
  position: relative; z-index: 10;
  border-top: 1px solid rgba(201,168,76,0.1);
  margin-top: 3rem; padding: 2rem;
  text-align: center;
}
.footer-text {
  font-family: var(--font-text); font-size: 0.9rem;
  color: rgba(212,197,160,0.3); letter-spacing: 0.05em;
}
.footer-sigil { color: rgba(201,168,76,0.3); }
.footer-sub { font-size: 0.8rem; color: rgba(212,197,160,0.2); font-style: italic; margin-top: 0.25rem; }

/* ══════════════════════════════════════════════
   MISC UTILITIES
═══════════════════════════════════════════════ */
.text-gold { color: var(--gold); }
.text-muted { color: rgba(212,197,160,0.4); font-style: italic; }
.text-danger { color: #f4a0aa; }
.text-success { color: #a0d4a8; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.badge {
  display: inline-block; font-size: 0.72rem; padding: 1px 7px;
  border-radius: 2px; font-family: var(--font-text); letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-draft { background: rgba(61,53,69,0.5); color: var(--ghostwhite); border: 1px solid rgba(61,53,69,0.7); }
.badge-pending { background: rgba(138,111,46,0.3); color: #e8c870; border: 1px solid rgba(138,111,46,0.4); }
.badge-published { background: rgba(42,61,47,0.4); color: #a0d4a8; border: 1px solid rgba(42,61,47,0.6); }

/* Quill overrides */
.ql-toolbar { background: rgba(26,15,18,0.9) !important; border-color: rgba(201,168,76,0.2) !important; }
.ql-container { background: rgba(10,6,8,0.8) !important; border-color: rgba(201,168,76,0.2) !important; color: var(--parchment) !important; font-family: var(--font-body) !important; font-size: 1rem !important; }
.ql-editor { min-height: 180px; color: var(--parchment) !important; }
.ql-snow .ql-stroke { stroke: var(--bone) !important; }
.ql-snow .ql-fill { fill: var(--bone) !important; }
.ql-snow .ql-picker { color: var(--bone) !important; }
.ql-snow .ql-picker-options { background: var(--shadow) !important; }

/* Responsive */
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
  .nav-inner { flex-wrap: wrap; }
  h1 { font-size: 1.5rem; }
}
@media (max-width: 600px) {
  .site-main { padding: 1rem; }
  .nav-inner { padding: 0.5rem 1rem; }
}
@media (max-width: 700px) {
  .grimoire-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* ══════════════════════════════════════════════
   WIKI INFOBOX LAYOUT
═══════════════════════════════════════════════ */
.outdated-banner {
  background: rgba(139,26,43,0.12);
  border: 1px solid rgba(139,26,43,0.4);
  border-radius: 3px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--parchment);
  font-family: var(--font-text);
  font-size: 0.9rem;
  animation: outdated-glow 3.5s ease-in-out infinite;
}
@keyframes outdated-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(139,26,43,0.15); border-color: rgba(139,26,43,0.3); }
  50% { box-shadow: 0 0 18px rgba(139,26,43,0.55); border-color: rgba(139,26,43,0.7); }
}
.wiki-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}
.wiki-body {
  flex: 1;
  min-width: 0;
}
.wiki-infobox {
  flex-shrink: 0;
  width: 280px;
  background: linear-gradient(160deg, rgba(26,15,18,0.97) 0%, rgba(18,10,14,0.93) 100%);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  position: sticky;
  top: 80px;
}
.infobox-header {
  background: linear-gradient(135deg, rgba(74,32,64,0.8), rgba(139,26,43,0.5));
  border-bottom: 1px solid rgba(201,168,76,0.25);
  padding: 0.6rem 0.9rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold);
  text-align: center;
  letter-spacing: 0.04em;
}
.infobox-image {
  border-bottom: 1px solid rgba(201,168,76,0.15);
  background: rgba(0,0,0,0.3);
}
.infobox-image img {
  max-height: 320px;
  object-fit: cover;
  width: 100%;
}
.infobox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.infobox-table th {
  padding: 0.45rem 0.75rem;
  font-family: var(--font-text);
  font-size: 0.78rem;
  font-weight: normal;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-align: left;
  background: rgba(201,168,76,0.04);
  border-bottom: 1px solid rgba(201,168,76,0.07);
  border-right: 1px solid rgba(201,168,76,0.1);
  width: 42%;
  vertical-align: top;
  padding-top: 0.55rem;
}
.infobox-table td {
  padding: 0.45rem 0.75rem;
  color: var(--parchment);
  border-bottom: 1px solid rgba(201,168,76,0.07);
  vertical-align: top;
  line-height: 1.5;
}
.infobox-table tr:last-child th,
.infobox-table tr:last-child td { border-bottom: none; }
.infobox-table tr:hover td,
.infobox-table tr:hover th { background: rgba(201,168,76,0.03); }
.infobox-empty {
  color: rgba(212,197,160,0.3) !important;
  font-style: italic;
}
@media (max-width: 860px) {
  .wiki-layout { flex-direction: column-reverse; }
  .wiki-infobox { width: 100%; position: static; }
}
/* Infobox image tabs */
.img-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid rgba(201,168,76,0.2);
  background: rgba(0,0,0,0.2);
}
.img-tab {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(201,168,76,0.15);
  color: rgba(212,197,160,0.5);
  cursor: pointer;
  font-family: var(--font-text);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.75rem;
  transition: color 0.2s, background 0.2s;
}
.img-tab:hover { color: var(--bone); background: rgba(201,168,76,0.06); }
.img-tab.active { color: var(--gold); background: rgba(201,168,76,0.1); border-bottom: 2px solid var(--gold); }

.brand-title { color: var(--gold) !important; }
.user-link { color: var(--gold) !important; }
.home-random h2 span, 
[style*="FROM THE ARCHIVES"] { color: var(--gold) !important; }

/* ══════════════════════════════════════════════
   QUILL CONTENT DISPLAY
═══════════════════════════════════════════════ */
.rich-content ol, .rich-content ul {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}
.rich-content li { margin: 0.25rem 0; }
.rich-content .ql-indent-1 { padding-left: 2rem; }
.rich-content .ql-indent-2 { padding-left: 4rem; }
.rich-content .ql-indent-3 { padding-left: 6rem; }
.rich-content .ql-indent-4 { padding-left: 8rem; }
.rich-content .ql-indent-5 { padding-left: 10rem; }
.rich-content li.ql-indent-1 { list-style-type: circle; }
.rich-content li.ql-indent-2 { list-style-type: square; }
.rich-content li.ql-indent-3 { list-style-type: disc; }
.rich-content ol li.ql-indent-1 { list-style-type: lower-alpha; }
.rich-content ol li.ql-indent-2 { list-style-type: lower-roman; }

// ── Wiki-style [[Page Name]] link resolution ──────────────────────────────
document.querySelectorAll('.rich-content').forEach(el => {
  el.innerHTML = el.innerHTML.replace(
    /\[\[([^\]]+)\]\]/g,
    (match, name) => {
      const slug = name.trim().toLowerCase()
        .replace(/[^a-z0-9]+/g, '-')
        .replace(/^-|-$/g, '');
      return `<a href="/wiki/${slug}" class="wiki-link">${name.trim()}</a>`;
    }
  );
});

.wiki-link {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: rgba(201,168,76,0.4);
}
.wiki-link:hover {
  color: var(--parchment);
  text-decoration-color: var(--gold);
}

/* Shared collapsible <details>/<summary> base -- hides the native
   disclosure marker so pages can style their own summary content
   instead. Reused by DM Screen's Character Ownership box and Calendar
   moon editors. */
.collapsible-section summary {
  cursor: pointer;
  list-style: none;
}
.collapsible-section summary::-webkit-details-marker { display: none; }

/* Global Templates library pagination */
.template-pagination { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.template-page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border: 1px solid rgba(201,168,76,0.25); border-radius: 2px;
  font-family: var(--font-text); font-size: 0.85rem;
  color: var(--bone); text-decoration: none;
}
.template-page-link:hover { border-color: var(--gold); color: var(--gold); }
.template-page-link.active { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.1); }
.template-page-gap { color: rgba(212,197,160,0.4); font-size: 0.85rem; }
.template-page-jump { cursor: pointer; padding: 0 4px; }
.template-page-jump:hover { color: var(--gold); }
body.light-mode .template-page-link { color: rgba(90,74,60,0.8); border-color: rgba(138,106,30,0.25); }
body.light-mode .template-page-link.active { background: rgba(138,106,30,0.1); }
body.light-mode .template-page-gap { color: rgba(90,74,60,0.4); }
