:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #5b6675;
  --line: #d9e0ea;
  --brand: #2f6fed;
  --brand-dark: #1f52bb;
  --ok: #1e9e5a;
  --ok-bg: #e6f7ee;
  --bad: #d4383a;
  --bad-bg: #fdeaea;
  --warn: #b7791f;
  --radius: 16px;
  --shadow: 0 8px 26px rgba(24, 39, 75, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

body.grade5 { font-size: 20px; }

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

.screen { display: none; }
.screen.active { display: block; }

h1 { font-size: 1.6rem; margin: 0 0 6px; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }

.sub { color: var(--muted); margin: 0 0 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 20px;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #eef2fb; color: var(--brand-dark); }
.btn.secondary:hover { background: #e2e9f9; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.day-list { display: grid; gap: 14px; }

.day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.day:hover { border-color: var(--brand); }
.day .meta { font-weight: 500; color: var(--muted); font-size: .9rem; }
.day .check { color: var(--ok); font-size: 1.4rem; }

.field { display: block; margin: 6px 0 16px; }
.field input {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--brand); }

.progress-bar {
  height: 12px;
  background: #e7ecf5;
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 18px;
}
.progress-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width .25s ease;
}

.q-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 8px;
}
.tag {
  display: inline-block;
  background: #eef2fb;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.bodytext { margin: 0 0 14px; }
.bodytext p { margin: 0 0 10px; }
.question { font-weight: 600; margin: 0 0 16px; }
.source { color: var(--muted); font-size: .8rem; margin-top: 16px; }

img.fig { max-width: 100%; height: auto; display: block; margin: 8px 0; }
.option img.fig { display: inline-block; max-height: 140px; vertical-align: middle; }

.options { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.5;
}
.option:hover:not(:disabled) { border-color: var(--brand); background: #f8faff; }
.option .key {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--brand-dark);
  min-width: 1.2em;
}
.option .opt-body { flex: 1 1 auto; }
.option:disabled { cursor: default; }
.option.chosen-right { border-color: var(--ok); background: var(--ok-bg); }
.option.chosen-wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.dim { opacity: .55; }

.feedback {
  margin-top: 16px;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1.5px solid transparent;
}
.feedback.ok { background: var(--ok-bg); border-color: #b9e6cd; }
.feedback.bad { background: var(--bad-bg); border-color: #f3c1c2; }
.feedback .head { font-weight: 700; margin-bottom: 4px; }
.feedback.ok .head { color: var(--ok); }
.feedback.bad .head { color: var(--bad); }

.confirm {
  text-align: center;
}
.confirm .big { font-size: 2.4rem; }
.confirm .pct { font-size: 2rem; font-weight: 800; color: var(--ok); }
.msgbox {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f7f9fd;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: .9rem;
  margin: 16px 0;
}

.note { color: var(--muted); font-size: .88rem; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1 1 auto; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.protected * { -webkit-user-select: none; user-select: none; }

.katex { font-size: 1.06em; }
.katex-display { margin: 0.4em 0; }

.landing-links { display: grid; gap: 16px; max-width: 480px; margin: 0 auto; }
.landing-links a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
}
.landing-links a:hover { border-color: var(--brand); }
.landing-links span { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin-top: 4px; }

@media (max-width: 560px) {
  html, body { font-size: 17px; }
  body.grade5 { font-size: 18px; }
  .wrap { padding: 16px 12px 64px; }
  .card { padding: 16px; }
}
