/* ===== Fable Neon — self-hosted type ===== */
@font-face {
  font-family: Inter;
  src: url("assets/ui/inter-regular.woff2?v=e55bac58284133c5") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("assets/ui/inter-500.woff2?v=e55bac58284133c5") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("assets/ui/inter-600.woff2?v=e55bac58284133c5") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("assets/ui/inter-700.woff2?v=e55bac58284133c5") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("assets/ui/playfair-italic-latin-ext.woff2?v=e55bac58284133c5") format("woff2");
  font-weight: 700 900;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Playfair Display";
  src: url("assets/ui/playfair-italic-latin.woff2?v=e55bac58284133c5") format("woff2");
  font-weight: 700 900;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===== Design tokens (neon green + pink, deep black) ===== */
:root {
  color-scheme: dark;
  --bg: #080808;
  --bg-soft: #0e0e10;
  --surface: #141417;
  --surface-2: #1a1a1f;
  --raised: #24242a;
  --line: #26262c;
  --line-soft: #1f1f24;
  --text: #f5f5f7;
  --muted: #8a8a93;
  --muted-2: #5a5a63;
  --accent: #39ff14;
  --accent-ink: #061400;
  --accent-dim: rgba(57, 255, 20, 0.12);
  --accent-glow: rgba(57, 255, 20, 0.35);
  --accent-2: #ff3ea5;
  --accent-2-dim: rgba(255, 62, 165, 0.14);
  --accent-2-glow: rgba(255, 62, 165, 0.35);
  --danger: #ff5c7a;
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 72px;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button,
input,
textarea,
select {
  font: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  display: block;
  max-width: 100%;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  color: inherit;
  border: 1px solid var(--line);
  background: var(--raised);
  padding: 8px 12px;
  border-radius: 10px;
  min-height: 36px;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.1s;
}
button:hover:not(:disabled) {
  background: #2d2d34;
  border-color: #34343c;
}
button:active:not(:disabled) {
  transform: scale(0.98);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.primary {
  background: linear-gradient(135deg, #39ff14, #1acc00);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 700;
}
.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #52ff32, #22dd05);
  box-shadow: 0 0 18px var(--accent-glow);
}
input,
textarea,
select {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  min-width: 0;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.15);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 100;
  left: 12px;
  top: -60px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 12px;
}

/* ===== Brand ===== */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #1a8c0a);
  display: grid;
  place-items: center;
  color: #000;
  font-weight: 900;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--accent-glow);
}
.brand-name {
  white-space: nowrap;
}

/* ===== Icons ===== */
.icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  background: currentColor;
  mask: var(--icon) center/contain no-repeat;
  -webkit-mask: var(--icon) center/contain no-repeat;
  flex-shrink: 0;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 8px;
  background: transparent;
  border-color: transparent;
}
.icon-button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
}

/* ===== Shared bits ===== */
.muted {
  color: var(--muted);
}
.status {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.status:empty {
  display: none;
}
.error {
  color: var(--danger) !important;
}
.empty-note {
  color: var(--muted);
  padding: 32px 0;
  line-height: 1.8;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Sidebar ===== */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  z-index: 20;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 18px;
}
.side-nav {
  display: grid;
  gap: 2px;
}
.side-nav > a,
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  text-align: left;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}
.side-nav > a:hover,
.nav-group-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}
.side-nav > a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 2px 0 0 var(--accent);
}
.side-nav .icon {
  width: 20px;
  height: 20px;
}
.nav-chevron {
  margin-left: auto;
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
  opacity: 0.7;
}
.nav-group[data-open] .nav-chevron {
  transform: rotate(180deg);
}
.nav-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 999px;
  padding: 1px 7px;
}
.nav-group[data-open] .nav-count {
  display: none;
}
.nav-children {
  display: grid;
  gap: 2px;
  padding: 2px 0 4px 34px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.nav-group[data-open] .nav-children {
  max-height: 42vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.sidebar-run {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 2px solid var(--line);
  min-width: 0;
}
.sidebar-run:hover {
  background: var(--surface-2);
  border-left-color: var(--accent-2);
}
.sidebar-run strong {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-run span {
  font-size: 10.5px;
  color: var(--muted-2);
}
.sidebar-run:hover span {
  color: var(--accent);
}
.sidebar-runs-empty {
  font-size: 11.5px;
  color: var(--muted-2);
  padding: 8px 10px 10px;
  line-height: 1.5;
}
.sidebar-manage {
  margin: 4px 0 0 34px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  text-align: left;
  min-height: 0;
  width: fit-content;
}
.sidebar-manage:hover {
  color: var(--accent-2);
  background: transparent;
}
.sidebar-bottom {
  margin-top: auto;
  padding: 12px 8px 4px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line-soft);
}
.sidebar-bottom a {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
}
.sidebar-bottom a:hover {
  color: var(--text);
  background: var(--surface-2);
}
.sidebar-caption {
  font-size: 12px;
  color: var(--muted-2);
  padding: 0 2px;
}
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
}

/* sidebar collapsed */
.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-w-collapsed);
}
.sidebar-collapsed .app-main,
.sidebar-collapsed .player-main {
  margin-left: var(--sidebar-w-collapsed);
}
.sidebar-collapsed .brand-name,
.sidebar-collapsed .nav-text,
.sidebar-collapsed .nav-count,
.sidebar-collapsed .nav-chevron,
.sidebar-collapsed .nav-children,
.sidebar-collapsed .sidebar-manage,
.sidebar-collapsed .sidebar-caption {
  display: none;
}
.sidebar-collapsed .sidebar-top {
  justify-content: center;
  padding: 4px 0 18px;
}
.sidebar-collapsed .side-nav > a,
.sidebar-collapsed .nav-group-toggle,
.sidebar-collapsed .sidebar-bottom a {
  justify-content: center;
  padding: 8px;
}

