/* ═════════════════════════════════════════════════════════════
   AZOTA-STYLE DESIGN SYSTEM — Scalable Multi-Grade Theme
   ═════════════════════════════════════════════════════════════ */

:root {
  /* Primary Green (Azota brand) */
  --primary: #00B074;
  --primary-dark: #009963;
  --primary-light: #33C08F;
  --primary-soft: rgba(0, 176, 116, 0.08);
  --primary-glow: rgba(0, 176, 116, 0.15);
  --primary-border: rgba(0, 176, 116, 0.3);

  /* Backgrounds (Light Mode) */
  --bg-page: #F4F6F8;
  --bg-white: #FFFFFF;
  --bg-gray: #F7F8FA;
  --bg-hover: #F5F5F5;
  --bg-card: #FFFFFF;

  /* Text (Light Mode) */
  --text-primary: #1A1A2E;
  --text-secondary: #5A5A72;
  --text-muted: #9E9EB8;
  --text-white: #FFFFFF;

  /* Borders (Light Mode) */
  --border: #E8E8EF;
  --border-hover: #D0D0DC;

  /* Status Colors */
  --green: #00B074;
  --green-bg: rgba(0, 176, 116, 0.1);
  --green-border: rgba(0, 176, 116, 0.25);
  --red: #FF4757;
  --red-bg: rgba(255, 71, 87, 0.08);
  --red-border: rgba(255, 71, 87, 0.25);
  --orange: #FF9F43;
  --orange-bg: rgba(255, 159, 67, 0.1);
  --blue: #3B82F6;
  --blue-bg: rgba(59, 130, 246, 0.08);

  /* Subject Card Gradients */
  --grad-purple: linear-gradient(135deg, #f3e8ff 0%, #d8b4fe 100%);
  --grad-green: linear-gradient(135deg, #dcfce7 0%, #86efac 100%);
  --grad-blue: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%);
  --grad-orange: linear-gradient(135deg, #ffedd5 0%, #fdba74 100%);
  --grad-red: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);

  /* Sizing */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-full: 50px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-page: #0F1115;
  --bg-white: #1A1D24;
  --bg-gray: #242832;
  --bg-hover: #20242D;
  --bg-card: #1A1D24;

  --text-primary: #F0F2F5;
  --text-secondary: #B0B3C0;
  --text-muted: #7A7D8F;
  --text-white: #FFFFFF;

  --border: #2D313D;
  --border-hover: #404554;

  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);

  --grad-purple: linear-gradient(135deg, rgba(216, 180, 254, 0.15) 0%, rgba(216, 180, 254, 0.05) 100%);
  --grad-green: linear-gradient(135deg, rgba(134, 239, 172, 0.15) 0%, rgba(134, 239, 172, 0.05) 100%);
  --grad-blue: linear-gradient(135deg, rgba(147, 197, 253, 0.15) 0%, rgba(147, 197, 253, 0.05) 100%);
  --grad-orange: linear-gradient(135deg, rgba(253, 186, 116, 0.15) 0%, rgba(253, 186, 116, 0.05) 100%);
  --grad-red: linear-gradient(135deg, rgba(252, 165, 165, 0.15) 0%, rgba(252, 165, 165, 0.05) 100%);
}

/* ═════════════════════════════════════════════════════════════
   RESET & BASE
   ═════════════════════════════════════════════════════════════ */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═════════════════════════════════════════════════════════════
   LAYOUT
   ═════════════════════════════════════════════════════════════ */

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 40px;
  position: relative;
  z-index: 1;
}

/* Screen Management */
.screen { display: none; }

.screen.on {
  display: block;
  animation: fadeSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ═════════════════════════════════════════════════════════════
   TOP NAVIGATION BAR (Azota style)
   ═════════════════════════════════════════════════════════════ */

.header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  margin: 0 -20px 0;
  padding-left: 20px;
  padding-right: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--bg-gray);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  font-size: 1.1rem;
}

.theme-toggle:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.theme-icon.dark-icon { display: none; }
[data-theme="dark"] .theme-icon.dark-icon { display: block; }
[data-theme="dark"] .theme-icon.light-icon { display: none; }

/* ═════════════════════════════════════════════════════════════
   DASHBOARD HERO & STATS
   ═════════════════════════════════════════════════════════════ */

.dashboard-hero {
  text-align: center;
  padding: 32px 0 24px;
}

.home-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.home-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.stats-banner {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.stat-pill {
  background: var(--bg-white);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
  box-shadow: var(--shadow);
}

.stat-pill span {
  font-weight: 800;
  color: var(--primary);
}

/* Announcement Banner */
.announcement-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.02) 100%);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 0 auto 28px;
  max-width: 600px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.05);
  transition: var(--transition);
}

