/* ═══════════════════════════════════════════════════════════════════════
   VoiceCoach — Design System & Styles
   Light translucent palette: cool white · refined blue · soft chrome
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ─────────────────────────────────────────────── */
:root {
  /* Palette */
  --bg-primary:          #f5f7fa;
  --bg-secondary:        #ffffff;
  --surface-glass:       rgba(255, 255, 255, 0.72);
  --surface-pressed:     rgba(11, 18, 32, 0.04);

  --color-navy-deepest:  #eef3f8;
  --color-navy-deep:     #f5f7fa;
  --color-navy-mid:      #ffffff;
  --color-navy-light:    rgba(255, 255, 255, 0.72);
  --color-navy-lighter:  #edf2f8;

  --color-gold:          #3b82f6;
  --color-gold-light:    #2563eb;
  --color-gold-dim:      #6b7a90;
  --color-gold-muted:    rgba(59, 130, 246, 0.10);

  --color-offwhite:      #0b1220;
  --color-offwhite-dim:  #5b6472;
  --color-text-muted:    #8a93a3;

  --color-coach-bubble:  #ffffff;
  --color-user-bubble:   #eff6ff;
  --color-error:         #e05c5c;
  --color-success:       #22c55e;
  --color-warn:          #f59e0b;

  /* Ring colours per dimension */
  --ring-grammar:        #6fa8ff;
  --ring-vocab:          #c9a84c;
  --ring-pronunciation:  #7ed4a7;
  --ring-coherence:      #bf8be0;

  /* Typography */
  --font-display: 'Inter', 'SF Pro Display', 'Segoe UI', 'Noto Sans', system-ui, sans-serif;
  --font-body:    'Inter', 'SF Pro Text', 'Segoe UI', 'Noto Sans', system-ui, sans-serif;

  --text-xs:    0.72rem;
  --text-sm:    0.85rem;
  --text-base:  1rem;
  --text-md:    1.1rem;
  --text-lg:    1.3rem;
  --text-xl:    1.6rem;
  --text-2xl:   2rem;
  --text-3xl:   2.8rem;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Borders & Radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  --border-subtle:    1px solid rgba(11, 18, 32, 0.08);
  --border-accent:    1px solid rgba(59, 130, 246, 0.22);
  --border-strong:    1px solid var(--color-gold);

  /* Shadows */
  --shadow-sm:   0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow-md:   0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg:   0 14px 40px rgba(15, 23, 42, 0.10);
  --shadow-gold: 0 12px 30px rgba(59, 130, 246, 0.12);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   400ms ease;
  --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --header-height:   60px;
  --sidebar-width:   380px;
  --max-chat-width:  760px;
  --nav-sidebar-width: 220px;
  --nav-sidebar-collapsed-width: 76px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.08), transparent 30%),
    linear-gradient(180deg, #fbfcfe 0%, var(--bg-primary) 55%, #eef3f8 100%);
  color: var(--color-offwhite);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

img, svg { display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
textarea, input { font-family: inherit; }

/* ── Grain Overlay ─────────────────────────────────────────────────── */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
}

/* ── App Shell ─────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

.device-smartphone .app-shell {
  height: 100svh;
  min-height: 100svh;
}

/* ── Header ────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-6);
  background: var(--surface-glass);
  backdrop-filter: blur(24px);
  border-bottom: var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: var(--space-4);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.header-brand:hover {
  opacity: 0.96;
}

.header-brand:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 4px;
  border-radius: 14px;
}

.brand-icon {
  width: 66px;
  height: 66px;
  flex: 0 0 66px;
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 4px 14px rgba(201, 168, 76, 0.18));
  pointer-events: none;
}

.brand-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-offwhite);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.28em;
  flex-wrap: wrap;
}

.brand-language {
  color: var(--brand-language-color, #3b82f6);
  font-weight: 700;
  text-shadow: 0 0 18px color-mix(in srgb, var(--brand-language-color, #3b82f6) 16%, transparent);
}

.brand-tagline {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 300;
  letter-spacing: 0.04em;
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 600px) {
  .brand-tagline { display: block; }
}

.header-status {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ── Header sign-out button ─────────────────────────────────── */
.header-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 140ms, color 140ms, border-color 140ms;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-logout-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.22);
}
.header-logout-btn:active {
  background: rgba(255, 255, 255, 0.08);
}

.voice-status-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: var(--border-subtle);
  background: rgba(255, 255, 255, 0.76);
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.voice-status-icon {
  width: 17px;
  height: 17px;
}

.voice-status-badge.ready {
  color: var(--color-success);
  border-color: rgba(90, 184, 120, 0.35);
  background: rgba(34, 197, 94, 0.10);
}

.voice-status-badge.warning {
  color: var(--color-warn);
  border-color: rgba(225, 177, 79, 0.35);
  background: rgba(245, 158, 11, 0.10);
}

.voice-status-badge.error {
  color: var(--color-error);
  border-color: rgba(224, 92, 92, 0.35);
  background: rgba(224, 92, 92, 0.10);
}

.status-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.status-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-gold);
  transition: color var(--transition-base);
  font-variant-numeric: tabular-nums;
}

.level-badge {
  background: var(--color-gold-muted);
  border: var(--border-accent);
  color: var(--color-gold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: all var(--transition-base);
}

.connection-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  background: var(--color-text-muted);
  transition: background var(--transition-base);
  flex-shrink: 0;
}

