/* ============================================================
   Member-Ex — dark emerald memory chamber
   Layers: universe (ambient) → glass panels → content.
   Motion: transform/opacity only. No grain, no feTurbulence.
   ============================================================ */

/* Vendored variable fonts (no CDN): Fraunces = editorial display serif,
   Sora = geometric UI/body sans. Latin subset only. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("vendor/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("vendor/fonts/sora-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
/* Norse (Joël Carrouché, 2010 — personal & commercial use) = Viking-carved
   display face. Latin only — English display font; non-English locales fall
   back to Cinzel/Fraunces (see the [lang] rule below). */
@font-face {
  font-family: "Norse";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("vendor/fonts/norse-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Norse";
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url("vendor/fonts/norse-bold-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Cinzel = secondary Norse-saga serif; also Latin-only fallback for Norse. */
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("vendor/fonts/cinzel-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* palette */
  --void-0: #020504;
  --void-1: #030806;
  --void-2: #06110d;
  --void-3: #0a1a14;
  --emerald-0: #082f22;
  --emerald-1: #0e6f4a;
  --emerald-2: #1ec992;
  --emerald-3: #5eecc0;
  --gold-0: #6f5520;
  --gold-1: #b99a45;
  --gold-2: #d6b65a;
  --gold-3: #ffe08a;
  --cyan-0: #65f7ff;

  /* fog / smoke ambient washes — atmospheric depth, not a flat neon field */
  --fog-green-0: color-mix(in srgb, var(--emerald-0) 30%, transparent);
  --fog-green-1: color-mix(in srgb, var(--emerald-1) 22%, transparent);
  --fog-green-2: color-mix(in srgb, var(--emerald-2) 16%, transparent);
  --fog-green-3: color-mix(in srgb, var(--emerald-3) 13%, transparent);
  --fog-gold-0: color-mix(in srgb, var(--gold-0) 26%, transparent);
  --fog-gold-1: color-mix(in srgb, var(--gold-1) 22%, transparent);
  --fog-gold-2: color-mix(in srgb, var(--gold-2) 18%, transparent);
  --fog-gold-3: color-mix(in srgb, var(--gold-3) 15%, transparent);
  --smoke-emerald-0: color-mix(in srgb, var(--emerald-0) 85%, transparent);
  --smoke-emerald-1: color-mix(in srgb, var(--emerald-1) 68%, transparent);
  --smoke-emerald-2: color-mix(in srgb, var(--emerald-2) 38%, transparent);
  --smoke-emerald-3: color-mix(in srgb, var(--emerald-3) 28%, transparent);
  --smoke-gold-0: color-mix(in srgb, var(--gold-0) 62%, transparent);
  --smoke-gold-1: color-mix(in srgb, var(--gold-1) 52%, transparent);
  --smoke-gold-2: color-mix(in srgb, var(--gold-2) 38%, transparent);
  --smoke-gold-3: color-mix(in srgb, var(--gold-3) 30%, transparent);

  /* depth plane blur tokens */
  --depth-blur-far: 100px;
  --depth-blur-mid: 72px;
  --depth-blur-near: 48px;

  /* Apple glass material tokens */
  --glass-blur: 44px;
  --glass-blur-strong: 64px;
  --glass-blur-soft: 32px;
  --glass-saturate: 108%;
  --glass-bright: 1.02;
  --glass-tint: rgba(4, 10, 7, 0.22);
  --glass-fill: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.04) 42%,
    rgba(0, 0, 0, 0.08) 100%
  );
  --glass-border-outer: rgba(255, 255, 255, 0.2);
  --glass-rim-top: rgba(255, 255, 255, 0.38);
  --glass-gold-whisper: inset 0 0 0 1px rgba(214, 182, 90, 0.18);
  --glass-shadow-float: 0 28px 90px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 255, 255, 0.06);
  /* pressed: shadow tightens + hardens close to the element boundary */
  --glass-shadow-press: 0 2px 6px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.55);
  --glass-shadow-inset-top: inset 0 1px 0 var(--glass-rim-top);
  --glass-shadow-inset-bottom: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  --glass-scrim-heavy: color-mix(in srgb, var(--void-0) 48%, transparent);
  --glass-scrim-mid: color-mix(in srgb, var(--void-0) 28%, transparent);
  --glass-scrim-light: color-mix(in srgb, var(--void-0) 8%, transparent);
  --glass-scrim-veil: color-mix(in srgb, var(--emerald-0) 12%, transparent);
  --glass-rim-bottom: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(8, 47, 34, 0.12);
  --glass-border: var(--glass-border-outer);
  --glass-highlight: var(--glass-rim-top);

  /* semantic aliases used across components */
  --void: var(--void-1);
  --emerald-bright: var(--emerald-2);
  --emerald: var(--emerald-1);
  --emerald-deep: var(--emerald-0);
  --emerald-dim: rgba(46, 201, 146, 0.55);
  --gold: var(--gold-2);
  --gold-deep: var(--gold-1);
  --gold-dim: rgba(214, 182, 90, 0.55);
  --cyan: var(--cyan-0);
  --ink: #eefff7;
  --ink-dim: rgba(226, 248, 240, 0.68);
  --ink-faint: rgba(205, 235, 222, 0.4);
  --glass: var(--glass-fill), var(--glass-tint);
  --glass-line: var(--glass-border-outer);
  --glass-gold: rgba(214, 182, 90, 0.22);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.35, 0.64, 1);
  --danger: #f97e7e;
  --ok: #4ade80;
  --font: "Sora", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fraunces", "Sora", Georgia, "Times New Roman", serif;
  --dock-h: 74px;

  /* layout tokens */
  --space-section: clamp(24px, 4vw, 48px);
  --content-max: clamp(1120px, 88vw, 1360px);
  --hero-gap: clamp(32px, 5vw, 72px);
  --card-radius-lg: 24px;
  --transcript-max: 680px;
}

/* Norse-saga display font in English only. Cinzel is Latin-only, so every other
   locale keeps the basic serif above to stay fully readable. app.js keeps
   <html lang> in sync with the active locale. */
html[lang="en"] {
  --font-display: "Norse", "Cinzel", "Fraunces", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

html { background: var(--void-0); }

body {
  font-family: var(--font);
  color: var(--ink);
  background: transparent;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  font-optical-sizing: auto;
}

/* Editorial display face for headlines, names, and the wordmark */
.display, h1, h2,
.hero-name, .bb-name, .cc-name, .fp-name, .fr-name,
.discover-section-title, .modal-head h2, .presence-name, .brand-name {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.012em;
  font-feature-settings: "kern" 1, "liga" 1, "ss01" 1;
}

/* Norse is a carved display face — give English titles more size + breathing room
   so they read as bold headings, while body text stays on the readable base font. */
html[lang="en"] .display,
html[lang="en"] h1,
html[lang="en"] h2,
html[lang="en"] .hero-name,
html[lang="en"] .bb-name,
html[lang="en"] .cc-name,
html[lang="en"] .fp-name,
html[lang="en"] .fr-name,
html[lang="en"] .discover-section-title,
html[lang="en"] .modal-head h2,
html[lang="en"] .presence-name,
html[lang="en"] .brand-name {
  letter-spacing: 0.02em;
  font-weight: 700;
  font-size: 1.14em;
  line-height: 1.14;
}

/* ================= UNIVERSE — 28 depth layers ================= */

.universe {
  position: fixed;
  inset: 0;
  z-index: 0;
  perspective: 800px;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse 100% 80% at 50% 100%, var(--void-3), var(--void-0));
}

.layer { position: absolute; inset: 0; }

/* --- void base (depth anchor) --- */
.void-base {
  background:
    radial-gradient(ellipse 120% 90% at 50% 110%, var(--void-2) 0%, transparent 62%),
    radial-gradient(ellipse 90% 70% at 15% -10%, color-mix(in srgb, var(--emerald-0) 32%, var(--void-1)) 0%, transparent 55%),
    radial-gradient(ellipse 100% 100% at 100% 40%, var(--void-1) 0%, transparent 65%),
    var(--void-0);
}

.void-horizon {
  background:
    radial-gradient(ellipse 120% 40% at 50% 100%, color-mix(in srgb, var(--gold-2) 18%, transparent) 0%, transparent 74%),
    radial-gradient(ellipse 100% 34% at 50% 100%, color-mix(in srgb, var(--emerald-1) 16%, transparent) 0%, transparent 70%);
  opacity: 0.9;
}

/* --- far plane: distant haze blobs --- */
[data-depth="far"],
.haze-d1,
.haze-d2,
.haze-d3,
.haze-d4 {
  inset: auto;
  border-radius: 50%;
  filter: blur(var(--depth-blur-far));
  will-change: transform;
  pointer-events: none;
}
.haze-d1 {
  width: 160vmax; height: 110vmax;
  top: -42vmax; left: -38vmax;
  background: radial-gradient(ellipse, var(--fog-green-0) 0%, var(--fog-green-1) 38%, transparent 72%);
  filter: blur(108px);
  opacity: 0.5;
  animation: haze-drift 112s ease-in-out infinite alternate;
}
.haze-d2 {
  width: 148vmax; height: 96vmax;
  bottom: -36vmax; right: -32vmax;
  background: radial-gradient(ellipse, var(--fog-gold-0) 0%, var(--fog-gold-1) 34%, transparent 70%);
  filter: blur(120px);
  opacity: 0.48;
  animation: haze-drift 98s ease-in-out infinite alternate-reverse;
}
.haze-d3 {
  width: 132vmax; height: 88vmax;
  top: 18%; left: 42%;
  background: radial-gradient(ellipse, var(--fog-green-1) 0%, var(--fog-green-2) 42%, transparent 68%);
  filter: blur(96px);
  opacity: 0.46;
  animation: haze-drift 104s ease-in-out infinite alternate;
}
.haze-d4 {
  width: 140vmax; height: 92vmax;
  top: 52%; left: -28vmax;
  background: radial-gradient(ellipse, var(--fog-gold-1) 0%, var(--fog-gold-2) 36%, transparent 74%);
  filter: blur(114px);
  opacity: 0.44;
  animation: haze-drift 118s ease-in-out infinite alternate-reverse;
}

/* --- mid plane: fog banks (green + gold washes) --- */
.fog-bank-a,
.fog-bank-b,
.fog-bank-c,
.fog-bank-d,
.fog-bank-e {
  mix-blend-mode: soft-light;
  opacity: 0.42;
  will-change: transform;
  animation: fog-bank-drift 68s ease-in-out infinite;
}
.fog-bank-a {
  background:
    radial-gradient(ellipse 92% 72% at 38% 48%, var(--fog-green-1), var(--fog-green-0) 44%, transparent 70%),
    radial-gradient(ellipse 78% 64% at 64% 52%, var(--fog-gold-1), var(--fog-gold-0) 40%, transparent 66%);
  animation-duration: 72s;
}
.fog-bank-b {
  background:
    radial-gradient(ellipse 88% 68% at 32% 56%, var(--fog-green-2), var(--fog-green-1) 46%, transparent 68%),
    radial-gradient(ellipse 84% 66% at 70% 44%, var(--fog-gold-2), var(--fog-gold-1) 42%, transparent 72%);
  animation-duration: 80s;
  animation-direction: reverse;
  opacity: 0.58;
}
.fog-bank-c {
  background:
    radial-gradient(ellipse 96% 74% at 48% 42%, var(--fog-green-0), var(--fog-green-2) 48%, transparent 72%),
    radial-gradient(ellipse 80% 62% at 58% 62%, var(--fog-gold-0), var(--fog-gold-2) 38%, transparent 68%);
  animation-duration: 64s;
  opacity: 0.55;
}
.fog-bank-d {
  background:
    radial-gradient(ellipse 90% 70% at 22% 38%, var(--fog-green-3), var(--fog-green-1) 44%, transparent 70%),
    radial-gradient(ellipse 86% 68% at 78% 58%, var(--fog-gold-3), var(--fog-gold-1) 40%, transparent 74%);
  animation-duration: 76s;
  animation-direction: reverse;
  opacity: 0.54;
}
.fog-bank-e {
  background:
    radial-gradient(ellipse 94% 70% at 52% 54%, var(--fog-green-2), var(--fog-green-3) 42%, transparent 68%),
    radial-gradient(ellipse 82% 64% at 44% 46%, var(--fog-gold-2), var(--fog-gold-3) 38%, transparent 72%);
  animation-duration: 84s;
  opacity: 0.5;
}

/* --- smoke: emerald core (mid) + gold rim (near) --- */
.smoke {
  border-radius: 50%;
  inset: auto;
  will-change: transform;
}
.smoke.s1,
.smoke.s3,
.smoke.s5 {
  filter: blur(var(--depth-blur-mid));
  opacity: 0.58;
}
.smoke.s1 {
  width: 108vmax; height: 62vmax;
  background: radial-gradient(ellipse, var(--smoke-emerald-0) 0%, var(--smoke-emerald-1) 42%, transparent 72%);
  top: -18vmax; left: -22vmax;
  animation: smoke-a 54s ease-in-out infinite alternate;
}
.smoke.s3 {
  width: 72vmax; height: 46vmax;
  background: radial-gradient(ellipse, var(--smoke-emerald-2) 0%, var(--smoke-emerald-3) 38%, transparent 68%);
  top: 28%; left: 18%;
  animation: smoke-c 46s ease-in-out infinite alternate;
}
.smoke.s5 {
  width: 62vmax; height: 40vmax;
  background: radial-gradient(ellipse, var(--smoke-emerald-0) 0%, var(--smoke-emerald-2) 45%, transparent 70%);
  bottom: 8%; left: 8%;
  animation: smoke-e 50s ease-in-out infinite alternate;
}
.smoke.s2,
.smoke.s4,
.smoke.s6 {
  filter: blur(var(--depth-blur-near));
}
.smoke.s2 {
  width: 96vmax; height: 58vmax;
  background: radial-gradient(ellipse, var(--smoke-emerald-1) 0%, var(--smoke-emerald-2) 28%, var(--smoke-gold-0) 48%, var(--smoke-gold-1) 58%, transparent 72%);
  bottom: -20vmax; right: -18vmax;
  animation: smoke-b 66s ease-in-out infinite alternate;
  opacity: 0.72;
}
.smoke.s4 {
  width: 80vmax; height: 50vmax;
  background: radial-gradient(ellipse, var(--smoke-emerald-2) 0%, var(--smoke-emerald-3) 24%, var(--smoke-gold-1) 46%, var(--smoke-gold-2) 56%, transparent 74%);
  top: 55%; right: -10vmax;
  animation: smoke-d 58s ease-in-out infinite alternate-reverse;
  opacity: 0.68;
}
.smoke.s6 {
  width: 54vmax; height: 36vmax;
  background: radial-gradient(ellipse, var(--smoke-emerald-3) 0%, var(--smoke-gold-1) 34%, var(--smoke-gold-2) 48%, var(--smoke-gold-3) 62%, transparent 68%);
  top: 8%; right: 22%;
  animation: smoke-f 42s ease-in-out infinite alternate-reverse;
  opacity: 0.64;
}

