/* ===== ANATMATH — colorful Hebrew RTL math learning site ===== */

:root {
  --pink: #ff6b9d;
  --pink-light: #ffc1d8;
  --purple: #a05cf6;
  --purple-light: #d9c3ff;
  --blue: #4cc9f0;
  --blue-light: #c4f1ff;
  --teal: #06d6a0;
  --teal-light: #b8f3dc;
  --yellow: #ffd166;
  --yellow-light: #fff1c2;
  --orange: #ff9f43;
  --orange-light: #ffd8b3;
  --red: #ef476f;
  --indigo: #6366f1;

  --bg: #fff7fb;
  --surface: #ffffff;
  --ink: #1f1147;
  --ink-soft: #4b3b7c;
  --muted: #8a85a9;
  --line: #ece4f8;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 28px;
  --shadow-sm: 0 2px 8px rgba(160, 92, 246, 0.08);
  --shadow: 0 6px 24px rgba(160, 92, 246, 0.14);
  --shadow-lg: 0 18px 48px rgba(160, 92, 246, 0.22);

  --gradient-1: linear-gradient(135deg, #ff6b9d 0%, #a05cf6 100%);
  --gradient-2: linear-gradient(135deg, #4cc9f0 0%, #6366f1 100%);
  --gradient-3: linear-gradient(135deg, #ffd166 0%, #ff9f43 100%);
  --gradient-4: linear-gradient(135deg, #06d6a0 0%, #4cc9f0 100%);
  --gradient-5: linear-gradient(135deg, #ef476f 0%, #ffd166 100%);
  --gradient-6: linear-gradient(135deg, #a05cf6 0%, #6366f1 100%);
  --gradient-7: linear-gradient(135deg, #ff9f43 0%, #ef476f 100%);
  --gradient-8: linear-gradient(135deg, #6366f1 0%, #06d6a0 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Heebo', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255, 107, 157, 0.10), transparent 40%),
    radial-gradient(circle at 88% 20%, rgba(76, 201, 240, 0.10), transparent 40%),
    radial-gradient(circle at 50% 95%, rgba(6, 214, 160, 0.08), transparent 50%);
}

/* ========= AUTH GATE ========= */
.auth-gate[hidden] { display: none !important; }
.auth-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient-1);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.3), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.2), transparent 50%),
    var(--gradient-1);
  z-index: 999;
  padding: 20px;
}

.auth-card {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: pop 0.5s cubic-bezier(.34,1.56,.64,1);
}

@keyframes pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.auth-icon {
  font-size: 56px;
  margin-bottom: 8px;
  animation: bounce 2s infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.auth-card h1 {
  font-size: 26px;
  margin: 0 0 8px;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.auth-card input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}
.auth-card input:focus {
  outline: none;
  border-color: var(--purple);
}
.auth-card button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--gradient-1);
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.auth-card button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.auth-error { color: var(--red); margin: 10px 0 0; font-size: 14px; }

/* ========= LAYOUT ========= */
.app { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-size: 22px;
  margin: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
}

.brand-emoji {
  display: inline-block;
  font-size: 28px;
  -webkit-text-fill-color: initial;
  animation: wiggle 3s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

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

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--purple-light); transform: translateY(-1px); }

/* ========= HERO ========= */
.hero {
  padding: 48px 24px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero h2 {
  font-size: clamp(28px, 5vw, 44px);
  margin: 0 0 12px;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.hero-sub {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

.hero-floats {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.hero-float {
  position: absolute;
  font-size: 28px;
  opacity: 0.7;
  animation: float 6s ease-in-out infinite;
}
.hero-float:nth-child(1) { top: 20%; left: 8%; animation-delay: 0s; }
.hero-float:nth-child(2) { top: 60%; left: 15%; animation-delay: 1s; }
.hero-float:nth-child(3) { top: 30%; right: 10%; animation-delay: 2s; }
.hero-float:nth-child(4) { top: 70%; right: 18%; animation-delay: 1.5s; }
.hero-float:nth-child(5) { top: 15%; left: 50%; animation-delay: 0.5s; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-20px) rotate(10deg); }
}

/* ========= ANAT'S PERSONAL DASHBOARD ========= */
.anat-card {
  max-width: 1100px;
  margin: 0 auto 32px;
  padding: 28px;
  background: linear-gradient(135deg, #fff 0%, #fff5fb 60%, #f3e8ff 100%);
  border-radius: var(--radius-lg);
  border: 3px solid transparent;
  background-clip: padding-box;
  box-shadow: var(--shadow);
  display: flex;
  gap: 26px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.anat-card::before {
  content: '';
  position: absolute;
  inset: -3px;
  background: var(--gradient-1);
  border-radius: var(--radius-lg);
  z-index: -1;
  opacity: 0.65;
  margin: -3px;
  filter: blur(0);
}
.anat-card::after {
  content: '🌸 🦄 ✨ 🌙 🐱 🎵 ⭐ 🌷';
  position: absolute;
  top: -10px; left: 10px;
  font-size: 18px;
  opacity: 0.18;
  letter-spacing: 8px;
  pointer-events: none;
}

.anat-avatar {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  background: white;
  border-radius: 50%;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(160, 92, 246, 0.2);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.anat-avatar svg { width: 100%; height: 100%; }
.anat-avatar::before {
  content: '✨';
  position: absolute;
  top: -8px; right: -6px;
  font-size: 26px;
  animation: twinkle 2.5s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0); opacity: 1; }
  50% { transform: scale(1.3) rotate(15deg); opacity: 0.7; }
}

.anat-body { flex: 1; min-width: 0; }
.anat-hello {
  font-size: clamp(20px, 3.5vw, 28px);
  font-weight: 900;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
  line-height: 1.2;
}
.anat-encourage {
  color: var(--ink-soft);
  font-size: 15px;
  margin-bottom: 16px;
  font-weight: 600;
}
.anat-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.anat-stat {
  background: white;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.anat-stat .num {
  display: block;
  font-size: 22px;
  font-weight: 900;
  color: var(--purple);
  line-height: 1.1;
}
.anat-stat .lbl {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 600;
}

.anat-bar {
  height: 12px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.anat-bar-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(.34,1.56,.64,1);
}

@media (max-width: 640px) {
  .anat-card { flex-direction: column; text-align: center; padding: 22px; }
  .anat-avatar { width: 100px; height: 100px; }
  .anat-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ========= TOPICS TITLE ========= */
.topics-title {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 4px;
}

/* ========= TOPIC GRID (homepage) ========= */
.topics-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.topic-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  border: none;
  text-align: right;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s;
  box-shadow: var(--shadow-sm);
}
.topic-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--card-gradient, var(--gradient-1));
  opacity: 0.08;
  transition: opacity 0.25s;
  z-index: 0;
}
.topic-card::after {
  content: '';
  position: absolute;
  top: -40px;
  left: -40px;
  width: 120px; height: 120px;
  background: var(--card-gradient, var(--gradient-1));
  opacity: 0.18;
  border-radius: 50%;
  filter: blur(20px);
  z-index: 0;
}
.topic-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-lg);
}
.topic-card:hover::before { opacity: 0.14; }

.topic-card > * { position: relative; z-index: 1; }

.topic-badge {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 2;
  background: white;
  color: var(--ink);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  letter-spacing: 0.3px;
}
.topic-badge.done {
  background: var(--teal);
  color: white;
}
.topic-badge.progress {
  background: var(--purple);
  color: white;
}

.topic-emoji {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.15));
}

