/* ==========================================================================
   REFLECT & REPAIR — MODERN DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. COLOR SYSTEM & CSS VARIABLES
   -------------------------------------------------------------------------- */
:root {
  /* Color Scheme Baseline */
  color-scheme: dark light;

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Dark Theme Palette (Default) */
  --bg-app: #0d1117;
  --bg-surface: #161b22;
  --bg-panel: rgba(22, 27, 34, 0.75);
  --bg-panel-border: rgba(255, 255, 255, 0.08);
  --bg-card: rgba(33, 38, 45, 0.6);
  --bg-card-hover: rgba(48, 54, 61, 0.8);
  --bg-input: #090d12;
  
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --text-dim: #6e7681;

  /* Brand Accents */
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);

  --accent-success: #10b981; /* Emerald */
  --accent-success-bg: rgba(16, 185, 129, 0.15);
  
  --accent-warning: #f59e0b; /* Amber */
  --accent-warning-bg: rgba(245, 158, 11, 0.15);

  --accent-danger: #ef4444; /* Rose */
  --accent-danger-bg: rgba(239, 68, 68, 0.15);

  --accent-info: #06b6d4; /* Cyan */
  --accent-info-bg: rgba(6, 182, 212, 0.15);

  /* Layout Constants */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Overrides */
[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --bg-panel-border: rgba(0, 0, 0, 0.08);
  --bg-card: rgba(243, 244, 246, 0.8);
  --bg-card-hover: #e5e7eb;
  --bg-input: #ffffff;

  --text-main: #111827;
  --text-muted: #4b5563;
  --text-dim: #6b7280;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* --------------------------------------------------------------------------
   2. RESET & BASE STYLES
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.25;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   3. LAYOUT & GLASS PANELS
   -------------------------------------------------------------------------- */
.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* MODAL OVERLAY */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-size: 1.15rem;
}

/* SPINNER ANIMATION */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* INPUT MODE TOGGLE */
.input-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--bg-panel-border);
}

.mode-btn {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.mode-btn.active {
  background: var(--accent-primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   4. HEADER & NAV
   -------------------------------------------------------------------------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.15;
}

.brand-text .tagline {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#api-key-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#api-key-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.user-stats-pill {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-divider {
  width: 1px;
  height: 14px;
  background: var(--bg-panel-border);
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.icon-button:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

/* Theme Toggle Icons */
.sun-icon { display: none; }
.moon-icon { display: block; }
[data-theme="light"] .sun-icon { display: block; }
[data-theme="light"] .moon-icon { display: none; }

/* NAV TABS */
.app-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

.nav-tab.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   5. TAB PANELS & GENERAL LAYOUT
   -------------------------------------------------------------------------- */
.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

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

/* BUTTON UTILITIES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--bg-panel-border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
}

/* --------------------------------------------------------------------------
   6. TAB 1: SCENARIOS & ROLEPLAY STAGE
   -------------------------------------------------------------------------- */
.scenarios-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .scenarios-layout {
    grid-template-columns: 1fr;
  }
}

/* SIDEBAR */
.scenario-sidebar {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  cursor: pointer;
  transition: var(--transition-fast);
}

.scenario-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.scenario-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-primary);
}

.scenario-item .s-title {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scenario-item .s-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-panel-border);
  color: var(--text-muted);
}

.scenario-item.completed .s-tag {
  background: var(--accent-success-bg);
  color: var(--accent-success);
}

/* ROLEPLAY STAGE */
.roleplay-stage {
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 620px;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bg-panel-border);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 16px;
}

.partner-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.partner-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.partner-meta h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

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

.stage-meters {
  display: flex;
  gap: 20px;
}

.meter-box {
  width: 140px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.meter-num {
  color: var(--text-main);
}

.meter-bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--bg-panel-border);
}

.meter-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s ease, background-color 0.4s ease;
}

.tension-fill { background-color: var(--accent-warning); }
.connection-fill { background-color: var(--accent-success); }

/* BRIEFING BOX */
.scenario-briefing {
  background: var(--bg-card);
  border: 1px dashed var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
}