/* --- near plane: mist wisps (brighter gold) --- */
.mist-n1,
.mist-n2,
.mist-n3,
.mist-n4 {
  inset: auto;
  border-radius: 50%;
  filter: blur(var(--depth-blur-near));
  mix-blend-mode: soft-light;
  will-change: transform;
}
.mist-n1 {
  width: 48vmax; height: 32vmax;
  top: 14%; left: 12%;
  background: radial-gradient(ellipse, var(--smoke-gold-2) 0%, var(--smoke-gold-3) 42%, transparent 68%);
  opacity: 0.52;
  animation: mist-drift 28s ease-in-out infinite alternate;
}
.mist-n2 {
  width: 42vmax; height: 28vmax;
  bottom: 22%; right: 16%;
  background: radial-gradient(ellipse, var(--fog-gold-2) 0%, color-mix(in srgb, var(--gold-3) 32%, transparent) 46%, transparent 72%);
  opacity: 0.48;
  animation: mist-drift 34s ease-in-out infinite alternate-reverse;
}
.mist-n3 {
  width: 38vmax; height: 26vmax;
  top: 62%; left: 38%;
  background: radial-gradient(ellipse, var(--smoke-emerald-3) 0%, var(--smoke-gold-2) 38%, var(--smoke-gold-3) 58%, transparent 70%);
  opacity: 0.44;
  animation: mist-drift 32s ease-in-out infinite alternate;
}
.mist-n4 {
  width: 36vmax; height: 24vmax;
  top: 32%; right: 28%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--gold-3) 24%, transparent) 0%, var(--smoke-gold-3) 36%, transparent 66%);
  opacity: 0.56;
  animation: mist-drift 25s ease-in-out infinite alternate-reverse;
}

/* --- godrays: conic light shafts --- */
.godray,
.godray-1,
.godray-2 {
  inset: -20%;
  mix-blend-mode: soft-light;
  opacity: 0.1;
  will-change: transform;
  pointer-events: none;
}
.godray-1 {
  background: conic-gradient(
    from 210deg at 38% 28%,
    transparent 0deg,
    color-mix(in srgb, var(--gold-2) 18%, transparent) 18deg,
    transparent 42deg,
    color-mix(in srgb, var(--emerald-2) 12%, transparent) 58deg,
    transparent 88deg,
    color-mix(in srgb, var(--gold-3) 14%, transparent) 108deg,
    transparent 360deg
  );
  animation: godray-spin 180s linear infinite;
}
.godray-2 {
  background: conic-gradient(
    from 30deg at 72% 64%,
    transparent 0deg,
    color-mix(in srgb, var(--emerald-1) 14%, transparent) 22deg,
    transparent 48deg,
    color-mix(in srgb, var(--gold-1) 16%, transparent) 72deg,
    transparent 360deg
  );
  opacity: 0.06;
  animation: godray-spin 240s linear infinite reverse;
}

/* --- gold accents --- */
.bloom {
  opacity: 0.92;
  mix-blend-mode: soft-light;
  animation: bloom-pulse 48s ease-in-out infinite alternate;
  background:
    radial-gradient(circle at 28% 18%, var(--fog-green-1), var(--fog-green-2) 28%, transparent 46%),
    radial-gradient(circle at 82% 72%, var(--fog-gold-1), var(--fog-gold-2) 24%, transparent 42%),
    radial-gradient(circle at 52% 38%, color-mix(in srgb, var(--gold-3) 22%, transparent), transparent 50%),
    radial-gradient(circle at 18% 78%, color-mix(in srgb, var(--gold-2) 18%, transparent), transparent 38%);
}

.sheen {
  opacity: 0.18;
  mix-blend-mode: soft-light;
  background: linear-gradient(
    105deg,
    transparent 28%,
    var(--fog-gold-2) 42%,
    color-mix(in srgb, var(--gold-3) 36%, transparent) 50%,
    var(--fog-gold-1) 58%,
    color-mix(in srgb, var(--gold-2) 20%, transparent) 62%,
    transparent 68%
  );
  animation: sheen-sweep 24s ease-in-out infinite;
}

/* --- sparse rising motes --- */
.particles { inset: -100vh 0 0; }
.particles::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 8% 12%, color-mix(in srgb, var(--emerald-2) 45%, transparent), transparent),
    radial-gradient(1px 1px at 28% 38%, color-mix(in srgb, var(--emerald-2) 32%, transparent), transparent),
    radial-gradient(1.2px 1.2px at 66% 22%, color-mix(in srgb, var(--gold-2) 28%, transparent), transparent),
    radial-gradient(1px 1px at 84% 64%, color-mix(in srgb, var(--emerald-1) 30%, transparent), transparent),
    radial-gradient(1px 1px at 46% 82%, color-mix(in srgb, var(--emerald-2) 22%, transparent), transparent),
    radial-gradient(0.8px 0.8px at 92% 18%, color-mix(in srgb, var(--gold-3) 24%, transparent), transparent),
    radial-gradient(0.8px 0.8px at 14% 68%, color-mix(in srgb, var(--gold-1) 20%, transparent), transparent);
  background-size: 100% 50%;
  animation: particles-rise 96s linear infinite;
  will-change: transform;
}

/* --- edge falloff --- */
.vignette {
  background: radial-gradient(ellipse at center, transparent 40%, color-mix(in srgb, var(--void-0) 82%, transparent) 100%);
}

/* When Vanta.FOG renders the background, retire the CSS fog layers and keep
   only the vignette for edge framing. The Vanta <canvas> is not a .layer, so
   it stays visible; the vignette paints on top for a soft cinematic frame. */
body.vanta-on #universe { background: var(--void-0); }
body.vanta-on #universe > .layer:not(.vignette) { display: none !important; }
body.vanta-on .vignette {
  background: radial-gradient(ellipse at center, transparent 52%, color-mix(in srgb, var(--void-0) 62%, transparent) 100%);
  z-index: 2;
}

/* --- WebGL fog canvas overlay --- */
.fog-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.34;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* --- depth band keyframes --- */
@keyframes haze-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(4vmax, -2.5vmax) scale(1.04); }
  66% { transform: translate(-3vmax, 3vmax) scale(1.02); }
}
@keyframes fog-bank-drift {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(3.5%, -2.8%); }
  50% { transform: translate(-2.8%, 3.2%); }
  75% { transform: translate(4.2%, 1.8%); }
}
@keyframes smoke-a { to { transform: translate(7vmax, 4vmax) scale(1.08); } }
@keyframes smoke-b { to { transform: translate(-6vmax, -3vmax) scale(1.05); } }
@keyframes smoke-c { to { transform: translate(5vmax, -2vmax) scale(1.06); } }
@keyframes smoke-d { to { transform: translate(-4vmax, 3vmax); } }
@keyframes smoke-e { to { transform: translate(3vmax, -4vmax) scale(1.04); } }
@keyframes smoke-f { to { transform: translate(-3vmax, 2vmax); } }
@keyframes mist-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(2.5vmax, -1.8vmax) scale(1.06); }
}
@keyframes godray-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes bloom-pulse {
  0%, 100% { opacity: 0.82; }
  50% { opacity: 0.96; }
}
@keyframes sheen-sweep {
  0%, 100% { transform: translateX(-10%); opacity: 0.12; }
  50% { transform: translateX(10%); opacity: 0.26; }
}
@keyframes particles-rise { to { transform: translateY(50%); } }

@media (prefers-reduced-motion: reduce) {
  .universe .layer { animation: none !important; }
}

/* ================= APPLE GLASS MATERIALS ================= */

.glass,
.glass-strong,
.glass-soft,
.glass-float {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--glass-border-outer);
  box-shadow: var(--glass-shadow-inset-top), var(--glass-shadow-inset-bottom), var(--glass-shadow-float);
}

.glass {
  background: var(--glass-fill), var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate)) brightness(var(--glass-bright));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate)) brightness(var(--glass-bright));
}

.glass-strong {
  background: var(--glass-fill), rgba(4, 12, 8, 0.28);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-saturate)) brightness(var(--glass-bright));
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-saturate)) brightness(var(--glass-bright));
  box-shadow: var(--glass-shadow-inset-top), var(--glass-shadow-inset-bottom), var(--glass-gold-whisper), var(--glass-shadow-float);
}

.glass-soft {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)), rgba(4, 12, 8, 0.32);
  -webkit-backdrop-filter: blur(var(--glass-blur-soft)) saturate(140%) brightness(1.03);
  backdrop-filter: blur(var(--glass-blur-soft)) saturate(140%) brightness(1.03);
  box-shadow: var(--glass-shadow-inset-top), inset 0 -1px 0 var(--glass-rim-bottom), 0 16px 48px rgba(0, 0, 0, 0.42);
}

.glass-float {
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.glass-float:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow-inset-top), var(--glass-shadow-inset-bottom), 0 32px 90px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.28);
}

/* ============================================================
   SPATIAL PRESS — floating cards physically push into the screen.
   Default: high float (wide soft shadow, handled per-component).
   Press: shrink + shadow tightens/hardens close to the boundary.
   Release springs back (base transition uses the spring curve).
   ============================================================ */
.glass-float,
.card,
.character-card.is-clickable,
.btn-primary,
.btn-gold,
.btn-ghost,
.dock-btn {
  transition: transform 0.36s var(--ease-spring), box-shadow 0.36s var(--ease-out);
}
.glass-float:active,
.card:active,
.character-card.is-clickable:active,
.btn-primary:active,
.btn-gold:active,
.btn-ghost:active,
.dock-btn:active {
  transform: scale(0.965);
  box-shadow: var(--glass-shadow-inset-top), var(--glass-shadow-press);
  /* touch-down is snappy; release falls back to the springy base transition */
  transition-duration: 0.1s;
  transition-timing-function: var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .glass-float:active,
  .card:active,
  .character-card.is-clickable:active,
  .btn-primary:active,
  .btn-gold:active,
  .btn-ghost:active,
  .dock-btn:active { transform: none; }
}

.glass::before,
.glass-strong::before,
.glass-soft::before,
.glass-float::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 48%);
  mask: linear-gradient(#fff, transparent 58%);
  -webkit-mask: linear-gradient(#fff, transparent 58%);
}

.glass-strong::before {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(214, 182, 90, 0.025) 26%,
    transparent 50%
  );
}

.glass-inset {
  position: relative;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.gold { color: var(--gold); }

.display, .bb-name, .hero-name { text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35); }

@media (max-width: 480px) {
  :root {
    --glass-blur: 28px;
    --glass-blur-strong: 36px;
    --glass-blur-soft: 22px;
  }
}

/* ================= SHELL ================= */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) clamp(16px, 3.2vw, 56px)
           calc(var(--dock-h) + 12px + env(safe-area-inset-bottom));
  padding-left: max(clamp(16px, 3.2vw, 56px), env(safe-area-inset-left));
  padding-right: max(clamp(16px, 3.2vw, 56px), env(safe-area-inset-right));
  gap: 12px;
  background: transparent;
}

.stage { min-height: 0; display: grid; background: transparent; }

.view {
  min-height: 0;
  min-width: 0;
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  animation: view-enter 0.5s var(--ease-out) both;
  background: transparent;
}
@keyframes view-enter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Typography polish — balanced headings, readable body wrapping */
h1, h2,
.hero-name, .bb-name, .cc-name, .discover-section-title,
.card-name, .modal-head h2, .hero-title {
  text-wrap: balance;
}
.lede, .hero-bio, .cc-hook, .modal-sub, .card-tagline, .empty-story p {
  text-wrap: pretty;
}

.page-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 4px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 241, 149, 0.55) transparent;
}

#view-discover .page-scroll {
  justify-content: center;
  min-height: min(100%, calc(100dvh - var(--dock-h) - 120px));
}

/* ---- Luminous line scrollbar: a slim, floating gradient thread that
   glows emerald→cyan→gold and breathes, instead of a sharp gray bar. ---- */
.page-scroll,
.transcript,
.modal-scroll,
.rail-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 241, 149, 0.55) transparent;
}
.page-scroll::-webkit-scrollbar,
.transcript::-webkit-scrollbar,
.modal-scroll::-webkit-scrollbar,
.rail-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.page-scroll::-webkit-scrollbar-track,
.transcript::-webkit-scrollbar-track,
.modal-scroll::-webkit-scrollbar-track,
.rail-scroll::-webkit-scrollbar-track { background: transparent; }
.page-scroll::-webkit-scrollbar-thumb,
.transcript::-webkit-scrollbar-thumb,
.modal-scroll::-webkit-scrollbar-thumb,
.rail-scroll::-webkit-scrollbar-thumb {
  min-height: 44px;
  /* transparent border + padding-box clip = a thin ~4px thread floating
     inside the 10px gutter, fully rounded like a light-pipe. */
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
  background-color: rgba(20, 241, 149, 0.85);
  background-image: linear-gradient(
    180deg,
    rgba(20, 241, 149, 0.95),
    rgba(101, 247, 255, 0.8) 45%,
    rgba(214, 182, 90, 0.9)
  );
  box-shadow:
    0 0 8px rgba(20, 241, 149, 0.55),
    inset 0 0 4px rgba(255, 255, 255, 0.45);
  transition: box-shadow 0.35s ease, filter 0.35s ease;
  animation: scroll-breathe 3.4s ease-in-out infinite;
}
.page-scroll::-webkit-scrollbar-thumb:hover,
.transcript::-webkit-scrollbar-thumb:hover,
.modal-scroll::-webkit-scrollbar-thumb:hover,
.rail-scroll::-webkit-scrollbar-thumb:hover {
  filter: brightness(1.2);
  box-shadow:
    0 0 16px rgba(20, 241, 149, 0.85),
    inset 0 0 5px rgba(255, 255, 255, 0.6);
}
@keyframes scroll-breathe {
  0%, 100% { filter: brightness(0.92); }
  50% { filter: brightness(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .page-scroll::-webkit-scrollbar-thumb,
  .transcript::-webkit-scrollbar-thumb,
  .modal-scroll::-webkit-scrollbar-thumb,
  .rail-scroll::-webkit-scrollbar-thumb { animation: none; }
}

/* ============================================================
   LIQUID GLASS v3 — Apple scroll-edge + prismatic dispersion
   (1) continuous scroll-edge fade, (2) chromatic prism border,
   (3) gel-press retained-color icons, (4) clear-glass tinting.
   ============================================================ */

/* (1) Scroll-edge continuous fade: content dissolves at the top/bottom
   of scroll containers instead of a hard clipped border. */
.page-scroll,
.transcript {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 100%);
}

/* (2) Chromatic dispersion — prismatic rainbow stroke hugging the rounded
   corners of the signature glass surfaces. Gradient-border via mask-exclude,
   so only the 1.5px edge paints; content is untouched. */
.billboard, .character-card, .hero-meta, .chat-stage { position: relative; }
.billboard::before,
.character-card::before,
.hero-meta::before,
.chat-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  background: conic-gradient(
    from 210deg,
    rgba(255, 255, 255, 0.55),
    rgba(20, 241, 149, 0.5) 18%,
    rgba(101, 247, 255, 0.34) 34%,
    rgba(255, 255, 255, 0.45) 52%,
    rgba(214, 182, 90, 0.55) 72%,
    rgba(20, 241, 149, 0.4) 88%,
    rgba(255, 255, 255, 0.55)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.55;
}
.character-card::before { opacity: 0.7; }
/* keep the forge birth-sweep above the prism ring */
.forge-result.card-reveal .fr-card-host .character-card::after { z-index: 6; }

/* (3) Retained-color, gel-fluid press: icons keep their hue at rest and
   bloom with a liquid highlight on touch/press (no flat desaturation). */
.dock-btn svg,
.topnav-btn svg { transition: filter 0.2s ease, transform 0.2s var(--ease-spring); }
.dock-btn:active svg,
.topnav-btn:active svg {
  filter: drop-shadow(0 0 7px rgba(20, 241, 149, 0.7)) brightness(1.15);
  transform: scale(1.08);
}
.dock-btn:active,
.topnav-btn:active {
  background: radial-gradient(120% 120% at 50% 0%, rgba(20, 241, 149, 0.18), rgba(255, 255, 255, 0.05) 60%, transparent);
}

/* (4) Clear-glass adaptive tinting for media-rich surfaces: keep underlying
   artwork bright/sharp while the physical glass layer carries the tint. */
.glass-clear {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(3, 8, 6, 0.14)) !important;
  -webkit-backdrop-filter: blur(26px) saturate(112%) brightness(1.05) !important;
  backdrop-filter: blur(26px) saturate(112%) brightness(1.05) !important;
}

