:root {
  --bg: #0f1115;
  --card: #171a21;
  --card2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --accent: #4f8cff;
  --ok: #2ecc71;
  --bad: #ff5c5c;
  --warn: #f5b335;
  --radius: 14px;
  font-size: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
.app { max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; min-height: 100dvh; }

h1 { font-size: 1.5rem; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; margin: 20px 0 8px; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 14px 18px; font-size: 1rem; font-weight: 600; cursor: pointer; width: 100%; }
.btn.secondary { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 0; width: auto; padding: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], select { width: 100%; background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-size: 1rem; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: .75rem; color: var(--muted); }

.progress { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
.progress > div { height: 100%; background: var(--accent); transition: width .25s; }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { font-size: .7rem; padding: 3px 8px; border-radius: 99px; background: var(--card2); color: var(--muted);
  border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .03em; }
.tag.retry { color: var(--warn); border-color: var(--warn); }

.stem { font-size: 1.05rem; line-height: 1.55; }
pre { background: #0b0d12; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  overflow-x: auto; font-size: .85rem; line-height: 1.45; margin: 10px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
p code, .opt code, .stem code { background: #0b0d12; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.app pre code.hljs { background: transparent; padding: 0; }  /* .app beats highlight.js's own padding */

.opts { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.opt { text-align: left; background: var(--card2); color: var(--text); border: 2px solid var(--line);
  border-radius: 12px; padding: 13px 14px; font-size: .98rem; line-height: 1.45; cursor: pointer; width: 100%; }
.opt:active { transform: scale(.99); }
.opt pre { margin: 6px 0 0; }
.opt.correct { border-color: var(--ok); background: rgba(46, 204, 113, .12); }
.opt.wrong { border-color: var(--bad); background: rgba(255, 92, 92, .12); }
.opt.dim { opacity: .55; }
.opt:disabled { cursor: default; }

.feedback { margin-top: 14px; border-radius: 12px; padding: 14px; border: 1px solid; }
.feedback.ok { border-color: var(--ok); background: rgba(46, 204, 113, .08); }
.feedback.bad { border-color: var(--bad); background: rgba(255, 92, 92, .08); }
.feedback h3 { margin: 0 0 6px; font-size: 1rem; }
.feedback .refer { margin-top: 8px; font-size: .85rem; color: var(--muted); }

.topic-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.topic-row:last-child { border-bottom: 0; }
.bar { height: 6px; background: var(--card2); border-radius: 99px; overflow: hidden; grid-column: 1 / -1; }
.bar > div { height: 100%; background: var(--accent); }
.bar.weak > div { background: var(--bad); }
.bar.strong > div { background: var(--ok); }
.trend { font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.trend.stronger { color: var(--ok); background: rgba(46,204,113,.15); }
.trend.weaker { color: var(--bad); background: rgba(255,92,92,.15); }
.trend.steady { color: var(--muted); background: var(--card2); }
.trend.new, .trend.untested { color: var(--warn); background: rgba(245,179,53,.15); }

.sticky-bottom { position: sticky; bottom: 0; padding: 12px 0 0; background: linear-gradient(transparent, var(--bg) 30%); }
.sticky-bottom:empty { display: none; }
details { margin-top: 14px; }
details > summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; padding: 12px 14px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; float: right; color: var(--muted); }
details[open] > summary::after { content: "–"; }
details[open] > summary { border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
details[open] > .card { border-radius: 0 0 var(--radius) var(--radius); }
.list { display: flex; flex-direction: column; gap: 8px; }
.err { color: var(--bad); }
.spin { opacity: .6; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
/* phones: wrap long code lines instead of hiding them behind a sideways scroll */
@media (max-width: 639px) { pre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; } }
