/* Self-hosted BIZ UD fonts (SIL OFL 1.1, see /fonts/OFL.txt), subset to the characters the app uses. */
@font-face { font-family: "BIZ UDPGothic"; src: url("/fonts/BIZUDPGothic-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "BIZ UDPGothic"; src: url("/fonts/BIZUDPGothic-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "BIZ UDMincho"; src: url("/fonts/BIZUDMincho-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --bg: #14161a; --panel: #1d2026; --panel-2: #262a32; --text: #e7e9ee; --muted: #9aa1ad; --line: #343945;
  --accent: #7fb3ff; --good: #6fcf97; --bad: #ff8a80; --warn: #f2c94c;
  --jp: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  --q: var(--jp);
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #eef1f5; --text: #1b1f27; --muted: #5d6573; --line: #d7dce4;
  --accent: #1f5fbf; --good: #1e7d4a; --bad: #b3261e; --warn: #8a6d00;
}
:root[data-print="mincho"] { --q: "BIZ UDMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--jp); }
a { color: var(--accent); }
button, input, select { font: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand span { color: var(--accent); }
nav a { margin-left: 1rem; color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.4rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: .8rem 0; }
.muted { color: var(--muted); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.btn { background: var(--accent); color: #0b1220; border: 0; border-radius: 10px; padding: .7rem 1.1rem; font-weight: 700;
  cursor: pointer; min-height: 44px; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #1a0505; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; margin: .5rem 0 .2rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date] {
  width: 100%; padding: .6rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.error { color: var(--bad); }

/* Test runner */
.bar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .8rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.timer.low { color: var(--warn); }
.split { display: grid; gap: 1rem; margin-top: 1rem; }
@media (min-width: 900px) { .split.with-passage { grid-template-columns: 1fr 1fr; } }
.passage { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem;
  font-family: var(--q); font-size: 1.1rem; line-height: 2; white-space: pre-wrap; max-height: 70vh; overflow: auto; }
.question { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.qhead { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .9rem; }
.stem { font-family: var(--q); font-size: 1.3rem; line-height: 2; margin: .6rem 0 1rem; }
.stem u { text-decoration-thickness: 2px; text-underline-offset: 5px; }
.choices { display: grid; gap: .5rem; }
.choice { text-align: left; font-family: var(--q); font-size: 1.15rem; padding: .8rem 1rem; min-height: 52px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
.choice .n { color: var(--muted); margin-right: .7rem; font-family: var(--jp); }
.choice.sel { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.choice.right { border-color: var(--good); box-shadow: inset 0 0 0 2px var(--good); }
.choice.wrong { border-color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.flag { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: .3rem .6rem; cursor: pointer; }
.flag.on { color: var(--warn); border-color: var(--warn); }
.nav-q { display: flex; justify-content: space-between; margin-top: 1rem; gap: .6rem; }
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: .35rem; margin-top: 1rem; }
.map button { min-height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; }
.map button.done { color: var(--text); border-color: var(--accent); }
.map button.cur { background: var(--accent); color: #0b1220; }
.map button.flagged { outline: 2px solid var(--warn); }

/* Results */
.scores { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.score { background: var(--panel-2); border-radius: 10px; padding: .8rem; }
.score b { font-size: 1.6rem; display: block; }
.verdict { font-weight: 700; }
.verdict.pass { color: var(--good); } .verdict.fail { color: var(--bad); } .verdict.incomplete { color: var(--warn); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--line); }
.review-item { border-top: 1px solid var(--line); padding: .8rem 0; }
.review-item .stem { font-size: 1.1rem; margin: .3rem 0 .5rem; }
.explain { color: var(--muted); font-size: .95rem; }