@media (prefers-reduced-motion: reduce) {
  .dock-btn svg, .topnav-btn svg { transition: none; }
}

/* ================= TOPBAR ================= */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-xl);
}

.topbar-compact {
  min-height: 56px;
  padding: 6px 12px;
}

.topbar-center {
  display: flex;
  min-width: 0;
}

@media (min-width: 768px) {
  .topbar-center {
    flex: 1;
    justify-content: center;
  }
  .topbar-center .topnav {
    flex: 1;
    justify-content: center;
    margin: 0;
  }
}

.topbar.glass {
  background: var(--glass-fill), rgba(3, 8, 6, 0.22);
  -webkit-backdrop-filter: blur(48px) saturate(140%) brightness(1.03);
  backdrop-filter: blur(48px) saturate(140%) brightness(1.03);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 12px 40px rgba(0, 0, 0, 0.38);
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; cursor: pointer; border-radius: 12px; transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out); }
.brand:hover { opacity: 0.9; }
.brand:active { transform: scale(0.98); }
.brand:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 3px; }
.brand-mark {
  position: relative;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.35s ease;
}
.brand-mark svg {
  display: block;
  width: 100%; height: 100%;
}
.brand:hover .brand-mark {
  transform: scale(1.05);
  box-shadow: 0 0 18px rgba(20, 241, 149, 0.28);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0.005em;
  background: linear-gradient(100deg, #f4fff9 8%, #b9f5db 52%, #7fe9c0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.brand-name .brand-it {
  font-style: italic;
  font-weight: 600;
  background: linear-gradient(100deg, #ffe9ac, var(--gold) 60%, #c79a38);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  margin-left: 1px;
}
.brand-sub {
  margin-top: 4px;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
}

.topnav { display: flex; gap: 4px; margin: 0 auto; }
.topnav-btn {
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.topnav-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
.topnav-btn.active {
  color: var(--ink);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)), var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--glass-blur-soft)) saturate(160%);
  backdrop-filter: blur(var(--glass-blur-soft)) saturate(160%);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 20px rgba(0, 0, 0, 0.25);
}

.topbar .topnav-btn.active {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.topnav-btn:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }

.locale-picker {
  appearance: none;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(20, 241, 149, 0.15);
  background: rgba(3, 8, 6, 0.5);
  color: var(--ink-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.locale-picker:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 1px; }

.account-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.08), rgba(3, 8, 6, 0.4));
  color: var(--ink-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: box-shadow 0.25s ease, transform 0.15s var(--ease-spring),
              color 0.25s ease, border-color 0.25s ease;
}
.account-gear {
  display: block;
  transition: transform 0.5s var(--ease-spring);
}
.account-btn:hover {
  color: var(--ink);
  border-color: rgba(20, 241, 149, 0.4);
  box-shadow: 0 0 16px rgba(20, 241, 149, 0.22);
}
.account-btn:hover .account-gear { transform: rotate(60deg); }
.account-btn:active { transform: scale(0.94); }
.account-btn:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }
/* signed-in indicator: a small emerald dot on the gear */
.account-btn.signed { color: var(--emerald-bright); border-color: rgba(20, 241, 149, 0.45); }
.account-btn.signed::after {
  content: "";
  position: absolute;
  top: -2px; right: -2px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--emerald-bright);
  border: 1.5px solid var(--void-2);
  box-shadow: 0 0 8px rgba(20, 241, 149, 0.7);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); box-shadow: 0 0 8px currentColor; flex: none; }
.status-dot.ok { background: var(--ok); color: var(--ok); }
.status-dot.bad { background: var(--danger); color: var(--danger); }
.status-text { font-size: 12px; color: var(--ink-dim); }

/* ================= TYPOGRAPHY ================= */

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--emerald-dim);
}
.eyebrow.gold { color: var(--gold-dim); }

.display {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.lede { margin: 0; font-size: 14px; color: var(--ink-dim); max-width: 52ch; line-height: 1.6; }

.row-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 2px 12px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
}
.row-label::before {
  content: "";
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold-2), transparent);
  flex: none;
}

/* premium empty state for Continue your story */
.empty-story {
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  text-align: center;
}
.empty-story p { margin: 0; font-size: 15px; font-style: italic; color: var(--gold-3); opacity: 0.8; }
.empty-story span { display: block; margin-top: 8px; font-size: 12.5px; font-style: normal; color: var(--ink-faint); }

/* ================= DISCOVER — welcome home ================= */

.discover-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-section);
  width: 100%;
}

.discover-home {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 5vw, 40px);
  padding: clamp(12px, 3vw, 28px) 0 clamp(32px, 6vw, 48px);
}

.discover-intro {
  text-align: center;
}

.discover-title {
  margin: 10px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vw, 2.65rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--ink);
}

.discover-lead {
  margin: 0 auto;
  max-width: 420px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-dim);
}

.guide-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
}

.guide-avatar-wrap {
  position: relative;
  flex: none;
}

.guide-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(20, 241, 149, 0.14), rgba(214, 182, 90, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.guide-avatar.has-photo {
  background: #030806;
}

.guide-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.guide-avatar-mono {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gold-2);
  user-select: none;
}

.guide-live {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--emerald-bright);
  border: 2px solid rgba(3, 8, 6, 0.9);
  box-shadow: 0 0 8px var(--emerald-bright);
}

.guide-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-name {
  margin: 0;
  font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.guide-hook {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.discover-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), border-color 0.2s ease, background 0.2s ease;
}

.quick-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(20, 241, 149, 0.28);
  background: rgba(20, 241, 149, 0.04);
}

.quick-tile:active { transform: scale(0.98); }

.quick-icon {
  font-size: 14px;
  color: var(--gold);
  line-height: 1;
}

.quick-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.quick-desc {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.35;
}

.discover-chars-wrap {
  margin-top: 48px;
  width: 100%;
}

.discover-section-title {
  margin: 0 0 18px;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.discover-chars {
  min-height: 80px;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.billboard {
  position: relative;
  border-radius: calc(var(--radius-xl) + 6px);
  overflow: hidden;
  min-height: clamp(360px, 48vh, 480px);
  display: flex;
  align-items: center;
  flex: none;
  margin: 0 auto;
  width: 100%;
  max-width: 980px;
  isolation: auto;
  background: linear-gradient(160deg, rgba(4, 15, 10, 0.78), rgba(2, 6, 4, 0.66)), var(--glass-fill);
  -webkit-backdrop-filter: blur(30px) saturate(120%) brightness(0.92);
  backdrop-filter: blur(30px) saturate(120%) brightness(0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 40px 110px rgba(0, 0, 0, 0.6);
}

.billboard-media {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 80% at 72% 42%, color-mix(in srgb, var(--emerald-1) 22%, transparent), transparent 68%),
    radial-gradient(ellipse 45% 50% at 70% 38%, color-mix(in srgb, var(--gold-2) 18%, transparent), transparent 72%),
    linear-gradient(155deg, color-mix(in srgb, var(--emerald-0) 18%, transparent), color-mix(in srgb, var(--void-2) 12%, transparent) 80%);
  background-size: cover;
  background-position: center 28%;
  transform: scale(1);
  transition: transform 12s var(--ease-out);
}
.billboard:hover .billboard-media { transform: scale(1.07); }

/* When a real portrait is set, fit the whole figure to the right (no crop-zoom)
   and fade it into the card on the left so the copy stays readable. */
.billboard-media.has-photo {
  background-size: cover;
  background-position: right 20%;
  background-repeat: no-repeat;
  transform: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,0.5) 40%, #000 66%);
  mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,0.5) 40%, #000 66%);
}
/* On wide cards, hold the portrait to a clean right-hand band so it reads as a
   framed figure rather than a full-bleed crop. */
@media (min-width: 761px) {
  .billboard-media.has-photo {
    background-size: auto 116%;
    background-position: right center;
  }
}
.billboard:hover .billboard-media.has-photo { transform: none; }
@media (max-width: 760px) {
  .billboard-media.has-photo {
    background-position: right top;
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 55%, transparent 92%);
    mask-image: linear-gradient(to bottom, #000 0, #000 55%, transparent 92%);
  }
}

.bb-mono {
  position: absolute;
  top: 42%; left: 72%;
  transform: translate(-50%, -50%);
  font-size: clamp(8rem, 22vw, 17rem);
  font-weight: 800;
  background: linear-gradient(180deg, rgba(255, 224, 138, 0.3), rgba(214, 182, 90, 0.04) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
}

.billboard-fade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--glass-scrim-heavy) 0%, var(--glass-scrim-mid) 45%, var(--glass-scrim-light) 80%),
    linear-gradient(0deg, var(--glass-scrim-heavy) 0%, var(--glass-scrim-veil) 28%, transparent 48%);
}

.billboard-body {
  position: relative;
  z-index: 2;
  padding: 32px 32px 30px;
  max-width: 680px;
}

.discover-billboard .billboard-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 15px;
  padding: 44px 48px;
  max-width: 560px;
}

.discover-billboard .bb-name {
  font-size: clamp(2.5rem, 5.5vw, 3.8rem);
}

.bb-name { margin: 0 0 10px; font-size: clamp(2.2rem, 5.5vw, 3.6rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1; }
.bb-quote {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--gold-3);
  opacity: 0.85;
  font-style: italic;
  max-width: 500px;
}
.bb-stats { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 16px; }
.bb-stat { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-dim); font-weight: 600; }
.bb-stat .dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald-bright); box-shadow: 0 0 8px var(--emerald-bright); }
.bb-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* tags */
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tags.small .tag { font-size: 10px; padding: 3px 9px; }
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(8, 47, 34, 0.15));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--emerald-bright);
}
.tag.gold-tag { border-color: rgba(214, 182, 90, 0.22); background: linear-gradient(145deg, rgba(214, 182, 90, 0.12), rgba(8, 47, 34, 0.1)); color: var(--gold); }

/* search */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-radius: 999px;
  flex: none;
  transition: box-shadow 0.25s ease;
}
.search-wrap:focus-within { box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(20, 241, 149, 0.3), 0 0 22px rgba(20, 241, 149, 0.1); }
.search-wrap .ico { color: var(--emerald-dim); flex: none; }
.search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 13px 0;
  outline: none;
  min-width: 0;
}
.search-wrap input::placeholder { color: var(--ink-faint); }

/* rows (Netflix rails) */
.rows { display: flex; flex-direction: column; gap: 18px; }
.rail-block { min-width: 0; }
.rail {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 12px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.rail::-webkit-scrollbar { display: none; }

/* grid used for search results */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

/* ================= CHARACTER CARDS ================= */

.card {
  position: relative;
  flex: none;
  width: 246px;
  aspect-ratio: 3 / 4.15;
  border: none;
  padding: 0;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  background: transparent;
  text-align: left;
  scroll-snap-align: start;
  transition: transform 0.35s var(--ease-spring);
}
.grid .card { width: auto; }
.card:hover { transform: translateY(-7px) scale(1.025); z-index: 2; }
.card:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 3px; }

.card-glow {
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--radius-lg) + 2px);
  background: linear-gradient(135deg, rgba(20, 241, 149, 0.35), rgba(214, 182, 90, 0.22));
  opacity: 0;
  transition: opacity 0.3s ease;
  filter: blur(7px);
}
.card:hover .card-glow { opacity: 1; }

.card-frame {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  border: 1px solid rgba(20, 241, 149, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 14px 40px rgba(0, 0, 0, 0.55);
  background: var(--void-2);
  transition: border-color 0.3s ease;
}
.card:hover .card-frame { border-color: rgba(214, 182, 90, 0.5); }

.card-media {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  transition: transform 0.45s var(--ease-out);
}
.card:hover .card-media { transform: scale(1.07); }
.card-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 22%, rgba(3, 8, 6, 0.45) 52%, rgba(3, 8, 6, 0.95) 100%);
}

.card-mono {
  position: absolute;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3.6rem;
  font-weight: 800;
  opacity: 0.24;
  color: var(--gold);
}

.card-shimmer {
  position: absolute;
  top: 10%; left: 20%;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 12px 26px 0 -1px var(--emerald-bright), 34px 8px 0 -1.4px var(--cyan);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.card:hover .card-shimmer { opacity: 0.5; }

.card-body { position: absolute; inset: auto 0 0; z-index: 2; padding: 16px 15px 15px; }
.card-name { display: block; font-weight: 800; font-size: 17.5px; letter-spacing: -0.02em; }
.card-hook {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--ink-dim);
  margin-top: 5px;
  line-height: 1.45;
}
.card-foot { display: flex; align-items: center; gap: 7px; margin-top: 9px; }
.card-chip {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--glass-gold);
  color: var(--gold);
  background: rgba(214, 182, 90, 0.1);
  white-space: nowrap;
}
.card-chip.mem { border-color: rgba(20, 241, 149, 0.25); color: var(--emerald-bright); background: rgba(15, 81, 56, 0.3); }
.card-live { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald-bright); box-shadow: 0 0 7px var(--emerald-bright); flex: none; }
.card-cta { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--emerald-bright); opacity: 0; transition: opacity 0.25s ease; white-space: nowrap; }
.card:hover .card-cta, .card:focus-visible .card-cta { opacity: 1; }

