:root{
  --cream:        #F5EFE3;   /* page background */
  --cream-dark:   #EDE4D3;   /* sidebar, input card background */
  --cream-deeper: #E0D5C1;   /* hover states, dividers */
  --brown:        #3B2F24;   /* headings, logo text, strong elements */
  --brown-mid:    #5C4033;   /* primary buttons, active nav, AI avatar */
  --brown-light:  #8C6B55;   /* secondary labels, icons, muted actions */
  --brown-ghost:  #C4A882;   /* borders, dividers, disabled states */
  --white:        #FDFAF5;   /* cards, bubbles, modal surfaces */
  --text:         #2A1F17;   /* body text */
  --text-muted:   #7A6558;   /* placeholders, hints, timestamps */
  --danger:       #C0392B;   /* recording active, sign out, errors */
  --success:      #4A6741;   /* scores above 8, positive indicators */
  --font-serif:   Georgia, 'Lora', Palatino, 'Times New Roman', serif;
  --font-body:    'Segoe UI', Arial, Helvetica, sans-serif;
  --font-mono:    'Courier New', Courier, monospace;
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    20px;
  --shadow-sm:    0 1px 4px rgba(42,31,23,0.08);
  --shadow-md:    0 4px 16px rgba(42,31,23,0.12);
  --shadow-lg:    0 12px 40px rgba(42,31,23,0.18);
  --sidebar-w:    268px;
  --header-h:     58px;
  --input-bar-h:  80px;
}
*{box-sizing:border-box; margin:0; padding:0}
html, body { height: 100%; overflow: hidden; }
body { background: var(--cream); color: var(--text); font-family: var(--font-body); font-size: 16px; line-height: 1.6; }
::placeholder { color: var(--text-muted); }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brown-ghost); border-radius: 4px; }
a { color: var(--brown-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
select, input, textarea, button { font-family: var(--font-body); }

/* App Shell (two-column layout) */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--cream-dark);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(196,168,130,0.35);
  transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
}
#sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
}
.sidebar-top {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(196,168,130,0.3);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 150px;
  height: auto;
  display: block;
}
.auth-landing-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-main-logo {
  width: 320px;
  max-width: 100%;
  height: auto;
  display: inline-block;
}
.sidebar-new-btn-wrap {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}
.sidebar-history-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}
.history-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--brown-light);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  padding: 10px 6px 6px;
}
.history-item {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.12s;
}
.history-item:hover { background: rgba(196,168,130,0.22); }
.history-item.active { background: rgba(196,168,130,0.38); }
.history-item-title {
  font-size: 13px;
  color: var(--brown);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.history-item.active .history-item-title { font-weight: 600; }
.history-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(196,168,130,0.3);
  flex-shrink: 0;
}

/* Main Content Area */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cream);
}

/* Header Bar */
#header-bar {
  height: var(--header-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(196,168,130,0.3);
  background: var(--cream);
  flex-shrink: 0;
}
.header-session-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
}
.header-session-info:hover .session-edit-hint { opacity: 1; }
.session-field { text-align: center; }
.session-field-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.session-field-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--brown);
}
.session-divider {
  width: 1px;
  height: 26px;
  background: rgba(196,168,130,0.5);
}
.session-edit-hint {
  font-size: 11px;
  color: var(--brown-light);
  opacity: 0;
  transition: opacity 0.15s;
}
/* Inline editing state */
.session-edit-input {
  border: none;
  border-bottom: 1.5px solid var(--brown-mid);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--brown);
  text-align: center;
  outline: none;
  width: 90px;
  padding: 2px 4px;
}

/* Chat Area */
#chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Hero empty state */
.chat-hero {
  text-align: center;
  padding-top: 80px;
}
.chat-hero-title {
  font-family: var(--font-serif);
  font-size: clamp(38px, 5vw, 52px);
  font-weight: 600;
  color: var(--brown);
  letter-spacing: -1.5px;
  line-height: 1.12;
  text-transform: none;
}

/* Message rows */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.msg-row.user { justify-content: flex-end; }
.msg-row.ai   { justify-content: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid rgba(92, 64, 51, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.app-logo-mark {
  width: 24px;
  height: 24px;
  display: block;
  border-radius: 50%;
}
.msg-bubble {
  max-width: 68%;
  padding: 13px 17px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.msg-bubble.user {
  background: var(--brown-mid);
  color: var(--cream);
  border-radius: 18px 18px 4px 18px;
}
.msg-bubble.ai {
  background: var(--white);
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
}

/* Result bubble - rich content */
.result-bubble {
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  padding: 20px 22px;
  max-width: 80%;
  box-shadow: var(--shadow-sm);
}
.result-score-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.result-score-big {
  font-size: 40px;
  font-weight: 900;
  color: var(--brown);
  letter-spacing: -2px;
}
.result-score-label {
  font-size: 13px;
  color: var(--text-muted);
}
.result-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--brown-light);
  text-transform: uppercase;
  letter-spacing: 1.3px;
  margin: 14px 0 6px;
}
.result-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.result-bar-label { font-size: 13px; color: var(--text); min-width: 130px; }
.result-bar-track {
  flex: 1;
  height: 5px;
  background: var(--cream-dark);
  border-radius: 3px;
}
.result-bar-fill {
  height: 5px;
  background: var(--brown-mid);
  border-radius: 3px;
  transition: width 0.7s ease;
}
.result-bar-fill.high { background: var(--success); }
.result-bar-score { font-size: 12px; color: var(--text-muted); min-width: 30px; text-align: right; }
.result-tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.result-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--cream-dark);
  color: var(--brown);
}
.result-tag.strength { background: rgba(74,103,65,0.12); color: var(--success); }
.result-tag.improve  { background: rgba(192,57,43,0.10); color: var(--danger); }
.result-divider {
  height: 1px;
  background: var(--cream-dark);
  margin: 14px 0;
}

