:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --subtle: #f4f4f5;
  --ink: #18181b;
  --muted: #63636b;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #2557d6;
  --accent-soft: #edf2fd;
  --on-ink: #fafafa;
  --good: #17784a;
  --good-soft: #e8f5ee;
  --bad: #b8321f;
  --bad-soft: #fbecea;
  --radius: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #18181b;
    --subtle: #1f1f23;
    --ink: #ececee;
    --muted: #9b9ba3;
    --line: #2a2a2f;
    --line-strong: #3a3a40;
    --accent: #7b9cff;
    --accent-soft: #1b2440;
    --on-ink: #111113;
    --good: #52c48b;
    --good-soft: #142a1f;
    --bad: #ff8a76;
    --bad-soft: #2f1915;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Geist", -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* Nav */
.nav { display: flex; align-items: center; height: 64px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.logo-mark { width: 16px; height: 16px; border-radius: 4px; background: var(--ink); }

/* Hero: copy left, the tool itself on the right */
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  padding: 40px 0 64px;
}
@media (min-width: 900px) {
  .hero { grid-template-columns: 5fr 6fr; gap: 64px; padding: 72px 0 96px; align-items: start; }
}

h1, h2 { font-weight: 600; letter-spacing: -0.03em; margin: 0; }
h1 { font-size: clamp(36px, 5vw, 52px); line-height: 1.05; max-width: 12ch; }
.lede { font-size: 17px; color: var(--muted); max-width: 40ch; margin: 20px 0 40px; }

.facts { margin: 0; display: grid; gap: 0; max-width: 380px; border-top: 1px solid var(--line); }
.facts div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-weight: 500; }
.facts dd { margin: 0; color: var(--muted); }
/* On phones the tool matters more than the list; keep it within the first screen. */
@media (max-width: 899px) {
  .facts { display: none; }
  .lede { margin-bottom: 8px; }
}

/* Tool panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 20px;
  box-shadow: 0 1px 0 rgba(24, 24, 27, 0.03), 0 12px 32px -12px rgba(24, 24, 27, 0.10);
}

.dropzone {
  display: flex; align-items: center; gap: 14px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 16px; cursor: pointer;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 26px; color: var(--accent); }
.drop-title { display: block; font-weight: 500; }
.drop-sub { display: block; font-size: 13px; color: var(--muted); }

.field { display: grid; gap: 8px; }
.field label { font-weight: 500; font-size: 14px; }
textarea {
  width: 100%; resize: vertical; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 12px 14px; min-height: 160px;
}
textarea::placeholder { color: var(--muted); }
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.hint { font-size: 13px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500; border-radius: var(--radius); padding: 10px 16px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 88%, var(--bg)); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-full { width: 100%; padding: 12px 16px; }
.btn-icon { padding: 9px 11px; }
.btn i { font-size: 17px; }

.error { color: var(--bad); background: var(--bad-soft); padding: 10px 14px; border-radius: var(--radius); margin: 0; font-size: 14px; }
.banner { background: var(--accent-soft); color: var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 24px; font-size: 14px; }

/* Results */
.results { max-width: 760px; padding: 48px 0 96px; border-top: 1px solid var(--line); }
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.result-head h2 { font-size: 28px; line-height: 1.2; }

.tabs { display: flex; gap: 24px; margin: 24px 0 28px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  font: inherit; font-weight: 500; background: none; border: none; color: var(--muted);
  padding: 10px 0; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.count { color: var(--muted); font-weight: 400; margin-left: 2px; }

.summary { margin: 0 0 28px; padding: 0; list-style: none; display: grid; gap: 14px; }
.summary li { padding-left: 18px; position: relative; max-width: 65ch; }
.summary li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 6px; height: 1px; background: var(--muted); }

/* Flashcards */
.flashcard {
  width: 100%; min-height: 280px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px 28px; font: inherit; color: var(--ink); cursor: pointer; text-align: center;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.flashcard:hover { border-color: var(--line-strong); }
.flashcard.flipped { background: var(--accent-soft); border-color: var(--accent); }
.fc-side { font-size: 13px; color: var(--muted); font-weight: 500; }
.flashcard.flipped .fc-side { color: var(--accent); }
.fc-text { font-size: clamp(19px, 3vw, 23px); line-height: 1.4; font-weight: 500; letter-spacing: -0.01em; max-width: 36ch; }
.fc-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.fc-nav { display: flex; align-items: center; gap: 12px; }
.fc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Quiz */
.q-progress { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.q-text { font-size: 20px; line-height: 1.4; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 20px; max-width: 40ch; }
.options { display: grid; gap: 8px; }
.option {
  font: inherit; text-align: left; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.option:hover:not(:disabled) { border-color: var(--ink); }
.option:disabled { cursor: default; }
.option.correct { background: var(--good-soft); border-color: var(--good); }
.option.wrong { background: var(--bad-soft); border-color: var(--bad); }
.explanation { margin: 16px 0 0; padding: 12px 16px; background: var(--subtle); border-radius: var(--radius); font-size: 15px; max-width: 65ch; }
.q-next { margin-top: 20px; }
.score { padding: 16px 0; }
.score-num { font-size: 56px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; margin: 0 0 12px; }
.score p { margin: 0 0 20px; }

/* Loading skeleton: same shape as the result it turns into */
.skeleton { display: grid; gap: 14px; margin-top: 16px; }
.sk { display: block; height: 14px; border-radius: 6px; background: var(--subtle); }
.sk-title { height: 30px; width: 55%; margin-bottom: 6px; }
.sk-tabs { height: 20px; width: 40%; margin-bottom: 14px; }
.sk-80 { width: 80%; } .sk-90 { width: 90%; } .sk-60 { width: 60%; }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: pulse 1.4s ease-in-out infinite; }
  .results:not([hidden]) { animation: rise .4s var(--ease); }
}
@keyframes pulse { 50% { opacity: .5; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Footer */
.footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-top: 24px; padding-bottom: 40px; color: var(--muted); font-size: 13px;
}
.footer span:first-child { color: var(--ink); font-weight: 500; }
