/* ==========================================================================
   OPIc AI — Production Web Stylesheet
   Faithfully implemented from Figma Prototype (node-id: 7-583)
   ========================================================================== */

:root {
  /* Color Tokens */
  --sidebar-bg: #0F172A;
  --sidebar-surface: #1E293B;
  --sidebar-hover: #1E293B;
  --sidebar-text: #94A3B8;
  --sidebar-active-text: #FFFFFF;
  --sidebar-active-bg: #4F46E5;
  --sidebar-border: #1E293B;

  --app-bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-subtle: #F1F5F9;
  --border: #E2E8F0;
  --border-light: #F1F5F9;

  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-text: #4338CA;

  --accent-cyan: #06B6D4;
  --accent-cyan-light: #ECFEFF;
  --accent-cyan-border: #A5F3FC;

  --accent-amber: #F59E0B;
  --accent-amber-light: #FEF3C7;
  --accent-amber-text: #B45309;

  --accent-green: #10B981;
  --accent-green-hover: #059669;
  --accent-green-light: #DCFCE7;
  --accent-green-text: #15803D;

  --accent-red: #EF4444;
  --accent-red-hover: #DC2626;
  --accent-red-light: #FEE2E2;
  --accent-red-text: #B91C1C;

  --accent-purple: #8B5CF6;
  --accent-purple-light: #EDE9FE;
  --accent-purple-text: #6D28D9;

  --text-main: #0F172A;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-pulse: 0 0 0 8px rgba(239, 68, 68, 0.2);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-width: 250px;
  --header-height: 72px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--app-bg);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Master App Layout */
#app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--app-bg);
}

/* ==========================================================================
   Left Navigation Sidebar
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
  z-index: 50;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 24px 20px 20px;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge-ai {
  font-size: 0.65rem;
  font-weight: 700;
  background-color: #F59E0B;
  color: #0F172A;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--sidebar-text);
  font-weight: 500;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: #FFFFFF;
}

.nav-item.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.nav-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 20px 16px;
  border-top: 1px solid var(--sidebar-border);
  background-color: rgba(15, 23, 42, 0.6);
}

.lang-selector-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #64748B;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.lang-pills {
  display: flex;
  gap: 6px;
  background-color: #1E293B;
  padding: 4px;
  border-radius: var(--radius-md);
}

.lang-pill {
  flex: 1;
  padding: 6px 0;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94A3B8;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-pill:hover {
  color: #FFFFFF;
}

.lang-pill.active {
  background-color: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

/* ==========================================================================
   Main Workspace & Header
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--app-bg);
}

.topbar {
  height: var(--header-height);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  padding: 6px;
  color: var(--text-body);
  border-radius: var(--radius-md);
}

.topbar-headings {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#topbar-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

#topbar-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.context-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.context-badge.badge-yellow {
  background-color: var(--accent-amber-light);
  color: var(--accent-amber-text);
  border: 1px solid #FDE68A;
}

.context-badge.badge-red {
  background-color: var(--accent-red-light);
  color: var(--accent-red-text);
  border: 1px solid #FECACA;
  animation: pulse-red 1.8s infinite;
}

@keyframes pulse-red {
  0% { opacity: 1; }
  50% { opacity: 0.55; }
  100% { opacity: 1; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Exam Timer Bar */
.exam-timer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exam-counter-chip {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.exam-time-chip {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 12px;
  background-color: #0F172A;
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
}

.exam-time-chip.recording {
  background-color: #DC2626;
  animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Streak Badge */
.streak-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background-color: var(--accent-amber-light);
  border: 1px solid #FDE68A;
  border-radius: var(--radius-full);
  cursor: default;
}

.streak-flame {
  font-size: 1rem;
}

.streak-text {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent-amber-text);
  letter-spacing: 0.01em;
}

/* User Profile Widget (button — opens the accounts window) */
.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color 0.15s ease;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
}

.user-profile-widget:hover {
  background-color: var(--surface-subtle);
}

.user-avatar-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background-color: #E2E8F0;
  box-shadow: 0 0 0 2px #E2E8F0;
}

.user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.user-target-level {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Screen Content Area */
.screen-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 40px;
}

/* ==========================================================================
   Shared Components: Cards, Buttons, Form Elements
   ========================================================================== */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-main);
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  background-color: var(--primary);
  color: #FFFFFF;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-green {
  background-color: var(--accent-green);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-green:hover {
  background-color: var(--accent-green-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--text-body);
}

