/* 掐表 — a stopwatch you look at for half a second at a time, mid-question.
   So: the clock is the only large thing, colour is reserved for pace state
   (ahead / tight / behind), and the accent is a warm neutral rather than a hue —
   otherwise the button competes with the one signal that matters. */
:root {
  --bg: #12110f;
  --panel: #1b1917;
  --line: #2b2823;
  --ink: #edeae4;
  --dim: #9c958a;
  --faint: #6b6459;
  --accent: #d8c9a8;      /* the tap target, and nothing else */
  --good: #57b877;
  --bad: #e0685f;
  --warn: #e0b155;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { 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; }
b { font-weight: 600; }

/* ---------- 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: #171512;
  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: #17150f;
  background: linear-gradient(140deg, #efe3c6, var(--accent));
}
.titles { margin-right: auto; min-width: 0; }
.titles h1 { margin: 0; font-size: 17px; letter-spacing: .06em; }
.titles p { margin: 0; font-size: 11px; color: var(--faint); white-space: nowrap;
            overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 6px; }
.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(--panel); border-color: var(--line); color: var(--ink); }
@media (max-width: 460px) { .tabs { flex-basis: 100%; } .tabs .tab { flex: 1 1 0; } }

main { padding: 14px max(12px, env(safe-area-inset-right))
                24px max(12px, env(safe-area-inset-left)); max-width: 760px; margin: 0 auto; }
input, button, select { font: inherit; font-family: inherit; }

/* ---------- panels & forms ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.panel h2 { margin: 0 0 6px; font-size: 15px; }
.sub { color: var(--dim); font-size: 13px; }
.tiny { font-size: 12px; color: var(--faint); }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; background: #100f0d; color: var(--ink);
  border: 1px solid var(--line); border-radius: 11px;
}
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid3 .field input { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row > button { flex: 1 1 0; min-width: 92px; }
.primary, .ghost {
  min-height: 46px; padding: 10px 14px; cursor: pointer;
  border-radius: 11px; border: 1px solid var(--line);
  background: #221f1b; color: var(--ink);
}
.primary { background: var(--accent); color: #17150f; font-weight: 700; border-color: transparent; }
.primary.big { width: 100%; margin-top: 8px; min-height: 52px; font-size: 17px; }
.primary:active, .ghost:active { filter: brightness(1.25); }
.resume { border-color: var(--warn); }

/* ---------- the running screen ---------- */
/* Fills the viewport and doesn't scroll: mid-paper, a page that can move under
   your thumb is a page that loses a tap. */
.view.run {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--bg); z-index: 20;
}
.runtop { text-align: center; padding-top: 6px; }
.qcount { font-size: 15px; color: var(--dim); font-variant-numeric: tabular-nums; }
.qcount span:first-child { font-size: 22px; color: var(--ink); font-weight: 600; }
.qcount .of { margin-left: 4px; }
.clock {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(56px, 21vw, 104px); line-height: 1.05; letter-spacing: -.02em;
  margin: 4px 0 0;
}
.clocklabel { font-size: 12px; color: var(--faint); letter-spacing: .12em; }
.clock.tight { color: var(--warn); }
.clock.over  { color: var(--bad); }

.pacebar { margin: 18px 2px 0; }
.track {
  position: relative; height: 10px; border-radius: 999px;
  background: #221f1b; border: 1px solid var(--line); overflow: hidden;
}
/* The plan is a hairline you're measured against, not a bar that fills. */
.track .plan { position: absolute; inset: 0; width: 0; border-right: 2px dashed var(--faint); }
.track .you  { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--good);
               transition: width .25s linear, background .25s ease; border-radius: 999px; }
.track .you.behind { background: var(--bad); }
.track .you.tight  { background: var(--warn); }

