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

:root {
  color-scheme: dark;
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-hover: #1e2d50;
  --text: #e0e0e0;
  --text-muted: #a0a0b4;
  --text-on-accent: #fff;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --border: #3a3a5a;
  --success: #2e7d32;
  --warning: #ff9800;
  --danger: #f44336;
  --danger-hover: #d32f2f;
  --preview: #c792ea;
  --max-width: 700px;
  --overlay: rgba(0, 0, 0, 0.5);
  --shadow: rgba(0, 0, 0, 0.4);
  --accent-soft: rgba(233, 69, 96, 0.3);
  --warning-soft: rgba(255, 152, 0, 0.3);
  --preview-soft: rgba(199, 146, 234, 0.3);
  --ai-border: #3a3a6a;
  --ai-text: #a0a0e0;
  --ai-text-hover: #c0c0ff;
  --ai-bg: rgba(90, 90, 160, 0.15);
  --ai-pulse-from: #3a3a6a;
  --ai-pulse-to: #8080d0;
  --convergence: #4ecdc4;
  --convergence-soft: rgba(78, 205, 196, 0.15);
  --convergence-border: rgba(78, 205, 196, 0.4);

  /* z-index scale */
  --z-fab: 20;
  --z-selection: 30;
  --z-toolbar: 60;
  --z-header: 100;
  --z-modal-sheet: 150;
  --z-editor: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-hint: 410;
}

/* Visually hidden but accessible to screen readers */
.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;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* =======================================================================
   Edu brand theme (ScenarioSplice)
   Activated when body.brand-terminology-edu is present (set by brand.js).
   Clean/modern, Quizlet-ish: light background, Inter-alike sans, rounded
   corners, generous whitespace, softer accents.
   ======================================================================= */
body.brand-terminology-edu {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-on-accent: #ffffff;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --preview: #8b5cf6;
  --overlay: rgba(15, 23, 42, 0.55);
  --shadow: rgba(15, 23, 42, 0.08);
  --accent-soft: rgba(79, 70, 229, 0.12);
  --warning-soft: rgba(245, 158, 11, 0.18);
  --preview-soft: rgba(139, 92, 246, 0.15);
  --ai-border: #c7d2fe;
  --ai-text: #4f46e5;
  --ai-text-hover: #4338ca;
  --ai-bg: rgba(79, 70, 229, 0.06);
  --ai-pulse-from: #c7d2fe;
  --ai-pulse-to: #4f46e5;
  --convergence: #0d9488;
  --convergence-soft: rgba(13, 148, 136, 0.1);
  --convergence-border: rgba(13, 148, 136, 0.3);

  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}

body.brand-terminology-edu .auth-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.brand-terminology-edu .header-nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
}
body.brand-terminology-edu .header-nav-link:hover {
  color: var(--text);
  background: #f1f5f9;
}
body.brand-terminology-edu .header-nav-link.nav-active {
  color: var(--accent);
  background: var(--accent-soft);
}
body.brand-terminology-edu .header-nav-cta {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}
body.brand-terminology-edu .header-nav-cta:hover {
  background: var(--accent-hover);
  color: #ffffff;
}

/* Buttons: rounded, confident */
body.brand-terminology-edu .btn,
body.brand-terminology-edu .btn-small {
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  letter-spacing: 0;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
body.brand-terminology-edu .btn {
  background: var(--accent);
  color: #ffffff;
  padding: 0.7rem 1.35rem;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
body.brand-terminology-edu .btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
body.brand-terminology-edu .btn:active { transform: translateY(1px); }
body.brand-terminology-edu .btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
body.brand-terminology-edu .btn-outline:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}

/* Home screen / landing */
body.brand-terminology-edu .landing-headline {
  color: var(--text);
  letter-spacing: -0.03em;
  font-weight: 700;
}
body.brand-terminology-edu .landing-tagline,
body.brand-terminology-edu .landing-how-sub,
body.brand-terminology-edu .landing-pricing-sub,
body.brand-terminology-edu .landing-browse-sub,
body.brand-terminology-edu .landing-demo-sub {
  color: var(--text-muted);
}
body.brand-terminology-edu .landing-stats { color: var(--text-muted); }

body.brand-terminology-edu .landing-step {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 1px 2px var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
body.brand-terminology-edu .landing-step:hover {
  box-shadow: 0 6px 20px var(--shadow);
  transform: translateY(-2px);
}
body.brand-terminology-edu .landing-step .step-number {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  border-radius: 999px;
}
body.brand-terminology-edu .landing-step h3 {
  color: var(--text);
  font-weight: 700;
}
body.brand-terminology-edu .landing-step p,
body.brand-terminology-edu .landing-step li {
  color: var(--text-muted);
}

body.brand-terminology-edu .pricing-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 2px var(--shadow);
  color: var(--text);
}
body.brand-terminology-edu .pricing-card-pro {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.12);
}
body.brand-terminology-edu .pricing-card-badge {
  background: var(--accent);
  color: #ffffff;
}

body.brand-terminology-edu .landing-footer {
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
body.brand-terminology-edu .footer-links a { color: var(--text-muted); }
body.brand-terminology-edu .footer-links a:hover { color: var(--text); }

/* Library: card-first layout, drop the serif tone */
body.brand-terminology-edu .library-card,
body.brand-terminology-edu .story-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px var(--shadow);
  transition: box-shadow 0.2s, transform 0.1s, border-color 0.15s;
}
body.brand-terminology-edu .library-card:hover,
body.brand-terminology-edu .story-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 6px 16px var(--shadow);
}