/* mobile nav (hidden on desktop) */
.mobile-header,
.mobile-nav {
  display: none;
}

/* ===== HERO ===== */
.hero {
  position: relative;
  padding: 48px 0 32px;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  top: -220px;
  left: 22%;
  width: 680px;
  height: 680px;
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
  animation: glowPulse 6s ease-in-out infinite;
}
.hero::after {
  content: "";
  position: absolute;
  bottom: -260px;
  right: -12%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-2-dim) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
  animation: glowPulse 7s ease-in-out infinite reverse;
}
@keyframes glowPulse {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}
.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 48px;
}
.hero-copy {
  flex: 1 1 55%;
  min-width: 0;
}
.hero-demo {
  flex: 1 1 45%;
  min-width: 0;
}
.hero-without-demo .hero-copy {
  max-width: 720px;
}
.rating-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
  opacity: 0;
  animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}
.stars {
  letter-spacing: 2px;
  font-size: 15px;
  display: inline-block;
  animation: twinkle 2.5s ease-in-out infinite;
}
.stars .s-green {
  color: var(--accent);
}
.stars .s-pink {
  color: var(--accent-2);
}
@keyframes twinkle {
  0%,
  100% {
    opacity: 1;
    text-shadow: 0 0 8px var(--accent-glow);
  }
  50% {
    opacity: 0.7;
    text-shadow: 0 0 16px var(--accent-glow);
  }
}
.hero h1 {
  font-size: clamp(38px, 5vw, 68px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}
.hero h1 .line {
  display: block;
  opacity: 0;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hero h1 .line-1 {
  animation-delay: 0.2s;
}
.hero .accent-word {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 800;
  background: linear-gradient(
    100deg,
    #39ff14 0%,
    #aaff88 20%,
    #ff3ea5 40%,
    #ff9ed1 55%,
    #39ff14 70%,
    #ff3ea5 90%,
    #39ff14 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3.5s linear infinite,
    fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.4s forwards;
  opacity: 0;
  filter: drop-shadow(0 0 24px var(--accent-glow));
}
@keyframes shimmer {
  to {
    background-position: 200% center;
  }
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.hero .lede {
  max-width: 520px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
  opacity: 0;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.6s forwards;
}
.cta-primary {
  display: inline-block;
  background: linear-gradient(135deg, #39ff14, #1acc00);
  color: #000;
  padding: 15px 36px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 16px;
  border: 0;
  transition: box-shadow 0.25s, transform 0.15s;
  opacity: 0;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.75s forwards,
    ctaGlow 2.5s ease-in-out 1.5s infinite;
}
@keyframes ctaGlow {
  0%,
  100% {
    box-shadow: 0 0 12px var(--accent-glow), 0 0 8px var(--accent-2-glow);
  }
  50% {
    box-shadow: 0 0 30px var(--accent-glow), 0 0 60px var(--accent-dim),
      0 0 40px var(--accent-2-glow);
  }
}
.cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}
.hero-meta {
  margin-top: 18px;
  color: var(--muted-2);
  font-size: 13px;
  opacity: 0;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}
.hero-meta span {
  margin: 0 6px;
}

/* live demo card */
.demo-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  opacity: 0;
  animation: fadeUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  transition: box-shadow 0.25s;
}
.demo-card:hover {
  box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.5),
    0 0 0 2px rgba(255, 62, 165, 0.35),
    0 20px 60px rgba(57, 255, 20, 0.12),
    0 20px 60px rgba(255, 62, 165, 0.08);
}
.demo-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.demo-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a2a30, #1a1a1f);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.demo-title {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.1em;
}
.live-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
.demo-body {
  padding: 18px;
  min-height: 250px;
  display: flex;
  flex-direction: column;
}
.demo-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 170px;
  overflow: hidden;
}
.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
  animation: msgIn 0.4s ease-out;
}
@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.chat-msg.narrator {
  background: var(--surface-2);
  color: #d4d4d8;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-msg.player {
  background: linear-gradient(
    135deg,
    rgba(255, 62, 165, 0.22),
    rgba(57, 255, 20, 0.12)
  );
  color: #fff0f7;
  align-self: flex-end;
  border: 1px solid rgba(255, 62, 165, 0.35);
  border-bottom-right-radius: 4px;
}
.chat-msg .cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.7s step-end infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.demo-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px 8px 14px;
}
.demo-input-bar .placeholder {
  flex: 1;
  color: var(--muted-2);
  font-size: 14px;
}
.demo-send {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #000;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 0;
  padding: 0;
  min-height: 0;
}

