/* ===================================================================
   Novel Wiki — Stitch Design System
   Gold-on-black with glass-morphism, Inter + Playfair Display
   =================================================================== */

/* -- Reset & Base ------------------------------------------------------- */

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

:root {
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
  --bg:           #0b0f19;
  --bg2:          #1e293b;
  --bg3:          #334155;
  --bg4:          #475569;
  --border:       #334155;
  --border-l:     rgba(255,255,255,0.08);
  --accent:       #facc15;
  --accent-dim:   #eab308;
  --accent-glow:  rgba(250,204,21,0.10);
  --gold:         #facc15;
  --gold-dim:     #eab308;
  --gold-glow:    rgba(250,204,21,0.08);
  --text:         #94a3b8;
  --text-dim:     #64748b;
  --text-head:    #f8fafc;
  --red:          #ef4444;
  --green:        #22c55e;
  --blue:         #38bdf8;
  --purple:       #a78bfa;
  --cyan:         #22d3ee;
  --emerald:      #34d399;
  --radius:       12px;
  --radius-sm:    8px;
  --sidebar-w:    230px;
  --topbar-h:     64px;
  --transition:   0.2s ease;
  --card-shadow:  0 4px 16px rgba(0,0,0,0.25);
  --card-border:  var(--border);
  --topbar-shadow: none;
  --glass-bg:     #1e293b;
  --glass-blur:   blur(10px);
  --emerald-bg:   rgba(6,78,59,0.3);
  --emerald-text: #34d399;
  --emerald-border: rgba(6,78,59,0.5);
}

/* -- Light Theme -------------------------------------------------------- */

[data-theme="light"] {
  --bg:           #f8fafc;
  --bg2:          #ffffff;
  --bg3:          #f1f5f9;
  --bg4:          #e2e8f0;
  --border:       #e2e8f0;
  --border-l:     #cbd5e1;
  --accent:       #D4AF37;
  --accent-dim:   #b8962e;
  --accent-glow:  rgba(212,175,55,0.08);
  --gold:         #D4AF37;
  --gold-dim:     #b8962e;
  --gold-glow:    rgba(212,175,55,0.06);
  --text:         #64748b;
  --text-dim:     #94a3b8;
  --text-head:    #1e293b;
  --red:          #dc2626;
  --green:        #16a34a;
  --blue:         #0284c7;
  --purple:       #7c3aed;
  --cyan:         #0891b2;
  --emerald:      #059669;
  --card-shadow:  0 1px 3px rgba(0,0,0,0.06);
  --card-border:  var(--border);
  --topbar-shadow: 0 1px 4px rgba(0,0,0,0.06);
  --glass-bg:     rgba(255, 255, 255, 0.85);
  --glass-blur:   blur(10px);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-dim); }


/* -- Layout ------------------------------------------------------------- */

#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(11,15,25,0.80);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 24px;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--topbar-shadow);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="light"] #topbar {
  background: rgba(248,250,252,0.90);
  border-bottom-color: rgba(226,232,240,0.6);
}

.topbar-start {
  display: flex;
  align-items: center;
  min-width: 0;
}
.topbar-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

#topbar .logo {
  font-size: 1.35rem; font-weight: 800;
  color: var(--text-head);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-accent { color: var(--accent); }

#sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px 0;
  z-index: 90;
  transition: transform 0.25s ease, background 0.3s ease;
}

#main {
  margin-top: var(--topbar-h);
  margin-left: var(--sidebar-w);
  padding: 32px 44px 48px;
  max-width: 1100px;
}

.no-sidebar #sidebar { display: none; }
.no-sidebar #main {
  margin-left: auto; margin-right: auto;
  max-width: 1200px;
  padding: 48px 32px 0;
}


/* -- Footer ------------------------------------------------------------- */

#site-footer {
  margin-top: 80px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 64px 24px 32px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: 48px;
  flex-wrap: wrap;
}

.footer-brand-block { max-width: 320px; }

.footer-brand {
  font-size: 1.35rem; font-weight: 800;
  color: var(--text-head);
  margin-bottom: 16px;
}