.announcement-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.announcement-icon {
  font-size: 24px;
  line-height: 1;
  margin-top: 2px;
}

.announcement-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.announcement-text strong {
  font-size: 1rem;
  color: var(--blue);
  font-weight: 700;
}

.announcement-text span {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

[data-theme="dark"] .announcement-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 100%);
  border-color: rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .announcement-text span {
  color: var(--text-muted);
}

/* ═════════════════════════════════════════════════════════════
   GRADE TABS
   ═════════════════════════════════════════════════════════════ */

.grade-tabs-container {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.grade-tabs {
  display: inline-flex;
  background: var(--bg-gray);
  padding: 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  gap: 4px;
}

.grade-tab {
  padding: 8px 24px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  border: none;
  font-family: inherit;
}

.grade-tab:hover {
  color: var(--text-primary);
}

.grade-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
}

/* ═════════════════════════════════════════════════════════════
   SUBJECTS GRID (Cards)
   ═════════════════════════════════════════════════════════════ */

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.subject-card {
  position: relative;
  padding: 24px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: var(--transition);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  user-select: none;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--card-color, var(--primary));
  opacity: 0.8;
}

.subject-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.subject-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.subject-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  background: var(--bg-gray);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.subject-info { flex: 1; min-width: 0; }

.subject-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

.subject-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.subject-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Progress logic */
.subject-progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.subject-progress-bar-bg {
  width: 60px;
  height: 6px;
  background: var(--bg-gray);
  border-radius: 3px;
  overflow: hidden;
}

.subject-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}

/* ═════════════════════════════════════════════════════════════
   TOPICS SCREEN
   ═════════════════════════════════════════════════════════════ */

.topics-container {
  max-width: 720px;
  margin: 0 auto;
}

.topics-header {
  text-align: center;
  margin-bottom: 24px;
}

.topics-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.topics-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.select-all-btn {
  padding: 7px 18px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.select-all-btn:hover {
  background: var(--primary);
  color: #fff;
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.topic-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.topic-card:hover {
  border-color: var(--primary-border);
  background: var(--bg-hover);
}

.topic-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* Custom checkbox */
.topic-checkbox-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.topic-checkbox {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0; width: 0;
}

.topic-checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-hover);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.topic-checkbox-wrapper:hover .topic-checkmark {
  border-color: var(--primary);
}

.topic-checkbox:checked ~ .topic-checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.topic-checkmark::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}

.topic-checkbox:checked ~ .topic-checkmark::after {
  transform: rotate(45deg) scale(1);
}

.topic-info { flex: 1; }

.topic-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.topic-meta {
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topic-questions::before { content: '📝 '; }
.topic-tf::before { content: '✅ '; }
.topic-time::before { content: '⏱️ '; }

/* Quiz Config Panel */
.quiz-config {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.config-row label {
  font-size: 0.92rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.config-row select {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.config-row select:hover { border-color: var(--primary-border); }
.config-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Quiz Summary Bar */
.quiz-summary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-gray);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.summary-item {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.summary-item strong {
  color: var(--primary);
  font-weight: 700;
}

.summary-divider { color: var(--text-muted); }

/* Start Button */
.start-btn {
  width: 100%;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: var(--transition);
  margin-top: 6px;
}

.start-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--primary-glow);
}

.start-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ═════════════════════════════════════════════════════════════
   QUIZ CONFIGURATION (Custom Quiz Inputs)
   ═════════════════════════════════════════════════════════════ */
.quiz-config {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 30px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.config-label {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

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

.config-item label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.config-input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-gray);
  font-size: 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 600;
  transition: var(--transition);
  text-align: center;
}

.config-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--bg-white);
}

.config-input:hover {
  border-color: var(--border-hover);
}

.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.config-row label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.quiz-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-gray);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
}

.summary-item strong {
  font-size: 1.1rem;
  color: var(--primary);
}

/* ═════════════════════════════════════════════════════════════
   RESULT SCREEN
   ═════════════════════════════════════════════════════════════ */

.result-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 540px;
  margin: 20px auto 0;
  position: relative;
}

.score-circle {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 20px;
}

.score-circle svg { transform: rotate(-90deg); }

.score-bg {
  fill: none;
  stroke: var(--bg-gray);
  stroke-width: 8;
}

.score-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-value {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -2px;
}

.score-total {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: -4px;
}

.result-title {
  font-size: 1.25rem;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--text-primary);
}

.result-message {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.92rem;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin-bottom: 24px;
}

.stat { text-align: center; }

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  display: block;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat.correct .stat-num { color: var(--green); }
.stat.wrong .stat-num { color: var(--red); }
.stat.time .stat-num { color: var(--blue); }