/* Editor toolbar: lighter, crisper */
body.brand-terminology-edu .toolbar-btn,
body.brand-terminology-edu .toolbar .btn-small {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-weight: 500;
}
body.brand-terminology-edu .toolbar-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
body.brand-terminology-edu .toolbar-btn-publish {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
body.brand-terminology-edu .toolbar-btn-publish:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
body.brand-terminology-edu .toolbar-btn-publish.is-published {
  background: var(--success);
  border-color: var(--success);
}

/* Modals: rounded, generous */
body.brand-terminology-edu .modal-overlay {
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
body.brand-terminology-edu .modal-content,
body.brand-terminology-edu .sheet {
  background: #ffffff;
  color: var(--text);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

/* Inputs: clean, focused ring */
body.brand-terminology-edu input[type="text"],
body.brand-terminology-edu input[type="email"],
body.brand-terminology-edu input[type="search"],
body.brand-terminology-edu textarea,
body.brand-terminology-edu select {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
body.brand-terminology-edu input[type="text"]:focus,
body.brand-terminology-edu input[type="email"]:focus,
body.brand-terminology-edu textarea:focus,
body.brand-terminology-edu select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Player: brighter feedback, keep reading experience calm */
body.brand-terminology-edu #player-screen {
  background: var(--bg);
}
body.brand-terminology-edu .player-wrap {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 2px 10px var(--shadow);
  padding: 2rem;
}

/* Feedback pill (rendered by player.js — base styles defined inline, but expose a hook) */
body.brand-terminology-edu .feedback-pill {
  box-shadow: 0 1px 2px var(--shadow);
}

/* Choice buttons: pill-ish, obvious tap targets */
body.brand-terminology-edu .choice-btn {
  background: #ffffff;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  margin-bottom: 0.75rem;
}
body.brand-terminology-edu .choice-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Map card feedback-type border (applied via data attribute on the card — see editor-track.js if needed) */
body.brand-terminology-edu .node-card[data-feedback="correct"] { box-shadow: inset 4px 0 0 #10b981; }
body.brand-terminology-edu .node-card[data-feedback="incorrect"] { box-shadow: inset 4px 0 0 #ef4444; }
body.brand-terminology-edu .node-card[data-feedback="partial"] { box-shadow: inset 4px 0 0 #f59e0b; }
body.brand-terminology-edu .node-card[data-feedback="info"] { box-shadow: inset 4px 0 0 #3b82f6; }

/* Edu landing additions (injected by edu-landing.js) */
body.brand-terminology-edu .edu-eyebrow {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.5rem;
}

body.brand-terminology-edu .edu-use-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
body.brand-terminology-edu .edu-use-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.35rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
body.brand-terminology-edu .edu-use-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 4px 12px var(--shadow);
}
body.brand-terminology-edu .edu-use-card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--text);
}
body.brand-terminology-edu .edu-use-card p {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

body.brand-terminology-edu .edu-pricing .pricing-cards {
  justify-content: center;
}
body.brand-terminology-edu .edu-pricing .pricing-card {
  max-width: 420px;
  width: 100%;
}

body.brand-terminology-edu .landing-use-cases {
  padding: 3rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}
body.brand-terminology-edu .landing-use-cases h2 {
  text-align: center;
  color: var(--text);
  letter-spacing: -0.02em;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* --- end edu brand theme --- */

/* --- Auth Header / Nav Bar --- */
.auth-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  min-height: 44px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-nav-link {
  font-family: sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.header-nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.header-nav-link.nav-active {
  color: var(--text);
  background: var(--bg);
}

.header-nav-cta {
  color: var(--accent);
  font-weight: 600;
}

.header-nav-cta:hover {
  color: var(--accent-hover);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.auth-name {
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text-muted);
}

.auth-signin {
  text-decoration: none;
}

/* --- Library Tabs --- */
.library-tabs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.tab-active {
  border-color: var(--accent);
  color: var(--text);
}

.sort-controls {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

.sort-controls .btn-small {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  min-height: 36px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --- Upvote --- */
.upvote-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0.4rem;
  margin: -0.4rem;
}

.upvote-btn:hover {
  color: var(--accent);
}

.upvote-btn.upvoted {
  color: var(--accent);
}

.upvote-btn.upvoted .upvote-icon {
  fill: var(--accent);
}

.upvote-icon {
  width: 16px;
  height: 16px;
  vertical-align: -2px;
}

/* --- Status Filters --- */
.library-filters {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.filter-chip {
  font-family: sans-serif;
  font-size: 0.78rem;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.filter-chip:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.filter-chip.filter-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.filter-chip .filter-count {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* --- Badges --- */
.published-badge {
  font-size: 0.75rem;
  background: var(--success);
  color: var(--text-on-accent);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: sans-serif;
  text-transform: uppercase;
  vertical-align: middle;
}

.draft-badge {
  font-size: 0.75rem;
  background: var(--text-muted);
  color: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: sans-serif;
  text-transform: uppercase;
  vertical-align: middle;
}

.unlisted-badge {
  font-size: 0.75rem;
  background: #6366f1;
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: sans-serif;
  text-transform: uppercase;
  vertical-align: middle;
}

/* --- Screens --- */
.screen {
  display: none;
}

.screen.active {
  display: flex;
}

/* --- Library Screen --- */
#library-screen {
  flex-direction: column;
  min-height: 100vh;
}

.library-header {
  text-align: center;
  padding: 1rem 1.5rem;
}

.library-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.library-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.library-empty p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.signin-cta {
  margin-top: 1rem;
}

.signin-gate {
  text-align: center;
  padding: 4rem 2rem;
  max-width: 440px;
  margin: 0 auto;
  grid-column: 1 / -1;
}

.signin-gate h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.signin-gate-sub {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.signin-gate-features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  text-align: left;
  display: inline-block;
}

.signin-gate-features li {
  padding: 0.35rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.signin-gate-features li::before {
  content: '\2713 ';
  color: var(--accent);
  margin-right: 0.5rem;
}

.signin-gate-back {
  display: block;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.signin-gate-back:hover {
  color: var(--text);
}

.story-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  border-left: 3px solid var(--border);
}

.story-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--shadow);
}

.story-card.status-published {
  border-left-color: var(--success);
}

.story-card.status-unlisted {
  border-left-color: #6366f1;
}

.story-card.status-draft {
  border-left-color: var(--text-muted);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.story-card h3 {
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-card .card-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.story-card .card-description {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-card .card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-stats {
  display: flex;
  gap: 0.75rem;
  font-family: sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.card-stat-icon {
  display: inline-flex;
  align-items: center;
}

.card-stat svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.card-timestamp {
  font-family: sans-serif;
  font-size: 0.73rem;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.15rem;
}

/* --- Overflow Menu --- */
.card-overflow-wrap {
  position: relative;
}

.card-overflow-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  letter-spacing: 1px;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.card-overflow-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.card-overflow-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0;
  min-width: 160px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 100;
  display: none;
}

.card-overflow-menu.open {
  display: block;
}

.card-overflow-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: sans-serif;
  font-size: 0.82rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.card-overflow-menu button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.card-overflow-menu button.menu-danger {
  color: var(--danger);
}

.card-overflow-menu button.menu-danger:hover {
  background: var(--danger);
  color: var(--text-on-accent);
}

.card-overflow-menu .menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* --- Share Modal --- */
.share-modal-url {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}

.share-modal-url input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.82rem;
  min-width: 0;
}

.share-modal-url input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.share-modal-url .btn-small {
  flex-shrink: 0;
}

/* --- Player Screen --- */
#player-screen {
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

#player-screen .player-wrap {
  width: 100%;
  max-width: var(--max-width);
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Title sub-screen within player */
.player-title {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
}

.player-title.active {
  display: flex;
}

.player-title h2 {
  font-size: 2.4rem;
  font-weight: bold;
  color: var(--text);
  line-height: 1.2;
}

.player-title .author {
  font-size: 1rem;
  color: var(--text-muted);
  font-style: italic;
}

.player-title .description {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 500px;
  margin-top: 0.5rem;
}

.title-actions {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Story reading sub-screen */
.player-story {
  flex: 1;
  display: none;
  flex-direction: column;
}

.player-story.active {
  display: flex;
}

.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.story-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

#node-content {
  flex: 1;
}

#node-image {
  width: 100%;
  max-height: 350px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: none;
}

#node-text {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text);
}

#node-text p { margin-bottom: 1rem; }
#node-text em { color: var(--preview); }
#node-text strong { color: var(--text-on-accent); }

#choices {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 3rem;
}

.choice-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Georgia', serif;
  font-size: 1.05rem;
  text-align: left;
  line-height: 1.5;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.choice-btn:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  transform: translateX(4px);
}

.ending-marker {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.ending-marker p {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
}

/* --- Comments Panel --- */
.comments-toggle-btn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: sans-serif;
  cursor: pointer;
  z-index: var(--z-header);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.comments-toggle-btn:hover {
  filter: brightness(1.1);
}
.comments-badge {
  display: inline-block;
  background: var(--danger, #e94560);
  color: #fff;
  border-radius: 10px;
  padding: 0 0.4rem;
  font-size: 0.7rem;
  margin-left: 0.4rem;
  min-width: 1.2rem;
  text-align: center;
}
.comments-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: var(--z-editor);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}
.comments-panel.open {
  right: 0;
}
.comments-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.comments-panel-header h3 {
  font-family: sans-serif;
  font-size: 1rem;
  margin: 0;
}
.comments-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.comments-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}
.comments-section {
  margin-bottom: 1rem;
}
.comments-section h4 {
  font-family: sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.comment-item {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
  font-family: sans-serif;
  font-size: 0.85rem;
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.comment-header strong {
  font-size: 0.85rem;
}
.comment-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.comment-anchor {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
  font-style: italic;
}
.comment-body {
  line-height: 1.4;
}
.comment-form {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}
.comment-name-input,
.comment-text-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-family: sans-serif;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.comment-text-input {
  resize: vertical;
}
.comment-form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.comment-anchor-select {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* --- Editor Screen --- */
body.editor-active #auth-header {
  display: none;
}

#editor-screen {
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  inset: 0;
  z-index: var(--z-editor);
  overflow: hidden;
  background: var(--bg);
}

#track-viewport {
  will-change: transform;
}

.editor-loading .track-canvas {
  opacity: 0;
}

.editor-loading::after {
  content: 'Loading story\2026';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-family: sans-serif;
  font-size: 0.9rem;
}

/* --- Editor Top Bar --- */
.editor-floating-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-toolbar);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  white-space: nowrap;
}

.toolbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: sans-serif;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.toolbar-title {
  font-family: 'Georgia', serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 0.15rem;
  flex-shrink: 0;
}

.editor-dirty .toolbar-dirty-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--warning);
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

.toolbar-btn-publish {
  color: var(--accent);
}

.toolbar-btn-publish:hover {
  color: var(--accent-hover);
  background: var(--surface-hover);
}

.toolbar-btn-publish.is-published {
  color: var(--success);
}

/* --- Track Canvas --- */
.track-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.track-canvas:active {
  cursor: grabbing;
}

/* --- Track Cards (nodes as pages) --- */
.card-bg {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1.5;
}

.track-card:hover .card-bg {
  stroke: var(--accent);
}

.card-bg.selected {
  stroke: var(--accent);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(233, 69, 96, 0.35));
}

.card-bg.start {
  stroke: var(--success);
  stroke-width: 2;
}

.card-bg.start.selected {
  stroke: var(--success);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(76, 175, 80, 0.35));
}

.card-bg.ending {
  stroke-dasharray: 6 3;
}

.card-bg.empty {
  fill: var(--bg);
}

.card-title {
  fill: var(--text);
  font-size: 11px;
  font-family: monospace;
  text-anchor: middle;
  pointer-events: none;
  font-weight: bold;
}

.card-preview {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: 'Georgia', serif;
  text-anchor: middle;
  pointer-events: none;
}

.card-info {
  fill: var(--text-muted);
  font-size: 9px;
  font-family: sans-serif;
  text-anchor: middle;
  pointer-events: none;
  opacity: 0.8;
}

.card-info.card-end {
  fill: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.card-start-dot {
  fill: var(--success);
}

/* --- Track Edges --- */
.track-edge {
  stroke: var(--border);
  stroke-width: 2;
  fill: none;
  opacity: 0.6;
}

/* Reduce rendering cost during pan/zoom */
svg.panning { shape-rendering: optimizeSpeed; }
svg.panning .edge-label,
svg.panning .edge-label-bg { visibility: hidden; }
svg.panning .card-preview,
svg.panning .card-info,
svg.panning .card-end,
svg.panning .card-start-dot,
svg.panning .connector-handle,
svg.panning .card-drag-handle { visibility: hidden; }
svg.panning .track-edge-hit { pointer-events: none; }
svg.panning .track-grid { visibility: hidden; }

.edge-label {
  font-size: 10px;
  font-family: sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  fill: var(--text);
}

.track-edge-dim {
  opacity: 0.15 !important;
}

.track-edge.route-highlight { opacity: 1; stroke-width: 3px; }
.track-edge.route-dim { opacity: 0.1; }
.edge-label.route-dim { opacity: 0.1; }
.card-bg.route-dim { opacity: 0.4; }

/* --- Track Tooltip --- */
.track-tooltip {
  position: absolute;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  max-width: 320px;
  font-size: 0.8rem;
  font-family: 'Georgia', serif;
  line-height: 1.4;
  pointer-events: none;
  z-index: var(--z-editor);
  box-shadow: 0 4px 16px var(--shadow);
}

.track-tooltip-id {
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.track-tooltip-text {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  white-space: pre-wrap;
}

.track-tooltip-choices {
  font-family: sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--border);
}

.track-tooltip-choice {
  margin: 0.15rem 0;
}

.track-tooltip-choice-num {
  font-weight: bold;
}

/* --- Drag Handle --- */
.drag-dot {
  fill: var(--text-muted);
  opacity: 0.4;
  pointer-events: none;
}

.card-drag-handle:hover .drag-dot {
  opacity: 0.8;
}

/* --- Node Context Menu --- */
.node-context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  z-index: var(--z-editor);
  min-width: 180px;
  box-shadow: 0 4px 20px var(--shadow);
  animation: ctx-in 0.1s ease;
}

@keyframes ctx-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.node-context-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.75rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  font-family: sans-serif;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}

.node-context-item:hover {
  background: var(--accent);
  color: var(--text-on-accent);
}

.node-context-item.danger {
  color: var(--danger);
}

.node-context-item.danger:hover {
  background: var(--danger);
  color: var(--text-on-accent);
}

.ctx-icon {
  width: 1.1em;
  text-align: center;
  font-size: 0.9rem;
}

/* --- Edge Interactions --- */
.track-edge-hover {
  stroke-width: 3.5 !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 4px currentColor);
}

