/* ─────────────────────────────────────────────────────────────
   Clara — French Language Tutor
   Design: Refined French Intimacy
   Dark ink-blue, warm amber accent, elegant typography
───────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=DM+Sans:wght@300;400;500&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  --bg-base:        #0d1117;
  --bg-surface:     #141b24;
  --bg-raised:      #1c2733;
  --bg-input:       #1c2733;

  --amber:          #d4a853;
  --amber-dim:      #a07a36;
  --amber-glow:     rgba(212, 168, 83, 0.12);

  --text-primary:   #e8e0d4;
  --text-secondary: #8a9aaa;
  --text-muted:     #4a5a6a;

  --clara-bubble:   #1c2733;
  --student-bubble: #1a2840;
  --student-border: rgba(212, 168, 83, 0.25);

  --border:         rgba(255,255,255,0.07);
  --border-focus:   rgba(212, 168, 83, 0.5);

  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      18px;
  --radius-xl:      24px;

  --font-display:   'Cormorant Garamond', Georgia, serif;
  --font-body:      'DM Sans', -apple-system, sans-serif;

  --transition:     0.2s ease;
  --shadow-glow:    0 0 40px rgba(212, 168, 83, 0.08);
}

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

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  line-height: 1.6;
}

/* ── Loading Overlay ────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.875rem;
  color: var(--text-primary);
  z-index: 150;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: fadeUp 0.3s ease both;
}

.toast.hidden {
  display: none;
}

/* ── Screen Management ──────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* ─────────────────────────────────────────────────────────────
   LOGIN SCREEN
───────────────────────────────────────────────────────────── */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-base);
}

/* Subtle background texture */
#login-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(212,168,83,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 100%, rgba(30,60,90,0.4) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  animation: fadeUp 0.6s ease both;
}

/* ── Login Wrapper (two-column: media + form) ───────────── */
.login-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Media Container ────────────────────────────────────── */
.media-container {
  position: relative;
  width: 100%;
  flex: 1;
  overflow: hidden;
  background: var(--bg-surface);
  min-height: 220px;
  max-height: 340px;
}

.media-content {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-content.hidden {
  display: none !important;
}

/* Gradient overlay — blends media into the dark form below */
.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(13,17,23,0) 0%,
    rgba(13,17,23,0.3) 60%,
    rgba(13,17,23,0.95) 100%
  );
  pointer-events: none;
}

/* ── Login Panel ────────────────────────────────────────── */
.login-panel {
  flex-shrink: 0;
  width: 100%;
  padding: 24px 24px 40px;
  background: var(--bg-base);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* On wider screens: side-by-side layout */
@media (min-width: 768px) {
  .login-wrapper {
    flex-direction: row;
  }

  .media-container {
    flex: 1;
    max-height: none;
    min-height: 100%;
  }

  .media-overlay {
    background: linear-gradient(
      to right,
      rgba(13,17,23,0) 0%,
      rgba(13,17,23,0.2) 70%,
      rgba(13,17,23,0.98) 100%
    );
  }

  .login-panel {
    flex-shrink: 0;
    width: 420px;
    padding: 0 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
  }

  #login-screen::before {
    display: none;
  }
}

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

/* ── Login Header ───────────────────────────────────────── */
.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--bg-raised), var(--bg-surface));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.login-logo svg {
  width: 28px;
  height: 28px;
  color: var(--amber);
}

.login-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  line-height: 1;
}

.login-title span {
  color: var(--amber);
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.04em;
}

/* ── Login Form ─────────────────────────────────────────── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 300;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

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

.field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.08);
}

/* ── Login Button ───────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 15px 24px;
  background: linear-gradient(135deg, var(--amber), var(--amber-dim));
  border: none;
  border-radius: var(--radius-md);
  color: #0d1117;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 4px;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

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

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Secondary Button ──────────────────────────────────── */
.btn-secondary {
  width: 100%;
  padding: 13px 24px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-secondary:hover {
  border-color: rgba(255,255,255,0.18);
  color: var(--text-primary);
}

/* ── Error Message ──────────────────────────────────────── */
.error-msg {
  padding: 12px 16px;
  background: rgba(220, 80, 80, 0.1);
  border: 1px solid rgba(220, 80, 80, 0.2);
  border-radius: var(--radius-sm);
  color: #e07070;
  font-size: 0.875rem;
  text-align: center;
  display: none;
}

.error-msg.visible {
  display: block;
  animation: fadeUp 0.3s ease both;
}

/* ── Login Footer ───────────────────────────────────────── */
.login-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────────
   CONVERSATION SCREEN
───────────────────────────────────────────────────────────── */
#conversation-screen {
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
}

/* ── Top Bar ────────────────────────────────────────────── */
.top-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.top-bar-brand .brand-name span {
  color: var(--amber);
}

/* ── Status Indicator ───────────────────────────────────── */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
  flex-shrink: 0;
}

