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

:root {
  --bg: #f5f5f7;
  --card-bg: rgba(255,255,255,0.8);
  --card-border: rgba(0,0,0,0.06);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #0071e3;
  --accent-light: #e8f2ff;
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --nav-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-top: calc(var(--nav-height) + 12px);
  padding-bottom: 20px;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ===== Typography ===== */
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
h3 { font-size: 1.15rem; font-weight: 600; line-height: 1.4; }
p { color: var(--text-secondary); line-height: 1.7; }

/* ===== Container ===== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(245,245,247,0.72);
  border-bottom: 0.5px solid var(--card-border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
}

.page-header h1 {
  font-size: 1.15rem;
  text-align: left;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-header .subtitle {
  display: none;
}

/* ===== Hamburger Button ===== */
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
  transition: background 0.15s;
}
.hamburger-btn:active {
  background: rgba(0,0,0,0.06);
}
.hamburger-btn svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

/* ===== Slide-Out Navigation Menu ===== */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.nav-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.nav-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--bg);
  z-index: 1002;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding: calc(var(--nav-height) + 16px) 0 40px 0;
  overflow-y: auto;
  box-shadow: -4px 0 30px rgba(0,0,0,0.1);
}
.nav-menu.open {
  transform: translateX(0);
}

.nav-menu a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s;
}
.nav-menu a:active {
  background: rgba(0,0,0,0.04);
}
.nav-menu a.active {
  color: var(--accent);
  background: var(--accent-light);
}
.nav-menu a svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  flex-shrink: 0;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:active {
  transform: scale(0.98);
}

.card-gradient {
  color: white;
  border: none;
}

.card-gradient p,
.card-gradient .text-secondary {
  color: rgba(255,255,255,0.85);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.animate-in {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }
.animate-in:nth-child(7) { animation-delay: 0.35s; }
.animate-in:nth-child(8) { animation-delay: 0.4s; }

/* ===== Section Titles ===== */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 28px 0 14px;
  letter-spacing: -0.01em;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ===== Quick Links Grid ===== */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-link {
  text-decoration: none;
  color: var(--text);
  background: var(--card-bg);
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-link:active {
  transform: scale(0.96);
}

.quick-link .icon {
  font-size: 1.8rem;
}

.quick-link .label {
  font-weight: 600;
  font-size: 0.9rem;
}

.quick-link .desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
  background: var(--accent);
}

.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }

/* ===== Accordion ===== */
.accordion {
  margin-bottom: 12px;
}

.accordion-header {
  width: 100%;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.accordion-header::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(-45deg);
  transition: transform 0.3s ease;
  flex-shrink: 0;
  margin-left: 12px;
}

.accordion-header.active::after {
  transform: rotate(45deg);
}

.accordion-header.active {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
  background: var(--card-bg);
  border: 0.5px solid var(--card-border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.accordion-body.open {
  max-height: 3000px;
}

.accordion-content {
  padding: 20px;
}

.accordion-content p {
  margin-bottom: 12px;
}

.accordion-content ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.accordion-content li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.accordion-content li strong {
  color: var(--text);
}

/* ===== Math Blocks ===== */
.math-block {
  background: rgba(0,113,227,0.04);
  border: 1px solid rgba(0,113,227,0.12);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.math-inline {
  background: rgba(0,113,227,0.04);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ===== Definition / Theorem Boxes ===== */
.def-box {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px;
  margin: 14px 0;
}

.def-box .def-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}

.theorem-box {
  border-left: 4px solid #764ba2;
  background: rgba(118,75,162,0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px;
  margin: 14px 0;
}

.theorem-box .theorem-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #764ba2;
  margin-bottom: 6px;
}

.warning-box {
  border-left: 4px solid var(--warning);
  background: rgba(255,159,10,0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px;
  margin: 14px 0;
}

.warning-box .warning-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--warning);
  margin-bottom: 6px;
}

.tip-box {
  border-left: 4px solid var(--success);
  background: rgba(48,209,88,0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px;
  margin: 14px 0;
}

.tip-box .tip-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--success);
  margin-bottom: 6px;
}

/* ===== Flashcard ===== */
.flashcard-container {
  perspective: 1000px;
  height: 340px;
  margin: 20px 0;
  touch-action: pan-y;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

.flashcard-front {
  background: white;
  border: 0.5px solid var(--card-border);
}

.flashcard-back {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: rotateY(180deg);
}

.flashcard-back p {
  color: rgba(255,255,255,0.9);
}

.flashcard-category {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}

.flashcard-back .flashcard-category {
  color: rgba(255,255,255,0.7);
}

.flashcard-question {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
}

.flashcard-answer {
  font-size: 1rem;
  line-height: 1.6;
}

.flashcard-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 16px;
}

.flashcard-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.fc-btn {
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.fc-btn:active {
  transform: scale(0.92);
}

.fc-btn.wrong {
  background: #fff2f0;
  color: var(--danger);
}

.fc-btn.flip-btn {
  background: white;
  color: var(--accent);
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
}

.fc-btn.correct {
  background: #f0fff4;
  color: var(--success);
}

.flashcard-progress {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 12px;
}

.flashcard-swipe-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 8px;
  opacity: 0.7;
}

/* ===== Category Chips ===== */
.chip-group {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chip-group::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--card-border);
  background: white;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  color: var(--text-secondary);
}

.chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== Quiz ===== */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quiz-timer {
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.quiz-question-num {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.quiz-question {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.5;
  color: var(--text);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  width: 100%;
  padding: 16px 18px;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: white;
  font-family: var(--font);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
  line-height: 1.5;
}

.quiz-option:active {
  transform: scale(0.98);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.quiz-option.correct {
  border-color: var(--success);
  background: rgba(48,209,88,0.1);
}

.quiz-option.incorrect {
  border-color: var(--danger);
  background: rgba(255,59,48,0.06);
}

.quiz-option.show-correct {
  border-color: var(--success);
  background: rgba(48,209,88,0.1);
}

.quiz-explanation {
  background: rgba(0,113,227,0.04);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}

.quiz-nav {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-secondary {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--card-border);
  color: var(--text);
}

/* ===== Results ===== */
.results-score {
  font-size: 3.5rem;
  font-weight: 700;
  text-align: center;
  margin: 16px 0 8px;
}

.results-label {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 24px;
}

.results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-item {
  text-align: center;
  padding: 12px;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}

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

/* ===== Formula Cards ===== */
.formula-card {
  background: white;
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.formula-card .formula-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.formula-card .formula-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 10px;
  line-height: 1.5;
}

/* ===== Tip Cards ===== */
.tip-card {
  background: white;
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.tip-card .tip-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.tip-card h3 {
  margin-bottom: 8px;
}

/* ===== Hero ===== */
.hero {
  padding: 40px 0 24px;
  text-align: center;
}

.hero h1 {
  font-size: 2.2rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hero p {
  font-size: 1rem;
  max-width: 300px;
  margin: 0 auto;
}

/* ===== Misc ===== */
.spacer { height: 24px; }
.spacer-sm { height: 12px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: rgba(48,209,88,0.12); color: #248a3d; }
.badge-purple { background: rgba(118,75,162,0.1); color: #764ba2; }
.badge-orange { background: rgba(255,159,10,0.12); color: #c77600; }

.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* ===== Scroll indicator ===== */
.scroll-indicator {
  width: 40px;
  height: 5px;
  background: rgba(0,0,0,0.1);
  border-radius: 3px;
  margin: 0 auto 16px;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-state .emoji {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ===== Divider ===== */
.divider {
  height: 0.5px;
  background: var(--card-border);
  margin: 20px 0;
}

/* ===== Quiz Start Screen ===== */
.quiz-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.config-option {
  background: white;
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.config-option label {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 8px;
}

.config-option select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--card-border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  background: white;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ===== Daily Tip ===== */
.daily-tip {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}

.daily-tip .tip-title {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
  margin-bottom: 8px;
}

.daily-tip p {
  color: rgba(255,255,255,0.9);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ===== KaTeX overrides for mobile ===== */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

.katex {
  font-size: 1.05em !important;
}

/* ===== Media Queries ===== */
@media (min-width: 481px) {
  .container {
    max-width: 560px;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 720px;
    padding: 0 32px;
  }

  h1 { font-size: 2.4rem; }
  .hero h1 { font-size: 2.8rem; }

  .quick-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

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

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

  .accordion-content {
    padding: 24px 32px;
  }

  .math-block {
    padding: 20px;
  }

  .katex {
    font-size: 1.1em !important;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 860px;
  }

  .accordion-content {
    padding: 28px 40px;
  }

  .flashcard-container {
    height: 400px;
    max-width: 600px;
    margin: 24px auto;
  }

  .bottom-nav a {
    font-size: 0.72rem;
    gap: 4px;
  }

  .bottom-nav a svg {
    width: 26px;
    height: 26px;
  }
}

/* Summary read badge */
.summary-check {
  display: inline-block;
  color: var(--success);
  margin-left: 8px;
  font-size: 0.85em;
}

/* Summary section title */
.teil-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 24px 0 12px;
  padding-left: 4px;
  letter-spacing: 0.02em;
}

.teil-title:first-of-type {
  margin-top: 8px;
}

/* Link banner */
.link-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(88,86,214,0.08), rgba(88,86,214,0.04));
  border-radius: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 16px;
  transition: background 0.2s;
}
.link-banner:hover {
  background: linear-gradient(135deg, rgba(88,86,214,0.14), rgba(88,86,214,0.08));
}

/* Data management card */
.data-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px 20px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.data-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.data-btns {
  display: flex;
  gap: 10px;
}
.data-btns button {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.data-btns button:active {
  transform: scale(0.97);
}

/* ===== Dark Mode Toggle ===== */
.theme-toggle {
  background: none;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-secondary);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:active { transform: scale(0.9); }

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --bg: #1c1c1e;
  --card-bg: rgba(44,44,46,0.8);
  --card-border: rgba(255,255,255,0.1);
  --text: #f5f5f7;
  --text-secondary: #98989d;
  --accent: #4facfe;
  --accent-light: rgba(79,172,254,0.15);
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --border: rgba(255,255,255,0.12);
}

[data-theme="dark"] .page-header {
  background: rgba(28,28,30,0.72);
}

[data-theme="dark"] .nav-menu {
  background: #1c1c1e;
  box-shadow: -4px 0 30px rgba(0,0,0,0.4);
}
[data-theme="dark"] .nav-menu a:active {
  background: rgba(255,255,255,0.06);
}
[data-theme="dark"] .nav-menu a.active {
  background: rgba(0,113,227,0.15);
}
[data-theme="dark"] .nav-overlay {
  background: rgba(0,0,0,0.5);
}
[data-theme="dark"] .hamburger-btn:active {
  background: rgba(255,255,255,0.08);
}

[data-theme="dark"] .flashcard-front,
[data-theme="dark"] .chip,
[data-theme="dark"] .quiz-option,
[data-theme="dark"] .formula-card,
[data-theme="dark"] .tip-card,
[data-theme="dark"] .config-option,
[data-theme="dark"] .config-option select {
  background: #2c2c2e;
  color: var(--text);
}

[data-theme="dark"] .fc-btn.wrong {
  background: rgba(255,69,58,0.15);
}

[data-theme="dark"] .fc-btn.flip-btn {
  background: #2c2c2e;
}

[data-theme="dark"] .fc-btn.correct {
  background: rgba(48,209,88,0.15);
}

[data-theme="dark"] .stat-item {
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .scroll-indicator {
  background: rgba(255,255,255,0.1);
}

[data-theme="dark"] .progress-bar {
  background: rgba(255,255,255,0.08);
}

[data-theme="dark"] .quiz-explanation {
  background: rgba(79,172,254,0.08);
}

[data-theme="dark"] .quiz-option.correct {
  background: rgba(48,209,88,0.15);
}

[data-theme="dark"] .quiz-option.incorrect {
  background: rgba(255,69,58,0.1);
}

[data-theme="dark"] .quiz-option.show-correct {
  background: rgba(48,209,88,0.15);
}

[data-theme="dark"] .btn-secondary {
  background: rgba(79,172,254,0.12);
}

[data-theme="dark"] .link-banner {
  background: linear-gradient(135deg, rgba(79,172,254,0.12), rgba(79,172,254,0.06));
}

[data-theme="dark"] .link-banner:hover {
  background: linear-gradient(135deg, rgba(79,172,254,0.2), rgba(79,172,254,0.1));
}

[data-theme="dark"] .badge-green { background: rgba(48,209,88,0.15); color: #30d158; }
[data-theme="dark"] .badge-purple { background: rgba(118,75,162,0.2); color: #b07cd8; }
[data-theme="dark"] .badge-orange { background: rgba(255,159,10,0.15); color: #ff9f0a; }

[data-theme="dark"] .data-btns button {
  background: #2c2c2e;
  border-color: rgba(255,255,255,0.12);
}

[data-theme="dark"] .config-option select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398989d' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="dark"] .math-block {
  background: rgba(79,172,254,0.06);
  border-color: rgba(79,172,254,0.15);
}

[data-theme="dark"] .def-box {
  background: rgba(79,172,254,0.04);
  border-color: rgba(79,172,254,0.12);
}

[data-theme="dark"] .theorem-box {
  background: rgba(118,75,162,0.08);
  border-color: rgba(118,75,162,0.2);
}

[data-theme="dark"] .tip-box {
  background: rgba(48,209,88,0.06);
  border-color: rgba(48,209,88,0.15);
}

[data-theme="dark"] .warning-box {
  background: rgba(255,159,10,0.06);
  border-color: rgba(255,159,10,0.15);
}

[data-theme="dark"] .daily-tip {
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

/* ===== Motivationsnachrichten für Klaudia ===== */
.milestone-msg {
  background: var(--gradient-4);
  color: #1d1d1f;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 12px;
  animation: milestoneIn 0.5s ease;
}

@keyframes milestoneIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.res-motivation {
  margin-top: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
  border: 1px solid rgba(102,126,234,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  text-align: center;
}

[data-theme="dark"] .milestone-msg {
  color: #1d1d1f;
}

[data-theme="dark"] .res-motivation {
  background: linear-gradient(135deg, rgba(102,126,234,0.15) 0%, rgba(118,75,162,0.15) 100%);
  border-color: rgba(102,126,234,0.3);
}
