/* 过遍 — a study tool you use half-asleep on a phone, so: big targets, calm
   colours, and nothing that moves unless it means something. */
:root {
  --bg: #0e1116;
  --panel: #161b23;
  --line: #232b36;
  --ink: #e6ebf2;
  --dim: #8b97a8;
  --faint: #5d6878;
  --accent: #6ea8fe;      /* the one hue that acts */
  --good: #57b877;
  --bad: #e0685f;
  --warn: #e0b155;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           10px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: #10151c;
  position: sticky; top: 0; z-index: 10;
}
.mark {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-weight: 700; color: #0e1116;
  background: linear-gradient(140deg, #8fc0ff, var(--accent));
}
.titles { margin-right: auto; min-width: 0; }
.titles h1 { margin: 0; font-size: 17px; letter-spacing: .04em; }
.titles p { margin: 0; font-size: 11px; color: var(--faint); white-space: nowrap;
            overflow: hidden; text-overflow: ellipsis; }

select, textarea, input, button { font: inherit; font-family: inherit; }
select {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 9px; max-width: 42vw;
}
.tab {
  background: none; border: 1px solid transparent; color: var(--dim);
  padding: 7px 11px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.tab.on { background: var(--accent); color: #0e1116; font-weight: 600; }

main { padding: 16px max(14px, env(safe-area-inset-right))
                 max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
       max-width: 720px; margin: 0 auto; }

/* ---------- the drill ---------- */
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.counter { margin: 6px 0 14px; font-size: 12px; color: var(--faint);
           font-variant-numeric: tabular-nums; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 18px;
}
.front { font-size: 21px; font-weight: 600; line-height: 1.45; white-space: pre-wrap; }
.back  { font-size: 17px; color: #cfd8e4; white-space: pre-wrap; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

.ask .prompt { font-size: 13px; color: var(--dim); margin: 20px 0 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > button { flex: 1 1 0; min-width: 92px; }

.conf, .grade, .primary {
  min-height: 46px; padding: 10px 12px; cursor: pointer;
  border-radius: 11px; border: 1px solid var(--line);
  background: #1d242e; color: var(--ink); transition: filter .15s ease;
}
.conf:active, .grade:active, .primary:active { filter: brightness(1.35); }
.grade.again { border-color: #5a3330; color: #f0a49d; }
.grade.easy  { border-color: #2f5240; color: #a5dcbb; }
.primary { background: var(--accent); color: #0e1116; font-weight: 600; border-color: transparent; }

.link { background: none; border: none; color: var(--faint); font-size: 12px;
        text-decoration: underline; cursor: pointer; padding: 10px 0 0; }
.said { font-size: 12px; color: var(--faint); margin: 14px 0 8px; }
.grades { margin-top: 4px; }
.hint { font-size: 12px; color: var(--faint); margin: 10px 0 0; min-height: 1.2em; }

.empty { text-align: center; padding: 56px 12px; }
.empty .big { font-size: 19px; margin: 0 0 6px; }
.sub { color: var(--dim); font-size: 13px; }

/* ---------- panels / calibration ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.panel h2 { margin: 0 0 4px; font-size: 15px; }
textarea {
  width: 100%; margin: 10px 0; padding: 12px; resize: vertical;
  background: #10151c; color: var(--ink);
  border: 1px solid var(--line); border-radius: 11px;
}
code { background: #10151c; padding: 1px 5px; border-radius: 5px; font-size: .9em; }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { flex: 1 1 120px; background: #10151c; border: 1px solid var(--line);
        border-radius: 11px; padding: 12px; }
.stat .n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--faint); }

/* Confidence vs reality: two bars per row, so the gap is a shape you see
   rather than a number you have to interpret. */
.cal-row { margin: 12px 0; }
.cal-row .lbl { display: flex; justify-content: space-between; font-size: 12px;
                color: var(--dim); margin-bottom: 5px; }
.bars { display: grid; gap: 3px; }
.bar { height: 9px; border-radius: 9px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 9px; }
.bar.said > span   { background: var(--faint); }
.bar.actual > span { background: var(--accent); }

.verdict { padding: 12px 14px; border-radius: 11px; font-size: 14px; margin-bottom: 14px; }
.verdict.overconfident  { background: #33231f; color: #f0b8ae; border: 1px solid #5a3330; }
.verdict.underconfident { background: #1e2a33; color: #a9cfe6; border: 1px solid #2f4a5a; }
.verdict.calibrated     { background: #1c2a22; color: #a5dcbb; border: 1px solid #2f5240; }
.verdict.not_enough     { background: #10151c; color: var(--dim); border: 1px solid var(--line); }

.spot { border-top: 1px solid var(--line); padding: 11px 0; }
.spot:first-child { border-top: none; }
.spot .q { font-weight: 600; }
.spot .a { color: var(--dim); font-size: 14px; }
.tag { font-size: 10px; padding: 2px 7px; border-radius: 999px;
       background: #33231f; color: #f0b8ae; margin-left: 6px; white-space: nowrap; }

.cardrow { border-top: 1px solid var(--line); padding: 10px 0; display: flex; gap: 10px; }
.cardrow:first-child { border-top: none; }
.cardrow .txt { flex: 1; min-width: 0; }
.cardrow .f { font-weight: 600; }
.cardrow .b { color: var(--dim); font-size: 13px; }
.cardrow .meta { font-size: 11px; color: var(--faint); white-space: nowrap;
                 font-variant-numeric: tabular-nums; }
.del { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 18px;
       padding: 0 4px; align-self: start; }

.foot { text-align: center; font-size: 11px; color: #3f4855;
        padding: 8px 0 max(10px, env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Repeatedly failing the same card while sure is the strongest signal on the
   page — it gets its own weight rather than blending into the confidence tag. */
.tag.times { background: #3a2c14; color: #e7c98a; }
