/* === RESET & ROOT === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* aether•Pro•se™ palette — Void Aether dark theme */
  --bg:            #0B0C14;
  --surface:       #12131F;
  --surface2:      #191A2A;
  --surface3:      #202135;
  --border:        #252638;
  --text:          #F4F6FB;
  --muted:         #A7ACBF;
  --accent:        #5B5BFF;
  --accent-hi:     #7B7BFF;
  --success:       #3cc070;
  --warning:       #d4a030;
  --danger:        #e05060;
  --claude-c:      #d97706;
  --openai-c:      #10a37f;
  --gemini-c:      #4285f4;
  --r:             10px;
  --r-sm:          6px;
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:          'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* === LAYOUT === */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
}

/* ── Top header bar ── */
#header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}

#home-btn {
  justify-self: start;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--muted);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}
#home-btn:hover { color: var(--text); border-color: var(--muted); background: var(--surface2); }

#header-title {
  justify-self: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-align: center;
}
#header-version {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

#header-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
}
#settings-btn {
  width: 36px; height: 36px; font-size: 18px;
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--r-sm);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
#settings-btn:hover { color: var(--text); border-color: var(--muted); }
#tracker-btn {
  width: 36px; height: 36px; font-size: 16px;
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--r-sm);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
#tracker-btn:hover { color: var(--text); border-color: var(--muted); }
#signout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
#signout-btn:hover { color: var(--text); border-color: var(--muted); }

/* ── Breadcrumb bar — removed (redundant with phase ribbon) ── */
#breadcrumb-bar {
  display: none;
}

#breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  padding: 6px 12px;
}
#breadcrumb:empty { padding: 0; }

#breadcrumb .crumb {
  white-space: nowrap;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
#breadcrumb .crumb:hover { color: var(--text); background: var(--surface2); }
#breadcrumb .crumb.active { color: var(--text); font-weight: 600; }
#breadcrumb .sep { opacity: 0.4; flex-shrink: 0; font-size: 11px; }

#main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* === LOADING === */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 20, 0.88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
}
#loading-overlay.hidden { display: none; }

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text { color: var(--text); font-size: 15px; font-weight: 500; }

/* Progress bar for multi-AI calls */
#loading-progress {
  width: 260px;
  max-width: 80%;
}
#loading-progress.hidden { display: none; }

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}
/* Indeterminate shimmer for single-backend calls */
#loading-progress.loading-indeterminate .progress-fill {
  width: 100% !important;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s ease-in-out infinite;
}
@keyframes loading-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
#loading-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.loading-step-done { color: var(--success, #38a169); }
.loading-step-active { color: var(--text); }
.loading-step-pending { opacity: 0.5; }

/* === TYPOGRAPHY === */
.page-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.page-sub { font-size: 14px; color: var(--muted); margin-bottom: 20px; }
.page-phase-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 8px; white-space: nowrap; flex-shrink: 0;
  vertical-align: middle;
}
h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* === CARDS === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}
.card-title { font-size: 17px; font-weight: 700; }
.card-body { color: var(--text); font-size: 14px; line-height: 1.7; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hi); }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--muted); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.1); }

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

.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 34px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* === FORMS === */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 12px;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus,
.field textarea:focus,
.field select:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 100px; line-height: 1.65; }
.field input[type="password"] { font-family: var(--mono); letter-spacing: 0.05em; }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236f6f99' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input-row { display: flex; align-items: center; gap: 8px; }

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.badge-pending { background: var(--surface2); color: var(--muted); }
.badge-draft   { background: rgba(212,160,48,0.15); color: var(--warning); }
.badge-approved{ background: rgba(60,192,112,0.15); color: var(--success); }

/* === AI CHIPS === */
.ai-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.ai-chip-claude  { background: rgba(217,119,6,0.18);   color: var(--claude-c); }
.ai-chip-chatgpt { background: rgba(16,163,127,0.18);  color: var(--openai-c); }
.ai-chip-gemini  { background: rgba(66,133,244,0.18);  color: var(--gemini-c); }
.ai-chip-synth   { background: rgba(91,91,255,0.18);   color: var(--accent-hi); }

/* === TABS === */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0;
}
.tab-btn {
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: var(--font);
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* === AI RESULTS PANEL === */
.ai-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
}
.ai-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.ai-raw {
  background: var(--surface2);
  border-radius: var(--r-sm);
  padding: 12px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
}

/* === STRUCTURE GRID (Trilogy / Series / Season) === */
.tri-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tri-cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tri-cell:hover { border-color: var(--accent); background: rgba(91,91,255,0.07); }
.tri-cell.locked { cursor: not-allowed; opacity: 0.45; }
.tri-cell .cell-act { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.tri-cell .cell-title { font-size: 13px; font-weight: 600; line-height: 1.3; }

/* === EPISODE LIST === */
.ep-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.ep-item:hover { border-color: var(--accent); }
.ep-item.locked { cursor: not-allowed; opacity: 0.4; }
.ep-num { font-size: 12px; color: var(--muted); font-weight: 700; min-width: 22px; }
.ep-info { flex: 1; overflow: hidden; }
.ep-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-premise { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-act-tag { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* === STORY TEXT === */
.story-text {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.story-text h1 { font-size: 20px; margin-bottom: 8px; }
.story-text h2 { font-size: 16px; color: var(--accent-hi); margin: 24px 0 10px; font-weight: 700; }

/* === ALERTS === */
.alert {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.5;
}
.alert-info    { background: rgba(91,91,255,0.1);    border: 1px solid rgba(91,91,255,0.3);    color: var(--accent-hi); }
.alert-warning { background: rgba(212,160,48,0.1);  border: 1px solid rgba(212,160,48,0.3);  color: var(--warning); }
.alert-error   { background: rgba(224,80,96,0.1);   border: 1px solid rgba(224,80,96,0.3);   color: var(--danger); }
.alert-success { background: rgba(60,192,112,0.1);  border: 1px solid rgba(60,192,112,0.3);  color: var(--success); }

/* === DIVIDER === */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* === THEME INFO BLOCK === */
.info-block {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
}
.info-block .info-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; font-weight: 700; }

/* === CHIPS ROW === */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--surface3); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--muted); }