.track-edge-hit {
  pointer-events: stroke;
}

/* --- Edge Popover --- */
.edge-popover {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  z-index: var(--z-editor);
  min-width: 200px;
  box-shadow: 0 4px 20px var(--shadow);
  animation: ctx-in 0.1s ease;
}

.edge-pop-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.edge-pop-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: sans-serif;
}

.edge-pop-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  font-family: sans-serif;
}

.edge-pop-input:focus {
  border-color: var(--accent);
  outline: none;
}

.edge-pop-remove {
  width: 100%;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 4px;
  padding: 0.3rem;
  font-size: 0.75rem;
  font-family: sans-serif;
  cursor: pointer;
  margin-top: 0.25rem;
}

.edge-pop-remove:hover {
  background: var(--danger);
  color: var(--text-on-accent);
}

/* --- Connector Handle --- */
.connector-handle {
  opacity: 0;
  cursor: crosshair;
  transition: opacity 0.15s;
}

.track-card:hover .connector-handle {
  opacity: 1;
}

.connector-dot {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.connector-plus {
  fill: var(--accent);
  font-size: 11px;
  font-family: sans-serif;
  font-weight: bold;
  text-anchor: middle;
  pointer-events: none;
}

.connecting-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  fill: none;
  pointer-events: none;
}