.briefing-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-info);
  margin-bottom: 4px;
  display: block;
}

.scenario-briefing p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* DIALOGUE STREAM */
.dialogue-stream {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.5;
  animation: bubblePop 0.25s ease-out;
}

@keyframes bubblePop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.chat-bubble.speaker {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  border-top-left-radius: 2px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent-primary);
  color: #ffffff;
  border-top-right-radius: 2px;
}

.chat-bubble .bubble-author {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 2px;
  opacity: 0.8;
}

/* AUTOPSY ALERT CARD */
.autopsy-container {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  animation: slideDown 0.3s ease-out;
}

.autopsy-container.healthy {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

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

.autopsy-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.autopsy-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
}

.autopsy-container.healthy .autopsy-badge {
  background: var(--accent-success-bg);
  color: var(--accent-success);
}

.autopsy-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.autopsy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}

@media (max-width: 650px) {
  .autopsy-grid { grid-template-columns: 1fr; }
}

.autopsy-col {
  background: var(--bg-panel);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.col-heading {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.autopsy-repair-box {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.repair-heading {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--accent-primary);
  display: block;
  margin-bottom: 2px;
}

/* RESPONSE OPTIONS */
.response-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.response-prompt {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  text-align: left;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateX(2px);
}

/* SUMMARY CARD */
.scenario-summary {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.3s ease;
}

.summary-header {
  text-align: center;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
}

.summary-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
}

.summary-header h2 {
  font-size: 1.4rem;
  margin: 10px 0 6px;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.timeline-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border-left: 4px solid var(--accent-primary);
  font-size: 0.88rem;
}

.timeline-item.defensive {
  border-left-color: var(--accent-danger);
}

.timeline-item.healthy {
  border-left-color: var(--accent-success);
}

.summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   7. TAB 2: DE-DEFENSIFIER WORKSHOP
   -------------------------------------------------------------------------- */
.workshop-container {
  padding: 30px;
  max-width: 900px;
  margin: 0 auto;
}

.workshop-header {
  margin-bottom: 24px;
}

.workshop-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.workshop-header p { color: var(--text-muted); font-size: 0.9rem; }

.exercise-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.ex-pill {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.ex-pill.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.defensive-quote-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px stroke rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.quote-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-danger);
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}

.defensive-quote-box blockquote {
  font-size: 1.15rem;
  font-weight: 600;
  font-style: italic;
  margin-bottom: 14px;
}

.trap-analysis {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.trap-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
  font-weight: 600;
}

.rephrase-input-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.rephrase-input-area label {
  font-weight: 600;
  font-size: 0.92rem;
}

.rephrase-input-area textarea {
  width: 100%;
  height: 110px;
  background: var(--bg-input);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  resize: vertical;
}

.rephrase-input-area textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-guidance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.checklist {
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  font-weight: 600;
}

.check-item { color: var(--text-dim); }
.check-item.valid { color: var(--accent-success); }
.check-item.invalid { color: var(--accent-danger); }

/* EVALUATION COMPARISON PANEL */
.rephrase-evaluation {
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 20px;
}

.eval-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

@media (max-width: 650px) {
  .eval-grid { grid-template-columns: 1fr; }
}

.eval-box {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  font-size: 0.9rem;
}

.eval-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.eval-master-text {
  font-weight: 600;
  color: var(--accent-primary);
}

.eval-explanation {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   8. TAB 3: DEFENSIVE STYLE QUIZ
   -------------------------------------------------------------------------- */
.quiz-container {
  padding: 30px;
  max-width: 800px;
  margin: 0 auto;
}

.quiz-header { margin-bottom: 24px; text-align: center; }
.quiz-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.quiz-header p { color: var(--text-muted); font-size: 0.9rem; }

.quiz-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-panel-border);
}

.quiz-progress-bar {
  height: 6px;
  background: var(--bg-panel-border);
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.3s ease;
}

.quiz-step-meta {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 14px;
  display: block;
}

