:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #1b2232;
  --muted: #5d6679;
  --border: #dde1ea;
  --accent: #3b5bdb;
  --accent-2: #e8edff;
  --good: #2b8a3e;
  --bad: #d6336c;
  --warn: #e8590c;
  --c-Gf: #3b5bdb;
  --c-Gq: #0c8599;
  --c-Gc: #9c36b5;
  --c-Gv: #e8590c;
  --c-Gwm: #2b8a3e;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121a; --surface: #161b26; --surface-2: #1e2432; --text: #e5e8ef; --muted: #9ba4b6;
    --border: #2a3244; --accent: #7d95ff; --accent-2: #212a45; --good: #51cf66; --bad: #ff6b9a; --warn: #ff922b;
    --c-Gf: #7d95ff; --c-Gq: #3bc9db; --c-Gc: #da77f2; --c-Gv: #ff922b; --c-Gwm: #51cf66;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e121a; --surface: #161b26; --surface-2: #1e2432; --text: #e5e8ef; --muted: #9ba4b6;
  --border: #2a3244; --accent: #7d95ff; --accent-2: #212a45; --good: #51cf66; --bad: #ff6b9a; --warn: #ff922b;
  --c-Gf: #7d95ff; --c-Gq: #3bc9db; --c-Gc: #da77f2; --c-Gv: #ff922b; --c-Gwm: #51cf66;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.7; font-size: 16px; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.center { text-align: center; }
.accent-text { color: var(--accent); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 4px; font-family: inherit; }
.progress { flex: 1; display: flex; align-items: center; gap: 10px; max-width: 520px; margin: 0 auto; }
.progress-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.progress-text { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 32px; }

/* ---------- card & buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; margin-bottom: 20px; }
.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 20px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0e121a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0e121a; } }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.lg { padding: 14px 32px; font-size: 1.05rem; }
.btn.sm { padding: 5px 12px; font-size: .85rem; }
.btn.icon { width: 34px; padding: 5px 0; }
.btn:focus-visible, .opt:focus-visible, input:focus-visible, .brand:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* ---------- home ---------- */
.intro h1 { font-size: 1.9rem; }
.lead { font-size: 1.05rem; }
.domain-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 20px 0 24px; }
.chip { display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--surface-2); border-radius: 10px; line-height: 1.4; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; flex: none; margin-top: 6px; }
.dot.lg { width: 16px; height: 16px; margin-top: 0; vertical-align: middle; }
.checklist { padding-left: 1.2em; }
.checklist li { margin-bottom: 4px; }

/* ---------- section intro ---------- */
.section-intro { text-align: center; padding: 40px 28px; }
.section-intro .lead { max-width: 640px; margin: 0 auto 1em; text-align: left; }
.example { max-width: 640px; margin: 0 auto 1em; text-align: left; background: var(--accent-2); border-radius: 10px; padding: 12px 16px; font-size: .95rem; }