/* Action Buttons */
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 11px 24px;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.action-btn.primary {
  background: var(--primary);
  color: #fff;
}

.action-btn.primary:hover {
  background: var(--primary-dark);
}

.action-btn.secondary {
  background: var(--bg-gray);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
}

.action-btn.secondary:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.action-btn:hover {
  transform: translateY(-1px);
}

/* Review Section */
.review-section {
  margin-top: 24px;
  text-align: left;
  max-height: 500px;
  overflow-y: auto;
}

.review-section.hidden { display: none; }

.review-section h3 {
  margin-bottom: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.review-item {
  background: var(--bg-gray);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 3px solid var(--border);
}

.review-item.correct { border-left-color: var(--green); }
.review-item.wrong { border-left-color: var(--red); }

.review-question {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.review-type {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-right: 4px;
}

.review-answer {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.review-answer.correct { color: var(--green); }
.review-answer.wrong { color: var(--red); }

.review-explanation {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ═════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-gray); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }

/* ═════════════════════════════════════════════════════════════
   RESPONSIVE
   ═════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .logo-text { font-size: 1.15rem; }
  .logo-icon { width: 36px; height: 36px; font-size: 18px; }
  .subjects-grid { grid-template-columns: 1fr; }
  .topics-list { gap: 8px; }
  .topic-card { padding: 12px 14px; }
  .quiz-config { padding: 18px; }
  .result-card { padding: 28px 18px; margin-top: 10px; }
  .score-circle { width: 120px; height: 120px; }
  .score-value { font-size: 2rem; }
  .result-stats { gap: 20px; }
  .result-actions { flex-direction: column; }
  .action-btn { width: 100%; text-align: center; }
  .header { margin: 0 -20px 20px; }
  .home-title { font-size: 1.3rem; }
}

@media (max-width: 400px) {
  .app { padding: 0 14px 32px; }
  .header { padding: 12px 14px; margin: 0 -14px 16px; }
  .subject-card { padding: 18px; }
}

/* ═════════════════════════════════════════════════════════════
   MODE SELECTOR — 5 learning mode cards
   ═════════════════════════════════════════════════════════════ */

.mode-selector {
  text-align: center;
  margin-bottom: 28px;
}

.mode-selector h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.mode-card {
  padding: 16px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-white);
  text-align: center;
  user-select: none;
}

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

.mode-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.mode-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.mode-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.mode-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.wrong-count-desc span {
  font-weight: 700;
  color: var(--red);
}

/* ═════════════════════════════════════════════════════════════
   STUDY MODE — Read questions + answers
   ═════════════════════════════════════════════════════════════ */

.study-layout,
.practice-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 0;
}

.study-progress-bar,
.practice-progress-bar,
.fc-progress-bar {
  height: 4px;
  background: var(--bg-gray);
  border-radius: 2px;
  margin: 0 0 16px;
  overflow: hidden;
}

.study-progress-fill,
.practice-progress-fill,
.fc-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0;
}

.study-badge-header { background: #3b82f620 !important; color: #3b82f6 !important; }
.fc-badge-header { background: #f59e0b20 !important; color: #f59e0b !important; }
.practice-badge-header { background: #ef444420 !important; color: #ef4444 !important; }

.study-card, .practice-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 16px;
}

.study-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 14px;
}

.study-badge.mcq {
  background: var(--primary-soft);
  color: var(--primary);
}

.study-badge.tf {
  background: var(--blue-bg);
  color: var(--blue);
}

.study-question, .study-passage {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

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

.study-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-gray);
  font-size: 0.9rem;
  transition: var(--transition);
}

.study-option.correct {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.study-option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}

.study-option.correct .study-option-letter {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.study-option-text { flex: 1; line-height: 1.4; }

.study-correct-icon {
  color: var(--green);
  font-weight: 700;
  font-size: 1.1rem;
}

/* TF Study Items */
.study-tf-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 0.88rem;
}

.study-tf-item.correct {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.study-tf-item.wrong {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.study-tf-letter {
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.study-tf-text { flex: 1; line-height: 1.4; }

.study-tf-label {
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.study-tf-label.correct {
  background: var(--green);
  color: #fff;
}

.study-tf-label.wrong {
  background: var(--red);
  color: #fff;
}

.study-nav, .practice-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* ═════════════════════════════════════════════════════════════
   FLASHCARD MODE — 3D flip cards
   ═════════════════════════════════════════════════════════════ */

.fc-layout {
  max-width: 620px;
  margin: 0 auto;
  padding: 10px 0;
}

.fc-known-counter {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--green);
  padding: 4px 12px;
  background: var(--green-bg);
  border-radius: var(--radius-full);
}

.practice-score-display {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 12px;
  background: var(--bg-gray);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.fc-content {
  perspective: 1000px;
  min-height: 300px;
  margin-bottom: 20px;
}

.fc-card {
  position: relative;
  width: 100%;
  min-height: 300px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius);
}

.fc-card.flipped {
  transform: rotateY(180deg);
}

.fc-front, .fc-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--border);
  background: var(--bg-white);
  overflow-y: auto;
}

.fc-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-color: var(--green-border);
}