/* ================= CHARACTER PAGE ================= */

.layout-split,
.char-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  flex: none;
}
@media (min-width: 980px) {
  .layout-split {
    grid-template-columns: 2fr 3fr;
    gap: var(--hero-gap);
    align-items: center;
  }
  /* portrait column hugs the portrait so it sits beside the meta (no floating
     gap), and the hero top-aligns so the meta panel wraps its content. */
  .char-hero {
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: var(--hero-gap);
    align-items: start;
  }
}

/* ---- Large-screen tier: fill wide monitors, scale hero + cards ---- */
@media (min-width: 1400px) {
  .billboard { max-width: 1080px; min-height: clamp(440px, 52vh, 620px); }
  .discover-chars { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
  .hero-stage { width: min(100%, 340px); }
  .char-panels { gap: 24px; }
}
@media (min-width: 1760px) {
  .billboard { max-width: 1180px; }
  .discover-chars { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

.hero-col-portrait {
  display: flex;
  justify-content: center;
}

.hero-col-portrait { display: flex; justify-content: center; align-items: center; }
.hero-stage {
  position: relative;
  width: min(100%, 320px);
  aspect-ratio: 3 / 4;
  margin: 0 auto;
}

.hero-smoke {
  position: absolute;
  inset: -8% -16%;
  background: radial-gradient(ellipse, rgba(20, 241, 149, 0.22), transparent 64%);
  filter: blur(48px);
  animation: smoke-c 22s ease-in-out infinite alternate;
  z-index: 0;
}
.hero-ring {
  position: absolute;
  inset: -5%;
  border: 1px solid rgba(214, 182, 90, 0.22);
  border-radius: var(--radius-xl);
  animation: ring-pulse 9s ease-in-out infinite;
  z-index: 1;
}
@keyframes ring-pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.035); }
}

.hero-portrait {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--avatar-grad, linear-gradient(160deg, var(--emerald-deep), var(--void-3)));
  background-size: cover;
  background-position: center;
  border: 2px solid rgba(214, 182, 90, 0.38);
  box-shadow:
    0 26px 64px rgba(0, 0, 0, 0.6),
    0 0 48px rgba(20, 241, 149, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.32);
  z-index: 3;
}
.hero-portrait.has-image { color: transparent; }

.hero-glow {
  position: absolute;
  bottom: -2%;
  left: 50%;
  transform: translateX(-50%);
  width: 82%; height: 36%;
  background: radial-gradient(ellipse, rgba(214, 182, 90, 0.2), transparent 70%);
  filter: blur(22px);
  z-index: 1;
}

.breathe { animation: breathe 5s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.022); }
}

.hero-meta {
  padding: 28px;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: -24px;
  z-index: 4;
  isolation: auto;
  background: var(--glass-fill), rgba(3, 8, 6, 0.24);
  -webkit-backdrop-filter: blur(34px) saturate(108%) brightness(1.02);
  backdrop-filter: blur(34px) saturate(108%) brightness(1.02);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 24px 70px rgba(0, 0, 0, 0.42);
}
@media (min-width: 980px) {
  .hero-meta { margin-top: 0; align-self: start; }
}
.hero-name { margin: 0; font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.03em; }
.hero-quote { margin: 0; font-size: 15px; font-style: italic; color: var(--gold); line-height: 1.5; }
.hero-bio { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-dim); }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 13px 0;
  border-top: 1px solid rgba(20, 241, 149, 0.1);
  border-bottom: 1px solid rgba(20, 241, 149, 0.1);
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-val { font-weight: 800; font-size: 14px; }
.stat-val.gold { color: var(--gold); }
.stat-lbl { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; }

.panels-grid,
.char-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  flex: none;
}
@media (min-width: 820px) {
  .panels-grid,
  .char-panels { grid-template-columns: 1fr 1fr; gap: 20px; }
}

/* remade memory-map header — the bond + summary + filters live in a defined
   "console" sub-panel that reads as a distinct layer above the timeline journal. */
.memory-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(20, 241, 149, 0.08), transparent 55%),
    radial-gradient(120% 140% at 100% 0%, rgba(214, 182, 90, 0.07), transparent 55%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.16));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 30px rgba(0, 0, 0, 0.28);
}
.memory-toolbar .memory-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 0;
}
@media (min-width: 560px) {
  .memory-toolbar .memory-header { flex-wrap: nowrap; }
}
.memory-toolbar .memory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
  padding: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.memory-toolbar .memory-filters .memory-filter {
  flex: 1;
  min-width: 0;
  text-align: center;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.panel {
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  isolation: auto;
  background: var(--glass-fill), rgba(3, 8, 6, 0.3);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 16px 48px rgba(0, 0, 0, 0.38);
}
.panel h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.panel h3::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), var(--emerald-bright));
  box-shadow: 0 0 10px rgba(214, 182, 90, 0.5);
}
.panel-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-dim);
  white-space: pre-wrap;
}

.memory-panel { grid-column: 1 / -1; }

.memory-lede {
  margin: -4px 0 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.memory-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 0;
}

.memory-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}
.memory-header-compact {
  gap: 14px;
  margin-bottom: 14px;
  align-items: center;
}
.memory-header-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memory-header-meta .memory-stats { margin-bottom: 0; }

.memory-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 72px;
}
.memory-stat b { font-size: 14px; color: var(--ink); }
.memory-stat small {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}

.memory-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-dim);
}
.bond-stage {
  margin: 0;
  font-family: var(--font-display, inherit);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--ink);
}
.bond-stage::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--emerald-bright);
  box-shadow: 0 0 10px rgba(20, 241, 149, 0.6);
  vertical-align: middle;
}

/* bond ring — relationship progress */
.bond-ring {
  --bond-pct: 0%;
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(
    from 225deg,
    var(--emerald-bright) var(--bond-pct),
    rgba(255, 255, 255, 0.07) var(--bond-pct)
  );
  box-shadow:
    0 0 28px rgba(20, 241, 149, 0.12),
    inset 0 0 0 1px rgba(20, 241, 149, 0.15);
}
.bond-ring-sm {
  width: 64px;
  height: 64px;
  padding: 3px;
}
.bond-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background:
    radial-gradient(circle at 35% 28%, rgba(20, 241, 149, 0.12), transparent 55%),
    var(--glass-fill),
    var(--glass-tint);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.bond-ring-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.bond-ring-sm .bond-ring-value { font-size: 14px; }
.bond-ring-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

/* memory filter pills */
.memory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.memory-filter {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out), color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.memory-filter:hover {
  border-color: rgba(20, 241, 149, 0.22);
  color: var(--ink-dim);
}
.memory-filter.is-active {
  background: linear-gradient(145deg, rgba(20, 241, 149, 0.14), rgba(20, 241, 149, 0.04));
  border-color: rgba(20, 241, 149, 0.32);
  color: var(--emerald-bright);
  box-shadow: 0 0 18px rgba(20, 241, 149, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.memory-filter:focus-visible {
  outline: 2px solid var(--emerald-bright);
  outline-offset: 2px;
}

/* vertical memory journal */
.memory-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 180px;
  padding: 8px 10px 12px 22px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 12% 8%, rgba(20, 241, 149, 0.05), transparent 42%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.memory-timeline::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(
    180deg,
    rgba(20, 241, 149, 0.35) 0%,
    rgba(214, 182, 90, 0.22) 50%,
    rgba(20, 241, 149, 0.08) 100%
  );
  pointer-events: none;
}
.memory-timeline.compact {
  min-height: 0;
  padding: 6px 6px 8px 18px;
  width: 100%;
  max-height: 168px;
  overflow-y: auto;
}
.memory-timeline.compact::before {
  top: 12px;
  bottom: 12px;
  left: 8px;
}
.memory-timeline-scroll {
  min-height: 120px;
  max-height: min(52vh, 440px);
  overflow-y: auto;
  padding-right: 4px;
}
.memory-timeline-scroll::-webkit-scrollbar,
.memory-timeline.compact::-webkit-scrollbar { width: 5px; }
.memory-timeline-scroll::-webkit-scrollbar-thumb,
.memory-timeline.compact::-webkit-scrollbar-thumb {
  background: rgba(20, 241, 149, 0.18);
  border-radius: 6px;
}

.memory-card,
.memory-timeline .memory-node {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 100%;
  margin: 0 0 10px 10px;
  padding: 11px 14px 11px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 3px;
  border-left-color: rgba(20, 241, 149, 0.35);
  background: var(--glass-fill), var(--glass-tint);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 22px rgba(0, 0, 0, 0.28);
}
.memory-timeline.compact .memory-node,
.memory-timeline.compact .memory-card {
  margin-bottom: 8px;
  padding: 8px 10px 8px 12px;
}
.memory-card:last-child,
.memory-timeline .memory-node:last-child { margin-bottom: 0; }

.memory-card::before,
.memory-timeline .memory-node::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 16px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--emerald-bright), rgba(14, 111, 74, 0.9));
  border: 2px solid rgba(3, 8, 6, 0.85);
  box-shadow: 0 0 10px rgba(20, 241, 149, 0.45);
}
.memory-timeline.compact .memory-node::before,
.memory-timeline.compact .memory-card::before {
  left: -17px;
  top: 14px;
  width: 7px;
  height: 7px;
}

.memory-card[data-kind="identity"],
.memory-timeline .memory-node[data-kind="identity"] { border-left-color: rgba(214, 182, 90, 0.65); }
.memory-card[data-kind="preference"],
.memory-timeline .memory-node[data-kind="preference"] { border-left-color: rgba(20, 241, 149, 0.55); }
.memory-card[data-kind="fact"],
.memory-timeline .memory-node[data-kind="fact"] { border-left-color: rgba(101, 247, 255, 0.5); }
.memory-card[data-kind="goal"],
.memory-timeline .memory-node[data-kind="goal"] { border-left-color: rgba(255, 224, 138, 0.5); }
.memory-card[data-kind="moment"],
.memory-timeline .memory-node[data-kind="moment"] { border-left-color: color-mix(in srgb, var(--gold-3) 45%, transparent); }

.memory-card.is-new,
.memory-timeline .memory-node.is-new {
  animation: memory-glow 2.8s ease-in-out infinite;
  border-color: rgba(20, 241, 149, 0.28);
}
@keyframes memory-glow {
  0%, 100% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.14),
      0 0 16px rgba(20, 241, 149, 0.12),
      0 8px 22px rgba(0, 0, 0, 0.28);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 0 28px rgba(20, 241, 149, 0.28),
      0 0 48px rgba(214, 182, 90, 0.12),
      0 10px 26px rgba(0, 0, 0, 0.32);
  }
}

.memory-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.memory-card .memory-kind {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--emerald-bright);
  opacity: 0.85;
}
.memory-card .memory-when {
  font-size: 10px;
  color: var(--ink-faint);
}
.memory-card .memory-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-dim);
}
.memory-pin {
  position: absolute;
  top: 8px;
  right: 28px;
  font-size: 11px;
  color: rgba(214, 182, 90, 0.85);
  opacity: 0.9;
}
.memory-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.memory-card:hover .memory-del,
.memory-timeline .memory-node:hover .memory-del { opacity: 1; }
.memory-del:hover {
  background: rgba(255, 80, 80, 0.22);
  color: #ffb4b4;
}

/* legacy constellation map — kept for compat */
.memory-map {
  position: relative;
  min-height: 220px;
  border-radius: var(--radius-lg);
  padding: 18px;
  background:
    radial-gradient(circle at 50% 50%, rgba(20, 241, 149, 0.06), transparent 55%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.memory-map::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px dashed rgba(20, 241, 149, 0.12);
  border-radius: 50%;
  pointer-events: none;
}
.memory-map.compact {
  min-height: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.memory-map.compact::before { display: none; }

.memory-empty {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-faint);
  font-style: italic;
  text-align: center;
  padding: 36px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.memory-empty::before {
  content: "";
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(20, 241, 149, 0.22), transparent 68%);
  border: 1.5px dashed rgba(20, 241, 149, 0.4);
  box-shadow: 0 0 22px rgba(20, 241, 149, 0.14), inset 0 0 14px rgba(20, 241, 149, 0.1);
  animation: memory-empty-breathe 3.4s ease-in-out infinite;
}
@keyframes memory-empty-breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.7; }
  50% { transform: scale(1.06); opacity: 1; }
}
.memory-timeline .memory-empty { padding: 30px 12px; }

.memory-node {
  position: absolute;
  left: var(--mx, 50%);
  top: var(--my, 50%);
  transform: translate(-50%, -50%);
  width: min(210px, 42%);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--glass-fill), var(--glass-tint);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 10px 28px rgba(0, 0, 0, 0.32);
}
.memory-map.compact .memory-node {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 100%;
  padding: 8px 10px;
}
.memory-node::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  background: var(--emerald-bright);
  box-shadow: 0 0 10px rgba(20, 241, 149, 0.45);
}
.memory-map.compact .memory-node::after,
.memory-timeline .memory-node::after { display: none; }

.memory-node[data-kind="identity"] { border-color: rgba(214, 182, 90, 0.28); }
.memory-node[data-kind="preference"] { border-color: rgba(20, 241, 149, 0.24); }
.memory-node[data-kind="fact"] { border-color: rgba(101, 247, 255, 0.22); }
.memory-node[data-kind="goal"] { border-color: rgba(255, 224, 138, 0.22); }

.memory-kind {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.memory-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}

.memory-when {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-faint);
}

.memory-meter { display: flex; flex-direction: column; gap: 10px; }
.memory-meter.compact { width: 100%; gap: 7px; }
.meter-row { display: flex; flex-direction: column; gap: 5px; }
.meter-lbl { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-faint); font-weight: 600; }
.meter-lbl b { color: var(--ink-dim); font-weight: 700; }
.meter-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(3, 8, 6, 0.6);
  border: 1px solid rgba(20, 241, 149, 0.08);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--emerald), var(--emerald-bright), var(--gold));
  transform-origin: left;
  transition: transform 0.8s var(--ease-out);
}

.gallery { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img {
  height: 130px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-gold);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  flex: none;
}

.suggest-block { flex: none; }

/* ================= CHAT ================= */

#view-chat {
  padding: 4px 2px;
}

.chat-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 14px;
  padding: 14px;
  border-radius: calc(var(--radius-xl) + 4px);
  overflow: hidden;
  --mood-glow: rgba(101, 247, 255, 0.1);
  margin: 0;
  isolation: auto;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015) 45%, rgba(0, 0, 0, 0.05)),
    rgba(3, 9, 6, 0.34);
  -webkit-backdrop-filter: blur(30px) saturate(104%) brightness(1);
  backdrop-filter: blur(30px) saturate(104%) brightness(1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 0 0 1px rgba(214, 182, 90, 0.06),
    0 24px 80px rgba(0, 0, 0, 0.5);
}
.chat-stage[data-mood="warm"] { --mood-glow: rgba(20, 241, 149, 0.18); }
.chat-stage[data-mood="thinking"] { --mood-glow: rgba(214, 182, 90, 0.2); }

