/* public/style.css
   CommonChapter Design System: Warm Paper & Literary Archive Aesthetic
   Accessible, High-Contrast, Responsive, Calm, and Human-First.
*/

:root {
  /* Default: Warm Paper */
  --bg-page: #f9f6ef;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f3ede2;
  --bg-surface-tint: #eae1d0;
  --text-main: #2b231d;
  --text-muted: #6b5e52;
  --text-subtle: #8a7c6f;
  --border-color: #e4dbc9;
  --border-subtle: #eee6d8;
  --border-focus: #235c3e;
  
  --color-primary: #235c3e;         /* Literary Forest Green */
  --color-primary-dark: #163e29;
  --color-primary-hover: #2d734e;
  --color-primary-subtle: #eaf4ee;
  
  --color-amber: #92400e;           /* Rich Amber/Bronze */
  --color-amber-bg: #fdf5ea;
  --color-green: #2d6a4f;           /* Forest Green */
  --color-green-bg: #eaf5ef;
  --color-blue: #1d5c80;            /* Archive Blue */
  --color-blue-bg: #edf6fb;
  --color-red: #a42323;             /* Literary Red */
  --color-red-bg: #faeaea;
  --color-purple: #7b1fa2;          /* Creative Purple */
  --color-purple-bg: #f3e5f5;

  --shadow-sm: 0 1px 3px rgba(43, 35, 29, 0.05);
  --shadow-md: 0 4px 12px rgba(43, 35, 29, 0.08);
  --shadow-lg: 0 10px 25px rgba(43, 35, 29, 0.12);

  --font-serif: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --reader-font-size: 19px;
  --reader-line-height: 1.78;
  --reader-max-width: 740px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* Theme Variations */
:root[data-theme="light"], body[data-theme="light"] {
  --bg-page: #fbfbfb;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f2f2f4;
  --bg-surface-tint: #e6e6ea;
  --text-main: #18181b;
  --text-muted: #52525b;
  --text-subtle: #71717a;
  --border-color: #e4e4e7;
  --border-subtle: #f0f0f3;
  --border-focus: #1b4d3e;
  --color-primary: #1b4d3e;
  --color-primary-dark: #0f3328;
  --color-primary-hover: #266b55;
  --color-primary-subtle: #eaf4ee;
  --color-amber: #9a3412;
  --color-amber-bg: #fff7ed;
  --color-green: #15803d;
  --color-green-bg: #f0fdf4;
  --color-blue: #0369a1;
  --color-blue-bg: #f0f9ff;
  --color-red: #b91c1c;
  --color-red-bg: #fef2f2;
  --color-purple: #7e22ce;
  --color-purple-bg: #faf5ff;
}

:root[data-theme="sepia"], body[data-theme="sepia"] {
  --bg-page: #f4ecdc;
  --bg-surface: #faefe0;
  --bg-surface-alt: #ebdcc6;
  --bg-surface-tint: #e0cea6;
  --text-main: #38271a;
  --text-muted: #5e432d;
  --text-subtle: #785a3e;
  --border-color: #dcc7a8;
  --border-subtle: #e5d4bb;
  --border-focus: #1e5237;
  --color-primary: #1e5237;
  --color-primary-dark: #123624;
  --color-primary-hover: #286d49;
  --color-primary-subtle: #dceada;
  --color-amber: #92400e;
  --color-amber-bg: #faeed7;
  --color-green: #1e5237;
  --color-green-bg: #e2ede5;
  --color-blue: #1d4d6e;
  --color-blue-bg: #dde8f0;
  --color-red: #8f1d1d;
  --color-red-bg: #f5dfdf;
  --color-purple: #6b21a8;
  --color-purple-bg: #ede0f5;
}

:root[data-theme="slate"], body[data-theme="slate"] {
  --bg-page: #1a1816;
  --bg-surface: #24211e;
  --bg-surface-alt: #2f2b27;
  --bg-surface-tint: #3b3631;
  --text-main: #f0ece1;
  --text-muted: #b8b0a2;
  --text-subtle: #968e82;
  --border-color: #423d37;
  --border-subtle: #312d29;
  --border-focus: #52b788;
  --color-primary: #52b788;
  --color-primary-dark: #3a8a5e;
  --color-primary-hover: #74c69d;
  --color-primary-subtle: #1b3827;
  
  --color-amber: #fbbf24;
  --color-amber-bg: #382508;
  --color-green: #4ade80;
  --color-green-bg: #143522;
  --color-blue: #38bdf8;
  --color-blue-bg: #0c2d48;
  --color-red: #f87171;
  --color-red-bg: #3d1414;
  --color-purple: #c084fc;
  --color-purple-bg: #2d1542;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.7);
}

:root[data-theme="midnight"], body[data-theme="midnight"] {
  --bg-page: #0d0c0b;
  --bg-surface: #151312;
  --bg-surface-alt: #1e1b19;
  --bg-surface-tint: #2a2623;
  --text-main: #f3efe6;
  --text-muted: #b5ada1;
  --text-subtle: #8a8276;
  --border-color: #312c28;
  --border-subtle: #211e1b;
  --border-focus: #52b788;
  --color-primary: #52b788;
  --color-primary-dark: #3a8a5e;
  --color-primary-hover: #74c69d;
  --color-primary-subtle: #173324;
  
  --color-amber: #fcd34d;
  --color-amber-bg: #2e1d05;
  --color-green: #4ade80;
  --color-green-bg: #0f2d1c;
  --color-blue: #38bdf8;
  --color-blue-bg: #082238;
  --color-red: #f87171;
  --color-red-bg: #330d0d;
  --color-purple: #c084fc;
  --color-purple-bg: #250e38;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.9);
}

/* Inspired Themes: Harry Potter / Heated Rivalry / Avengers */

/* 1. Arcane Gryphon (Inspired by Harry Potter: Castle Stone, Gryphon Crimson & Antique Gold) */
:root[data-theme="arcane-gryphon"], body[data-theme="arcane-gryphon"] {
  --bg-page: #fbf6ec;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f3ebd7;
  --bg-surface-tint: #eae0c5;
  --text-main: #2b1810;
  --text-muted: #5e3c28;
  --text-subtle: #7a543d;
  --border-color: #e5d7ba;
  --border-subtle: #f0e6d0;
  --border-focus: #85141b;
  --color-primary: #85141b;         /* Gryphon Crimson */
  --color-primary-dark: #5c0b11;
  --color-primary-hover: #a61c25;
  --color-primary-subtle: #fae8e9;
  
  --color-amber: #8c5304;          /* Deep Castle Bronze/Gold with 5.8:1 contrast on white/cream */
  --color-amber-bg: #fdf6e7;
  --color-green: #1b5e20;
  --color-green-bg: #e8f5e9;
  --color-blue: #0d47a1;
  --color-blue-bg: #e3f2fd;
  --color-red: #85141b;
  --color-red-bg: #fae8e9;
  --color-purple: #6a1b9a;
  --color-purple-bg: #f3e5f5;

  --shadow-sm: 0 1px 3px rgba(43, 24, 16, 0.08);
  --shadow-md: 0 4px 12px rgba(43, 24, 16, 0.12);
}

/* 2. Ice & Rivalry (Inspired by Heated Rivalry: Cold Rink Glacial Ice & Jersey Crimson) */
:root[data-theme="ice-rivalry"], body[data-theme="ice-rivalry"] {
  --bg-page: #eef5fa;
  --bg-surface: #ffffff;
  --bg-surface-alt: #dfecf5;
  --bg-surface-tint: #cfe2ef;
  --text-main: #0c1a24;
  --text-muted: #2d4557;
  --text-subtle: #4c687e;
  --border-color: #c4dbe8;
  --border-subtle: #dbeaf2;
  --border-focus: #0f3d63;
  --color-primary: #0f3d63;         /* Stadium Navy */
  --color-primary-dark: #082640;
  --color-primary-hover: #195b91;
  --color-primary-subtle: #e3eff7;
  
  --color-amber: #9a3412;          /* Rich Rivalry Bronze */
  --color-amber-bg: #ffedd5;
  --color-green: #166534;
  --color-green-bg: #dcfce7;
  --color-blue: #0369a1;           /* Crisp Stadium Blue with > 6:1 contrast on ice */
  --color-blue-bg: #e0f2fe;
  --color-red: #c9182b;            /* Rivalry Crimson */
  --color-red-bg: #fae8ea;
  --color-purple: #6b21a8;
  --color-purple-bg: #f3e8ff;

  --shadow-sm: 0 1px 3px rgba(12, 26, 36, 0.06);
  --shadow-md: 0 4px 12px rgba(12, 26, 36, 0.1);
}

/* 3. Heroic Assembly (Inspired by Avengers: Titanium Armor Slate & Arc Reactor Cyan) */
:root[data-theme="heroic-titanium"], body[data-theme="heroic-titanium"] {
  --bg-page: #0f131a;
  --bg-surface: #181d26;
  --bg-surface-alt: #222836;
  --bg-surface-tint: #2c3345;
  --text-main: #edf2f7;
  --text-muted: #94a3b8;
  --text-subtle: #78889e;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --border-focus: #0284c7;
  --color-primary: #0284c7;         /* Arc Reactor Cyan */
  --color-primary-dark: #0369a1;
  --color-primary-hover: #38bdf8;
  --color-primary-subtle: #082f49;
  
  --color-amber: #facc15;          /* Energy Gold (high contrast on dark slate) */
  --color-amber-bg: #422006;
  --color-green: #34d399;          /* Arc Emerald */
  --color-green-bg: #064e3b;
  --color-blue: #38bdf8;           /* High contrast cyan */
  --color-blue-bg: #0c3352;
  --color-red: #f87171;            /* Energy Red */
  --color-red-bg: #450a0a;
  --color-purple: #c084fc;
  --color-purple-bg: #2e1065;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.8);
}

/* Base Styles & Resets */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 20px;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  z-index: 10000;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 10px;
}