.footer-desc {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer-links {
  display: flex; flex-wrap: wrap; gap: 32px;
  font-size: 0.85rem;
}

#site-footer a { color: var(--text-dim); }
#site-footer a:hover { color: var(--accent); transition: color var(--transition); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 32px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}


/* -- Static Pages (privacy, terms, contact, 404) ----------------------- */

.static-page { max-width: 720px; margin: 0 auto; padding: 2rem 1rem; }
.static-page h2 { margin-top: 2rem; margin-bottom: 0.75rem; }
.static-page p { line-height: 1.7; margin-bottom: 1rem; color: var(--text-dim); }
.static-page a { color: var(--accent); }
.static-page ul { padding-left: 1.5rem; margin-bottom: 1rem; }
.static-page li { margin-bottom: 0.5rem; color: var(--text-dim); }
.static-updated { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 2rem; }
.contact-email { font-size: 1.2rem; }
.contact-email a { color: var(--accent); font-weight: 600; }
.static-404 { text-align: center; padding-top: 4rem; }
.static-404 p { color: var(--text-dim); }
.static-404 a { color: var(--accent); font-weight: 600; }


/* -- Theme Toggle ------------------------------------------------------- */

.theme-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--accent);
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.05); border-color: var(--accent); }
[data-theme="light"] .theme-toggle:hover { background: var(--bg3); }
.theme-toggle svg { width: 18px; height: 18px; }
#theme-icon-moon, #theme-icon-sun { display: none; }
[data-theme="dark"] #theme-icon-moon { display: block; }
[data-theme="light"] #theme-icon-sun { display: block; }


/* -- Hamburger Menu (mobile) -------------------------------------------- */

.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  width: 28px; height: 20px;
  position: relative; flex-shrink: 0;
  padding: 0;
}
.menu-toggle span {
  display: block; position: absolute; left: 0;
  width: 100%; height: 2px;
  background: var(--text-dim); border-radius: 2px;
  transition: all 0.25s ease;
}
.menu-toggle span:nth-child(1) { top: 0; }
.menu-toggle span:nth-child(2) { top: 9px; }
.menu-toggle span:nth-child(3) { top: 18px; }
.menu-toggle.open span:nth-child(1) { top: 9px; transform: rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { top: 9px; transform: rotate(-45deg); }


/* -- Sidebar Overlay (mobile) ------------------------------------------- */

.sidebar-overlay {
  display: none;
  position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 85;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.open { opacity: 1; }


/* -- Search Bar --------------------------------------------------------- */

#search-bar {
  width: 100%;
  max-width: 640px;
  position: relative;
}

.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-dim);
  transition: color var(--transition);
}
.search-icon svg { width: 18px; height: 18px; }
#search-bar:focus-within .search-icon { color: var(--accent); }

#search-input {
  width: 100%;
  background: rgba(30,41,59,0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 14px 9px 38px;
  color: var(--text-head); font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), background var(--transition),
              box-shadow var(--transition);
}
#search-input:focus {
  border-color: transparent;
  background: rgba(30,41,59,0.7);
  box-shadow: 0 0 0 2px var(--accent);
}
#search-input::placeholder { color: var(--text-dim); }
[data-theme="light"] #search-input { background: var(--bg3); }
[data-theme="light"] #search-input:focus {
  background: var(--bg2);
  box-shadow: 0 0 0 2px var(--accent);
}


/* -- Sidebar Navigation ------------------------------------------------- */

.nav-section {
  padding: 12px 20px 4px;
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-top: 10px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--text-dim); font-size: 0.85rem; font-weight: 500;
  border-right: 3px solid transparent;
  transition: all var(--transition);
}
.nav-link:hover { background: rgba(250,204,21,0.04); color: var(--text-head); }
[data-theme="light"] .nav-link:hover { background: var(--bg3); }
.nav-link.active {
  border-right-color: var(--accent); color: var(--accent);
  background: var(--accent-glow);
  font-weight: 600;
}

.nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nav-icon svg { width: 16px; height: 16px; opacity: 0.7; }
.nav-link:hover .nav-icon svg,
.nav-link.active .nav-icon svg { opacity: 1; }


/* -- Breadcrumb --------------------------------------------------------- */

.breadcrumb {
  display: flex; align-items: center; gap: 0;
  margin-bottom: 18px;
  font-size: 0.78rem; font-weight: 500;
  flex-wrap: wrap;
}
.breadcrumb-link { color: var(--text-dim); }
.breadcrumb-link:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-dim); margin: 0 8px; font-size: 0.85rem; opacity: 0.5; }
.breadcrumb-current { color: var(--accent); }


/* -- Page Title & Subtitle ---------------------------------------------- */

.page-title {
  font-size: 1.6rem; font-weight: 700;
  color: var(--text-head);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}

.no-sidebar .page-title {
  font-size: 1.85rem;
}

.title-accent {
  display: inline-block;
  width: 4px; height: 32px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.page-subtitle {
  color: var(--text-dim); font-size: 0.82rem;
  margin-bottom: 28px;
  font-weight: 500;
}


/* -- Section Header ----------------------------------------------------- */

.section-header {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 700;
  color: var(--text-head);
  margin: 40px 0 16px;
  padding-bottom: 10px;
  position: relative;
  letter-spacing: -0.01em;
}
.section-header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--border), transparent);
  opacity: 0.4;
}
.section-header:first-of-type { margin-top: 12px; }


/* -- Card Grid ---------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 14px;
}

.no-sidebar .card-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 32px;
}

.card {
  display: block;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  color: var(--text);
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(234,179,8,0.5);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
[data-theme="light"] .card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  border-color: var(--accent);
}

.card-name {
  font-weight: 700; font-size: 1.15rem;
  color: var(--text-head); margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
  transition: color 0.3s ease;
}
.card:hover .card-name { color: var(--accent); }
.card-desc {
  font-size: 0.8rem; color: var(--text-dim); line-height: 1.55;
  margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }


/* -- Entity Type Dots --------------------------------------------------- */

.entity-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.entity-dot-blue { background: var(--blue); }
.entity-dot-purple { background: var(--purple); }
.entity-dot-green { background: var(--emerald); }
.entity-dot-gold { background: var(--gold); }
.entity-dot-accent { background: var(--accent); }
.entity-dot-red { background: var(--red); }


/* -- Browse Grid (novel home) ------------------------------------------- */

.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.browse-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 4px;
  color: var(--text);
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
}
.browse-card:hover {
  transform: translateY(-2px);
  border-color: rgba(234,179,8,0.5);
  box-shadow: 0 8px 24px rgba(0,0,0,0.30);
}
[data-theme="light"] .browse-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.browse-icon {
  margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--accent-glow);
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
  color: var(--accent);
}
.browse-icon svg { width: 20px; height: 20px; }
.browse-card:hover .browse-icon {
  background: var(--accent);
  color: var(--bg);
}

.browse-label {
  font-size: 0.92rem; font-weight: 600; color: var(--text-head);
}
.browse-desc { font-size: 0.72rem; color: var(--text-dim); font-weight: 500; }


/* -- Library Page ------------------------------------------------------- */

