/* ============================================================
   OPERATION: MERIDIAN — Main Stylesheet
   ============================================================ */

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:       #0b1120;
  --bg-surface:    #111827;
  --bg-card:       #1a2236;
  --bg-card-hover: #1e2944;
  --border:        #2d3a52;
  --border-light:  #374357;

  --text-primary:   #f0f4ff;
  --text-secondary: #8b9ab5;
  --text-muted:     #5a6a88;

  --gold:          #f0b429;
  --gold-dim:      #a07820;
  --blue:          #3b82f6;
  --blue-dim:      #1d4ed8;
  --green:         #10b981;
  --amber:         #f59e0b;
  --red:           #ef4444;
  --purple:        #a855f7;

  --meter-budget:      #10b981;
  --meter-trust:       #3b82f6;
  --meter-stakeholder: #a855f7;
  --meter-compliance:  #10b981;
  --meter-ai:          #f59e0b;
  --meter-union:       #6b7280;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
}

/* --- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================================
   ONBOARDING OVERLAY
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.4s ease;
}

.overlay:not(.active) { opacity: 0; pointer-events: none; }

.onboarding-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem;
  max-width: 680px;
  width: 90%;
  box-shadow: var(--shadow);
}

/* Meridian brand mark */
.meridian-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.meridian-logo-mark {
  width: 48px;
  height: 48px;
  background: var(--gold);
  color: #000;
  font-size: 1.6rem;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.meridian-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--gold);
}
.meridian-sub {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Onboarding steps */
.onboarding-step { display: none; }
.onboarding-step.active { display: block; }

.onboarding-step h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.onboarding-step h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.sim-tagline {
  color: var(--gold);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
}
.sim-description {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.7;
}
.step-instruction {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Form elements */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color var(--transition);
}
.form-group input:focus {
  outline: none;
  border-color: var(--blue);
}
.form-group input::placeholder { color: var(--text-muted); }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Role selection grid */
.role-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.role-grid .role-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.role-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-primary);
  font-family: var(--font);
}
.role-card:hover {
  border-color: var(--gold);
  background: var(--bg-card-hover);
}
.role-card.selected {
  border-color: var(--gold);
  background: rgba(240,180,41,0.08);
}
.role-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.role-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.role-stakeholder { font-size: 0.8rem; color: var(--gold); margin-bottom: 0.25rem; }
.role-tension { font-size: 0.75rem; color: var(--text-muted); }

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

.btn-primary {
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.5rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}
.btn-primary:hover { background: #e0a420; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary.btn-large { padding: 0.85rem 2rem; font-size: 1rem; }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1.5rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color var(--transition);
  border-radius: var(--radius);
  width: 100%;
  text-align: left;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

/* ============================================================
   MAIN APP LAYOUT
   ============================================================ */

.app { display: flex; flex-direction: column; height: 100vh; }
.hidden { display: none !important; }

/* Header */
.app-header {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  flex-shrink: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 240px;
}
.header-logo-mark {
  width: 36px;
  height: 36px;
  background: var(--gold);
  color: #000;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-company {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.header-division {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 500px;
  margin: 0 auto;
}
.chapter-progress-bar {
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
}
.chapter-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.6s ease;
}
.chapter-progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.header-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 200px;
  justify-content: flex-end;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.player-role-badge {
  background: rgba(240,180,41,0.15);
  color: var(--gold);
  border: 1px solid rgba(240,180,41,0.3);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* App body */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-section { padding: 1.25rem 1rem 0.75rem; }
.sidebar-section + .sidebar-section { border-top: 1px solid var(--border); }
.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Meters */
.meter-item { margin-bottom: 1rem; }
.meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.meter-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.meter-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}
.meter-bar {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Union relations: special ±3 scale */
.union-meter { display: flex; flex-direction: column; }
.union-bar-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: 6px;
  margin-top: 0.35rem;
}
.union-segment {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: var(--bg-card);
  transition: background 0.5s ease;
}
.union-segment.negative.active { background: var(--red); }
.union-segment.positive.active { background: var(--green); }
.union-center-mark {
  width: 2px;
  height: 10px;
  background: var(--border-light);
  border-radius: 1px;
  flex-shrink: 0;
}