.connection-dot.connected    { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.connection-dot.connecting   { background: var(--color-warn); animation: pulse-dot 1.2s ease infinite; }
.connection-dot.disconnected { background: var(--color-error); }
.connection-dot.demo         { background: #9b5ce0; box-shadow: 0 0 6px #9b5ce0; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Main Layout ───────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.sidebar-nav {
  width: var(--nav-sidebar-width);
  flex-shrink: 0;
  border-right: var(--border-subtle);
  background: var(--surface-glass);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-4);
  min-height: 0;
  transition: width var(--transition-base), padding var(--transition-base);
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  color: var(--color-text-muted);
  justify-content: flex-start;
}

.sidebar-toggle:hover,
.sidebar-link:hover {
  color: var(--color-gold);
  background: rgba(59, 130, 246, 0.10);
}

.sidebar-section-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: var(--border-subtle);
  color: var(--color-offwhite-dim);
  justify-content: flex-start;
  transition: all var(--transition-fast);
}

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.10);
  border: var(--border-accent);
  color: var(--color-gold);
}

.sidebar-link-icon,
.sidebar-toggle-icon {
  width: 18px;
  height: 18px;
  text-align: center;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-link-icon svg,
.sidebar-toggle-icon svg,
.message-avatar svg,
.encouragement-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-toggle-icon {
  color: #6b7a90;
}

#nav-topics .sidebar-link-icon {
  color: #3b82f6;
}

#nav-session .sidebar-link-icon {
  color: #14b8a6;
}

#nav-feedback .sidebar-link-icon {
  color: #f59e0b;
}

.sidebar-link.active .sidebar-link-icon {
  filter: saturate(1.15);
}

.workspace-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.device-smartphone .app-main {
  flex-direction: column;
}

.device-smartphone .workspace-pane {
  overflow: auto;
}

.app-shell.sidebar-collapsed .sidebar-nav {
  width: var(--nav-sidebar-collapsed-width);
  padding-inline: var(--space-2);
}

.app-shell.sidebar-collapsed .sidebar-label,
.app-shell.sidebar-collapsed .sidebar-section-label {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-link,
.app-shell.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
  padding-inline: var(--space-2);
}

.hidden { display: none !important; }

/* ── Topic Selector ────────────────────────────────────────────────── */
.topic-selector {
  flex: 1;
  min-height: 0;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-12);
  width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.selector-header {
  text-align: center;
  margin-bottom: var(--space-5);
}

.selector-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-offwhite);
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
}

.selector-subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

.language-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.language-setting {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.language-select {
  height: 40px;
  padding: 0 var(--space-3);
  border-radius: 12px;
  border: var(--border-subtle);
  background: var(--surface-glass);
  color: var(--color-offwhite);
  backdrop-filter: blur(20px);
}

.language-select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.35);
}

/* Level Picker */
.level-picker, .domain-filter {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.picker-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  white-space: nowrap;
}

.level-buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.level-btn {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: var(--border-subtle);
  color: var(--color-offwhite-dim);
  font-size: var(--text-sm);
  font-weight: 500;
  background: transparent;
  letter-spacing: 0.05em;
  transition: all var(--transition-fast);
}

.level-btn:hover {
  border-color: var(--color-gold-dim);
  color: var(--color-gold);
}

.level-btn.active {
  background: var(--color-gold-muted);
  border: var(--border-accent);
  color: var(--color-gold);
}

/* Domain Chips */
.domain-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.chip {
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: var(--border-subtle);
  color: var(--color-offwhite-dim);
  font-size: var(--text-xs);
  font-weight: 500;
  background: rgba(11, 18, 32, 0.04);
  letter-spacing: 0.04em;
  text-transform: capitalize;
  transition: all var(--transition-fast);
}

.chip:hover {
  border-color: var(--color-gold-dim);
  color: var(--color-gold-light);
}

.chip.active {
  background: rgba(59, 130, 246, 0.10);
  border: var(--border-accent);
  color: var(--color-gold);
}

/* Topic Grid */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.topic-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-8);
}

.plan-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid rgba(217, 119, 6, 0.18);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.92), rgba(239, 246, 255, 0.92));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.plan-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.plan-status {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b45309;
}

.plan-message {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.5;
  color: #334155;
}

.plan-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.plan-install-hint {
  width: 100%;
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #64748b;
}

.device-smartphone .plan-banner {
  gap: 0.8rem;
  padding: 0.85rem;
  border-radius: 14px;
}

.device-smartphone .plan-message {
  font-size: 0.88rem;
  line-height: 1.4;
}

.device-smartphone .plan-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.device-smartphone .plan-actions button {
  min-height: 42px;
  padding-inline: 0.7rem;
  white-space: nowrap;
}

.owner-auth-note {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #64748b;
}

/* Topic Card */
.topic-card {
  background: var(--bg-secondary);
  border: var(--border-subtle);
  border-radius: 16px;
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
  --topic-accent: #94a3b8;
  --topic-accent-soft: rgba(148, 163, 184, 0.12);
  --topic-accent-border: rgba(148, 163, 184, 0.18);
}

.topic-card:hover {
  border-color: var(--topic-accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.topic-card:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.topic-card-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-offwhite);
  line-height: 1.3;
}

.topic-card-desc {
  font-size: var(--text-sm);
  color: var(--color-offwhite-dim);
  line-height: 1.5;
  flex: 1;
}

