:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #5d6762;
  --line: #d9ddd8;
  --accent: #1f5a47;
  --accent-ink: #ffffff;
  --ok: #1d7a44;
  --ok-bg: #e5f3ea;
  --ng: #b3261e;
  --ng-bg: #fbe9e7;
  --focus: #2f7dd1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151917;
    --panel: #1e2421;
    --ink: #e8ebe9;
    --muted: #9aa5a0;
    --line: #34403b;
    --accent: #5fb495;
    --accent-ink: #0f1311;
    --ok: #6fcf97;
    --ok-bg: #1b3326;
    --ng: #f2887e;
    --ng-bg: #3a1f1c;
    --focus: #7ab3f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 17px;
  line-height: 1.7;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--accent); color: var(--accent-ink);
}
.bar-title { background: none; border: 0; padding: 4px 0; font-weight: 700; font-size: 18px; color: inherit; }
.bar-sync { font-size: 13px; opacity: .9; }

.wrap { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1 { font-size: 22px; margin: 8px 0 12px; line-height: 1.4; }
h2 { font-size: 18px; margin: 24px 0 8px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 12px 0; }
.count { font-size: 15px; color: var(--muted); margin: 0; }
.count strong { font-size: 40px; color: var(--ink); font-weight: 700; margin: 0 4px; font-variant-numeric: tabular-nums; }

.btn {
  display: block; width: 100%; min-height: 52px; margin: 8px 0;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  padding: 12px 16px; text-align: left; font-weight: 600;
}
.btn-main { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); text-align: center; font-size: 18px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { text-align: center; }
.btn-sub { font-weight: 400; color: var(--muted); font-size: 14px; display: block; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .btn { border: 0; margin: 0; border-radius: 0; background: none; }

.meter { display: grid; grid-template-columns: 7.5em 1fr 4.5em; align-items: center; gap: 8px; margin: 6px 0; font-size: 15px; }
.meter-track { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }
.meter-num { text-align: right; font-variant-numeric: tabular-nums; }

.q-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.q-body p { margin: 0 0 10px; }
.q-body .fig { display: block; max-width: 100%; height: auto; margin: 8px auto; background: #fff; border-radius: 6px; }
.tbl { overflow-x: auto; margin: 8px 0 12px; }
.tbl table { border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.tbl th { background: var(--bg); }

.choices { margin: 16px 0; }
.choice {
  display: grid; grid-template-columns: 2em 1fr; gap: 8px; align-items: start;
  width: 100%; min-height: 52px; margin: 8px 0; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: left;
}
.choice-key { font-weight: 700; }
.choice[disabled] { cursor: default; }
.choice.is-answer { border-color: var(--ok); background: var(--ok-bg); }
.choice.is-wrong { border-color: var(--ng); background: var(--ng-bg); }

.verdict { font-weight: 700; font-size: 20px; margin: 4px 0 8px; }
.verdict.ok { color: var(--ok); }
.verdict.ng { color: var(--ng); }
.explain { border-left: 4px solid var(--accent); padding: 4px 0 4px 12px; margin: 12px 0; }
.tag-ai { font-size: 13px; color: var(--muted); }
.cite { font-size: 13px; color: var(--muted); margin-top: 12px; }

.field { display: block; margin: 12px 0; }
.field input { display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.error { color: var(--ng); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 16px);
  max-width: 560px; margin: 0 auto; padding: 12px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-size: 15px; z-index: 10;
}
