/* =========================================================
   Aline Masiosare — profile styles
   Palette: indigo night · sand gold · purple · warm parchment
   ========================================================= */

:root {
  --bg-deep: #0b0e1a;
  --bg-panel: #12172a;
  --bg-panel-2: #1a2038;
  --bg-soft: #222a45;
  --border: #3d4a6b;
  --border-gold: #c9a227;
  --gold: #e0b84a;
  --gold-dim: #a8842e;
  --purple: #9b6bff;
  --purple-soft: #c4a8ff;
  --purple-hair: #7a3d8c;
  --text: #f0e6d3;
  --text-muted: #a89b88;
  --text-dim: #6f6558;
  --danger: #c45c5c;
  --danger-bg: #2a1518;
  /* Dual personality bars: left trait + right trait (both always visible) */
  --slider-left: #9b6bff;   /* closer to label on the left */
  --slider-right: #e0b84a;  /* closer to label on the right */
  --slider-track: #2a3148;  /* fallback underlay */
  --slider-fill: var(--slider-left);
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font-body: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --max: 920px;

  /* POV / character accents (diary margins + optional themes) */
  --pov-aline: #9b6bff;
  --pov-susule: #e8e4dc; /* platinum / hair color — swap when you decide */
  --pov-lihua: #f0a0b8;  /* soft rose-pink royalty — try white #f5f0f0 if preferred */
  --susule-accent: #c45c5c; /* scarf / warm note against pale hair */
  --lihua-gold: #e8d5a3;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(155, 107, 255, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(201, 162, 39, 0.08), transparent 50%),
    var(--bg-deep);
  line-height: 1.65;
  /* page content sits above .bg-fx layers */
  position: relative;
  z-index: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--purple-soft);
  text-decoration: none;
}

a:hover {
  color: var(--gold);
  text-decoration: underline;
}

/* ---------- layout shell ---------- */

.page {
  /* sits above fixed .bg-fx layers */
  position: relative;
  z-index: 1;
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

/* decorative corner frame (Wigi-inspired, simpler) */
.frame {
  position: relative;
  background: linear-gradient(180deg, var(--bg-panel) 0%, #0f1324 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(201, 162, 39, 0.12), transparent 30%),
    linear-gradient(225deg, rgba(155, 107, 255, 0.08), transparent 35%);
  pointer-events: none;
}

/* =========================================================
   Liquid glass — character profile pages only (body.glass-ui)
   Diary keeps solid panels. Backgrounds (stars / sakura /
   Susule metal) show through the frosted panels.
   ========================================================= */

body.glass-ui {
  /* How strong the tint is (lower = more background shows) */
  --glass-tint: rgba(18, 23, 42, 0.40);
  --glass-tint-2: rgba(26, 32, 56, 0.30);
  --glass-edge: rgba(255, 255, 255, 0.10);
  --glass-edge-soft: rgba(255, 255, 255, 0.08);
  --glass-blur: 4px;
  --glass-saturate: 1.35;
}

/* Main info shell */
body.glass-ui .frame {
  --mx: 50%;
  --my: 30%;
  --spot-size: 100px;
  background: var(--glass-tint);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-edge);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

/* Soft sheen on top of glass (keeps character tint) */
body.glass-ui .frame::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 42%),
    linear-gradient(225deg, color-mix(in srgb, var(--purple) 18%, transparent), transparent 40%),
    linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.12) 100%);
  z-index: 0;
}

/*
 * Cursor spotlight — only a region around the mouse lights up.
 * --mx / --my set by js/main.js (pointermove).
 */
body.glass-ui .frame::after,
body.glass-ui .portrait-card::after,
body.glass-ui .motif-card::after,
body.glass-ui .rel-card::after,
body.glass-ui .note-box::after,
body.glass-ui .chapter-card::after,
body.glass-ui .market-card::after,
body.glass-ui .social-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: radial-gradient(
    var(--spot-size, 100px) circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.28) 0%,
    color-mix(in srgb, var(--purple) 22%, transparent) 28%,
    transparent 62%
  );
  mix-blend-mode: soft-light;
}

body.glass-ui .frame.is-spot-active::after,
body.glass-ui .portrait-card.is-spot-active::after,
body.glass-ui .motif-card.is-spot-active::after,
body.glass-ui .rel-card.is-spot-active::after,
body.glass-ui .note-box.is-spot-active::after,
body.glass-ui .chapter-card.is-spot-active::after,
body.glass-ui .market-card.is-spot-active::after,
body.glass-ui .social-card.is-spot-active::after {
  opacity: 1;
}

/* Diary cards: spotlight tint follows POV */
body.glass-ui .chapter-card.pov-aline {
  --spot-accent: var(--pov-aline);
}
body.glass-ui .chapter-card.pov-susule {
  --spot-accent: var(--pov-susule);
}
body.glass-ui .chapter-card.pov-lihua {
  --spot-accent: var(--pov-lihua);
}
body.glass-ui .chapter-card.pov-tess {
  --spot-accent: #6dbf8a;
}
body.glass-ui .chapter-card.pov-neon {
  --spot-accent: #00f0ff;
}
body.glass-ui .chapter-card.pov-sofa {
  --spot-accent: #c4a35a;
}

body.glass-ui .chapter-card.pov-aline::after,
body.glass-ui .chapter-card.pov-susule::after,
body.glass-ui .chapter-card.pov-lihua::after,
body.glass-ui .chapter-card.pov-tess::after,
body.glass-ui .chapter-card.pov-neon::after {
  background: radial-gradient(
    var(--spot-size, 100px) circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.32) 0%,
    color-mix(in srgb, var(--spot-accent, var(--purple)) 35%, transparent) 30%,
    transparent 62%
  );
}

body.glass-ui .frame-inner {
  z-index: 1;
}

body.glass-ui .corner {
  z-index: 2;
}