.device-smartphone .topic-card-desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.topic-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.topic-card-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--topic-accent-soft);
  color: var(--topic-accent);
  border: 1px solid var(--topic-accent-border);
}

.topic-card-icon svg {
  width: 19px;
  height: 19px;
}

.topic-card-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--topic-accent);
}

.topic-card.mastery-new {
  --topic-accent: #94a3b8;
  --topic-accent-soft: rgba(148, 163, 184, 0.12);
  --topic-accent-border: rgba(148, 163, 184, 0.18);
}

.topic-card.mastery-building {
  --topic-accent: #3b82f6;
  --topic-accent-soft: rgba(59, 130, 246, 0.12);
  --topic-accent-border: rgba(59, 130, 246, 0.24);
}

.topic-card.mastery-strong {
  --topic-accent: #8b5cf6;
  --topic-accent-soft: rgba(139, 92, 246, 0.12);
  --topic-accent-border: rgba(139, 92, 246, 0.24);
}

.topic-card.mastery-mastered {
  --topic-accent: #22c55e;
  --topic-accent-soft: rgba(34, 197, 94, 0.12);
  --topic-accent-border: rgba(34, 197, 94, 0.24);
}

.topic-card-locked {
  cursor: not-allowed;
  opacity: 0.82;
}

.topic-card-locked:hover {
  transform: none;
}

.topic-card-lock {
  font-size: var(--text-xs);
  line-height: 1.45;
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
}

/* ── Conversation Area ─────────────────────────────────────────────── */
.conversation-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: var(--max-chat-width);
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--space-4);
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: var(--border-subtle);
  gap: var(--space-3);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(24px);
}

.conversation-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  justify-content: center;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-full);
  border: var(--border-subtle);
  background: rgba(255, 255, 255, 0.74);
}

.view-toggle-btn {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all var(--transition-fast);
}

.view-toggle-btn.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-gold);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 22px rgba(15, 23, 42, 0.08);
}

.session-topic-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-offwhite);
  text-align: center;
}

.session-level-badge {
  background: var(--color-gold-muted);
  border: var(--border-accent);
  color: var(--color-gold);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* Interaction Mode Badge */
.interaction-mode-badge {
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: #818cf8;
  transition: background 0.3s, color 0.3s;
}
.interaction-mode-badge[data-mode="support_mode"] {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
  color: #fbbf24;
}
.interaction-mode-badge[data-mode="target_language_mode"] {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.28);
  color: #4ade80;
}

/* Reward Toast */
.reward-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(30, 30, 40, 0.92);
  color: #f0fdf4;
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: var(--radius-lg);
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}
.reward-toast.reward-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}
.reward-toast.reward-toast-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(0);
}

/* Ghost Buttons */
.btn-ghost {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: var(--border-subtle);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  background: transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-ghost:hover {
  border-color: var(--color-gold-dim);
  color: var(--color-gold);
  background: rgba(59, 130, 246, 0.10);
}

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

/* Message List */
.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-6) 0;
  padding-bottom: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.voice-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: calc(var(--space-10) + 28px) var(--space-8) calc(var(--space-12) + 80px);
  position: relative;
  overflow: hidden;
  --stage-shift-x: 0px;
  --stage-shift-y: 0px;
}

.voice-stage::before {
  content: '';
  position: absolute;
  inset: 10% 16%;
  border-radius: 40px;
  background:
    radial-gradient(circle at 50% 34%, rgba(105, 163, 255, 0.20), transparent 24%),
    radial-gradient(circle at 50% 62%, rgba(255, 176, 110, 0.10), transparent 28%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 72%);
  border: none;
  box-shadow: none;
  transform: translate(var(--stage-shift-x), var(--stage-shift-y));
  filter: blur(10px) saturate(1.04);
  pointer-events: none;
}

.voice-stage::after {
  content: '';
  position: absolute;
  inset: 20% 26%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 150, 255, 0.22), transparent 68%);
  transform: translate(calc(var(--stage-shift-x) * -0.6), calc(var(--stage-shift-y) * -0.6));
  filter: blur(28px);
  pointer-events: none;
}

.voice-orb-shell,
.voice-stage-toolbar,
.voice-waveform,
.voice-state-label,
.voice-state-caption {
  position: relative;
  z-index: 1;
}

.voice-stage-toolbar {
  position: absolute;
  top: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 56px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(11, 18, 32, 0.08);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.10);
  backdrop-filter: blur(18px);
  z-index: 3;
  pointer-events: auto;
}

.voice-stage-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.voice-stage-btn {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--color-offwhite-dim);
  border: 1px solid rgba(11, 18, 32, 0.08);
  background: rgba(255,255,255,0.58);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.voice-stage-btn:hover {
  color: var(--color-gold);
  border-color: rgba(59, 130, 246, 0.18);
  background: rgba(59, 130, 246, 0.08);
}

.voice-stage-topic {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--color-offwhite);
  text-align: center;
  flex: 1;
}

.voice-orb-shell {
  width: min(56vw, 420px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform: translate(calc(var(--stage-shift-x) * -0.4), calc(var(--stage-shift-y) * -0.4));
  pointer-events: none;
}

.voice-orb {
  position: relative;
  width: 62%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.voice-orb-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.9), rgba(255,255,255,0.12) 18%, transparent 28%),
    radial-gradient(circle at 50% 50%, rgba(120, 180, 255, 0.9), rgba(52, 95, 186, 0.9) 58%, rgba(15, 24, 48, 0.95) 100%);
  box-shadow:
    0 24px 60px rgba(52, 95, 186, 0.32),
    inset 0 2px 8px rgba(255,255,255,0.22),
    inset 0 -12px 24px rgba(7, 12, 24, 0.38);
  transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
}