.btn-outline:hover {
  background-color: var(--surface-subtle);
  border-color: #CBD5E1;
}

.btn-ghost {
  color: var(--text-muted);
  background-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--surface-subtle);
  color: var(--text-main);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-beginner {
  background-color: var(--accent-green-light);
  color: var(--accent-green-text);
}

.badge-intermediate {
  background-color: #E0F2FE;
  color: #0369A1;
}

.badge-advanced {
  background-color: var(--accent-purple-light);
  color: var(--accent-purple-text);
}

/* ==========================================================================
   SCREEN 1: Dashboard View
   ========================================================================== */
.dashboard-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.dash-top-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 20px;
}

/* Card 1: Level Estimation */
.level-estimation-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.level-card-body {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.level-circle-badge {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  border: 2px solid #C7D2FE;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.45rem;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.12);
  flex-shrink: 0;
}

.level-info-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.level-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-main);
}

.level-target-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.level-progress-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background-color: #EEF2FF;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366F1 0%, #4F46E5 100%);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card 2: Weekly Practice Tracker */
.weekly-tracker-grid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 8px;
}

.day-tracker-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.day-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.day-status-circle {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  border: 1px dashed var(--border);
  color: var(--text-subtle);
  background-color: var(--surface-subtle);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.day-status-circle.done {
  background-color: var(--accent-amber-light);
  border: 1.5px solid #FCD34D;
  color: var(--accent-amber-text);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

.day-status-circle.current {
  background-color: #FEF3C7;
  border: 2px solid #F59E0B;
  color: #B45309;
}

/* Quick Action Cards (Row 2) */
.dash-action-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-cta-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.dash-cta-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.dash-cta-card.cta-practice {
  border-color: #C7D2FE;
  background: linear-gradient(135deg, #FFFFFF 0%, #F5F3FF 100%);
}

.dash-cta-card.cta-practice:hover {
  border-color: #818CF8;
}

.dash-cta-card.cta-reading {
  border-color: #A5F3FC;
  background: linear-gradient(135deg, #FFFFFF 0%, #F0FDFA 100%);
}

.dash-cta-card.cta-reading:hover {
  border-color: #38BDF8;
}

.cta-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cta-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cta-practice .cta-icon-box {
  background-color: #4F46E5;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.cta-reading .cta-icon-box {
  background-color: #0891B2;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(8, 145, 178, 0.3);
}

.cta-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cta-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

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

.cta-arrow {
  color: var(--text-subtle);
  font-size: 1.5rem;
  font-weight: 400;
  transition: transform 0.2s ease, color 0.2s ease;
}

.dash-cta-card:hover .cta-arrow {
  transform: translateX(4px);
  color: var(--text-main);
}

/* Recent Test Performance Chart (Row 3) */
.dash-chart-card {
  display: flex;
  flex-direction: column;
}

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

.chart-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-main);
  text-transform: uppercase;
}

.chart-link {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chart-link:hover {
  text-decoration: underline;
}

.chart-svg-container {
  width: 100%;
  height: 180px;
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Recommended Practice Topics (Row 4) */
.dash-topics-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topics-section-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-main);
  text-transform: uppercase;
}

.topics-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.topic-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

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

.topic-thumbnail-wrap {
  width: 100%;
  height: 130px;
  position: relative;
  background-color: #E2E8F0;
  overflow: hidden;
}

.topic-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.topic-card:hover .topic-thumbnail {
  transform: scale(1.05);
}

.topic-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-q-count {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.topic-card-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
}

.topic-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   SCREEN 2 & 3: Practice Exam & Active Recording Views
   ========================================================================== */
.exam-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

/* Screen 2: Question Prompt Card */
.listen-question-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.listen-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--primary);
  text-transform: uppercase;
}

.question-text-prominent {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-main);
}

.audio-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 16px;
}

.btn-play-question {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background-color: #EEF2FF;
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-full);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn-play-question:hover {
  background-color: #E0E7FF;
  transform: translateY(-1px);
}

.play-icon-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.audio-settings-group {
  display: flex;
  align-items: center;
  gap: 20px;
}

.speed-toggle-wrap, .voice-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.speed-pills {
  display: flex;
  gap: 4px;
  background-color: var(--surface-subtle);
  padding: 2px;
  border-radius: var(--radius-sm);
}