.status-dot.connected {
  background: #4caf7d;
  box-shadow: 0 0 6px rgba(76, 175, 125, 0.5);
  animation: pulse-green 2.5s ease-in-out infinite;
}

.status-dot.connecting {
  background: var(--amber);
  animation: pulse-amber 1s ease-in-out infinite;
}

.status-dot.error {
  background: #e07070;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes pulse-amber {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.8); }
}

/* ── End Session Button ─────────────────────────────────── */
.btn-end-session {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-end-session:hover {
  border-color: rgba(220, 80, 80, 0.4);
  color: #e07070;
}

/* ── Messages Area ──────────────────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.messages-area::-webkit-scrollbar {
  width: 4px;
}

.messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
  background: var(--bg-raised);
  border-radius: 2px;
}

/* ── Message Bubbles ────────────────────────────────────── */
.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: messageIn 0.3s ease both;
}

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

.message.clara {
  align-self: flex-start;
}

.message.student {
  align-self: flex-end;
}

.message-sender {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
  padding: 0 4px;
}

.message.clara .message-sender {
  color: var(--amber-dim);
}

.message.student .message-sender {
  color: var(--text-muted);
  text-align: right;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.65;
  word-break: break-word;
}

.message.clara .message-bubble {
  background: var(--clara-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
  color: var(--text-primary);
}

.message.student .message-bubble {
  background: var(--student-bubble);
  border: 1px solid var(--student-border);
  border-bottom-right-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* ── Typing Indicator ───────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: flex-start;
  gap: 0;
  max-width: 82%;
  align-self: flex-start;
  animation: messageIn 0.3s ease both;
}

.typing-bubble {
  background: var(--clara-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-dot 1.4s ease-in-out infinite;
}

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

@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}

.typing-indicator.hidden {
  display: none;
}

/* ── Welcome State ──────────────────────────────────────── */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}

.welcome-state .welcome-icon {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 300;
  color: var(--amber);
  opacity: 0.4;
  letter-spacing: 0.1em;
}

.welcome-state p {
  font-size: 0.875rem;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.welcome-state.hidden {
  display: none;
}

/* ── Input Area ─────────────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  padding: 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 720px;
  margin: 0 auto;
}

.message-input {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  padding: 13px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.5;
  resize: none;
  outline: none;
  overflow-y: auto;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

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

.message-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.06);
}

.message-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Send Button ────────────────────────────────────────── */
.btn-send {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--amber), var(--amber-dim));
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-send:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

.btn-send:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-send svg {
  width: 18px;
  height: 18px;
  color: #0d1117;
  transform: translateX(1px);
}

/* ── Session Ended State ────────────────────────────────── */
.session-ended-bar {
  text-align: center;
  padding: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary); /* lifted from --text-muted — legible on dark bg */
  letter-spacing: 0.04em;
  display: none;
}

.session-ended-bar.visible {
  display: block;
}

/* Link inherits browser default blue without this rule — unreadable on dark
   background. Explicitly styled amber to match the UI accent colour and
   ensure legibility. Underline removed; opacity hover matches other
   interactive text elements in the UI. */
.session-ended-bar a {
  color: var(--amber);
  text-decoration: none;
}

.session-ended-bar a:hover {
  color: var(--amber-dim);
}

/* ── Confirm Dialog ─────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dialog-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

.dialog-overlay.visible .dialog {
  transform: scale(1);
}

.dialog h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--text-primary);
}

.dialog p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 300;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.btn-cancel {
  flex: 1;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color var(--transition);
}

.btn-cancel:hover {
  border-color: rgba(255,255,255,0.15);
}

.btn-confirm-end {
  flex: 1;
  padding: 11px;
  background: rgba(220, 80, 80, 0.15);
  border: 1px solid rgba(220, 80, 80, 0.3);
  border-radius: var(--radius-md);
  color: #e07070;
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-confirm-end:hover {
  background: rgba(220, 80, 80, 0.25);
}

/* ── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────── */
@media (min-width: 600px) {
  .messages-area {
    padding: 32px 24px;
  }

  .message {
    max-width: 70%;
  }

  .input-area {
    padding: 20px 24px;
  }

  .message-bubble {
    font-size: 1rem;
  }
}

@media (min-width: 960px) {
  .messages-area {
    padding: 40px;
  }

  .message {
    max-width: 60%;
  }
}


/* ─────────────────────────────────────────────────────────────
   REGISTRATION SCREEN ADDITIONS
───────────────────────────────────────────────────────────── */

/* Two-column field row (First Name / Last Name) */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Optional field label suffix */
.field-optional {
  font-weight: 300;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Register screen media — reuses the video as a CSS background
   so we don't need a second video element */
.register-media {
  background-image: url('../media/clara-bg.jpg');
  background-size: cover;
  background-position: center;
}

/* On mobile, register form needs scroll since it's taller */
#register-screen .login-panel {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#register-screen .login-card {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Tighten vertical spacing on register form so it fits better */
#register-screen .login-form {
  gap: 12px;
}