/* Focus styles */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Global Utility Classes */
.hidden {
  display: none !important;
}

/* System Banner */
.system-banner {
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  font-size: 0.88rem;
  color: var(--text-main);
}
.system-banner.hidden { display: none; }
.banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-amber);
  display: inline-block;
}
.banner-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Header */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}
.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.header-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}
.brand-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.brand-text {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-primary);
}
.brand-tagline {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  font-weight: 600;
}

/* Nav */
.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-item {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.nav-item:hover, .nav-item.active {
  color: var(--color-primary);
  background: var(--bg-surface-alt);
}
.nav-item.active {
  font-weight: 600;
}

/* Navigation Dropdowns & Condensation (Themed Controls) */
.nav-dropdown-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.nav-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.16s ease;
  white-space: nowrap;
}
.nav-dropdown-btn .btn-icon {
  font-size: 0.98rem;
  line-height: 1;
}
.nav-dropdown-btn:hover,
.nav-dropdown-wrapper:hover .nav-dropdown-btn,
.nav-dropdown-wrapper.open .nav-dropdown-btn {
  color: var(--color-primary);
  background: var(--bg-surface);
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.nav-dropdown-btn.active,
.nav-dropdown-wrapper.has-active .nav-dropdown-btn {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--bg-surface-tint);
  font-weight: 700;
}
.dropdown-chevron {
  font-size: 0.7rem;
  color: var(--color-primary);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-block;
  opacity: 0.85;
}
.nav-dropdown-wrapper:hover .dropdown-chevron,
.nav-dropdown-wrapper.open .dropdown-chevron {
  transform: rotate(180deg);
}
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 3px;
  z-index: 1200;
  animation: dropdownFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Invisible hover bridge to eliminate gap flickering on mouse move */