.library-img-wrap {
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.library-cover {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.card:hover .library-cover { transform: scale(1.05); }

.library-cover-placeholder {
  width: 100%; height: 100%;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.2rem; color: var(--text-dim); font-weight: 600;
  letter-spacing: 0.05em;
}

.library-author {
  font-size: 0.85rem; color: var(--text-dim);
  margin-bottom: 12px; font-weight: 400;
}

.library-status-wrap { padding-top: 8px; }
.library-status {
  display: inline-block;
  font-size: 0.65rem; font-weight: 700;
  padding: 4px 10px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.library-status-ongoing {
  background: rgba(11,15,25,0.8);
  color: var(--accent);
  border: 1px solid rgba(234,179,8,0.3);
}
.library-status-completed {
  background: var(--emerald-bg);
  color: var(--emerald-text);
  border: 1px solid var(--emerald-border);
}
[data-theme="light"] .library-status-ongoing {
  background: rgba(212,175,55,0.08);
  color: var(--accent);
  border-color: rgba(212,175,55,0.3);
}
[data-theme="light"] .library-status-completed {
  background: rgba(5,150,105,0.08);
  color: var(--emerald);
  border-color: rgba(5,150,105,0.3);
}


/* -- Novel Home Page ---------------------------------------------------- */

.home-cover { display: flex; gap: 28px; align-items: flex-start; margin-bottom: 24px; }

.home-cover-img {
  width: 180px; min-width: 180px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.home-cover-img-placeholder {
  width: 180px; min-width: 180px; height: 260px;
  background: var(--bg3); border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1rem; color: var(--text-dim); font-weight: 600;
}

.home-title {
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 700; color: var(--text-head);
  margin-bottom: 4px; letter-spacing: -0.02em;
}
.home-author { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 14px; font-weight: 500; }
.home-desc { color: var(--text); line-height: 1.75; font-size: 0.9rem; }

.novel-meta { margin-bottom: 12px; }
.novel-meta .chip-list { margin-bottom: 6px; }
.novel-meta .chip-list:last-child { margin-bottom: 0; }


/* -- Tag Overflow (show more/less) -------------------------------------- */

.tag-overflow { display: none; flex-wrap: wrap; gap: 6px; }
.tag-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 0.72rem; font-weight: 600;
  font-family: var(--font); padding: 3px 0;
  transition: color var(--transition);
}
.tag-toggle:hover { color: var(--accent-dim); }


/* -- Protagonist Spotlight ---------------------------------------------- */

.protagonist-card {
  display: block;
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg2) 100%);
  border: 1px solid rgba(250,204,21,0.15);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 8px;
  transition: all 0.3s ease;
  position: relative; overflow: hidden;
  color: var(--text);
}
.protagonist-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at top left, rgba(250,204,21,0.06) 0%, transparent 60%);
  pointer-events: none;
}
[data-theme="light"] .protagonist-card {
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg2) 100%);
  border-color: rgba(212,175,55,0.2);
}
[data-theme="light"] .protagonist-card::before {
  background: radial-gradient(ellipse at top left, rgba(212,175,55,0.06) 0%, transparent 60%);
}
.protagonist-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 24px rgba(250,204,21,0.10);
  transform: translateY(-2px);
}
.protagonist-card .card-name {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 700;
}
.protagonist-card .card-meta { margin-top: 8px; }
.protagonist-card .card-desc {
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
  color: var(--text);
}


/* -- Badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 0.68rem; font-weight: 600;
  padding: 2px 9px; border-radius: 12px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}
.badge-gold   { background: rgba(250,204,21,0.10); color: var(--gold);   border: 1px solid rgba(250,204,21,0.25); }
.badge-blue   { background: rgba(56,189,248,0.10); color: var(--blue);   border: 1px solid rgba(56,189,248,0.25); }
.badge-green  { background: rgba(52,211,153,0.10); color: var(--emerald); border: 1px solid rgba(52,211,153,0.25); }
.badge-red    { background: rgba(239,68,68,0.10);  color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.badge-purple { background: rgba(167,139,250,0.10); color: var(--purple); border: 1px solid rgba(167,139,250,0.25); }
.badge-gray   { background: rgba(100,116,139,0.10); color: var(--text-dim); border: 1px solid rgba(100,116,139,0.25); }

[data-theme="light"] .badge-gold   { background: rgba(212,175,55,0.08);  border-color: rgba(212,175,55,0.25); }
[data-theme="light"] .badge-blue   { background: rgba(2,132,199,0.08);   border-color: rgba(2,132,199,0.25); }
[data-theme="light"] .badge-green  { background: rgba(5,150,105,0.08);   border-color: rgba(5,150,105,0.25); }
[data-theme="light"] .badge-red    { background: rgba(220,38,38,0.08);   border-color: rgba(220,38,38,0.25); }
[data-theme="light"] .badge-purple { background: rgba(124,58,237,0.08);  border-color: rgba(124,58,237,0.25); }
[data-theme="light"] .badge-gray   { background: rgba(148,163,184,0.08); border-color: rgba(148,163,184,0.25); }


/* -- Tag Chips ---------------------------------------------------------- */

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 0.72rem; padding: 4px 12px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-weight: 400;
}
[data-theme="light"] .chip { background: var(--bg3); border-color: var(--border); }