.speed-pill {
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.speed-pill.active {
  background-color: var(--primary);
  color: #FFFFFF;
}

.voice-select {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-body);
}

/* Screen 2: Record Ready Card */
.record-ready-card {
  text-align: center;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.record-ready-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-main);
  text-transform: uppercase;
}

.record-ready-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.record-button-concentric {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, #EF4444 0%, #DC2626 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  margin: 12px 0;
  box-shadow: 0 0 0 10px rgba(239, 68, 68, 0.15), 0 0 0 20px rgba(239, 68, 68, 0.08);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.record-button-concentric:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 14px rgba(239, 68, 68, 0.22), 0 0 0 26px rgba(239, 68, 68, 0.12);
}

.record-inner-dot {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background-color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-inner-dot::after {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background-color: #DC2626;
}

.record-btn-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #DC2626;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Exam Bottom Actions */
.exam-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
}

.exam-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* SCREEN 3: Active Recording Screen */
.recording-active-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.transcript-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.live-transcript-box {
  min-height: 140px;
  padding: 16px;
  background-color: var(--surface-subtle);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-body);
}

.live-transcript-box .highlighted {
  color: var(--primary);
  font-weight: 600;
}

.waveform-container {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 0;
}

.wave-bar {
  width: 4px;
  height: 12px;
  background-color: #EF4444;
  border-radius: 2px;
  animation: wave-anim 1.2s ease-in-out infinite alternate;
}

@keyframes wave-anim {
  0% { height: 8px; opacity: 0.4; }
  100% { height: 48px; opacity: 1; }
}

.wave-bar:nth-child(2n) { animation-delay: 0.2s; }
.wave-bar:nth-child(3n) { animation-delay: 0.4s; }
.wave-bar:nth-child(4n) { animation-delay: 0.1s; }
.wave-bar:nth-child(5n) { animation-delay: 0.3s; }

/* Web Interface Guidelines: honor prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .wave-bar { animation: none; height: 24px; }
  .rec-live-dot { animation: none; }
}

/* Live recording panel (practice view): status + mic level + live transcript.
   Hidden while idle via the `hidden` attribute set by showRecPanel(). */
.rec-live-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.05);
}

.rec-live-panel[hidden] { display: none; }

.rec-live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #dc2626;
}

.rec-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

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

.waveform-container.wave-compact {
  height: 56px;
  gap: 5px;
  padding: 0;
}

.live-transcript-box.live-compact {
  min-height: 0;
  max-height: 140px;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 0.86rem;
  line-height: 1.5;
}

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

/* Recording list: one row per take, newest first. */
.clip-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.clip-list:empty { display: none; }

.clip-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
}

.clip-del-all {
  border: 0;
  background: transparent;
  color: #dc2626;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}

.clip-del-all:hover { background: rgba(239, 68, 68, 0.08); }

.clip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  flex-wrap: wrap;
}

.clip-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* The text a take was judged against, so a stored score stays explainable. */
.clip-ref {
  flex: 1 1 100%;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--surface-subtle);
}

.clip-ref-label { font-weight: 800; flex-shrink: 0; }

.clip-ref-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

.clip-ref-stale {
  flex-shrink: 0;
  font-weight: 700;
  color: #B45309;
  background: #FEF3C7;
  border-radius: 999px;
  padding: 1px 7px;
}

.clip-row.active {
  border-color: var(--primary);
  background: var(--purple-light);
}

.clip-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  text-align: left;
  color: var(--text-main);
  font-size: 0.82rem;
}

.clip-index { font-weight: 800; flex-shrink: 0; }

.clip-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  flex-shrink: 0;
}

