:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --text: #1d2330;
  --muted: #5d6677;
  --border: #d9dde5;
  --accent: #2456c9;
  --accent-text: #ffffff;
  --accent-soft: #edf2fc;
  --ok: #1f8a4c;
  --warn: #a87300;
  --danger: #c93a32;
  --ok-bg: #e7f5ec;
  --ng-bg: #fbeceb;
  --timeout-bg: #fdf4df;
  /* グラフ */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --track: #dbe7f8;
  --grid: #e6e8ec;
  --axis: #c3c7cf;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14171d;
    --surface: #1d2129;
    --surface-2: #242934;
    --text: #e7eaf0;
    --muted: #a3abba;
    --border: #353b47;
    --accent: #7aa2ff;
    --accent-text: #0f1420;
    --accent-soft: #222c42;
    --ok: #5fcf8e;
    --warn: #f0c050;
    --danger: #ff7b72;
    --ok-bg: #18301f;
    --ng-bg: #3a1d1c;
    --timeout-bg: #3a3017;
    --series-1: #3987e5;
    --series-2: #d95926;
    --track: #26354d;
    --grid: #2c313b;
    --axis: #474e5b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.7;
}
.site-header {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}
.brand {
  background: none;
  border: 0;
  padding: 0;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 0.85rem; }
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}
.screen {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 20px;
}
h1 { font-size: 1.5rem; line-height: 1.4; margin: 0 0 8px; }
h2 { font-size: 1.35rem; line-height: 1.4; margin: 0 0 8px; }
h3 { font-size: 1.1rem; margin: 28px 0 10px; }
.lead { margin: 0 0 12px; }
.rules { margin: 0 0 20px; padding-left: 1.2em; color: var(--muted); }
.muted, .hint { color: var(--muted); }
.small { font-size: 0.9rem; }
.hint { font-size: 0.9rem; margin: 6px 0 0; }

fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 700; margin-bottom: 8px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; }
.pill span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.pill input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.type-group + .type-group { margin-top: 14px; }
.type-group-title { font-weight: 700; margin: 0 0 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.type-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.type-list.wide { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; }

button { font: inherit; cursor: pointer; }
a { color: var(--accent); }
.primary, .secondary {
  border-radius: 8px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
}
.primary { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.secondary { background: transparent; color: var(--accent); }
.big { width: 100%; padding: 14px 18px; font-size: 1.05rem; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 0; text-decoration: underline; }
.link.small { font-size: 0.85rem; font-weight: 400; padding: 0; }
.link.quiet { color: var(--muted); font-size: 0.9rem; margin-top: 16px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0 0 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ホーム */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 20px 0 8px; }
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mode-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(36, 86, 201, 0.12); }
#go-mock { border-color: var(--accent); background: var(--accent-soft); }
.mode-title { font-weight: 800; font-size: 1.15rem; }
.mode-desc { color: var(--muted); font-size: 0.95rem; }
.mode-meta {
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 10px;
  margin-top: 4px;
  background: var(--surface);
}
.records h2 { margin-top: 32px; font-size: 1.2rem; }
.records .link.quiet { display: block; }
.weak-btn { margin: 4px 0 0; text-align: left; }

/* 模試の内容 */
.plan { display: grid; gap: 12px; margin: 0 0 18px; }
.plan-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.plan-title { font-weight: 700; margin: 0 0 6px; }
.plan-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 18px; }
.plan-list li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.plan-name { white-space: nowrap; }
.plan-list li.plan-pool { grid-column: 1 / -1; flex-wrap: wrap; }
.plan-pool .plan-name { white-space: normal; }
.plan-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 問題画面 */
.q-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; margin-bottom: 10px; }
.q-progress { font-weight: 700; }
.q-category {
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
}
.q-total { margin-left: auto; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.timer { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: var(--ok); }
.timer-bar[data-level="warn"] { background: var(--warn); }
.timer-bar[data-level="danger"] { background: var(--danger); }
.timer-text { margin: 4px 0 16px; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.passage {
  white-space: pre-line;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  line-height: 1.95;
  max-height: 24em;
  overflow-y: auto;
  margin-bottom: 16px;
}
.q-text { white-space: pre-line; font-size: 1.05rem; margin-bottom: 18px; }

.table-wrap { overflow-x: auto; margin: 0 0 18px; }
.data-table { border-collapse: collapse; font-size: 0.95rem; }
.data-table caption { caption-side: top; text-align: left; color: var(--muted); font-size: 0.85rem; padding-bottom: 4px; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 6px 12px; white-space: nowrap; }
.data-table thead th { background: var(--surface-2); font-weight: 700; }
.data-table tbody th { background: var(--surface-2); font-weight: 600; text-align: left; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table.history { width: 100%; }
.data-table.history th, .data-table.history td { white-space: normal; vertical-align: top; }
.data-table .sub { color: var(--muted); font-size: 0.8rem; }
.data-table .block { display: block; }

.num-answer { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; margin-bottom: 18px; }
.num-answer input {
  width: 9em;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.options { display: grid; gap: 8px; margin-bottom: 18px; }
.options.multi { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.multi-note { margin: 0 0 8px; color: var(--muted); font-size: 0.9rem; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.option:hover { border-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { width: 18px; height: 18px; flex: none; }
.opt-label { font-weight: 700; width: 1.2em; flex: none; }
.opt-text { line-height: 1.6; }
.q-actions { margin-top: 8px; }

/* 熟語の成り立ち（1語ずつA〜Dを選ぶ） */
.matrix-legend {
  list-style: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 2px;
}
.matrix-legend li { display: flex; gap: 10px; }
.matrix { border-collapse: collapse; margin-bottom: 18px; }
.matrix th, .matrix td { padding: 6px; text-align: center; }
.matrix thead th { color: var(--muted); font-weight: 700; }
.matrix tbody tr + tr > * { border-top: 1px solid var(--border); }
.matrix-word { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.08em; text-align: left !important; padding-right: 18px !important; }
.cell { position: relative; display: inline-flex; cursor: pointer; }
.cell input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cell-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--muted);
}
.cell:hover .cell-mark { border-color: var(--accent); }
.cell input:checked + .cell-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.cell input:focus-visible + .cell-mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 結果 */
.eyebrow { color: var(--muted); font-weight: 700; margin: 0; }
.hero { margin: 6px 0 0; line-height: 1; }
.hero-num { font-size: 64px; font-weight: 800; letter-spacing: -0.02em; }
.hero-unit { font-size: 1.6rem; font-weight: 700; margin-left: 4px; }
.hero-sub { font-size: 1.1rem; font-weight: 700; margin: 10px 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 12px; }
.tile { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; }
.tile-label { color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.tile-value { font-size: 1.8rem; font-weight: 800; line-height: 1.25; }
.tile-sub { color: var(--muted); font-size: 0.85rem; }
.compare { font-weight: 700; margin: 4px 0 0; }

.meter-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.meter-row { display: grid; grid-template-columns: minmax(8em, 11em) 1fr auto; align-items: center; gap: 2px 12px; }
.meter-name { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.meter-bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }
.meter-figure { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; min-width: 8.5em; }
.meter-pct { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.8em; text-align: right; }
.meter-count { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.tag-weak {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 0 8px;
  line-height: 1.6;
}

/* 推移グラフ */
.chart { margin: 8px 0 16px; padding: 12px 14px 8px; border: 1px solid var(--border); border-radius: 12px; }
.chart-title { font-weight: 700; font-size: 0.95rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 2px 0 6px; color: var(--muted); font-size: 0.85rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { display: inline-block; width: 16px; height: 2px; border-radius: 2px; flex: none; }
.legend-line.s1 { background: var(--series-1); }
.legend-line.s2 { background: var(--series-2); }
.chart-wrap { position: relative; }
.chart-svg { display: block; touch-action: pan-y; }
.chart-svg:focus { outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .line.s1 { stroke: var(--series-1); }
.chart-svg .line.s2 { stroke: var(--series-2); }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .dot.s1 { fill: var(--series-1); }
.chart-svg .dot.s2 { fill: var(--series-2); }
.chart-svg .end-label { fill: var(--text); font-size: 12px; font-weight: 700; }
.chart-svg .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  z-index: 2;
}
.tip-head { color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tip-value { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2.8em; }
.tip-name { color: var(--muted); }

/* 見直し */
.review-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.review-item > summary {
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.review-item .rv-body { padding: 0 12px 12px; }
.review-item .rv-label { font-weight: 700; margin: 10px 0 2px; }
.review-item .rv-text { white-space: pre-line; margin: 0; }
.rv-passage { margin-top: 8px; }
.rv-passage > summary { cursor: pointer; color: var(--accent); }
.rv-passage .rv-text { margin-top: 6px; padding: 10px 12px; background: var(--surface); border-radius: 8px; line-height: 1.9; }
.rv-status { font-weight: 700; white-space: nowrap; }
.rv-status.correct { color: var(--ok); }
.rv-status.wrong, .rv-status.blank, .rv-status.partial { color: var(--danger); }
.rv-status.timeout { color: var(--warn); }
.review-item.wrong, .review-item.blank, .review-item.partial { background: var(--ng-bg); }
.review-item.timeout { background: var(--timeout-bg); }
.result-actions { display: grid; gap: 10px; margin-top: 24px; }

/* 誤りの報告（見直しの各問題の下） */
.rv-foot { margin-top: 12px; padding-top: 6px; border-top: 1px dashed var(--border); }
.rv-foot-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 16px; }
.rv-id { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.report-box { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.report-box p { margin: 0 0 8px; }
.report-text {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
a.primary, a.secondary { display: inline-block; text-decoration: none; text-align: center; }

/* このサイトについて */
.about-list { margin: 0 0 12px; padding-left: 1.2em; }
.about-list li + li { margin-top: 4px; }
#screen-about h3 { margin-top: 24px; }
#screen-about p { margin: 0 0 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  max-width: calc(100% - 32px);
  text-align: center;
}

footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 0.85rem;
}
footer p { margin: 0 0 6px; }
.footer-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; }

@media (max-width: 520px) {
  .meter-row { grid-template-columns: 1fr auto; grid-template-areas: "name figure" "bar bar"; }
  .meter-name { grid-area: name; }
  .meter-figure { grid-area: figure; min-width: 0; }
  .meter-bar { grid-area: bar; }
}
@media (max-width: 480px) {
  .screen { padding: 20px 16px; }
  h1 { font-size: 1.3rem; }
  .hero-num { font-size: 52px; }
  .matrix-word { font-size: 1.1rem; padding-right: 8px !important; }
  .matrix th, .matrix td { padding: 4px 3px; }
  .cell-mark { width: 38px; height: 38px; }
  .q-total { margin-left: 0; }
  .data-table th, .data-table td { padding: 6px 8px; }
}