.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
}
.nav-dropdown-wrapper:hover .nav-dropdown-menu,
.nav-dropdown-wrapper.open .nav-dropdown-menu {
  display: flex;
}
@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.14s ease;
  white-space: nowrap;
}
.nav-dropdown-item:hover,
.nav-dropdown-item.active {
  background: var(--bg-surface-alt);
  color: var(--color-primary);
  transform: translateX(3px);
}
.nav-dropdown-item.active {
  border-left: 3px solid var(--color-primary);
  font-weight: 600;
}
.nav-dropdown-item .item-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}
.nav-dropdown-item .item-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-dropdown-item .item-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: inherit;
}
.nav-dropdown-item .item-desc {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 400;
}
.nav-dropdown-item:hover .item-desc {
  color: var(--text-main);
}
.nav-item-highlight {
  background: var(--bg-surface-alt);
  color: var(--color-primary);
  font-weight: 600;
  border: 1px solid var(--border-color);
}
.staff-badge-btn {
  color: var(--color-primary);
  font-weight: 700;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
}
.archivist-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--color-primary);
  font-weight: 700;
  background: var(--bg-surface-alt);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.archivist-pill-btn:hover {
  background: var(--color-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.menu-section-header {
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  padding: 8px 12px 3px;
  margin-top: 4px;
}

.header-user-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* -------------------------------------------------------------
   HAMBURGER & TOP-RIGHT NAVIGATION MENU
   ------------------------------------------------------------- */
.nav-menu-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.hamburger-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
  user-select: none;
}

.hamburger-btn:hover,
.hamburger-btn[aria-expanded="true"] {
  border-color: var(--color-primary);
  background: var(--bg-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.hamburger-icon {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  width: 17px;
  height: 12px;
  flex-shrink: 0;
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.hamburger-label {
  font-size: 0.88rem;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header Notification Center */
.notifications-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.icon-btn-header {
  position: relative;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}
.icon-btn-header:hover {
  background: var(--bg-surface-tint);
  border-color: var(--color-primary);
}
.notifications-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  line-height: 1.2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.notifications-badge.hidden {
  display: none !important;
}
.notifications-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 8px 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  animation: menuFadeIn 0.15s ease-out;
}
.notifications-dropdown.hidden {
  display: none !important;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 10px 14px;
  border-bottom: 1px solid var(--border-color);
}
.notif-header-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.15s ease;
}
.notif-item:hover {
  background: var(--bg-surface-alt);
}
.notif-item.unread {
  background: var(--color-primary-subtle);
  border-left: 3px solid var(--color-primary);
}
.notif-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--color-primary);
}
.notif-message {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.notif-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

.hamburger-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 6px 0;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  animation: menuFadeIn 0.15s ease-out;
}

/* Slim elegant scrollbar for hamburger dropdown */
.hamburger-dropdown::-webkit-scrollbar {
  width: 5px;
}
.hamburger-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.hamburger-dropdown::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.hamburger-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

.hamburger-dropdown.hidden {
  display: none !important;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-user-header {
  padding: 8px 14px 6px;
}

.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.menu-auth-buttons {
  padding: 8px 12px 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.88rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
  box-sizing: border-box;
}

.menu-item:hover,
.menu-item:focus {
  background: var(--bg-surface-alt);
  color: var(--color-primary);
  outline: none;
}

.menu-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-item-badge {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.menu-item-danger {
  color: var(--color-danger);
}
.menu-item-danger:hover {
  background: rgba(185, 28, 28, 0.08);
  color: var(--color-danger);
}

/* Reader controls inside drop menu */
.menu-reading-panel {
  padding: 10px 14px 12px 14px;
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-reading-panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

/* Global Search Strip */
.global-search-strip {
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
}
.search-strip-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.global-search-form {
  flex: 1;
  max-width: 650px;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-subtle);
  pointer-events: none;
}
.search-input-wrap input[type="search"] {
  width: 100%;
  padding: 9px 90px 9px 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input-wrap input[type="search"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}
.btn-search {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  padding: 0 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-search:hover {
  background: var(--color-primary-dark);
}
.quick-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.84rem;
}
.quick-label {
  color: var(--text-subtle);
  font-weight: 600;
  margin-right: 2px;
}

/* Main Container */
.main-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-surface-alt);
  border-color: var(--text-subtle);
}
.btn.active-subscribed {
  background: var(--color-green-bg) !important;
  border-color: var(--color-green) !important;
  color: var(--color-green) !important;
  font-weight: 600 !important;
}
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover {
  background: var(--color-primary-subtle);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.84rem;
}
.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}
.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover {
  color: var(--color-primary-dark);
}

/* Badges & Tags */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-sans);
  border: 1px solid transparent;
}
/* Ratings */
.badge-rating-general {
  background: var(--color-green-bg);
  color: var(--color-green);
  border-color: var(--color-green);
}
.badge-rating-teen {
  background: var(--color-blue-bg);
  color: var(--color-blue);
  border-color: var(--color-blue);
}
.badge-rating-mature {
  background: var(--color-amber-bg);
  color: var(--color-amber);
  border-color: var(--color-amber);
}
.badge-rating-explicit {
  background: var(--color-red-bg);
  color: var(--color-red);
  border-color: var(--color-red);
}

/* Warnings */
.badge-warning {
  background: var(--bg-surface-tint);
  color: var(--text-muted);
  border-color: var(--border-color);
  font-weight: 600;
  text-transform: none;
}
.badge-warning.warning-major {
  background: var(--color-red-bg);
  color: var(--color-red);
  border-color: var(--color-red);
}

