@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');

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

:root {
  --primary: #1a4f7a;
  --primary-light: #2471a3;
  --primary-dark: #0f2d45;
  --accent: #e8830a;
  --bg: #F7F5F1;
  --card: #ffffff;
  --text: #1a202c;
  --muted: #6b7280;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --s0: #e74c3c;
  --s1: #e67e22;
  --s2: #2980b9;
  --s3: #27ae60;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== PAGES ===== */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 22px; border: none; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all 0.18s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,79,122,0.3); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d9e6; }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; }
.btn-lg { padding: 14px 36px; font-size: 1.1rem; border-radius: 10px; }
.btn-back {
  background: none; border: none; color: var(--primary);
  font-size: 0.92rem; font-weight: 600; cursor: pointer; padding: 6px 0;
}
.btn-back:hover { text-decoration: underline; color: var(--primary-light); }

/* ===== LANDING ===== */
#page-landing {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 48px; border-bottom: 1px solid var(--border);
  background: white; position: sticky; top: 0; z-index: 10;
}
.nav-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px;
}
.nav-logo span {
  color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #d4720a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-split {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 60px; align-items: center;
  max-width: 1100px; margin: 0 auto; padding: 72px 48px;
}
.hero-eyebrow {
  font-size: 0.8rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 18px;
}
.hero-left h1 {
  font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 800;
  line-height: 1.1; color: var(--primary); margin-bottom: 20px;
  letter-spacing: -1px;
}
.hero-left .hero-sub {
  font-size: 1.05rem; color: var(--muted); line-height: 1.75;
  max-width: 460px; margin-bottom: 32px;
}
.hero-cta { margin-bottom: 28px; }
.hero-facts {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 0.88rem; color: var(--muted); margin-bottom: 14px;
}
.hero-facts strong { color: var(--primary); }
.hero-facts .sep { color: var(--border); }
.browser-note { font-size: 0.78rem; color: var(--muted); }