.chat-presence {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  padding: 18px 14px 14px;
  border-radius: var(--radius-lg);
  text-align: center;
  overflow-y: auto;
  scrollbar-width: none;
}

.chat-presence.glass-soft {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(4, 12, 8, 0.4);
  -webkit-backdrop-filter: blur(22px) saturate(106%) brightness(1);
  backdrop-filter: blur(22px) saturate(106%) brightness(1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 var(--glass-rim-bottom),
    0 12px 40px rgba(0, 0, 0, 0.4);
}
.chat-presence::-webkit-scrollbar { display: none; }

.presence-frame { position: relative; width: 100%; max-width: 190px; aspect-ratio: 3 / 4; flex: none; }
.presence-portrait {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: var(--avatar-grad, linear-gradient(160deg, var(--emerald-deep), var(--void-3)));
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(214, 182, 90, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 34px var(--mood-glow);
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.35);
  transition: box-shadow 0.6s ease;
}
.presence-portrait.has-image { color: transparent; }
.presence-portrait.breathe { animation: presence-breathe 5s ease-in-out infinite; }
@keyframes presence-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.018); }
}
.presence-aura {
  position: absolute;
  inset: -8px;
  border-radius: calc(var(--radius-md) + 8px);
  border: 1px solid rgba(214, 182, 90, 0.2);
  animation: ring-pulse 6.5s ease-in-out infinite;
  pointer-events: none;
  opacity: 0.6;
}
.presence-name { margin: 0; font-size: 16px; font-weight: 800; }
.presence-mood { margin: 0; font-size: 12px; color: var(--emerald-dim); min-height: 15px; }

.presence-memory-wrap {
  width: 100%;
  margin-top: 2px;
}

/* dropdown: native <details>/<summary> disclosure */
.presence-memory-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-align: left;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.presence-memory-label::-webkit-details-marker { display: none; }
.presence-memory-label:hover {
  background: rgba(20, 241, 149, 0.06);
  border-color: rgba(20, 241, 149, 0.22);
  color: var(--emerald-bright);
}
.presence-memory-wrap[open] > .presence-memory-label {
  margin-bottom: 8px;
  border-color: rgba(20, 241, 149, 0.2);
  color: var(--emerald-bright);
}
.presence-memory-caret {
  flex: none;
  transition: transform 0.3s var(--ease-spring);
  opacity: 0.8;
}
.presence-memory-wrap[open] > .presence-memory-label .presence-memory-caret {
  transform: rotate(180deg);
}
.presence-memory-wrap:not([open]) > .presence-memory-label { margin-bottom: 0; }

.presence-memory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-height: 132px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(16px) saturate(108%);
  backdrop-filter: blur(16px) saturate(108%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 241, 149, 0.15) transparent;
}

.presence-memory-list::-webkit-scrollbar { width: 4px; }
.presence-memory-list::-webkit-scrollbar-thumb {
  background: rgba(20, 241, 149, 0.15);
  border-radius: 4px;
}

.presence-memory-snippet {
  margin: 0;
  padding: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-dim);
  text-align: left;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.presence-memory-snippet::before {
  content: "·";
  color: var(--emerald-bright);
  margin-right: 6px;
  font-weight: 800;
}

.presence-memory-empty {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-faint);
  font-style: italic;
  text-align: left;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(2, 6, 4, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(18px) saturate(106%);
  backdrop-filter: blur(18px) saturate(106%);
}

.chat-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(20, 241, 149, 0.08);
}
.chat-bar-center {
  justify-self: center;
  min-width: 0;
  text-align: center;
}
.chat-bar-meta { flex: 1; min-width: 0; }
.memory-btn {
  color: var(--ink-faint);
  transition: color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.memory-btn:hover { color: var(--emerald-bright); }
.memory-btn:focus-visible {
  outline: 2px solid var(--emerald-bright);
  outline-offset: 2px;
}
.head-name { font-weight: 700; font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-status { font-size: 11px; color: var(--ink-faint); }
.head-status.busy { color: var(--gold); animation: pulse-text 1.6s ease-in-out infinite; }
@keyframes pulse-text { 50% { opacity: 0.55; } }

.chat-main-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-width: var(--transcript-max);
  margin: 0 auto;
  width: 100%;
  padding: 18px 24px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  background: transparent;
}
.transcript::-webkit-scrollbar { width: 5px; }
.transcript::-webkit-scrollbar-thumb {
  background: rgba(214, 182, 90, 0.2);
  border-radius: 6px;
}
.transcript::-webkit-scrollbar-track { background: transparent; }

.row { display: flex; align-items: flex-end; gap: 10px; max-width: min(82%, 640px); animation: msg-in 0.38s var(--ease-out) both; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.row.user { align-self: flex-end; flex-direction: row-reverse; }
.row.bot, .row.system { align-self: flex-start; }

.bubble {
  padding: 13px 17px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.62;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 28px rgba(0, 0, 0, 0.28);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.bubble-p {
  margin: 0;
}
.bubble-p + .bubble-p,
.bubble-p + .bubble-list,
.bubble-list + .bubble-p {
  margin-top: 10px;
}
.bubble-list {
  margin: 0;
  padding: 0 0 0 1.15em;
  list-style: decimal;
}
.bubble-list li {
  margin: 0 0 6px;
  padding-left: 4px;
  line-height: 1.55;
}
.bubble-list li:last-child { margin-bottom: 0; }
.bubble-p, .bubble-list li { text-wrap: pretty; }

/* roleplay markup: *action* renders as soft italic narration, **x** as emphasis */
/* Roleplay actions (rendered from *asterisks*) — a themed, Norse-gold "stage
   direction" so it reads as something happening, distinct from spoken lines. */
.bubble em {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 500;
  color: var(--gold-3);
  letter-spacing: 0.012em;
  opacity: 0.97;
  text-shadow: 0 0 16px color-mix(in srgb, var(--gold-2) 42%, transparent);
}
.bubble em::before {
  content: "\2739\00a0"; /* ✹ rune-like mark */
  font-style: normal;
  font-size: 0.72em;
  color: color-mix(in srgb, var(--gold-2) 80%, transparent);
  vertical-align: 0.06em;
  text-shadow: none;
}
.row.user .bubble em {
  color: color-mix(in srgb, #fff 60%, var(--gold-3));
  text-shadow: none;
}
.row.user .bubble em::before { color: color-mix(in srgb, #fff 55%, var(--gold-2)); }
.bubble strong {
  font-weight: 700;
  color: color-mix(in srgb, var(--gold-3) 70%, var(--ink));
  letter-spacing: 0.008em;
}

/* typewriter caret while a live reply streams in */
.bubble.is-typing > :last-child::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.14em;
  border-radius: 1px;
  background: linear-gradient(180deg, var(--emerald-bright), var(--gold));
  box-shadow: 0 0 8px rgba(20, 241, 149, 0.55);
  animation: caret-blink 0.9s steps(1) infinite;
}
@keyframes caret-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.row.bot .bubble {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(5, 14, 10, 0.52);
  -webkit-backdrop-filter: blur(20px) saturate(108%);
  backdrop-filter: blur(20px) saturate(108%);
  border-bottom-left-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 0 1px rgba(214, 182, 90, 0.08),
    0 10px 28px rgba(0, 0, 0, 0.32);
}
.row.user .bubble {
  background:
    linear-gradient(155deg, rgba(214, 182, 90, 0.16), rgba(214, 182, 90, 0.04)),
    rgba(8, 18, 12, 0.56);
  -webkit-backdrop-filter: blur(20px) saturate(108%);
  backdrop-filter: blur(20px) saturate(108%);
  border-color: rgba(214, 182, 90, 0.26);
  border-bottom-right-radius: 8px;
}

.chat-stage .row.bot .bubble,
.chat-stage .row.user .bubble {
  -webkit-backdrop-filter: blur(20px) saturate(108%);
  backdrop-filter: blur(20px) saturate(108%);
}
.row.system .bubble {
  background: linear-gradient(160deg, rgba(249, 126, 126, 0.12), rgba(0, 0, 0, 0.15));
  border-color: rgba(249, 126, 126, 0.28);
  color: #ffd0d0;
  font-size: 13px;
}

/* thinking indicator — shimmer text + spark, no plain dots */
.row.thinking .bubble { display: flex; align-items: center; gap: 10px; }
.think-spark {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold), var(--emerald-bright));
  box-shadow: 0 0 12px var(--gold-dim), 0 0 22px rgba(20, 241, 149, 0.3);
  animation: spark-pulse 1.4s ease-in-out infinite;
  flex: none;
}
@keyframes spark-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
.think-label {
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(90deg, var(--emerald-bright), var(--gold), var(--emerald-bright));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer-text 2.2s linear infinite;
}
@keyframes shimmer-text { to { background-position: -200% 0; } }

.retry-btn {
  margin-left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(249, 126, 126, 0.4);
  background: transparent;
  color: #ffd0d0;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.hero-empty { margin: auto; text-align: center; padding: 24px; animation: view-enter 0.5s var(--ease-out) both; }
.hero-empty .avatar { width: 74px; height: 74px; border-radius: 22px; font-size: 28px; margin: 0 auto 12px; }
.hero-empty h2 { margin: 0 0 6px; font-size: 20px; }
.hero-empty p { margin: 0 0 16px; color: var(--ink-dim); font-size: 14px; max-width: 380px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(20, 241, 149, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease;
}
.chip:hover { border-color: var(--gold-dim); color: var(--ink); box-shadow: 0 0 16px rgba(214, 182, 90, 0.14); }

.composer-wrap { padding: 12px 20px 20px; }

/* action bar under the text box — scene photo, regenerate, continue, ideas */
.composer-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.composer-actions::-webkit-scrollbar { display: none; }
.act-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 14px rgba(0, 0, 0, 0.24);
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s var(--ease-spring),
    border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.act-btn svg { flex: none; opacity: 0.85; }
.act-btn:hover {
  color: var(--emerald-bright);
  border-color: rgba(20, 241, 149, 0.34);
  background: linear-gradient(150deg, rgba(20, 241, 149, 0.12), rgba(20, 241, 149, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 6px 18px rgba(0, 0, 0, 0.3),
    0 0 16px rgba(20, 241, 149, 0.14);
}
.act-btn:active {
  transform: scale(0.95);
  transition-duration: 0.1s;
  transition-timing-function: var(--ease-out);
}
.act-btn:disabled { opacity: 0.45; cursor: default; }
.act-btn:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }
#act-photo:hover { color: var(--gold); border-color: rgba(214, 182, 90, 0.4); }

/* tiny voice play button above a bot message */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 0 0 7px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(20, 241, 149, 0.3);
  background: rgba(20, 241, 149, 0.1);
  color: var(--emerald-bright);
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring), background 0.2s ease, box-shadow 0.2s ease;
}
.tts-btn:hover {
  background: rgba(20, 241, 149, 0.2);
  box-shadow: 0 0 12px rgba(20, 241, 149, 0.3);
}
.tts-btn:active { transform: scale(0.88); }
.tts-btn:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }
.tts-btn.is-playing {
  background: rgba(20, 241, 149, 0.28);
  animation: tts-pulse 1.1s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(20, 241, 149, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(20, 241, 149, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .tts-btn.is-playing { animation: none; }
}
.act-btn.is-active {
  color: var(--emerald-bright);
  border-color: rgba(20, 241, 149, 0.5);
  background: linear-gradient(150deg, rgba(20, 241, 149, 0.2), rgba(20, 241, 149, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 18px rgba(20, 241, 149, 0.22);
}

/* inline generated scene image */
.bubble-image { padding: 6px !important; }
.chat-image {
  display: block;
  width: min(320px, 68vw);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 2px);
  background: rgba(0, 0, 0, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  .act-btn:active { transform: none; }
}

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--card-radius-lg);
  transition: box-shadow 0.3s ease;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)), rgba(4, 10, 7, 0.42);
  -webkit-backdrop-filter: blur(24px) saturate(108%);
  backdrop-filter: blur(24px) saturate(108%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--glass-shadow-inset-top), var(--glass-shadow-inset-bottom), 0 12px 36px rgba(0, 0, 0, 0.32);
}
/* a gold wisp slides through the composer while the character thinks */
.composer::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold-3) 50%, transparent);
  opacity: 0;
  transform: translateX(-100%);
}
.composer.composing::after {
  opacity: 0.75;
  animation: wisp-slide 2.4s var(--ease-out) infinite;
}
@keyframes wisp-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
.composer:focus-within {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 0 0 1px rgba(20, 241, 149, 0.3), 0 0 24px rgba(20, 241, 149, 0.1);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 0;
  max-height: 120px;
  outline: none;
}
.composer textarea::placeholder { color: var(--ink-faint); }

/* ================= CREATE — Character Forge ================= */

.forge-head { flex: none; padding: 6px 4px 0; }

.forge-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  flex: none;
  align-items: stretch;
}
@media (min-width: 980px) {
  .forge-wrap.forge-studio,
  .forge-studio {
    grid-template-columns: 55fr 45fr;
    gap: 32px;
    align-items: start;
  }
}

.forge {
  flex: none;
  padding: 28px;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  isolation: auto;
  background: var(--glass-fill), rgba(3, 8, 6, 0.3);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 20px 60px rgba(0, 0, 0, 0.4);
}

.forge-preview {
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  isolation: auto;
  background: var(--glass-fill), rgba(3, 8, 6, 0.32);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 20px 60px rgba(0, 0, 0, 0.4);
}

.forge-preview-sticky {
  position: sticky;
  top: 88px;
}
.fp-stage { position: relative; width: 128px; height: 128px; margin-bottom: 4px; }
.fp-ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(214, 182, 90, 0.3);
  animation: ring-pulse 7s ease-in-out infinite;
}
.fp-portrait {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 800;
  color: rgba(255, 224, 138, 0.5);
  background:
    radial-gradient(circle at 35% 30%, rgba(20, 241, 149, 0.25), transparent 60%),
    linear-gradient(160deg, var(--emerald-0), var(--void-2));
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(214, 182, 90, 0.35);
  box-shadow: 0 0 34px rgba(20, 241, 149, 0.15), 0 14px 30px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.6s ease;
}
.forge-preview.alive .fp-portrait {
  box-shadow:
    0 0 58px rgba(214, 182, 90, 0.38),
    0 0 28px rgba(20, 241, 149, 0.22),
    0 14px 30px rgba(0, 0, 0, 0.5);
}
.fp-portrait.has-image { color: transparent; }
.fp-name { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.fp-trait-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  max-width: 320px;
}
.fp-trait-chips:empty { display: none; }
.fp-trait-chips .fp-trait-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--gold-3);
  border: 1px solid rgba(214, 182, 90, 0.45);
  background: rgba(214, 182, 90, 0.1);
  box-shadow: 0 0 12px rgba(214, 182, 90, 0.15);
}
.fp-hook { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-dim); font-style: italic; max-width: 300px; }
.fp-core {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
}
.fp-chip {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(20, 241, 149, 0.1);
  background: rgba(2, 5, 4, 0.45);
  padding: 9px 11px;
  text-align: start;
  min-width: 0;
}
.fp-k {
  display: block;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 3px;
}
.fp-v {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.field.check { flex-direction: row; align-items: center; gap: 9px; }
.field.check .field-label { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink-dim); }
.field.check.small span { font-size: 12px; color: var(--ink-dim); }
.field.check input[type="checkbox"] { accent-color: var(--emerald); width: 16px; height: 16px; }