/* Chapter navigation */
#chapter-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-chapter-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.78rem;
  text-align: left;
  width: 100%;
  transition: all var(--transition);
}
.nav-chapter-btn:hover:not(:disabled) {
  background: var(--bg-card);
  color: var(--text-primary);
}
.nav-chapter-btn.active {
  background: rgba(240,180,41,0.12);
  color: var(--gold);
}
.nav-chapter-btn.completed {
  color: var(--text-secondary);
}
.nav-chapter-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.nav-ch-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-card);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-chapter-btn.completed .nav-ch-num { background: var(--green); color: #fff; }
.nav-chapter-btn.active .nav-ch-num { background: var(--gold); color: #000; }
.nav-ch-title { line-height: 1.3; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */

.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-base);
}

#chapter-content-area {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* Chapter header */
.chapter-header {
  margin-bottom: 2rem;
}
.chapter-week-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.chapter-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}
.chapter-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Scene / narrative card */
.scene-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  position: relative;
}
.scene-card.highlighted {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(240,180,41,0.04) 100%);
}

.scene-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
}
.scene-text {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.95rem;
}
.scene-text p { margin-bottom: 0.9rem; }
.scene-text p:last-child { margin-bottom: 0; }
.scene-text strong { color: var(--text-primary); }
.scene-text em { color: var(--gold); font-style: normal; }

/* Briefing card (stakeholder context) */
.briefing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.briefing-card.gold-border { border-left-color: var(--gold); }
.briefing-card.red-border { border-left-color: var(--red); }
.briefing-card.green-border { border-left-color: var(--green); }
.briefing-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.briefing-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}
.briefing-who { font-size: 0.85rem; }
.briefing-name { font-weight: 600; color: var(--text-primary); }
.briefing-role { font-size: 0.75rem; color: var(--text-muted); }
.briefing-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  font-style: italic;
}

/* Decision section */
.decision-section { margin-bottom: 2rem; }
.decision-prompt {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}
.decision-instruction {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.decision-options { display: flex; flex-direction: column; gap: 0.75rem; }
.decision-option {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--font);
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}
.decision-option:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}
.decision-option.selected {
  border-color: var(--gold);
  background: rgba(240,180,41,0.08);
}
.decision-option:disabled { cursor: not-allowed; opacity: 0.6; }

.option-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.option-text { font-size: 0.9rem; line-height: 1.5; color: var(--text-secondary); }
.option-subtext { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; }

/* Consequence reveal */
.consequence-reveal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
  display: none;
}
.consequence-reveal.visible { display: block; animation: fadeIn 0.4s ease; }

.consequence-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber);
  font-weight: 600;
  margin-bottom: 1rem;
}
.meter-changes { display: flex; flex-direction: column; gap: 0.5rem; }
.meter-change-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.change-meter-name { color: var(--text-secondary); min-width: 160px; }
.change-delta {
  font-weight: 700;
  font-size: 0.9rem;
}
.change-delta.positive { color: var(--green); }
.change-delta.negative { color: var(--red); }
.change-delta.neutral { color: var(--text-muted); }
.change-explanation { color: var(--text-muted); font-size: 0.8rem; }

.consequence-narrative {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  font-style: italic;
}

/* Talk to character button */
.character-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  color: var(--text-primary);
  transition: all var(--transition);
  margin-bottom: 1rem;
}
.character-trigger-btn:hover {
  border-color: var(--blue);
  background: var(--bg-card-hover);
}
.char-trigger-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}
.char-trigger-info { flex: 1; }
.char-trigger-name { font-weight: 600; font-size: 0.9rem; }
.char-trigger-prompt { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.char-trigger-arrow { color: var(--text-muted); font-size: 1.2rem; }
.char-trigger-badge {
  background: rgba(59,130,246,0.15);
  color: var(--blue);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}
.char-trigger-badge.complete {
  background: rgba(16,185,129,0.15);
  color: var(--green);
  border-color: rgba(16,185,129,0.3);
}

/* Reflection section */
.reflection-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin: 1.5rem 0;
}
.reflection-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--purple);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.reflection-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.reflection-prompt {
  margin-bottom: 1.25rem;
}
.reflection-prompt label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.reflection-prompt label span {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.5rem;
}
.reflection-prompt textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.75rem;
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
  transition: border-color var(--transition);
}
.reflection-prompt textarea:focus {
  outline: none;
  border-color: var(--purple);
}
.reflection-prompt textarea::placeholder { color: var(--text-muted); }