/* === EXPORT === */
.export-file {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.export-file-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.export-file-size { font-size: 12px; color: var(--muted); }

/* === PROGRESS BAR === */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* === UTILITY === */
.text-muted    { color: var(--muted); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-accent   { color: var(--accent-hi); }
.text-sm       { font-size: 13px; }
.text-xs       { font-size: 12px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .page-title { font-size: 19px; }
  .btn { font-size: 14px; }
  .card { padding: 12px; }
  .tri-cell { padding: 10px 6px; }
  .tri-cell .cell-title { font-size: 12px; }
}

/* === FOOTER NAV BAR === */
#bottom-bar {
  flex-shrink: 0;
  position: relative;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#bottom-bar-inner {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-top: 2px solid var(--border);
}
#nav-save-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
#nav-save-btn:hover      { color: var(--success); background: var(--surface2); }
#nav-save-btn.saved      { color: var(--success); }
.nav-save-icon           { font-size: 16px; line-height: 1; }

#nav-git-save-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
#nav-git-save-btn.hidden     { display: none; }
#nav-git-save-btn:hover      { color: var(--accent); background: var(--surface2); }
#nav-git-save-btn.saved      { color: var(--success); }
#nav-git-save-btn.saving     { color: var(--muted); opacity: 0.7; }
#nav-git-save-btn.git-error  { color: var(--danger); }

/* ── Dev Error Ticker ──────────────────────────────────── */
#err-ticker {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  background: rgba(224,80,96,0.12);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font);
  letter-spacing: 0.02em;
  transition: background 0.15s;
}
#err-ticker.hidden    { display: none; }
#err-ticker:hover     { background: rgba(224,80,96,0.22); }
#err-ticker-icon      { font-size: 14px; }
#err-ticker-count     { min-width: 14px; text-align: center; }

#err-log-panel {
  position: relative;
  background: var(--surface);
  border-top: 2px solid var(--danger);
  border-bottom: 1px solid var(--border);
  max-height: 260px;
  overflow-y: auto;
  z-index: 210;
}
#err-log-panel.hidden { display: none; }
#err-log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(224,80,96,0.08);
  border-bottom: 1px solid rgba(224,80,96,0.2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.err-log-title {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--danger);
}
.err-log-entry {
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
}
.err-log-entry:last-child { border-bottom: none; }
.err-log-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 1px;
}
.err-log-ts  { color: var(--muted); font-size: 10px; white-space: nowrap; }
.err-log-msg { font-weight: 700; color: var(--danger); }
.err-log-detail {
  color: var(--text);
  font-family: var(--mono, monospace);
  font-size: 10px;
  word-break: break-all;
  opacity: 0.8;
  padding-left: 2px;
}