/* --- Multi-Select --- */
.card-bg.multi-selected {
  stroke: var(--accent);
  stroke-width: 2.5;
  animation: multi-sel-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes multi-sel-pulse {
  from { filter: drop-shadow(0 0 4px rgba(233, 69, 96, 0.3)); }
  to { filter: drop-shadow(0 0 10px rgba(233, 69, 96, 0.5)); }
}

/* --- Selection Toolbar --- */
.selection-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: var(--z-selection);
  box-shadow: 0 4px 16px var(--shadow);
  animation: ctx-in 0.15s ease;
}

.sel-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: sans-serif;
  white-space: nowrap;
}

.sel-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-family: sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.sel-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.sel-btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.sel-btn-danger:hover {
  background: var(--danger);
  color: var(--text-on-accent);
}

.sel-btn-accept {
  background: var(--success);
  border-color: var(--success);
  color: var(--text-on-accent);
}

.sel-btn-accept:hover {
  filter: brightness(1.15);
}

.sel-btn-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.2rem 0.4rem;
}

.sel-btn-clear:hover {
  color: var(--text);
}

/* --- Zoom Controls --- */
.track-zoom-controls {
  position: absolute;
  bottom: 24px;
  right: 16px;
  z-index: var(--z-fab);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.zoom-btn {
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  font-family: sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.zoom-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.zoom-btn.layout-horizontal {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- FAB (Add Node) --- */
.fab {
  position: absolute;
  bottom: 24px;
  left: 16px;
  z-index: var(--z-fab);
  width: 48px;
  height: 48px;
  background: var(--accent);
  border: none;
  color: var(--text-on-accent);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  font-family: sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--accent-soft);
  transition: background 0.2s, transform 0.1s;
}

.fab:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

/* --- Focus Indicators --- */
.toolbar-btn:focus-visible,
.zoom-btn:focus-visible,
.modal-close-btn:focus-visible,
.help-menu-item:focus-visible,
.adv-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.fab:focus-visible {
  outline: 2px solid var(--text-on-accent);
  outline-offset: 2px;
}

.btn:focus-visible {
  outline: 2px solid var(--text-on-accent);
  outline-offset: 2px;
}

.btn-outline:focus-visible,
.btn-small:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.track-card:focus-visible .card-bg {
  stroke: var(--accent);
  stroke-width: 2.5;
}

/* --- Modal Sheet --- */
.modal-sheet-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-modal-sheet);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-sheet-overlay.modal-open {
  opacity: 1;
}

.modal-sheet-overlay.modal-closing {
  opacity: 0;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-open .modal-sheet {
  transform: translateY(0);
}

.modal-closing .modal-sheet {
  transform: translateY(100%);
}

.modal-sheet-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 85vh;
}

.modal-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.modal-sheet-header h3 {
  font-size: 1rem;
  color: var(--text);
  font-family: sans-serif;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.modal-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.modal-sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Desktop: centered dialog instead of bottom sheet */
@media (min-width: 769px) {
  .modal-sheet-overlay {
    align-items: center;
  }

  .modal-sheet {
    border-radius: 12px;
    max-height: 80vh;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
  }

  .modal-open .modal-sheet {
    transform: translateY(0);
    opacity: 1;
  }

  .modal-closing .modal-sheet {
    transform: translateY(20px);
    opacity: 0;
  }

  .modal-sheet-content {
    max-height: 80vh;
  }
}

/* --- Node Editor Modal --- */
.node-textarea {
  width: 100%;
  min-height: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem;
  border-radius: 6px;
  font-family: 'Georgia', serif;
  font-size: 0.95rem;
  resize: vertical;
  line-height: 1.7;
}

.node-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.choices-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
  font-family: sans-serif;
}

.adv-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: sans-serif;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-top: 0.75rem;
  opacity: 0.7;
}

.adv-toggle:hover {
  color: var(--text);
  opacity: 1;
}

.adv-section {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

/* --- Settings sections --- */
.settings-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-family: sans-serif;
}

/* --- Help Menu --- */
.help-menu-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.help-menu-item:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.help-menu-item strong {
  font-size: 0.9rem;
  font-family: sans-serif;
  color: var(--text);
}

.help-menu-item span {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: sans-serif;
}

.help-shortcuts {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.help-shortcuts h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-family: sans-serif;
}

.help-shortcuts div {
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.help-shortcuts kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--text);
  margin-right: 0.5rem;
}

/* --- Editor Field (shared across modals) --- */
.editor-field {
  margin-bottom: 0.75rem;
}

.editor-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-family: sans-serif;
}

.editor-field input,
.editor-field textarea,
.editor-field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-family: 'Georgia', serif;
  font-size: 0.95rem;
  resize: vertical;
}

.editor-field input:focus,
.editor-field textarea:focus,
.editor-field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.editor-field textarea {
  min-height: 150px;
}

.editor-field-label {
  margin-bottom: 0.5rem;
}
.editor-field-label input {
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  font-family: sans-serif;
}

/* Choice editor rows */
.choice-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.choice-row input {
  flex: 2;
}

.choice-row select {
  flex: 1;
}

.choice-row .btn-icon {
  flex-shrink: 0;
}

.choice-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.choice-target-wrap {
  position: relative;
  flex: 1;
}