.field-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .field-grid { grid-template-columns: repeat(3, 1fr); } }

.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(20, 241, 149, 0.14);
  background: rgba(3, 8, 6, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
  resize: vertical;
}
.input:focus { border-color: rgba(20, 241, 149, 0.4); box-shadow: 0 0 0 1px rgba(20, 241, 149, 0.25), 0 0 18px rgba(20, 241, 149, 0.08); }
select.input { appearance: none; cursor: pointer; }

/* personality tag chip picker */
.personality-picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(20, 241, 149, 0.12);
  background:
    var(--glass-fill),
    rgba(3, 8, 6, 0.42);
  -webkit-backdrop-filter: blur(var(--glass-blur-soft)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur-soft)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow-inset-top), inset 0 0 0 1px rgba(214, 182, 90, 0.06);
}
.tag-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tag-group-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.tag-group-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.personality-tag {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(20, 241, 149, 0.16);
  background: rgba(3, 8, 6, 0.55);
  color: var(--ink-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.25s ease, background 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-out);
}
.personality-tag:hover {
  border-color: rgba(214, 182, 90, 0.35);
  color: var(--ink);
  background: rgba(8, 47, 34, 0.45);
}
.personality-tag:focus-visible {
  outline: none;
  border-color: rgba(214, 182, 90, 0.5);
  box-shadow: 0 0 0 1px rgba(214, 182, 90, 0.35), 0 0 16px rgba(214, 182, 90, 0.12);
}
.personality-tag.is-selected {
  border-color: rgba(214, 182, 90, 0.72);
  color: var(--gold-3);
  background: rgba(214, 182, 90, 0.14);
  box-shadow:
    0 0 0 1px rgba(214, 182, 90, 0.28),
    0 0 18px rgba(214, 182, 90, 0.22),
    inset 0 1px 0 rgba(255, 224, 138, 0.12);
}

.btn-gold.big { align-self: flex-start; padding: 13px 26px; font-size: 15px; }

.forge-steps {
  margin: 0;
  padding: 4px 2px 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.forge-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-faint);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out), color 0.3s ease;
}
.forge-step.on { opacity: 1; transform: none; color: var(--ink-dim); }
.forge-step.done { color: var(--emerald-dim); }
.forge-step .step-orb {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  flex: none;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.forge-step.on .step-orb { background: var(--gold); box-shadow: 0 0 10px var(--gold-dim); animation: spark-pulse 1.2s ease-in-out infinite; }
.forge-step.done .step-orb { background: var(--emerald-bright); border-color: transparent; box-shadow: 0 0 8px rgba(20, 241, 149, 0.4); animation: none; }

/* forge ritual — forging state + overlay */
.forge-forging .fp-ring {
  animation: forge-ring-glow 2.8s ease-in-out infinite;
  border-color: rgba(214, 182, 90, 0.55);
}
@keyframes forge-ring-glow {
  0%, 100% { opacity: 0.82; box-shadow: 0 0 14px rgba(214, 182, 90, 0.28); }
  50% { opacity: 1; box-shadow: 0 0 32px rgba(214, 182, 90, 0.58), 0 0 52px rgba(20, 241, 149, 0.14); }
}

.forge-forging .fp-portrait {
  animation: forge-portrait-glow 2.8s ease-in-out infinite;
}
@keyframes forge-portrait-glow {
  0%, 100% { box-shadow: 0 0 34px rgba(20, 241, 149, 0.15), 0 14px 30px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 0 48px rgba(214, 182, 90, 0.35), 0 0 24px rgba(20, 241, 149, 0.22), 0 14px 30px rgba(0, 0, 0, 0.5); }
}

.forge-preview.alive.card-reveal {
  animation: forge-card-reveal 0.7s var(--ease-out) both;
}
.forge-preview.alive.card-reveal .fp-portrait {
  animation: none;
  box-shadow:
    0 0 58px rgba(214, 182, 90, 0.38),
    0 0 28px rgba(20, 241, 149, 0.22),
    0 14px 30px rgba(0, 0, 0, 0.5);
}

.forge-ritual {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--radius-xl);
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
}
.forge-ritual.is-active {
  display: block !important;
  opacity: 1;
}

.forge-ritual-fog {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, var(--fog-gold-2) 0%, transparent 70%),
    radial-gradient(ellipse 70% 50% at 50% 50%, var(--fog-green-2) 0%, transparent 65%);
  opacity: 0;
  transform: none;
  animation: forge-fog-breathe 5s ease-in-out infinite;
}
.forge-ritual.is-active .forge-ritual-fog { opacity: 0.55; }
@keyframes forge-fog-breathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.65; }
}

.forge-ritual-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.forge-ritual-particles::before,
.forge-ritual-particles::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold-3);
  opacity: 0;
  box-shadow:
    -120px 40px 0 0 rgba(255, 224, 138, 0.75),
    -80px 10px 0 0 rgba(214, 182, 90, 0.65),
    -40px 60px 0 0 rgba(255, 224, 138, 0.55),
    -10px 25px 0 0 rgba(214, 182, 90, 0.7),
    20px 50px 0 0 rgba(255, 224, 138, 0.6),
    55px 15px 0 0 rgba(214, 182, 90, 0.5),
    90px 45px 0 0 rgba(255, 224, 138, 0.65),
    130px 20px 0 0 rgba(214, 182, 90, 0.55);
  animation: forge-particles-rise 4.5s ease-in infinite;
}
.forge-ritual-particles::after {
  animation-delay: 2.2s;
  box-shadow:
    -100px 30px 0 0 rgba(214, 182, 90, 0.6),
    -60px 55px 0 0 rgba(255, 224, 138, 0.5),
    -25px 12px 0 0 rgba(214, 182, 90, 0.7),
    15px 38px 0 0 rgba(255, 224, 138, 0.55),
    50px 8px 0 0 rgba(214, 182, 90, 0.65),
    85px 52px 0 0 rgba(255, 224, 138, 0.5),
    115px 28px 0 0 rgba(214, 182, 90, 0.6);
}
.forge-ritual.is-active .forge-ritual-particles::before,
.forge-ritual.is-active .forge-ritual-particles::after { opacity: 1; }
@keyframes forge-particles-rise {
  0% { transform: translate(-50%, 0) scale(1); opacity: 0; }
  12% { opacity: 0.85; }
  88% { opacity: 0.35; }
  100% { transform: translate(-50%, -115%) scale(0.6); opacity: 0; }
}

/* ---- conjuration core: rotating rings + energy orb + converging sparks ---- */
.forge-ritual-core {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  transition: opacity 0.5s var(--ease-out), transform 0.6s var(--ease-spring);
}
.forge-ritual.is-active .forge-ritual-core { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.frc-ring {
  position: absolute;
  inset: 0;
  margin: auto;
  border-radius: 50%;
  border: 1.5px solid transparent;
}
.frc-ring-1 {
  width: 220px; height: 220px;
  border-top-color: rgba(20, 241, 149, 0.85);
  border-right-color: rgba(20, 241, 149, 0.35);
  box-shadow: 0 0 26px rgba(20, 241, 149, 0.28), inset 0 0 22px rgba(20, 241, 149, 0.14);
  animation: forge-ring-slow 12s linear infinite;
}
.frc-ring-2 {
  width: 158px; height: 158px;
  border-bottom-color: rgba(214, 182, 90, 0.9);
  border-left-color: rgba(214, 182, 90, 0.4);
  box-shadow: 0 0 22px rgba(214, 182, 90, 0.3);
  animation: forge-ring-slow 16s linear infinite reverse;
}
.frc-ring-3 {
  width: 104px; height: 104px;
  border-top-color: rgba(255, 255, 255, 0.7);
  border-right-color: rgba(20, 241, 149, 0.5);
  animation: forge-ring-slow 10s linear infinite;
}
.frc-glyphs {
  position: absolute;
  inset: 0; margin: auto;
  width: 190px; height: 190px;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg,
      transparent 0deg 14deg,
      rgba(214, 182, 90, 0.5) 14deg 15deg,
      transparent 15deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 78px, #000 80px, #000 92px, transparent 94px);
  mask: radial-gradient(circle, transparent 78px, #000 80px, #000 92px, transparent 94px);
  animation: forge-ring-slow 24s linear infinite reverse;
  opacity: 0.7;
}
@keyframes forge-ring-slow { to { transform: rotate(360deg); } }
.frc-orb {
  position: absolute;
  inset: 0; margin: auto;
  width: 62px; height: 62px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 38%, #ffffff 0%, var(--gold) 32%, var(--emerald-bright) 66%, rgba(20, 241, 149, 0) 100%);
  box-shadow: 0 0 40px rgba(20, 241, 149, 0.6), 0 0 70px rgba(214, 182, 90, 0.4);
  animation: forge-orb-glow 3.2s ease-in-out infinite;
}
@keyframes forge-orb-glow {
  0%, 100% { transform: scale(0.94); filter: brightness(0.98); }
  50% { transform: scale(1.04); filter: brightness(1.12); }
}
.frc-spark {
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold-3);
  box-shadow: 0 0 10px rgba(255, 224, 138, 0.9);
  opacity: 0;
  animation: forge-spark-in 2.2s ease-in infinite;
}
.frc-spark-1 { --sx: -130px; --sy: -70px; animation-delay: 0s; }
.frc-spark-2 { --sx: 120px; --sy: -90px; animation-delay: 0.55s; background: var(--emerald-bright); }
.frc-spark-3 { --sx: -110px; --sy: 95px; animation-delay: 1.1s; }
.frc-spark-4 { --sx: 135px; --sy: 80px; animation-delay: 1.65s; background: var(--emerald-bright); }
@keyframes forge-spark-in {
  0% { transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(1); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
}

.forge-ritual-label {
  position: absolute;
  left: 50%;
  top: 82%;
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-3);
  text-shadow: 0 0 16px rgba(214, 182, 90, 0.5);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: forge-label-pulse 2.4s ease-in-out infinite;
}
.forge-ritual.is-active .forge-ritual-label { opacity: 1; }
@keyframes forge-label-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.forge-result.card-reveal {
  animation: forge-card-reveal 0.65s var(--ease-out) both;
}
@keyframes forge-card-reveal {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

/* the character materializes: blur-in + luminous sweep across the card */
.forge-result.card-reveal .fr-card-host .character-card {
  animation: forge-materialize 0.95s var(--ease-out) both;
  position: relative;
}
@keyframes forge-materialize {
  0% { opacity: 0; transform: translateY(12px); filter: blur(10px) brightness(1.3); }
  60% { opacity: 1; filter: blur(1px) brightness(1.08); }
  100% { opacity: 1; transform: none; filter: none; }
}
.forge-result.card-reveal .fr-card-host .character-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.5) 48%, rgba(20, 241, 149, 0.35) 52%, transparent 70%);
  background-size: 260% 100%;
  animation: forge-sweep 0.95s var(--ease-out) both;
}
@keyframes forge-sweep {
  0% { background-position: 160% 0; opacity: 0; }
  25% { opacity: 1; }
  100% { background-position: -80% 0; opacity: 0; }
}

.forge-result.is-new {
  animation: forge-celebrate 1.4s ease-out both;
}
@keyframes forge-celebrate {
  0% { box-shadow: inset 0 0 0 2px rgba(214, 182, 90, 0.85), 0 0 32px rgba(214, 182, 90, 0.35); opacity: 1; }
  40% { box-shadow: inset 0 0 0 1px rgba(214, 182, 90, 0.45), 0 0 18px rgba(214, 182, 90, 0.18); opacity: 1; }
  100% { box-shadow: none; opacity: 1; }
}