/* Segment feedback cards inside bubble */
.segment-card {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--brown-ghost);
  background: var(--cream);
  margin-bottom: 10px;
  font-size: 13px;
}
.segment-timestamp { font-size: 11px; color: var(--brown-light); margin-bottom: 4px; }
.segment-issue { color: var(--danger); font-weight: 600; margin-bottom: 4px; }
.segment-fix { color: var(--text); }

/* Transcript block inside bubble */
.transcript-block {
  background: var(--cream);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--cream-dark);
}

/* Thinking / loading dots */
.thinking-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 18px;
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow-sm);
}
.thinking-dots span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brown-ghost);
  animation: dotPulse 1.3s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

/* Result bubble — rich content */
.result-bubble {
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  padding: 20px 22px;
  max-width: 80%;
  box-shadow: var(--shadow-sm);
}
.result-score-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.result-score-big {
  font-size: 40px;
  font-weight: 900;
  color: var(--brown);
  letter-spacing: -2px;
}
.result-score-label {
  font-size: 13px;
  color: var(--text-muted);
}
.result-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--brown-light);
  text-transform: uppercase;
  letter-spacing: 1.3px;
  margin: 14px 0 6px;
}
.result-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.result-bar-label { font-size: 13px; color: var(--text); min-width: 130px; }
.result-bar-track {
  flex: 1;
  height: 5px;
  background: var(--cream-dark);
  border-radius: 3px;
}
.result-bar-fill {
  height: 5px;
  background: var(--brown-mid);
  border-radius: 3px;
  transition: width 0.7s ease;
}
.result-bar-fill.high { background: var(--success); }
.result-bar-score { font-size: 12px; color: var(--text-muted); min-width: 30px; text-align: right; }
.result-tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.result-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--cream-dark);
  color: var(--brown);
}
.result-tag.strength { background: rgba(74,103,65,0.12); color: var(--success); }
.result-tag.improve  { background: rgba(192,57,43,0.10); color: var(--danger); }
.result-divider {
  height: 1px;
  background: var(--cream-dark);
  margin: 14px 0;
}

/* Segment feedback cards inside bubble */
.segment-card {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--brown-ghost);
  background: var(--cream);
  margin-bottom: 10px;
  font-size: 13px;
}
.segment-timestamp { font-size: 11px; color: var(--brown-light); margin-bottom: 4px; }
.segment-issue { color: var(--danger); font-weight: 600; margin-bottom: 4px; }
.segment-fix { color: var(--text); }

/* Transcript block inside bubble */
.transcript-block {
  background: var(--cream);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--cream-dark);
}

/* Thinking / loading dots */
.thinking-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 18px;
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow-sm);
}
.thinking-dots span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brown-ghost);
  animation: dotPulse 1.3s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

/* ── Loading logo animation ── */
.loading-logo-spin {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logoPulseScale 1.1s ease-in-out infinite;
}
.loading-logo-spin svg {
  animation: logoSpin 2s linear infinite;
}
.loading-logo-spin .app-logo-mark {
  animation: logoSpin 2s linear infinite;
}
@keyframes logoSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes logoPulseScale {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.18); }
}

/* ── Analysis loading bubble ── */
.analysis-loading-bubble {
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px;
  min-width: 260px;
  max-width: 400px;
  box-shadow: var(--shadow-sm);
}
.analysis-loading-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.analysis-loading-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--brown);
}
.analysis-progress-track {
  height: 4px;
  background: var(--cream-dark);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.analysis-progress-fill {
  height: 4px;
  background: var(--brown-mid);
  border-radius: 2px;
  width: 0%;
  transition: width 0.6s ease;
}
.analysis-status-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  transition: opacity 0.3s;
}
.result-fade-in {
  animation: resultAppear 0.4s ease forwards;
}
@keyframes resultAppear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Input Bar */
#input-bar {
  padding: 12px 20px 18px;
  border-top: 1px solid rgba(196,168,130,0.3);
  background: var(--cream);
  flex-shrink: 0;
}
.input-card {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  box-shadow: 0 10px 32px -10px rgba(66,39,21,.27), 0 2px 6px rgba(66,39,21,.06);
  border: 1px solid #bda68b;
  transition: border-color .18s, box-shadow .18s;
}
.input-card:focus-within {
  border-color: #805940;
  box-shadow: 0 10px 32px -10px rgba(66,39,21,.32), 0 0 0 2px rgba(146,105,75,.15);
}
#speech-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: 16px/1.5 var(--font-body);
  color: var(--text);
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 2px 0;
}
.speech-type-select {
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: var(--cream);
  font-size: 12px;
  color: var(--text-muted);
  outline: none;
  cursor: pointer;
  font-family: var(--font-serif);
  flex-shrink: 0;
}
.recording-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--danger);
}
.recording-status.visible { display: flex; }
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}
.interim-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 5px;
  padding: 0 4px;
  min-height: 18px;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font-serif);
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary   { background: var(--brown-mid); color: var(--cream); }
.btn-primary:hover { background: var(--brown); }
.btn-secondary { background: transparent; color: var(--brown-mid); border: 1.5px solid var(--brown-mid); }
.btn-secondary:hover { background: var(--cream-dark); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: none; text-align: left; font-family: var(--font-serif); cursor: pointer; }
.btn-danger    { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover { background: rgba(192,57,43,0.06); }
.btn-full      { width: 100%; }
.btn-sm        { padding: 7px 12px; font-size: 12px; }
.btn-pill      { border-radius: 20px; padding: 6px 14px; font-size: 12px; }
/* Icon-only circle buttons */
.btn-circle {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  padding: 0;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-circle-icon { background: none; color: var(--brown-light); }
.btn-circle-icon:hover { color: var(--brown); }
.input-card .btn-circle { width:44px; height:44px; font-size:19px; }
.input-card button:enabled:active { transform:translateY(1px); }
.btn-record { background:#f0e4d4; color:var(--brown); }
.btn-record:hover { background:#e5d3bc; }
.btn-record.active {
  background: var(--danger);
  color: white;
  animation: recordPulse 1s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 8px rgba(192, 57, 43, 0); }
}
.btn-send { background: var(--cream-dark); color: var(--brown-ghost); }
.btn-send.ready { background: var(--brown-mid); color: var(--cream); }
.btn-send.ready:hover:enabled { background:var(--brown); }
.btn-send:disabled { cursor:default; }
@media (prefers-reduced-motion: reduce) {
  .btn-record.active, .rec-dot { animation:none; }
}
/* Hamburger toggle */
.btn-menu { background: none; border: none; cursor: pointer; color: var(--brown-light); font-size: 20px; padding: 4px; }
.btn-menu:hover { color: var(--brown); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: var(--font-serif);
  transition: border-color 0.18s;
}
.form-input:focus { border-color: var(--brown-mid); }

/* Overlay / Modal */
.overlay {
  position: fixed; inset: 0;
  background: rgba(42,31,23,0.42);
  backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.overlay.hidden { display: none; }
.modal-card {
  background: var(--cream);
  border-radius: var(--radius-xl);
  padding: 36px;
  width: 100%;
  max-width: 410px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.28s ease;
}
.modal-logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}
.auth-header-logo {
  width: 170px;
  height: auto;
  display: block;
}

/* In-app auth overlay choices and steps */
#auth-overlay .step-bar { display: flex; gap: 5px; margin-bottom: 22px; }
#auth-overlay .step-seg {
  flex: 1; height: 3px; border-radius: 2px;
  background: var(--cream-dark); transition: background 0.3s;
}
#auth-overlay .step-seg.done { background: var(--brown-mid); }

#auth-overlay .option-card {
  padding: 12px 16px; margin-bottom: 9px;
  border-radius: var(--radius-md); cursor: pointer;
  border: 1.5px solid var(--cream-dark);
  background: var(--white); font-size: 14px;
  color: var(--text-muted); transition: all 0.12s;
}
#auth-overlay .option-card:hover:not(.selected) { border-color: var(--brown-ghost); }
#auth-overlay .option-card.selected {
  border-color: var(--brown-mid);
  background: var(--cream-dark);
  color: var(--brown); font-weight: 600;
}