.save-status             { font-size: 11px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.save-status.saving      { color: var(--muted); }
.save-status.saved       { color: var(--success); }
.save-status.error       { color: var(--danger); cursor: default; }

.sync-badge              { font-size: 13px; padding: 0 4px; color: var(--muted); transition: color .3s, opacity .3s; }
.sync-badge.syncing      { color: var(--accent, #3182ce); animation: sync-pulse 1s ease-in-out infinite; }
.sync-badge.synced       { color: var(--success, #38a169); }
.sync-badge.error        { color: var(--danger, #e53e3e); }
.sync-badge.offline      { color: var(--warning, #d69e2e); opacity: 0.7; }
@keyframes sync-pulse    { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

#bottom-bar-spacer       { flex: 1; background: var(--surface); }
#nav-hamburger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
}
#nav-hamburger-icon { font-size: 20px; line-height: 1; }
#nav-current-label  { color: var(--muted); font-size: 13px; }
#nav-menu {
  position: absolute;
  bottom: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow-y: auto;
}
#nav-menu.hidden { display: none; }
.nav-tab {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, background 0.15s;
  min-height: 56px;
}
.nav-tab:last-child { border-bottom: none; }
.nav-tab.active { color: var(--accent-hi); background: var(--surface2); }
.nav-tab:hover:not(.active) { color: var(--text); background: var(--surface2); }
.nav-icon { font-size: 20px; line-height: 1; flex-shrink: 0; display: block; }

/* Reset All — danger tint in the hamburger menu */
.nav-reset-btn { color: var(--danger) !important; }
.nav-reset-btn:hover { background: rgba(224,80,96,0.1) !important; }

/* === ROMANCE / INTIMACY TOGGLES === */
.ri-row { margin-bottom: 14px; }
.ri-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.ri-label { font-size: 13px; font-weight: 500; color: var(--text); }
.ri-toggle { display: flex; border-radius: var(--r-sm); overflow: hidden; border: 1.5px solid var(--border); }
.ri-toggle-btn {
  padding: 6px 13px; font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  border: none; background: var(--surface2); color: var(--muted);
  cursor: pointer; font-family: var(--font); transition: all 0.15s; white-space: nowrap;
}
.ri-toggle-btn:disabled { opacity: 0.5; cursor: default; }
.ri-toggle-btn + .ri-toggle-btn { border-left: 1.5px solid var(--border); }
.ri-active-no  { background: rgba(224,80,96,0.18); color: #e05060; }
.ri-active-yes { background: rgba(52,200,90,0.18);  color: #34c85a; }
.ri-levels { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 0 4px; }
.ri-levels.hidden { display: none; }
.ri-level-btn {
  padding: 4px 11px; font-size: 12px; font-weight: 500;
  border-radius: var(--r-sm); border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--muted);
  cursor: pointer; font-family: var(--font); transition: all 0.15s;
}
.ri-level-btn:disabled { opacity: 0.5; cursor: default; }
.ri-level-btn.ri-active-yes { background: rgba(52,200,90,0.18); border-color: #34c85a; color: #34c85a; }
.ri-freq-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.ri-freq-row.hidden { display: none; }

/* Vocab grade level slider */
.vocab-slider-wrap { padding: 4px 0 2px; }
.vocab-slider-wrap input[type=range] { width: 100%; accent-color: var(--accent); margin-bottom: 4px; }
.vocab-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 2px; }

/* === FEATURE TRACKER PAGE === */
.tracker-list { list-style: none; margin: 0; padding: 0; }
.tracker-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px; line-height: 1.5; align-items: flex-start;
}
.tracker-item:last-child { border-bottom: none; }
.tracker-id {
  font-weight: 700; color: var(--muted); font-size: 11px;
  white-space: nowrap; padding-top: 2px; min-width: 28px; flex-shrink: 0;
}
.tracker-text { color: var(--text); }
.tracker-section-title { display: flex; align-items: center; gap: 8px; }
.tracker-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 99px; font-size: 11px; font-weight: 700;
  color: var(--muted); width: 22px; height: 22px;
}
.tracker-done .tracker-text { color: var(--muted); text-decoration: line-through; }

/* BACK / NEXT page navigation footer */
/* === PAGE NAV BAR (anchored in #bottom-bar, above Save/Menu row) === */
#page-nav-bar {
  background: var(--surface2);
  border-top: 1px solid var(--border);
}
#page-nav-bar.hidden { display: none; }

.pnb-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  gap: 6px;
}
.pnb-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pnb-btn {
  font-size: 12px !important;
  padding: 4px 10px !important;
  white-space: nowrap;
}
/* Amber tint: NEXT target has no content yet (navigates anyway — soft warning) */
.page-nav-btn-warn {
  color: var(--warning) !important;
  opacity: 0.75;
}
.pnb-current {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

/* --- (?) tooltip tips --- */
.pnb-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
  outline: none;
}
.pnb-tip-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
}
.pnb-tip:hover .pnb-tip-icon,
.pnb-tip:focus .pnb-tip-icon  { color: var(--accent-hi); border-color: var(--accent-hi); }

.pnb-tip-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  width: 220px;
  z-index: 1001;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
  white-space: normal;
  box-shadow: 0 4px 20px rgba(0,0,0,0.45);
}
/* right-side tip: tooltip extends rightward from the ? icon */
.pnb-tip--right .pnb-tip-popup { left: 0; }
/* left-side tip: tooltip extends leftward from the ? icon */
.pnb-tip--left  .pnb-tip-popup { right: 0; }

.pnb-tip:hover .pnb-tip-popup,
.pnb-tip:focus .pnb-tip-popup { opacity: 1; transform: translateY(0); }

/* === PROJECT SELECT SCREEN === */
.project-select-wrap { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.project-choice-card {
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.15s, background 0.15s;
}
.project-choice-card:hover     { border-color: var(--accent-hi); background: var(--surface2); }
.project-choice-continue       { border-color: var(--accent); }
.project-choice-body           { flex: 1; min-width: 0; }
.project-choice-title          { font-size: 16px; font-weight: 700; color: var(--text); }
.project-choice-sub            { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.project-choice-arrow          { font-size: 22px; color: var(--muted); flex-shrink: 0; }
.project-choice-continue .project-choice-arrow { color: var(--accent-hi); }
.project-saved-section         { margin-top: 4px; }
.project-saved-title {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.project-saved-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border); margin-bottom: 6px;
  background: var(--surface); transition: background 0.15s;
}
.project-saved-item:hover      { background: var(--surface2); }
.project-saved-info            { flex: 1; min-width: 0; }
.project-saved-name            { font-size: 14px; font-weight: 600; color: var(--text); }
.project-saved-meta            { font-size: 12px; color: var(--muted); margin-top: 2px; }
.project-saved-preview {
  font-size: 12px; color: var(--muted); font-style: italic;
  margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-saved-actions         { display: flex; gap: 4px; flex-shrink: 0; }

/* === PROFILE LOCK NOTICE === */
.profile-lock-notice {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-sm);
  background: rgba(212,160,48,0.1); border: 1px solid rgba(212,160,48,0.3);
  color: var(--warning); font-size: 13px; margin-bottom: 12px;
}
.profile-lock-notice strong { flex: 1; }

/* Profile sub-section headers */
.profile-subsect {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 14px; margin: 18px 0 2px;
}
.profile-subsect:first-child { border-top: none; padding-top: 0; margin-top: 4px; }

/* Toggle (checkbox) rows inside Writing Profile */
.toggle-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.field input[type="checkbox"],
.field input[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
  width: auto;
  padding: 0;
}
.toggle-row input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.toggle-row span { font-size: 13px; color: var(--fg); }

/* === EPISODE ELEMENT SECTIONS === */
.element-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.element-section.active-gen { border-color: var(--accent); }
.element-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.element-header:hover { background: var(--surface3); }
.elem-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  min-width: 18px;
}
.elem-name {
  font-size: 13px;
  font-weight: 700;
  flex: 1;
}
.elem-wc {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.element-body {
  padding: 0 14px 14px;
  display: none;
}
.element-body.open { display: block; }
.element-body textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.8;
  padding: 12px;
  resize: vertical;
  min-height: 200px;
  margin-top: 8px;
}
.element-body textarea:focus { outline: none; border-color: var(--accent); }
.element-pending {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}
.element-generating {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--accent-hi);
  display: flex;
  align-items: center;
  gap: 8px;
}
.mini-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* === WORD COUNT / PROGRESS === */
.wc-bar {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.wc-number {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
}
.wc-target { font-size: 12px; color: var(--muted); }
.wc-pct { font-size: 13px; font-weight: 700; }
.wc-pct.on-target { color: var(--success); }
.wc-pct.low { color: var(--warning); }

/* === GENERATION PROGRESS BAR === */
#gen-progress-bar {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}
#gen-progress-label {
  font-size: 13px;
  color: var(--accent-hi);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === CHARACTER CARDS === */
.char-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px;
  margin-bottom: 8px;
}
.char-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.char-name { font-size: 16px; font-weight: 700; }
.char-role { font-size: 12px; color: var(--muted); }
.char-pov { background: rgba(91,91,255,0.15); color: var(--accent-hi); font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }

/* === WORLD-BUILDING SECTIONS === */
.wb-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.wb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
}
.wb-section-header:hover { background: var(--surface3); }
.wb-section-title { font-weight: 700; font-size: 15px; }
.wb-section-body { padding: 0 14px 14px; display: none; }
.wb-section-body.open { display: block; }
.wb-always { font-size: 11px; color: var(--success); }

/* === THEME ITEMS === */
.theme-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.theme-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.theme-desc { font-size: 13px; color: var(--muted); }
.theme-motifs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.motif-tag {
  background: rgba(91,91,255,0.12);
  color: var(--accent-hi);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(91,91,255,0.25);
}

/* === SECTION HEADERS WITH ACTIONS === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 { margin-bottom: 0; }

/* === BACKEND SELECTOR === */
.backend-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.backend-opt {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  font-family: var(--font);
}
.backend-opt.selected { border-color: var(--accent); color: var(--accent-hi); background: rgba(91,91,255,0.1); }
.backend-opt:disabled { opacity: 0.3; cursor: not-allowed; }

/* === PLOT THREADS === */
.thread-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.thread-item.resolved {
  opacity: 0.55;
  border-color: var(--success);
}
.thread-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 20px;
  margin-right: 6px;
}
.thread-type-question  { background: rgba(91,91,255,0.18); color: var(--accent-hi); }
.thread-type-promise   { background: rgba(255,200,0,0.18);  color: var(--warning); }
.thread-type-clue      { background: rgba(0,200,120,0.18);  color: var(--success); }
.thread-type-foreshadowing { background: rgba(200,80,255,0.18); color: #d080ff; }
.thread-text { font-size: 14px; font-weight: 600; line-height: 1.5; margin-bottom: 4px; }
.thread-meta { font-size: 11px; color: var(--muted); }
.thread-resolved-badge { font-size: 11px; color: var(--success); font-weight: 700; }

/* Thread scope sections */
.thread-section { border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; }
.thread-section-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.thread-section-title { font-weight: 700; font-size: 15px; }
.thread-season-group { border-left: 3px solid var(--border); padding-left: 14px; margin-top: 14px; }
.thread-season-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.thread-section-subtitle { font-weight: 600; font-size: 13px; color: var(--muted); }

/* Scope badges */
.scope-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 20px; margin-left: 5px; vertical-align: middle; text-transform: uppercase; }
.scope-saga   { background: var(--accent); color: #000; }
.scope-season { background: rgba(255,200,0,0.25); color: var(--warning); }

/* AI suggestion result area */
.suggest-result-zone { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; margin-bottom: 12px; background: var(--surface2); }
.suggest-result-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px; }
.suggest-result-card { background: var(--surface3); border-radius: var(--r-sm); padding: 12px; margin-bottom: 8px; }
.suggest-result-text { font-size: 14px; line-height: 1.55; }