#register-screen .login-header {
  gap: 10px;
}

#register-screen .login-title {
  font-size: 2.4rem;
}

/* ── Select field — matches input styling ───────────────── */
.field select {
  width: 100%;
  padding: 14px 40px 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 300;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  /* Custom amber chevron arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d4a853' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.field select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.08);
}

/* Style the dropdown options (limited browser support, best effort) */
.field select option {
  background: var(--bg-raised);
  color: var(--text-primary);
}


/* ─────────────────────────────────────────────────────────────
   PHASE 10d — VOICE MODE
   Mic area, mic button states, Clara speaking indicator,
   waveform animation.
───────────────────────────────────────────────────────────── */

/* ── Mic Area (replaces .input-area) ────────────────────── */
.mic-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 24px 28px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

/* ── Mic Button ──────────────────────────────────────────── */
.mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background var(--transition), box-shadow var(--transition),
              transform 0.15s ease;
}

.mic-btn svg {
  width: 28px;
  height: 28px;
}

/* off / connecting */
.mic-btn.mic-off,
.mic-btn.mic-connecting {
  background: var(--bg-raised);
  color: var(--text-muted);
}

.mic-btn.mic-connecting {
  animation: pulse-amber 1s ease-in-out infinite;
}

/* listening — open, waiting for student to speak */
.mic-btn.mic-listening {
  background: var(--bg-raised);
  border: 1.5px solid rgba(212, 168, 83, 0.3);
  color: var(--amber-dim);
}

/* speaking — student is talking */
.mic-btn.mic-speaking {
  background: linear-gradient(135deg, var(--amber), var(--amber-dim));
  color: #0d1117;
  box-shadow: 0 0 0 8px  rgba(212, 168, 83, 0.15),
              0 0 0 16px rgba(212, 168, 83, 0.06);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

/* clara-speaking — mic muted while Clara talks */
.mic-btn.mic-clara-speaking {
  background: var(--bg-raised);
  color: var(--text-muted);
  opacity: 0.5;
}

/* processing — VAD detected end of student speech */
.mic-btn.mic-processing {
  background: var(--bg-raised);
  color: var(--amber-dim);
  animation: pulse-amber 0.8s ease-in-out infinite;
}

/* error */
.mic-btn.mic-error {
  background: rgba(220, 80, 80, 0.12);
  border: 1px solid rgba(220, 80, 80, 0.3);
  color: #e07070;
}

@keyframes mic-pulse {
  0%, 100% {
    box-shadow: 0 0 0 8px  rgba(212, 168, 83, 0.15),
                0 0 0 16px rgba(212, 168, 83, 0.06);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(212, 168, 83, 0.2),
                0 0 0 24px rgba(212, 168, 83, 0.08);
  }
}

/* ── Mic Status Label ────────────────────────────────────── */
.mic-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-align: center;
  min-height: 1.2em;
  transition: color var(--transition);
}

/* ── Clara Speaking Waveform ─────────────────────────────── */
.clara-speaking-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.clara-speaking-indicator.active {
  opacity: 1;
}

.wave-bar {
  width: 3px;
  height: 4px;
  background: var(--amber);
  border-radius: 2px;
}

.clara-speaking-indicator.active .wave-bar {
  animation: wave 1.2s ease-in-out infinite;
}

.clara-speaking-indicator.active .wave-bar:nth-child(1) { animation-delay: 0s;    }
.clara-speaking-indicator.active .wave-bar:nth-child(2) { animation-delay: 0.15s; }
.clara-speaking-indicator.active .wave-bar:nth-child(3) { animation-delay: 0.3s;  }
.clara-speaking-indicator.active .wave-bar:nth-child(4) { animation-delay: 0.15s; }
.clara-speaking-indicator.active .wave-bar:nth-child(5) { animation-delay: 0s;    }

@keyframes wave {
  0%, 100% { height: 4px;  }
  50%       { height: 20px; }
}

/* ── Mic Permission Error ────────────────────────────────── */
.mic-error-msg {
  font-size: 0.8rem;
  color: #e07070;
  text-align: center;
  padding: 0 16px;
  max-width: 320px;
  line-height: 1.5;
}

/* ── Reconnect Failed Bar ────────────────────────────────── */
.reconnect-failed-bar {
  text-align: center;
  padding: 10px 16px;
  font-size: 0.8rem;
  color: #e07070;
  background: rgba(220, 80, 80, 0.08);
  border-top: 1px solid rgba(220, 80, 80, 0.2);
  letter-spacing: 0.02em;
}

.reconnect-failed-bar a {
  color: var(--amber);
  text-decoration: none;
  margin-left: 4px;
}

.reconnect-failed-bar a:hover {
  text-decoration: underline;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .mic-area {
    padding: 16px 16px 24px;
    gap: 10px;
  }

  .mic-btn {
    width: 64px;
    height: 64px;
  }

  .mic-btn svg {
    width: 24px;
    height: 24px;
  }
}