.a11y-off {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.forge-result { flex: none; padding: 0; animation: view-enter 0.5s var(--ease-out) both; }

.forge-result-wide {
  max-width: var(--content-max);
  margin: 32px auto 0;
  width: 100%;
}

.fr-card-host { margin-bottom: 28px; }

.fr-detail-label {
  margin: 0 0 14px;
  padding: 0 4px;
}

/* ================= PREMIUM CHARACTER CARD ================= */

.character-card {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  animation: view-enter 0.55s var(--ease-out) both;
}

.character-card-compact {
  border-radius: var(--radius-lg);
}

.cc-glow {
  position: absolute;
  inset: -20% -10%;
  background:
    radial-gradient(ellipse 55% 45% at 18% 38%, rgba(20, 241, 149, 0.14), transparent 68%),
    radial-gradient(ellipse 45% 40% at 82% 72%, rgba(214, 182, 90, 0.12), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.cc-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

@media (min-width: 720px) {
  .cc-inner {
    grid-template-columns: minmax(200px, 34%) 1fr;
    min-height: 320px;
  }
  .character-card-compact .cc-inner {
    grid-template-columns: 1fr;
    min-height: 0;
  }
}

.cc-portrait-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px 20px;
  background: linear-gradient(165deg, rgba(3, 12, 8, 0.55), rgba(3, 8, 6, 0.15));
  border-bottom: 1px solid rgba(20, 241, 149, 0.08);
}

@media (min-width: 720px) {
  .cc-portrait-col {
    padding: 32px 28px;
    border-bottom: none;
    border-right: 1px solid rgba(20, 241, 149, 0.08);
  }
}

.cc-stage {
  position: relative;
  width: min(100%, 220px);
  aspect-ratio: 3 / 4;
}

/* Compact card = poster: full-width portrait on top, info below, equal heights.
   (Previously a small square in a narrow side column left awkward empty space.) */
.character-card-compact { height: 100%; }
.character-card-compact .cc-inner {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  height: 100%;
}
.character-card-compact .cc-portrait-col {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  border-right: none;
  border-bottom: 1px solid rgba(20, 241, 149, 0.1);
}
.character-card-compact .cc-stage {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  min-height: 0;
}
.character-card-compact .cc-portrait {
  inset: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
.character-card-compact .cc-ring { display: none; }
.character-card-compact .cc-smoke { display: none; }
.character-card-compact .cc-mono { font-size: 3rem; }

.cc-smoke {
  position: absolute;
  inset: 6% -14%;
  background: radial-gradient(ellipse, rgba(20, 241, 149, 0.2), transparent 64%);
  filter: blur(36px);
  animation: smoke-c 20s ease-in-out infinite alternate;
}

.cc-ring {
  position: absolute;
  inset: 8%;
  border: 1px solid rgba(214, 182, 90, 0.22);
  border-radius: 50%;
  animation: ring-pulse 8s ease-in-out infinite;
}

.cc-portrait {
  position: absolute;
  inset: 10% 8% 4%;
  border-radius: var(--radius-lg);
  background: var(--avatar-grad, linear-gradient(160deg, var(--emerald-deep), var(--void-3)));
  background-size: cover;
  background-position: center;
  border: 2px solid rgba(214, 182, 90, 0.34);
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.55),
    0 0 36px rgba(20, 241, 149, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-size: clamp(2.8rem, 8vw, 4rem);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.28);
  z-index: 2;
}

.cc-portrait.has-image { color: transparent; }

.cc-mono { pointer-events: none; user-select: none; }

.cc-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 24px 26px;
}

.character-card-compact .cc-body {
  padding: 16px 18px;
  gap: 8px;
}

.cc-badge {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.cc-name {
  margin: 0;
  font-size: clamp(1.55rem, 3.2vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.12;
}

.character-card-compact .cc-name {
  font-size: 1.15rem;
}

.cc-hook {
  margin: 0;
  font-size: 15px;
  font-style: italic;
  color: var(--gold);
  line-height: 1.55;
}

.character-card-compact .cc-hook {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cc-tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--emerald-bright);
  background: rgba(15, 81, 56, 0.35);
  border: 1px solid rgba(20, 241, 149, 0.22);
}

.cc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.character-card-compact .cc-stats { display: none; }

.cc-stat {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(3, 8, 6, 0.42);
  border: 1px solid rgba(20, 241, 149, 0.1);
}

.cc-stat-k {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.cc-stat-v {
  display: block;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cc-greeting {
  margin: 2px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-dim);
  background: rgba(214, 182, 90, 0.06);
  border-left: 3px solid rgba(214, 182, 90, 0.45);
}

.character-card-compact .cc-greeting { display: none; }

.cc-greeting::before {
  content: "First words";
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  font-style: normal;
}

.cc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.cc-meta-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: capitalize;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cc-meta-chip.mem-on {
  color: var(--emerald-bright);
  border-color: rgba(20, 241, 149, 0.28);
  background: rgba(15, 81, 56, 0.28);
}

.character-card.is-clickable {
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  border: none;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.25s ease;
}

.character-card.is-clickable:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35), 0 0 24px rgba(20, 241, 149, 0.08);
}

.character-card.is-clickable:focus-visible {
  outline: 2px solid var(--emerald-bright);
  outline-offset: 3px;
}

.fr-name { margin: 0 0 4px; font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.02em; }
.fr-hook { margin: 0 0 16px; font-size: 15px; font-style: italic; color: var(--gold); line-height: 1.5; }

.fr-sections { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 0 4px; }
@media (min-width: 820px) { .fr-sections { grid-template-columns: 1fr 1fr; } }
.fr-section {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(3, 8, 6, 0.4);
  border: 1px solid rgba(20, 241, 149, 0.09);
}
.fr-section h4 {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.fr-section p,
.fr-section .fr-value { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-dim); white-space: pre-wrap; }
.fr-section .fr-name.fr-value { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.fr-section .fr-hook.fr-value { font-size: 15px; font-style: italic; color: var(--gold); line-height: 1.5; }
.fr-section.wide { grid-column: 1 / -1; }

.fr-section.is-editable { cursor: pointer; position: relative; }
.fr-section.is-editing {
  border-color: rgba(214, 182, 90, 0.45);
  box-shadow: 0 0 0 1px rgba(214, 182, 90, 0.25), 0 0 18px rgba(214, 182, 90, 0.12);
}
.fr-edit {
  width: 100%;
  min-height: 80px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(20, 241, 149, 0.18);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  line-height: 1.55;
  resize: vertical;
}
.fr-edit:focus { outline: none; border-color: rgba(214, 182, 90, 0.45); }
.fr-edit-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(3, 8, 6, 0.65);
  color: var(--gold-dim);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.fr-section.is-editable:hover .fr-edit-btn,
.fr-section.is-editing .fr-edit-btn { opacity: 1; color: var(--gold); }
.fr-header-section { margin-bottom: 8px; background: transparent; border-color: transparent; padding: 0 0 4px; }
.fr-header-section.is-editing { padding: 14px 16px; background: rgba(3, 8, 6, 0.4); border-color: rgba(214, 182, 90, 0.45); }

.fr-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding: 0 4px 24px; }
.fr-note { margin: 12px 4px 0; font-size: 12px; color: var(--ink-faint); }

/* ================= BUTTONS ================= */

.btn-primary, .btn-gold, .btn-ghost, .btn-send, .btn-icon, .link-btn {
  font: inherit;
  cursor: pointer;
  border: none;
  transition: filter 0.18s ease, transform 0.14s var(--ease-spring), box-shadow 0.25s ease;
}
.btn-primary {
  padding: 12px 24px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--emerald-bright), var(--emerald));
  color: var(--void);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(20, 241, 149, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-gold {
  padding: 12px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--void);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(214, 182, 90, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 17px;
  border-radius: 999px;
  border: 1px solid rgba(20, 241, 149, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 600;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--gold-dim); box-shadow: 0 0 16px rgba(214, 182, 90, 0.12); }
.btn-ghost.full, .btn-primary.full { width: 100%; justify-content: center; display: inline-flex; }
.btn-ghost.back { align-self: flex-start; flex: none; position: relative; z-index: 2; }
/* clear the page-scroll top mask fade so the back button isn't clipped/overlapping */
#view-character .page-scroll { padding-top: 22px; }
.btn-primary:hover, .btn-gold:hover { filter: brightness(1.08); }
.btn-primary:active, .btn-gold:active, .btn-ghost:active { transform: scale(0.97); }
.btn-primary:disabled, .btn-gold:disabled { filter: saturate(0.35) brightness(0.8); cursor: default; }
.btn-primary:focus-visible, .btn-gold:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }

.btn-icon {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(20, 241, 149, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  font-size: 14px;
}
.btn-icon:hover { color: var(--ink); }

.btn-send {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(214, 182, 90, 0.55), rgba(214, 182, 90, 0.28));
  border: 1px solid rgba(214, 182, 90, 0.4);
  color: var(--void);
  box-shadow: 0 4px 14px rgba(214, 182, 90, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-send:disabled { opacity: 0.4; cursor: default; }

.link-btn { background: none; color: var(--emerald-dim); font-size: 12px; padding: 0; text-decoration: underline; }
.link-btn:hover { color: var(--emerald-bright); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 11px;
  flex: none;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--avatar-grad, linear-gradient(145deg, var(--emerald), var(--emerald-deep)));
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(214, 182, 90, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.avatar.has-image { color: transparent; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  border-radius: 999px;
  padding: 3px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
  flex: none;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  position: relative; z-index: 1;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  border-radius: 999px;
  cursor: pointer;
  text-align: center;
  user-select: none;
}
.segmented-thumb {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04)), rgba(214, 182, 90, 0.12);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(214, 182, 90, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.28s var(--ease-spring);
}
.segmented input:checked + label { color: var(--ink); font-weight: 800; }
.segmented.deep .segmented-thumb { transform: translateX(100%); }

/* ================= DOCK ================= */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(8px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 999px;
  width: min(360px, calc(100vw - 24px));
  background: var(--glass-fill), rgba(3, 8, 6, 0.42);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(130%);
  backdrop-filter: blur(var(--glass-blur)) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 16px 48px rgba(0, 0, 0, 0.48);
}

.dock-enhanced {
  padding: 10px 16px;
}

.dock-btn {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s ease, background 0.25s ease;
}
.dock-btn svg { opacity: 0.55; transition: opacity 0.25s ease; }
.dock-btn.dock-active,
.dock-btn.active {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)), rgba(8, 47, 34, 0.25);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 6px 18px rgba(0, 0, 0, 0.28);
}
.dock-enhanced .dock-btn.dock-active::after,
.dock-enhanced .dock-btn.active::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-dim);
}
.dock-btn.dock-active svg,
.dock-btn.active svg { opacity: 1; color: var(--emerald-bright); }
.dock-btn:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }

/* ================= MODALS & TOAST ================= */

.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; }
.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 6, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  width: min(470px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 22px;
  border-radius: var(--radius-xl);
  animation: view-enter 0.35s var(--ease-out) both;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-sub { margin: 8px 0 14px; font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* memory drawer */
.memory-drawer-card {
  width: min(540px, 100%);
  padding: 24px 24px 20px;
}
.memory-drawer .modal-sub { margin: 6px 0 16px; }
.memory-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}
/* bond band — ring + relationship stage + summary in one framed row */
.memory-drawer .memory-header-compact {
  gap: 15px;
  margin-bottom: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 14% 18%, rgba(20, 241, 149, 0.09), transparent 58%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.16));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.memory-drawer .memory-header-compact .memory-header-meta { gap: 6px; }

/* filters as a segmented control */
.memory-filters-drawer {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.memory-filters-drawer .memory-filter {
  flex: 1;
  text-align: center;
  padding: 7px 10px;
  border: none;
  background: transparent;
  box-shadow: none;
}
.memory-filters-drawer .memory-filter:hover { color: var(--ink-dim); background: rgba(255, 255, 255, 0.04); }
.memory-filters-drawer .memory-filter.is-active {
  border: none;
  background: linear-gradient(145deg, rgba(20, 241, 149, 0.18), rgba(20, 241, 149, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 16px rgba(0, 0, 0, 0.28);
}

.memory-drawer .memory-timeline-scroll {
  margin-top: 0;
  padding: 12px 12px 12px 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    radial-gradient(circle at 12% 6%, rgba(20, 241, 149, 0.045), transparent 46%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.025), rgba(0, 0, 0, 0.12));
}
.memory-drawer .memory-empty {
  margin: 0;
  align-self: center;
  max-width: 32ch;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  line-height: 1.6;
  padding: 40px 16px;
}
/* no timeline spine when there is nothing to plot on it */
.memory-timeline:has(> .memory-empty)::before { display: none; }

.portrait-stage { min-height: 50px; display: grid; place-items: center; margin: 12px 0 0; }
.portrait-stage img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-gold);
  animation: reveal 0.9s var(--ease-out) both;
}
@keyframes reveal {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}
.portrait-progress { display: none; text-align: center; }
.portrait-stage[data-state="busy"] .portrait-progress { display: grid; place-items: center; gap: 8px; padding: 12px 0; }
.ring-spin {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(20, 241, 149, 0.2);
  border-top-color: var(--gold);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.conjure { margin: 0; font-size: 12px; color: var(--ink-faint); }
.portrait-msg { font-size: 13px; color: var(--ink-dim); text-align: center; margin: 8px 0 0; }
.portrait-stage[data-state="error"] .portrait-msg { color: var(--danger); }

/* auth — the memory vault */
.auth-card.vault {
  border-color: rgba(214, 182, 90, 0.3);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 0 0 1px rgba(20, 241, 149, 0.06),
    0 24px 70px rgba(0, 0, 0, 0.65),
    0 0 60px rgba(214, 182, 90, 0.1);
  text-align: initial;
}
.vault-ring {
  position: relative;
  width: 66px;
  height: 66px;
  margin: 2px auto 14px;
  border-radius: 50%;
  border: 1px solid rgba(214, 182, 90, 0.45);
  display: grid;
  place-items: center;
}
.vault-ring::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px solid rgba(20, 241, 149, 0.18);
  animation: ring-pulse 6s ease-in-out infinite;
}
.vault-core {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-3), var(--gold-1));
  box-shadow: 0 0 18px rgba(214, 182, 90, 0.55);
}
.auth-card.vault .modal-head { justify-content: center; text-align: center; }
.auth-card.vault .modal-head .btn-icon { position: absolute; top: 16px; inset-inline-end: 16px; }
.auth-card.vault .modal-sub { text-align: center; }