/* === AI ADVISOR === */
.advisor-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.advisor-tab { padding: 7px 14px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.advisor-tab:hover { background: var(--surface3); }
.advisor-tab.active { background: var(--accent); color: #000; border-color: var(--accent); }
.advisor-panel.card { padding: 20px; }
.advisor-role-header { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.advisor-role-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.advisor-role-title { font-weight: 700; font-size: 16px; margin-bottom: 3px; }
.advisor-role-sub { font-size: 13px; color: var(--muted); line-height: 1.4; }
.advisor-result { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 16px; background: var(--surface2); }
.advisor-prose { font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.advisor-prose p { margin: 0 0 12px; }
.advisor-prose p:last-child { margin-bottom: 0; }
.advisor-prose strong { color: var(--text); font-weight: 700; }

/* === CANON TIMELINE === */
.timeline-event { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); }
.timeline-ep-badge { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: var(--accent); color: #000; margin-top: 2px; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-label { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.timeline-summary { font-size: 13px; color: var(--text); line-height: 1.5; }
.timeline-sig { font-size: 12px; color: var(--muted); margin-top: 4px; font-style: italic; }

/* === I'M STUCK TAB === */
.advisor-tab-stuck { border-color: var(--warning) !important; color: var(--warning) !important; }
.advisor-tab-stuck.active { background: var(--warning) !important; color: #000 !important; border-color: var(--warning) !important; }
.advisor-tab-stuck:hover { background: rgba(255,200,0,0.12) !important; }

/* === WORKFLOW GUIDE OVERLAY === */
.guide-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.guide-panel { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-md); width: 100%; max-width: 620px; max-height: calc(100vh - 48px); overflow-y: auto; }
.guide-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface2); z-index: 1; }
.guide-title { font-weight: 700; font-size: 17px; }
.guide-intro { font-size: 13px; color: var(--muted); line-height: 1.5; padding: 14px 20px 4px; margin: 0; }

/* Story Bible — static pinned card */
.guide-bible-pin {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}
.guide-bible-pin-icon { font-size: 20px; flex-shrink: 0; }
.guide-bible-pin-body { flex: 1; min-width: 0; }
.guide-bible-pin-body strong { display: block; font-size: 14px; font-weight: 700; color: var(--fg); }
.guide-bible-pin-body span  { font-size: 12px; color: var(--muted); }

/* Phase-complete callout */
.guide-phase-complete {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(80, 200, 80, 0.08);
}
.guide-phase-complete.hidden { display: none; }
.gpc-check { font-size: 18px; font-weight: 700; color: var(--success); flex-shrink: 0; }
.gpc-body { flex: 1; min-width: 0; }
.gpc-body strong { display: block; font-size: 13px; font-weight: 700; color: var(--success); }
.gpc-body span   { font-size: 12px; color: var(--muted); }

/* Next-step banner */
.guide-next-step { border-bottom: 1px solid var(--border); }
.guide-next-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: rgba(91,91,255,0.10); }
.guide-next-label { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 2px; }
.guide-next-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* Phase dividers */
.guide-phase { display: flex; align-items: center; gap: 10px; padding: 10px 20px 8px; background: var(--surface3); border-top: 1px solid var(--border); }
.guide-phase:first-child { border-top: none; }
.guide-phase-num { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); background: rgba(91,91,255,0.15); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.guide-phase-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* Steps */
.guide-step { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.guide-step-done { opacity: 0.55; }
.guide-step-next { background: rgba(91,91,255,0.07); }
.guide-step-num { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--surface3); color: var(--muted); font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.guide-step-done .guide-step-num { background: var(--success); color: #000; }
.guide-step-next .guide-step-num { background: var(--accent); color: #fff; }
.guide-step-icon { flex-shrink: 0; font-size: 20px; margin-top: -1px; }
.guide-step-body { flex: 1; min-width: 0; }
.guide-step-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.guide-step-sub { font-size: 13px; color: var(--text); line-height: 1.4; margin-bottom: 6px; }
.guide-step-tip { font-size: 12px; color: var(--muted); line-height: 1.45; }
.guide-nav-btn { flex-shrink: 0; margin-top: 2px; white-space: nowrap; }

/* === EPISODE BLUEPRINT === */
.blueprint-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.blueprint-card summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.blueprint-card summary::-webkit-details-marker { display: none; }
.blueprint-card summary:hover { background: var(--surface3); }
.blueprint-card[open] summary { border-bottom: 1px solid var(--border); }
.blueprint-body { padding: 12px 14px; }
.blueprint-field { margin-bottom: 10px; }
.blueprint-field label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 4px; }
.blueprint-field textarea, .blueprint-field input[type=text] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  resize: vertical;
  box-sizing: border-box;
}
.blueprint-field textarea:focus, .blueprint-field input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
}

/* === AI CONSISTENCY CHECK === */
.consistency-result {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* === NAV MENU: smooth scroll if content overflows === */
#nav-menu { scroll-behavior: smooth; }
#nav-menu::-webkit-scrollbar { display: none; }

/* === STORY ARC OUTLINE === */
.progress-bar-wrap {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.outline-season { margin-bottom: 28px; }
.outline-season-header {
  border-left: 3px solid var(--border);
  padding-left: 10px;
  margin-bottom: 12px;
}
.outline-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.outline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.outline-card.ep-card:hover {
  border-color: var(--accent);
  background: rgba(91,91,255,0.04);
}
.outline-card-empty { opacity: 0.4; }
.outline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.ep-code {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.outline-card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}
.outline-card-premise {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 6px;
}
.outline-card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface2);
  color: var(--muted);
  white-space: nowrap;
}
.tag-accent {
  background: rgba(91,91,255,0.15);
  color: var(--accent-hi);
}
.tag-beat {
  background: rgba(212,160,48,0.15);
  color: var(--warning);
}

/* === EXPORT ENHANCEMENTS === */
.export-file-highlight {
  border-color: var(--accent);
  background: rgba(91,91,255,0.05);
}

/* === STORY BIBLE VIEW === */
.bible-field { margin: 8px 0; font-size: 13px; line-height: 1.7; }
.bible-field-inline { font-size: 13px; color: var(--muted); margin: 4px 0; }
.bible-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 2px;
}
.bible-char {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}
.bible-char-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.bible-char-desc { font-size: 13px; color: var(--text); line-height: 1.6; }
.bible-section { border-top: 1px solid var(--border); padding: 10px 16px; }
.bible-section-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.bible-section-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}
.bible-subsection-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 8px 16px 2px;
}
.bible-thread { padding: 8px 16px; border-top: 1px solid var(--border); }
.bible-thread-title { font-size: 13px; font-weight: 600; margin-left: 6px; }