.choice-target-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: monospace;
}

.choice-target-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.choice-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.status-has-content { background: var(--success); }
.status-empty { background: var(--warning); }
.status-missing { background: var(--danger); }

.choice-target-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: var(--z-toolbar);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px var(--shadow);
  max-height: 160px;
  overflow-y: auto;
  display: none;
}

.choice-target-dropdown.open {
  display: block;
}

.target-dropdown-item {
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.8rem;
  font-family: sans-serif;
  transition: background 0.1s;
}

.target-dropdown-item:hover {
  background: var(--surface-hover);
}

.target-dropdown-item .dd-id {
  color: var(--text);
  font-family: monospace;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.target-dropdown-item .dd-preview {
  color: var(--text-muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Validation list (used in modal) --- */
.validation-list {
  list-style: none;
  padding: 0.5rem 0;
}

.validation-list li {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  font-family: sans-serif;
  border-radius: 4px;
  transition: background 0.15s;
}

.validation-list li:hover {
  background: var(--surface-hover);
}

.val-error { color: var(--danger); }
.val-error::before { content: 'Error: '; font-weight: bold; }
.val-warning { color: var(--warning); }
.val-warning::before { content: 'Warning: '; font-weight: bold; }
.val-ok { color: var(--success); }

.val-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}


/* --- Shared Buttons --- */
.btn {
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  padding: 0.8rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: sans-serif;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn:hover { background: var(--accent-hover); }

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: none;
}

.btn-small {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.45rem 0.75rem;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: sans-serif;
  transition: border-color 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
}

.btn-small:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-small:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-small:disabled:hover {
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-on-accent);
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--text-on-accent);
}

.btn-small.btn-danger {
  background: none;
  color: var(--danger);
}

.btn-small.btn-danger:hover {
  background: var(--danger);
  color: var(--text-on-accent);
}

.btn-small.btn-danger-armed {
  background: var(--danger);
  color: var(--text-on-accent);
  border-color: var(--danger);
}


/* --- Story Bible Characters --- */
.bible-character {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.bible-character-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.bible-character-header input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: sans-serif;
}

.bible-character-header input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.bible-character textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: sans-serif;
  resize: vertical;
  min-height: 50px;
}

.bible-character textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

/* --- AI Toolbar --- */
.ai-toolbar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.ai-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-color: var(--ai-border);
  color: var(--ai-text);
}

.ai-btn:hover {
  border-color: var(--ai-text);
  color: var(--ai-text-hover);
}

.ai-stop-btn {
  border-color: var(--danger);
  color: var(--danger);
}

.ai-model-select {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.2rem 0.35rem;
  background: var(--bg);
  border: 1px solid var(--ai-border);
  color: var(--ai-text);
  border-radius: 4px;
  cursor: pointer;
}

.ai-model-select:focus {
  outline: 2px solid var(--ai-text);
  outline-offset: -1px;
  border-color: var(--ai-text);
}

.ai-custom-input {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.ai-custom-input input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--ai-border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: sans-serif;
}

.ai-custom-input input:focus {
  outline: 2px solid var(--ai-text);
  outline-offset: -1px;
  border-color: var(--ai-text);
}

/* --- AI Accept/Reject Bar --- */
.ai-accept-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 6px;
}

.ai-accept-label {
  font-size: 0.75rem;
  color: var(--ai-text);
  font-family: sans-serif;
  margin-right: auto;
}

.ai-accept-btn {
  border-color: var(--success);
  color: var(--success);
}

/* --- AI Generating Animation --- */
.ai-generating {
  border-color: var(--ai-text);
  animation: aiPulse 1.5s ease-in-out infinite;
}

@keyframes aiPulse {
  0%, 100% { border-color: var(--ai-pulse-from); }
  50% { border-color: var(--ai-pulse-to); }
}

/* --- AI Choice Suggestions --- */
.ai-suggestion-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ai-suggestion-card {
  background: var(--bg);
  border: 1px solid var(--ai-border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.ai-suggestion-card .suggestion-text {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.ai-suggestion-card .suggestion-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.ai-suggestion-card .suggestion-actions {
  display: flex;
  gap: 0.35rem;
}

/* --- AI Spinner --- */
.ai-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ai-border);
  border-top-color: var(--ai-text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Outline / Structure --- */
.outline-params {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.outline-params .editor-field {
  flex: 1;
}

.outline-params select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: sans-serif;
}

.outline-preview-content {
  max-height: 65vh;
  overflow-y: auto;
  padding: 0 0 1rem;
  margin: 0.5rem 0 0;
}

.outline-header {
  margin-bottom: 1rem;
}

.outline-title {
  font-size: 1rem;
  margin: 0 0 0.25rem;
  color: var(--text);
  border-radius: 3px;
  padding: 0.1rem 0.2rem;
  margin-left: -0.2rem;
}

.outline-title[contenteditable]:hover {
  outline: 1px dashed var(--border);
}

.outline-title[contenteditable]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.outline-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  border-radius: 3px;
  padding: 0.1rem 0.2rem;
  margin-left: -0.2rem;
}

.outline-desc[contenteditable]:hover {
  outline: 1px dashed var(--border);
}

.outline-desc[contenteditable]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.outline-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: sans-serif;
}

.outline-nodes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.outline-node {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.outline-node.start {
  border-left-color: var(--success);
}

.outline-node.ending {
  border-left-color: var(--accent);
}

.outline-node-id {
  display: inline-block;
  font-size: 0.7rem;
  font-family: monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

.outline-node-summary {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: text;
  min-height: 1.2em;
}

.outline-node-summary:hover {
  border-color: var(--border);
}

.outline-node-summary:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
  background: var(--surface);
}

.outline-node-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.outline-choice {
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  color: var(--text-muted);
  font-family: sans-serif;
}

.outline-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: sans-serif;
}

/* --- Outline Expansion (Prose Writing Phase) --- */
.expansion-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: sans-serif;
  margin-bottom: 0.5rem;
}

.expansion-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.expansion-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.expansion-node-list {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.expansion-node {
  font-size: 0.8rem;
  font-family: sans-serif;
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
}

.expansion-node.writing {
  opacity: 1;
  border-color: var(--accent);
  color: var(--text);
}

.expansion-node.done {
  opacity: 0.8;
  color: var(--text);
}

.expansion-node.done::before {
  content: '\2713 ';
  color: var(--success);
}

.expansion-node.error {
  opacity: 0.8;
  border-color: var(--danger);
  color: var(--text-muted);
}

.expansion-node.error::before {
  content: '\2717 ';
  color: var(--danger);
}

.expansion-node-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  max-height: 2.4em;
  overflow: hidden;
  line-height: 1.2;
  font-style: italic;
}