#auth-overlay .auth-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 5px;
}
#auth-overlay .auth-subtext {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}
#auth-overlay .btn-row { display: flex; gap: 10px; }
#auth-overlay .btn-row .btn { flex: 1; }
#auth-overlay .btn-primary { background: var(--brown-mid); color: var(--cream); opacity: 1; }
#auth-overlay .btn-primary:hover { background: var(--brown); }

/* Settings Drawer */
.drawer-overlay {
  position: fixed; inset: 0;
  z-index: 999;
  display: flex;
}
.drawer-overlay.hidden { display: none; }
.drawer-backdrop { flex: 1; background: rgba(42,31,23,0.28); backdrop-filter: blur(4px); }
.drawer-panel {
  width: 340px;
  background: var(--cream);
  padding: 26px 22px;
  overflow-y: auto;
  box-shadow: -14px 0 44px rgba(42,31,23,0.15);
  animation: slideFromRight 0.28s ease;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.drawer-title { font-size: 18px; font-weight: 700; color: var(--brown); }
.drawer-close {
  background: none; border: none; font-size: 22px;
  color: var(--brown-light); cursor: pointer; padding: 0;
}
.section-label {
  font-size: 10px; font-weight: 700; color: var(--brown-light);
  text-transform: uppercase; letter-spacing: 1.3px; margin-bottom: 12px;
}
.settings-section { margin-bottom: 26px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream-dark);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 14px; color: var(--text); }
.settings-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* Toggle Switch */
.toggle {
  width: 44px; height: 24px; border-radius: 12px;
  background: var(--brown-ghost); position: relative;
  cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.toggle.on { background: var(--brown-mid); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  transition: left 0.2s;
}
.toggle.on .toggle-thumb { left: 23px; }

/* Status badge */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; color: var(--text-muted);
  background: var(--cream-dark);
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brown-ghost);
}
.status-badge.ready .status-dot { background: var(--success); }
.status-badge.loading .status-dot { background: var(--brown-ghost); animation: pulse 1s infinite; }

/* Dashboard View */
#dashboard-view {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: none;
}
#dashboard-view.visible { display: block; }
.dashboard-heading {
  font-size: 24px; font-weight: 800; color: var(--brown);
  letter-spacing: -0.5px; margin-bottom: 4px;
}
.dashboard-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-number {
  font-size: 36px; font-weight: 900;
  color: var(--brown); letter-spacing: -1.5px;
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.score-breakdown { margin-bottom: 28px; }
.score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.score-row-label { font-size: 13px; color: var(--text); min-width: 140px; font-weight: 600; }
.score-track { flex: 1; height: 5px; background: var(--cream-dark); border-radius: 3px; }
.score-fill { height: 5px; background: var(--brown-mid); border-radius: 3px; transition: width 0.7s ease; }
.score-fill.high { background: var(--success); }
.score-val { font-size: 12px; color: var(--text-muted); min-width: 26px; text-align: right; }
.dashboard-section-title {
  font-size: 14px; font-weight: 700; color: var(--brown);
  margin-bottom: 14px;
}
.history-table-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--cream-dark);
  cursor: pointer; transition: background 0.1s;
}
.history-table-row:hover { background: var(--cream-dark); margin: 0 -8px; padding: 11px 8px; border-radius: 6px; }
.history-table-title { font-size: 13px; color: var(--brown); font-weight: 600; }
.history-table-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.history-table-score { font-size: 14px; font-weight: 700; color: var(--brown-mid); }

/* Keyframes */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideFromRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spinning { animation: spin 1.8s linear infinite; }