/* Category & Freeform Tags */
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  text-decoration: none;
  margin: 2px 3px 2px 0;
  border: 1px solid transparent;
  transition: all 0.12s ease;
}
.tag-fandom {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  font-weight: 600;
  border-color: var(--border-color);
}
.tag-fandom:hover {
  background: var(--bg-surface-tint);
}
.tag-relationship {
  background: var(--color-amber-bg);
  color: var(--color-amber);
  border-color: var(--border-color);
  font-weight: 600;
}
.tag-relationship:hover {
  background: var(--bg-surface-tint);
}
.tag-character {
  background: var(--color-blue-bg);
  color: var(--color-blue);
  border-color: var(--border-color);
}
.tag-character:hover {
  background: var(--bg-surface-tint);
}
.tag-freeform {
  background: var(--bg-surface-alt);
  color: var(--text-muted);
  border-color: var(--border-color);
}
.tag-freeform:hover {
  background: var(--bg-surface-tint);
  color: var(--text-main);
}

/* Work Cards */
.work-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.work-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.work-card a,
.work-card button,
.work-card input,
.work-card select,
.work-card textarea {
  position: relative;
  z-index: 2;
  cursor: pointer;
}
.work-card-banner {
  transition: opacity 0.15s ease;
}
.work-card:hover .work-card-banner img {
  transform: scale(1.02);
  transition: transform 0.25s ease;
}
.work-card-header {
  margin-bottom: 12px;
}
.work-card-title {
  margin: 0 0 6px 0;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  line-height: 1.3;
}
.work-card-title a {
  color: var(--color-primary);
  text-decoration: none;
}
.work-card-title a:hover {
  text-decoration: underline;
}
.work-card-byline {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.work-card-byline a {
  color: var(--text-main);
  font-weight: 600;
  text-decoration: none;
}
.work-card-byline a:hover {
  text-decoration: underline;
}
.work-card-meta-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.work-card-tags {
  margin-bottom: 14px;
  line-height: 1.8;
}
.work-card-summary {
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-surface-alt);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-color);
  margin-bottom: 16px;
}
.work-card-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 12px;
}
.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stat-item strong {
  color: var(--text-main);
}

/* Home Page Layout */
.home-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.home-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-amber), var(--color-green));
}
.hero-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  margin: 0 0 12px 0;
  color: var(--color-primary);
  line-height: 1.25;
}
.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 780px;
  margin-bottom: 24px;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text-main);
  margin: 0;
}
.section-link {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
}
.section-link:hover {
  text-decoration: underline;
}

/* Explore & Discovery Grid */
.explore-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: start;
}
.filter-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.filter-panel::-webkit-scrollbar {
  width: 6px;
}
.filter-panel::-webkit-scrollbar-track {
  background: transparent;
}
.filter-panel::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.filter-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.filter-group {
  margin-bottom: 18px;
}
.filter-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-select, .filter-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
}
.filter-select:focus, .filter-input:focus {
  border-color: var(--color-primary);
  outline: none;
}
.word-range-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
}
.word-range-inputs input {
  width: 100%;
}
.filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* Multi-select Dropdown (Content Types) */
.multiselect-group {
  position: relative;
}
.multiselect-dropdown-btn {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease;
}
.multiselect-dropdown-btn:hover {
  border-color: var(--color-primary);
}
.multiselect-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.multiselect-dropdown-btn[aria-expanded="true"] .multiselect-arrow {
  transform: rotate(180deg);
}
.multiselect-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  z-index: 100;
  margin-top: 4px;
  padding: 8px 0;
  max-height: 290px;
  overflow-y: auto;
}
.multiselect-dropdown-menu.hidden {
  display: none !important;
}
.multiselect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}
.multiselect-section-title {
  padding: 8px 12px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
  background: var(--bg-surface-tint);
  letter-spacing: 0.5px;
}
.multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.88rem;
  color: var(--text-base);
  cursor: pointer;
  transition: background 0.15s ease;
}
.multiselect-option:hover {
  background: var(--bg-surface-alt);
}
.multiselect-option input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-primary);
  transform: scale(1.1);
}

/* Reader View */
.reader-container {
  max-width: var(--reader-max-width);
  margin: 0 auto;
}
.reader-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}
.reader-title {
  font-family: var(--font-serif);
  font-size: 2.3rem;
  color: var(--color-primary);
  margin: 0 0 10px 0;
  line-height: 1.25;
}
.reader-byline {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.reader-metadata-grid {
  background: var(--bg-surface-alt);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 0.92rem;
  margin-bottom: 20px;
  border: 1px solid var(--border-subtle);
}
.reader-meta-row {
  margin-bottom: 8px;
}
.reader-meta-row:last-child {
  margin-bottom: 0;
}
.reader-meta-label {
  font-weight: 700;
  color: var(--text-muted);
  width: 130px;
  display: inline-block;
}
.reader-summary-box {
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 20px;
}

/* Reading Controls (Scrolls past naturally so mobile reading screen is 100% unobstructed) */
.reading-controls-bar {
  position: relative;
  z-index: 10;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.reading-controls-bar .control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
@media (max-width: 768px) {
  .reading-controls-bar {
    position: relative !important;
    top: auto !important;
    padding: 6px 10px;
    margin-bottom: 18px;
    gap: 8px;
  }
  .reading-controls-bar .control-label {
    display: none;
  }
  .reading-controls-bar .controls-group {
    gap: 4px;
  }
  .reading-controls-bar .theme-select {
    max-width: 125px;
    font-size: 0.82rem;
    padding: 4px 6px;
  }
  .reading-controls-bar .font-size-btn {
    padding: 3px 6px;
    font-size: 0.8rem;
  }
  .reading-controls-bar .btn-sm {
    padding: 4px 8px;
    font-size: 0.78rem;
  }
}
.controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.font-size-btn {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}
.font-size-btn:hover {
  background: var(--bg-surface-tint);
}
.theme-select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.88rem;
}

/* Chapter Reading Content */
.chapter-article {
  margin-bottom: 48px;
}
.chapter-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 28px;
  text-align: center;
}
.chapter-number-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--text-main);
  margin: 0;
}
.author-notes {
  background: var(--bg-surface-alt);
  border-left: 4px solid var(--color-primary);
  padding: 16px 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 28px 0;
  font-size: 0.96rem;
  color: var(--text-muted);
}
.author-notes strong {
  color: var(--text-main);
  display: block;
  margin-bottom: 6px;
}
.chapter-body {
  font-family: var(--font-serif);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-main);
  text-rendering: optimizeLegibility;
}
.chapter-body p {
  margin: 0 0 1.25em 0;
  text-indent: 0;
}
.chapter-body blockquote {
  border-left: 3px solid var(--border-color);
  margin: 1.5em 0;
  padding-left: 1.5em;
  color: var(--text-muted);
  font-style: italic;
}