.voice-orb.idle .voice-orb-core {
  animation: orb-idle-breathe 4.2s ease-in-out infinite;
}

.voice-orb.listening .voice-orb-core {
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.9), rgba(255,255,255,0.12) 18%, transparent 28%),
    radial-gradient(circle at 50% 50%, rgba(255, 180, 119, 0.95), rgba(255, 126, 51, 0.92) 58%, rgba(55, 24, 10, 0.96) 100%);
  box-shadow:
    0 24px 70px rgba(255, 126, 51, 0.36),
    inset 0 2px 8px rgba(255,255,255,0.24),
    inset 0 -12px 24px rgba(26, 11, 4, 0.34);
  animation: orb-listening 1.2s ease-in-out infinite;
}

.voice-orb.speaking .voice-orb-core {
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.94), rgba(255,255,255,0.14) 18%, transparent 28%),
    radial-gradient(circle at 50% 50%, rgba(126, 201, 255, 0.98), rgba(62, 123, 255, 0.95) 58%, rgba(10, 24, 72, 0.98) 100%);
  box-shadow:
    0 24px 72px rgba(68, 133, 255, 0.42),
    inset 0 2px 8px rgba(255,255,255,0.26),
    inset 0 -12px 24px rgba(8, 17, 48, 0.34);
  animation: orb-speaking 1s ease-in-out infinite;
}

.voice-orb.thinking .voice-orb-core {
  animation: orb-thinking 1.8s ease-in-out infinite;
}

/* ── Speech Presence Avatar ─────────────────────────────────────────────── */

.voice-avatar {
  width: 62%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 12px 32px rgba(52, 95, 186, 0.45));
  transition: opacity 0.15s ease, transform 0.15s ease, filter 0.3s ease;
  animation: avatar-float 4.2s ease-in-out infinite;
  will-change: transform;
  user-select: none;
  pointer-events: none;
}

.voice-avatar.swapping {
  opacity: 0;
  transform: scale(0.88);
}

.voice-stage.listening .voice-avatar {
  filter: drop-shadow(0 12px 32px rgba(255, 126, 51, 0.5));
  animation: avatar-listen 1.2s ease-in-out infinite;
}

.voice-stage.speaking .voice-avatar {
  filter: drop-shadow(0 12px 36px rgba(68, 133, 255, 0.55));
  animation: avatar-speak 0.9s ease-in-out infinite;
}

.voice-stage.thinking .voice-avatar {
  filter: drop-shadow(0 12px 28px rgba(160, 100, 255, 0.45));
  animation: avatar-think 1.8s ease-in-out infinite;
}

.voice-stage.levelup .voice-avatar,
.voice-stage.feedback .voice-avatar {
  filter: drop-shadow(0 12px 36px rgba(255, 200, 50, 0.55));
  animation: avatar-celebrate 0.6s ease-in-out infinite alternate;
}

.voice-stage.error .voice-avatar {
  filter: drop-shadow(0 8px 20px rgba(220, 60, 60, 0.4));
  animation: avatar-float 4.2s ease-in-out infinite;
}

@keyframes avatar-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

@keyframes avatar-listen {
  0%, 100% { transform: translateY(0px) scale(1); }
  50%       { transform: translateY(-4px) scale(1.04); }
}

@keyframes avatar-speak {
  0%, 100% { transform: translateY(0px) scale(1); }
  50%       { transform: translateY(-6px) scale(1.02); }
}

@keyframes avatar-think {
  0%, 100% { transform: translateY(0px) rotate(-1deg); }
  33%       { transform: translateY(-5px) rotate(1deg); }
  66%       { transform: translateY(-3px) rotate(-0.5deg); }
}

@keyframes avatar-celebrate {
  from { transform: translateY(0px) rotate(-3deg) scale(1); }
  to   { transform: translateY(-10px) rotate(3deg) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .voice-avatar,
  .voice-stage.listening .voice-avatar,
  .voice-stage.speaking .voice-avatar,
  .voice-stage.thinking .voice-avatar,
  .voice-stage.levelup .voice-avatar,
  .voice-stage.feedback .voice-avatar {
    animation: none;
  }
}

.voice-waveform {
  width: min(72vw, 560px);
  height: 90px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  transform: translate(calc(var(--stage-shift-x) * -0.2), calc(var(--stage-shift-y) * -0.2));
  pointer-events: none;
}

.voice-wave-bar {
  width: 8px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(113, 153, 255, 0.82), rgba(115, 170, 255, 0.14));
  box-shadow: 0 0 14px rgba(88, 144, 255, 0.10);
  transform-origin: center bottom;
  transition: transform 80ms linear, opacity 120ms linear, background var(--transition-fast), box-shadow var(--transition-fast);
  pointer-events: none;
}

.voice-stage.listening .voice-wave-bar {
  background: linear-gradient(180deg, rgba(255,238,225,0.95), rgba(255, 132, 56, 0.28));
  box-shadow: 0 0 14px rgba(255, 132, 56, 0.16);
}

.voice-stage.speaking .voice-wave-bar {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(96, 145, 255, 0.34));
  box-shadow: 0 0 16px rgba(89, 149, 255, 0.2);
}