/* ── Loading logo animation ── */
.loading-logo-spin {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logoPulseScale 1.1s ease-in-out infinite;
}
.loading-logo-spin svg { animation: logoSpin 2s linear infinite; }
.loading-logo-spin .app-logo-mark { animation: logoSpin 2s linear infinite; }
@keyframes logoSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes logoPulseScale {
 0%, 100% { transform: scale(1); }
 50%       { transform: scale(1.18); }
}

/* ── Analysis loading bubble ── */
.analysis-loading-bubble {
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px;
  min-width: 260px;
  max-width: 400px;
  box-shadow: var(--shadow-sm);
}
.analysis-loading-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.analysis-loading-label { font-size: 14px; font-weight: 600; color: var(--brown); }
.analysis-progress-track { height: 4px; background: var(--cream-dark); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.analysis-progress-fill { height: 4px; background: var(--brown-mid); border-radius: 2px; width: 0%; transition: width 0.6s ease; }
.analysis-status-text { font-size: 12px; color: var(--text-muted); font-style: italic; transition: opacity 0.3s; }
.result-fade-in { animation: resultAppear 0.4s ease forwards; }
@keyframes resultAppear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Dashboard sections ── */
.dash-section { margin-bottom: 28px; }
.dash-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dash-section-label { font-size: 14px; font-weight: 700; color: var(--brown); margin-bottom: 14px; }
.dash-section-header .dash-section-label { margin-bottom: 0; }
.dash-time-filters { display: flex; gap: 6px; }
.dash-time-btn {
  padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 600;
  border: 1.5px solid var(--cream-dark); background: transparent; color: var(--text-muted);
  cursor: pointer; font-family: var(--font-serif); transition: all 0.12s;
}
.dash-time-btn:hover { border-color: var(--brown-ghost); color: var(--brown); }
.dash-time-btn.active { background: var(--brown-mid); color: var(--cream); border-color: var(--brown-mid); }
.dash-chart-wrap { background: var(--white); border-radius: var(--radius-lg); padding: 18px 16px; box-shadow: var(--shadow-sm); position: relative; }
#score-chart { display: block; width: 100%; height: 180px; }
.dash-chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-muted); background: var(--white); border-radius: var(--radius-lg); }
.dash-chart-empty.hidden { display: none; }

/* ── Dashboard summary ── */
.dash-summary-card { background: var(--white); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.dash-summary-overall { font-size: 13px; font-weight: 700; color: var(--brown-mid); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.8px; }
.dash-summary-text { font-size: 14px; color: var(--text); line-height: 1.7; }

/* ── Dashboard exercises ── */
.dash-exercises-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding-bottom: 14px; }
.exercise-card {
  min-width: 0; background: var(--white); border-radius: var(--radius-lg);
  padding: 18px 16px; box-shadow: var(--shadow-sm); border: 1.5px solid var(--cream-dark);
  display: flex; flex-direction: column; gap: 8px; transition: transform 0.15s, box-shadow 0.15s; cursor: default;
}
.exercise-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.exercise-card-name { font:600 21px/1.25 'Lora', Georgia, serif; color:var(--brown); }
.exercise-card-desc { font-size:15px; color:var(--text-muted); line-height:1.55; flex:1; }
.drill-topic-picker { margin:0 0 16px; }
.drill-topic-picker summary { width:fit-content; max-width:100%; color:var(--brown-mid); cursor:pointer; overflow-wrap:anywhere; }
.drill-topic-picker form { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-top:10px; }
.drill-topic-picker input { width:min(25ch,100%); min-height:44px; border:1px solid var(--brown-ghost); border-radius:6px; padding:7px 10px; }
.exercise-card-tag {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
  background: var(--cream-dark); color: var(--brown-light); align-self: flex-start;
}
.exercise-card-tag.delivery { background: rgba(92,64,51,0.1); color: var(--brown-mid); }
.exercise-card-tag.argumentation { background: rgba(74,103,65,0.1); color: var(--success); }
.exercise-card-tag.language { background: rgba(196,168,130,0.3); color: var(--brown); }
.dash-exercises-empty.hidden { display: none; }