/* Chapter Navigation Footer */
.chapter-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  margin-top: 40px;
}

/* Kudos & Social Action Bar */
.kudos-action-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin: 40px 0;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.kudos-btn {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: 30px;
  padding: 12px 28px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.kudos-btn:hover {
  background: var(--color-primary);
  color: #fff;
  transform: scale(1.04);
}
.kudos-btn.given {
  background: var(--color-green-bg);
  color: var(--color-green);
  border-color: var(--color-green);
  pointer-events: none;
}
.kudos-message {
  margin-top: 12px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* Comments Section */
.comments-section {
  margin-top: 48px;
}
.comment-form {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 32px;
}
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.form-textarea {
  min-height: 100px;
  resize: vertical;
}
.form-input:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  outline: none;
}
.comment-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 16px;
}
.comment-card.reply {
  margin-left: 36px;
  border-left: 3px solid var(--color-primary-subtle);
}
.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.comment-author {
  font-weight: 700;
  color: var(--text-main);
}
.comment-date {
  color: var(--text-subtle);
}
.comment-content {
  font-size: 0.96rem;
  line-height: 1.6;
}

/* Author Studio / Publishing */
.editor-container {
  max-width: 900px;
  margin: 0 auto;
}
.creator-rights-callout {
  background: var(--color-green-bg);
  border: 1px solid #bce0cc;
  border-radius: var(--radius-md);
  padding: 18px 24px;
  margin-bottom: 28px;
  color: #1a4d36;
}
.creator-rights-callout h3 {
  margin: 0 0 6px 0;
  font-size: 1.1rem;
}
.autosave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-subtle);
  background: var(--bg-surface-alt);
  padding: 4px 10px;
  border-radius: 20px;
}
.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-green);
}
.autosave-dot.pulsing {
  animation: pulseDot 1.5s infinite;
}
@keyframes pulseDot {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 14, 0.6);
  backdrop-filter: blur(2px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden {
  display: none;
}
.modal-content,
.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 540px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  margin: 0;
  color: var(--color-primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
  font-size: 0.92rem;
  animation: slideIn 0.25s ease;
  max-width: 360px;
}
.toast.toast-success {
  border-left-color: var(--color-green);
}
.toast.toast-error {
  border-left-color: var(--color-red);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Footer */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 48px 24px 32px;
  margin-top: 60px;
}
.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: 40px;
}
.footer-brand {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
}
.footer-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
}
.copyright-notice {
  font-size: 0.8rem;
  color: var(--text-subtle);
  line-height: 1.5;
}
.footer-column h3 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-main);
  margin: 0 0 16px 0;
}
.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-column li {
  margin-bottom: 10px;
}
.footer-column a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.footer-column a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}
.footer-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.footer-theme-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}
.footer-theme-picker select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-main);
}

/* Chapter Illustrations & Photos */
.chapter-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: block;
  margin: 24px auto;
  box-shadow: var(--shadow-sm);
}
.chapter-body figure {
  margin: 28px 0;
  text-align: center;
}
.chapter-body figcaption {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
  font-family: var(--font-sans);
}

/* Chapter Like / Heart Action Bar */
.chapter-like-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 28px 0 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-subtle);
}
.chapter-heart-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.chapter-heart-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}
.chapter-heart-btn.liked {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Fandom Hubs */
.fandom-hub-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}
.fandom-banner {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-surface-tint);
  display: block;
}
.fandom-hub-content {
  padding: 28px 32px;
}
.fandom-hub-meta-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 16px 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.fandom-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
}
.fandom-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* Author Support / Tip Jar Callout */
.support-author-callout {
  background: var(--color-green-bg);
  border: 1px solid #bce0cc;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0;
  font-size: 0.92rem;
}
.support-author-callout strong {
  color: #1a4d36;
}

/* ==========================================================================
   VIRTUAL BOOKSHELF (3D Customizable Personal Library)
   ========================================================================== */
.bookshelf-suite {
  margin: 24px 0 40px;
}
.bookshelf-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.bookshelf-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
}
.bookshelf-tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}
.bookshelf-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.bookshelf-unit {
  position: relative;
  margin-bottom: 40px;
  border-radius: 6px;
  padding: 24px 24px 0 24px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4), 0 10px 24px rgba(0, 0, 0, 0.15);
}

