:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #8b93a3;
  --accent: #7c8cff;
  --accent-2: #a78bfa;
  --good: #34d399;
  --bad: #f87171;
  --radius: 18px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(124, 140, 255, .14), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(167, 139, 250, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 720px; margin: 0 auto; padding: 24px 16px 64px; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 40px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 14px;
}

/* Screens */
.screen { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { margin-bottom: 40px; }
h1 {
  font-family: var(--serif); font-weight: 500; font-size: clamp(40px, 8vw, 60px);
  line-height: 1.02; letter-spacing: -.02em; margin: 0 0 16px;
}
h1 em { font-style: italic; color: var(--accent); }
h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); max-width: 52ch; }
.error-text { color: var(--bad); }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); border-radius: 12px; padding: 12px 20px;
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { border-color: #3a4150; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0d12; }
.btn.primary:hover { background: #8f9cff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
kbd {
  font: 11px var(--sans); opacity: .6; border: 1px solid currentColor; border-radius: 5px;
  padding: 1px 5px; margin-left: 6px;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Set list */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.set-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.set-item {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}
.set-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.set-info { flex: 1; min-width: 0; }
.set-title { font-weight: 600; }
.set-meta { color: var(--muted); font-size: 13px; }
.mini-bar { width: 90px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.mini-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.set-arrow { color: var(--muted); }
.empty { color: var(--muted); padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Learn */
.learn-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.learn-title { flex: 1; display: flex; align-items: center; gap: 10px; justify-content: center; min-width: 0; }
.set-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: rgba(124, 140, 255, .15); color: var(--accent);
}
.pill.master { background: rgba(167, 139, 250, .15); color: var(--accent-2); }
.pct { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 28px; }
.bar-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 32px; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6);
}
.card.good { animation: pulse-good .5s; }
.card.bad { animation: shake .4s; }
@keyframes pulse-good { 50% { border-color: var(--good); box-shadow: 0 0 0 4px rgba(52, 211, 153, .15); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.prompt {
  font-family: var(--serif); font-size: clamp(28px, 6vw, 40px); line-height: 1.15;
  margin: 12px 0 28px; letter-spacing: -.01em; word-break: break-word;
}

.answer {
  width: 100%; font: 500 20px var(--sans); color: var(--text);
  background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 16px 18px; outline: none;
  transition: border-color .15s;
}
.answer:focus { border-color: var(--accent); }
.form-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }

.feedback { margin-top: 4px; }
.fb-title { font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.fb-title.good { color: var(--good); }
.fb-title.bad { color: var(--bad); }
.fb-body { display: grid; gap: 8px; }
.fb-row { padding: 12px 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.fb-row small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.fb-row.yours { border-color: rgba(248, 113, 113, .4); }
.fb-row.yours span { text-decoration: line-through; text-decoration-color: rgba(248, 113, 113, .6); }
.fb-row.correct { border-color: rgba(52, 211, 153, .5); font-weight: 600; font-size: 18px; }

/* Subset tracker */
.tracker { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.pip { display: flex; gap: 3px; padding: 6px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.pip.current { border-color: var(--accent); }
.pip i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.pip i.on { background: var(--good); }

/* Checkpoint / complete */
.center-block { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 20px; }
.center-block .muted { margin: 0 0 8px; }
.badge {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 28px;
  background: rgba(52, 211, 153, .12); color: var(--good); border: 1px solid rgba(52, 211, 153, .35);
}
.badge.big {
  width: 88px; height: 88px; font-size: 40px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0;
}
.word-list {
  list-style: none; padding: 0; margin: 4px 0 16px; width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: left;
}
.word-list li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 18px; border-top: 1px solid var(--line); }
.word-list li:first-child { border-top: 0; }
.word-list b { font-weight: 600; }
.word-list span { color: var(--muted); text-align: right; }
.saved-note { color: var(--muted); font-size: 13px; margin: 0; }

@media (max-width: 520px) {
  .card { padding: 22px; }
  .learn-head .btn { padding: 8px 10px; }
  .mini-bar { width: 56px; }
}

.btn.icon { padding: 6px 10px; font-size: 16px; line-height: 1; }
.top-actions { display: flex; gap: 6px; }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.fb-head .fb-title { margin-bottom: 0; }
.btn.hear { padding: 6px 12px; font-size: 13px; }

/* Accent keys */
.accents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.accent-key {
  font: 500 16px var(--sans); color: var(--text); cursor: pointer;
  min-width: 38px; height: 38px; padding: 0 8px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background .12s, border-color .12s, transform .08s;
}
.accent-key:hover { border-color: var(--accent); background: #252a35; }
.accent-key:active { transform: scale(.92); }
@media (max-width: 520px) { .accent-key { min-width: 34px; height: 36px; } }