/* ===== Scroll reveal ===== */
.reveal {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 {
  transition-delay: 0.1s;
}
.reveal-delay-2 {
  transition-delay: 0.2s;
}
.reveal-delay-3 {
  transition-delay: 0.3s;
}
.reveal-delay-4 {
  transition-delay: 0.4s;
}
.reveal-delay-5 {
  transition-delay: 0.5s;
}

/* ===== Sections ===== */
.section {
  padding: 56px 0;
}
.section-label {
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.section-label.pink {
  color: var(--accent-2);
}
.section-title {
  font-size: clamp(26px, 3.6vw, 40px);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

/* search + genre controls */
.search-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
}
.search-panel input {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  border-radius: 14px;
  background: var(--surface);
}
.search-panel .icon-button {
  font-size: 20px;
  color: var(--muted);
}
.genre-tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  scrollbar-width: none;
  padding: 20px 0 6px;
  margin-bottom: 28px;
}
.genre-tabs::-webkit-scrollbar {
  display: none;
}
.genre-tabs button {
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  min-height: 34px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
}
.genre-tabs button:hover {
  color: var(--text);
  border-color: #3a3a42;
  background: var(--surface-2);
}
.genre-tabs button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 14px var(--accent-glow);
}
.catalog-status {
  margin: -8px 0 20px;
}

/* ===== Story cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.story-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  aspect-ratio: 9 / 16;
  cursor: pointer;
  padding: 0;
  min-height: 0;
  text-align: left;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.story-card:hover {
  transform: translateY(-4px);
  border-color: transparent;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(57, 255, 20, 0.35);
}
.story-card .cover {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
}
.story-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.story-card .cover img[data-image-state="loading"],
.story-card .cover img[data-image-state="error"] { opacity: 0; }
.story-card .cover img[data-image-state="ready"] { animation: cover-reveal 350ms ease-out both; }
@keyframes cover-reveal { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .story-card .cover img[data-image-state="ready"] { animation: none; }
}
.story-card .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.35) 45%,
    rgba(0, 0, 0, 0.92) 100%
  );
}
.card-tags {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 1;
}
.tag-pill {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.tag-pill.pink {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #16020d;
}
.card-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  z-index: 1;
}
.card-title {
  display: block;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 3px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#originals-grid .card-title {
  font-size: clamp(22px, 3.2vw, 36px);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}
.card-author {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Features ===== */
.features {
  background: var(--bg-soft);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.feature-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.feature {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  padding: 34px 0;
  border-bottom: 1px solid var(--line-soft);
  align-items: start;
}
.feature:last-child {
  border-bottom: none;
}
.feature-num {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 54px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.45;
  line-height: 1;
  min-width: 80px;
}
.feature-list .feature:nth-child(2) .feature-num {
  color: var(--accent-2);
}
.feature h3 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.feature p {
  color: var(--muted);
  font-size: 15.5px;
  max-width: 640px;
  margin: 0;
}

/* ===== Steps ===== */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}
.step {
  padding: 26px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s, transform 0.2s;
}
.step:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}
.step-num {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.5;
  line-height: 1;
  margin-bottom: 14px;
}
.steps-grid .step:nth-child(even) .step-num {
  color: var(--accent-2);
}
.step h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
}
.step p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

/* ===== Testimonials ===== */
.testimonials {
  background: var(--bg-soft);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
}
.testimonials-head {
  margin-bottom: 24px;
}
.testi-track {
  display: flex;
  gap: 22px;
  overflow-x: auto;
  padding: 8px 24px 28px;
  margin: 0 -24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
}
.testi-track::-webkit-scrollbar {
  display: none;
}
.testi {
  flex: 0 0 360px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
}
.testi-stars {
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 14px;
  font-size: 14px;
}
.testi-text {
  font-size: 14.5px;
  line-height: 1.7;
  color: #d4d4d8;
  margin: 0 0 18px;
  min-height: 96px;
}
.testi-author {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
}

/* ===== FAQ ===== */
.faq-list {
  max-width: 760px;
}
.faq-item {
  border-bottom: 1px solid var(--line-soft);
}
.faq-q {
  width: 100%;
  text-align: left;
  padding: 20px 0;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 0;
}
.faq-q:hover {
  color: var(--accent);
  background: transparent;
}
.faq-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: var(--accent);
  transition: transform 0.25s;
}
.faq-item.open .faq-icon {
  transform: rotate(45deg);
}
.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding-bottom 0.3s ease;
  color: var(--muted);
  font-size: 14.5px;
}
.faq-item.open .faq-a {
  max-height: none;
  padding-bottom: 20px;
}

/* ===== Footer ===== */
.site-footer,
.footer {
  background: var(--bg-soft);
  border-top: 1px solid var(--line-soft);
  padding: 52px 0 30px;
  color: var(--muted);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 36px;
}
.footer-brand p {
  color: var(--muted);
  font-size: 14px;
  margin: 14px 0 0;
  max-width: 280px;
}
.footer-col h5 {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 14px;
  color: var(--text);
}
.footer-col a {
  display: block;
  color: var(--muted);
  font-size: 14px;
  padding: 5px 0;
}
.footer-col a:hover {
  color: var(--accent);
}
.footer-bottom {
  border-top: 1px solid var(--line-soft);
  padding-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted-2);
  font-size: 13px;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-bottom-links {
  display: flex;
  gap: 22px;
}