/* Nested cards — lighter glass so layers stay readable */
body.glass-ui .portrait-card,
body.glass-ui .motif-card,
body.glass-ui .rel-card,
body.glass-ui .note-box,
body.glass-ui .chapter-card,
body.glass-ui .market-card,
body.glass-ui .social-card {
  --mx: 50%;
  --my: 50%;
  --spot-size: 100px;
  position: relative;
  overflow: hidden;
  background: var(--glass-tint-2);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-color: var(--glass-edge-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Keep POV left margin on diary cards even with glass */
body.glass-ui .chapter-card.pov-aline {
  border-left-color: var(--pov-aline);
  border-left-width: 5px;
}
body.glass-ui .chapter-card.pov-susule {
  border-left-color: var(--pov-susule);
  border-left-width: 5px;
}
body.glass-ui .chapter-card.pov-lihua {
  border-left-color: var(--pov-lihua);
  border-left-width: 5px;
}
body.glass-ui .chapter-card.pov-tess {
  border-left-color: #6dbf8a;
  border-left-width: 5px;
}
body.glass-ui .chapter-card.pov-neon {
  border-left-color: #00f0ff;
  border-left-width: 5px;
}
body.glass-ui .chapter-card.pov-sofa {
  border-left-width: 6px;
}

/* Chapter reading pages: prose sits on glass shell already (.frame) */
body.glass-ui .chapter-banner {
  border-color: var(--glass-edge-soft);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}

/* No full-panel brighten — spotlight only (see ::after + JS) */
@media (prefers-reduced-motion: reduce) {
  body.glass-ui .frame::after,
  body.glass-ui .portrait-card::after,
  body.glass-ui .motif-card::after,
  body.glass-ui .rel-card::after,
  body.glass-ui .note-box::after,
  body.glass-ui .chapter-card::after,
  body.glass-ui .market-card::after,
  body.glass-ui .social-card::after {
    display: none;
  }
}

body.glass-ui .portrait-card figcaption {
  background: rgba(0, 0, 0, 0.2);
  border-top-color: var(--glass-edge-soft);
}

body.glass-ui .tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.glass-ui .tabs {
  border-bottom-color: var(--glass-edge-soft);
}

body.glass-ui .section {
  border-top-color: var(--glass-edge-soft);
}

body.glass-ui .fact-table th,
body.glass-ui .fact-table td {
  border-bottom-color: var(--glass-edge-soft);
}

/* Keep dual trait colors on glass pages (don't wash the right side out) */
body.glass-ui .slider-track {
  background: var(--slider-right);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

body.glass-ui .tag {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--glass-edge-soft);
}

body.glass-ui .cw {
  background: rgba(42, 21, 24, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* If blur unsupported, keep a readable solid-ish fallback */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.glass-ui .frame {
    background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
  }
  body.glass-ui .portrait-card,
  body.glass-ui .motif-card,
  body.glass-ui .rel-card,
  body.glass-ui .note-box,
  body.glass-ui .chapter-card,
  body.glass-ui .market-card,
  body.glass-ui .social-card {
    background: color-mix(in srgb, var(--bg-panel-2) 90%, transparent);
  }
}

/* Chapter pages: glass tint follows POV when no full theme class */
body.chapter-page.pov-aline.glass-ui {
  --glass-tint: rgba(12, 16, 32, 0.5);
  --glass-tint-2: rgba(20, 26, 48, 0.4);
  --glass-edge: rgba(196, 168, 255, 0.2);
  --glass-edge-soft: rgba(196, 168, 255, 0.1);
}

body.chapter-page.pov-susule.glass-ui {
  --glass-tint: rgba(36, 38, 48, 0.5);
  --glass-tint-2: rgba(48, 50, 60, 0.42);
  --glass-edge: rgba(230, 232, 240, 0.28);
  --glass-edge-soft: rgba(230, 232, 240, 0.12);
  /* soft static platinum behind the story */
  background-color: #1c1d24;
  background-image:
    linear-gradient(
      118deg,
      transparent 0%,
      transparent 40%,
      rgba(255, 255, 255, 0.06) 50%,
      transparent 60%
    ),
    linear-gradient(
      155deg,
      #14151a 0%,
      #3a3c48 30%,
      #9a9eac 48%,
      #3e404a 70%,
      #12131a 100%
    );
  background-attachment: fixed;
}

body.chapter-page.pov-lihua.glass-ui,
body.theme-lihua.chapter-page.glass-ui {
  --glass-tint: rgba(255, 248, 252, 0.28);
  --glass-tint-2: rgba(255, 252, 254, 0.20);
  --glass-edge: rgba(255, 140, 180, 0.4);
  --glass-edge-soft: rgba(255, 160, 190, 0.25);
  --glass-blur: 3px;
  --purple: #ff8fb3;
  --text: #5c2a3d;
  --text-muted: #8a4a62;
  --text-dim: #b07088;
  --gold: #d4a84b;
  background:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(255, 200, 220, 0.65), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(255, 230, 240, 0.8), transparent 50%),
    linear-gradient(165deg, #ffe4ee 0%, #ffc8dc 45%, #ffb3d0 100%);
}

.frame-inner {
  position: relative;
  padding: 1.75rem 1.5rem 2rem;
}

@media (min-width: 700px) {
  .frame-inner {
    padding: 2.25rem 2.5rem 2.75rem;
  }
}

.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--gold-dim);
  border-style: solid;
  opacity: 0.85;
  z-index: 2;
  pointer-events: none;
}

.corner-tl { top: 10px; left: 10px; border-width: 2px 0 0 2px; }
.corner-tr { top: 10px; right: 10px; border-width: 2px 2px 0 0; }
.corner-bl { bottom: 10px; left: 10px; border-width: 0 0 2px 2px; }
.corner-br { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }

/* ---------- header ---------- */

.site-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.site-header .eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin: 0 0 0.5rem;
}

.char-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  margin: 0;
  color: var(--text);
  letter-spacing: 0.02em;
}

.char-title {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 1.05rem;
  color: var(--gold);
  font-style: italic;
}

.char-title::before { content: "« "; color: var(--gold-dim); }
.char-title::after { content: " »"; color: var(--gold-dim); }

.hero-quote {
  margin: 1.25rem auto 0;
  max-width: 28rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--purple-soft);
  line-height: 1.5;
}

