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

/* ── Same CSS variables as openprep.css ──────── */
:root {
  --black: #0f0f0f;
  --ink: #1a1a1a;
  --mid: #444;
  --muted: #888;
  --border: #e8e8e8;
  --surface: #f7f7f5;
  --white: #ffffff;
  --green: #16a34a;
  --amber: #d97706;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", sans-serif;
}

html {
  scroll-behavior: smooth;
}
body {
  font-family: var(--sans);
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
}

/* ── NAV — matches site nav exactly ─────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 58px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  /* backdrop-filter: blur(12px); */
}
.nav-logo {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--black);
  text-decoration: none;
}
.nav-logo span {
  font-style: italic;
}
.nav-back {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
}
.nav-back:hover {
  color: var(--ink);
}

/* ── LAYOUT ──────────────────────────────────── */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── LOADING / ERROR ─────────────────────────── */
.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── ANIMATIONS ──────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.anim-1 {
  animation: fadeUp 0.4s 0s ease both;
}
.anim-2 {
  animation: fadeUp 0.4s 0.06s ease both;
}
.anim-3 {
  animation: fadeUp 0.4s 0.1s ease both;
}
.anim-4 {
  animation: fadeUp 0.4s 0.14s ease both;
}
.anim-5 {
  animation: fadeUp 0.4s 0.18s ease both;
}

/* ── PAGE HEADER ─────────────────────────────── */
.page-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.page-title {
  font-family: var(--serif);
  font-size: 32px;
  color: var(--black);
  margin-bottom: 6px;
  line-height: 1.1;
}
.page-title em {
  font-style: italic;
}
.page-subtitle {
  font-size: 14px;
  color: var(--muted);
  font-weight: 300;
  margin-bottom: 28px;
}

/* ── PROGRESS STATS ──────────────────────────── */
.progress-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.prog-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  transition: box-shadow 0.2s;
}
.prog-box:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.prog-val {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.prog-val.green {
  color: var(--green);
}
.prog-val.amber {
  color: var(--amber);
}
.prog-val.muted {
  color: var(--muted);
}
.prog-lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── MASTERY BAR ─────────────────────────────── */
.mastery-bar-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 28px;
}
.mastery-bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
}
.mastery-bar-label {
  color: var(--mid);
  font-weight: 500;
}
.mastery-bar-pct {
  color: var(--black);
  font-weight: 600;
}
.bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--black);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

/* ── FILTER TABS + COUNTER ───────────────────── */
.card-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-counter-text {
  font-size: 13px;
  color: var(--muted);
}
.card-counter-text strong {
  color: var(--ink);
}
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-tab {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--sans);
}
.filter-tab.active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.filter-tab:hover:not(.active) {
  border-color: #aaa;
  color: var(--ink);
}

/* ── 3D FLIP CARD ────────────────────────────── */
.card-scene {
  perspective: 1200px;
  margin-bottom: 20px;
  cursor: pointer;
  user-select: none;
}
.card-3d {
  position: relative;
  width: 100%;
  height: 240px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-3d.flipped {
  transform: rotateY(180deg);
}
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
.card-front-face {
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
.card-back-face {
  background: var(--black);
  transform: rotateY(180deg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}
.card-face-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.card-front-face .card-face-label {
  color: var(--muted);
}
.card-back-face .card-face-label {
  color: rgba(255, 255, 255, 0.4);
}
.card-word {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.2;
  color: var(--black);
  margin-bottom: 12px;
}
.card-back-face .card-word {
  color: var(--white);
  font-size: 22px;
  line-height: 1.5;
}
.card-hint {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.card-hint svg {
  width: 13px;
  height: 13px;
}
.card-status-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
}
.badge-mastered {
  background: #f0fdf4;
  color: var(--green);
  border: 1px solid #bbf7d0;
}
.badge-in-progress {
  background: #fffbeb;
  color: var(--amber);
  border: 1px solid #fde68a;
}
.badge-new {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── ACTION BUTTONS ──────────────────────────── */
.card-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  pointer-events: none;
}
.card-actions.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.action-btn {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn-again {
  background: var(--white);
  color: var(--mid);
}
.btn-again:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: #fffbeb;
}
.btn-mastered {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.btn-mastered:hover {
  opacity: 0.88;
}

/* ── PREV / NEXT ─────────────────────────────── */
.card-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 0;
}
.nav-arrow {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--mid);
}
.nav-arrow:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--ink);
}
.nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.nav-arrow svg {
  width: 16px;
  height: 16px;
}
.nav-pos {
  font-size: 13px;
  color: var(--muted);
  min-width: 60px;
  text-align: center;
}

/* ── DONE STATE ──────────────────────────────── */
.done-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 24px;
}
.done-icon {
  font-size: 36px;
  margin-bottom: 14px;
}
.done-title {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--black);
  margin-bottom: 8px;
}
.done-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 22px;
  line-height: 1.6;
}
.done-btn {
  padding: 11px 24px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.done-btn:hover {
  opacity: 0.85;
}

/* ── WORD LIST ───────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.word-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.word-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}
.word-row:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border-color: #ccc;
}
.word-row.active {
  border-color: var(--black);
}
.word-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-mastered {
  background: var(--green);
}
.dot-in-progress {
  background: var(--amber);
}
.dot-new {
  background: var(--border);
}
.word-front {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--black);
  flex: 1;
}
.word-back {
  font-size: 12px;
  color: var(--muted);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.word-badge {
  flex-shrink: 0;
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 540px) {
  nav {
    padding: 0 16px;
  }
  .page {
    padding: 28px 14px 60px;
  }
  .card-3d {
    height: 200px;
  }
  .card-word {
    font-size: 22px;
  }
  .word-back {
    display: none;
  }
}