.topic-num {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-gradient, var(--gradient-1));
  color: white;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.topic-card h3 {
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--ink);
}

.topic-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

/* ========= TOPIC PAGE ========= */
.topic-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px;
}

.topic-header {
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  background: var(--card-gradient, var(--gradient-1));
  color: white;
  margin-bottom: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.topic-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.3), transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(255,255,255,0.2), transparent 50%);
}
.topic-header > * { position: relative; }

.topic-header .topic-emoji { font-size: 72px; margin: 0; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));}
.topic-header h1 { margin: 8px 0 6px; font-size: clamp(26px, 4vw, 38px); }
.topic-header p { margin: 0; opacity: 0.95; font-size: 17px; }

.back-btn {
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 20px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.2s;
}
.back-btn:hover { background: var(--purple-light); border-color: var(--purple); }

/* ========= LESSON BLOCKS ========= */
.lesson-block {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border-right: 6px solid var(--accent, var(--purple));
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lesson-block h2 {
  margin: 0 0 16px;
  font-size: 26px;
  display: flex; align-items: center; gap: 10px;
  color: var(--ink);
}
.lesson-block h2 .emoji { font-size: 32px; }

.lesson-block h3 {
  font-size: 20px;
  margin: 20px 0 10px;
  color: var(--accent, var(--purple));
}

.lesson-block p {
  line-height: 1.75;
  font-size: 16px;
  color: var(--ink-soft);
  margin: 8px 0;
}

.lesson-block ul, .lesson-block ol {
  line-height: 1.85;
  font-size: 16px;
  color: var(--ink-soft);
  padding-right: 22px;
}
.lesson-block li { margin-bottom: 6px; }
.lesson-block strong { color: var(--ink); }
.lesson-block em { font-style: normal; background: var(--yellow-light); padding: 0 6px; border-radius: 6px; color: var(--ink); }

/* ========= CALLOUT BOXES ========= */
.callout {
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
  display: flex; gap: 14px;
  align-items: flex-start;
  border-right: 5px solid;
  line-height: 1.7;
}
.callout-icon { font-size: 28px; flex-shrink: 0; }
.callout-body { flex: 1; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }

.callout.tip { background: #fff8e1; border-color: var(--yellow); color: #6b4f00; }
.callout.note { background: #e3f2fd; border-color: var(--blue); color: #1a3a5f; }
.callout.warn { background: #fde2e7; border-color: var(--red); color: #7a1a30; }
.callout.success { background: #e3f9ed; border-color: var(--teal); color: #0a5a3c; }
.callout.example { background: #f3e8ff; border-color: var(--purple); color: #3b1c5f; }

.callout strong { color: inherit; }

/* ========= EXAMPLE / FORMULA ========= */
.formula {
  background: linear-gradient(135deg, #fff 0%, #fff5fb 100%);
  border: 2px dashed var(--pink);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 14px 0;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  direction: ltr;
  font-family: 'Cambria Math', 'Times New Roman', serif;
  letter-spacing: 0.5px;
}

.formula-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  direction: rtl;
  font-family: inherit;
  letter-spacing: 0;
}

.math {
  display: inline-block;
  direction: ltr;
  font-family: 'Cambria Math', 'Times New Roman', serif;
  background: #f6f0ff;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  color: var(--purple);
}

.example-card {
  background: linear-gradient(135deg, #f3e8ff 0%, #fff 100%);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
  border-right: 5px solid var(--purple);
}
.example-card h4 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--purple);
  display: flex; align-items: center; gap: 8px;
}

/* ========= INTERACTIVE WIDGETS ========= */
.widget {
  background: linear-gradient(135deg, #ffffff 0%, #faf6ff 100%);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  box-shadow: 0 4px 16px rgba(160, 92, 246, 0.08);
  border: 2px solid var(--line);
}
.widget-title {
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}

.widget label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 8px 0 4px;
}

.widget input[type="number"],
.widget input[type="text"],
.widget select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: white;
}
.widget input:focus, .widget select:focus {
  outline: none;
  border-color: var(--purple);
}

.widget input[type="range"] {
  width: 100%;
  margin: 8px 0;
  accent-color: var(--purple);
}

.widget-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}
.widget-row > * { flex: 1; min-width: 100px; }

.widget-result {
  background: var(--gradient-1);
  color: white;
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-top: 12px;
  direction: ltr;
}
.widget-result .label { font-size: 12px; opacity: 0.85; display: block; margin-bottom: 2px; direction: rtl;}

.btn {
  background: var(--gradient-1);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 2px solid var(--line); }
.btn.secondary:hover { background: var(--purple-light); border-color: var(--purple); }

.btn-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap;}

/* ========= QUIZ ========= */
.quiz {
  background: linear-gradient(135deg, #fff8e1 0%, #fff 100%);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  border: 2px solid var(--yellow);
  box-shadow: 0 4px 16px rgba(255, 209, 102, 0.18);
}
.quiz-title {
  font-weight: 800;
  font-size: 17px;
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}

.quiz-q { font-weight: 700; margin: 0 0 12px; font-size: 16px; line-height: 1.6;}

.quiz-options { display: grid; gap: 8px; }

.quiz-option {
  background: white;
  border: 2px solid var(--line);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  text-align: right;
  transition: all 0.15s;
  font-weight: 600;
  color: var(--ink);
}
.quiz-option:hover { border-color: var(--purple); background: var(--purple-light); }
.quiz-option.correct {
  background: var(--teal-light);
  border-color: var(--teal);
  color: #0a5a3c;
}
.quiz-option.wrong {
  background: #fde2e7;
  border-color: var(--red);
  color: #7a1a30;
}
.quiz-feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.ok { background: var(--teal-light); color: #0a5a3c; }
.quiz-feedback.no { background: #fde2e7; color: #7a1a30; }

/* ========= GEOMETRY VIZ ========= */
.geo-viz {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin: 14px 0;
  text-align: center;
  border: 2px solid var(--line);
}
.geo-viz svg { max-width: 100%; height: auto; }
.geo-viz-caption {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  direction: rtl;
}

/* ========= NUMBER LINE ========= */
.number-line {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  border: 2px solid var(--line);
}

/* ========= TABLE ========= */
.lesson-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 14px 0;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.lesson-table th {
  background: var(--gradient-1);
  color: white;
  padding: 12px;
  font-weight: 700;
  text-align: center;
}
.lesson-table td {
  padding: 12px;
  text-align: center;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.lesson-table tr:nth-child(even) td { background: #fafafa; }

/* ========= STEPS ========= */
.steps { counter-reset: step; padding: 0; list-style: none; }
.steps li {
  position: relative;
  padding: 14px 60px 14px 16px;
  margin: 10px 0;
  background: #faf6ff;
  border-radius: var(--radius-sm);
  border-right: 4px solid var(--purple);
  counter-increment: step;
  font-size: 15px;
  line-height: 1.6;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  right: 14px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  background: var(--gradient-1);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 15px;
}

/* ========= NAV TOC ========= */
.toc {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.toc h3 { margin: 0 0 12px; font-size: 16px; color: var(--ink-soft); }
.toc-links {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.toc-link {
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.15s;
  text-decoration: none;
}
.toc-link:hover {
  border-color: var(--accent, var(--purple));
  background: var(--accent, var(--purple));
  color: white;
}

/* ========= NEXT/PREV ========= */
.nav-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0;
  flex-wrap: wrap;
}
.nav-pager .btn { flex: 1; min-width: 140px; }

/* ========= FOOTER ========= */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--muted);
  font-size: 14px;
}

/* ========= RESPONSIVE ========= */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 18px; }
  .hero { padding: 32px 16px 24px; }
  .topics-grid { padding: 8px 16px 32px; }
  .topic-card { padding: 22px 18px; }
  .topic-page { padding: 16px; }
  .lesson-block { padding: 22px 18px; }
  .topic-header { padding: 24px 18px; }
  .formula { font-size: 18px; }
}

/* ========= EXERCISES SECTION ========= */
.exercises-section {
  background: linear-gradient(135deg, #fff5fb 0%, #f3f0ff 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin: 24px 0;
  border: 3px solid var(--purple-light);
  position: relative;
  overflow: hidden;
}
.exercises-section::before {
  content: '✏️📚🎯';
  position: absolute;
  top: -12px; left: -14px;
  font-size: 60px;
  opacity: 0.08;
  letter-spacing: 4px;
  pointer-events: none;
}

.exercises-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.exercises-header h2 {
  margin: 0;
  font-size: 26px;
  color: var(--ink);
  display: flex; align-items: center; gap: 10px;
}

.progress-pill {
  background: white;
  border-radius: 999px;
  padding: 8px 16px 8px 8px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
}
.progress-pill .count { color: var(--purple); }
.progress-bar {
  width: 80px; height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(.34,1.56,.64,1);
}

.exercise-tip {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 18px;
  line-height: 1.6;
}

.reset-progress {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.reset-progress:hover { color: var(--red); border-color: var(--red); }

/* ========= EXERCISE CARD ========= */
.exercise {
  background: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 2px solid var(--line);
  transition: all 0.25s;
  position: relative;
}
.exercise.done {
  background: linear-gradient(135deg, #e3f9ed 0%, #fff 70%);
  border-color: var(--teal);
}
.exercise.done .exercise-q { opacity: 0.7; }
.exercise.done::after {
  content: '✓';
  position: absolute;
  top: 14px; left: 18px;
  width: 28px; height: 28px;
  background: var(--teal);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 16px;
  animation: pop 0.3s ease-out;
}

.exercise-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}

.exercise-num {
  display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--gradient-1);
  color: white;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.exercise-cat {
  display: inline-block;
  background: var(--purple-light);
  color: var(--purple);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.exercise-q {
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  margin: 4px 0 12px;
}
.exercise-q .math {
  background: #f6f0ff;
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--purple);
  direction: ltr;
  display: inline-block;
  font-family: 'Cambria Math', 'Times New Roman', serif;
}

.exercise-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center;
}

.exercise-toggle {
  background: var(--gradient-1);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.exercise-toggle:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.exercise-toggle .chev { transition: transform 0.25s; display: inline-block; }
.exercise-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

.exercise-done-btn {
  background: white;
  color: var(--ink);
  border: 2px solid var(--line);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.exercise-done-btn:hover { border-color: var(--teal); background: var(--teal-light); }
.exercise.done .exercise-done-btn {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}

.exercise-solution {
  margin-top: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #f3e8ff 0%, #fff 100%);
  border-right: 4px solid var(--purple);
  border-radius: var(--radius-sm);
  animation: slideDown 0.3s ease-out;
}
.exercise-solution[hidden] { display: none; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.exercise-solution h4 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--purple);
  display: flex; align-items: center; gap: 8px;
}
.exercise-solution .steps li {
  background: white;
}
.exercise-solution p { margin: 8px 0; font-size: 15px; line-height: 1.7; color: var(--ink-soft); }
.exercise-solution strong { color: var(--ink); }

/* ========= MEME CARD ========= */
.meme {
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin: 22px 0;
  display: flex;
  gap: 18px;
  align-items: center;
  background: var(--meme-bg, var(--gradient-1));
  color: white;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.meme::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  filter: blur(15px);
}
.meme > * { position: relative; }

.meme-img {
  flex-shrink: 0;
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
  font-size: 70px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.meme-img svg { width: 100%; height: 100%; }

.meme-body { flex: 1; }
.meme-pov {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.85;
  margin-bottom: 4px;
}
.meme-caption {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
  margin: 0;
}
.meme-sub {
  font-size: 14px;
  opacity: 0.95;
  margin-top: 6px;
  line-height: 1.5;
}

@media (max-width: 500px) {
  .meme { flex-direction: column; text-align: center; padding: 18px; }
  .meme-img { width: 70px; height: 70px; font-size: 56px; }
}

/* ========= CELEBRATION BANNER ========= */
.anat-celebrate {
  position: relative;
  background: var(--gradient-1);
  color: white;
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 18px;
  box-shadow: 0 12px 30px rgba(255, 107, 157, 0.4);
  overflow: hidden;
  animation: celebrate-in 0.6s cubic-bezier(.34,1.56,.64,1);
}
.anat-celebrate.soft {
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.6s ease;
}
@keyframes celebrate-in {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.anat-celebrate-inner {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
  border-radius: calc(var(--radius) - 4px);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.anat-celebrate-emoji {
  font-size: 44px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
  animation: spin 1.2s ease-in-out infinite alternate;
}
@keyframes spin {
  from { transform: rotate(-15deg) scale(1); }
  to   { transform: rotate(15deg) scale(1.1); }
}
.anat-celebrate-title {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}
.anat-celebrate-sub {
  font-size: 14px;
  opacity: 0.96;
  margin-top: 4px;
}
.anat-celebrate-close {
  margin-right: auto;
  background: rgba(255,255,255,0.25);
  border: none;
  color: white;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  font-family: inherit;
}
.anat-celebrate-close:hover { background: rgba(255,255,255,0.4); }

.anat-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.anat-confetti span {
  position: absolute;
  top: -30px;
  font-size: 22px;
  animation: confetti-fall 3.5s linear infinite;
  animation-delay: var(--d);
}
.anat-confetti span:nth-child(1)  { left: 4%; }
.anat-confetti span:nth-child(2)  { left: 12%; }
.anat-confetti span:nth-child(3)  { left: 20%; }
.anat-confetti span:nth-child(4)  { left: 28%; }
.anat-confetti span:nth-child(5)  { left: 36%; }
.anat-confetti span:nth-child(6)  { left: 44%; }
.anat-confetti span:nth-child(7)  { left: 52%; }
.anat-confetti span:nth-child(8)  { left: 60%; }
.anat-confetti span:nth-child(9)  { left: 68%; }
.anat-confetti span:nth-child(10) { left: 76%; }
.anat-confetti span:nth-child(11) { left: 84%; }
.anat-confetti span:nth-child(12) { left: 92%; }
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(220px) rotate(360deg); opacity: 0; }
}

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

/* prevent flash before auth */
#app[hidden] { display: none !important; }
