/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

/* ─── Theme ──────────────────────────────────────────── */
:root {
  --bg:        #0d0f14;
  --surface:   #161b27;
  --surface-2: #1e2535;
  --border:    #2a3347;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --accent:    #6366f1;
  --correct:   #22c55e;
  --wrong:     #ef4444;
  --u: #6b7280;
  --s: #3b82f6;
  --r: #f59e0b;
  --m: #10b981;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ─── Screens ────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ─── Home ───────────────────────────────────────────── */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 16px) 20px 12px;
  border-bottom: 1px solid var(--border);
}
.home-header h1 { font-size: 1.25rem; font-weight: 700; }

.home-buttons {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px;
  justify-content: center;
}

.mode-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
}
.mode-btn:active { transform: scale(0.98); background: var(--surface-2); }

.mode-icon { font-size: 2rem; }
.mode-title { font-size: 1.3rem; font-weight: 700; }
.mode-sub { font-size: 0.85rem; color: var(--muted); }

/* ─── Settings ───────────────────────────────────────── */
.settings-body {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field-label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
  width: 100%;
  outline: none;
}
.field-input:focus { border-color: var(--accent); }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* ─── Nav header ─────────────────────────────────────── */
.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-header h2 { font-size: 1rem; font-weight: 600; }

.back-btn, .icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.icon-btn {
  font-size: 1.7rem;
  padding: 6px 10px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.back-btn:active, .icon-btn:active { background: var(--surface-2); }

.progress-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ─── Progress bar ───────────────────────────────────── */
.progress-bar-wrap {
  height: 3px;
  background: var(--surface-2);
  flex-shrink: 0;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
  width: 0%;
}

/* ─── Status badge ───────────────────────────────────── */
.status-badge {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}
.status-badge.u { background: var(--u); color: #fff; }
.status-badge.s { background: var(--s); color: #fff; }
.status-badge.r { background: var(--r); color: #000; }
.status-badge.m { background: var(--m); color: #000; }

/* ─── Vocab card ─────────────────────────────────────── */
.card-scene {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  perspective: 1200px;
}

.card {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 3 / 4;
  cursor: pointer;
  position: relative;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 12px;
}
.card-back { transform: rotateY(180deg); }

.card-dutch {
  font-size: 3rem;
  font-weight: 800;
  text-align: center;
  color: var(--text);
  white-space: nowrap;
  width: 100%;
}

.card-tap-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 12px;
}

.card-english {
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.card-example {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  line-height: 1.5;
}

.card-category {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 20px;
}

/* Card swipe animation */
@keyframes swipe-right {
  to { transform: translateX(120%) rotate(15deg); opacity: 0; }
}
@keyframes swipe-left {
  to { transform: translateX(-120%) rotate(-15deg); opacity: 0; }
}
.card.exit-right .card-inner { animation: swipe-right 0.35s forwards; }
.card.exit-left .card-inner { animation: swipe-left 0.35s forwards; }

/* ─── Answer buttons ─────────────────────────────────── */
.answer-buttons {
  display: flex;
  gap: 16px;
  padding: 16px 20px calc(var(--safe-bot) + 16px);
  flex-shrink: 0;
}
.swipe-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--border);
  padding: 4px;
  flex-shrink: 0;
}

.answer-btn {
  flex: 1;
  padding: 16px;
  border-radius: 14px;
  border: 2px solid;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
.answer-btn:active { transform: scale(0.96); }

.answer-btn.correct {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--correct);
  color: var(--correct);
}
.answer-btn.wrong {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--wrong);
  color: var(--wrong);
}

/* ─── Summary ────────────────────────────────────────── */
.summary-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 24px;
  text-align: center;
}
.summary-wrap h2 { font-size: 1.5rem; font-weight: 700; }
.summary-wrap p { color: var(--muted); font-size: 0.95rem; }

.score-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text);
}

.pass-fail { font-size: 1.1rem; font-weight: 600; }
.pass-fail.pass { color: var(--correct); }
.pass-fail.fail { color: var(--wrong); }

.changes-list {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  max-width: 320px;
}

.resume-info { color: var(--muted); }

/* ─── Buttons ────────────────────────────────────────── */
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 15px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 200px;
  transition: opacity 0.15s, transform 0.1s;
}
.primary-btn:active { opacity: 0.85; transform: scale(0.98); }

.secondary-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 200px;
  transition: background 0.15s, transform 0.1s;
}
.secondary-btn:active { background: var(--surface-2); transform: scale(0.98); }

/* ─── KNM ────────────────────────────────────────────── */
.knm-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.knm-question {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.knm-glossary {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 4px;
  line-height: 1.5;
  min-height: 1.2em;
}

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

.option-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  text-align: left;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.option-btn:active { transform: scale(0.99); }

.option-key {
  font-weight: 800;
  color: var(--accent);
  min-width: 20px;
  flex-shrink: 0;
}

.option-btn.selected-correct {
  border-color: var(--correct);
  background: rgba(34, 197, 94, 0.1);
}
.option-btn.selected-wrong {
  border-color: var(--wrong);
  background: rgba(239, 68, 68, 0.1);
}
.option-btn.reveal-correct {
  border-color: var(--correct);
  background: rgba(34, 197, 94, 0.06);
}
.option-btn[disabled] {
  cursor: default;
  opacity: 0.7;
}
.option-btn.selected-correct, .option-btn.reveal-correct { opacity: 1; }
.option-btn.selected-wrong { opacity: 1; }

.next-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s, transform 0.1s;
}
.next-btn:active { opacity: 0.85; transform: scale(0.98); }
.next-btn.hidden { display: none; }

.topic-badge {
  font-size: 0.7rem;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

/* ─── Loading ────────────────────────────────────────── */
.loading-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
