:root {
  --bg: #f6f1ea;
  --card: #fff;
  --ink: #1f1a16;
  --muted: #6d6258;
  --line: #eadfd2;
  --accent: #b8461a;
  --accent-ink: #fff;
  --ok: #157347;
  --warn: #9a6700;
  --soft: #f8efe6;
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; font-size: 18px; }
.who { margin-left: auto; color: var(--muted); font-size: 15px; }
button, input { font: inherit; }
button { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 10px 14px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { background: transparent; }
button.on, .opt.on, .tfb.on { background: #fde7dc; border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .55; }
main { max-width: 920px; margin: 0 auto; padding: 16px; }
h1 { font-size: 28px; margin: 8px 0 12px; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); padding: 10px 12px; background: #fff; font-size: 18px;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 0 0 12px; }
.err { color: #9f1239; min-height: 1.2em; }
.list { display: grid; gap: 12px; }
.row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.muted { color: var(--muted); }
.pill { display: inline-block; border-radius: 999px; padding: 2px 8px; background: var(--soft); font-size: 13px; white-space: nowrap; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; line-height: 1.35; text-align: right; }
.clock.warn { color: var(--warn); }
.clock.blink { animation: clock-blink 1s step-end infinite; }
@keyframes clock-blink { 50% { opacity: .35; } }
.nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.nav button { min-width: 48px; padding: 8px; background: #fff; }
.nav button.here { box-shadow: inset 0 0 0 2px var(--accent); }
.nav button.partial { background: #fff6d8; border-color: #e0b000; }
.nav button.done { background: #e7f6ee; }
.nav button.later { outline: 2px solid var(--warn); }
.sq { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 0 0 12px; scroll-margin-top: 72px; }
.stem { font-size: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.opts, .parts { display: grid; gap: 8px; margin-top: 12px; }
.opt, .tfb { text-align: left; width: 100%; font-size: 17px; }
.part { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.part p { grid-column: 1 / -1; margin: 8px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.fig { margin: 12px 0; }
.fig img { max-width: 100%; height: auto; }
.net { margin: 0; padding: 8px 16px; background: #fff4d6; color: #7a4b00; text-align: center; }
@media (max-width: 800px) {
  .sq { display: none; }
  .sq.on { display: block; }
  h1 { font-size: 24px; }
}
@media (min-width: 801px) {
  .sq.on { box-shadow: inset 0 0 0 2px var(--accent); }
}
@media (max-width: 480px) {
  .home-head, .exam-head { flex-direction: column; align-items: flex-start; }
  .clock { text-align: left; }
}
@media (max-width: 420px) {
  .part { grid-template-columns: 1fr 1fr; }
  main { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .clock.blink { animation: none; }
}
.qhead { font-weight: 700; margin: 0 0 8px; }
.note { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
#wrong-only { margin: 0 0 12px; }
.choices { display: grid; gap: 8px; margin-top: 12px; }
.choice { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.choice .stem { flex: 1; }
.choice.right { background: #e7f6ee; border-color: var(--ok); }
.choice.wrong { background: #fde8e8; border-color: #9f1239; }
.tag { white-space: nowrap; font-size: 14px; font-weight: 700; color: var(--accent); }
.mark { font-weight: 700; white-space: nowrap; }
.mark.ok { color: var(--ok); }
.mark.bad { color: #9f1239; }
.tfres { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tfres th, .tfres td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.tfres th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tfres td.idea { overflow-wrap: anywhere; }
.solve { margin-top: 12px; }
.solve summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--accent); }
.solve .stem { white-space: pre-wrap; margin: 0 0 8px; }
.modal-back { position: fixed; inset: 0; background: rgba(31, 26, 22, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; }
.modal { background: var(--card); border-radius: 16px; padding: 20px; width: min(520px, 100%); max-height: min(90vh, 720px); overflow: auto; }
.modal h2 { margin: 0 0 8px; font-size: 24px; }
.modal .actions { display: flex; flex-wrap: nowrap; gap: 8px; }
.modal .actions button { flex: 1 1 0; min-height: 52px; font-size: 18px; }
.jumps { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.jumps button { min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: 10px; }
.jumps button.partial { background: #fff6d8; border-color: #e0b000; }