.quiz-question {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-opt-btn {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  text-align: left;
  font-size: 0.92rem;
  transition: var(--transition-fast);
}

.quiz-opt-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateX(4px);
}

/* QUIZ RESULTS */
.quiz-results-card {
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.result-hero {
  padding: 30px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.result-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

.result-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
}

.result-hero h2 {
  font-size: 1.8rem;
  margin: 10px 0;
}

.archetype-desc {
  max-width: 600px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.result-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.detail-card {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-panel-border);
}

.detail-card h4 {
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.detail-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* STATS DASHBOARD CARDS */
.stats-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stats-card {
  background: var(--bg-card);
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-panel-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition-fast);
}

.stats-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.stats-card-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats-card-val {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 4px 0 2px;
}

.stats-card-sub {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.quiz-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   9. TAB 4: SOMATIC & PHRASING CHEAT SHEET
   -------------------------------------------------------------------------- */
.cheatsheet-container {
  padding: 30px;
  max-width: 1100px;
  margin: 0 auto;
}

.cheatsheet-header { margin-bottom: 24px; }
.cheatsheet-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.cheatsheet-header p { color: var(--text-muted); font-size: 0.9rem; }

.cheatsheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .cheatsheet-grid { grid-template-columns: 1fr; }
}

.sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.sheet-card.full-width {
  grid-column: 1 / -1;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.sheet-card h3 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.somatic-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.somatic-steps li {
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.framework-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 500px) {
  .framework-steps { grid-template-columns: 1fr; }
}

.f-step {
  background: var(--bg-panel);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.f-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.f-step strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.88rem;
}

.f-step p { color: var(--text-muted); }

/* PHRASES TABLE */
.table-responsive {
  overflow-x: auto;
}

.phrases-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.88rem;
}

.phrases-table th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg-panel-border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
}

.phrases-table td {
  padding: 14px;
  border-bottom: 1px solid var(--bg-panel-border);
  vertical-align: top;
}

.phrase-bad {
  color: var(--accent-danger);
  font-weight: 600;
}

.phrase-good {
  color: var(--accent-success);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   10. FOOTER & UTILITIES
   -------------------------------------------------------------------------- */
.app-footer {
  text-align: center;
  margin-top: auto;
  padding-top: 30px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   11. MOBILE RESPONSIVENESS & TOUCH OPTIMIZATIONS
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .app-container {
    padding: 10px 12px 24px;
  }

  .app-header {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }

  .header-brand {
    gap: 10px;
  }

  .header-actions {
    gap: 6px;
    justify-content: flex-end;
    width: auto;
  }

  .brand-text h1 {
    font-size: 1.1rem;
  }

  .brand-text .tagline {
    font-size: 0.72rem;
  }

  .nav-tab {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .scenarios-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .scenario-sidebar {
    padding: 14px;
  }

  .roleplay-stage {
    padding: 16px;
    min-height: auto;
  }

  .stage-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .partner-profile {
    justify-content: space-between;
  }

  .stage-meters {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .meter-box {
    flex: 1;
    width: auto;
  }

  .dialogue-stream {
    max-height: 48vh;
  }

  .chat-bubble {
    max-width: 90%;
    font-size: 0.88rem;
    padding: 10px 14px;
  }

  /* Prevent iOS Safari auto-zoom on textarea focus */
  #freeform-input, 
  #user-rephrase-input,
  #custom-scenario-prompt,
  #gemini-key-input {
    font-size: 16px !important;
  }

  .input-mode-toggle {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
  }

  .mode-btn {
    flex: 1;
    text-align: center;
  }

  .workshop-container,
  .quiz-container,
  .cheatsheet-container {
    padding: 16px 14px;
  }

  .exercise-pills {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .phrases-table th, 
  .phrases-table td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .user-stats-pill {
    font-size: 0.78rem;
    padding: 4px 10px;
  }

  .btn {
    width: 100%;
  }

  .input-guidance {
    flex-direction: column;
    align-items: stretch;
  }

  .checklist {
    flex-direction: column;
    gap: 6px;
  }
}