/* ===== Story detail dialog ===== */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: min(760px, calc(100% - 32px));
  padding: 0;
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(57, 255, 20, 0.08);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
dialog[open] {
  display: flex;
  flex-direction: column;
}
.account-modal[open]{width:min(540px,calc(100% - 28px));height:min(760px,calc(100dvh - 28px));max-height:calc(100dvh - 28px);padding:0;background:#141916;border:1px solid rgba(57,255,20,.25);border-radius:18px;overflow:hidden}
.account-modal-header{display:flex;align-items:center;justify-content:space-between;gap:16px;flex:none;padding:20px 24px 12px}
.account-modal-header h2{margin:0;font-size:20px;line-height:1.2}
.account-modal-close{border:0;background:transparent;color:var(--muted);font-size:28px;line-height:1;cursor:pointer;padding:3px 6px}
.account-modal-close:hover{color:var(--accent-2)}.account-modal-close:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.account-modal-frame{display:block;flex:1;width:100%;min-height:0;border:0;background:#141916}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 22px;
  flex-shrink: 0;
}
.dialog-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}
.dialog-body {
  padding: 24px;
  overflow: auto;
  min-height: 0;
}
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 15px 22px;
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
  background: var(--bg-soft);
}
.dialog-footer .status {
  margin: 0 auto 0 0;
}
.dialog-footer button {
  flex-shrink: 0;
}
.detail-overview {
  display: grid;
  grid-template-columns: 192px minmax(0, 1fr);
  gap: 26px;
}
.detail-cover {
  width: 100%;
  aspect-ratio: 9 / 16;
  align-self: start;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.detail-copy h3 {
  font-size: 22px;
  line-height: 1.35;
  margin: 2px 0 10px;
  overflow-wrap: anywhere;
}
.detail-copy p {
  margin: 10px 0;
  color: #c8c8cf;
}
.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tag-list .tag {
  background: var(--accent-dim);
  border: 1px solid rgba(57, 255, 20, 0.25);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11.5px;
  font-weight: 600;
}
.detail-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.detail-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
}
.detail-section p, #detail-description, #detail-prologue {
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.8;
  margin: 8px 0;
}
.detail-expandable > :first-child {
  overflow: hidden;
  overflow-wrap: anywhere;
}
.detail-expandable.is-collapsed > :first-child {
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, rgba(0, 0, 0, 0.65) 75%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 40%, rgba(0, 0, 0, 0.65) 75%, transparent 100%);
}
.detail-expand-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  margin: 10px auto 0;
  padding: 8px 22px;
  border: 1px solid rgba(57, 255, 20, 0.3);
  border-radius: 999px;
  background: linear-gradient(115deg, rgba(57, 255, 20, 0.16), rgba(133, 255, 206, 0.05));
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.detail-expand-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 180ms ease;
}
.detail-expand-toggle[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
.detail-expand-toggle:hover,
.detail-expand-toggle:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(57, 255, 20, 0.12);
}
.detail-expand-toggle[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .detail-expand-toggle, .detail-expand-toggle::after { transition: none; }
}
.segment-picker {
  display: grid;
  gap: 8px;
}
.segment-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}
.segment-option:hover {
  border-color: rgba(57, 255, 20, 0.4);
}
.segment-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.15);
}
.segment-option input {
  accent-color: var(--accent);
  flex-shrink: 0;
  margin: 0;
}
.segment-option .segment-title {
  font-size: 14px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.player-name-label {
  display: block;
  color: var(--muted-2);
  font-size: 13px;
  margin-bottom: 8px;
}
#player-name-input {
  width: 100%;
}
#player-name-input::placeholder {
  color: var(--muted-2);
  opacity: 1;
}
.detail-section a {
  color: var(--accent);
  font-weight: 600;
}
.detail-subtitle {
  color: var(--muted);
  font-size: 13px;
}

/* ===== Side sheet (settings / history) ===== */
.sheet {
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  width: min(380px, 100%);
  border-radius: 0;
  border-right: 0;
  border-top: 1px solid var(--line);
}
.sheet .dialog-body {
  display: grid;
  gap: 22px;
  align-content: start;
}
.setting-group {
  overflow-wrap: anywhere;
  display: grid;
  gap: 8px;
}
.setting-group h3 {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
  margin: 0;
}
.setting-group p {
  white-space: pre-line;
  margin: 0;
  overflow-wrap: anywhere;
}
.setting-group button {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
}
.setting-group button:hover {
  border-color: var(--accent);
}
.setting-group progress {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
}
.setting-group label {
  font-size: 13px;
  color: var(--muted);
}
.history-sheet .saved-run {
  grid-template-columns: 1fr;
}
.history-tools {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.history-actions {
  display: flex;
  gap: 8px;
}
.history-actions button {
  font-size: 12px;
  padding: 6px 12px;
  min-height: 0;
}
.history-tools p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  flex: 1;
  min-width: 120px;
}
.saved-runs,
#runs {
  display: grid;
  gap: 10px;
}
.saved-run {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.saved-run > a,
.saved-run > strong {
  margin-right: auto;
  font-weight: 600;
  overflow-wrap: anywhere;
  font-size: 13.5px;
}
.saved-run > a:hover {
  color: var(--accent);
}
.history-dialog .saved-run {
  flex-wrap: wrap;
}

/* ===== Memory dialog ===== */
.memory-tabs {
  display: flex;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line-soft);
  overflow: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.memory-tabs::-webkit-scrollbar {
  display: none;
}
.memory-tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  white-space: nowrap;
  padding: 13px 2px;
  color: var(--muted);
  min-height: 0;
}
.memory-tabs button:hover {
  color: var(--text);
  background: transparent;
}
.memory-tabs button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.memory-item {
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
}
.memory-item p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 6px 0 0;
  color: #d4d4d8;
  font-size: 13.5px;
}
.memory-item span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