.plans-modal { width: min(860px, calc(100vw - 28px)); max-width: 860px; max-height: 90vh; overflow-y: auto; }
.checkout-modal { width: min(620px, calc(100vw - 28px)); max-height: 90vh; overflow-y: auto; }
.plans-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.plans-head h2 { margin: 0; color: var(--brown); }
.plans-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.plan-card { border: 1px solid var(--cream-dark); border-radius: var(--radius-lg); padding: 18px; text-align: left; background: var(--white); }
.plan-card.featured { border: 2px solid var(--brown-mid); }
.plan-card h3 { margin: 0 0 8px; color: var(--brown); }
.plan-card p { font-size: 13px; line-height: 1.45; }
.plan-card .plan-price { font-size: 28px; font-weight: 700; color: var(--brown); margin: 0 0 12px; }
.plan-price span { font-size: 12px; font-weight: 400; }
.plan-card .plan-buy { margin-top: 14px; }
.drill-modal { width: min(560px, calc(100vw - 28px)); max-height: 90vh; overflow-y: auto; }
#drill-overlay .drill-modal { display:flex; flex-direction:column; overflow:hidden; }
.drill-modal > .plans-head, .drill-modal > .drill-progress-label, .drill-modal > .drill-progress-track, .drill-controls { flex:none; }
.drill-modal .plans-head button { min-width:44px; min-height:44px; }
.drill-body { min-height:0; overflow-y:auto; overscroll-behavior:contain; padding-right:6px; }
.drill-controls { border-top:1px solid var(--cream-deeper); padding-top:10px; margin-top:12px; }
.drill-controls .practice-actions { margin-top:0; }
.drill-controls > p { font-size:13px; line-height:1.5; margin:8px 0 0; }
.drill-controls .btn { min-height:44px; }
.drill-blurb { background: var(--cream); border-left: 3px solid var(--brown-mid); border-radius: 8px; padding: 16px; line-height: 1.7; }
#drill-reference summary { cursor: pointer; color: var(--brown); font-weight: 600; }
.drill-question { font:600 21px/1.45 Georgia,serif; color:var(--brown); margin:16px 0; }
.drill-brand { display:grid; place-items:center; min-height:150px; padding:20px; border-radius:12px; background:var(--cream); }
.drill-brand img { display:block; width:130px; height:130px; object-fit:contain; }
.drill-next { margin-top:16px; white-space:normal; }
.practice-complete { text-align:center; width:min(420px,calc(100vw - 28px)); isolation:isolate; }
.practice-complete-mark { display:grid; place-items:center; width:76px; height:76px; margin:0 auto 20px; border-radius:50%; background:var(--cream-dark); color:var(--success); font-size:42px; animation:practiceFinish .65s ease-out both; }
.practice-complete-animation { display:block; width:min(100%,280px); aspect-ratio:1; object-fit:contain; max-height:45vh; margin:0 auto 20px; mix-blend-mode:multiply; }
@keyframes practiceFinish { from { opacity:0; transform:scale(.6); } 65% { opacity:1; transform:scale(1.12); } to { opacity:1; transform:scale(1); } }
@media(prefers-reduced-motion:reduce) { .practice-complete-mark { animation:none; } }
.drill-timer { margin: 10px 0; color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.recording-feedback { display: grid; gap: 14px; margin-top: 18px; }
.recording-feedback-card { padding: 16px; border: 1px solid var(--cream-deeper); border-radius: 12px; background: var(--white); min-width: 0; overflow-wrap: anywhere; }
.recording-feedback-card h3, .recording-feedback-card h4 { color: var(--brown); font-family: Georgia, serif; line-height: 1.3; margin: 0 0 12px; }
.recording-feedback-card p { margin: 8px 0; line-height: 1.55; }
.recording-feedback-card ul { padding-left:20px; margin:10px 0; }
.recording-feedback-card li { line-height:1.55; margin:8px 0; }
.recording-feedback-score { color: var(--brown); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.recording-feedback-facts { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 12px 0; }
.recording-feedback-facts dt { font-size: 12px; color: var(--text-muted); }
.recording-feedback-facts dd { margin: 3px 0 0; font-weight: 600; font-size: 15px; }
.recording-feedback-card details { margin-top: 12px; font-size: 13px; }
.recording-feedback-card summary { cursor: pointer; color: var(--brown); }
.question-delivery { margin: 16px 0; background: var(--cream); }
.drill-progress-label { margin-top: 16px; font-weight: 700; color: var(--brown); }
.drill-progress-track { height: 12px; background: var(--cream-dark); border-radius: 99px; overflow: hidden; margin: 8px 0 16px; }
.drill-progress-fill { height: 100%; width: 0; border-radius: inherit; background: var(--success); transition: width .6s ease; }
.drill-progress-fill.complete { animation: drillCelebrate .55s ease-in-out 2; }
@keyframes drillCelebrate { 50% { filter: brightness(1.35); transform: scaleY(1.25); } }
.exercise-card { cursor: pointer; }
.exercise-card button { align-self: flex-start; margin-top: 4px; }
.exercise-progress { height: 7px; background: var(--cream-dark); border-radius: 99px; overflow: hidden; }
.exercise-progress-fill { height: 100%; background: var(--success); transition: width .6s ease; }
#stat-best-skill { font-size: clamp(18px, 2vw, 28px); line-height: 1.2; overflow-wrap: anywhere; }
.dashboard-recent-session { display: block; width: 100%; margin: 8px 0; text-align: left; }
@media (max-width: 700px) { .plans-grid, .dash-exercises-row { grid-template-columns: 1fr; } .dash-section-header { align-items: flex-start; flex-direction: column; } .dash-time-filters { flex-wrap: wrap; } }
@media (prefers-reduced-motion: reduce) { .drill-progress-fill, .exercise-progress-fill { transition: none; animation: none; } }

/* Legacy styles (to be migrated) */
.container{max-width:960px;margin:0 auto}
header{display:flex;flex-direction:column;gap:4px;margin-bottom:12px}
h1{margin:0;font-size:28px}
.tag{color:var(--muted)}
.panel{background:#fff;padding:16px;border-radius:10px;box-shadow:0 6px 18px rgba(107,76,59,0.06);margin-bottom:16px}
.row{display:flex;flex-direction:column;margin-bottom:10px}
.row label{font-size:13px;color:var(--muted);margin-bottom:6px}
.row input, .row select{padding:10px;border-radius:8px;border:1px solid #efe0d6}
.actions{display:flex;gap:8px;flex-wrap:wrap}
button{background:var(--coffee);color:var(--cream);border:none;padding:10px 14px;border-radius:8px;cursor:pointer}
button.secondary{background:transparent;color:var(--coffee);border:1px solid var(--accent)}
#onboard_status{margin-top:6px}
.setup-modal{
  position:fixed;
  inset:0;
  background:rgba(50,34,24,0.48);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:1000;
  padding:20px;
}
.setup-modal-card{
  width:min(560px, 95vw);
  background:#fff;
  border-radius:14px;
  box-shadow:0 16px 40px rgba(40,20,10,0.2);
  padding:18px;
}
.setup-modal-card h2{margin:0 0 6px 0}
.results h2{margin-top:0}
#transcript{white-space:pre-wrap;background:#fff7f2;padding:12px;border-radius:8px;margin:10px 0}
.segment{border-left:4px solid var(--accent);padding:8px;margin:8px 0;background:#fffaf6}
.small{font-size:13px;color:var(--muted)}
.analysis-card{background:#fffaf6;border-left:4px solid var(--coffee);padding:10px;margin:10px 0;border-radius:8px}
.analysis-card h3{margin:0 0 6px 0;font-size:15px}
.history-list{display:flex;flex-direction:column;gap:8px}
.history-item{border:1px solid #efe0d6;border-radius:8px;background:#fffaf6;padding:8px;cursor:pointer}
.history-item:hover{background:#fff2e8}
.history-item .title{font-weight:600}
.live-transcript{
  margin-top:8px;
  padding:10px;
  border-radius:8px;
  border:1px solid #efe0d6;
  background:#fffaf6;
  white-space:pre-wrap;
  min-height:46px;
}
/* Metrics panel */
.metrics{display:flex;gap:12px;flex-wrap:wrap;margin:10px 0}
.metric-card{background:#fff;padding:10px;border-radius:8px;box-shadow:0 4px 10px rgba(107,76,59,0.04);min-width:160px}
.metric-card h3{margin:0;font-size:14px;color:var(--coffee)}
.drill{background:linear-gradient(90deg, rgba(214,184,154,0.12), rgba(214,184,154,0.04));padding:8px;border-radius:6px;margin:6px 0}
footer{margin-top:10px;color:var(--muted)}

/* ═══════════════════════════════════════════════════════════
   ANALYSIS LOADING CARD — outer container
═══════════════════════════════════════════════════════════ */

#analysis-loading-card {
  animation: loadCardEnter 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}
#analysis-loading-card.exiting {
  animation: loadCardExit 0.4s ease forwards;
}

@keyframes loadCardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes loadCardExit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}


/* ═══════════════════════════════════════════════════════════
   AVATAR / LOGO — spinning + pulsing + glowing halo
═══════════════════════════════════════════════════════════ */

/* The outer .msg-avatar circle gets a pulsing glow ring */
#analysis-loading-card .msg-avatar {
  position: relative;
  animation: avatarPulse 1.4s ease-in-out infinite;
}

/* The glow ring — a pseudo-element that expands and fades */
#analysis-loading-card .msg-avatar::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(92, 64, 51, 0.35);
  animation: glowRing 1.4s ease-in-out infinite;
}

/* Second outer ring — slightly delayed, larger */
#analysis-loading-card .msg-avatar::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(92, 64, 51, 0.15);
  animation: glowRing 1.4s ease-in-out infinite 0.3s;
}

@keyframes avatarPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}

@keyframes glowRing {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* The SVG logo INSIDE the avatar — spins on its own */
#analysis-loading-card .msg-avatar svg,
#analysis-loading-card .msg-avatar .app-logo-mark {
  animation: logoSpin 2.2s linear infinite;
  display: block;
}

/* Brief flash when a checkpoint stage is hit */
#analysis-loading-card .msg-avatar.flash {
  animation: avatarFlash 0.4s ease forwards,
             avatarPulse 1.4s ease-in-out infinite 0.4s;
}
@keyframes avatarFlash {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(2.2) saturate(0.5); }
  100% { filter: brightness(1); }
}