/* === SETUP/PAYOFF LEDGER === */
.pl-list { padding: 0 0 4px; }
.pl-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.pl-type-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(91,91,255,0.15);
  color: var(--accent-hi);
  padding: 3px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}
.pl-entry-body { flex: 1; min-width: 0; }
.pl-entry-name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.pl-entry-meta { font-size: 11px; color: var(--muted); line-height: 1.5; }
.pl-status-badge {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
  opacity: 0.85;
}

/* === AUTH === */
.auth-hidden { display: none !important; }

#login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9999;
}
#login-overlay.hidden { display: none; }

#login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  width: 320px;
  text-align: left;
}

#login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

#login-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: -8px;
}

#google-signin-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #3c3c3c;
  border: none;
  border-radius: var(--r-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: box-shadow 0.15s;
}
#google-signin-btn:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.25); }

#auth-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: -8px;
}
#auth-error.hidden { display: none; }


/* === NAV BREADCRUMB FIX: home crumb always visible === */
#breadcrumb .crumb:first-child {
  flex-shrink: 0;
}

/* === WRITER'S PACKET (Triangulation T6) === */
.writers-packet {
  background: var(--surface2);
  border-radius: var(--r-sm);
  padding: 16px 20px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  max-height: 600px;
  overflow-y: auto;
}
.writers-packet p { margin: 0 0 10px; }
.wp-section-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hi);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(91,91,255,0.2);
}
.wp-section-header:first-child { margin-top: 0; }
.wp-num { color: var(--accent-hi); font-weight: 600; margin-right: 2px; }
.wp-bullet { color: var(--accent-hi); margin-right: 4px; }