.hero-quote cite {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---------- content warning ---------- */

.cw {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  background: var(--danger-bg);
  border: 1px solid rgba(196, 92, 92, 0.45);
  border-radius: 8px;
  font-size: 0.9rem;
  color: #e8c4c4;
}

.cw strong {
  color: #ffb4b4;
  display: block;
  margin-bottom: 0.35rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 1.5rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
}

.tab-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.tab-btn[aria-selected="true"] {
  color: var(--bg-deep);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- overview grid ---------- */

.overview-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 720px) {
  .overview-grid {
    grid-template-columns: 1fr 1.15fr;
    align-items: start;
  }
}

.portrait-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.portrait-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top center;
  background: #000;
}

.portrait-card figcaption {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

.fact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.fact-table th,
.fact-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.fact-table th {
  width: 38%;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fact-table td {
  color: var(--text);
}

.fact-table tr:last-child th,
.fact-table tr:last-child td {
  border-bottom: none;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--purple-soft);
  background: rgba(155, 107, 255, 0.08);
}

/* ---------- gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.gallery a {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s;
}

.gallery a:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  text-decoration: none;
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* ---------- sections ---------- */

.section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.section h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 400;
  margin: 0 0 1rem;
  color: var(--gold);
}

.section h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--purple-soft);
  letter-spacing: 0.03em;
}

.section p {
  margin: 0 0 1rem;
  color: var(--text);
}

.section p:last-child {
  margin-bottom: 0;
}

.lede {
  font-size: 1.05rem;
  color: var(--text-muted);
}

/* ---------- personality sliders (dual color: both traits marked) ---------- */

.slider-list {
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
}

@media (min-width: 560px) {
  .slider-row {
    grid-template-columns: 5.5rem 1fr 5.5rem;
    align-items: center;
    gap: 0.65rem;
  }
}

.slider-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: color 0.15s ease, font-weight 0.15s ease;
}

/* Left label color = left bar; right label = right bar */
.slider-label:not(.right) {
  color: color-mix(in srgb, var(--slider-left) 75%, var(--text-muted));
}

.slider-label.right {
  text-align: left;
  color: color-mix(in srgb, var(--slider-right) 75%, var(--text-muted));
}

@media (min-width: 560px) {
  .slider-label.right {
    text-align: right;
  }
}

/*
 * Full bar always shows two traits:
 *   LEFT  = --slider-left  (width from .slider-fill)
 *   RIGHT = --slider-right (remainder of the track)
 * A small thumb sits on the split so you see “where she leans.”
 */
.slider-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--slider-right);
  overflow: visible; /* thumb can sit on the edge */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.slider-fill {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: 999px 0 0 999px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--slider-left) 85%, #000) 0%,
    var(--slider-left) 100%
  );
  min-width: 0;
  max-width: 100%;
}

/* When fill is nearly full, round the right side too */
.slider-fill[style*="width: 100%"],
.slider-fill[style*="width:100%"] {
  border-radius: 999px;
}

/* Split marker — “this is how far toward the left trait” */
.slider-fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-right: -7px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--slider-left);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--slider-right) 70%, transparent),
    0 1px 4px rgba(0, 0, 0, 0.35);
  z-index: 1;
}

/* Tiny left-edge / right-edge hints when one side is very small */
.slider-track::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.slider-pct {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.35rem;
}

@media (min-width: 560px) {
  .slider-pct {
    display: none;
  }
}

/* Optional legend under a slider block */
.slider-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slider-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.slider-legend i {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  font-style: normal;
}

.slider-legend .swatch-left {
  background: var(--slider-left);
}

.slider-legend .swatch-right {
  background: var(--slider-right);
}

/* ---------- motifs ---------- */

.motif-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .motif-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.motif-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1rem;
}

.motif-card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--gold);
}

.motif-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* ---------- relationships ---------- */

.rel-list {
  display: grid;
  gap: 1.25rem;
}

.rel-card {
  display: grid;
  gap: 1rem;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

@media (min-width: 560px) {
  .rel-card.has-portrait {
    grid-template-columns: 120px 1fr;
    align-items: start;
  }
}

.rel-card img {
  width: 100%;
  max-width: 120px;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 0 auto;
}

.rel-card h3 {
  margin: 0 0 0.2rem;
  color: var(--gold);
  font-size: 1.1rem;
}

.rel-role {
  font-size: 0.8rem;
  color: var(--purple-soft);
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rel-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ---------- extra / mature note ---------- */

.note-box {
  background: var(--bg-panel-2);
  border-left: 3px solid var(--purple);
  padding: 1rem 1.15rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.note-box strong {
  color: var(--text);
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--text-muted);
}

/* ---------- print / a11y ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tab-panel.is-active { animation: none; }
}

/* =========================================================
   Site nav (shared across pages)
   ========================================================= */

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  justify-content: center;
  margin: 0 0 1.25rem;
  padding: 0.5rem 0;
}

.site-nav a {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--bg-soft);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--bg-deep);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 600;
}

/* =========================================================
   Diary — chapter cards
   ========================================================= */