/* --- Splinter Modal --- */
.splinter-modal-sheet {
  max-width: 750px;
}

.splinter-narrative-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  overflow-y: auto;
  margin-bottom: 0.25rem;
  opacity: 0.7;
  transition: max-height 0.3s ease;
}

.splinter-narrative-preview.collapsed {
  max-height: 4.5em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.splinter-narrative-preview p {
  margin: 0 0 0.5em;
}

.splinter-narrative-preview p:last-child {
  margin-bottom: 0;
}

.splinter-narrative-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.75rem;
  font-family: sans-serif;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.5rem;
}

.splinter-narrative-toggle:hover {
  text-decoration: underline;
}

.splinter-review-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.splinter-points-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 45vh;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.splinter-point-card {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  transition: opacity 0.2s;
}

.splinter-point-card.disabled {
  opacity: 0.35;
  background: var(--surface);
}

.splinter-point-card.disabled .splinter-point-question {
  text-decoration: line-through;
  color: var(--text-muted);
}

.splinter-point-card input[type="checkbox"] {
  margin-top: 0.3rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.splinter-point-question {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: sans-serif;
}

.splinter-point-question:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.splinter-point-meta {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.splinter-point-location {
  display: inline-block;
  font-size: 0.7rem;
  width: fit-content;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 0.2rem;
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.splinter-point-reason {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim, var(--text-muted));
  font-family: sans-serif;
  margin-top: 0.15rem;
  font-style: italic;
  line-height: 1.3;
}

.splinter-char-counter {
  text-align: right;
  font-size: 0.75rem;
  font-family: sans-serif;
  color: var(--text-muted);
  margin-top: 0.25rem;
  opacity: 0.7;
}

.splinter-char-counter.over-limit {
  color: var(--danger);
  opacity: 1;
  font-weight: 600;
}

.splinter-loading-text {
  transition: opacity 0.4s ease;
}

.splinter-loading-text.fade-out,
.structure-loading-text.fade-out {
  opacity: 0;
}

.structure-loading-text {
  transition: opacity 0.4s ease;
}

.structure-loading-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.structure-loading-hint {
  font-size: 0.75rem;
  color: var(--text-dim, var(--text-muted));
  opacity: 0.6;
}

/* --- Structure Hub Modal --- */
.structure-modal-sheet {
  max-width: 750px;
}

.structure-hub-title-field {
  margin-bottom: 1rem;
}
.structure-hub-title-field label {
  display: block;
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.structure-hub-title-field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-family: 'Georgia', serif;
  font-size: 1.1rem;
}
.structure-hub-title-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.structure-hub-info {
  font-size: 0.8rem;
  font-family: sans-serif;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.structure-hub-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.structure-hub-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.structure-hub-card:hover,
.structure-hub-card:focus-visible {
  border-color: var(--accent);
  background: var(--surface-hover, rgba(255,255,255,0.03));
}

.structure-hub-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.structure-hub-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: sans-serif;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.structure-hub-card-desc {
  font-size: 0.8rem;
  font-family: sans-serif;
  color: var(--text-muted);
  line-height: 1.4;
}

.structure-hub-card-warn {
  font-size: 0.75rem;
  font-family: sans-serif;
  color: var(--danger);
  margin-top: 0.25rem;
  font-style: italic;
}

/* --- Structure Preview Enhancements --- */
.outline-node {
  position: relative;
}

.outline-node-delete {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.3rem;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.outline-node:hover .outline-node-delete {
  opacity: 1;
}

.outline-node-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.outline-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  cursor: default;
}

.outline-choice-text {
  cursor: pointer;
}

.outline-choice-text:hover {
  color: var(--text);
  text-decoration: underline;
}

.outline-choice-text.placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.outline-choice-target {
  cursor: pointer;
  font-family: monospace;
  font-size: 0.7rem;
}

.outline-choice-target:hover {
  color: var(--text);
  text-decoration: underline;
}

.outline-choice-edit {
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.75rem;
  font-family: sans-serif;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  width: 120px;
}

.outline-choice-target-select {
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.7rem;
  font-family: monospace;
  padding: 0.1rem;
  border-radius: 3px;
}

.outline-choice-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}

.outline-choice:hover .outline-choice-remove {
  opacity: 1;
}

.outline-choice-remove:hover {
  color: var(--danger);
}

.outline-add-choice-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: sans-serif;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.outline-add-choice-btn:hover {
  opacity: 1;
  color: var(--accent);
}

.outline-add-node-btn {
  display: block;
  width: 100%;
  background: none;
  border: 2px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: sans-serif;
  padding: 0.6rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: border-color 0.15s, color 0.15s;
}

.outline-add-node-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Branch Wizard Modal --- */
.branch-modal-sheet {
  max-width: 750px;
}

.branch-source-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 80px;
  overflow-y: auto;
  white-space: pre-wrap;
  opacity: 0.7;
}

.branch-radio-label {
  display: block;
  font-family: sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.35rem 0;
  cursor: pointer;
}

.branch-radio-label input[type="radio"] {
  accent-color: var(--accent);
  margin-right: 0.4rem;
}

.branch-idea-field {
  margin-top: 0.5rem;
}

.branch-idea-field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: sans-serif;
  resize: vertical;
}

.branch-idea-field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.branch-plans-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.branch-plan-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.branch-plan-card:hover {
  border-color: var(--ai-border);
  box-shadow: 0 0 0 1px var(--ai-border);
}

.branch-plan-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.branch-plan-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}

.branch-plan-premise {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.branch-plan-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.branch-type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-family: sans-serif;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.branch-type-badge.ending {
  background: rgba(233, 69, 96, 0.2);
  color: var(--accent);
  border: 1px solid rgba(233, 69, 96, 0.4);
}

.branch-type-badge.convergence {
  background: var(--convergence-soft);
  color: var(--convergence);
  border: 1px solid var(--convergence-border);
}

.branch-plan-size {
  font-size: 0.75rem;
  font-family: sans-serif;
  color: var(--text-muted);
}

.branch-plan-edits {
  font-size: 0.75rem;
  font-family: sans-serif;
  color: var(--warning);
  margin-top: 0.35rem;
}

.branch-plan-explain {
  font-size: 0.8rem;
  font-family: sans-serif;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.3rem;
  line-height: 1.3;
}

.branch-new-choice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--preview);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text);
}

.branch-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.branch-edits-header {
  font-size: 0.85rem;
  font-weight: 600;
  font-family: sans-serif;
  color: var(--warning);
  margin: 1rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--warning-soft);
}

.branch-edit-card {
  background: var(--bg);
  border: 1px solid var(--warning-soft);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
}

.branch-edit-old {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.6;
  margin: 0.3rem 0;
  line-height: 1.4;
}

.branch-edit-new {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: text;
  min-height: 1.2em;
}