/* === BEGIN WRITING READY PULSE === */
@keyframes ready-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60,192,112,0.5); }
  50%       { box-shadow: 0 0 0 10px rgba(60,192,112,0); }
}
.btn-ready {
  background: var(--success) !important;
  color: #fff !important;
  border-color: var(--success) !important;
  animation: ready-glow 2s ease-in-out infinite;
}

/* === AUTH EMAIL: hide on small screens === */
.auth-email-display {
  font-size: 10px;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 500px) { .auth-email-display { display: none; } }

/* === CLEAR BUTTON: inline API key clear === */
.btn-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.btn-clear:hover { color: var(--danger); border-color: var(--danger); }

/* === PREMISE QUALITY INDICATOR === */
.premise-quality {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--surface);
}
.premise-quality-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.premise-quality-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pq-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.pq-ok   { color: var(--success); }
.pq-warn { color: var(--warning); }
.pq-dot  { font-size: 11px; flex-shrink: 0; }

/* === SPECIAL PROJECT MODE BANNER === */
.mode-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid;
}
.mode-banner-interface { background: rgba(212,160,48,0.12); border-color: rgba(212,160,48,0.35); color: var(--warning); }
.mode-banner-prose     { background: rgba(91,91,255,0.10);  border-color: rgba(91,91,255,0.30);  color: var(--accent-hi); }

/* === SETUP PHASE BADGE === */
.setup-phase-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(91,91,255,0.14);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}

/* === GENRE CHIPS === */
.genre-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.genre-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.genre-chip:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}
.genre-chip-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.genre-chip-selected:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
}
.genre-chip:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.genre-count { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: right; }

/* === GENRE ACCORDION === */
.genre-selected-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  padding: 8px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  margin-top: 6px;
  align-items: center;
}
.genre-preview-empty { font-size: 12px; color: var(--muted); font-style: italic; }

.genre-accordion { display: flex; flex-direction: column; gap: 3px; }

.genre-cat-item {
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.15s;
}
.genre-cat-item.has-selection { border-color: rgba(91,91,255,0.45); }
.genre-cat-item.open { border-color: var(--accent); }

.genre-cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  text-align: left;
  transition: background 0.12s;
}
.genre-cat-btn:hover { background: var(--surface3); }
.genre-cat-item.open .genre-cat-btn { background: var(--surface3); }

.genre-cat-icon  { font-size: 16px; flex-shrink: 0; }
.genre-cat-label { flex: 1; }

.genre-cat-sel-count {
  font-size: 10px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.genre-cat-chevron {
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
  line-height: 1;
}
.genre-cat-item.open .genre-cat-chevron { transform: rotate(90deg); }

.genre-cat-panel {
  padding: 8px 12px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.genre-grp-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 10px 0 5px;
  padding-left: 2px;
}
.genre-grp-label:first-child { margin-top: 4px; }

.genre-grp-chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* ============================================================ */
/* HERITAGE FLAIR ACCORDION                                      */
/* ============================================================ */

.heritage-accordion { display: flex; flex-direction: column; gap: 3px; }

.heritage-cat-item {
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.15s;
}
.heritage-cat-item.open { border-color: var(--accent); }

.heritage-cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  text-align: left;
  transition: background 0.12s;
}
.heritage-cat-btn:hover { background: var(--surface3); }
.heritage-cat-item.open .heritage-cat-btn { background: var(--surface3); }

.heritage-cat-label { flex: 1; }