.diary-intro {
  text-align: center;
  max-width: 36rem;
  margin: 0 auto 1.75rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.chapter-list {
  display: grid;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  /* POV margin — left bar */
  border-left-width: 5px;
  border-left-style: solid;
  border-left-color: var(--pov-aline);
  cursor: pointer;
}

.chapter-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

.chapter-card.pov-aline { border-left-color: var(--pov-aline); }
.chapter-card.pov-susule { border-left-color: var(--pov-susule); box-shadow: inset 5px 0 0 rgba(196, 92, 92, 0.35); }
.chapter-card.pov-lihua { border-left-color: var(--pov-lihua); }
.chapter-card.pov-tess { border-left-color: #6dbf8a; }
.chapter-card.pov-neon { border-left-color: #00f0ff; box-shadow: inset 5px 0 0 rgba(255, 43, 214, 0.45); }

/* Ensemble / Cozy Sofa — rainbow cast stripe on the left */
.chapter-card.pov-sofa {
  border-left-color: #c4a35a;
  border-left-width: 6px;
  position: relative;
}

.chapter-card.pov-sofa::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  z-index: 5;
  pointer-events: none;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(
    180deg,
    #9b6bff 0%,
    #c8c4bc 18%,
    #ff8fb3 36%,
    #6dbf8a 54%,
    #00f0ff 72%,
    #c4a35a 100%
  );
}

/* Placeholder thumbs when a character has no portrait yet */
.chapter-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  background: #1a2030;
}

.chapter-thumb--tess {
  background:
    radial-gradient(ellipse 70% 50% at 50% 80%, rgba(80, 140, 100, 0.55), transparent 60%),
    linear-gradient(165deg, #0f1a14 0%, #1a2e24 50%, #24382e 100%);
  color: #9ed9b4;
}

.chapter-thumb--neon {
  background:
    radial-gradient(ellipse 50% 40% at 30% 40%, rgba(0, 240, 255, 0.25), transparent 55%),
    radial-gradient(ellipse 45% 40% at 75% 60%, rgba(255, 43, 214, 0.22), transparent 50%),
    linear-gradient(165deg, #05040f 0%, #12102a 100%);
  color: #00f0ff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.chapter-thumb--sofa {
  background:
    radial-gradient(ellipse 50% 40% at 20% 30%, rgba(155, 107, 255, 0.2), transparent 50%),
    radial-gradient(ellipse 40% 35% at 80% 70%, rgba(255, 143, 179, 0.2), transparent 50%),
    linear-gradient(165deg, #fff9f2 0%, #f0e0d0 50%, #e8d5b8 100%);
  color: #7a6b5c;
}

.chapter-banner--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  max-height: 280px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 1rem 0 1.25rem;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chapter-meta .pov-pill + .pov-pill {
  margin-left: 0;
}

.chapter-meta--cast {
  gap: 0.35rem;
}

@media (min-width: 560px) {
  .chapter-card {
    grid-template-columns: 140px 1fr;
  }
}

.chapter-card .chapter-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #000;
}

@media (min-width: 560px) {
  .chapter-card .chapter-thumb {
    aspect-ratio: auto;
    height: 100%;
    min-height: 120px;
  }
}

.chapter-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/*
 * POV pills — fixed high-contrast colors so they stay readable on
 * Cozy Sofa cream, Lihua pink glass, Susule metal, etc.
 * Use: <span class="pov-pill pov-aline">Aline</span>
 * Diary cards also inherit via .chapter-card.pov-* .
 */
.pov-pill,
.chapter-meta .pov-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.12);
}

/* Aline — deep indigo + soft lavender text */
.pov-pill.pov-aline,
.chapter-card.pov-aline .pov-pill {
  background: #2a1848;
  border-color: #9b6bff;
  color: #f0e6ff;
}

/* Susule — dark metal + platinum text */
.pov-pill.pov-susule,
.chapter-card.pov-susule .pov-pill {
  background: #1e2028;
  border-color: #c8c4bc;
  color: #f2f2f6;
}

/* Lihua — deep rose + near-white (fixes unreadable pale-on-pink) */
.pov-pill.pov-lihua,
.chapter-card.pov-lihua .pov-pill {
  background: #5a1830;
  border-color: #ff8fb3;
  color: #fff8fb;
}

/* Neon OC — for diary cards later */
.pov-pill.pov-neon,
.chapter-card.pov-neon .pov-pill {
  background: #0a0618;
  border-color: #ff2bd6;
  color: #e8f7ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.65);
}

/* Tess — forest dark + mint text */
.pov-pill.pov-tess,
.chapter-card.pov-tess .pov-pill {
  background: #0f1a14;
  border-color: #6dbf8a;
  color: #e8f5ea;
}

/* Cozy Sofa / ensemble — warm cream chip */
.pov-pill.pov-sofa {
  background: #5c4a3a;
  border-color: #c4a35a;
  color: #fff9f2;
}

/* On ensemble cards, keep each cast pill’s own colors (do not override) */
.chapter-card.pov-sofa .pov-pill.pov-aline {
  background: #2a1848;
  border-color: #9b6bff;
  color: #f0e6ff;
}
.chapter-card.pov-sofa .pov-pill.pov-susule {
  background: #1e2028;
  border-color: #c8c4bc;
  color: #f2f2f6;
}
.chapter-card.pov-sofa .pov-pill.pov-lihua {
  background: #5a1830;
  border-color: #ff8fb3;
  color: #fff8fb;
}
.chapter-card.pov-sofa .pov-pill.pov-tess {
  background: #0f1a14;
  border-color: #6dbf8a;
  color: #e8f5ea;
}
.chapter-card.pov-sofa .pov-pill.pov-neon {
  background: #0a0618;
  border-color: #ff2bd6;
  color: #e8f7ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.65);
}


.badge-mature {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--danger-bg);
  border: 1px solid rgba(196, 92, 92, 0.5);
  color: #ffb4b4;
  font-weight: 600;
}

.chapter-body h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  margin: 0;
  color: var(--text);
}

.chapter-body .synopsis {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.chapter-body .open-hint {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--gold-dim);
}

/* =========================================================
   Chapter reading page
   ========================================================= */

.chapter-header {
  margin-bottom: 1.5rem;
}

.chapter-header .back-link {
  display: inline-block;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.chapter-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 400;
  margin: 0 0 0.5rem;
}

.chapter-banner {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 1rem 0 1.25rem;
}

.chapter-prose {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--text);
}

.chapter-prose p {
  margin: 0 0 1.1rem;
}

.chapter-prose .placeholder-note {
  font-size: 0.88rem;
  color: var(--text-dim);
  font-style: italic;
  border-left: 3px solid var(--border);
  padding-left: 0.85rem;
}

/* POV stripe on chapter pages */
body.chapter-page .frame {
  border-left: 4px solid var(--pov-aline);
}