/* -- Quote Block -------------------------------------------------------- */

.quote-block {
  border-left: 3px solid var(--accent);
  padding: 14px 22px;
  margin: 12px 0;
  background: var(--accent-glow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.quote-text {
  font-family: var(--font-display);
  font-size: 0.95rem; color: var(--text-head); font-style: italic; line-height: 1.7;
}
.quote-chapter { font-size: 0.75rem; color: var(--text-dim); margin-top: 6px; font-weight: 500; }


/* -- Info Callout ------------------------------------------------------- */

.info-callout {
  background: var(--glass-bg); border: 1px solid var(--card-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius); padding: 18px 22px;
  margin-bottom: 12px;
}
[data-theme="light"] .info-callout {
  background: var(--bg3);
  border-color: var(--border);
}
.info-callout-text { font-size: 0.88rem; color: var(--text); line-height: 1.7; }


/* -- Detail Layout (infobox + body) ------------------------------------- */

.detail-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 30px;
  align-items: start;
}

.infobox {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--card-shadow);
}
[data-theme="light"] .infobox {
  background: var(--bg2);
  border-color: var(--border);
}
.infobox-title {
  font-family: var(--font-display);
  background: rgba(250,204,21,0.06); border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  font-weight: 700; font-size: 0.9rem; color: var(--accent);
}
[data-theme="light"] .infobox-title { background: var(--bg3); }
.infobox-row {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.84rem;
}
[data-theme="light"] .infobox-row { border-bottom-color: var(--bg3); }
.infobox-row:last-child { border-bottom: none; }
.infobox-label {
  width: 100px; flex-shrink: 0;
  padding: 10px 16px;
  color: var(--text-dim); font-weight: 600; font-size: 0.78rem;
}
.infobox-value { padding: 10px 16px; color: var(--text); flex: 1; word-break: break-word; }

.detail-body { min-width: 0; }
.detail-body h2 {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 700; color: var(--text-head);
  padding-bottom: 8px; margin: 32px 0 14px;
  position: relative;
}
.detail-body h2::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--border), transparent);
  opacity: 0.3;
}
.detail-body h2:first-child { margin-top: 0; }
.detail-body p { color: var(--text); line-height: 1.75; margin-bottom: 12px; font-size: 0.9rem; }
.detail-body ul { padding-left: 20px; }
.detail-body li { margin-bottom: 8px; color: var(--text); font-size: 0.88rem; }
.rel-list li { margin-bottom: 10px; line-height: 1.5; }

.rel-context { color: var(--text-dim); font-size: 0.85em; }
.rel-chapter { color: var(--text-dim); font-size: 0.8em; }

.members-overflow { margin-top: 12px; font-size: 0.85rem; color: var(--text-dim); }


/* -- Cultivation Realm Table -------------------------------------------- */

.realm-table { width: 100%; border-collapse: collapse; margin-top: 12px; }

.realm-table th {
  text-align: left; padding: 10px 16px;
  background: rgba(250,204,21,0.04); color: var(--text-dim);
  font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .realm-table th { background: var(--bg3); }

.realm-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: top; font-size: 0.86rem;
}
[data-theme="light"] .realm-table td { border-bottom-color: var(--bg3); }
.realm-table tr:hover td { background: rgba(250,204,21,0.03); }
[data-theme="light"] .realm-table tr:hover td { background: var(--bg3); }