.heritage-cat-count {
  font-size: 10px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.heritage-cat-chevron {
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
  line-height: 1;
}
.heritage-cat-item.open .heritage-cat-chevron { transform: rotate(90deg); }

.heritage-cat-panel {
  padding: 8px 12px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.heritage-chip {
  font-size: 12px;
  padding: 4px 10px;
}

.heritage-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.heritage-sel-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-hi);
  color: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.heritage-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.heritage-remove:hover { color: #fff; }

/* ============================================================ */
/* PHASE RIBBON                                                  */
/* ============================================================ */

#phase-ribbon {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 52px;
  z-index: 98;
  /* relative for ::after swipe hint */
}
#phase-ribbon:empty { display: none; }
#phase-ribbon::-webkit-scrollbar { display: none; }

/* Swipe-hint: fade gradient when ribbon overflows on small screens */
#phase-ribbon.has-overflow::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0; width: 32px;
  background: linear-gradient(90deg, transparent, var(--surface));
  pointer-events: none;
  animation: swipe-hint 1.5s ease-out 0.5s 1;
}
@keyframes swipe-hint {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

.phase-ribbon-inner {
  display: flex;
  align-items: flex-start;
  padding: 5px 10px;
  min-width: max-content;
  gap: 0;
}

.pr-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.pr-phase {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.15s;
  line-height: 1;
}
.pr-phase:hover { background: var(--surface2); }

.pr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Dot & label colors by status */
.pr-complete .pr-dot  { background: var(--success); }
.pr-active   .pr-dot  { background: var(--warning); box-shadow: 0 0 4px var(--warning); }
.pr-warn     .pr-dot  { background: var(--danger); }
.pr-pending  .pr-dot  { background: var(--border); }

.pr-complete .pr-label { color: var(--success); }
.pr-active   .pr-label { color: var(--warning); }
.pr-warn     .pr-label { color: var(--danger); }
.pr-pending  .pr-label { color: var(--muted); }

.pr-frac {
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: 0.7;
  line-height: 1;
}
.pr-complete .pr-frac { color: var(--success); opacity: 1; }
.pr-active   .pr-frac { color: var(--warning); opacity: 1; }
.pr-warn     .pr-frac { color: var(--danger); opacity: 1; }

.pr-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  flex-shrink: 0;
  margin: 4px 6px;
}

.pr-page-dots {
  display: flex;
  gap: 4px;
  padding-bottom: 4px;
}

.pr-page-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.15s;
}
/* Page dots inherit phase traffic-light color */
.pr-complete .pr-page-dot { background: var(--success); opacity: 0.35; }
.pr-active   .pr-page-dot { background: var(--warning); opacity: 0.35; }
.pr-warn     .pr-page-dot { background: var(--danger);  opacity: 0.35; }
.pr-pending  .pr-page-dot { background: var(--border);  opacity: 1; }

/* Pages with saved content: slightly brighter within their phase color */
.pr-complete .pr-page-dot.pr-pd-done { opacity: 0.75; }
.pr-active   .pr-page-dot.pr-pd-done { opacity: 0.75; }
.pr-warn     .pr-page-dot.pr-pd-done { opacity: 0.75; }

/* Hover: lighten slightly */
.pr-page-dot:hover { opacity: 1 !important; }

/* Active page: always accent (blue/purple), full glow — var(--accent) is not defined, use --accent */
.pr-page-dot.pr-pd-active {
  background: var(--accent) !important;
  box-shadow: 0 0 6px 2px var(--accent);
  opacity: 1 !important;
  width: 7px !important;
  height: 7px !important;
}

/* ============================================================ */
/* AI FIELD HELPER                                               */
/* ============================================================ */

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.field-label-row > span { flex: 1; }

.field-help-btn {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-hi);
  background: none;
  border: 1px solid rgba(123, 123, 255, 0.3);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  cursor: pointer;
  opacity: 0.7;
  white-space: nowrap;
  line-height: 1.5;
  transition: opacity 0.15s, background 0.15s;
}
.field-help-btn:hover:not(:disabled) {
  opacity: 1;
  background: rgba(91, 91, 255, 0.1);
}
.field-help-btn:disabled { opacity: 0.35; cursor: default; }

.field-suggestion {
  margin-top: 6px;
  padding: 10px 12px;
  background: rgba(91, 91, 255, 0.05);
  border: 1px solid rgba(91, 91, 255, 0.2);
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}
.fh-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.fh-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ============================================================ */
/* PROFILE CHIP PICKERS                                          */
/* ============================================================ */

.pchips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.pchip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.6;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pchip:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--muted);
}
.pchip.pchip-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pchip.pchip-conflict {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(224,80,96,0.10);
}
.pchip.pchip-conflict.pchip-on {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.pchips-conflict-warn {
  font-size: 12px;
  color: var(--danger);
  padding: 2px 0 4px;
  line-height: 1.4;
}
.pchips-conflict-warn:empty { display: none; }

/* ── POV character slot cards ─────────────────────────── */
.pov-char-slot {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.pov-slot-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hi);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.pov-arch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  margin-bottom: 2px;
}
.pov-arch-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.6;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pov-arch-btn:hover  { background: var(--surface2); color: var(--text); border-color: var(--muted); }
.pov-arch-btn.pov-arch-on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Motivation / Fear quick-pick chips — same pill style, softer accent when active */
.pov-meta-chip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.6;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pov-meta-chip:hover { background: var(--surface2); color: var(--text); border-color: var(--muted); }
.pov-meta-chip.pchip-on { background: var(--accent-hi); color: #fff; border-color: var(--accent-hi); }

/* ── Saga Beat Map ─────────────────────────────────────────── */
.saga-timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.saga-season-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.saga-season-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  min-width: 24px;
  padding-top: 14px;
}
.saga-ep-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 4px;
}
.saga-ep-cell {
  position: relative;
  min-width: 58px;
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 4px 8px;
  cursor: default;
  transition: border-color 0.12s, background 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.saga-ep-cell.has-beat {
  border-color: var(--beat-color, var(--accent));
  box-shadow: inset 0 0 0 1000px rgba(255,255,255,.04);
}
.saga-ep-cell.selectable {
  cursor: pointer;
  border-style: dashed;
}
.saga-ep-cell.selectable:hover {
  border-color: var(--accent-hi);
  background: var(--surface2);
}
.saga-ep-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}
.saga-ep-title {
  font-size: 9px;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
  min-height: 22px;
}
.saga-beat-pin {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--beat-color, var(--accent));
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 1px 5px;
  border-radius: 0 0 5px 5px;
  white-space: nowrap;
}