body.chapter-page.pov-aline .frame { border-left-color: var(--pov-aline); }
body.chapter-page.pov-susule .frame { border-left-color: var(--pov-susule); }
body.chapter-page.pov-lihua .frame { border-left-color: var(--pov-lihua); }
body.chapter-page.pov-tess .frame { border-left-color: #6dbf8a; }
body.chapter-page.pov-neon .frame { border-left-color: #00f0ff; }
body.chapter-page.pov-sofa .frame {
  border-left: 4px solid #c4a35a;
}

/* =========================================================
   Mature warning modal
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border: 1px solid rgba(196, 92, 92, 0.55);
  border-radius: 12px;
  padding: 1.35rem 1.4rem 1.25rem;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  margin: 0 0 0.65rem;
  color: #ffb4b4;
}

.modal p {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.modal-actions button {
  appearance: none;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.modal-actions button.primary {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}

.modal-actions button:hover {
  filter: brightness(1.08);
}

/* =========================================================
   Character theme shells (Susule / Lihua mini-pages)
   ========================================================= */

/* Susule: static platinum metallic (no particle FX) */
body.theme-susule {
  --bg-deep: #1a1b20;
  --bg-panel: #2a2c34;
  --bg-panel-2: #32343e;
  --bg-soft: #3a3c48;
  --border: #6a6e7c;
  --text: #f2f2f6;
  --text-muted: #c4c6d0;
  --text-dim: #8e919e;
  --gold: #e8e4dc;
  --gold-dim: #b8b2a6;
  --purple: #6ec4bc;
  --purple-soft: #a8e0da;
  --purple-hair: #c45c5c;
  --slider-left: #6ec4bc;
  --slider-right: #c45c5c;
  --slider-fill: var(--slider-left);
  --slider-track: #2e3038;
  --border-gold: #c9c4b8;
  /* Glass tints tuned for silver metal behind the panel */
  --glass-tint: rgba(36, 38, 48, 0.48);
  --glass-tint-2: rgba(48, 50, 60, 0.4);
  --glass-edge: rgba(230, 232, 240, 0.28);
  --glass-edge-soft: rgba(230, 232, 240, 0.12);
  /*
   * Static metallic platinum — layered gradients only (no animation).
   * Think brushed silver + cool highlights + soft teal / scarf red accents.
   */
  background-color: #1c1d24;
  background-image:
    /* soft brand accents */
    radial-gradient(ellipse 55% 40% at 12% 20%, rgba(110, 196, 188, 0.12), transparent 55%),
    radial-gradient(ellipse 45% 35% at 88% 75%, rgba(196, 92, 92, 0.08), transparent 50%),
    /* bright metal streak */
    linear-gradient(
      118deg,
      transparent 0%,
      transparent 38%,
      rgba(255, 255, 255, 0.07) 46%,
      rgba(255, 255, 255, 0.2) 50%,
      rgba(255, 255, 255, 0.07) 54%,
      transparent 62%,
      transparent 100%
    ),
    /* brushed bands */
    repeating-linear-gradient(
      95deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px,
      transparent 4px
    ),
    /* main platinum body */
    linear-gradient(
      155deg,
      #14151a 0%,
      #2a2c34 14%,
      #5c5f6c 28%,
      #9a9eac 40%,
      #d8dae4 48%,
      #8e929f 56%,
      #3e404a 72%,
      #22232a 88%,
      #12131a 100%
    );
  background-attachment: fixed;
}

body.theme-susule .char-title { color: var(--purple-soft); }
body.theme-susule .site-nav a[aria-current="page"] {
  background: var(--purple-soft);
  border-color: var(--purple-soft);
  color: var(--bg-deep);
}

/* Glass tint per character (shows their bg through the frost) */
body.glass-ui:not(.theme-susule):not(.theme-lihua):not(.theme-sofa):not(.theme-tess):not(.theme-neon) {
  /* Aline — indigo night + stars */
  --glass-tint: rgba(12, 16, 32, 0.5);
  --glass-tint-2: rgba(20, 26, 48, 0.4);
  --glass-edge: rgba(196, 168, 255, 0.2);
  --glass-edge-soft: rgba(196, 168, 255, 0.1);
}

/* Lihua glass — lighter tint so sakura petals read through the frost */
body.theme-lihua.glass-ui {
  --glass-tint: rgba(255, 248, 252, 0.28);
  --glass-tint-2: rgba(255, 252, 254, 0.20);
  --glass-edge: rgba(255, 130, 170, 0.45);
  --glass-edge-soft: rgba(255, 150, 185, 0.28);
  --glass-blur: 3px;
  --glass-saturate: 1.45;
}

body.theme-lihua.glass-ui .frame {
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

body.theme-lihua.glass-ui .portrait-card,
body.theme-lihua.glass-ui .motif-card,
body.theme-lihua.glass-ui .rel-card,
body.theme-lihua.glass-ui .note-box,
body.theme-lihua.glass-ui .chapter-card {
  backdrop-filter: blur(8px) saturate(1.25);
  -webkit-backdrop-filter: blur(8px) saturate(1.25);
}

/* Lihua: bright pink / soft rose (lighter, not dark wine) */
body.theme-lihua {
  --bg-deep: #ffe8f0;
  --bg-panel: #fff0f5;
  --bg-panel-2: #ffe4ee;
  --bg-soft: #ffd6e5;
  --border: #f0a0b8;
  --text: #5a2438;
  --text-muted: #8b4560;
  --text-dim: #b07088;
  --gold: #d4a84b;
  --gold-dim: #b8923e;
  --purple: #ff7aab;
  --purple-soft: #ff9ec4;
  --purple-hair: #ffb6d0;
  --slider-left: #ff7aab;
  --slider-right: #e8c878;
  --slider-fill: var(--slider-left);
  --slider-track: #ffd0e0;
  --border-gold: #e8c878;
  --pov-lihua: #ff8fb3;
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(255, 255, 255, 0.9), transparent 50%),
    radial-gradient(ellipse 55% 45% at 95% 15%, rgba(255, 200, 220, 0.85), transparent 55%),
    radial-gradient(ellipse 50% 40% at 5% 85%, rgba(255, 170, 200, 0.45), transparent 55%),
    radial-gradient(ellipse 40% 35% at 70% 90%, rgba(255, 230, 180, 0.35), transparent 50%),
    linear-gradient(165deg, #fff5f8 0%, #ffd6e8 40%, #ffb8d4 100%);
  background-attachment: fixed;
}

body.theme-lihua .site-nav a[aria-current="page"] {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

body.theme-lihua .char-name {
  color: #5a2438;
}

body.theme-lihua .tab-btn[aria-selected="true"] {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

/* Cozy Sofa lounge — cream / pastel, soft FC hub */
body.theme-sofa {
  --bg-deep: #f5efe6;
  --bg-panel: #faf6f0;
  --bg-panel-2: #f3ebe0;
  --bg-soft: #ebe3d6;
  --border: #d4c4b0;
  --text: #4a3f36;
  --text-muted: #7a6b5c;
  --text-dim: #a09080;
  --gold: #c4a35a;
  --gold-dim: #a88848;
  --purple: #c9a88a;
  --purple-soft: #e0c8b0;
  --purple-hair: #d4b896;
  --slider-left: #d4b08c;
  --slider-right: #8eb4c8;
  --slider-fill: var(--slider-left);
  --slider-track: #e8ddd0;
  --border-gold: #d4c09a;
  --glass-tint: rgba(255, 252, 247, 0.5);
  --glass-tint-2: rgba(255, 250, 244, 0.45);
  --glass-edge: rgba(255, 255, 255, 0.55);
  --glass-edge-soft: rgba(212, 176, 140, 0.25);
  background:
    radial-gradient(ellipse 80% 50% at 50% -5%, rgba(255, 255, 255, 0.95), transparent 55%),
    radial-gradient(ellipse 45% 40% at 10% 70%, rgba(255, 220, 210, 0.4), transparent 55%),
    radial-gradient(ellipse 40% 35% at 90% 30%, rgba(220, 235, 255, 0.35), transparent 50%),
    radial-gradient(ellipse 35% 30% at 70% 90%, rgba(255, 235, 200, 0.4), transparent 50%),
    linear-gradient(165deg, #fff9f2 0%, #f5e6d8 45%, #ebe0d4 100%);
  background-attachment: fixed;
}

body.theme-sofa .char-name {
  color: #5c4a3a;
}

body.theme-sofa .char-title {
  color: #c4a35a;
}

body.theme-sofa .hero-quote {
  color: #9a7a60;
}

body.theme-sofa .site-nav a[aria-current="page"] {
  background: #e8d5b8;
  border-color: #d4c09a;
  color: #4a3f36;
}

body.theme-sofa .tab-btn[aria-selected="true"] {
  background: #e8d5b8;
  border-color: #d4c09a;
  color: #4a3f36;
}

body.theme-sofa .section h2 {
  color: #c4a35a;
}

body.theme-sofa a {
  color: #8b6b4a;
}

body.theme-sofa a:hover {
  color: #c4a35a;
}

/* Tess River — green forest + mist */
body.theme-tess {
  --bg-deep: #0f1a14;
  --bg-panel: #15241c;
  --bg-panel-2: #1a2e24;
  --bg-soft: #24382e;
  --border: #3d5c4a;
  --text: #e8f0e6;
  --text-muted: #a8c0b0;
  --text-dim: #6e8a78;
  --gold: #c4d4a0;
  --gold-dim: #9aab78;
  --purple: #6dbf8a;
  --purple-soft: #9ed9b4;
  --purple-hair: #4a8f68;
  --slider-left: #6dbf8a;
  --slider-right: #8a9e6e;
  --slider-fill: var(--slider-left);
  --slider-track: #1e3228;
  --border-gold: #a8c090;
  --glass-tint: rgba(18, 36, 28, 0.48);
  --glass-tint-2: rgba(26, 48, 38, 0.42);
  --glass-edge: rgba(160, 220, 180, 0.22);
  --glass-edge-soft: rgba(160, 220, 180, 0.12);
  background:
    radial-gradient(ellipse 70% 45% at 50% 100%, rgba(40, 80, 55, 0.55), transparent 55%),
    radial-gradient(ellipse 50% 40% at 15% 20%, rgba(60, 100, 70, 0.25), transparent 50%),
    radial-gradient(ellipse 40% 35% at 85% 30%, rgba(30, 60, 45, 0.35), transparent 50%),
    linear-gradient(180deg, #0c1610 0%, #142218 40%, #1a2e20 100%);
  background-attachment: fixed;
}

body.theme-tess .char-name {
  color: #e8f5ea;
}

body.theme-tess .char-title {
  color: #9ed9b4;
}

body.theme-tess .site-nav a[aria-current="page"] {
  background: #6dbf8a;
  border-color: #6dbf8a;
  color: #0f1a14;
}

body.theme-tess .tab-btn[aria-selected="true"] {
  background: #6dbf8a;
  border-color: #6dbf8a;
  color: #0f1a14;
}

body.theme-tess .section h2 {
  color: #9ed9b4;
}

/* Soft mist layers (Tess) — positions/durations set by JS (data-bg="mist") */
.bg-fx--mist {
  z-index: 0;
}

.bg-fx--mist .mist,
.bg-mist {
  position: absolute;
  border-radius: 50%;
  filter: blur(var(--mist-blur, 42px));
  opacity: var(--mist-opacity, 0.32);
  width: var(--mist-w, 40vw);
  height: var(--mist-h, 28vh);
  left: var(--mist-x, 10%);
  top: var(--mist-y, 40%);
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(200, 230, 210, var(--mist-core, 0.55)) 0%,
    rgba(160, 200, 170, 0.12) 45%,
    transparent 72%
  );
  animation: mist-drift var(--mist-dur, 24s) ease-in-out var(--mist-delay, 0s) infinite;
  will-change: transform, opacity;
}

/* Fallback static blobs if JS off */
.bg-fx--mist .mist-1 {
  --mist-w: 55vw;
  --mist-h: 35vh;
  --mist-x: -10%;
  --mist-y: 55%;
  --mist-dur: 22s;
}
.bg-fx--mist .mist-2 {
  --mist-w: 45vw;
  --mist-h: 30vh;
  --mist-x: 55%;
  --mist-y: 50%;
  --mist-opacity: 0.28;
  --mist-dur: 28s;
  --mist-delay: -6s;
}
.bg-fx--mist .mist-3 {
  --mist-w: 40vw;
  --mist-h: 25vh;
  --mist-x: 30%;
  --mist-y: 20%;
  --mist-opacity: 0.2;
  --mist-dur: 32s;
  --mist-delay: -12s;
}
.bg-fx--mist .mist-4 {
  --mist-w: 60vw;
  --mist-h: 20vh;
  --mist-x: 10%;
  --mist-y: 35%;
  --mist-opacity: 0.18;
  --mist-dur: 26s;
  --mist-delay: -4s;
}

/*
 * Forest mist: drifts on X/Y with gentle scale + opacity breathe.
 * --dx / --dy are set per blob in JS (random direction & distance).
 */
@keyframes mist-drift {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: var(--mist-opacity, 0.32);
  }
  25% {
    transform: translate(var(--dx, 4vw), calc(var(--dy, -2vh) * 0.5)) scale(1.04);
    opacity: calc(var(--mist-opacity, 0.32) * 1.15);
  }
  50% {
    transform: translate(var(--dx, 4vw), var(--dy, -3vh)) scale(1.08);
    opacity: calc(var(--mist-opacity, 0.32) * 0.85);
  }
  75% {
    transform: translate(calc(var(--dx, 4vw) * 0.35), calc(var(--dy, -3vh) * 1.1)) scale(1.03);
    opacity: calc(var(--mist-opacity, 0.32) * 1.05);
  }
  100% {
    transform: translate(0, 0) scale(1);
    opacity: var(--mist-opacity, 0.32);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-fx--mist .mist,
  .bg-mist {
    animation: none;
  }
}

/* Empty portrait box (Tess draft) */
.portrait-placeholder {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(160deg, rgba(80, 120, 90, 0.35), rgba(20, 40, 30, 0.6));
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

/* ----- Cozy Sofa market & social ----- */

.social-grid,
.market-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

@media (min-width: 560px) {
  .social-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .market-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 800px) {
  .social-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.social-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.05rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease;
}

.social-card:hover {
  text-decoration: none;
  color: inherit;
  transform: translateY(-2px);
}

.social-card--static {
  cursor: default;
}

.social-card--static:hover {
  transform: none;
}

.social-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.social-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.social-handle {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.market-heading {
  margin: 1.75rem 0 0.25rem;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.market-card {
  padding: 1.05rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.market-card h3 {
  margin: 0.4rem 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text);
}

.market-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.market-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.market-tag {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.35);
}

.market-price {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold-dim);
}

/* Fill-in placeholders on mini-pages */
.todo-fill {
  color: var(--text-dim);
  font-style: italic;
}


/* =========================================================
   Dynamic backgrounds (stars / sakura)
   HTML: <div class="bg-fx" data-bg="stars" aria-hidden="true"></div>
   JS:   js/backgrounds.js builds the particles
   ========================================================= */

.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none; /* clicks pass through to the page */
  overflow: hidden;
}

/* ----- Stars (Aline) ----- */

.bg-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.55;
  box-shadow: 0 0 4px rgba(200, 180, 255, 0.6);
  animation: star-twinkle var(--dur, 4s) ease-in-out var(--delay, 0s) infinite;
}

.bg-star--bright {
  opacity: 0.9;
  box-shadow:
    0 0 6px rgba(255, 255, 255, 0.9),
    0 0 12px rgba(155, 107, 255, 0.55);
}

.bg-nebula {
  position: absolute;
  width: var(--size, 220px);
  height: var(--size, 220px);
  margin-left: calc(var(--size, 220px) / -2);
  margin-top: calc(var(--size, 220px) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 90, 200, 0.2), transparent 70%);
  animation: nebula-breathe 12s ease-in-out var(--delay, 0s) infinite;
}

@keyframes star-twinkle {
  0%,
  100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes nebula-breathe {
  0%,
  100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.08); }
}

/*
 * Shooting stars (Aline)
 * Angle, travel, and duration are randomized in JS each launch
 * (full 360° direction, random streak length & time).
 */
.bg-shooting-star {
  position: absolute;
  width: var(--shoot-len, 90px);
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(200, 180, 255, 0.15) 35%,
    rgba(255, 255, 255, 0.95) 100%
  );
  box-shadow:
    0 0 6px rgba(200, 180, 255, 0.7),
    0 0 12px rgba(155, 107, 255, 0.35);
  opacity: 0;
  transform: rotate(var(--shoot-angle, -20deg)) translateX(0);
  transform-origin: right center;
  pointer-events: none;
  will-change: transform, opacity;
}

.bg-shooting-star.is-flying {
  animation: shooting-star-once var(--shoot-dur, 1.4s) linear forwards;
}

.bg-shooting-star::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px rgba(220, 200, 255, 0.9);
}

@keyframes shooting-star-once {
  0% {
    opacity: 0;
    transform: rotate(var(--shoot-angle, -20deg)) translateX(0);
  }
  10% {
    opacity: 1;
  }
  75% {
    opacity: 1;
    transform: rotate(var(--shoot-angle, -20deg)) translateX(var(--shoot-travel, 200px));
  }
  100% {
    opacity: 0;
    transform: rotate(var(--shoot-angle, -20deg)) translateX(calc(var(--shoot-travel, 200px) + 24px));
  }
}

/* ----- Sakura petals (Lihua) ----- */

.bg-petal {
  position: absolute;
  top: -24px;
  border-radius: 80% 0 80% 0;
  opacity: 0.85;
  box-shadow: 0 0 6px rgba(255, 200, 220, 0.35);
  /* fall + slight horizontal drift via custom properties from JS */
  animation:
    petal-fall var(--fall-dur, 12s) linear var(--delay, 0s) infinite,
    petal-sway var(--sway-dur, 3s) ease-in-out var(--delay, 0s) infinite;
  transform: rotate(var(--spin, 0deg));
}

@keyframes petal-fall {
  0% {
    top: -5%;
    opacity: 0;
  }
  8% {
    opacity: 0.9;
  }
  100% {
    top: 105%;
    opacity: 0.5;
    transform: translateX(var(--drift, 20px)) rotate(calc(var(--spin, 0deg) + 360deg));
  }
}

@keyframes petal-sway {
  0%,
  100% { margin-left: 0; }
  50% { margin-left: 18px; }
}

/* Videos embedded in content */
.media-video {
  width: 100%;
  max-height: 360px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #000;
  margin: 0.75rem 0 0;
}

/* =========================================================
   Neon / Solution 9 / cyberpunk character theme
   ========================================================= */

body.theme-neon {
  --bg-deep: #05040f;
  --bg-panel: #0c0a1a;
  --bg-panel-2: #12102a;
  --bg-soft: #1a1638;
  --border: #3d2a6b;
  --text: #e8f0ff;
  --text-muted: #9aa8c8;
  --text-dim: #5e6a8a;
  --gold: #00f0ff;
  --gold-dim: #00a8b8;
  --purple: #ff2bd6;
  --purple-soft: #ff7ae8;
  --purple-hair: #7b5cff;
  --slider-left: #00f0ff;
  --slider-right: #ff2bd6;
  --slider-fill: var(--slider-left);
  --slider-track: #1a1430;
  --border-gold: #00f0ff;
  --glass-tint: rgba(8, 6, 22, 0.42);
  --glass-tint-2: rgba(14, 10, 36, 0.36);
  --glass-edge: rgba(0, 240, 255, 0.28);
  --glass-edge-soft: rgba(255, 43, 214, 0.18);
  --pov-neon: #00f0ff;
  background-color: #05040f;
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(123, 92, 255, 0.22), transparent 55%),
    radial-gradient(ellipse 45% 40% at 10% 80%, rgba(255, 43, 214, 0.12), transparent 50%),
    radial-gradient(ellipse 40% 35% at 90% 30%, rgba(0, 240, 255, 0.1), transparent 50%),
    linear-gradient(180deg, #05040f 0%, #0a0820 50%, #08061a 100%);
  background-attachment: fixed;
}

body.theme-neon .char-name {
  color: #f0f4ff;
  text-shadow:
    0 0 12px rgba(0, 240, 255, 0.45),
    0 0 28px rgba(255, 43, 214, 0.25);
}

body.theme-neon .char-title {
  color: #00f0ff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

body.theme-neon .hero-quote {
  color: #ff7ae8;
}

body.theme-neon .site-nav a[aria-current="page"] {
  background: #00f0ff;
  border-color: #00f0ff;
  color: #05040f;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.45);
}

body.theme-neon .tab-btn[aria-selected="true"] {
  background: #ff2bd6;
  border-color: #ff2bd6;
  color: #fff;
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.45);
}

body.theme-neon .section h2 {
  color: #00f0ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
}

body.theme-neon .corner {
  border-color: #00f0ff;
  opacity: 0.7;
  filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.5));
}