/* Wood Themes */
.theme-oak {
  background: linear-gradient(180deg, #c49a6c 0%, #aa7f53 100%);
  border: 10px solid #8f643b;
  border-bottom: none;
}
.theme-walnut {
  background: linear-gradient(180deg, #573e2e 0%, #3e281b 100%);
  border: 10px solid #322015;
  border-bottom: none;
}
.theme-mahogany {
  background: linear-gradient(180deg, #6c2d2c 0%, #4a1c1c 100%);
  border: 10px solid #381313;
  border-bottom: none;
}
.theme-frost {
  background: linear-gradient(180deg, #d8e8f2 0%, #b8d2e4 100%);
  border: 10px solid #7a9cb3;
  border-bottom: none;
}
.theme-titanium {
  background: linear-gradient(180deg, #252c3b 0%, #171b24 100%);
  border: 10px solid #3d475a;
  border-bottom: none;
  box-shadow: inset 0 0 35px rgba(2, 132, 199, 0.25), 0 10px 24px rgba(0, 0, 0, 0.4);
}
.theme-midnight {
  background: linear-gradient(180deg, #1c1a19 0%, #0c0b0a 100%);
  border: 10px solid #c59b27;
  border-bottom: none;
}
.theme-birch {
  background: linear-gradient(180deg, #dfcbaf 0%, #c5b093 100%);
  border: 10px solid #a89478;
  border-bottom: none;
}
.theme-pine {
  background: linear-gradient(180deg, #d8b26e 0%, #be944e 100%);
  border: 10px solid #9c7634;
  border-bottom: none;
}

.bookshelf-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.bookshelf-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bookshelf-badge {
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.bookshelf-rack {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 230px;
  overflow-x: auto;
  padding: 10px 10px 0 10px;
}

/* 3D Book Spines */
.book-spine {
  position: relative;
  width: 46px;
  height: 200px;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 10px;
  color: #f7e6c4;
  text-align: center;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  box-shadow: inset -4px 0 7px rgba(0,0,0,0.5), inset 3px 0 4px rgba(255,255,255,0.25), 2px 5px 8px rgba(0,0,0,0.35);
}
.book-spine:hover {
  transform: translateY(-16px) rotateZ(-1deg) scale(1.02);
  box-shadow: inset -4px 0 7px rgba(0,0,0,0.5), inset 3px 0 4px rgba(255,255,255,0.3), 0 16px 20px rgba(0,0,0,0.45);
  z-index: 5;
}
.book-spine.active-selected {
  transform: translateY(-22px) scale(1.05);
  outline: 2px solid #ffd700;
  z-index: 10;
}

/* Spine Colors */
.spine-forest {
  background: linear-gradient(90deg, #163826 0%, #235c3e 40%, #163826 100%);
  border-top: 3px solid #ffd700;
}
.spine-crimson {
  background: linear-gradient(90deg, #581515 0%, #852222 40%, #581515 100%);
  border-top: 3px solid #e0a96d;
}
.spine-navy {
  background: linear-gradient(90deg, #101d2d 0%, #1d3557 40%, #101d2d 100%);
  border-top: 3px solid #a8dadc;
}
.spine-amber {
  background: linear-gradient(90deg, #6c3b06 0%, #a25c11 40%, #6c3b06 100%);
  border-top: 3px solid #ffe6a7;
}
.spine-leather {
  background: linear-gradient(90deg, #382415 0%, #573922 40%, #382415 100%);
  border-top: 3px solid #d4a373;
}
.spine-plum {
  background: linear-gradient(90deg, #381235 0%, #5c2057 40%, #381235 100%);
  border-top: 3px solid #dda15e;
}

.spine-title-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-serif);
  font-size: 0.76rem;
  letter-spacing: 0.8px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  max-height: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spine-author-text {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.85;
}
.spine-ribbon {
  position: absolute;
  bottom: -6px;
  width: 10px;
  height: 14px;
  background: #a42323;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%);
}

/* Shelf Wooden Plank Bottom */
.bookshelf-ledge {
  height: 22px;
  margin: 0 -24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(0,0,0,0.3) 100%), #704825;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.5), inset 0 2px 2px rgba(255,255,255,0.4);
  border-bottom: 4px solid #4a2d13;
}
.theme-frost .bookshelf-ledge {
  background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(0,0,0,0.15) 100%), #7093aa;
  border-bottom: 4px solid #4a6c82;
}
.theme-titanium .bookshelf-ledge {
  background: linear-gradient(180deg, rgba(2,132,199,0.3) 0%, rgba(0,0,0,0.5) 100%), #1c222e;
  border-bottom: 4px solid #0284c7;
}
.theme-midnight .bookshelf-ledge {
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.6) 100%), #151312;
  border-bottom: 4px solid #c59b27;
}

/* Selected Book Inspect Drawer */
.book-inspect-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0 28px;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
}
.book-inspect-spine-preview {
  width: 38px;
  height: 130px;
  border-radius: 3px;
  box-shadow: 2px 4px 8px rgba(0,0,0,0.25);
}

/* ==========================================================================
   PARENTAL CONTROLS & RATING SAFETY
   ========================================================================== */
.safe-mode-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  transition: all 0.15s ease;
}
.safe-mode-toggle-btn:hover {
  border-color: var(--color-primary);
}
.safe-mode-toggle-btn.active-safe {
  background: var(--color-green-bg);
  color: var(--color-green);
  border-color: var(--color-green);
  box-shadow: 0 0 0 2px var(--color-green-bg);
}

.age-gate-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 32px auto;
  max-width: 620px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.age-gate-card h2 {
  font-family: var(--font-serif);
  color: var(--color-red);
  margin-bottom: 12px;
}
.age-gate-card p {
  color: var(--text-muted);
  font-size: 0.96rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ==========================================================================
   TAG SUGGESTION AUTOCOMPLETE
   ========================================================================== */
.tag-suggest-wrapper {
  position: relative;
}
.tag-suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}
.tag-suggestion-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  transition: background 0.1s ease;
}
.tag-suggestion-chip:hover {
  background: var(--bg-surface-alt);
}
.tag-suggestion-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--border-subtle);
  padding: 2px 6px;
  border-radius: 10px;
}

/* ==========================================================================
   COMMONCHAPTER CLUB & FOR-PROFIT ENTERPRISE SHOWCASE
   ========================================================================== */
.club-tier-banner {
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin: 24px 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}
.club-tier-banner h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 6px;
  color: #f7e6c4;
}
.club-tier-banner p {
  color: #e5f2eb;
  font-size: 0.92rem;
  max-width: 600px;
  line-height: 1.5;
  margin: 0;
}
.club-badge-gold {
  background: linear-gradient(135deg, #ffd700 0%, #e0a96d 100%);
  color: #382415;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-left: 8px;
}

/* Responsive Breakpoints */
@media (max-width: 860px) {
  .explore-layout {
    grid-template-columns: 1fr;
  }
  .filter-panel {
    position: static;
  }
  .footer-container {
    grid-template-columns: 1fr 1fr;
  }
  .site-nav {
    display: none;
  }
}
@media (max-width: 600px) {
  .header-container {
    padding: 10px 16px;
  }
  .hamburger-dropdown {
    width: calc(100vw - 24px);
    max-width: 310px;
    right: 0;
    max-height: calc(100dvh - 65px);
  }
  .footer-container {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------
   INTELLECTUAL PROPERTY & COMPLIANCE SYSTEM STYLES
   ------------------------------------------------------------- */
.badge-classification {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-classification-original {
  background: var(--color-blue-bg);
  color: var(--color-blue);
  border: 1px solid var(--border-color);
}
.badge-classification-fanfiction {
  background: var(--color-purple-bg);
  color: var(--color-purple);
  border: 1px solid var(--border-color);
}
.badge-classification-art {
  background: var(--color-amber-bg);
  color: var(--color-amber);
  border: 1px solid var(--border-color);
}
.badge-classification-oc {
  background: var(--color-green-bg);
  color: var(--color-green);
  border: 1px solid var(--border-color);
}
.badge-classification-collab {
  background: var(--color-purple-bg);
  color: var(--color-purple);
  border: 1px solid var(--border-color);
}
.badge-classification-other {
  background: var(--bg-surface-tint);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

/* Work Restriction Notices */
.restriction-banner {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.restriction-banner-dmca {
  background: var(--color-red-bg);
  color: var(--color-red);
  border: 2px solid var(--color-red);
}
.restriction-banner-investigation {
  background: var(--color-amber-bg);
  color: var(--color-amber);
  border: 2px solid var(--color-amber);
}
.restriction-banner-unpublished {
  background: var(--bg-surface-alt);
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
}

/* Compliance Hub & Tabs */
.compliance-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
}
.compliance-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -2px;
  white-space: nowrap;
}
.compliance-tab-btn:hover {
  color: var(--color-primary);
}
.compliance-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Plagiarism & Passage Side-by-Side Comparison */
.diff-comparison-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
@media (max-width: 760px) {
  .diff-comparison-container {
    grid-template-columns: 1fr;
  }
}
.diff-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.diff-panel-title {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 8px;
  color: var(--color-primary);
}
.diff-content {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--bg-surface-alt);
  padding: 12px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 250px;
  overflow-y: auto;
}

/* Compliance Status Cards */
.compliance-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}
.compliance-stat-number {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 4px;
}
.compliance-stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* -------------------------------------------------------------
   COMMUNITY CHATROOMS, FORUMS & DIRECT MESSAGES
   ------------------------------------------------------------- */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  min-height: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
}

.chat-sidebar {
  background: var(--bg-surface-alt);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.chat-channel-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - 250px);
}

.chat-channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-left: 3px solid transparent;
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.9rem;
}

.chat-channel-item:hover {
  background: var(--bg-surface-tint);
  color: var(--color-primary);
}

.chat-channel-item.active {
  background: var(--bg-surface);
  border-left-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}

.chat-main-pane {
  display: flex;
  flex-direction: column;
  height: 640px;
}

.chat-pane-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
}

.chat-messages-container {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chat-msg-body {
  background: var(--bg-surface-alt);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-width: 80%;
  line-height: 1.5;
  font-size: 0.92rem;
}

.chat-msg-body.own-message {
  background: var(--bg-surface-tint);
  border-color: var(--color-primary-bg);
}

.chat-composer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  background: var(--bg-surface);
}

/* Direct Messages Layout */
.dm-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  min-height: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

@media (max-width: 768px) {
  .dm-container {
    grid-template-columns: 1fr;
  }
}

.dm-conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s ease;
  display: flex;
  gap: 12px;
  align-items: center;
}

.dm-conv-item:hover {
  background: var(--bg-surface-tint);
}

.dm-conv-item.active {
  background: var(--bg-surface-tint);
  border-left: 3px solid var(--color-primary);
}

/* Beta Reader Workshop Styles */
.beta-note-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.beta-note-praise { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.beta-note-critique { background: #fbe9e7; color: #d84315; border: 1px solid #ffccbc; }
.beta-note-grammar { background: #e1f5fe; color: #0277bd; border: 1px solid #b3e5fc; }
.beta-note-suggestion { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.beta-note-plot { background: #f3e5f5; color: #7b1fa2; border: 1px solid #e1bee7; }

.beta-volunteer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

/* Inline Beta Feedback Annotations */
.beta-reader-banner {
  background: var(--bg-surface-alt);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.beta-paragraph-wrap {
  position: relative;
  margin-bottom: 1.2rem;
  transition: background-color 0.15s ease;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}
.beta-paragraph-wrap:hover {
  background-color: var(--bg-surface-alt);
}
.beta-paragraph-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.beta-paragraph-btn {
  opacity: 0.4;
  transition: opacity 0.2s ease;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.beta-paragraph-wrap:hover .beta-paragraph-btn,
.beta-paragraph-wrap.has-notes .beta-paragraph-btn {
  opacity: 1;
}
.beta-inline-notes-list {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.beta-inline-note-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 6px;
}
.beta-inline-note-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.beta-inline-note-item.resolved {
  opacity: 0.65;
}

/* AI Assisted Badges & Disclosure */
.badge-ai-assisted {
  background: var(--color-purple-bg);
  color: var(--color-purple);
  border: 1px solid var(--border-color);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-disclosure-box {
  background: var(--bg-surface-alt);
  border-left: 3px solid var(--color-purple);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Digital Bazaar Styles */
.bazaar-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}
.bazaar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.bazaar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.bazaar-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.bazaar-preview-box {
  height: 120px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-alt);
  border: 1px dashed var(--border-color);
  position: relative;
  overflow: hidden;
}
.bazaar-badge-club {
  background: linear-gradient(135deg, #ffd700, #ffb300);
  color: #4a2800;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
}
.bazaar-badge-direct {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

/* Custom Book Cover Styles */
.custom-cover-jacket {
  width: 140px;
  height: 200px;
  border-radius: 4px 10px 10px 4px;
  box-shadow: 3px 5px 15px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 12px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  border-left: 6px solid rgba(0,0,0,0.3);
  text-align: center;
  flex-shrink: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}
.custom-cover-title {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}
.custom-cover-author {
  font-size: 0.72rem;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bazaar-mini-cover {
  width: 84px;
  height: 114px;
  border-radius: 3px 6px 6px 3px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  border-left: 5px solid rgba(0,0,0,0.4);
}
.bazaar-mini-cover-title {
  font-size: 0.48rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.bazaar-mini-cover-subtitle {
  font-size: 0.44rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  opacity: 0.9;
}

/* Kindness & Courtesy Modal */
.kindness-alert-banner {
  background: var(--color-purple-bg);
  border-left: 4px solid var(--color-purple);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--color-purple);
  margin-bottom: 18px;
  line-height: 1.5;
  font-size: 0.92rem;
}

/* ========================================================= */
/* HELP WIKI & DOCUMENTATION STYLES                         */
/* ========================================================= */
.wiki-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.wiki-hero {
  text-align: center;
  margin-bottom: 32px;
  position: relative;
}
.wiki-hero-icon {
  font-size: 2.6rem;
  margin-bottom: 8px;
  display: inline-block;
}
.wiki-title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  color: var(--color-primary);
  margin: 0 0 10px;
  line-height: 1.25;
}
.wiki-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 auto 20px;
  line-height: 1.6;
}
.wiki-detected-role-banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 0.88rem;
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.wiki-detected-role-badge {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}

/* Role Selector Bar */
.wiki-role-selector-wrap {
  margin-bottom: 24px;
}
.wiki-role-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 6px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}
.wiki-role-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.wiki-role-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}
.wiki-role-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.wiki-role-count {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  background: rgba(0,0,0,0.08);
}
.wiki-role-btn.active .wiki-role-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* Wiki Search Bar */
.wiki-search-strip {
  margin-bottom: 30px;
}
.wiki-search-box {
  position: relative;
  max-width: 680px;
  margin: 0 auto;
}
.wiki-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}
.wiki-search-input {
  width: 100%;
  padding: 14px 44px 14px 48px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.wiki-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44, 95, 69, 0.15);
}
.wiki-search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* Quick Jump Pill Links */
.wiki-quick-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
  font-size: 0.85rem;
}
.wiki-jump-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}
.wiki-jump-pill:hover {
  background: var(--bg-surface-alt);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Articles Layout */
.wiki-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
  margin: 36px 0 20px;
}
.wiki-section-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--color-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wiki-section-tag {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}

.wiki-article-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.wiki-article-card:hover {
  border-color: rgba(44, 95, 69, 0.4);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.wiki-article-header {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  background: var(--bg-surface);
  user-select: none;
}
.wiki-article-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.wiki-article-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.wiki-article-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}
.wiki-article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.wiki-toggle-icon {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.wiki-article-card.expanded .wiki-toggle-icon {
  transform: rotate(180deg);
}

.wiki-article-body {
  padding: 0 22px 22px;
  color: var(--text-main);
  line-height: 1.65;
  font-size: 0.96rem;
  border-top: 1px solid var(--border-color);
}
.wiki-article-card:not(.expanded) .wiki-article-body {
  display: none;
}

/* Step list */
.wiki-steps {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wiki-step-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.wiki-step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.wiki-step-content {
  flex: 1;
}
.wiki-step-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}
.wiki-step-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
}

/* Tip & Alert Boxes */
.wiki-tip-box {
  background: var(--bg-surface-alt);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.9rem;
  line-height: 1.55;
}
.wiki-tip-box.policy {
  border-left-color: var(--color-primary);
  background: rgba(44, 95, 69, 0.05);
}
.wiki-tip-box.warning {
  border-left-color: var(--color-amber);
  background: rgba(217, 119, 6, 0.06);
}
.wiki-tip-box.club {
  border-left-color: #ffd700;
  background: rgba(255, 215, 0, 0.07);
}

/* Role Badges */
.badge-role-visitor {
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
  border: 1px solid rgba(14, 165, 233, 0.25);
}
.badge-role-reader {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.badge-role-author {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.badge-role-beta {
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(139, 92, 246, 0.25);
}
.badge-role-club {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 179, 0, 0.25));
  color: #b45309;
  border: 1px solid rgba(255, 179, 0, 0.4);
}
.badge-role-admin {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Data & Formats Table */
.wiki-table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}
.wiki-table th {
  background: var(--bg-surface-alt);
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}
.wiki-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}
.wiki-table tr:last-child td {
  border-bottom: none;
}

/* Action Strip */
.wiki-action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}