.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.chip {
  font-size: 12.5px; padding: 5px 10px; border-radius: 999px;
  background: #221f1b; border: 1px solid var(--line); color: var(--dim);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip.good   { color: var(--good); border-color: #2c4433; }
.chip.behind { color: var(--bad);  border-color: #4a2f2c; }
.chip.warn   { color: var(--warn); border-color: #4a3d24; }

.tap {
  flex: 1 1 auto; margin: 16px 0; min-height: 140px; width: 100%;
  border: none; border-radius: 22px; cursor: pointer;
  background: var(--accent); color: #17150f;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.tap:active { filter: brightness(.88); }
.tap.flagged { background: var(--warn); }
.tapbig { font-size: 30px; font-weight: 700; letter-spacing: .04em; }
.tapsub { font-size: 13px; opacity: .72; }
.runfoot { display: flex; gap: 10px; }
.runfoot > button { flex: 1 1 0; }
.runfoot .ghost.on { border-color: var(--warn); color: var(--warn); }

/* ---------- results ---------- */
.verdict { padding: 14px 15px; border-radius: 12px; margin-bottom: 14px; font-size: 14.5px;
           background: var(--panel); border: 1px solid var(--line); }
.verdict b { display: block; font-size: 16px; margin-bottom: 4px; }
.verdict.bad  { border-color: #4a2f2c; background: #251b19; }
.verdict.good { border-color: #2c4433; background: #182219; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 460px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat { background: #100f0d; border: 1px solid var(--line); border-radius: 11px;
        padding: 10px; text-align: center; }
.stat .n { font-size: 20px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--faint); margin-top: 2px; }

.chart { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
.axis { font-size: 10px; fill: var(--faint); font-family: var(--mono); }

.qrow { display: flex; align-items: center; gap: 10px; padding: 9px 0;
        border-top: 1px solid var(--line); }
.qrow:first-child { border-top: none; }
.qrow .qn { width: 44px; font-family: var(--mono); color: var(--dim); font-size: 13px; }
.qrow .qbar { position: relative; flex: 1 1 auto; height: 10px; background: #221f1b;
              border-radius: 999px; overflow: hidden; }
.qrow .qbar > i { display: block; height: 100%; background: var(--bad); border-radius: 999px; }
/* Where the budget for one question sits. Without it three equally slow
   questions are three identical full bars, which looks like a broken chart
   rather than the finding it is. */
.qrow .qbar > u { position: absolute; top: 0; bottom: 0; width: 2px; z-index: 1;
                  background: var(--ink); opacity: .55; }
.qrow .qs { width: 74px; text-align: right; font-family: var(--mono);
            font-variant-numeric: tabular-nums; font-size: 13px; }
.pill { font-size: 10px; padding: 2px 7px; border-radius: 999px; margin-left: 6px;
        background: #33291f; color: var(--warn); white-space: nowrap; }

/* Marking the paper: one tappable square per question. */
.marker { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 7px; }
.mq { border: 1px solid var(--line); background: #100f0d; color: var(--dim);
      border-radius: 10px; padding: 9px 4px; cursor: pointer; text-align: center;
      font-family: var(--mono); font-size: 13px; line-height: 1.3; }
.mq b { display: block; font-size: 15px; }
.mq.right { border-color: #2c4433; color: var(--good); background: #131a15; }
.mq.wrong { border-color: #4a2f2c; color: var(--bad);  background: #1c1413; }

.runcard { display: flex; align-items: baseline; gap: 10px; padding: 11px 0;
           border-top: 1px solid var(--line); cursor: pointer; }
.runcard:first-child { border-top: none; }
.runcard .t { flex: 1 1 auto; min-width: 0; }
.runcard .t b { display: block; font-size: 14.5px; }
.runcard .t span { font-size: 12px; color: var(--faint); }
.runcard .n { font-family: var(--mono); font-size: 13px; color: var(--dim); white-space: nowrap; }
.del { background: none; border: none; color: var(--faint); cursor: pointer;
       font-size: 18px; padding: 0 4px; line-height: 1; }

.move { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0;
        border-top: 1px solid var(--line); font-size: 13.5px; }
.move:first-of-type { border-top: none; }
.move .v { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--dim); }
.move .v b.better { color: var(--good); }
.move .v b.worse  { color: var(--bad); }

.foot { text-align: center; padding: 6px 0 max(18px, env(safe-area-inset-bottom));
        color: var(--faint); font-size: 11px; }

.runfoot .ghost:disabled { opacity: .38; cursor: default; }
