/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
button { border: none; background: none; cursor: pointer; font-family: inherit; }

/* ── Tokens ─────────────────────────────────────── */
:root {
  --bg:        #FAFAF8;
  --surface:   #FFFFFF;
  --border:    #E4E4E7;
  --border-2:  #F0F0EE;
  --text:      #18181B;
  --text-2:    #52525B;
  --text-3:    #A1A1AA;
  --pink:      #FFD6E0;
  --cat:       #C9B99E;
  --r:         12px;
  --r-sm:      8px;
  --r-lg:      16px;
  --font:      'Geist', system-ui, -apple-system, sans-serif;
  --w:         780px;
  --ease:      200ms ease;
}

/* ── Base ─────────────────────────────────────── */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────── */
.wrap {
  max-width: var(--w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Exam list ─────────────────────────────────── */
.exam-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}
.exam-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-2);
  transition: opacity var(--ease);
}
.exam-row:first-child { border-top: 1px solid var(--border-2); }
.exam-row.done { opacity: 0.35; }
.exam-row-num {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  width: 20px;
  flex-shrink: 0;
}
.exam-row-date {
  font-size: 12px;
  color: var(--text-3);
  width: 68px;
  flex-shrink: 0;
}
.exam-row-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  color: var(--text);
}
.exam-row-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.exam-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: #F4F4F5;
  color: #71717A;
}
.exam-badge.today-badge {
  background: #FEF3C7;
  color: #92400E;
  font-weight: 500;
}
.exam-badge.done-badge {
  background: transparent;
  color: var(--text-3);
}
.exam-row-cta {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
}
.exam-row-cta:hover { opacity: 0.75; }
@media (max-width: 500px) {
  .wrap { padding: 0 16px; }

  /* Exam list */
  .exam-row { gap: 10px; padding: 12px 0; }
  .exam-row-date { display: none; }
  .exam-row-name { font-size: 13px; }
  .exam-row-num { width: 16px; }

  /* Format grid */
  .format-grid { grid-template-columns: 1fr !important; }

  /* Topic accordion — bigger tap target */
  .topic-head { padding: 13px 14px; min-height: 48px; }

  /* Flashcard */
  .card-face { padding: 32px 20px; }
  .card-inner { min-height: 260px; }

  /* Nav buttons — larger touch target */
  .btn-nav { width: 48px; height: 48px; }

  /* Bottom bar */
  .bottom-bar { padding: 12px 16px; }

  /* Welcome popup */
  #welcome-title { font-size: 19px; }
  #welcome-body { font-size: 12px; padding: 0 20px; }
  #welcome-btn { width: calc(100% - 32px); margin: 0 16px 20px; }
}

/* ── Format grid ─────────────────────────────────── */
.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ── Topic accordion ─────────────────────────────── */
.topic {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.topic-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  user-select: none;
}
.topic-head:hover { background: #FAFAF8; }
.topic-body {
  display: none;
  padding: 2px 16px 16px 34px;
  border-top: 1px solid var(--border-2);
}
.topic.open .topic-body { display: block; }
.topic-chevron {
  font-size: 14px;
  color: var(--text-3);
  transition: transform var(--ease);
  line-height: 1;
}
.topic.open .topic-chevron { transform: rotate(90deg); }

/* ── Flashcard flip ─────────────────────────────── */
.card-scene { perspective: 1200px; width: 100%; }
.card-inner {
  position: relative;
  width: 100%;
  min-height: 290px;
  transform-style: preserve-3d;
  transition: transform 0.48s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.card-inner.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  min-height: 290px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--r-lg);
  padding: 44px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}
.card-front {
  background: var(--surface);
  border: 1px solid var(--border);
}
.card-back {
  background: var(--text);
  border: 1px solid var(--text);
  transform: rotateY(180deg);
}

/* ── Nav button ─────────────────────────────────── */
.btn-nav {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background var(--ease);
}
.btn-nav:hover:not(:disabled) { background: var(--border); }
.btn-nav:disabled { opacity: 0.28; cursor: not-allowed; }

/* ── Fixed bottom bar ─────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 14px 24px;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

/* ── Back link ─────────────────────────────────── */
.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-3);
  transition: color var(--ease);
  margin-bottom: 32px;
}
.back:hover { color: var(--text); }


/* ── Progress dots ─────────────────────────────── */
.dots {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--ease);
}
.dot.active { background: var(--text); }

/* ── Welcome popup ─────────────────────────────── */
#welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
  animation: fade-in 0.35s ease;
}
#welcome-overlay.fade-out {
  animation: fade-out 0.3s ease forwards;
}
#welcome-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  max-width: 380px;
  width: 100%;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.12);
}
#welcome-art {
  width: 100%;
  height: 100px;
  background: #FFF5F7;
  border-bottom: 1px solid var(--border-2);
  overflow: hidden;
  position: relative;
}
#welcome-art svg {
  width: 100%;
  height: 100%;
}
#welcome-hey {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 24px 0 8px;
}
#welcome-title {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.25;
  padding: 0 28px;
  margin-bottom: 14px;
}
#welcome-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
  padding: 0 28px;
  margin-bottom: 28px;
}
#welcome-btn {
  display: block;
  width: calc(100% - 48px);
  margin: 0 24px 24px;
  background: #18181B;
  color: #FAFAF8;
  border-radius: 12px;
  padding: 13px 0;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: .01em;
  cursor: pointer;
  transition: opacity var(--ease);
}
#welcome-btn:hover { opacity: 0.82; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