/* ===== Play page ===== */
.player-workspace { display: flex; flex: 1; min-height: 0; min-width: 0; }
.player-debug-open #app-navigation { display: none; }
.player-debug-open .player-main { margin-left: 0; }
.player-debug-open .player-workspace { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(340px, 1.5fr) minmax(260px, 1fr); }
.player-debug-open .conversation { min-width: 0; }
.player-debug-open .live-messages { padding-inline: max(16px, calc((100% - 768px) / 2)); }
.player-debug-open .composer-wrap { padding-inline: 16px; }
.player-debug-open .player-time-debug { background: rgba(57,255,20,.1); border-color: var(--accent); }
.player-debug-panel { min-width: 0; min-height: 0; overflow-y: auto; background: var(--surface); padding: 16px 12px; scrollbar-width: thin; }
.director-panel { border-right: 1px solid var(--line); }
.performer-panel { border-left: 1px solid var(--line); }
.player-debug-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.player-debug-panel h2 { margin: 0; font-size: 14px; }
.player-debug-panel > header span, .player-debug-hint { color: var(--muted); font-size: 11px; }
.player-debug-tools { display: grid; gap: 8px; margin: 12px 0; font-size: 11px; color: var(--muted); }
.player-debug-tools button { justify-self: start; }
.player-debug-auto-refresh { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.player-debug-auto-refresh input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); }
.player-debug-panel button { font-size: 11px; padding: 6px 9px; min-height: 30px; }
.player-debug-list { display: grid; gap: 12px; }
.player-debug-call { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 7px; padding: 10px; min-width: 0; background: var(--bg); }
.performer-panel .player-debug-call { border-left-color: #a39df7; }
.player-debug-call.is-error { border-color: #ff5c7a; }
.player-debug-call.is-error .player-debug-badge { color: #ff5c7a; }
.player-debug-time { margin: 0 0 7px; color: var(--muted); font: 10px/1.6 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.player-debug-call-meta { margin-bottom: 8px; font-size: 10px; color: var(--muted); overflow-wrap: anywhere; }
.player-debug-call > details > summary { cursor: pointer; font-size: 12px; }
.player-debug-badge { display: block; color: var(--muted); font-size: 11px; margin: 6px 0 0; }
.player-debug-payload { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.player-debug-payload > header { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.player-debug-payload h4 { margin: 0; font-size: 12px; }
.player-debug-payload pre { margin: 5px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.7 ui-monospace, Consolas, monospace; color: var(--text); }
.debug-model-message { margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; min-width: 0; }
.debug-model-message h5 { margin: 0 0 8px; font-size: 11px; color: #a8c2f7; overflow-wrap: anywhere; }
.debug-model-message > pre { max-height: 480px; overflow: auto; }
.debug-request-audit > button { margin-top: 10px; }
.debug-json-node, .debug-json-raw { margin-top: 8px; }
.debug-json-node > summary, .debug-json-leaf > summary, .debug-json-raw > summary { cursor: pointer; font: 11px/1.6 ui-monospace, Consolas, monospace; color: #a8c2f7; overflow-wrap: anywhere; }
.debug-json-children { margin: 6px 0 0 5px; border-left: 1px solid var(--line); padding-left: 9px; }
.debug-json-leaf { margin: 8px 0; min-width: 0; }
.debug-json-leaf > strong { font: 600 11px/1.6 ui-monospace, Consolas, monospace; color: #a8c2f7; overflow-wrap: anywhere; }
.debug-json-raw pre, .debug-json-leaf pre { max-height: 380px; overflow: auto; }
.player-debug-empty { color: var(--muted); font-size: 12px; }
@media (max-width: 1000px) {
  .player-debug-open .player-workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 3fr) minmax(0, 2fr); }
  .player-debug-open .conversation { grid-column: 1 / -1; grid-row: 1; }
  .player-debug-panel { grid-row: 2; border-top: 1px solid var(--line); padding: 12px 8px; }
  .player-debug-call { padding: 8px; }
}
.play-page {
  height: 100dvh;
  overflow: hidden;
  background: var(--chat-background, hsl(240 4% 10%));
}
.play-page .app-sidebar {
  background: var(--chat-background, hsl(240 4% 10%));
}
.player-main {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}
.player-header {
  height: 62px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--chat-background, hsl(240 4% 10%));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
}
.player-header img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.player-header h1 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-header .story-heading {
  min-width: 0;
  margin-right: auto;
  display: grid;
  gap: 1px;
}
.player-time-debug {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--accent);
}
.player-time-debug:hover { background: var(--surface); }
.player-header #connection-state {
  font-size: 11px;
  color: var(--muted);
}
.model-control {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 14px;
  min-height: 32px;
}
.model-control:hover {
  color: var(--accent);
  border-color: rgba(57, 255, 20, 0.4);
  background: var(--surface);
}
.conversation {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(
      ellipse 60% 40% at 80% -5%,
      rgba(255, 62, 165, 0.06),
      transparent 70%
    ),
    radial-gradient(
      ellipse 60% 40% at 10% -5%,
      rgba(57, 255, 20, 0.05),
      transparent 70%
    ) var(--chat-background, hsl(240 4% 10%));
}
.live-messages {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  flex: 1;
  min-height: 0;
  padding: 34px max(28px, calc((100% - 744px) / 2)) 20px;
}
.message {
  margin: 0 0 28px;
  font-size: var(--reading-size, 16px);
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.message .speaker {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}
.message.assistant .speaker {
  color: var(--accent);
}
/* Consecutive performances read as one round; debug keeps each turn selectable. */
body:not(.player-debug-open) #messages > .message.assistant:not(.prologue-preview) + .message.assistant > .speaker {
  display: none;
}
body:not(.player-debug-open) #messages > .message.assistant:not(.prologue-preview):has(+ .message.assistant) {
  margin-bottom: 12px;
}
.player-debug-open .message.assistant .speaker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.story-debug-meta { display: inline-flex; flex-wrap: wrap; gap: 5px; font-size: 10px; font-weight: 500; letter-spacing: 0; line-height: 1.5; color: var(--muted); }
.story-debug-meta > span { border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.story-debug-meta [data-track="ON_TRACK"], .story-debug-meta [data-story-state="COMPLETE"] { color: var(--accent); }
.story-debug-meta [data-track="OFF_TRACK"], .story-debug-meta [data-story-state="FREEFORM"] { color: #e8bd79; }
.player-debug-open .message .speaker[role="button"] { cursor: pointer; border-radius: 4px; }
.player-debug-open .message .speaker[role="button"]:hover,
.player-debug-open .message .speaker[aria-pressed="true"] { background: rgba(57,255,20,.1); outline: 1px solid var(--accent); }
.player-debug-open .message .speaker[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.message > div {
  white-space: pre-wrap;
  color: #dcdce2;
}
/* AI 正文：叙述部分灰色，竖线对白整行加粗白色，中英文双引号及其内容一并加粗 */
.message.assistant > div {
  color: #8f8f99;
}
.message.assistant > div .spoken-line {
  color: #ffffff;
  font-weight: 700;
}
.message.assistant > div .story-heading { color: #ffffff; font-size: 1.15em; font-weight: 700; }
.message.assistant > div strong { color: #dcdce2; font-weight: 700; }
.message.user {
  background: linear-gradient(
    135deg,
    rgba(255, 62, 165, 0.16),
    rgba(57, 255, 20, 0.07)
  ) var(--chat-bubble, hsl(240 4% 14%));
  border: 1px solid rgba(255, 62, 165, 0.3);
  border-radius: 16px;
  padding: 15px 19px;
}
.message.user .speaker {
  color: var(--accent-2);
}
.message.user .slash-command-name { color: var(--accent-2); }
.message.user > div {
  color: #f3e9ef;
}
.message.incomplete {
  opacity: 0.75;
  border-left: 2px solid var(--accent-2);
  padding-left: 14px;
}
.turn-note {
  font-size: 12px;
  color: #ffb067;
}
.committed-scene-image,
.scene-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 14px auto;
  border: none;
  background: #0c0c10;
}
.committed-scene-image {
  margin: 14px 0;
}
.scene-image[data-image-state="loading"],.scene-image[data-image-state="error"] {
  aspect-ratio: var(--image-ratio,2 / 3);
  min-height: 100px;
  object-fit: contain;
}
.scene-image[data-image-state="loading"] {
  color: transparent;
  background: linear-gradient(110deg,#131722 20%,#273143 45%,#131722 70%);
  background-size: 240% 100%;
  animation: scene-image-loading 1.8s ease-in-out infinite;
}
.scene-image[data-image-state="ready"] {
  clip-path: inset(0 round 12px);
  animation: scene-image-reveal 800ms ease-out both;
}
@keyframes scene-image-loading {
  0%,100% { background-position: 100% 0; }
  50% { background-position: 0 0; }
}
@keyframes scene-image-reveal {
  from { filter: blur(14px); opacity: .45; }
  to { filter: blur(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .scene-image[data-image-state] { animation: none; filter: none; opacity: 1; }
}
.composer-wrap {
  width: min(800px, 100%);
  padding: 6px 28px 16px;
  align-self: center;
  flex-shrink: 0;
}
.composer-wrap .status {
  margin: 0 0 8px;
}
.composer-wrap .status:empty {
  display: none;
}
.story-end-notice {
  margin: 0 0 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chat-bubble, hsl(240 4% 14%));
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 25dvh;
  overflow-y: auto;
  flex-shrink: 0;
}
.composer-wrap form {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--chat-bubble, hsl(240 4% 14%));
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-wrap form:focus-within {
  border-color: rgba(57, 255, 20, 0.5);
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.08),
    0 0 26px rgba(57, 255, 20, 0.08);
}
.composer-wrap textarea {
  resize: none;
  display: block;
  width: 100%;
  max-height: 180px;
  min-height: 68px;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 15px 17px;
  line-height: 1.5;
  transition: max-height 0.2s ease;
}
.composer-wrap textarea:focus {
  box-shadow: none;
}
.composer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 10px 10px;
}
.composer-actions > span {
  font-size: 11px;
  color: var(--muted-2);
  margin-right: auto;
}
.composer-actions .primary {
  margin-left: auto;
  border-radius: 12px;
  min-width: 44px;
  padding: 8px 14px;
}
.story-suggestions-shell {
  display: grid;
  grid-template-rows: 0fr;
  min-height: 0;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  pointer-events: none;
  transition: grid-template-rows 200ms ease, padding-bottom 200ms ease,
    opacity 160ms ease, transform 200ms ease, visibility 0s linear 200ms;
}
.story-suggestions-shell.is-visible {
  grid-template-rows: 1fr;
  padding-bottom: 10px;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.story-suggestions {
  display: grid;
  grid-template-columns: 1fr;
  /* Keep full button heights measurable while the outer grid collapses.
     Shrinking these rows feeds the animation back into isAtBottom(). */
  grid-auto-rows: max-content;
  min-height: 0;
  overflow: hidden;
  gap: 6px;
}
.story-suggestions button, .slash-menu button {
  font-size: 12.5px;
  white-space: normal;
  text-align: left;
  padding: 9px 14px;
  color: var(--text);
  background: var(--chat-bubble, hsl(240 4% 14%));
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 0;
  width: 100%;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.story-suggestions button:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(57, 255, 20, 0.45);
  background: color-mix(in srgb, var(--chat-bubble, hsl(240 4% 14%)), var(--accent) 12%);
}
.suggestions-setting { display: flex; align-items: center; gap: 10px; }
.suggestions-setting input { width: auto; }
.prologue-preview { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.prologue-preview .prologue-image { display: block; margin: 16px 0; }
#detail-prologue { white-space: pre-wrap; overflow-wrap: anywhere; }
.keyboard-open #story-suggestions { display: none; }
.review-recovery {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}
.review-recovery[hidden] {
  display: none;
}
.review-recovery button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 76px;
  min-height: 40px;
  font-size: 12px;
  padding: 6px 12px;
}
.review-recovery button[aria-busy="true"]::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: recovery-spin 0.8s linear infinite;
}
@keyframes recovery-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .review-recovery button[aria-busy="true"]::before { animation: none; }
}
.mobile-back {
  display: none;
}

/* ===== Responsive: tablet ===== */
@media (max-width: 1100px) {
  .hero {
    padding: 36px 0 24px;
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Responsive: phone ===== */
@media (max-width: 760px) {
  .app-sidebar {
    display: none;
  }
  .app-main,
  .player-main {
    margin-left: 0;
  }
  .mobile-header {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line-soft);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .mobile-header .brand {
    margin-right: auto;
    font-size: 15px;
  }
  .mobile-header .brand-mark {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }
  .mobile-header > a:not(.brand) {
    font-size: 14px;
    color: var(--muted);
    padding: 6px 4px;
  }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    display: flex;
    justify-content: space-around;
    height: calc(62px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(14, 14, 16, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
    z-index: 50;
  }
  .mobile-nav a,
  .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 64px;
    font-size: 10px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    min-height: 0;
  }
  .mobile-nav a:hover,
  .mobile-nav button:hover {
    background: transparent;
    color: var(--text);
  }
  .mobile-nav a[aria-current="page"] {
    color: var(--accent);
  }
  .mobile-nav .icon {
    width: 23px;
    height: 23px;
  }

  .app-main {
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }
  .play-page {
    padding-bottom: 0;
  }
  .hero-inner {
    flex-direction: column;
    gap: 30px;
  }
  .container {
    padding: 0 16px;
  }
  .testi-track {
    padding: 8px 16px 24px;
    margin: 0 -16px;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .home-page .hero {
    padding: 24px 0 20px;
  }
  .home-page .hero-inner {
    gap: 22px;
    align-items: stretch;
  }
  .home-page .hero h1 {
    font-size: clamp(26px, 7.2vw, 36px);
    line-height: 1.12;
    margin-bottom: 14px;
    overflow-wrap: anywhere;
  }
  .home-page .rating-row {
    font-size: 11px;
    gap: 7px;
    margin-bottom: 14px;
  }
  .home-page .stars {
    font-size: 12px;
    flex-shrink: 0;
    letter-spacing: 1px;
  }
  .home-page .hero .lede {
    font-size: 13px;
    line-height: 1.65;
    margin-bottom: 18px;
  }
  .home-page .cta-primary {
    font-size: 13px;
    padding: 12px 24px;
    border-radius: 10px;
  }
  .home-page .hero-meta {
    font-size: 10px;
    margin-top: 12px;
  }
  .home-page .demo-title { font-size: 13px; }
  .home-page .demo-chat,
  .home-page .demo-input-bar { font-size: 12px; }
  .home-page .section-title { font-size: 22px; }
  .home-page .section-label { font-size: 10px; }
  .home-page .card-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 24px) / 3);
    align-items: start;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding: 4px 0 12px;
  }
  .home-page .card-grid::-webkit-scrollbar { display: none; }
  .home-page .story-card,
  .home-page #originals-grid .story-card {
    display: block;
    min-width: 0;
    width: 100%;
    aspect-ratio: auto;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
    scroll-snap-align: start;
  }
  .home-page .story-card:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
  }
  .home-page .story-card:focus-visible {
    outline-offset: -2px;
    border-radius: 10px;
  }
  .home-page .story-card .cover {
    position: relative;
    display: block;
    aspect-ratio: 9 / 16;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
  }
  .home-page .story-card .overlay,
  .home-page .story-card .card-tags { display: none; }
  .home-page .card-body {
    position: static;
    display: block;
    padding: 8px 0 0;
  }
  .home-page .card-title,
  .home-page #originals-grid .card-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-height: 2.6em;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    white-space: normal;
    overflow: hidden;
    overflow-wrap: anywhere;
    text-shadow: none;
    margin-bottom: 4px;
  }
  .home-page .card-author {
    font-size: 11px;
    color: var(--muted);
  }
  .home-page .card-grid > .empty-note,
  .home-page .card-grid > a { grid-column: span 3; }
  .steps-grid {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .feature {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 26px 0;
  }
  .feature-num {
    font-size: 40px;
  }
  .section {
    padding: 40px 0;
  }
  .genre-tabs {
    padding-top: 14px;
    margin-bottom: 22px;
  }
  dialog {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 28px);
    border-radius: 16px;
  }
  #story-dialog {
    position: fixed;
    top: var(--story-viewport-top, 0px);
    bottom: calc(100% - var(--story-viewport-top, 0px) - var(--story-viewport-height, 100dvh));
    max-height: calc(var(--story-viewport-height, 100dvh) - 28px);
  }
  #player-name-input {
    font-size: 16px;
  }
  .dialog-header {
    padding: 10px 16px;
  }
  .dialog-body {
    padding: 18px 16px;
  }
  .dialog-footer {
    padding: 14px 16px;
  }
  .detail-overview {
    grid-template-columns: 114px minmax(0, 1fr);
    gap: 16px;
  }
  .detail-copy h3 {
    font-size: 18px;
  }
  .sheet {
    width: min(360px, 100%);
  }
  .history-sheet {
    width: 100%;
    margin: 0;
  }
  .player-header {
    padding: 8px 12px;
    gap: 8px;
  }
  .player-header img {
    width: 30px;
    height: 30px;
  }
  .player-header h1 {
    font-size: 14px;
  }
  .model-control {
    display: none;
  }
  .mobile-back {
    display: inline-flex;
  }
  .play-page .mobile-nav {
    display: none;
  }
  .player-main {
    position: fixed;
    inset-inline: 0;
    top: var(--player-viewport-top, 0px);
    height: var(--player-viewport-height, 100dvh);
  }
  .live-messages {
    padding: 24px 12px 12px;
  }
  .message {
    font-size: var(--reading-size, 15px);
    line-height: 1.8;
    margin-bottom: 24px;
  }
  .composer-wrap {
    padding: 6px 12px max(12px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc((var(--player-viewport-height, 100dvh) - 62px) * 0.6);
  }
  .composer-wrap form,
  .composer-wrap .status,
  .composer-wrap .review-recovery {
    flex-shrink: 0;
  }
  .story-suggestions {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    max-height: min(240px, calc(var(--player-viewport-height, 100dvh) * 0.3));
  }
  .composer-wrap form {
    display: block;
    border-radius: 24px;
  }
  .composer-actions {
    gap: 8px;
    padding: 0 12px 12px;
  }
  .composer-actions .primary {
    min-width: 44px;
    height: 44px;
    padding: 6px 10px;
  }
  .composer-actions > span {
    display: none;
  }
  .composer-wrap textarea {
    min-height: 64px;
    max-height: min(120px, calc(var(--player-viewport-height, 100dvh) * 0.22));
    padding: 14px 16px;
    font-size: 16px;
    overflow-y: auto;
    transition: none;
  }
  .message.user {
    padding: 12px 14px;
  }
  #memory-dialog {
    height: auto;
  }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal,
  .hero .line,
  .hero .accent-word,
  .hero .lede,
  .cta-primary,
  .hero-meta,
  .rating-row,
  .demo-card {
    opacity: 1 !important;
    transform: none !important;
  }
}
/* Configurable homepage copy preserves line breaks and wraps long words. */
[data-home-copy], .chat-msg { white-space: pre-line; overflow-wrap: anywhere; }
/* Public information illustrations follow the text column without a frame. */
.detail-expandable .detail-inline-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 18px 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.story-information-page { padding: 24px 16px; }
.story-information-page main { max-width: 700px; margin: 0 auto 16px; }
.story-information-home { color: inherit; text-decoration: none; }
.story-information-page #story-dialog {
  position: relative;
  inset: auto;
  width: min(700px, 100%);
  max-width: 100%;
  max-height: none;
  margin: 0 auto;
}
.story-information-page #story-dialog .dialog-body { max-height: none; overflow: visible; }
@media (max-width: 760px) {
  .story-information-page { padding: 16px 10px; }
  .story-information-page #story-dialog { height: auto; transform: none; }
}
