:root {
  --bg: #f4f5ea; --bg-card: #fdfdf7; --ink: #20221a; --ink-soft: #5c6152;
  --ink-faint: #8a8f7c; --accent: #5f6a3d; --accent-soft: #e6e9d6;
  --accent-line: #c3cc9e; --rule: #dcd9c4; --rule-strong: #bdb890;
  --field-bg: #fbfbf1; --ok: #2c6e8a; --warn: #a3271d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14160f; --bg-card: #1b1e14; --ink: #e7e6da; --ink-soft: #9da393;
    --ink-faint: #6d7264; --accent: #9cb57a; --accent-soft: #232a19;
    --accent-line: #3a4429; --rule: #2a2d20; --rule-strong: #3c4030;
    --field-bg: #15170f; --ok: #6fb8d4; --warn: #e2857a;
  }
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); margin: 0;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2 { font-weight: 800; letter-spacing: -0.02em; margin: 0; }
[hidden] { display: none !important; }

#app { max-width: 760px; margin: 0 auto; padding: 40px 20px 90px; }

.brand { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 10px; }

/* INTRO */
#intro h1 { font-size: 1.6rem; margin-bottom: 10px; }
#intro p.desc { color: var(--ink-soft); margin-bottom: 20px; max-width: 60ch; }
.meta-row { display: flex; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.meta-row .m { text-align: center; }
.meta-row .m b { display: block; font-size: 1.3rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.meta-row .m span { font-size: 0.78rem; color: var(--ink-faint); }

.form-card { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 8px; padding: 24px; }
.form-card label { display: block; font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 6px; margin-top: 14px; }
.form-card label:first-child { margin-top: 0; }
.form-card input[type=text], .form-card input[type=tel] {
  width: 100%; background: var(--field-bg); border: 1px solid var(--rule); border-radius: 6px;
  padding: 10px 12px; font-size: 0.95rem; color: var(--ink); font-family: inherit;
}
.consent-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 0.76rem; color: var(--ink-faint); line-height: 1.4; }
.consent-row input[type=checkbox] { width: 15px; height: 15px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.consent-row label { cursor: pointer; }
.btn { display: inline-block; border: none; border-radius: 6px; padding: 11px 20px; font-size: 0.92rem; font-weight: 600; cursor: pointer; font-family: inherit; text-decoration: none; text-align: center; }
.btn-primary { background: var(--accent); color: var(--bg-card); width: 100%; margin-top: 18px; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border: 1px solid var(--rule-strong); color: var(--ink); width: 100%; margin-top: 10px; }

/* TEST SCREEN */
#testScreen .topbar {
  position: sticky; top: 0; background: var(--bg); padding: 12px 0; margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--rule);
  font-size: 0.85rem; z-index: 5;
}
#testScreen .topbar b { font-variant-numeric: tabular-nums; }
#timerDisplay { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

.section { margin-bottom: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--accent-line); padding-bottom: 6px; margin-bottom: 14px; }
.section-head h2 { font-size: 1.02rem; }
.section-meta { font-size: 0.78rem; color: var(--ink-faint); }

.question { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 18px; margin-bottom: 10px; }
.q-row { display: flex; gap: 8px; margin-bottom: 10px; }
.q-num { font-weight: 800; color: var(--accent); flex: none; }
.q-text { color: var(--ink); }
.ans-input {
  width: 160px; background: var(--field-bg); border: 1px solid var(--rule); border-radius: 6px;
  padding: 8px 10px; font-size: 0.95rem; color: var(--ink); font-family: inherit;
}

/* RESULT */
#resultScreen { text-align: center; }
.score-big { font-size: 3rem; font-weight: 800; color: var(--accent); }
.score-pct { font-size: 1rem; color: var(--ink-faint); margin-bottom: 24px; }
.wrong-list { text-align: left; background: var(--bg-card); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; }
.wrong-title { font-weight: 700; margin-bottom: 10px; font-size: 0.88rem; color: var(--ink-soft); }
.wrong-item { padding: 6px 0; border-bottom: 1px dashed var(--rule); font-size: 0.9rem; color: var(--ink-soft); }
.wrong-item:last-child { border-bottom: none; }

/* PRINT SHEET */
#printRoot { display: none; max-width: 720px; margin: 0 auto; padding: 28px; font-family: Georgia, "Times New Roman", serif; }
.print-head { margin-bottom: 26px; border-bottom: 2px solid #222; padding-bottom: 14px; }
.print-brand-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.print-brand { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; color: #555; font-family: -apple-system, sans-serif; }
.print-meta { font-size: 0.72rem; color: #555; font-family: -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
.print-head h1 { font-size: 1.35rem; margin-bottom: 16px; font-family: -apple-system, sans-serif; font-weight: 800; }
.print-fields { display: flex; justify-content: space-between; gap: 16px; font-size: 0.88rem; color: #222; font-family: -apple-system, sans-serif; flex-wrap: wrap; }
.print-field-name { flex: 1 1 auto; }
.print-section { margin-bottom: 22px; break-inside: avoid; }
.print-section-head { font-weight: 700; border-bottom: 1px solid #999; padding-bottom: 5px; margin-bottom: 14px; font-size: 0.95rem; font-family: -apple-system, sans-serif; color: #333; }
.print-question { margin-bottom: 18px; break-inside: avoid; }
.print-q-row { display: flex; gap: 8px; font-size: 1rem; line-height: 1.45; }
.print-q-row .q-num { font-weight: 700; flex: none; }
.print-answer-line {
  margin-top: 10px; margin-left: 26px; border-bottom: 1px solid #999;
  min-height: 26px; position: relative;
}
.print-unit {
  position: absolute; right: 0; bottom: 2px; font-size: 0.72rem; color: #999;
  font-family: -apple-system, sans-serif; font-style: italic;
}

@media print {
  @page { margin: 14mm 16mm; }
  body.print-mode #intro,
  body.print-mode #testScreen,
  body.print-mode #resultScreen,
  body.print-mode .brand { display: none !important; }
  body.print-mode #printRoot { display: block; padding: 0; max-width: none; }
  body.print-mode { background: #fff; color: #111; }
  body:not(.print-mode) #printRoot { display: none !important; }
}
@media screen {
  #printRoot { display: none !important; }
}