.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.auth-tab {
  flex: 1;
  padding: 9px 10px;
  border-radius: 999px;
  border: 1px solid rgba(20, 241, 149, 0.12);
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.auth-tab.active {
  color: var(--ink);
  background: linear-gradient(135deg, rgba(15, 81, 56, 0.5), rgba(214, 182, 90, 0.12));
  border-color: rgba(20, 241, 149, 0.25);
}
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.auth-divider { text-align: center; color: var(--ink-faint); font-size: 11px; margin: 12px 0; letter-spacing: 0.3em; }
.auth-oauth { display: flex; flex-direction: column; gap: 8px; }
.auth-note { margin: 12px 0 0; font-size: 12px; color: var(--ink-faint); text-align: center; }
.auth-who { margin: 4px 0 10px; font-size: 14px; font-weight: 700; text-align: center; color: var(--ink); }

#auth-code { text-align: center; letter-spacing: 0.5em; font-size: 20px; font-weight: 700; }
textarea.input { resize: vertical; min-height: 84px; font: inherit; line-height: 1.5; }

.auth-admin {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line, #14f19533);
  border-radius: 14px;
  background: rgba(6, 20, 13, 0.5);
  text-align: left;
}
.auth-admin-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 8px; }
.auth-admin-title { font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold, #d6b65a); }
.auth-admin-stats { font-size: 12px; color: var(--ink-faint); }
.admin-accounts { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.admin-acct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.admin-acct-email { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-acct-badge { flex: none; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: var(--ink-faint); border: 1px solid var(--line, #14f19533); }
.admin-acct-badge.ok { color: var(--emerald, #14f195); border-color: #14f19566; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 16px);
  transform: translateX(-50%);
  z-index: 40;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  animation: view-enter 0.3s var(--ease-out) both;
  max-width: min(90vw, 460px);
  text-align: center;
}
.toast.error { border-color: rgba(249, 126, 126, 0.35); color: #ffd0d0; }

/* ================= RESPONSIVE ================= */

@media (max-width: 480px) {
  .guide-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
  }
  .guide-actions { width: 100%; }
  .guide-actions .btn-primary,
  .guide-actions .btn-ghost { flex: 1; justify-content: center; }
  .discover-quick { grid-template-columns: 1fr; }

  .chat-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding: 8px;
  }
  .chat-presence {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    text-align: left;
    padding: 10px 12px;
    gap: 8px;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .presence-frame { width: 52px; max-width: 52px; aspect-ratio: 1; }
}

@media (max-width: 880px) {
  .topnav { display: none; }
  .brand-sub { display: none; }
  .status-text { display: none; }

  .billboard { min-height: 300px; }
  .billboard-fade {
    background:
      linear-gradient(90deg, var(--glass-scrim-heavy) 0%, var(--glass-scrim-mid) 55%, var(--glass-scrim-light) 100%),
      linear-gradient(0deg, var(--glass-scrim-heavy) 0%, var(--glass-scrim-veil) 32%, transparent 55%);
  }
  .bb-mono { left: 78%; top: 30%; }

  .card { width: 188px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .billboard { min-height: 340px; }
  .billboard-body { padding: 22px 20px 22px; }

  /* Phone chat: collapse the side rail into a slim identity strip so the
     conversation gets the full screen. Memories live behind the drawer btn. */
  .chat-stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; padding: 8px; gap: 8px; }
  .chat-presence {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    text-align: left;
    padding: 8px 12px;
    gap: 11px;
    overflow: visible;
  }
  .presence-frame { width: 42px; max-width: 42px; aspect-ratio: 1; }
  .presence-aura { display: none; }
  .presence-name { flex: 1; min-width: 0; font-size: 15px; margin: 0; }
  .presence-mood,
  #presence-tags,
  .presence-memory-wrap,
  .chat-presence .btn-ghost.full { display: none; }
  .segmented { max-width: 168px; margin-left: auto; flex: none; }

  .hero-stage { width: min(64%, 240px); }
  .row { max-width: 92%; }

  .fr-actions .btn-primary, .fr-actions .btn-gold { flex: 1; }
}

/* RTL */
[dir="rtl"] .billboard-fade {
  background:
    linear-gradient(270deg, var(--glass-scrim-heavy) 0%, var(--glass-scrim-mid) 45%, var(--glass-scrim-light) 80%),
    linear-gradient(0deg, var(--glass-scrim-heavy) 0%, var(--glass-scrim-veil) 28%, transparent 45%);
}
[dir="rtl"] .bb-mono { left: 28%; }
[dir="rtl"] .back svg { transform: scaleX(-1); }
[dir="rtl"] .layout-split,
[dir="rtl"] .char-hero {
  direction: rtl;
}
@media (min-width: 980px) {
  [dir="rtl"] .layout-split,
  [dir="rtl"] .char-hero {
    grid-template-columns: 3fr 2fr;
  }
}

/* ================= LIQUID GLASS ================= */
/* Web analogue of UIKit UIGlassEffect / UIGlassContainerEffect: crisp
   refractive rims, pointer-tracked interactive specular, and a morphing
   dock "container" that merges the tabs into one liquid pill. */

.lg-defs { position: absolute; width: 0; height: 0; pointer-events: none; }

/* Sharper Apple-style edge on every glass surface */
.glass, .glass-strong, .glass-soft, .glass-float, .dock, .composer {
  border-color: rgba(255, 255, 255, 0.3);
}
.glass::before, .glass-strong::before, .glass-soft::before, .glass-float::before {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1.5px 1px rgba(255, 255, 255, 0.14),
    inset 1px 0 0 rgba(255, 255, 255, 0.12),
    inset -1px 0 0 rgba(255, 255, 255, 0.12);
}

/* Static glass definition on interactive surfaces — fixed top specular +
   chromatic edge. No pointer/hover tracking. */
.lg-interactive {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.lg-interactive > * { position: relative; z-index: 2; }
.lg-interactive::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    60% 68% at 50% 0%,
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0.14) 40%,
    transparent 72%
  );
  box-shadow:
    inset 2px 2px 0 rgba(94, 236, 192, 0.6),
    inset -2px -2px 0 rgba(214, 182, 90, 0.52),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  opacity: 0.42;
  mix-blend-mode: screen;
}
.lg-interactive:active { transform: scale(0.968); }

/* Dock = UIGlassContainerEffect — the pill merges the tabs; a single liquid
   highlight morphs to whichever tab is active. */
.dock-btn { z-index: 1; }
.dock-liquid {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.3), rgba(94, 236, 192, 0.08) 46%, rgba(8, 47, 34, 0.42));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.7),
    inset 2px 0 0 rgba(94, 236, 192, 0.35),
    inset -2px 0 0 rgba(214, 182, 90, 0.3),
    inset 0 -2px 8px rgba(0, 0, 0, 0.25),
    0 8px 22px rgba(0, 0, 0, 0.36),
    0 0 34px rgba(20, 241, 149, 0.28);
  transition:
    transform 0.5s var(--ease-spring),
    width 0.5s var(--ease-spring),
    height 0.5s var(--ease-spring),
    opacity 0.3s ease;
}
.dock-liquid::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.42), transparent 44%, transparent 60%, rgba(214, 182, 90, 0.22));
  filter: url(#lg-liquid);
  opacity: 0.8;
}
.dock-liquid.ready { opacity: 1; }
.dock-btn.dock-active,
.dock-btn.active {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
.dock-enhanced .dock-btn.dock-active::after,
.dock-enhanced .dock-btn.active::after { display: none; }

/* Chromatic dispersion — narrow 3D border that splits into emerald / gold at
   opposing edges, fading in with the specular on hover/touch (lensing). */
.lg-interactive::after {
  box-shadow:
    inset 1.5px 1.5px 0 rgba(94, 236, 192, 0.42),
    inset -1.5px -1.5px 0 rgba(214, 182, 90, 0.36);
}

/* Retained-color icons — nav/dock glyphs hold an emerald hue instead of
   desaturating into the blur (edge-to-edge "physically alive" feel). */
.dock-btn svg { color: var(--emerald-dim); opacity: 0.6; }

/* Black Glass modal — signature dark gradient mask over frosted glass:
   crisp dark top → pure clear glass bottom. Sits above the glass blur, below
   the modal content. */
.modal-card { isolation: isolate; }
.modal-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(2, 5, 4, 0.74) 0%,
    rgba(2, 5, 4, 0.3) 44%,
    transparent 100%
  );
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(214, 182, 90, 0.18);
}

/* ================= MOTION PREFERENCES ================= */

@media (prefers-reduced-motion: reduce) {
  .lg-interactive::after { transition: none; }
  .dock-liquid { transition: opacity 0.2s ease; }
  .layer, .card, .view, .row, .breathe, .presence-portrait.breathe, .think-spark, .think-label,
  .toast, .modal-card, .forge-result, .hero-smoke, .hero-ring, .presence-aura,
  .portrait-stage img, .step-orb, .hero-empty, .fp-ring, .vault-ring::before,
  .composer.composing::after,
  .memory-card.is-new,
  .memory-timeline .memory-node.is-new,
  .forge-ritual-fog, .forge-ritual-label, .forge-forging .fp-ring, .forge-forging .fp-portrait,
  .forge-preview.alive.card-reveal, .forge-preview.alive.card-reveal .fp-portrait,
  .forge-result.is-new {
    animation: none !important;
  }
  .forge-ritual-particles::before,
  .forge-ritual-particles::after { animation: none !important; opacity: 0 !important; }
  .forge-result.card-reveal { animation: none !important; opacity: 1 !important; transform: none !important; }
  .forge-preview.alive.card-reveal { opacity: 1 !important; transform: none !important; }
  .forge-result.card-reveal .fr-card-host .character-card { animation: none !important; filter: none !important; transform: none !important; opacity: 1 !important; }
  .forge-result.card-reveal .fr-card-host .character-card::after { display: none !important; }
  .frc-ring, .frc-orb, .frc-spark, .frc-glyphs, .memory-empty::before { animation: none !important; }
  .transcript { scroll-behavior: auto; }
  .card, .card-media, .segmented-thumb, .billboard-media, .forge-step, .glass-float { transition: none; }
  .forge-step { opacity: 1; transform: none; }
}

/* Manual "Reduce motion" toggle (Settings) — mirror the media query globally. */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ============================================================
   SETTINGS MODAL + CONVERSATIONS DRAWER
   ============================================================ */
.settings-card, .chats-drawer-card {
  width: min(560px, 94vw);
  max-height: min(86dvh, 760px);
  display: flex;
  flex-direction: column;
}
.settings-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-right: 4px;
  margin-top: 8px;
}
.settings-group { display: flex; flex-direction: column; gap: 6px; }
.settings-legend { margin: 0 0 6px; letter-spacing: 0.14em; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 15px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--void-2) 55%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.settings-row + .settings-row { margin-top: 8px; }
.settings-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-label { font-weight: 600; color: var(--ink); font-size: 0.95rem; }
.settings-hint { font-size: 0.78rem; color: var(--ink-dim); }
.settings-select { width: auto; min-width: 120px; padding: 8px 12px; }
.settings-about { text-align: center; font-size: 0.76rem; color: var(--ink-dim); opacity: 0.7; margin: 4px 0 0; }

/* toggle switch */
.switch {
  position: relative;
  width: 46px; height: 27px;
  flex: none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: color-mix(in srgb, var(--void-3) 70%, transparent);
  cursor: pointer;
  transition: background 0.22s var(--ease-out), border-color 0.22s var(--ease-out);
}
.switch-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #d8ddd9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.22s var(--ease-out);
}
.switch[aria-checked="true"] {
  background: linear-gradient(180deg, var(--emerald-bright), var(--emerald-1));
  border-color: color-mix(in srgb, var(--emerald-bright) 60%, transparent);
}
.switch[aria-checked="true"] .switch-knob { transform: translateX(19px); }
.switch:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }

/* mini segmented (default mode) */
.settings-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--void-3) 70%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex: none;
}
.settings-seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.settings-seg-btn.is-active {
  color: #04120b;
  background: linear-gradient(180deg, var(--emerald-bright), var(--emerald-1));
}
.settings-seg-btn:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }

.btn-ghost.danger { color: color-mix(in srgb, #ff8a7a 78%, var(--ink)); border-color: rgba(255, 120, 100, 0.3); }
.btn-ghost.danger:hover { background: rgba(255, 90, 70, 0.12); }

/* Conversations list */
.chats-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  min-height: 80px;
  max-height: 56dvh;
  padding-right: 4px;
}
.chat-row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--void-2) 52%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), background 0.2s, border-color 0.2s;
}
.chat-row:hover {
  background: color-mix(in srgb, var(--emerald-1) 14%, var(--void-2));
  border-color: color-mix(in srgb, var(--emerald-bright) 34%, transparent);
}
.chat-row:active { transform: scale(0.985); }
.chat-row:focus-visible { outline: 2px solid var(--emerald-bright); outline-offset: 2px; }
.chat-row-avatar {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 13px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(214, 182, 90, 0.34);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--gold-3);
  overflow: hidden;
}
.chat-row-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.chat-row-name { font-weight: 650; color: var(--ink); font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-time { font-size: 0.72rem; color: var(--ink-dim); flex: none; }
.chat-row-snippet { font-size: 0.82rem; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chats-empty { text-align: center; color: var(--ink-dim); padding: 24px 8px; font-size: 0.9rem; }

@media (max-width: 560px) {
  .settings-row { flex-wrap: wrap; }
  .settings-row .settings-select,
  .settings-row .settings-seg { margin-left: auto; }
}

/* ================= FORGE — character type selector ================= */
.forge-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.forge-type {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 14px 14px 15px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(8, 47, 34, 0.12));
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s var(--ease-out), box-shadow 0.2s ease, background 0.2s ease;
}
.forge-type:hover { transform: translateY(-2px); border-color: rgba(20, 241, 149, 0.4); }
.forge-type.is-active {
  border-color: var(--emerald, #14f195);
  background: linear-gradient(160deg, rgba(20, 241, 149, 0.16), rgba(8, 47, 34, 0.2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 0 1px rgba(20, 241, 149, 0.35), 0 10px 30px rgba(0, 0, 0, 0.4);
}
.ft-glyph { font-size: 20px; color: var(--gold, #d6b65a); line-height: 1; }
.ft-title { font-weight: 800; font-size: 15px; }
.ft-desc { font-size: 12px; color: var(--ink-dim); line-height: 1.35; }

.forge-mode { display: block; }
.forge-mode[hidden] { display: none !important; }

.field-hint { font-size: 11px; color: var(--ink-faint); font-weight: 500; }
.input.file { padding: 10px 12px; cursor: pointer; }
.input.file::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(20, 241, 149, 0.35);
  background: rgba(20, 241, 149, 0.1);
  color: var(--emerald-bright, #14f195);
  font: inherit;
  cursor: pointer;
}

.forge-soon {
  margin-top: 6px;
  padding: 16px;
  border: 1px dashed rgba(214, 182, 90, 0.35);
  border-radius: 14px;
  background: rgba(214, 182, 90, 0.05);
}
.forge-soon-title { margin: 0 0 12px; font-weight: 800; color: var(--gold, #d6b65a); font-size: 13px; letter-spacing: 0.04em; }
.forge-soon-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.soon-chip {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
}
.forge-soon .field-hint { margin: 0; }

@media (max-width: 640px) {
  .forge-types { grid-template-columns: 1fr; gap: 8px; }
  .forge-type { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .ft-desc { flex-basis: 100%; }
}

/* Admin broadcast composer */
.admin-compose { gap: 10px; }
.admin-ai-row { display: flex; gap: 8px; align-items: stretch; }
.admin-ai-row .input { flex: 1; min-width: 0; }
.admin-ai-row .btn-gold { flex: none; white-space: nowrap; padding: 0 14px; }
.admin-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-compose textarea.input { resize: vertical; }
#forge-import-site { align-self: flex-start; }
.forge-social-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.forge-social-chips .soon-chip { border-color: rgba(20,241,149,.35); color: var(--emerald-bright, #14f195); }
@media (max-width: 560px) {
  .admin-ai-row { flex-direction: column; }
  .admin-ai-row .btn-gold { padding: 10px 14px; }
}

/* ================= PHONE REFORMAT =================
   Kept last so it wins the cascade over the wider breakpoints above.
   Fixes: (1) Discover couldn't scroll — a centered flex column clips its top
   in an overflow container; switch to top-aligned. (2) oversized/zoomed hero +
   billboard. (3) crowding — tighter, consistent rhythm. */
@media (max-width: 640px) {
  .shell {
    padding: max(8px, env(safe-area-inset-top)) 12px
             calc(var(--dock-h) + 10px + env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 10px;
  }

  /* momentum scrolling + no clipped/centered content */
  .page-scroll {
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    padding: 2px 2px 16px;
  }
  #view-discover .page-scroll {
    justify-content: flex-start;
    min-height: 0;
  }

  /* discover welcome — compact on small screens */
  .discover-home { padding-bottom: 24px; gap: 22px; }
  .discover-title { font-size: clamp(1.65rem, 7vw, 2rem); }
  .guide-card { padding: 16px; gap: 14px; }
  .guide-avatar { width: 64px; height: 64px; }
  .guide-name { font-size: 1.3rem; }
  .guide-hook { font-size: 13px; }

  /* section rhythm */
  .rows { gap: 16px; }
  .discover-section-title { font-size: 1.15rem; }
  .discover-chars { gap: 12px; }

  /* cards a touch smaller so two fit cleanly */
  .card { width: 152px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  /* character + create views: comfortable reading width, no side crush */
  .layout-split,
  .char-hero { gap: 16px; }
  .hero-stage { width: min(72%, 220px); margin: 0 auto; }
  .hero-name { font-size: clamp(1.8rem, 7.5vw, 2.4rem); }
  .modal-card { padding: 20px 16px; }
}