/* ---------- item ---------- */
.item { transition: opacity .18s; }
.item.leaving { opacity: .3; }
.item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pill { display: inline-block; padding: 2px 12px; border-radius: 99px; font-size: .85rem; font-weight: 700; color: var(--pc); background: color-mix(in srgb, var(--pc) 14%, transparent); }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.timebar { height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 20px; }
.timebar-fill { height: 100%; width: 100%; background: var(--accent); }
.timebar-fill.low { background: var(--warn); }
.prompt { font-size: 1.1rem; margin-bottom: 16px; }
.premise { margin-top: 12px; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 6px; font-size: 1rem; }
.stim-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.figure { background: #fff; border: 1px solid #d1d5db; border-radius: 12px; padding: 10px; display: inline-flex; flex-direction: column; align-items: center; }
.figure .fig-matrix { width: min(330px, 80vw); height: auto; display: block; }
.figure.target .fig-cell { width: 130px; height: 130px; }
.fig-caption { font-size: .8rem; color: #4b5563; }
.sequence { font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; padding: 16px 24px; background: var(--surface-2); border-radius: 12px; white-space: pre-wrap; text-align: center; }
.sequence .q { color: var(--accent); }

.options { display: grid; gap: 12px; margin-bottom: 8px; }
.options.fig.n6 { grid-template-columns: repeat(3, 1fr); max-width: 480px; margin-left: auto; margin-right: auto; }
.options.fig.n4 { grid-template-columns: repeat(4, 1fr); max-width: 600px; margin-left: auto; margin-right: auto; }
.options.fig.n5 { grid-template-columns: repeat(5, 1fr); max-width: 720px; margin-left: auto; margin-right: auto; }
.options.text { grid-template-columns: 1fr; max-width: 560px; margin-left: auto; margin-right: auto; }
.opt {
  font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-radius: 12px;
  cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-align: left; transition: border-color .12s, background .12s;
}
.options.fig .opt { flex-direction: column; padding: 8px; gap: 4px; }
.opt:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-2); }
.opt-no { font-size: .8rem; font-weight: 700; color: var(--muted); min-width: 1.4em; }
.opt-body { display: flex; justify-content: center; width: 100%; }
.options.text .opt-body { justify-content: flex-start; font-size: 1.02rem; }
.options.fig .opt-body { background: #fff; border-radius: 8px; }
.fig-cell { width: 100%; max-width: 110px; height: auto; aspect-ratio: 1; display: block; }
.answer-input { display: flex; justify-content: center; margin-bottom: 8px; }
.answer-input input {
  font: inherit; font-size: 1.6rem; text-align: center; width: min(280px, 100%); padding: 10px 14px; letter-spacing: .1em;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
}
.answer-input input:focus { border-color: var(--accent); outline: none; }
.item-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.hint { text-align: center; margin: 12px 0 0; }

.wm-box { width: min(360px, 90vw); height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 16px; }
.wm-box.done { height: 120px; }
.wm-note { color: var(--muted); font-size: .95rem; }
.wm-note strong { color: var(--text); }
.wm-digit { font-size: 5rem; font-weight: 800; line-height: 1.1; min-height: 1.2em; font-variant-numeric: tabular-nums; }

.spinner { width: 42px; height: 42px; border: 4px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; margin: 20px auto; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- report ---------- */
.hero { display: grid; grid-template-columns: minmax(240px, 1fr) 1.6fr; gap: 24px; align-items: center; }
.iq-label { margin-top: 8px; font-weight: 700; color: var(--muted); }
.iq-value { font-size: 4.6rem; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.iq-class { font-size: 1.2rem; font-weight: 700; margin: 6px 0 14px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.kv dt { font-size: .78rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: auto; display: block; }
.chart .ax { font-size: 12px; fill: var(--muted); font-family: inherit; }
.chart .ax.strong { fill: var(--text); font-weight: 700; }
.chart .ax.tiny { font-size: 10px; }
.radar { max-width: 380px; margin: 0 auto; }
.quad { max-width: 300px; margin: 0 auto; }
.split { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; align-items: start; }
.split3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.stat.accent { background: var(--accent-2); }
.stat-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 8px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl td:first-child { min-width: 8em; }
.tbl td strong { white-space: nowrap; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl.compact td, .tbl.compact th { padding: 5px 8px; }
.tbl td .dot { margin-top: 0; }
.ok { color: var(--good); font-weight: 700; }
.ng { color: var(--bad); font-weight: 700; }
.to { color: var(--warn); font-weight: 700; }
.flag { font-size: .75rem; background: var(--warn); color: #fff; border-radius: 4px; padding: 0 5px; }
.sw { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.sw-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.sw p { margin-bottom: .4em; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.strong { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge.weak { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tip { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: .92rem; }
.insights { display: grid; gap: 10px; }
.insight { border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 10px 14px; }
.insight.warn { border-left-color: var(--warn); }
.insight h4 { margin: 4px 0; font-size: 1rem; }
.insight p { margin: 0; font-size: .92rem; }
.notice { border-color: var(--warn); }
.notice h3 { color: var(--warn); }
.notice ul { margin: 0; padding-left: 1.2em; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 3px; width: 16px; background: var(--text); vertical-align: 3px; }
details summary { cursor: pointer; margin-top: 10px; color: var(--accent); font-weight: 600; }
.method li { margin-bottom: 8px; }
.disclaimer { background: var(--surface-2); box-shadow: none; }
.disclaimer p { font-size: .9rem; margin: 0; }

@media (max-width: 760px) {
  .card { padding: 20px 16px; }
  .hero, .split { grid-template-columns: 1fr; }
  .split3 { grid-template-columns: 1fr; }
  .options.fig.n6 { grid-template-columns: repeat(3, 1fr); }
  .options.fig.n4, .options.fig.n5 { grid-template-columns: repeat(3, 1fr); }
  .iq-value { font-size: 3.8rem; }
  .topbar { padding: 8px 12px; gap: 10px; }
  .brand span { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar, .no-print, .foot { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  main { padding: 0; max-width: none; }
  details { display: block; }
  details > summary { display: none; }
  details:not([open]) > *:not(summary) { display: block; }
}