.topic-mosaic {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.mosaic-item {
  background: white; border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 10px; display: flex; flex-direction: column;
  align-items: center; gap: 7px; font-size: 1.7rem; text-align: center;
  transition: transform 0.2s, box-shadow 0.2s; box-shadow: var(--shadow);
  cursor: default;
}
.mosaic-item span { font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.mosaic-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.mosaic-item.m-alt1 { background: #FFF7F4; border-color: #FAD9CC; }
.mosaic-item.m-alt1 span { color: #C0441A; }
.mosaic-item.m-alt2 { background: #F2FAF8; border-color: #B9E4DA; }
.mosaic-item.m-alt2 span { color: #0D7A65; }

.how-strip {
  background: var(--primary-dark); color: white; padding: 60px 48px;
}
.how-inner { max-width: 1000px; margin: 0 auto; }
.how-strip h2 {
  font-size: 1.5rem; font-weight: 800; margin-bottom: 36px; letter-spacing: -0.5px;
}
.how-steps {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
}
.how-step {
  display: flex; align-items: flex-start; gap: 14px; flex: 1; min-width: 180px;
}
.how-num {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: white; font-weight: 800; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.how-step p { font-size: 0.92rem; line-height: 1.6; opacity: 0.85; }
.how-arrow { font-size: 1.8rem; opacity: 0.25; align-self: center; flex-shrink: 0; }

.rubric-section { padding: 64px 48px; background: white; }
.rubric-inner { max-width: 760px; margin: 0 auto; }
.rubric-section h2 {
  font-size: 1.5rem; font-weight: 800; color: var(--primary);
  margin-bottom: 10px; letter-spacing: -0.5px;
}
.rubric-intro { font-size: 0.95rem; color: var(--muted); margin-bottom: 28px; line-height: 1.6; }
.rubric-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rubric-table thead tr { border-bottom: 2px solid var(--border); }
.rubric-table th {
  text-align: left; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted);
  padding: 0 20px 12px 0;
}
.rubric-table tbody tr { border-bottom: 1px solid var(--border); }
.rubric-table tbody tr:last-child { border-bottom: none; }
.rubric-table td { padding: 13px 20px 13px 0; vertical-align: middle; color: var(--text); line-height: 1.5; }
.score-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem; color: white;
}
.s5-dot { background: #1a7a3c; }
.s4-dot { background: #27ae60; }
.s3-dot { background: #2980b9; }
.s2-dot { background: #e67e22; }
.s1-dot { background: #e74c3c; }
.s0-dot { background: #95a5a6; }

/* Score badge (used in practice + results pages) */
.score-badge {
  width: 26px; height: 26px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; flex-shrink: 0;
}
.score-badge.s5 { background: #1a7a3c; color: white; }
.score-badge.s4 { background: var(--s3); color: white; }
.score-badge.s3 { background: #2980b9; color: white; }
.score-badge.s2 { background: var(--s2); color: white; }
.score-badge.s1 { background: var(--s1); color: white; }
.score-badge.s0 { background: var(--s0); color: white; }

/* ===== PAGE HEADER ===== */
.page-header {
  background: white; border-bottom: 1px solid var(--border);
  padding: 20px 28px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.page-header h2 { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); margin: 6px 0 3px; }
.page-header p { color: var(--muted); font-size: 0.875rem; }

/* ===== TOPICS GRID ===== */
.topics-grid {
  display: flex; flex-direction: column; gap: 14px;
  padding: 28px; max-width: 700px; margin: 0 auto;
}
.topic-card {
  background: white; border: 2px solid var(--border); border-radius: var(--radius);
  padding: 24px 26px; display: flex; align-items: center; gap: 20px;
  cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow);
}
.topic-card:hover { border-color: var(--primary); transform: translateX(4px); box-shadow: var(--shadow-lg); }
.topic-icon { font-size: 2.6rem; flex-shrink: 0; }
.topic-info { flex: 1; }
.topic-info h3 { font-size: 1.15rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.topic-info p  { font-size: 0.88rem; color: var(--muted); margin-bottom: 8px; }
.topic-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===== CONVOS GRID ===== */
.convos-grid {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 28px; max-width: 700px; margin: 0 auto;
}
.convo-card {
  background: white; border: 2px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; display: flex; align-items: flex-start; gap: 16px;
  cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow);
}
.convo-card:hover { border-color: var(--primary); transform: translateX(4px); box-shadow: var(--shadow-lg); }
.convo-label {
  background: var(--primary); color: white; font-size: 0.72rem; font-weight: 800;
  padding: 4px 10px; border-radius: 20px; white-space: nowrap; flex-shrink: 0;
  align-self: flex-start; margin-top: 2px;
}
.convo-info { flex: 1; }
.convo-info h3 { font-size: 1rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.convo-info p  { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }

/* ===== SETS GRID (legacy kept for .set-tag / .set-meta reuse) ===== */
.set-card {
  background: white; border: 2px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; display: flex; align-items: center; gap: 18px;
  cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow);
}
.set-card:hover { border-color: var(--primary); transform: translateX(4px); box-shadow: var(--shadow-lg); }
.set-icon { font-size: 2.2rem; flex-shrink: 0; }
.set-info { flex: 1; }
.set-info h3 { font-size: 1.05rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.set-info p { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin-bottom: 8px; }
.set-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.set-tag {
  background: #eef3ff; color: var(--primary);
  font-size: 0.72rem; font-weight: 600; padding: 2px 10px; border-radius: 20px;
}
.set-arrow { color: var(--primary); font-size: 1.5rem; font-weight: 300; flex-shrink: 0; }

/* ===== PRACTICE HEADER ===== */
.practice-header {
  background: white; border-bottom: 1px solid var(--border);
  padding: 14px 20px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.btn-rerandom {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 1rem; cursor: pointer; color: var(--muted);
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.btn-rerandom:hover { background: var(--surface); color: var(--primary); }
.btn-rerandom:disabled { opacity: 0.5; cursor: default; }
.practice-title-block { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.practice-set-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); }
.progress-bar-wrap { background: var(--border); border-radius: 4px; height: 5px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary-light), var(--accent)); border-radius: 4px; transition: width 0.4s ease; width: 0%; }
.progress-label { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.running-score {
  background: var(--primary); color: white; padding: 5px 14px;
  border-radius: 20px; font-size: 0.82rem; font-weight: 700; white-space: nowrap; flex-shrink: 0;
}

/* ===== TRANSCRIPT AREA ===== */
.transcript-area {
  max-width: 720px; margin: 0 auto; padding: 20px 20px 0;
  display: flex; flex-direction: column; gap: 12px;
}
.transcript-item {
  display: flex; gap: 10px;
  animation: fadeSlide 0.35s ease;
}
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.transcript-item.en-speaker { flex-direction: row; }
.transcript-item.id-speaker { flex-direction: row-reverse; }

.t-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0; margin-top: 2px;
}
.transcript-item.id-speaker .t-avatar { background: #7d3c98; }

.t-bubble {
  max-width: 75%; background: white; border-radius: 12px;
  padding: 10px 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.transcript-item.en-speaker .t-bubble { border-top-left-radius: 2px; }
.transcript-item.id-speaker .t-bubble { border-top-right-radius: 2px; }

.t-speaker { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 4px; }
.t-text { font-size: 0.875rem; line-height: 1.55; color: var(--text); }
.t-interp {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 0.8rem; color: var(--muted); font-style: italic; line-height: 1.5;
}
.t-score {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  color: white; font-size: 0.65rem; font-weight: 800;
  text-align: center; line-height: 18px; margin-left: 6px; vertical-align: middle;
}
.t-score.s0 { background: #95a5a6; }
.t-score.s1 { background: var(--s0); }
.t-score.s2 { background: var(--s1); }
.t-score.s3 { background: var(--s2); }
.t-score.s4 { background: #2ecc71; }
.t-score.s5 { background: var(--s3); }

/* ===== PRACTICE BODY ===== */
.practice-body { max-width: 720px; margin: 0 auto; padding: 16px 20px 60px; }

.segment-card {
  background: white; border-radius: 16px; padding: 26px 24px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}

/* Speaker row */
.speaker-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.speaker-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center;
  justify-content: center; font-size: 1.4rem; flex-shrink: 0;
}
.speaker-info { flex: 1; }
.speaker-name { font-size: 1rem; font-weight: 700; color: var(--primary-dark); }
.speaker-lang { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.btn-play {
  display: flex; align-items: center; gap: 6px;
  background: var(--primary); color: white;
  border: none; border-radius: 8px; padding: 8px 16px;
  font-size: 0.88rem; font-weight: 700; cursor: pointer;
  transition: all 0.2s; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.btn-play:hover:not(:disabled) { background: var(--primary-light); transform: scale(1.03); }
.btn-play.playing { background: var(--accent); animation: pulse 1.2s infinite; }
.btn-play:disabled { cursor: not-allowed; opacity: 0.7; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.75; } }

/* Source text */
.source-text-box {
  background: #f8faff; border: 1px solid #dbe8f9;
  border-radius: 10px; padding: 16px 18px; margin-bottom: 20px;
}
.source-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--primary); margin-bottom: 8px;
}
.segment-text { font-size: 1rem; line-height: 1.75; color: var(--text); }

/* ===== RECORD SECTION ===== */
.record-section { border-top: 1px solid var(--border); padding-top: 20px; }

.your-turn-banner {
  background: #fffbea; border: 1px solid #fde68a;
  border-radius: 8px; padding: 10px 14px;
  font-size: 0.9rem; color: #7c4f00; margin-bottom: 20px;
}

/* Mic button */
.mic-area { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }

.mic-btn {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--primary); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(26,79,122,0.3);
}
.mic-btn:hover { transform: scale(1.07); box-shadow: 0 6px 20px rgba(26,79,122,0.4); }
.mic-btn.recording {
  background: var(--s0);
  animation: micPulse 1s infinite;
  box-shadow: 0 0 0 0 rgba(231,76,60,0.5);
}
@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0 rgba(231,76,60,0.55); }
  70%  { box-shadow: 0 0 0 18px rgba(231,76,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
}

.mic-status {
  font-size: 0.85rem; font-weight: 600; color: var(--muted);
  text-align: center;
}
.mic-status.recording-active { color: var(--s0); font-weight: 700; }

/* Transcription */
.transcription-box {
  background: #fafafa; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 14px 16px; min-height: 80px;
  transition: border-color 0.2s;
}
.transcription-box.active-recording { border-color: var(--s0); background: #fff8f8; }
.transcription-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-bottom: 8px; }
.transcription-text { font-size: 0.95rem; line-height: 1.65; color: var(--text); }
.transcription-text.placeholder { color: #adb5bd; font-style: italic; }
.transcription-interim { color: var(--muted); }

/* No speech support */
.no-speech-support {
  background: #fff8f0; border: 1px solid #fad7a0; border-radius: 8px;
  padding: 14px; font-size: 0.875rem; color: #7c4f00; margin-top: 12px;
  line-height: 1.6;
}

/* Mic permission / device error */
.mic-error {
  display: flex; align-items: flex-start; gap: 12px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
  padding: 14px; margin-top: 12px; animation: slideIn 0.2s ease;
}
.mic-error-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; }
.mic-error strong { display: block; color: #991b1b; font-size: 0.9rem; margin-bottom: 4px; }
.mic-error p { font-size: 0.82rem; color: #7f1d1d; margin: 0 0 10px; line-height: 1.5; }

/* ===== WAVEFORM CANVASES ===== */
.wave-canvas {
  display: block; width: 100%; height: 68px;
  border-radius: 8px;
  background: #f4f5f7;
  border: 1px solid #e5e7eb;
}
.user-wave-canvas {
  background: #f9fafb;
  border-color: #e5e7eb;
  margin-bottom: 4px;
}

/* Countdown ring */
.countdown-ring {
  width: 80px; height: 80px; position: relative;
  margin: 0 auto 14px; display: flex; align-items: center; justify-content: center;
}
.countdown-ring svg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.countdown-track {
  fill: none; stroke: var(--border); stroke-width: 5;
}
.countdown-arc {
  fill: none; stroke: var(--accent); stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 163.36; stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.05s linear;
}
.countdown-num {
  position: relative; font-size: 1.6rem; font-weight: 800;
  color: var(--accent); z-index: 1;
}

/* Reveal + re-record */
.reveal-section { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.btn-outline-sm {
  background: transparent; color: var(--primary); border: 2px solid var(--primary);
  padding: 8px 16px; border-radius: 8px; font-size: 0.88rem; font-weight: 700;
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.btn-outline-sm:hover { background: var(--primary); color: white; }

/* Model answer */
.model-answer-box {
  margin-top: 18px; background: #f0faf4; border: 1px solid #b7dfca;
  border-radius: 10px; padding: 18px; animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.model-answer-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.model-label { background: var(--s3); color: white; font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.model-note { font-size: 0.78rem; color: #555; font-style: italic; }
.model-answer-text { font-size: 0.98rem; line-height: 1.75; color: #1a3a2a; font-weight: 500; }
.key-terms-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.key-terms-label { font-size: 0.75rem; font-weight: 700; color: #555; white-space: nowrap; margin-top: 2px; }
.key-terms-list { display: flex; gap: 6px; flex-wrap: wrap; }
.key-term { background: white; border: 1px solid #b7dfca; color: #1a5c38; font-size: 0.76rem; padding: 2px 10px; border-radius: 20px; font-weight: 600; }

/* Auto-score card */
.scoring-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); animation: slideIn 0.3s ease; }

.auto-score-card {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
}
.auto-score-left { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; }
.auto-score-badge {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; color: white;
  transition: background 0.3s;
}
.auto-score-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-align: center; }
.auto-score-right { flex: 1; }
.auto-score-detail { font-size: 0.88rem; color: var(--text); margin-bottom: 8px; }
.auto-score-terms { display: flex; flex-wrap: wrap; gap: 6px; }
.kt-chip {
  font-size: 0.76rem; font-weight: 700; padding: 3px 10px; border-radius: 20px;
}
.kt-hit { background: #eafaf1; color: #1a5c38; border: 1px solid #a9dfbf; }
.kt-miss { background: #fdecea; color: #922b21; border: 1px solid #f5c6c2; }

/* Score loading state */
.score-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 4px; color: var(--muted); font-size: 0.9rem; font-weight: 600;
}
.score-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  display: inline-block; animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Score error state */
.score-error {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 4px 0;
}
.score-error-icon {
  font-size: 1.4rem; flex-shrink: 0; margin-top: 2px;
}
.score-error strong { display: block; color: #92400e; margin-bottom: 4px; }
.score-error p { font-size: 0.85rem; color: var(--muted); margin: 0 0 10px; }

/* Next */
.next-section { margin-top: 18px; text-align: center; animation: slideIn 0.3s ease; }
.next-section .btn { min-width: 190px; }

/* ===== INTRO MODAL ===== */
.intro-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100; backdrop-filter: blur(4px);
}
.intro-modal {
  background: white; border-radius: 20px; width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 72px rgba(0,0,0,0.22);
  animation: slideIn 0.25s ease;
  display: flex; flex-direction: column;
}
.intro-step { padding: 32px 32px 0; flex: 1; }
.intro-step-header {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); margin-bottom: 20px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.intro-candidate-tag {
  display: inline-block; background: var(--primary); color: white;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 1.5px;
  padding: 4px 12px; border-radius: 4px; margin-bottom: 20px;
  text-transform: uppercase;
}
.intro-body p {
  font-size: 0.92rem; color: var(--text); line-height: 1.7;
  margin-bottom: 12px;
}
.intro-body p:last-child { margin-bottom: 0; }
.intro-hint {
  font-size: 0.85rem; color: var(--muted); margin: 20px 0 0;
}
/* Mic test */
.intro-wave-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin: 16px 0;
}
.intro-wave-canvas {
  width: 100%; height: 64px; border-radius: 8px;
  background: #f4f5f7; display: block; margin-bottom: 12px;
}
.intro-mic-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.intro-mic-status {
  font-size: 0.82rem; color: var(--muted); font-style: italic;
}
.intro-repeat-note {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px;
  padding: 12px 14px; font-size: 0.85rem; color: #166534; line-height: 1.6;
}
.intro-repeat-note strong { color: #14532d; }
/* Footer */
.intro-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 32px 24px; gap: 10px; border-top: 1px solid var(--border);
  margin-top: 24px;
}
.intro-footer-right { display: flex; gap: 10px; }

/* ===== REPLAY WARNING MODAL ===== */
.replay-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(3px);
}
.replay-modal {
  background: white; border-radius: 24px; padding: 40px 32px 32px;
  max-width: 340px; width: 90%; text-align: center; position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
  animation: slideIn 0.25s ease;
}
.replay-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 1.3rem; color: #c0c0c0;
  cursor: pointer; line-height: 1;
}
.replay-close:hover { color: #888; }

/* Sparkle decorations */
.replay-sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkle {
  position: absolute; font-size: 1rem; font-weight: 700; line-height: 1;
  color: #d1d5db;
}
.sp-tl { top: 52px;  left: 32px;  font-size: 1.1rem; }
.sp-tr { top: 44px;  right: 36px; font-size: 0.85rem; color: #e5e7eb; }
.sp-bl { bottom: 80px; left: 28px;  font-size: 0.7rem; }
.sp-br { bottom: 72px; right: 30px; font-size: 1rem; }

.replay-icon-wrap {
  width: 88px; height: 88px; border-radius: 50%;
  background: #f3f4f6; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.replay-icon {
  width: 0; height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 36px solid #f59e0b;
  position: relative;
  filter: drop-shadow(0 2px 4px rgba(245,158,11,0.35));
}
.replay-icon::after {
  content: '!'; position: absolute; top: 9px; left: -5px;
  color: white; font-size: 0.95rem; font-weight: 900;
}
.replay-title {
  font-size: 1.05rem; font-weight: 700; color: #111827;
  margin-bottom: 8px; line-height: 1.4;
}
.replay-body {
  font-size: 0.875rem; color: #6b7280; line-height: 1.6; margin-bottom: 28px;
}
.replay-actions {
  display: flex; gap: 10px; justify-content: center;
}
.replay-btn-cancel {
  flex: 1; padding: 12px 20px; border-radius: 50px; border: none;
  background: #f3f4f6; color: #374151; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.replay-btn-cancel:hover { background: #e5e7eb; }
.replay-btn-ok {
  flex: 1; padding: 12px 20px; border-radius: 50px; border: none;
  background: #0d9488; color: white; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.replay-btn-ok:hover { background: #0f766e; }

/* Replay penalty banner */
.replay-penalty-banner {
  background: #fff7ed; border: 1px solid #fed7aa;
  border-radius: 8px; padding: 8px 14px;
  font-size: 0.82rem; color: #92400e; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

/* ===== RESULTS ===== */
#page-results { background: var(--bg); }
.results-container { max-width: 700px; margin: 0 auto; padding: 48px 20px 60px; text-align: center; }
.results-badge { font-size: 4rem; margin-bottom: 14px; }
.results-title { font-size: 1.7rem; font-weight: 800; color: var(--primary-dark); margin-bottom: 22px; }
.results-score-display {
  background: white; border-radius: 18px; padding: 28px;
  box-shadow: var(--shadow); margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center; gap: 36px; flex-wrap: wrap;
}
.big-score { font-size: 3.4rem; font-weight: 800; line-height: 1; }
.big-score.grade-great { color: var(--s3); }
.big-score.grade-good  { color: var(--s2); }
.big-score.grade-ok    { color: var(--s1); }
.big-score.grade-low   { color: var(--s0); }
.score-detail { text-align: left; }
.score-detail-raw { font-size: 1.4rem; font-weight: 700; }
.score-detail-label { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.results-naati { background: var(--primary-dark); color: white; border-radius: 12px; padding: 16px 22px; margin-bottom: 32px; font-size: 0.95rem; font-weight: 500; line-height: 1.65; }
.results-breakdown { background: white; border-radius: 14px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 28px; text-align: left; }
.results-breakdown h3 { font-size: 0.85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.breakdown-list { display: flex; flex-direction: column; gap: 10px; }
.breakdown-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--bg); }
.breakdown-num { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.82rem; color: white; flex-shrink: 0; }
.breakdown-num.s0 { background: #95a5a6; }
.breakdown-num.s1 { background: var(--s0); }
.breakdown-num.s2 { background: var(--s1); }
.breakdown-num.s3 { background: var(--s2); }
.breakdown-num.s4 { background: #2ecc71; }
.breakdown-num.s5 { background: var(--s3); }
.breakdown-content { flex: 1; }
.breakdown-speaker { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--primary); margin-bottom: 3px; }
.breakdown-text { font-size: 0.855rem; color: var(--text); line-height: 1.5; }
.breakdown-score-label { font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-top: 3px; }
.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.results-actions .btn { min-width: 160px; }

/* ===== SETTINGS BUTTON ===== */
.nav-actions { display: flex; align-items: center; gap: 10px; }
.btn-settings {
  background: none; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  color: var(--muted); transition: all 0.18s; font-family: inherit;
}
.btn-settings:hover { border-color: var(--primary); color: var(--primary); }

/* ===== SETTINGS MODAL ===== */
.settings-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.settings-modal {
  background: white; border-radius: 18px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); overflow: hidden;
}
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.settings-header h3 { font-size: 1.05rem; font-weight: 800; color: var(--primary); }
.settings-close {
  background: none; border: none; font-size: 1rem; cursor: pointer;
  color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.settings-close:hover { background: var(--bg); }
.settings-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; max-height: 70vh; overflow-y: auto; }
.settings-section h4 { font-size: 0.9rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.settings-section p  { font-size: 0.83rem; color: var(--muted); line-height: 1.55; margin-bottom: 10px; }
.settings-steps { font-size: 0.83rem; color: var(--muted); padding-left: 18px; margin-bottom: 12px; line-height: 2; }
.settings-label { display: block; font-size: 0.78rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.settings-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 0.9rem; font-family: inherit;
  transition: border-color 0.18s; outline: none;
}
.settings-input:focus { border-color: var(--primary); }
.settings-select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 0.9rem; font-family: inherit;
  background: white; cursor: pointer; outline: none;
}
.settings-select:focus { border-color: var(--primary); }
.el-status { font-size: 0.8rem; font-weight: 600; margin-top: 8px; padding: 6px 10px; border-radius: 6px; }
.el-active   { background: #eafaf1; color: #1a7a3c; }
.el-inactive { background: #fdf5e6; color: #9a6c00; }
.settings-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg);
}

/* ===== PLAYBACK SECTION ===== */
.playback-section {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 14px 18px;
  margin-top: 12px;
}

.playback-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #166534;
  white-space: nowrap;
}

.playback-play-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.playback-play-btn:hover { background: #15803d; }

.playback-icon {
  font-size: 0.75rem;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .rubric-grid { grid-template-columns: 1fr; }
  .steps-row { flex-direction: column; align-items: center; }
  .step-arrow { transform: rotate(90deg); }
  .hero-split { grid-template-columns: 1fr; padding: 40px 24px; gap: 40px; }
  .landing-nav { padding: 16px 24px; }
  .how-strip { padding: 40px 24px; }
  .rubric-section { padding: 40px 24px; }
  .topic-mosaic { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 580px) {
  .practice-header { padding: 10px 14px; gap: 10px; }
  .practice-body { padding: 12px 12px 40px; }
  .segment-card { padding: 18px 14px; }
  .score-buttons { gap: 6px; }
  .score-btn { min-width: 68px; padding: 10px 10px; }
  .score-num { font-size: 1.1rem; }
  .score-desc { font-size: 0.62rem; }
  .results-score-display { flex-direction: column; gap: 14px; }
  .sets-grid { padding: 16px; }
  .mic-btn { width: 70px; height: 70px; font-size: 1.7rem; }
}