.realm-name {
  font-family: var(--font-display);
  font-weight: 600; color: var(--text-head);
}
.realm-alt-names { color: var(--text-dim); font-size: 0.78rem; font-style: italic; margin-top: 2px; }
.realm-stages { color: var(--text-dim); font-size: 0.78rem; margin-top: 4px; }
.realm-description { font-size: 0.85rem; color: var(--text); }


/* -- Story Arcs --------------------------------------------------------- */

.arc-card {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 10px;
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
}
[data-theme="light"] .arc-card {
  background: var(--bg2);
  border-color: var(--border);
}
.arc-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,0.20);
}
.arc-card-title {
  font-family: var(--font-display);
  font-weight: 700; color: var(--text-head); margin-bottom: 4px; font-size: 0.98rem;
}
.arc-card-ch { font-size: 0.75rem; color: var(--accent); margin-bottom: 8px; font-weight: 600; }
.arc-card-desc { font-size: 0.85rem; color: var(--text); line-height: 1.65; }

.arc-sub-label { font-size: 0.72rem; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.arc-meta { margin-top: 10px; font-size: 0.8rem; color: var(--text-dim); }
.arc-meta + .arc-meta { margin-top: 4px; }


/* -- Search Results ----------------------------------------------------- */

.search-results { margin-top: 12px; }

.search-result-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius); margin-bottom: 8px;
  box-shadow: var(--card-shadow);
  transition: all var(--transition);
}
[data-theme="light"] .search-result-item {
  background: var(--bg2);
  border-color: var(--border);
}
.search-result-item:hover { background: var(--bg3); }
.search-result-item.focused { border-color: var(--accent); background: var(--bg3); }
.search-result-type {
  font-size: 0.68rem; color: var(--text-dim); min-width: 70px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.search-result-name {
  font-weight: 600; color: var(--text-head); font-size: 0.9rem;
}
.search-result-desc { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }


/* -- Filter Bar (character list) ---------------------------------------- */

.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px; align-items: center;
}

.filter-btn {
  padding: 5px 16px; border-radius: 20px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); font-size: 0.78rem; font-weight: 500;
  font-family: var(--font); cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--accent); color: var(--text-head); }
.filter-btn.active {
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
  font-weight: 600;
}

.page-search {
  margin-left: auto;
  background: transparent; border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 14px;
  color: var(--text-head); font-size: 0.8rem; outline: none;
  font-family: var(--font); width: 180px;
  transition: all var(--transition);
}
.page-search:focus { border-color: var(--accent); background: var(--bg3); }
.page-search::placeholder { color: var(--text-dim); }


/* -- Inline Entity (thin-content expanded card) ------------------------- */

.card-inline {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--card-shadow);
  margin-bottom: 0;
}
[data-theme="light"] .card-inline {
  background: var(--bg2);
  border-color: var(--border);
}
.card-inline .card-name { margin-bottom: 6px; }
.card-inline .infobox-row { font-size: 0.8rem; }
.card-inline .infobox-label { padding: 6px 0 6px 0; width: 90px; font-size: 0.74rem; }
.card-inline .infobox-value { padding: 6px 0 6px 10px; font-size: 0.8rem; }


/* -- Empty State -------------------------------------------------------- */

.empty {
  text-align: center; padding: 48px 0;
  color: var(--text-dim); font-size: 0.88rem;
}


/* -- Scrollbar ---------------------------------------------------------- */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }


/* -- Responsive --------------------------------------------------------- */

@media (max-width: 768px) {
  .menu-toggle { display: block; }

  #sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  #sidebar.open { transform: translateX(0); }

  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar-overlay.open { pointer-events: auto; }

  #main { margin-left: 0; padding: 20px 16px; }
  #topbar { padding: 0 12px; column-gap: 10px; }
  #search-input { width: 140px; }
  #search-input:focus { width: 180px; }
  .topbar-start { gap: 10px; }

  .detail-layout { grid-template-columns: 1fr; }
  .home-cover { flex-direction: column; }
  .home-cover-img { width: 140px; min-width: 140px; }
  .browse-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .menu-toggle { display: none !important; }
  .sidebar-overlay { display: none !important; }
}