.clip-date {
  color: var(--text-muted);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.clip-score {
  flex-shrink: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.clip-score.score-good { background: #DCFCE7; color: #15803D; }
.clip-score.score-mid { background: #FEF3C7; color: #B45309; }
.clip-score.score-low { background: #FEE2E2; color: #B91C1C; }
.clip-score.score-none { background: var(--surface-subtle); color: var(--text-muted); font-weight: 600; }

.clip-del {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.clip-del:hover { background: rgba(239, 68, 68, 0.12); }

/* Per-take play/stop. Filled while that take is the one playing. */
.clip-play {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--purple-border, #DDD6FE);
  background: var(--purple-light, #F5F3FF);
  color: var(--primary, #4F46E5);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.clip-play:hover { background: var(--primary, #4F46E5); color: #fff; }
.clip-play:focus-visible { outline: 2px solid var(--primary, #4F46E5); outline-offset: 2px; }
.clip-play.is-playing { background: var(--primary, #4F46E5); border-color: var(--primary, #4F46E5); color: #fff; }

/* Pronunciation / intonation sub-scores under the overall score. */
.score-axis-grid {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.score-axis {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  font-size: 0.78rem;
}

.score-axis-label { color: var(--text-muted); }

.score-axis-value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

/* Real-time Analysis Panel */
.analysis-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.metric-bar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-header-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-status-green { color: var(--accent-green-text); }
.metric-status-orange { color: var(--accent-amber-text); }

.status-pulse-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-green-text);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--accent-green);
  animation: pulse-dot-anim 1.4s infinite;
}

@keyframes pulse-dot-anim {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Web Interface Guidelines: honor prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .pulse-dot { animation: none; }
}

/* ==========================================================================
   SCREEN 4: Speaking Test Results View
   ========================================================================== */
.results-view {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.results-left-col, .results-right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Overall Rating Donut Card */
.overall-rating-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
}

.rating-gauge-wrap {
  width: 130px;
  height: 130px;
  position: relative;
  margin: 16px 0 20px;
}

.rating-gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg-circle {
  fill: none;
  stroke: #EEF2FF;
  stroke-width: 10;
}

.gauge-val-circle {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 94; /* ~75% */
  transition: stroke-dashoffset 1s ease;
}

.gauge-center-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-level-main {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.gauge-level-sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.ielts-equivalent-sub {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-body);
}

/* Sub-Scores List */
.sub-scores-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sub-score-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sub-score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
}

.sub-score-bar {
  height: 6px;
  background-color: var(--surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.sub-score-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

.fill-green { background-color: var(--accent-green); }
.fill-orange { background-color: var(--accent-amber); }
.fill-purple { background-color: var(--accent-purple); }

/* Assessment Narrative Card */
.assessment-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-body);
}

/* Phonetic Correction Table Card */
.phonetic-table-card {
  overflow: hidden;
}

.phonetic-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.phonetic-table th {
  text-align: left;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 8px 12px 12px;
  border-bottom: 1px solid var(--border);
}

.phonetic-table td {
  padding: 14px 12px;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border-light);
}

.phonetic-table tr:last-child td {
  border-bottom: none;
}

.word-error {
  color: #DC2626;
  font-weight: 700;
}

.ipa-user {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.ipa-correct {
  font-family: var(--font-mono);
  color: #16A34A;
  font-weight: 700;
  font-size: 0.82rem;
}

.btn-tts-speaker {
  padding: 6px;
  border-radius: var(--radius-full);
  color: var(--primary);
  background-color: #EEF2FF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn-tts-speaker:hover {
  background-color: #E0E7FF;
  transform: scale(1.1);
}

.results-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

/* ==========================================================================
   SCREEN 5: Settings / Personalization & Configuration
   ========================================================================== */
/* Sub-menu bar: Personal info | General. Sticky so switching tabs is reachable
   from anywhere in a long settings page. */
.settings-subtabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 12px;
  background: var(--surface-subtle, #F1F5F9);
  align-self: start;
}

.settings-subtab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.settings-subtab:hover { color: var(--text-main); }

.settings-subtab.active {
  background: var(--surface, #fff);
  color: var(--primary, #4F46E5);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.settings-subtab:focus-visible { outline: 2px solid var(--primary, #4F46E5); outline-offset: 1px; }

/* One sub-menu at a time; cards inside still use the 2-column field grid. */
.settings-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.settings-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Two fields side by side inside a card so short inputs (name, age, country)
   do not each claim a full row. `span-2` keeps a wide field on its own line. */
.settings-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.settings-fields > .form-field { margin-bottom: 0; min-width: 0; }
.settings-fields > .span-2 { grid-column: 1 / -1; }

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

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

.form-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: #FFFFFF;
  color: var(--text-main);
  font-size: 0.88rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus-visible, .form-select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Topic chips */
.topic-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: #EEF2FF;
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
}

.chip-remove-btn {
  cursor: pointer;
  color: #818CF8;
  font-size: 0.9rem;
}

.chip-remove-btn:hover {
  color: #DC2626;
}

.btn-add-chip {
  padding: 6px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-add-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* AI Engine Tabs */
.ai-provider-tabs {
  display: flex;
  gap: 8px;
  background-color: var(--surface-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.ai-tab-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ai-tab-btn.active {
  background-color: #FFFFFF;
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.key-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.key-input-wrapper .form-input {
  width: 100%;
  padding-right: 110px;
}

.key-status-badge {
  position: absolute;
  right: 10px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #16A34A;
  background-color: #DCFCE7;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.settings-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}

/* Settings cards: tighter rhythm between title and fields, and a hairline rule
   so the eye can scan a long page without reading every label. */
.settings-view .card { padding: 18px 20px; }
.settings-view .card-title {
  font-size: 0.92rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #E5E7EB);
}
.settings-view .card-title:last-child { border-bottom: 0; }
.settings-view .form-field { margin-bottom: 10px; }
.settings-view .form-label { font-size: 0.72rem; }
.settings-view .hint { margin: 0 0 8px; }
.settings-view .check-row { margin-bottom: 6px; }

/* ==========================================================================
   SCREEN 6: Reading Practice Arena
   ========================================================================== */
.reading-arena-view {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 1100px;
  margin: 0 auto;
}

.reading-filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-left-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.difficulty-pills {
  display: flex;
  gap: 6px;
  background-color: #FFFFFF;
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--radius-full);
}

.diff-pill {
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.diff-pill.active {
  background-color: #0284C7;
  color: #FFFFFF;
}

.article-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Passage Card */
.reading-passage-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.passage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.passage-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.passage-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.passage-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-body);
}

.highlight-phrase {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  cursor: pointer;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.highlight-phrase:hover, .highlight-phrase.active {
  background-color: #EEF2FF;
}

/* Word-definition tooltip shown after selecting text in a passage or answer.
   Positioned in viewport coordinates by dictionary.js. */
.dict-popover {
  position: fixed;
  z-index: 1000;
  width: min(320px, calc(100vw - 20px));
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E5E7EB);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-main);
}

.dict-popover[hidden] { display: none; }

.dict-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border, #E5E7EB);
}

.dict-word { font-size: 1rem; font-weight: 800; }

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

.dict-audio, .dict-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1;
}

.dict-audio:hover, .dict-close:hover { background: var(--surface-subtle, #F1F5F9); }
.dict-close { margin-left: auto; color: var(--text-muted); }

.dict-sense { margin-bottom: 8px; }
.dict-sense:last-of-type { margin-bottom: 0; }

.dict-pos { color: var(--primary, #4F46E5); font-style: normal; font-weight: 700; font-size: 0.78rem; }

.dict-example {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.dict-source {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border, #E5E7EB);
  color: var(--text-muted);
  font-size: 0.7rem;
}

.dict-loading { color: var(--text-muted); }

/* Inline hint under a passage: points at the selection tooltip. */
.collocation-inline-hint {
  display: block;
  margin: 10px 0 4px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-subtle, #F1F5F9);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.collocation-inline-hint .colloc-title { font-weight: 800; color: var(--text-main); margin-right: 6px; }

/* Text in a passage should be selectable, otherwise the lookup can never fire. */
.passage-text, .passage-text p, .practice-answer-input { -webkit-user-select: text; user-select: text; }

/* Reading Audio Bar */
.reading-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

/* Speech Comparison Card */
.comparison-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comparison-boxes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.comparison-box {
  padding: 16px;
  border-radius: var(--radius-md);
  background-color: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comp-box-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comp-box-text {
  font-size: 0.92rem;
  line-height: 1.6;
}

.comp-correct {
  color: #16A34A;
  font-weight: 700;
}

.comp-wrong {
  color: #DC2626;
  font-weight: 700;
}

.actionable-tip-box {
  padding: 12px 16px;
  background-color: #FEF3C7;
  border-left: 4px solid #F59E0B;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #92400E;
}

/* ==========================================================================
   Toast & Modal Utility
   ========================================================================== */
#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background-color: #0F172A;
  color: #FFFFFF;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.25s ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Mock Test Select / Survey & Legacy View Utilities
   ========================================================================== */
.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

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

.qtype {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--primary-text);
  background-color: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.q-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}


.survey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border-light);
}

.survey-row:last-child {
  border-bottom: none;
}

.survey-row .q {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-body);
}

/* iOS-style toggle switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.switch i {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background-color: #CBD5E1;
  transition: background-color 0.2s ease;
  position: relative;
}

.switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background-color: #FFFFFF;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease;
}

.switch input:checked + i {
  background-color: var(--accent-green);
}

.switch input:checked + i::after {
  transform: translateX(18px);
}

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.empty .big {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 8px;
}

/* ===== Practice: speaker cursor + larger speaker icon ===== */
.speaker-cursor {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 24 24'%3E%3Cpath fill='%234F46E5' stroke='%23ffffff' stroke-width='1.4' d='M3 9v6h4l5 5V3L7 9H3z'/%3E%3Cpath fill='none' stroke='%234F46E5' stroke-width='2' stroke-linecap='round' d='M15.5 8.5a4.5 4.5 0 0 1 0 7M18 6a8 8 0 0 1 0 12'/%3E%3C/svg%3E") 6 15, pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(79, 70, 229, 0.12);
}
.speaker-cursor:focus-visible {
  outline: 2px solid var(--primary, #4F46E5);
  outline-offset: 3px;
}
/* The question bubble carries its own speaker button, so the old standalone
   "tap to hear" hint strip below it is no longer rendered anywhere. */
.q-hint-spk { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.q-hint-spk .spk-icon { font-size: 2rem; line-height: 1; font-weight: 800; }
.q-hint-spk .spk-text { font-size: 0.85rem; color: var(--text-muted); }
.answer-editor-card { width: 100%; }
.practice-answer-input { display: block; width: 100%; min-height: 260px; resize: vertical; box-sizing: border-box; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface, #fff); color: var(--text-main); line-height: 1.6; }
.practice-answer-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14); }
.circular-timer-wrap {
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.15s ease, filter 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(79, 70, 229, 0.12);
}
.circular-timer-wrap:hover { transform: scale(1.12); filter: brightness(1.05); }
.circular-timer-wrap:focus-visible {
  outline: 2px solid var(--primary, #4F46E5);
  outline-offset: 3px;
}

/* ===== Topics: compact card grid ===== */
.topics-list.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; margin-top: 16px; }
.topics-list.topics-grid .card { padding: 16px 18px; }
.topics-list.topics-grid .topic-row { gap: 14px; }
.topics-list.topics-grid .topic-emoji { font-size: 1.5rem; }
.topics-list.topics-grid .topic-name { font-size: 0.96rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topics-list.topics-grid .topic-count { font-size: 0.76rem; }
.topics-list.topics-grid .fav-btn { font-size: 0.9rem; }

/* ===== Mock test: hidden question (real-exam style) ===== */
.question-hidden-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 18px 16px; border-radius: 12px; border: 1.5px dashed var(--border, #C7D2FE); background: rgba(79, 70, 229, 0.04); }
.question-hidden-icon { font-size: 1.3rem; }
.question-hidden-text { font-size: 0.85rem; color: var(--text-muted); flex: 1; min-width: 200px; }
.show-question-btn { flex-shrink: 0; }

/* ===== Dashboard: About OPIc ===== */
.dash-opic-about { margin-top: 20px; }
.opic-about-details > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.opic-about-details > summary::-webkit-details-marker { display: none; }
.opic-about-icon { font-size: 1.2rem; }
.opic-about-title { font-size: 0.95rem; font-weight: 800; color: var(--text-main); }
.opic-about-arrow { margin-left: auto; color: var(--text-muted); transition: transform 0.2s ease; }
.opic-about-details[open] .opic-about-arrow { transform: rotate(180deg); }
.opic-about-body { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.opic-about-desc { font-size: 0.85rem; line-height: 1.6; color: var(--text-muted); margin: 0 0 12px; }
.opic-level-ladder { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.opic-level-step { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; min-width: 70px; padding: 10px 8px; border-radius: 10px; background: var(--purple-light, rgba(79, 70, 229, 0.06)); border: 1px solid var(--purple-border, rgba(79, 70, 229, 0.2)); }
.opic-level-code { font-size: 1rem; font-weight: 800; color: var(--primary, #4F46E5); }
.opic-level-name { font-size: 0.68rem; color: var(--text-muted); text-align: center; }

.btn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.btn.wide {
  width: 100%;
}


/* Legacy mobile-flow components (topic/question practice views) */
.q-bubble.accent {
  border-color: #C7D2FE;
  background: linear-gradient(135deg, #FFFFFF 0%, #F5F3FF 100%);
}

.q-text {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-main);
}

/* Question bubble: text on the left, speaker + timer as a pair on the right. */
.q-bubble-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.q-bubble-text { flex: 1; min-width: 0; }

.q-bubble-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.spk-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border, #C7D2FE);
  background: var(--surface, #fff);
  color: var(--primary, #4F46E5);
  font-size: 1.05rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.spk-icon-btn:hover { background: var(--purple-light, #EEF2FF); border-color: var(--primary, #4F46E5); }
.spk-icon-btn:active { transform: scale(0.94); }
.spk-icon-btn:focus-visible { outline: 2px solid var(--primary, #4F46E5); outline-offset: 2px; }

/* The practice-language line under the question: tighter gap, larger than the
   old inline style so it stays readable next to the bold question text. */
.q-practice-text {
  margin-top: 2px;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 600;
  color: var(--text-body);
  opacity: 0.92;
}

/* Answer card header: label on the left, tool buttons + Save on the right. */
.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.answer-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.timer-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.timer-value {
  font-family: var(--font-mono);
  color: var(--text-main);
}

.timer-value.warn {
  color: var(--accent-red-text);
}

.timer-bar {
  height: 8px;
  background-color: var(--surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.timer-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6366F1 0%, #4F46E5 100%);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.timer-bar i.warn {
  background: linear-gradient(90deg, #F87171 0%, #DC2626 100%);
}

.section-gap {
  height: 16px;
}

.score-big {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-text);
  line-height: 1.1;
}

.score-sub {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.mistake {
  padding: 10px 14px;
  background-color: var(--accent-red-light);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.mistake .said {
  color: var(--accent-red-text);
  font-weight: 700;
}

.mistake .correct {
  color: var(--accent-green-text);
  font-weight: 700;
}

.tip {
  padding: 10px 14px;
  background-color: #FEF3C7;
  border-left: 4px solid #F59E0B;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #92400E;
  margin-top: 8px;
}

.transcript {
  font-style: italic;
  color: var(--text-body);
}

.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* Prompt recap box on the active recording screen */
.prompt-recap-box {
  padding: 14px 18px;
  background-color: var(--primary-light);
  border: 1px solid #C7D2FE;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--primary-text);
}

.field {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 10px 0 6px;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Legacy topic list rows */
.topic-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topic-emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.topic-meta {
  flex: 1 1 170px;
  min-width: 0;
}

.topic-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
}

.topic-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.progress-mini {
  height: 5px;
  background-color: var(--surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 6px;
}

.progress-mini i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6366F1 0%, #4F46E5 100%);
  border-radius: var(--radius-full);
}

.fav-btn {
  font-size: 1.2rem;
  color: var(--text-subtle);
  padding: 6px;
  border-radius: var(--radius-sm);
}

.fav-btn.on {
  color: #F59E0B;
}

.fav-btn:hover {
  background-color: var(--surface-subtle);
}

/* Legacy modal shell */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 20px;
}

.modal {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .dash-top-metrics-grid,
  .dash-action-cards-grid,
  .topics-cards-grid,
  .settings-view,
  .results-view,
  .recording-active-grid,
  .comparison-boxes-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .screen-content {
    padding: 20px 16px;
  }

  .topics-cards-grid {
    grid-template-columns: 1fr;
  }

  .user-meta, .streak-text {
    display: none;
  }
}


/* ===== Mock test selection ===== */
.mock-select-page { display: flex; flex-direction: column; gap: 22px; max-width: 1100px; margin: 0 auto; }
.official-tests-section { padding: 4px 0; }
.official-tests-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.official-tests-heading h3 { margin: 0; font-size: 1.15rem; }
.official-tests-heading p { margin: 4px 0 0; color: var(--text-muted); font-size: .82rem; }
.test-count-badge { padding: 6px 10px; border-radius: 999px; background: var(--purple-light, #EEF2FF); color: var(--primary); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.test-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 10px; }
.thinking-bar { box-shadow: 0 5px 15px rgba(79,70,229,.1); }
@media (max-width: 600px) { .official-tests-heading { align-items: flex-start; flex-direction: column; gap: 8px; } }