@keyframes logoSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* ═══════════════════════════════════════════════════════════
   LOADING BUBBLE — the card next to the avatar
═══════════════════════════════════════════════════════════ */

.analysis-loading-bubble {
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px 18px;
  min-width: 280px;
  max-width: 420px;
  box-shadow:
    0 1px 4px rgba(42, 31, 23, 0.08),
    0 4px 20px rgba(42, 31, 23, 0.06);
  position: relative;
  overflow: hidden;
}

/* Subtle shimmer sweep across the whole card while loading */
.analysis-loading-bubble::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; bottom: 0;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 100%
  );
  animation: cardShimmer 2.4s ease-in-out infinite;
}

@keyframes cardShimmer {
  0%   { left: -100%; }
  100% { left: 150%; }
}


/* ═══════════════════════════════════════════════════════════
   LABEL ROW — "Analyzing your speech…" with animated dots
═══════════════════════════════════════════════════════════ */

.analysis-loading-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}

.analysis-loading-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--brown);
  letter-spacing: -0.2px;
}

/* The animated ellipsis — three dots that light up one by one */
.analysis-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  margin-left: 1px;
  position: relative;
  top: 1px;
}
.analysis-dots span {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brown-ghost);
  animation: dotLight 1.5s ease-in-out infinite;
}
.analysis-dots span:nth-child(1) { animation-delay: 0s; }
.analysis-dots span:nth-child(2) { animation-delay: 0.2s; }
.analysis-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotLight {
  0%, 60%, 100% {
    background: var(--brown-ghost);
    transform: scale(1);
  }
  30% {
    background: var(--brown-mid);
    transform: scale(1.4);
  }
}


/* ═══════════════════════════════════════════════════════════
   PROGRESS BAR — shimmer + color shift + bounce
═══════════════════════════════════════════════════════════ */

.analysis-progress-track {
  height: 5px;
  background: var(--cream-dark);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
  /* Inner shadow to give it depth */
  box-shadow: inset 0 1px 2px rgba(42, 31, 23, 0.12);
  position: relative;
}

.analysis-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  /* Transition with a slight overshoot (cubic-bezier bounce) */
  transition: width 0.65s cubic-bezier(0.34, 1.3, 0.64, 1);
  /* Base color — warm brown */
  background: var(--brown-mid);
}

/* The sweeping shimmer on the fill */
.analysis-progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -80%; bottom: 0;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  animation: progressShimmer 1.4s ease-in-out infinite;
}

@keyframes progressShimmer {
  0%   { left: -80%; }
  100% { left: 120%; }
}