body.theme-neon.glass-ui .frame {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 240, 255, 0.12),
    inset 0 1px 0 rgba(0, 240, 255, 0.1),
    0 0 40px rgba(255, 43, 214, 0.08);
}

/* Neon FX layer */
.bg-fx--neon .neon-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 43, 214, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  opacity: 0.55;
  animation: neon-grid-drift 28s linear infinite;
}

/*
 * Neon radio / techno waveform (replaces static horizon + shooting streaks)
 * SVG path is driven by JS on a shared BPM beat.
 */
.bg-fx--neon .neon-wave-wrap {
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: 12%;
  height: min(22vh, 180px);
  z-index: 1;
  pointer-events: none;
  filter:
    drop-shadow(0 0 6px rgba(0, 240, 255, 0.75))
    drop-shadow(0 0 18px rgba(255, 43, 214, 0.4));
  opacity: 0.92;
  /* beat flash (JS sets --wave-glow) */
  --wave-glow: 0.55;
}

.bg-fx--neon .neon-wave {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bg-fx--neon .neon-wave-base {
  fill: none;
  stroke: rgba(0, 240, 255, 0.22);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

.bg-fx--neon .neon-wave-path {
  fill: none;
  stroke: url(#neon-wave-grad);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.bg-fx--neon .neon-wave-path--glow {
  stroke: #fff;
  stroke-width: 1;
  opacity: var(--wave-glow, 0.55);
  filter: blur(0.4px);
}

/* Soft under-glow band under the signal */
.bg-fx--neon .neon-wave-band {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 18%;
  height: 48px;
  background: linear-gradient(
    180deg,
    rgba(0, 240, 255, 0.12) 0%,
    rgba(255, 43, 214, 0.08) 40%,
    transparent 100%
  );
  filter: blur(12px);
  opacity: calc(0.35 + var(--wave-glow, 0.55) * 0.5);
  pointer-events: none;
}

.bg-fx--neon .neon-scan {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.35;
  pointer-events: none;
}

/* Orbs — transform/opacity driven by JS beat (no free-running CSS pulse) */
.bg-neon-orb {
  position: absolute;
  border-radius: 50%;
  width: var(--orb-size, 180px);
  height: var(--orb-size, 180px);
  margin-left: calc(var(--orb-size, 180px) / -2);
  margin-top: calc(var(--orb-size, 180px) / -2);
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--orb-color, #00f0ff) 50%, transparent) 0%,
    color-mix(in srgb, var(--orb-color, #00f0ff) 12%, transparent) 42%,
    transparent 70%
  );
  filter: blur(8px);
  opacity: 0.45;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0) scale(1);
}

/* Static fallback when motion is reduced */
.bg-fx--neon.is-static .neon-wave-path {
  d: path("M 0 40 L 1200 40");
}

@keyframes neon-grid-drift {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 0 48px, 48px 0; }
}

body.chapter-page.pov-neon .frame,
body.theme-neon.chapter-page .frame {
  border-left-color: #00f0ff;
}

@media (prefers-reduced-motion: reduce) {
  .bg-star,
  .bg-nebula,
  .bg-shooting-star,
  .bg-petal,
  .bg-fx--neon .neon-grid {
    animation: none !important;
  }
  .bg-shooting-star {
    display: none;
  }
  .bg-star {
    opacity: 0.7;
  }
  .bg-petal {
    top: 20%;
    opacity: 0.5;
  }
  .bg-fx--neon .neon-wave-wrap {
    height: 4px;
    bottom: 18%;
    filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.6));
  }
}
