:root {
  --bg: #11131a;
  --surface: #1a1d27;
  --surface2: #232736;
  --border: #2f3446;
  --text: #e8e9ef;
  --muted: #9aa0b4;
  --accent: #f2b544;
  --accent-ink: #11131a;
  --easy: #4cc38a;
  --medium: #f2b544;
  --hard: #f06a6a;
  --link: #8ab4ff;
  --extra-bg: #1e2433;
  --radius: 14px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface2: #eef0f5;
  --border: #dcdfe8;
  --text: #1b1d26;
  --muted: #5d6275;
  --accent: #c98a12;
  --accent-ink: #ffffff;
  --easy: #1f9a63;
  --medium: #b57a08;
  --hard: #cf3e3e;
  --link: #2f5fd0;
  --extra-bg: #eef3ff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: 980px; margin: 0 auto;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 40px; height: 40px; border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.title { font-weight: 700; font-size: 18px; }
.sub { color: var(--muted); font-size: 13px; }
.theme-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  width: 40px; height: 40px; font-size: 18px;
}

.tabs {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; max-width: 980px; margin: 0 auto;
  border-bottom: 1px solid var(--border); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 7px 14px; color: var(--muted); white-space: nowrap; font-weight: 600; font-size: 14px;
}
.tabs button.active { background: var(--accent); color: var(--accent-ink); }

main { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }
.foot { max-width: 980px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 13px; }

h2 { font-size: 24px; margin: 4px 0 6px; }
h3 { font-size: 18px; margin: 0 0 6px; }
h4 { font-size: 16px; margin: 20px 0 6px; }
.muted { color: var(--muted); }
.lead { font-size: 17px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle;
}
.lv-easy { color: var(--easy); } .lv-medium { color: var(--medium); } .lv-hard { color: var(--hard); }
.kind { color: var(--muted); }
.extra-pill { color: var(--link); }
.tag { font-size: 11px; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.tag.hard { color: var(--hard); border-color: var(--hard); }

table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface2); font-weight: 700; }
table.raci td:not(:first-child), table.raci th:not(:first-child) { text-align: center; }
td.a { color: var(--hard); font-weight: 800; }
td.r { font-weight: 800; }

.callout { background: var(--surface2); border-radius: 10px; padding: 10px 12px; }
.mnemonic { background: var(--surface2); border-radius: 10px; padding: 10px 12px; color: var(--accent); }
.extra { background: var(--extra-bg); border: 1px dashed var(--link); border-radius: 10px; padding: 10px 12px; margin: 12px 0; font-size: 14px; }
.quote { font-style: italic; color: var(--muted); }
ul, ol { padding-left: 22px; }
li { margin: 3px 0; }

.btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; font-weight: 600; font-size: 14px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.good { border-color: var(--easy); color: var(--easy); }
.btn.bad { border-color: var(--hard); color: var(--hard); }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

select {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font: inherit; font-size: 14px; max-width: 100%;
}

/* topic list */
.topic { cursor: pointer; transition: border-color .15s; }
.topic:hover { border-color: var(--accent); }
.topic .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.done-mark { color: var(--easy); font-weight: 700; font-size: 13px; }
.back { background: none; border: none; color: var(--link); padding: 0; margin-bottom: 10px; font-weight: 600; }

/* progress bar */
.bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* flashcards */
.flash {
  min-height: 230px; display: grid; place-items: center; text-align: center; padding: 26px 20px;
  cursor: pointer; user-select: none; font-size: 19px;
}
.flash .side { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.flash.flipped { border-color: var(--accent); }
.flash .ans { font-size: 17px; }

/* quiz */
.opt {
  display: block; width: 100%; text-align: left; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; margin: 8px 0; font-size: 15px;
}
.opt.correct { border-color: var(--easy); background: color-mix(in srgb, var(--easy) 16%, var(--surface2)); }
.opt.wrong { border-color: var(--hard); background: color-mix(in srgb, var(--hard) 16%, var(--surface2)); }
.explain { margin-top: 8px; color: var(--muted); font-size: 14px; }

/* scenarios */
.prompt { white-space: pre-wrap; background: var(--surface2); border-radius: 10px; padding: 12px; font-size: 15px; }
textarea {
  width: 100%; min-height: 140px; margin-top: 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; font: inherit; font-size: 15px; resize: vertical;
}
.model { border-left: 0; background: var(--surface2); border-radius: 10px; padding: 12px; margin-top: 10px; }

/* cheat grid */
.cheat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 720px) { .cheat { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .cheat { grid-template-columns: 1fr; } }
.cheat div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.cheat b { display: block; color: var(--accent); margin-bottom: 4px; }

.tree {
  background: var(--surface2); border-radius: 10px; padding: 12px; overflow-x: auto;
  font: 13px/1.5 ui-monospace, Consolas, monospace; margin: 8px 0;
}
.stat { font-size: 28px; font-weight: 800; }
.schedule li { margin: 8px 0; }
.time { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