/* Chapter complete / next */
.chapter-complete-section {
  text-align: center;
  padding: 2rem 0;
  display: none;
}
.chapter-complete-section.visible { display: block; animation: fadeIn 0.5s ease; }
.complete-icon { font-size: 3rem; margin-bottom: 1rem; }
.complete-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.complete-subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.complete-actions { display: flex; gap: 1rem; justify-content: center; }

/* Ripple warning */
.ripple-warning {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.ripple-warning-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.1rem; }

.ripple-flag {
  background: rgba(240,180,41,0.08);
  border: 1px solid rgba(240,180,41,0.25);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ripple-flag-icon { color: var(--gold); }

/* ============================================================
   CHARACTER PANEL
   ============================================================ */

.character-panel {
  width: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.3s ease;
}
.character-panel.open { width: 340px; }

.character-panel-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.character-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}
.character-panel-info { flex: 1; min-width: 0; }
.character-panel-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.character-panel-title { font-size: 0.75rem; color: var(--text-muted); }
.panel-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.panel-close-btn:hover { color: var(--text-primary); background: var(--bg-card); }

.conversation-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.conv-message {
  max-width: 90%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.6;
  animation: fadeIn 0.3s ease;
}
.conv-message.student {
  background: var(--blue-dim);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.conv-message.character {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.conv-message.context {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.35);
  border-left: 3px solid var(--amber);
  color: var(--amber);
  align-self: stretch;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.55;
  max-width: 100%;
}

.conv-message.system {
  background: rgba(240,180,41,0.08);
  border: 1px solid rgba(240,180,41,0.2);
  color: var(--text-muted);
  font-style: italic;
  align-self: center;
  font-size: 0.8rem;
  max-width: 100%;
}
.conv-typing {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  align-self: flex-start;
  display: flex;
  gap: 4px;
  align-items: center;
  animation: fadeIn 0.3s ease;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

.conversation-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}
.conversation-input-area textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.65rem 0.85rem;
  resize: none;
  line-height: 1.5;
  transition: border-color var(--transition);
}
.conversation-input-area textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.conversation-input-area textarea::placeholder { color: var(--text-muted); }
.btn-send {
  align-self: flex-end;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
.modal-panel.modal-large { max-width: 720px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-card); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.modal-body h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; margin-top: 1.25rem; color: var(--text-primary); }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 0.5rem; line-height: 1.7; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow);
  min-width: 250px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toastIn 0.3s ease;
}
.toast.warning { border-color: rgba(245,158,11,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast.success { border-color: rgba(16,185,129,0.4); }

/* ============================================================
   JOURNAL
   ============================================================ */

.journal-entry {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
}
.journal-entry:last-child { border-bottom: none; }
.journal-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}
.journal-chapter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.journal-entry-theme {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.journal-entry-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
}
.journal-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 0.9rem;
}

/* ============================================================
   AUTOPSY
   ============================================================ */