.voice-state-label {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2vw, 2.4rem);
  color: var(--color-offwhite);
  letter-spacing: 0.02em;
}

.voice-state-caption {
  max-width: 520px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-md);
}

@keyframes orb-idle-breathe {
  0%, 100% { transform: scale(0.98); }
  50% { transform: scale(1.02); }
}

@keyframes orb-listening {
  0%, 100% { transform: scale(0.94) translateY(0); }
  50% { transform: scale(1.04) translateY(-2px); }
}

@keyframes orb-speaking {
  0%, 100% { transform: scale(0.96); }
  30% { transform: scale(1.06) translateY(-1px); }
  60% { transform: scale(1.01) translateY(1px); }
}

@keyframes orb-thinking {
  0%, 100% { transform: scale(0.96); filter: saturate(1); }
  50% { transform: scale(1.03); filter: saturate(1.2); }
}

.app-shell.voice-mode-active .app-header,
.app-shell.voice-mode-active .sidebar-nav,
.app-shell.voice-mode-active .conversation-header {
  display: none;
}

.app-shell.voice-mode-active .workspace-pane,
.app-shell.voice-mode-active .conversation-area {
  max-width: none;
  width: 100%;
  padding: 0;
}

.app-shell.voice-mode-active .voice-stage {
  display: flex;
}

.app-shell.voice-mode-active .input-area {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: auto;
  border: none;
  padding: 0;
  justify-content: center;
  z-index: 6;
}

.app-shell.voice-mode-active .voice-controls,
.app-shell.voice-mode-active .text-input-wrapper {
  display: none;
}

.app-shell.voice-mode-active .mic-btn {
  width: 84px;
  height: 84px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.32), inset 0 1px 0 rgba(255,255,255,0.08);
}

.app-shell.voice-mode-active .mic-icon svg {
  width: 30px;
  height: 30px;
}

.app-shell.voice-mode-active .recording-indicator {
  top: -50px;
}

.message-list::-webkit-scrollbar { width: 4px; }
.message-list::-webkit-scrollbar-track { background: transparent; }
.message-list::-webkit-scrollbar-thumb { background: var(--color-navy-lighter); border-radius: var(--radius-full); }

/* Message Bubbles */
.message {
  display: flex;
  gap: var(--space-3);
  animation: msg-appear 0.3s ease both;
}

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

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--color-navy-lighter);
  border: var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-muted);
  pointer-events: none;
}

.message-avatar-emoji {
  width: 26px;
  height: 26px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.message.coach .message-avatar {
  background: var(--color-gold-muted);
  border-color: rgba(201, 168, 76, 0.25);
  color: #3b82f6;
}

.message.user .message-avatar {
  color: #f97316;
}

.message-bubble {
  max-width: min(75%, 540px);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  position: relative;
}

.message.coach .message-bubble {
  background: var(--color-coach-bubble);
  border: var(--border-subtle);
  border-top-left-radius: var(--radius-sm);
  color: var(--color-offwhite);
}

.message.user .message-bubble {
  background: var(--color-user-bubble);
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-top-right-radius: var(--radius-sm);
  color: var(--color-offwhite);
}

.message-bubble.streaming::after {
  content: '▌';
  animation: blink-cursor 0.7s step-end infinite;
  color: var(--color-gold);
  margin-left: 2px;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.message-timestamp {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  text-align: right;
}

.message.coach .message-timestamp { text-align: left; }

/* System message */
.message.system .message-bubble {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
  max-width: 100%;
  padding: var(--space-2);
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: var(--space-2);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-gold-dim);
  animation: typing-dot 1.2s ease infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ── Input Area ────────────────────────────────────────────────────── */
.input-area {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) 0 var(--space-5);
  border-top: var(--border-subtle);
  flex-shrink: 0;
  position: relative;
}

.voice-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.voice-control-label {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mic-select {
  height: 44px;
  background: rgba(255, 255, 255, 0.74);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--color-offwhite);
  padding: 0 var(--space-3);
}

.mic-select:focus {
  outline: none;
  border-color: rgba(201, 168, 76, 0.4);
}

/* Mic Button */
.mic-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.8);
  border: var(--border-accent);
  color: var(--color-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-base);
}

.mic-btn:hover {
  background: var(--color-gold-muted);
  box-shadow: var(--shadow-gold);
}

.mic-btn.recording {
  background: rgba(224, 92, 92, 0.15);
  border-color: var(--color-error);
  color: var(--color-error);
}

.mic-icon svg {
  width: 22px;
  height: 22px;
}

.mic-pulse {
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-error);
  opacity: 0;
  pointer-events: none;
}

.mic-btn.recording .mic-pulse {
  animation: mic-ripple 1.5s ease infinite;
}

@keyframes mic-ripple {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Text Input */
.text-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.text-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.82);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--color-offwhite);
  font-size: var(--text-base);
  padding: var(--space-3) 52px var(--space-3) var(--space-4);
  resize: none;
  max-height: 160px;
  line-height: 1.5;
  transition: border-color var(--transition-fast);
  scrollbar-width: thin;
}

.text-input:focus {
  outline: none;
  border-color: rgba(201, 168, 76, 0.4);
}

.text-input::placeholder { color: var(--color-text-muted); }

