:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1d2330;
  --muted: #5c6577;
  --line: #d9dde5;
  --brand: #1f4e8c;
  --brand-ink: #ffffff;
  --bar: #24364f;
  --bar-ink: #f2f5fa;
  --sel: #e6eefb;
  --good: #1f7a4d;
  --good-bg: #e5f4ec;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --warn: #9a6200;
  --flag: #c77700;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c;
    --surface: #1a2029;
    --ink: #e6e9ef;
    --muted: #9aa3b2;
    --line: #2d3541;
    --brand: #6ea0e6;
    --brand-ink: #0c1320;
    --bar: #0b0f15;
    --bar-ink: #e6e9ef;
    --sel: #1f2d44;
    --good: #5cc28f;
    --good-bg: #15291f;
    --bad: #f08a80;
    --bad-bg: #2e1715;
    --warn: #e0a84a;
    --flag: #f0a640;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11151c; --surface: #1a2029; --ink: #e6e9ef; --muted: #9aa3b2; --line: #2d3541;
  --brand: #6ea0e6; --brand-ink: #0c1320; --bar: #0b0f15; --bar-ink: #e6e9ef; --sel: #1f2d44;
  --good: #5cc28f; --good-bg: #15291f; --bad: #f08a80; --bad-bg: #2e1715; --warn: #e0a84a; --flag: #f0a640;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
#app { max-width: 980px; margin: 0 auto; padding: 0 16px 120px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; margin-top: 24px; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 8px; font: inherit; font-size: .95rem; cursor: pointer; min-height: 40px;
}
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.danger { color: var(--bad); border-color: currentColor; }
.btn.ghost { background: transparent; }
.link { background: none; border: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* home */
.hero { padding: 40px 0 16px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 6px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
.lede { color: var(--muted); max-width: 70ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.grid2 .card > .row { margin-top: auto; }
.facts { margin: 0; padding-left: 18px; }
.domains { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { margin-top: 4px; }
.check em { color: var(--muted); font-style: normal; font-size: .85em; }
.inline { display: flex; gap: 6px; align-items: center; font-size: .92rem; }
select { font: inherit; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.resume { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; border-color: var(--flag); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid var(--line); }
.tag.pass { color: var(--good); background: var(--good-bg); border-color: transparent; }
.tag.new { color: var(--brand); border-color: var(--brand); }
.new-only { padding: 8px 10px; border: 1px dashed var(--brand); border-radius: 8px; }
.tag.fail { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.foot { color: var(--muted); font-size: .85rem; margin-top: 24px; }

/* exam chrome */
#app[data-screen="item"], #app[data-screen="review"] { max-width: none; padding: 0 0 96px; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bar); color: var(--bar-ink); padding: 10px 16px; flex-wrap: wrap;
}
.tb-title { font-weight: 600; }
.tb-right { display: flex; gap: 18px; align-items: center; }
.counter { opacity: .9; }
.timer-box { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.timer-box .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
#timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
#timer.low { color: #ffb4a8; }
.item, .review { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.meta { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
.stem { font-size: 1.05rem; margin: 0 0 12px; }
.instr { font-weight: 700; margin: 0 0 12px; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  font: inherit; cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt.sel { background: var(--sel); border-color: var(--brand); }
.opt.right { background: var(--good-bg); border-color: var(--good); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt:disabled { cursor: default; }
.box { flex: 0 0 20px; height: 20px; border: 2px solid var(--muted); display: grid; place-items: center; font-size: 12px; margin-top: 2px; color: var(--brand); }
.box.round { border-radius: 50%; }
.box.square { border-radius: 4px; }
.letter { font-weight: 700; }
.otext { flex: 1; }
.notice { color: var(--warn); font-weight: 600; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 8px; border-left: 4px solid; }
.feedback.ok { background: var(--good-bg); border-color: var(--good); }
.feedback.ko { background: var(--bad-bg); border-color: var(--bad); }
.verdict { font-weight: 700; margin: 0 0 4px; }
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mark { display: flex; gap: 6px; align-items: center; font-weight: 600; color: var(--flag); cursor: pointer; }

/* review screen */
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; margin: 16px 0 20px; }
.cell { position: relative; height: 44px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.cell.done { background: var(--sel); border-color: var(--brand); }
.cell.todo { border-style: dashed; }
.cell i { position: absolute; top: 1px; right: 4px; font-style: normal; color: var(--flag); font-size: .8rem; }
.legend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.legend .cell { width: 26px; height: 20px; display: inline-block; cursor: default; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 22px; max-width: 440px; width: 100%; box-shadow: var(--shadow); }

/* results */
.score { text-align: center; padding: 36px 16px 8px; }
.score h1 { font-size: 2.6rem; letter-spacing: .04em; }
.score.pass h1 { color: var(--good); }
.score.fail h1 { color: var(--bad); }
.big { font-size: 2.2rem; font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; }
.big span { font-size: 1rem; font-weight: 400; color: var(--muted); }
.bar { margin: 12px 0; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; }
.track { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.fill { height: 100%; }
.fill.good { background: var(--good); }
.fill.weak { background: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface); color: var(--ink); border: 0; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.ans { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.ans summary { cursor: pointer; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.ans .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.ans.ok .dot { background: var(--good); }
.ans.ko .dot { background: var(--bad); }
.olist { list-style: none; padding: 0; display: grid; gap: 6px; }
.olist li { padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); }
.olist li.right { background: var(--good-bg); border-color: var(--good); }
.olist li.wrong { background: var(--bad-bg); border-color: var(--bad); }
.why { color: var(--muted); }

/* alias + progress */
.small { font-size: .85rem; }
.loading { padding: 48px 0; text-align: center; }
.alias-card { max-width: 640px; }
.alias-card input {
  font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); min-height: 40px; flex: 1 1 200px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--sel); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; cursor: pointer; min-height: 36px; }
.chip:hover { border-color: var(--brand); }
.progress h3 { font-size: 1rem; margin: 22px 0 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9em, 1fr)); gap: 10px; margin: 8px 0 18px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat-v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-l { font-weight: 600; font-size: .9rem; }
.stat-n { color: var(--muted); font-size: .8rem; }
.trend { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); gap: 8px; height: 160px; margin: 8px 0 4px; }
.trend-axis { position: relative; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend-axis span { position: absolute; right: 0; transform: translateY(-50%); }
.trend-axis span:nth-child(1) { top: 0; }
.trend-axis span:nth-child(2) { top: 31.1%; }
.trend-axis span:nth-child(3) { top: 100%; }
.trend svg { width: 100%; height: 160px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: visible; }
.trend .cut { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 5 4; }
.trend .trend-line { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.dot-pass { fill: var(--good); stroke: var(--surface); stroke-width: 2; }
.dot-fail { fill: var(--bad); stroke: var(--surface); stroke-width: 2; }
.fill.mid { background: var(--warn); }
.small-btn { min-height: 32px; padding: 4px 12px; font-size: .85rem; }
.history-wrap { max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.history-wrap thead th { position: sticky; top: 0; background: var(--surface); }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  #app[data-screen="item"], #app[data-screen="review"] { padding-bottom: 190px; }
  .bottombar { justify-content: center; }
  .bottombar .row { justify-content: center; }
  .tb-right { gap: 12px; }
}