/* Color shift as progress increases — driven by JS adding data-pct class */
.analysis-progress-fill[data-pct="low"] {
  background: linear-gradient(90deg, #5C4033, #6B4F3E);
}
.analysis-progress-fill[data-pct="mid"] {
  background: linear-gradient(90deg, #5C4033, #7A5C42);
}
.analysis-progress-fill[data-pct="high"] {
  background: linear-gradient(90deg, #5C4033 0%, #8C6B45 60%, #A07840 100%);
}
.analysis-progress-fill[data-pct="done"] {
  background: linear-gradient(90deg, #4A6741, #6B9462);
  transition: width 0.4s ease, background 0.5s ease;
}


/* ═══════════════════════════════════════════════════════════
   STATUS TEXT — fade-swap animation between stages
═══════════════════════════════════════════════════════════ */

.analysis-status-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  min-height: 17px;
  position: relative;
  /* Transition handled by JS swapping .status-out / .status-in classes */
}

.analysis-status-text.status-out {
  animation: statusOut 0.22s ease forwards;
}
.analysis-status-text.status-in {
  animation: statusIn 0.28s ease forwards;
}

@keyframes statusOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-7px); }
}
@keyframes statusIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ═══════════════════════════════════════════════════════════
   RESULT BUBBLE — how the final result fades in
═══════════════════════════════════════════════════════════ */

.result-fade-in {
  animation: resultAppear 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

/* Account pages and narrow-screen access */
#auth-overlay { padding: 12px; }
#auth-overlay .modal-card,
#onboarding-overlay .modal-card,
#auth-card {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(16px, 4vw, 36px);
}
.auth-text-button,
.auth-inline-button {
  display: inline-block;
  background: none;
  border: 0;
  color: var(--brown-mid);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px;
}
.auth-text-button { display: block; margin: 12px auto 0; }
.policy-links { margin: 2px 0 16px; font-size: 13px; }
.policy-links a { text-decoration: underline; text-underline-offset: 3px; }
.form-checkbox-row { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; }
.form-checkbox-row input { flex: none; margin-top: 4px; }
.sample-example {
  max-height: min(44dvh, 310px);
  overflow-y: auto;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: 13px;
  line-height: 1.55;
}
.sample-example p { margin: 8px 0 14px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--brown-light);
  outline-offset: 2px;
}
@media (max-width: 480px), (max-height: 380px) {
  #auth-overlay { align-items: flex-start; overflow-y: auto; }
  #auth-overlay .modal-card { margin: auto 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@keyframes resultAppear {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Signup welcome coach: compact, keyboard-safe and visually tied to the app palette. */
.auth-coach-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  margin: 0 0 18px;
  padding: 8px 13px;
  overflow: hidden;
  border: 1px solid rgba(196,168,130,.48);
  border-radius: var(--radius-lg);
  background: linear-gradient(110deg, rgba(253,250,245,.96), rgba(237,228,211,.56));
  box-shadow: var(--shadow-sm);
}
.auth-gavel-motion {
  display: grid;
  flex: 0 0 72px;
  width: 72px;
  height: 48px;
  place-items: center;
  transform-origin: 55% 70%;
  animation: gavel-arrive 980ms cubic-bezier(.22,.72,.24,1) both;
}
.auth-gavel-motion img { display: block; width: 100%; height: 100%; object-fit: contain; }
.auth-coach-copy { display: grid; gap: 1px; min-width: 0; line-height: 1.4; }
.auth-coach-copy strong { color: var(--brown); font-family: var(--font-serif); font-size: 14px; }
.auth-coach-copy > span { color: var(--text-muted); font-size: 12px; }
.auth-coach-widget[data-mood="attentive"] .auth-gavel-motion { animation: gavel-listen 260ms cubic-bezier(.2,.8,.2,1) both; }
.auth-coach-widget[data-mood="thinking"] .auth-gavel-motion { animation: gavel-think 700ms cubic-bezier(.2,.75,.22,1) both; }
.auth-coach-widget[data-mood="ready"] .auth-gavel-motion { animation: gavel-encourage 480ms cubic-bezier(.2,.75,.22,1) both; }
@keyframes gavel-arrive {
  0% { opacity: .55; transform: translate(-18px, 5px) rotate(-13deg); }
  52% { opacity: 1; transform: translate(8px, -5px) rotate(7deg); }
  100% { transform: translate(0) rotate(0); }
}
@keyframes gavel-listen { from { transform: rotate(-7deg); } to { transform: rotate(0); } }
@keyframes gavel-think { 0% { transform: translateY(-5px) rotate(-9deg); } 52%, 70% { transform: translateY(3px) rotate(8deg); } 100% { transform: translateY(0) rotate(0); } }
@keyframes gavel-encourage { 0% { transform: translateY(0) rotate(0); } 58% { transform: translateY(-5px) rotate(4deg); } 100% { transform: translateY(0) rotate(0); } }

.speech-report-row.result-fade-in { animation: resultAppear 380ms cubic-bezier(.2,.75,.22,1) both; }

@media (max-width: 480px) {
  .auth-coach-widget { gap: 9px; min-height: 62px; padding: 7px 10px; }
  .auth-gavel-motion { flex-basis: 62px; width: 62px; height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-gavel-motion,
  .auth-coach-widget[data-mood="attentive"] .auth-gavel-motion,
  .auth-coach-widget[data-mood="thinking"] .auth-gavel-motion,
  .auth-coach-widget[data-mood="ready"] .auth-gavel-motion,
  .speech-report-row.result-fade-in { animation: none !important; transform: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   ANALYSIS LOADING CARD — outer container
═══════════════════════════════════════════════════════════ */

#analysis-loading-card {
  animation: loadCardEnter 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}
#analysis-loading-card.exiting {
  animation: loadCardExit 0.4s ease forwards;
}

@keyframes loadCardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes loadCardExit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}


/* ═══════════════════════════════════════════════════════════
   AVATAR / LOGO — spinning + pulsing + glowing halo
═══════════════════════════════════════════════════════════ */

/* The outer .msg-avatar circle gets a pulsing glow ring */
#analysis-loading-card .msg-avatar {
  position: relative;
  animation: avatarPulse 1.4s ease-in-out infinite;
}