.btn-send {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-gold-muted);
  border: var(--border-accent);
  color: var(--color-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-send:hover {
  background: var(--color-gold);
  color: var(--color-navy-deep);
}

.btn-send svg { width: 16px; height: 16px; }

/* Recording Indicator */
.recording-indicator {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(224, 92, 92, 0.15);
  border: 1px solid rgba(224, 92, 92, 0.35);
  color: var(--color-error);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.rec-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-error);
  animation: pulse-dot 1s ease infinite;
}

/* ── Feedback Drawer ───────────────────────────────────────────────── */
.feedback-drawer {
  position: fixed;
  right: 0;
  top: var(--header-height);
  bottom: 0;
  width: min(var(--sidebar-width), 92vw);
  background: rgba(255, 255, 255, 0.92);
  border-left: var(--border-subtle);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.12);
}

.feedback-drawer.open {
  transform: translateX(0);
}

.drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--color-navy-lighter);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto var(--space-1);
  flex-shrink: 0;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5) var(--space-8);
  scrollbar-width: thin;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.drawer-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-offwhite);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.btn-icon:hover { background: var(--color-navy-lighter); color: var(--color-offwhite); }
.btn-icon svg { width: 18px; height: 18px; }

/* Score Rings */
.score-rings {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.ring-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.ring-svg {
  width: 80px;
  height: 80px;
}

.ring-bg {
  fill: none;
  stroke: var(--color-navy-lighter);
  stroke-width: 7;
}

.ring-progress {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-grammar       { stroke: var(--ring-grammar); }
.ring-vocab         { stroke: var(--ring-vocab); }
.ring-pronunciation { stroke: var(--ring-pronunciation); }
.ring-coherence     { stroke: var(--ring-coherence); }

.ring-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

.ring-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-offwhite);
  margin-top: -var(--space-1);
}

/* Feedback Sections */
.feedback-section {
  margin-bottom: var(--space-5);
}

.feedback-section-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-gold);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: var(--border-subtle);
}

.hint-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.hint-list li {
  font-size: var(--text-sm);
  color: var(--color-offwhite-dim);
  padding-left: var(--space-4);
  position: relative;
  line-height: 1.5;
}

.hint-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--color-gold-dim);
}

/* Corrections */
.corrections-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.correction-item {
  background: var(--color-navy-light);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-sm);
}

.correction-original {
  color: #e05c5c;
  text-decoration: line-through;
  margin-bottom: var(--space-1);
}

.correction-arrow { color: var(--color-text-muted); font-size: var(--text-xs); }