.autopsy-paths { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.autopsy-path {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.autopsy-path.chosen { border-color: var(--gold); }
.autopsy-path-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.autopsy-path.chosen .autopsy-path-label { color: var(--gold); }
.autopsy-path:not(.chosen) .autopsy-path-label { color: var(--text-muted); }
.autopsy-outcome { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }
.autopsy-meters { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.autopsy-meter-row { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 0.5rem; }
.autopsy-insight {
  background: rgba(168,85,247,0.08);
  border: 1px solid rgba(168,85,247,0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
}
.autopsy-insight-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

/* ============================================================
   UTILITY & ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-4px); opacity: 1; }
}

.fade-in { animation: fadeIn 0.4s ease; }

/* Character color themes */
.char-sarah  { background: rgba(240,180,41,0.2); color: var(--gold); }
.char-nadia  { background: rgba(168,85,247,0.2); color: var(--purple); }
.char-margaret { background: rgba(59,130,246,0.2); color: var(--blue); }
.char-david  { background: rgba(16,185,129,0.2); color: var(--green); }
.char-james  { background: rgba(245,158,11,0.2); color: var(--amber); }
.char-rachel { background: rgba(239,68,68,0.2); color: var(--red); }
.char-karen  { background: rgba(107,114,128,0.2); color: #9ca3af; }

/* ── Conversation wrap-up ─────────────────────────────────────── */

.conversation-wrapup-area {
  padding: 0.6rem 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.btn-wrapup {
  width: 100%;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.btn-wrapup:hover {
  background: rgba(16,185,129,0.15);
  border-color: var(--green);
}

/* ── Company profile ──────────────────────────────────────────── */

.company-profile-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.company-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.company-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: center;
}

.company-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}

.company-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.3;
}

.company-stat-note {
  display: block;
  font-size: 0.7rem;
  color: var(--red);
  margin-top: 0.1rem;
}

.company-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.company-detail-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.company-detail-card p { margin-top: 0.5rem; }
.company-detail-card p:first-child { margin-top: 0; }

.company-detail-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.company-watchlist {
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.company-watchlist-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 0.6rem;
}

.company-watchlist-items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.company-watchlist-item {
  font-size: 0.83rem;
  color: var(--text-secondary);
  padding-left: 0.85rem;
  border-left: 2px solid rgba(245,158,11,0.4);
  line-height: 1.5;
}

@media (max-width: 900px) {
  .company-stat-row { grid-template-columns: repeat(2, 1fr); }
  .company-detail-grid { grid-template-columns: 1fr; }
}

/* ── Uber ride chat ───────────────────────────────────────────── */

.uber-ride-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.uber-chat {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 520px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.uber-message {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.uber-message.student {
  flex-direction: row-reverse;
}

.uber-avatar {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.uber-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 78%;
}

.uber-message.student .uber-bubble {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.3);
  color: #c7d8ff;
}

.uber-message.feedback .uber-bubble {
  background: rgba(16,185,129,0.06);
  border-color: rgba(16,185,129,0.2);
  font-size: 0.84rem;
}

.uber-insight {
  display: block;
  margin-top: 0.4rem;
  color: var(--text-secondary);
  font-style: normal;
  font-size: 0.82rem;
  border-left: 2px solid var(--green);
  padding-left: 0.6rem;
}

.uber-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.4rem 0 0.4rem 2rem;
}

.uber-option-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.uber-option-btn:hover {
  border-color: var(--blue);
  background: rgba(59,130,246,0.08);
}

.uber-debrief {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 0.5rem;
  text-align: center;
}
.uber-debrief-title { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.3rem; }
.uber-debrief-score { font-size: 1.1rem; font-weight: 700; color: var(--green); margin-bottom: 0.3rem; }
.uber-debrief-note  { font-size: 0.82rem; color: var(--text-muted); }

/* ── Project proposal cards ───────────────────────────────────── */

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.project-card-header {
  margin-bottom: 0.75rem;
}

.project-proposer {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.project-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.project-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.project-question {
  margin-top: 0.75rem;
}

.project-q-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.project-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.project-type-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.project-type-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--text-primary); }
.project-type-btn.selected { border-color: var(--blue); background: rgba(59,130,246,0.12); color: #c7d8ff; }
.project-type-btn:disabled { opacity: 0.6; cursor: default; }

.project-assess-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.project-assess-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 0.4rem 0.85rem;
  font-size: 0.83rem;
  cursor: pointer;
  transition: var(--transition);
}
.project-assess-btn:hover:not(:disabled) { border-color: var(--amber); color: var(--text-primary); }
.project-assess-btn.selected, .project-assess-btn.yes.selected  { border-color: var(--green); background: rgba(16,185,129,0.1); color: #6ee7b7; }
.project-assess-btn.no.selected  { border-color: var(--red); background: rgba(239,68,68,0.1); color: #fca5a5; }
.project-assess-btn.partly.selected { border-color: var(--amber); background: rgba(245,158,11,0.1); color: #fcd34d; }
.project-assess-btn:disabled { opacity: 0.6; cursor: default; }

.project-feedback {
  font-size: 0.84rem;
  line-height: 1.55;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  margin-top: 0.4rem;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-surface);
}
.project-feedback.correct { border-color: var(--green); }
.project-feedback.incorrect { border-color: var(--amber); }
.project-feedback.note { border-color: var(--blue); }

/* ── Contested landscape docs ─────────────────────────────────── */

.landscape-doc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.landscape-doc-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  flex-wrap: wrap;
}
.landscape-doc-header:hover { background: var(--bg-card-hover); }

.landscape-doc-label {
  font-size: 0.78rem;
  white-space: nowrap;
}

.landscape-doc-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.landscape-doc-from {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-basis: 100%;
  padding-left: 0;
}

.landscape-toggle {
  font-size: 0.78rem;
  color: var(--blue);
  white-space: nowrap;
  margin-left: auto;
}

.landscape-doc-body {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  border-top: 1px solid var(--border);
}
.landscape-doc-body p { margin-top: 0.75rem; }

.landscape-stance {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-top: 0.5rem;
}

/* ============================================================
   CHAPTER 2 — Confusion Matrix & Model Evaluation
   ============================================================ */

.cm-threshold-row {
  margin: 1rem 0 0.5rem;
}
.cm-threshold-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  display: block;
}
.cm-slider {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
  height: 4px;
  margin-bottom: 0.25rem;
}
.cm-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.cm-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem;
  align-items: start;
  margin: 1rem 0;
}

.confusion-matrix {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  grid-template-rows: auto 1fr 1fr;
  gap: 3px;
  font-size: 0.8rem;
  min-width: 280px;
}
.cm-corner   { }
.cm-col-head { padding: 0.4rem 0.5rem; text-align: center; font-weight: 600; font-size: 0.72rem; color: var(--text-muted); }
.cm-row-head { padding: 0.4rem 0.5rem; font-weight: 600; font-size: 0.72rem; color: var(--text-muted); writing-mode: vertical-lr; text-orientation: mixed; transform: rotate(180deg); text-align: center; }

.cm-cell {
  padding: 0.75rem 0.6rem;
  border-radius: 6px;
  text-align: center;
}
.cm-cell-val   { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.cm-cell-label { font-size: 0.65rem; color: inherit; margin-top: 0.3rem; opacity: 0.85; }

.cm-cell.tp { background: rgba(16,185,129,0.15);  color: var(--green); }
.cm-cell.tn { background: rgba(16,185,129,0.08);  color: var(--green); }
.cm-cell.fp { background: rgba(245,158,11,0.15);  color: var(--amber); }
.cm-cell.fn { background: rgba(239,68,68,0.2);    color: var(--red);   }

.cm-metrics-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cm-metric {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}
.cm-metric.good   { border-color: rgba(16,185,129,0.3); }
.cm-metric.warn   { border-color: rgba(245,158,11,0.3); }
.cm-metric.danger { border-color: rgba(239,68,68,0.4);  background: rgba(239,68,68,0.06); }

.cm-metric-val { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.cm-metric.good .cm-metric-val   { color: var(--green); }
.cm-metric.warn .cm-metric-val   { color: var(--amber); }
.cm-metric.danger .cm-metric-val { color: var(--red);   }
.cm-metric-key { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.cm-metric-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem; }

.cm-stakes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.cm-stake {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
}
.cm-stake.fn-stake { background: rgba(239,68,68,0.08);   border: 1px solid rgba(239,68,68,0.25); }
.cm-stake.fp-stake { background: rgba(245,158,11,0.08);  border: 1px solid rgba(245,158,11,0.25); }
.cm-stake-label { font-weight: 600; margin-bottom: 0.3rem; font-size: 0.78rem; }
.cm-stake.fn-stake .cm-stake-label { color: var(--red);   }
.cm-stake.fp-stake .cm-stake-label { color: var(--amber); }
.cm-stake-text { color: var(--text-secondary); line-height: 1.45; }

.cm-insight {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: rgba(240,180,41,0.06);
  border: 1px solid rgba(240,180,41,0.2);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================================
   CHAPTER 3 — Pipeline Builder
   ============================================================ */

.pipeline-canvas {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 1rem 0;
  margin: 0.75rem 0;
  flex-wrap: nowrap;
}

.pipeline-connector {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  color: var(--text-muted);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.pipeline-node {
  min-width: 110px;
  max-width: 140px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.7rem;
  text-align: center;
  transition: border-color var(--transition);
}
.pipeline-node.fixed      { border-color: var(--border-light); opacity: 0.9; }
.pipeline-node.empty      { border-color: var(--border); border-style: dashed; opacity: 0.7; }
.pipeline-node.configured { border-color: var(--gold-dim); background: rgba(240,180,41,0.06); }
.pipeline-node.locked     { opacity: 1; }

.pipeline-node-stage { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
.pipeline-node-icon  { font-size: 1.4rem; margin-bottom: 0.3rem; }
.pipeline-node-name  { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; margin-bottom: 0.25rem; }
.pipeline-node-desc  { font-size: 0.65rem; color: var(--text-muted); line-height: 1.35; }

.pipeline-config-section {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pipeline-config-prompt  { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.6rem; }
.pipeline-config-options { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.pipeline-config-btn {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color var(--transition), background var(--transition);
}
.pipeline-config-btn:hover   { border-color: var(--gold-dim); background: var(--bg-card-hover); }
.pipeline-config-btn.selected{ border-color: var(--gold); background: rgba(240,180,41,0.1); }
.pipeline-config-icon { font-size: 1.1rem; }
.pipeline-config-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.pipeline-config-desc { font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; }

.pipeline-summary {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(240,180,41,0.07);
  border: 1px solid rgba(240,180,41,0.3);
  border-radius: var(--radius);
}
.pipeline-summary-title  { font-weight: 600; color: var(--gold); font-size: 0.85rem; margin-bottom: 0.4rem; }
.pipeline-summary-detail { font-size: 0.82rem; color: var(--text-secondary); }

.pipeline-derived {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius);
}
.pipeline-derived-level { font-size: 1rem; font-weight: 700; color: var(--green); margin-bottom: 0.3rem; }
.pipeline-derived-desc  { font-size: 0.82rem; color: var(--text-secondary); }

/* ============================================================
   CHAPTER 2 — AI Readiness Assessment
   ============================================================ */

.readiness-dimensions { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 1rem; }

.readiness-dim {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.readiness-dim-header { margin-bottom: 0.5rem; }
.readiness-dim-label { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.readiness-dim-desc  { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; }

.readiness-dim-clue {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
}

.readiness-levels { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

.readiness-level-btn {
  flex: 1; min-width: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-primary);
}
.readiness-level-btn:hover:not(:disabled) { border-color: var(--gold-dim); background: var(--bg-card-hover); }
.readiness-level-btn.selected { border-color: var(--gold); background: rgba(240,180,41,0.1); }
.readiness-level-btn:disabled { opacity: 0.8; cursor: default; }
.readiness-level-name { font-weight: 600; font-size: 0.82rem; color: var(--gold); margin-bottom: 0.2rem; }
.readiness-level-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

.readiness-feedback {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  line-height: 1.5;
}
.readiness-feedback.correct  { background: rgba(16,185,129,0.1); color: var(--green);  border-left: 2px solid var(--green); }
.readiness-feedback.low      { background: rgba(245,158,11,0.1);  color: var(--amber);  border-left: 2px solid var(--amber); }
.readiness-feedback.high     { background: rgba(245,158,11,0.1);  color: var(--amber);  border-left: 2px solid var(--amber); }

.readiness-aggregate {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.readiness-agg-score { text-align: center; flex-shrink: 0; }
.readiness-agg-number { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.readiness-agg-label { font-size: 0.8rem; font-weight: 600; margin-top: 0.25rem; }
.readiness-agg-insight { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }

/* ============================================================
   CHAPTER 2 — Task Priority Selection
   ============================================================ */

.task-priority-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.task-priority-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.task-priority-card:hover:not(.locked) { border-color: var(--gold-dim); background: var(--bg-card-hover); }
.task-priority-card.selected { border-color: var(--gold); background: rgba(240,180,41,0.08); }
.task-priority-card.locked   { cursor: default; }

.task-priority-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.35rem; }
.task-priority-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); line-height: 1.35; }
.task-priority-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.task-priority-note { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }
.task-priority-selected-badge { font-size: 0.72rem; color: var(--gold); font-weight: 600; margin-top: 0.35rem; }
.task-priority-warning { font-size: 0.75rem; color: var(--amber); margin-top: 0.5rem; line-height: 1.4; padding: 0.4rem 0.6rem; background: rgba(245,158,11,0.08); border-radius: 4px; }

/* ============================================================
   CHAPTER 3 — Agent Loop Diagram
   ============================================================ */

.agent-loop-diagram {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 1.25rem 0;
  flex-wrap: wrap;
}

.agent-loop-step {
  flex: 1;
  min-width: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: center;
}
.agent-loop-icon  { font-size: 1.5rem; margin-bottom: 0.35rem; }
.agent-loop-stage { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.4rem; }
.agent-loop-desc  { font-size: 0.75rem; color: var(--text-muted); line-height: 1.45; }
.agent-loop-arrow { font-size: 1.25rem; color: var(--text-muted); display: flex; align-items: center; padding-top: 1.5rem; flex-shrink: 0; }

/* ============================================================
   CHAPTER 3 — Loop Quiz
   ============================================================ */

.loop-quiz-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.loop-quiz-item.correct   { border-color: rgba(16,185,129,0.4); }
.loop-quiz-item.incorrect { border-color: rgba(245,158,11,0.4); }

.loop-quiz-scenario { font-size: 0.88rem; color: var(--text-secondary); font-style: italic; margin-bottom: 0.75rem; line-height: 1.55; }
.loop-quiz-options  { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.loop-quiz-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.loop-quiz-btn:hover:not(:disabled) { border-color: var(--gold-dim); color: var(--text-primary); }
.loop-quiz-btn.selected { border-color: var(--blue); background: rgba(59,130,246,0.12); color: var(--blue); }
.loop-quiz-btn.correct  { border-color: var(--green); background: rgba(16,185,129,0.12); color: var(--green); }
.loop-quiz-btn:disabled { cursor: default; }

.loop-quiz-feedback {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  line-height: 1.5;
}
.loop-quiz-feedback.correct   { background: rgba(16,185,129,0.1); color: var(--green);  border-left: 2px solid var(--green); }
.loop-quiz-feedback.incorrect { background: rgba(245,158,11,0.1);  color: var(--amber);  border-left: 2px solid var(--amber); }

/* ============================================================
   CHAPTER 3 — Design Constraints + Brief
   ============================================================ */

.design-constraints-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.design-constraint-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.design-constraint-header {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.design-constraint-body {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.design-brief-fields { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 0.75rem; }
.design-brief-field  { display: flex; flex-direction: column; gap: 0.35rem; }
.design-brief-label  { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); line-height: 1.45; }
.design-brief-input  {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color var(--transition);
}
.design-brief-input:focus { outline: none; border-color: var(--gold-dim); }
.design-brief-input:disabled { opacity: 0.7; cursor: default; }

/* ============================================================
   CHAPTER 4 — Task Impact Map
   ============================================================ */

/* Archetype primer grid */
.archetype-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.archetype-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.archetype-card.replaces  { background: rgba(239,68,68,0.05);   border-color: rgba(239,68,68,0.2); }
.archetype-card.augments  { background: rgba(240,180,41,0.05);  border-color: rgba(240,180,41,0.2); }
.archetype-card.unchanged { background: rgba(59,130,246,0.05);  border-color: rgba(59,130,246,0.2); }
.archetype-icon  { font-size: 1.5rem; }
.archetype-label { font-weight: 700; font-size: 0.95rem; }
.archetype-card.replaces  .archetype-label { color: var(--red, #ef4444); }
.archetype-card.augments  .archetype-label { color: var(--gold); }
.archetype-card.unchanged .archetype-label { color: var(--blue, #3b82f6); }
.archetype-desc    { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.archetype-examples{ font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }

/* Task classification grid */
.task-classify-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.task-classify-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  transition: border-color var(--transition), background var(--transition);
}
.task-classify-card.tc-ai-replaces  { border-color: rgba(239,68,68,0.4);   background: rgba(239,68,68,0.04); }
.task-classify-card.tc-ai-augments  { border-color: rgba(240,180,41,0.4);  background: rgba(240,180,41,0.04); }
.task-classify-card.tc-unchanged    { border-color: rgba(59,130,246,0.4);  background: rgba(59,130,246,0.04); }
.task-classify-label   { font-size: 0.88rem; font-weight: 600; margin-bottom: 0.6rem; color: var(--text-primary); }
.task-classify-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.classify-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-base);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.classify-btn:hover { border-color: var(--gold-dim); color: var(--text-primary); }
.classify-btn.selected.replaces  { background: rgba(239,68,68,0.15);  border-color: rgba(239,68,68,0.6);  color: var(--red, #ef4444); font-weight: 600; }
.classify-btn.selected.augments  { background: rgba(240,180,41,0.15); border-color: rgba(240,180,41,0.6); color: var(--gold); font-weight: 600; }
.classify-btn.selected.unchanged { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.6); color: var(--blue, #3b82f6); font-weight: 600; }

/* Suitability scorecard */
.scorecard-primary   { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.scorecard-dims      { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.scorecard-dim-row   { display: grid; grid-template-columns: 180px 1fr; gap: 0.75rem; align-items: start; }
.dim-label-col       { display: flex; flex-direction: column; gap: 0.25rem; padding-top: 0.25rem; }
.dim-label           { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.dim-note            { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }
.dim-buttons         { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.dim-score-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-base);
  cursor: pointer;
  min-width: 52px;
  transition: all var(--transition);
}
.dim-score-btn:hover { border-color: var(--gold-dim); }
.dim-score-btn.selected { background: rgba(240,180,41,0.12); border-color: var(--gold); }
.dsb-num  { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.dsb-word { font-size: 0.65rem; color: var(--text-muted); }
.dim-score-btn.selected .dsb-num  { color: var(--gold); }
.dim-score-btn.selected .dsb-word { color: var(--gold); }

.scorecard-result {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--border);
  margin-top: 1rem;
}
.scorecard-result.high     { border-color: var(--green); background: rgba(16,185,129,0.06); }
.scorecard-result.moderate { border-color: var(--gold);  background: rgba(240,180,41,0.06); }
.scorecard-result.low      { border-color: var(--red, #ef4444); background: rgba(239,68,68,0.06); }
.sc-result-scores { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: 0.9rem; margin-bottom: 0.4rem; }
.sc-diff  { color: var(--text-muted); font-size: 0.85rem; }
.sc-verdict { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

.scorecard-comparison    { margin-top: 1.5rem; }
.scorecard-expert-grid   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.scorecard-expert-card   { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.sec-task-name   { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.6rem; color: var(--text-primary); }
.sec-bar-wrap    { background: var(--bg-base); border-radius: 4px; height: 6px; margin-bottom: 0.4rem; overflow: hidden; }
.sec-bar-fill    { height: 100%; background: var(--gold-dim); border-radius: 4px; transition: width 0.4s; }
.sec-meta        { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.6rem; }
.sec-dims        { display: flex; flex-direction: column; gap: 0.25rem; }
.sec-dim-row     { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }
.sec-dim-score   { font-weight: 600; color: var(--text-secondary); }

/* Scenario cards */
.scenario-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.scenario-card  { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.scenario-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.95rem; }
.scenario-icon   { font-size: 1.1rem; }
.scenario-timeframe { color: var(--text-muted); font-size: 0.82rem; margin-left: auto; }
.scenario-metrics { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.sc-metric { font-size: 0.74rem; padding: 0.2rem 0.5rem; border-radius: 4px; }
.sc-replaces { background: rgba(239,68,68,0.1);  color: var(--red, #ef4444); }
.sc-augments { background: rgba(240,180,41,0.1); color: var(--gold); }
.sc-unchanged{ background: rgba(59,130,246,0.1); color: var(--blue, #3b82f6); }
.sc-fte      { background: rgba(16,185,129,0.1); color: var(--green); }
.scenario-insight { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.55; flex: 1; }

/* Communication options */
.comms-research-note {
  background: var(--bg-surface);
  border-left: 3px solid var(--gold-dim);
  padding: 0.85rem 1.1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.comms-research-note cite { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 0.3rem; }
.communication-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.comm-option-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.comm-option-header { font-size: 0.95rem; }
.comm-option-desc   { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; flex: 1; }
.comm-consequences  { display: flex; flex-direction: column; gap: 0.4rem; }
.comm-consequence   { font-size: 0.78rem; padding: 0.35rem 0.6rem; border-radius: 4px; }
.comm-consequence.positive { background: rgba(16,185,129,0.1); color: var(--green); }
.comm-consequence.neutral  { background: var(--bg-base); color: var(--text-muted); }
.comm-risk { font-size: 0.78rem; color: var(--amber, #f59e0b); line-height: 1.4; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .character-panel.open { width: 280px; }
}
@media (max-width: 900px) {
  .design-constraints-grid { grid-template-columns: 1fr; }
  .task-priority-grid       { grid-template-columns: 1fr; }
  .agent-loop-diagram       { flex-direction: column; }
  .agent-loop-arrow         { display: none; }
  .readiness-aggregate      { flex-direction: column; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  .character-panel.open { width: 100%; position: fixed; inset: 60px 0 0 0; z-index: 50; }
  #chapter-content-area { padding: 1rem 1rem 3rem; }
  .readiness-levels { flex-direction: column; }
}