.branch-edit-new:hover {
  border-color: var(--border);
}

.branch-edit-new:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
  background: var(--surface);
}

.branch-loading-text {
  transition: opacity 0.4s ease;
}

.branch-loading-text.fade-out {
  opacity: 0;
}

/* --- Track Preview Overlay --- */
.card-bg.preview {
  stroke: var(--preview);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  fill: rgba(199, 146, 234, 0.08);
  filter: drop-shadow(0 0 6px var(--preview-soft));
}

.track-edge-preview {
  stroke-dasharray: 8 4;
  filter: drop-shadow(0 0 4px var(--preview-soft));
  opacity: 0.8;
}

.preview-dimmer {
  fill: rgba(26, 26, 46, 0.65);
  pointer-events: none;
}

.card-bg.will-edit {
  fill: none;
  stroke: var(--warning);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  pointer-events: none;
}

/* --- Fade animation --- */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

/* --- Toast notifications --- */
.toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--text-muted);
  font-family: sans-serif;
  font-size: 0.85rem;
  z-index: var(--z-toast);
  box-shadow: 0 4px 20px var(--overlay);
  animation: toastIn 0.3s ease-out;
}

.toast.toast-leaving {
  animation: toastOut 0.2s ease-in forwards;
}

.toast-success { border-bottom-color: var(--success); }
.toast-error   { border-bottom-color: var(--danger); }
.toast-info    { border-bottom-color: var(--accent); }

.toast-undo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.toast-undo-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 3px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: sans-serif;
}

.toast-undo-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-100%); }
}

/* --- Analytics Dashboard --- */
.analytics-stat-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.analytics-stat {
  text-align: center;
  flex: 1;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
}
.analytics-stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text);
}
.analytics-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.analytics-heat-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.analytics-heat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.analytics-heat-label {
  width: 120px;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.analytics-heat-bar {
  flex: 1;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.analytics-heat-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s;
}
.analytics-heat-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}
.analytics-choice-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.analytics-choice-label {
  width: 120px;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.analytics-choice-bar {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}
.analytics-choice-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
}
.analytics-choice-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 35px;
  text-align: right;
  flex-shrink: 0;
}
.analytics-path-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}
.analytics-teaser {
  text-align: center;
  padding: 1rem;
}
.analytics-teaser-blur {
  filter: blur(4px);
  pointer-events: none;
  opacity: 0.5;
  margin: 1rem 0;
}

/* --- Editor Hints --- */
.editor-hint {
  position: fixed;
  z-index: var(--z-hint);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-family: sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s, transform 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.editor-hint-visible {
  opacity: 1;
  transform: translateY(0);
}
.editor-hint::before {
  content: '\1F4A1';
  font-size: 1rem;
  flex-shrink: 0;
}
.editor-hint-text {
  flex: 1;
}
.editor-hint-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
  flex-shrink: 0;
}
.editor-hint-close:hover {
  color: var(--text);
}

/* --- Confirm dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
}

.modal-box p {
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.modal-box .modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* --- Landing Page --- */
#home-screen {
  flex-direction: column;
  min-height: 100vh;
}

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem 3rem;
}

.landing-headline {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--text);
  line-height: 1.2;
  max-width: 720px;
}

.landing-tagline {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
  max-width: 520px;
  line-height: 1.6;
}

.hero-screenshot {
  margin-top: 2.5rem;
  max-width: 860px;
  width: 100%;
}

.hero-screenshot img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.landing-ctas {
  display: flex;
  gap: 1rem;
  margin-top: 2.5rem;
}

.landing-ctas .btn {
  text-decoration: none;
  display: inline-block;
}

.landing-stats {
  margin-top: 1.5rem;
  min-height: 1.5em;
  font-family: sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.landing-scroll-hint {
  display: inline-block;
  margin-top: 2rem;
  font-family: sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  animation: scroll-bounce 2s ease-in-out infinite;
  transition: color 0.2s;
}

.landing-scroll-hint:hover {
  color: var(--text);
}

@keyframes scroll-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .landing-scroll-hint {
    animation: none;
  }
}

/* --- Step Features (within How It Works) --- */
.step-features {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  text-align: left;
}

.step-features li {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.25rem 0;
}

.step-features li::before {
  content: '\2713';
  color: var(--accent);
  font-weight: bold;
  margin-right: 0.5rem;
}

.step-features strong {
  color: var(--text);
}

/* --- Landing Demo --- */
.landing-demo {
  text-align: center;
  padding: 4rem 2rem;
  border-top: 1px solid var(--border);
}

.landing-demo h2 {
  font-size: 1.8rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.landing-demo-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.demo-container {
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  text-align: left;
}

.demo-text {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text);
}

.demo-text p { margin-bottom: 1rem; }
.demo-text em { color: var(--text-muted); }
.demo-text strong { color: var(--text-on-accent); }

#demo-choices {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.demo-ending {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.demo-ending .btn {
  text-decoration: none;
  display: inline-block;
}

.landing-how {
  text-align: center;
  padding: 4rem 2rem;
  border-top: 1px solid var(--border);
}

.landing-how h2 {
  font-size: 1.8rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.landing-how-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 3rem;
}

.landing-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.landing-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem 1.5rem;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: var(--text-on-accent);
  border-radius: 50%;
  font-family: sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.landing-step h3 {
  font-size: 1.1rem;
  color: var(--text);
}

.landing-step p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 300px;
}

.landing-pricing {
  text-align: center;
  padding: 4rem 2rem;
  border-top: 1px solid var(--border);
}

.landing-pricing h2 {
  font-size: 1.6rem;
  color: var(--text);
  margin-bottom: 1rem;
}

.landing-pricing-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.landing-pricing .btn {
  text-decoration: none;
  display: inline-block;
}

.pricing-cards {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 2rem;
  width: 320px;
  text-align: center;
  position: relative;
  font-family: sans-serif;
  display: flex;
  flex-direction: column;
}

.pricing-card-pro {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(233, 69, 96, 0.15);
}

.pricing-card-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 12px;
  white-space: nowrap;
}

.pricing-card-header {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.pricing-card-price {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.pricing-period {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
}

.pricing-card-alt {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.pricing-card-features {
  list-style: none;
  text-align: left;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 2;
}

.pricing-card-features li::before {
  content: '\2713';
  color: var(--success);
  margin-right: 0.5rem;
  font-weight: bold;
}

.pricing-card-cta {
  display: block;
  text-decoration: none;
  margin-top: auto;
}

/* --- Landing Pricing Export --- */
.landing-pricing-export {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: sans-serif;
}

/* --- Landing Browse CTA --- */
.landing-browse {
  text-align: center;
  padding: 4rem 2rem;
  border-top: 1px solid var(--border);
}

.landing-browse h2 {
  font-size: 1.6rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.landing-browse-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.landing-browse .btn {
  text-decoration: none;
  display: inline-block;
}

.landing-footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  font-family: sans-serif;
  color: var(--text-muted);
}

.footer-links {
  margin-top: 0.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text);
}

/* --- Legal Pages (Privacy, Accessibility) --- */
.legal-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
  font-family: sans-serif;
  line-height: 1.7;
}

.legal-page h1 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 2rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.legal-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.legal-page h2 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.15rem;
  color: var(--text);
  margin: 2rem 0 0.5rem;
}