/* The glow ring — a pseudo-element that expands and fades */
#analysis-loading-card .msg-avatar::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(92, 64, 51, 0.35);
  animation: glowRing 1.4s ease-in-out infinite;
}

/* Second outer ring — slightly delayed, larger */
#analysis-loading-card .msg-avatar::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(92, 64, 51, 0.15);
  animation: glowRing 1.4s ease-in-out infinite 0.3s;
}

@keyframes avatarPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}

@keyframes glowRing {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* The SVG logo INSIDE the avatar — spins on its own */
#analysis-loading-card .msg-avatar svg,
#analysis-loading-card .msg-avatar .app-logo-mark {
  animation: logoSpin 2.2s linear infinite;
  display: block;
}

/* Brief flash when a checkpoint stage is hit */
#analysis-loading-card .msg-avatar.flash {
  animation: avatarFlash 0.4s ease forwards,
             avatarPulse 1.4s ease-in-out infinite 0.4s;
}
@keyframes avatarFlash {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(2.2) saturate(0.5); }
  100% { filter: brightness(1); }
}

@keyframes logoSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* ═══════════════════════════════════════════════════════════
   LOADING BUBBLE — the card next to the avatar
═══════════════════════════════════════════════════════════ */

.analysis-loading-bubble {
  background: var(--white);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px 18px;
  min-width: 280px;
  max-width: 420px;
  box-shadow:
    0 1px 4px rgba(42, 31, 23, 0.08),
    0 4px 20px rgba(42, 31, 23, 0.06);
  position: relative;
  overflow: hidden;
}

/* Subtle shimmer sweep across the whole card while loading */
.analysis-loading-bubble::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; bottom: 0;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 100%
  );
  animation: cardShimmer 2.4s ease-in-out infinite;
}

@keyframes cardShimmer {
  0%   { left: -100%; }
  100% { left: 150%; }
}


/* ═══════════════════════════════════════════════════════════
   LABEL ROW — "Analyzing your speech…" with animated dots
═══════════════════════════════════════════════════════════ */

.analysis-loading-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}

.analysis-loading-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--brown);
  letter-spacing: -0.2px;
}

/* The animated ellipsis — three dots that light up one by one */
.analysis-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  margin-left: 1px;
  position: relative;
  top: 1px;
}
.analysis-dots span {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brown-ghost);
  animation: dotLight 1.5s ease-in-out infinite;
}
.analysis-dots span:nth-child(1) { animation-delay: 0s; }
.analysis-dots span:nth-child(2) { animation-delay: 0.2s; }
.analysis-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotLight {
  0%, 60%, 100% {
    background: var(--brown-ghost);
    transform: scale(1);
  }
  30% {
    background: var(--brown-mid);
    transform: scale(1.4);
  }
}


/* ═══════════════════════════════════════════════════════════
   PROGRESS BAR — shimmer + color shift + bounce
═══════════════════════════════════════════════════════════ */

.analysis-progress-track {
  height: 5px;
  background: var(--cream-dark);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
  /* Inner shadow to give it depth */
  box-shadow: inset 0 1px 2px rgba(42, 31, 23, 0.12);
  position: relative;
}

.analysis-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  /* Transition with a slight overshoot (cubic-bezier bounce) */
  transition: width 0.65s cubic-bezier(0.34, 1.3, 0.64, 1);
  /* Base color — warm brown */
  background: var(--brown-mid);
}

/* The sweeping shimmer on the fill */
.analysis-progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -80%; bottom: 0;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  animation: progressShimmer 1.4s ease-in-out infinite;
}

@keyframes progressShimmer {
  0%   { left: -80%; }
  100% { left: 120%; }
}

/* Color shift as progress increases — driven by JS adding data-pct class */
.analysis-progress-fill[data-pct="low"] {
  background: linear-gradient(90deg, #5C4033, #6B4F3E);
}
.analysis-progress-fill[data-pct="mid"] {
  background: linear-gradient(90deg, #5C4033, #7A5C42);
}
.analysis-progress-fill[data-pct="high"] {
  background: linear-gradient(90deg, #5C4033 0%, #8C6B45 60%, #A07840 100%);
}
.analysis-progress-fill[data-pct="done"] {
  background: linear-gradient(90deg, #4A6741, #6B9462);
  transition: width 0.4s ease, background 0.5s ease;
}


/* ═══════════════════════════════════════════════════════════
   STATUS TEXT — fade-swap animation between stages
═══════════════════════════════════════════════════════════ */

.analysis-status-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  min-height: 17px;
  position: relative;
  /* Transition handled by JS swapping .status-out / .status-in classes */
}

.analysis-status-text.status-out {
  animation: statusOut 0.22s ease forwards;
}
.analysis-status-text.status-in {
  animation: statusIn 0.28s ease forwards;
}

@keyframes statusOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-7px); }
}
@keyframes statusIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ═══════════════════════════════════════════════════════════
   RESULT BUBBLE — how the final result fades in
═══════════════════════════════════════════════════════════ */

.result-fade-in {
  animation: resultAppear 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}
@keyframes resultAppear {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Warm scan stays inside the live request card and behind its readable status. */
.analysis-loading-bubble { border: 1px solid rgba(196,168,130,.28); }
.analysis-loading-bubble::before {
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 42%;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent, rgba(196,168,130,.22), rgba(237,228,211,.32), transparent);
  animation: analysisWarmSweep 3.2s cubic-bezier(.4,0,.2,1) infinite;
}
.analysis-loading-bubble > * { position: relative; z-index: 1; }
@keyframes analysisWarmSweep {
  from { transform: translateX(-135%) skewX(-14deg); }
  to { transform: translateX(330%) skewX(-14deg); }
}
@media (prefers-reduced-motion: reduce) {
  .analysis-loading-bubble::before { animation: none !important; opacity: .14; transform: none; }
}