/* Season beat pin — sits at bottom of cell, offset from saga pin */
.saga-beat-pin.sn-pin {
  top: auto;
  bottom: 14px;  /* above the saga pin row */
  border-radius: 3px;
  font-size: 7px;
  opacity: 0.9;
}

/* AI suggestion block under a beat row */
.saga-beat-ai-suggestion {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: -4px 0 4px 36px;
}

/* Beat editor list */
.saga-beats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.saga-beat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--beat-color, var(--border));
  border-radius: 8px;
  transition: border-color 0.12s, background 0.12s;
}
.saga-beat-row.beat-selected {
  background: var(--surface2);
  border-color: var(--beat-color, var(--accent));
  border-left-width: 4px;
}
.saga-beat-num {
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}
.saga-beat-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.saga-beat-label-input {
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
}
.saga-beat-desc-input {
  width: 100%;
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
.saga-beat-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.saga-beat-placement {
  font-size: 11px;
  font-weight: 700;
  color: var(--beat-color, var(--accent));
  white-space: nowrap;
}
.saga-beat-unplaced {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ── Project Scope Toggle ─────────────────────────────────────── */
.scope-toggle {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.scope-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 16px 12px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.2;
}
.scope-btn:hover { border-color: var(--accent); }
.scope-btn-active {
  border-color: var(--accent-hi);
  background: rgba(91, 91, 255, 0.1);
  color: var(--accent-hi);
}
.scope-btn-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.scope-btn-active .scope-btn-sub { color: var(--accent); }
.scope-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.scope-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 72px;
}
.scope-stat span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.scope-stat strong { font-size: 13px; color: var(--text); }
input[type="range"].scope-wc-slider {
  width: 100%;
  margin-top: 6px;
  accent-color: var(--accent-hi);
}
.scope-wc-marks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Premise Builder Quiz ─────────────────────────────────────── */
.quiz-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 14px;
  background: var(--surface);
}
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.quiz-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hi);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.quiz-phase-label {
  font-size: 11px;
  color: var(--muted);
}
.quiz-progress {
  display: flex;
  gap: 5px;
  align-items: center;
}
.quiz-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.15s, width 0.15s, border-radius 0.15s;
}
.quiz-dot.qd-done   { background: var(--success); }
.quiz-dot.qd-active { background: var(--accent-hi); width: 16px; border-radius: 4px; }
.quiz-q {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 10px;
}
.quiz-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
  font-style: italic;
}
.quiz-answer {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 0.12s;
}
.quiz-answer:focus { border-color: var(--accent); outline: none; }
.quiz-answer-other { margin-top: 8px; }

/* === MULTIPLE-CHOICE QUIZ OPTIONS === */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.5;
}
.quiz-option:hover { border-color: var(--accent); background: rgba(91,91,255,0.04); }
.quiz-option-selected {
  border-color: var(--accent-hi) !important;
  background: rgba(91,91,255,0.08) !important;
}
.quiz-option input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--accent-hi);
  flex-shrink: 0;
}
.quiz-option-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-hi);
  min-width: 14px;
  flex-shrink: 0;
}
.quiz-option-text {
  font-size: 13px;
  color: var(--text);
}
.quiz-option-other {
  border-style: dashed;
}
.quiz-option-other .quiz-option-text {
  color: var(--muted);
  font-style: italic;
}

.quiz-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.quiz-synth-box {
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 14px;
  white-space: pre-wrap;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  resize: vertical;
}
.quiz-answered-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.quiz-answered-item {
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.quiz-answered-q {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.quiz-answered-a {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* ── Story Structure Comparison Panel (^3 pick) ── */
.story-compare-zone {
  padding: 16px 0 8px;
}
.story-compare-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.story-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.story-compare-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.story-compare-backend {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
  margin-bottom: 2px;
}
.sc-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.sc-logline {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 4px;
}
.sc-act {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  border-left: 2px solid var(--border);
  padding-left: 8px;
  margin-bottom: 2px;
}

/* ── Saga Beat Map AI Action Bar ── */
.saga-ai-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.saga-ai-bar-hint {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 160px;
}

/* ── Visual Timeline (W4) ────────────────────────────────── */
.vtl-strip {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  min-height: 56px;
}
.vtl-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  min-width: 20px;
  transition: transform 0.15s;
}
.vtl-cell:hover {
  transform: scaleY(1.15) scaleX(1.1);
  z-index: 1;
}
.vtl-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: height 0.3s;
}
.vtl-num {
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
}
.vtl-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.vtl-saga-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg);
  box-shadow: 0 0 0 1px var(--muted);
  margin: -1px 0;
}
.vtl-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 3px;
}
.vtl-legend-saga {
  background: var(--accent);
  border: 1.5px solid var(--bg);
  box-shadow: 0 0 0 1px var(--muted);
}

/* ── Bible inline editing (W1) ───────────────────────────── */
.bible-editable {
  outline: none;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s, background 0.2s;
  padding: 1px 2px;
  border-radius: 3px;
}
.bible-editable:hover {
  border-bottom-color: var(--muted);
}
.bible-editable:focus {
  border-bottom-color: var(--accent);
  background: rgba(80, 130, 230, 0.06);
}