.legal-page p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.legal-page ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.legal-page li {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.legal-page a {
  color: var(--accent);
  text-decoration: none;
}

.legal-page a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.legal-page strong {
  color: var(--text);
}

.legal-back {
  margin-top: 3rem;
  text-align: center;
}

.legal-back .btn {
  text-decoration: none;
  display: inline-block;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .landing-steps {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .landing-headline {
    font-size: 2rem;
  }

  .landing-hero {
    padding: 4rem 1.5rem 2rem;
  }

  .hero-screenshot {
    margin-top: 2rem;
  }

  .pricing-card {
    width: 100%;
    max-width: 340px;
  }

  .editor-floating-toolbar {
    padding: 0.3rem 0.5rem;
    gap: 0.15rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 85%, transparent);
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
  }

  .editor-floating-toolbar::-webkit-scrollbar {
    display: none;
  }

  .editor-floating-toolbar.scrolled-end {
    mask-image: none;
    -webkit-mask-image: none;
  }

  .toolbar-title {
    display: none;
  }

  .toolbar-title + .toolbar-separator {
    display: none;
  }

  .toolbar-btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.45rem;
    min-height: 40px;
  }

  .fab {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .choice-row {
    flex-wrap: wrap;
  }

  .choice-row > input[type="text"] {
    flex: 1 1 100%;
    min-width: 0;
  }

  .choice-row > .choice-target-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }
}

@media (max-width: 600px) {
  .header-nav-link { font-size: 0.78rem; padding: 0.3rem 0.5rem; }
  #player-screen .player-wrap { padding: 1.5rem 1rem; }
  .player-title h2 { font-size: 1.8rem; }
  #node-text { font-size: 1.05rem; }

  .library-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .card-overflow-menu {
    min-width: 140px;
  }

  .share-modal-url {
    flex-direction: column;
  }

  .share-modal-url input {
    width: 100%;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Expand with AI Modal --- */
.expand-section-label {
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.expand-choice-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.expand-choice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.expand-choice-card:hover {
  border-color: var(--text-muted);
}

.expand-choice-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.expand-choice-card input[type="radio"] {
  margin-top: 0.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.expand-choice-text {
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.expand-choice-status {
  font-size: 0.75rem;
  font-family: sans-serif;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.expand-depth-toggle {
  display: flex;
  gap: 0.35rem;
}

.expand-depth-btn {
  flex: 1;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.expand-depth-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.expand-depth-btn.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.expand-instruction-toggle {
  display: inline-block;
  background: none;
  border: none;
  color: var(--ai-text);
  font-size: 0.8rem;
  font-family: sans-serif;
  cursor: pointer;
  padding: 0;
  margin-top: 0.75rem;
}

.expand-instruction-toggle:hover {
  color: var(--ai-text-hover);
}

.expand-instruction-input {
  width: 100%;
  margin-top: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  font-family: sans-serif;
  resize: vertical;
}

.expand-instruction-input:focus {
  border-color: var(--accent);
  outline: none;
}

.expand-stats {
  font-size: 0.85rem;
  font-family: sans-serif;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.expand-node-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.expand-node-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.expand-node-item.ending {
  border-left: 3px solid var(--accent);
}

.expand-node-id {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.expand-node-text {
  font-size: 0.8rem;
  font-family: sans-serif;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expand-node-badge {
  font-size: 0.7rem;
  font-family: sans-serif;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Edge Popover Expand Button --- */
.edge-pop-expand {
  width: 100%;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  color: var(--ai-text);
  border-radius: 4px;
  padding: 0.3rem;
  font-size: 0.75rem;
  font-family: sans-serif;
  cursor: pointer;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: border-color 0.15s, color 0.15s;
}

.edge-pop-expand:hover {
  border-color: var(--ai-text);
  color: var(--ai-text-hover);
}

.edge-pop-expand .ctx-icon {
  font-size: 0.85rem;
}

/* --- Shepherd.js Tour Overrides --- */
.shepherd-element {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5) !important;
  max-width: 340px !important;
  font-family: sans-serif !important;
}

.shepherd-text {
  color: var(--text) !important;
  font-size: 0.9rem !important;
  line-height: 1.6 !important;
  padding: 1rem !important;
}

.shepherd-header {
  background: var(--surface) !important;
  padding: 0.75rem 1rem 0 !important;
}

.shepherd-title {
  color: var(--text) !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
}

.shepherd-cancel-icon {
  color: var(--text-muted) !important;
}

.shepherd-cancel-icon:hover {
  color: var(--text) !important;
}

.shepherd-footer {
  padding: 0 1rem 0.75rem !important;
  border-top: none !important;
}

.shepherd-button {
  background: var(--accent) !important;
  border: none !important;
  color: var(--text-on-accent) !important;
  border-radius: 6px !important;
  font-size: 0.85rem !important;
  padding: 0.35rem 0.8rem !important;
  cursor: pointer !important;
}

.shepherd-button:not(:disabled):hover {
  background: var(--accent-hover) !important;
}

.shepherd-button.shepherd-button-secondary {
  background: none !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
}

.shepherd-button.shepherd-button-secondary:hover {
  border-color: var(--text-muted) !important;
  color: var(--text) !important;
}

.shepherd-arrow::before {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

.shepherd-target-click-disabled.shepherd-enabled.shepherd-target,
.shepherd-target-click-disabled.shepherd-enabled.shepherd-target * {
  pointer-events: none !important;
}

.shepherd-modal-overlay-container {
  fill: rgba(0, 0, 0, 0.5) !important;
}

.shepherd-text kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--text);
}

/* Account dropdown */
.account-wrap {
  position: relative;
}

.account-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  color: var(--text-muted);
  font: inherit;
  transition: border-color 0.2s, color 0.2s;
}

.account-trigger:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.account-chevron {
  font-size: 0.7rem;
  margin-left: 0.1rem;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  min-width: 220px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: var(--z-header);
}

.account-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.account-name-row {
  display: flex;
  gap: 0.4rem;
}

.account-name-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

.account-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.account-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.6rem 0;
}

.account-dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0.4rem 0.25rem;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.account-dropdown-item:hover {
  color: var(--text);
  background: var(--surface-hover);
}