.correction-corrected {
  color: var(--color-success);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.correction-explanation {
  color: var(--color-offwhite-dim);
  line-height: 1.5;
}

/* Encouragement */
.encouragement-card {
  background: rgba(201, 168, 76, 0.06);
  border: var(--border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.encouragement-icon {
  color: var(--color-gold);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.encouragement-text {
  font-size: var(--text-sm);
  color: var(--color-offwhite-dim);
  line-height: 1.6;
  font-style: italic;
}

/* ── Level-Up Modal ─────────────────────────────────────────────────── */
.levelup-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(12px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.levelup-content {
  background: var(--color-navy-mid);
  border: var(--border-accent);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  animation: levelup-enter 0.5s var(--transition-spring) both;
}

@keyframes levelup-enter {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.levelup-stars {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.star {
  font-size: 1.8rem;
  color: var(--color-gold-dim);
  animation: star-pop 0.6s var(--transition-spring) both;
}

.star-center {
  font-size: 2.4rem;
  color: var(--color-gold);
  animation-delay: 0.1s;
}

.star:last-child { animation-delay: 0.2s; }

@keyframes star-pop {
  from { opacity: 0; transform: scale(0) rotate(-20deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.levelup-badge-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.levelup-from {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-text-muted);
  font-weight: 600;
}

.levelup-arrow {
  font-size: var(--text-xl);
  color: var(--color-gold);
}

.levelup-to {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-gold);
  font-weight: 700;
  animation: levelup-badge-glow 2s ease infinite;
}

@keyframes levelup-badge-glow {
  0%, 100% { text-shadow: 0 0 10px rgba(201,168,76,0.3); }
  50% { text-shadow: 0 0 30px rgba(201,168,76,0.8); }
}

.levelup-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-offwhite);
  margin-bottom: var(--space-2);
  letter-spacing: 0.02em;
}

.levelup-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.levelup-score {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--color-gold);
  margin-bottom: var(--space-6);
}

/* Primary Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-8);
  border-radius: var(--radius-full);
  background: var(--color-gold);
  color: var(--color-navy-deep);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background: var(--color-gold-light);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

/* ── Responsive Adjustments ─────────────────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  .app-header {
    padding: 0 var(--space-5);
    gap: var(--space-3);
  }

  .brand-icon {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .brand-name {
    font-size: 1.35rem;
  }

  .voice-status-badge {
    width: 34px;
    height: 34px;
  }

  .status-score {
    gap: 2px;
  }

  .sidebar-nav {
    width: 188px;
    padding: var(--space-3);
    gap: var(--space-4);
  }

  .sidebar-link {
    padding: 12px;
  }

  .topic-selector {
    max-width: 840px;
    padding: var(--space-6) var(--space-5) var(--space-8);
  }

  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .topic-card {
    min-height: 138px;
  }

  .conversation-area {
    max-width: none;
    padding: 0 var(--space-5);
  }

  .conversation-header {
    padding: 12px 0;
  }

  .voice-stage {
    padding: calc(var(--space-8) + 26px) var(--space-5) calc(var(--space-10) + 80px);
  }

  .voice-stage-toolbar {
    width: min(100%, calc(100% - 40px));
    top: var(--space-5);
  }

  .voice-stage-topic {
    font-size: var(--text-base);
  }

  .voice-orb-shell {
    width: min(58vw, 360px);
  }

  .voice-waveform {
    width: min(82vw, 520px);
    height: 82px;
  }

  .input-area {
    padding: var(--space-3) 0 var(--space-4);
  }
}

@media (max-width: 640px) {
  .app-header {
    height: 56px;
    padding: 0 12px;
    gap: 10px;
  }

  .header-brand {
    gap: 10px;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 10px;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .brand-tagline,
  .status-label {
    display: none;
  }

  .header-status {
    gap: 10px;
  }

  .voice-status-badge {
    width: 34px;
    height: 34px;
  }

  .score-value {
    font-size: 1rem;
  }

  .app-main {
    flex-direction: column;
  }

  .sidebar-nav {
    width: 100%;
    border-right: none;
    border-bottom: var(--border-subtle);
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    padding: 10px 12px;
    backdrop-filter: blur(18px);
  }

  .sidebar-top,
  .sidebar-links,
  .sidebar-footer {
    flex-direction: row;
    align-items: center;
  }

  .sidebar-top {
    gap: 6px;
  }

  .sidebar-links {
    flex: 1;
    gap: 8px;
    overflow-x: auto;
  }

  .sidebar-link,
  .sidebar-toggle {
    width: auto;
    white-space: nowrap;
    padding: 10px 12px;
    border-radius: 999px;
  }

  .sidebar-footer {
    margin-top: 0;
    padding: 8px 10px;
    min-width: max-content;
  }

  .topic-selector {
    padding: 20px 14px 28px;
  }

  .selector-header {
    margin-bottom: var(--space-4);
  }

  .selector-title {
    font-size: 1.5rem;
  }

  .selector-subtitle {
    font-size: 0.95rem;
  }

  .language-settings {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: var(--space-4);
  }

  .level-picker,
  .domain-filter {
    gap: 10px;
    margin-bottom: 14px;
  }

  .topic-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: var(--space-4);
  }

  .topic-card {
    padding: 14px;
    gap: 10px;
  }

  .topic-card-title {
    font-size: 1rem;
  }

  .conversation-area {
    max-width: none;
    padding: 0 12px;
  }

  .conversation-header {
    padding: 10px 0;
    gap: 10px;
  }

  .conversation-meta {
    gap: 10px;
  }

  .score-rings {
    grid-template-columns: repeat(2, 1fr);
  }

  .message-bubble {
    max-width: 90%;
  }

  .voice-controls {
    min-width: 100%;
  }

  .voice-stage {
    padding: 78px 16px 136px;
    gap: 18px;
  }

  .voice-stage::before {
    inset: 9% 4%;
    border-radius: 28px;
  }

  .voice-stage::after {
    inset: 22% 10%;
  }

  .voice-stage-toolbar {
    top: 12px;
    width: calc(100% - 20px);
    padding: 10px 12px;
    gap: 8px;
  }

  .voice-stage-actions {
    gap: 6px;
  }

  .voice-stage-btn {
    padding: 8px 10px;
    font-size: 10px;
  }

  .voice-stage-topic {
    font-size: 0.95rem;
  }

  .voice-orb-shell {
    width: min(78vw, 300px);
  }

  .voice-waveform {
    width: 100%;
    max-width: 420px;
    height: 72px;
    gap: 4px;
  }

  .voice-wave-bar {
    width: 6px;
  }

  .voice-state-label {
    font-size: 1.4rem;
  }

  .voice-state-caption {
    font-size: 0.95rem;
    max-width: 340px;
  }

  .app-shell.voice-mode-active .mic-btn {
    width: 74px;
    height: 74px;
  }

  .input-area {
    gap: 10px;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  }

  .voice-control-label {
    font-size: 10px;
  }

  .mic-select,
  .text-input {
    min-height: 44px;
  }

  .feedback-drawer {
    width: 100vw;
    top: 0;
  }

  .drawer-content {
    padding: var(--space-4) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom));
  }
}

@media (min-width: 1024px) {
  .feedback-drawer {
    top: var(--header-height);
  }
}

.device-smartphone .app-header {
  height: 56px;
  padding: 0 12px;
  gap: 10px;
}

.device-smartphone .brand-icon {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.device-smartphone .brand-name {
  font-size: 1.05rem;
}

.device-smartphone .brand-tagline,
.device-smartphone .status-label,
.device-smartphone .selector-subtitle,
.device-smartphone .sidebar-section-label,
.device-smartphone .sidebar-label {
  display: none;
}

.device-smartphone .sidebar-nav {
  width: 100%;
  min-height: auto;
  border-right: none;
  border-bottom: var(--border-subtle);
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
}

.device-smartphone .sidebar-top,
.device-smartphone .sidebar-links,
.device-smartphone .sidebar-footer {
  flex-direction: row;
  align-items: center;
}

.device-smartphone .sidebar-links {
  flex: 1;
  gap: 8px;
  overflow-x: auto;
}

.device-smartphone .sidebar-link,
.device-smartphone .sidebar-toggle {
  width: 42px;
  min-width: 42px;
  height: 42px;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
}

.device-smartphone .topic-selector {
  padding: 18px 12px 28px;
}

.device-smartphone .selector-header {
  margin-bottom: var(--space-3);
}

.device-smartphone .selector-title {
  font-size: 1.4rem;
}

.device-smartphone .language-settings {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: var(--space-4);
}

.device-smartphone .topic-grid {
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: var(--space-4);
}

.device-smartphone .topic-card {
  min-height: auto;
  padding: 14px;
}

.device-smartphone .conversation-area {
  padding: 0 12px;
}

.device-smartphone .message-bubble {
  max-width: 94%;
}

.device-smartphone .voice-stage {
  padding: 72px 12px 128px;
}

.device-smartphone .voice-stage-toolbar {
  top: 12px;
  width: calc(100% - 20px);
  padding: 10px 12px;
}

.device-smartphone .voice-orb-shell {
  width: min(84vw, 270px);
}

.device-smartphone .voice-waveform {
  width: 100%;
  max-width: 420px;
  height: 72px;
}

/* ── Utility Classes ────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-gold    { color: var(--color-gold); }
.text-muted   { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-error   { color: var(--color-error); }

/* ── Scrollbar Styling ──────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-navy-lighter) transparent;
}

*::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--color-navy-lighter);
  border-radius: var(--radius-full);
}

*::-webkit-scrollbar-thumb:hover { background: var(--color-navy-light); }

/* ── Focus Visible ──────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* ── Demo Mode Banner ────────────────────────────────────────────────── */
.demo-banner {
  background: rgba(155, 92, 224, 0.12);
  border-bottom: 1px solid rgba(155, 92, 224, 0.3);
  color: #c090f0;
  text-align: center;
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-4);
  letter-spacing: 0.04em;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.footer-brand {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.footer-sep {
  opacity: 0.4;
}

.footer-copy {
  opacity: 0.7;
}

.footer-links {
  display: flex;
  gap: var(--space-4);
}

.footer-links a {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

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

@media (max-width: 480px) {
  .brand-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .header-status {
    gap: 8px;
  }

  .sidebar-link .sidebar-label,
  .sidebar-toggle .sidebar-label {
    display: none;
  }

  .sidebar-link,
  .sidebar-toggle {
    padding-inline: 10px;
  }

  .topic-selector {
    padding-inline: 12px;
  }

  .conversation-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .view-toggle {
    width: 100%;
    justify-content: center;
  }

  .btn-ghost {
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  .message-list {
    padding-top: var(--space-4);
  }

  .message-bubble {
    max-width: 94%;
    padding: 12px 14px;
  }

  .voice-stage {
    padding: 72px 12px 128px;
  }

  .voice-stage-toolbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .voice-stage-topic {
    order: -1;
    width: 100%;
  }

  .voice-orb-shell {
    width: min(84vw, 270px);
  }

  .voice-state-caption {
    max-width: 300px;
  }

  .app-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Consent modal ──────────────────────────────────────────────────────── */
.consent-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  padding: 1rem;
}
.consent-modal.hidden { display: none; }

.consent-card {
  background: var(--surface, #fff);
  border-radius: 1.25rem;
  padding: 2rem 2rem 1.75rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  text-align: center;
}

.consent-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  color: var(--accent, #6366f1);
}
.consent-icon svg { width: 100%; height: 100%; }

.consent-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary, #111);
}

.consent-body {
  font-size: 0.9rem;
  color: var(--text-secondary, #555);
  line-height: 1.55;
  margin-bottom: 1rem;
}

.consent-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.consent-list li {
  font-size: 0.85rem;
  color: var(--text-secondary, #555);
  padding-left: 1.25rem;
  position: relative;
}
.consent-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent, #6366f1);
  font-weight: 700;
}

.consent-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.consent-allow { width: 100%; }
.consent-decline {
  width: 100%;
  font-size: 0.85rem;
  color: var(--text-secondary, #888);
}

.onboarding-card {
  max-width: 640px;
  text-align: left;
}

.owner-login-card {
  max-width: 540px;
  text-align: left;
}

.onboarding-step-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.9rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.onboarding-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.onboarding-field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary, #111);
}

.onboarding-field input,
.onboarding-field select,
.onboarding-field textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  font: inherit;
  background: rgba(248, 250, 252, 0.95);
  color: #0f172a;
}

.onboarding-field textarea {
  resize: vertical;
}

.onboarding-field-full {
  grid-column: 1 / -1;
}

.onboarding-consents {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.onboarding-verification {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(219, 234, 254, 0.28);
  border: 1px solid rgba(59, 130, 246, 0.14);
}

.onboarding-verification.hidden {
  display: none;
}

.onboarding-verification-actions {
  justify-content: flex-start;
}

.onboarding-note {
  margin: 0 0 0.75rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #475569;
}

.onboarding-check {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #475569;
}

.onboarding-check input {
  margin-top: 0.12rem;
}

.onboarding-error {
  min-height: 1.25rem;
  margin-bottom: 0.8rem;
  color: #b91c1c;
  font-size: 0.85rem;
}

.device-smartphone .consent-modal {
  align-items: flex-end;
  padding: 0;
}

.device-smartphone .consent-card {
  max-width: none;
  max-height: calc(100svh - env(safe-area-inset-top));
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
}

.device-smartphone .owner-login-card,
.device-smartphone .onboarding-card {
  max-width: none;
}

@media (max-width: 900px) {
  .plan-banner {
    flex-direction: column;
    align-items: stretch;
  }
}

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