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

:root {
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --text: #1e1b4b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #ffffff;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

/* ── Index page ── */

.page-header {
  background: var(--primary);
  color: var(--white);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-header .subtitle { font-size: 0.9rem; opacity: 0.8; margin-top: 0.25rem; }

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.lesson-item:active { transform: scale(0.98); }

.lesson-icon {
  width: 44px; height: 44px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}

.lesson-info { flex: 1; }
.lesson-title { font-weight: 600; font-size: 1rem; }
.lesson-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.lesson-arrow { color: var(--muted); font-size: 1.4rem; }

/* ── Flashcard page ── */

.flashcard-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.fc-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.back-btn {
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.fc-header span {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background 0.15s;
}

.icon-btn.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.fc-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.card-wrapper {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 3/2;
  perspective: 1000px;
}

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

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

.card-front, .card-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  box-shadow: var(--shadow);
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

.card-front { background: var(--white); color: var(--text); }
.card-back  { background: var(--white); color: var(--text); transform: rotateY(180deg); }

.fc-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem;
  background: var(--white);
  border-top: 1px solid var(--border);
}

.nav-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 48px; height: 48px;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-btn:active { background: var(--primary-light); }

.progress {
  font-size: 0.95rem;
  color: var(--muted);
  min-width: 60px;
  text-align: center;
}

/* ── Responsive tweaks ── */

@media (max-width: 400px) {
  .card-wrapper { aspect-ratio: 4/3; }
  .page-header h1 { font-size: 1.3rem; }
}