.fc-type {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 14px;
  width: fit-content;
}

.fc-type.mcq { background: var(--primary-soft); color: var(--primary); }
.fc-type.tf { background: var(--blue-bg); color: var(--blue); }

.fc-question {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 14px;
  flex: 1;
}

.fc-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 16px;
  animation: pulse 2s ease infinite;
}

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

.fc-statements {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fc-stmt {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.fc-options-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fc-opt-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 6px 0;
}

.fc-correct-answer {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green);
  text-align: center;
  padding: 20px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-answer-item {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.fc-answer-item.correct { color: var(--green); background: var(--green-bg); }
.fc-answer-item.wrong { color: var(--red); background: var(--red-bg); }

.fc-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.fc-btn {
  padding: 14px 32px;
  font-size: 0.95rem;
  font-weight: 700;
  border: 2px solid;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.25s ease;
  flex: 1;
  max-width: 200px;
}

.fc-btn.known {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}

.fc-btn.known:hover {
  background: var(--green);
  color: #fff;
}

.fc-btn.unknown {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
}

.fc-btn.unknown:hover {
  background: var(--red);
  color: #fff;
}

.fc-btn.reset {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  max-width: 250px;
}

.fc-done {
  text-align: center;
  padding: 40px 20px;
}

.fc-done-icon { font-size: 4rem; margin-bottom: 16px; }
.fc-done h2 { color: var(--green); margin-bottom: 8px; }
.fc-done p { color: var(--text-muted); margin-bottom: 20px; }

/* ═════════════════════════════════════════════════════════════
   PRACTICE MODE — Instant feedback
   ═════════════════════════════════════════════════════════════ */

.practice-options, .practice-statements {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.practice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-gray);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.practice-option.clickable {
  cursor: pointer;
}

.practice-option.clickable:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  transform: translateX(4px);
}

.practice-option.correct {
  border-color: var(--green);
  background: var(--green-bg);
  animation: flashCorrect 0.5s ease;
}

.practice-option.wrong {
  border-color: var(--red);
  background: var(--red-bg);
  animation: flashWrong 0.5s ease;
}

.practice-option.disabled { cursor: default; }

.practice-wrong-icon {
  color: var(--red);
  font-weight: 700;
  font-size: 1.1rem;
}

@keyframes flashCorrect {
  0% { transform: scale(1); }
  30% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes flashWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.practice-tf-stmt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 0.88rem;
  transition: all 0.3s ease;
  flex-wrap: wrap;
}

.practice-tf-stmt.correct {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.practice-tf-stmt.wrong {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.practice-tf-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
  align-items: center;
}

.practice-result {
  font-weight: 700;
  font-size: 0.82rem;
}

.practice-result.correct { color: var(--green); }
.practice-result.wrong { color: var(--red); }

.practice-correct-label {
  font-size: 0.78rem;
  color: var(--green);
  font-weight: 600;
}

/* ═════════════════════════════════════════════════════════════
   REVIEW TF STATEMENTS
   ═════════════════════════════════════════════════════════════ */

.review-tf-statement {
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  margin: 4px 0;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.review-tf-statement.correct { background: var(--green-bg); }
.review-tf-statement.wrong { background: var(--red-bg); }

.review-tf-label { font-weight: 600; margin-right: 4px; }

.review-tf-answer {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.78rem;
}

.review-passage-short {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
}

/* ═════════════════════════════════════════════════════════════
   MODE-SPECIFIC RESPONSIVE
   ═════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .mode-cards { grid-template-columns: repeat(3, 1fr); }
  .fc-card { min-height: 250px; }
  .fc-btn { padding: 12px 20px; font-size: 0.88rem; }
  .study-card, .practice-card { padding: 20px 16px; }
}

@media (max-width: 500px) {
  .mode-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .mode-card { padding: 12px 8px; }
  .mode-icon { font-size: 1.4rem; }
  .mode-name { font-size: 0.78rem; }
  .mode-desc { font-size: 0.65rem; }
  .fc-actions { flex-direction: column; align-items: center; }
  .fc-btn { max-width: 100%; width: 100%; }
}
