:root {
  color-scheme: light dark;
  --bg: #ededed;
  --bg-elev: #ffffff;
  --bg-elev-2: #f7f9fb;
  --line: #e0e0e0;
  --text: #333333;
  --text-dim: #666666;
  --text-faint: #999999;
  --accent: #2b7bbf;
  --accent-strong: #1f649c;
  --accent-soft: #e3f0fb;
  --rail: #dceaf6;
  --topbar-bg: rgba(237, 237, 237, 0.88);
  --shadow: 0 1px 3px rgba(21, 48, 74, 0.08);
  --ok: #2e7d32;
  --ok-soft: #e6f1e7;
  --ng: #c62828;
  --ng-soft: #fdecea;
  --btn-fg: #ffffff;
  --radius: 8px;
  --fs-h1: 22px;
  --fs-h2: 15px;
  --fs-stem: 16px;
  --fs-body: 14px;
  --fs-ui: 15px;
  --fs-small: 13px;
  --fs-hint: 12px;
  --fs-tiny: 11px;
  --fs-score: 54px;
}

html[data-text="large"] {
  --fs-h1: 24px;
  --fs-h2: 16px;
  --fs-stem: 19px;
  --fs-body: 17px;
  --fs-ui: 18px;
  --fs-small: 16px;
  --fs-hint: 14px;
  --fs-tiny: 13px;
  --fs-score: 58px;
}

html[data-theme="dark"] {
  --bg: #121212;
  --bg-elev: #2c2c2e;
  --bg-elev-2: #1c1c1e;
  --line: #3a3a3c;
  --text: #e8e8e8;
  --text-dim: #a8a8a8;
  --text-faint: #8a8a8a;
  --accent: #7eb8e8;
  --accent-strong: #9ccbea;
  --accent-soft: #1a2f42;
  --rail: #2a3a4a;
  --topbar-bg: rgba(18, 18, 18, 0.88);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --ok: #66bb6a;
  --ok-soft: #1e3320;
  --ng: #ef9a9a;
  --ng-soft: #3d1e1e;
  --btn-fg: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  white-space: nowrap;
  text-decoration: none;
}

.brand-sub {
  font-size: var(--fs-small);
  color: var(--text-dim);
  white-space: nowrap;
}

.topbar-right,
.topbar-access {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.access-email {
  font-size: var(--fs-hint);
  color: var(--text-dim);
  white-space: nowrap;
}

.access-mail {
  max-width: 22vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-btn {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  font-weight: 500;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.topbar-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 40px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.45);
}

.help-card {
  max-width: 640px;
  width: 100%;
}

.help-card h1 {
  margin-bottom: 16px;
}

.help-card h2 {
  margin-top: 20px;
  font-size: var(--fs-h2);
  color: var(--text);
}

.help-card ul {
  margin: 0 0 8px;
  padding-left: 1.2em;
  color: var(--text-dim);
  font-size: var(--fs-body);
}

.help-card li + li {
  margin-top: 6px;
}

.help-danger {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.help-legal {
  margin-top: 16px;
}

.price-offer {
  margin: 0 0 12px;
}

.price-now {
  margin: 0;
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1.5;
}

.price-until {
  margin: 4px 0 0;
  color: var(--text-dim);
}

.price-regular {
  margin: 4px 0 0;
  color: var(--text-dim);
  text-decoration: line-through;
}

.access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.access-input {
  flex: 1 1 220px;
  min-width: 200px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--rail);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs-ui);
  padding: 10px 12px;
}

.access-input:focus {
  outline: none;
  border-left-color: var(--accent);
  border-color: var(--accent);
}

.btn.compact {
  padding: 6px 12px;
  font-size: var(--fs-hint);
}

.help-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
}

.help-icon:hover {
  border-color: var(--accent);
}

.wide-only {
  display: inline;
}

@media (max-width: 720px) {
  :root {
    --fs-h1: 23px;
    --fs-stem: 17px;
    --fs-body: 15px;
    --fs-ui: 16px;
    --fs-small: 14px;
    --fs-hint: 13px;
  }

  .wide-only,
  .brand-sub,
  .access-mail {
    display: none;
  }

  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .brand-mark {
    font-size: 17px;
  }

  .access-email,
  .topbar-btn {
    font-size: 13px;
  }

  .topbar-btn {
    padding: 6px 11px;
  }

  .help-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .app {
    padding: 20px 14px 72px;
  }

  .card {
    padding: 18px 16px;
  }
}

/* ---------- layout ---------- */

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 96px;
}

.loading {
  color: var(--text-dim);
  text-align: center;
  padding: 80px 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 20px;
}

h1 {
  font-size: var(--fs-h1);
  margin: 0 0 6px;
  color: var(--text);
}

h2 {
  font-size: var(--fs-h2);
  margin: 0 0 14px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lede {
  margin: 0 0 24px;
  color: var(--text-dim);
  font-size: var(--fs-body);
}

/* ---------- home ---------- */

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode {
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 4px solid var(--rail);
  border-radius: var(--radius);
  padding: 16px 16px 16px 14px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, border-left-color 0.15s, transform 0.15s;
}

.mode:hover:not(:disabled) {
  border-color: var(--line);
  border-left-color: var(--accent);
  border-left-width: 5px;
  transform: translateY(-1px);
}

.mode:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.mode strong {
  display: inline;
  font-size: var(--fs-ui);
  margin-right: 0.75em;
}

.mode span {
  display: inline;
  font-size: var(--fs-small);
  color: var(--text-dim);
}

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.domain-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 4px solid var(--rail);
  border-radius: var(--radius);
  padding: 10px 14px 10px 12px;
  width: 100%;
  text-align: left;
  box-shadow: var(--shadow);
  transition: border-left-color 0.15s, border-left-width 0.15s;
}

.domain-row:hover:not(:disabled) {
  border-left-color: var(--accent);
  border-left-width: 5px;
}

.domain-row:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.domain-no {
  font-weight: 700;
  color: var(--accent);
  font-size: var(--fs-small);
}

.domain-title {
  font-size: var(--fs-body);
}

.domain-title small {
  display: block;
  color: var(--text-faint);
  font-size: var(--fs-tiny);
  letter-spacing: 0.02em;
}

.badge {
  font-size: var(--fs-tiny);
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- quiz ---------- */

.progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  font-size: var(--fs-hint);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--rail);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.stem {
  font-size: var(--fs-stem);
  margin: 0 0 22px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  align-items: start;
  text-align: left;
  font-size: var(--fs-stem);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 4px solid var(--rail);
  border-radius: var(--radius);
  padding: 13px 16px 13px 14px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, border-left-color 0.15s, background 0.15s;
}

.choice:hover:not(:disabled) {
  border-left-color: var(--accent);
  border-left-width: 5px;
}

.choice:disabled {
  cursor: default;
}

.choice-key {
  font-weight: 700;
  color: var(--text-faint);
  font-size: var(--fs-small);
  line-height: 1.9;
}

.choice.correct {
  border-color: var(--ok);
  border-left-color: var(--ok);
  border-left-width: 5px;
  background: var(--ok-soft);
}

.choice.correct .choice-key {
  color: var(--ok);
}

.choice.wrong {
  border-color: var(--ng);
  border-left-color: var(--ng);
  border-left-width: 5px;
  background: var(--ng-soft);
}

.choice.wrong .choice-key {
  color: var(--ng);
}

.choice.muted {
  opacity: 0.55;
}

.choice.picked {
  border-color: var(--line);
  border-left-color: var(--accent);
  border-left-width: 5px;
  background: var(--accent-soft);
}

.choice.picked .choice-key {
  color: var(--accent);
}

.multi-note {
  margin: 0 0 12px;
  font-size: var(--fs-small);
  color: var(--accent);
}

/* ---------- explanation ---------- */

.explain {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.verdict {
  font-weight: 700;
  font-size: var(--fs-body);
  margin: 0 0 12px;
}

.verdict.ok {
  color: var(--ok);
}

.verdict.ng {
  color: var(--ng);
}

.explain-body {
  font-size: var(--fs-body);
  margin: 0 0 18px;
}

.distractors {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-dim);
}

.distractors dt {
  float: left;
  clear: left;
  width: 26px;
  font-weight: 700;
  color: var(--text);
}

.distractors dd {
  margin: 0 0 8px 26px;
}

.refs {
  margin-top: 16px;
  font-size: var(--fs-tiny);
  color: var(--text-faint);
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--btn-fg);
  font-size: var(--fs-ui);
  font-weight: 700;
  padding: 11px 22px;
  box-shadow: var(--shadow);
  transition: background 0.15s, filter 0.15s;
}

.btn:hover {
  background: var(--accent-strong);
}

.btn.ghost {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 4px solid var(--rail);
  color: var(--text-dim);
  font-weight: 500;
}

.btn.ghost:hover {
  color: var(--text);
  border-left-color: var(--accent);
}

.hint {
  font-size: var(--fs-hint);
  color: var(--text-dim);
}

kbd {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: var(--fs-tiny);
  font-family: inherit;
}

/* ---------- result ---------- */

.score-hero {
  text-align: center;
  padding: 12px 0 22px;
}

.score-value {
  font-size: var(--fs-score);
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.score-label {
  color: var(--text-dim);
  font-size: var(--fs-small);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr 120px 54px;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-small);
}

.bar-track {
  height: 7px;
  background: var(--rail);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bar-value {
  text-align: right;
  color: var(--text-dim);
  font-size: var(--fs-hint);
  font-variant-numeric: tabular-nums;
}

.review-item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
  font-size: var(--fs-small);
}

.review-item:first-of-type {
  border-top: none;
}

.review-item .q {
  margin: 0 0 6px;
}

.review-item .a {
  color: var(--text-dim);
  font-size: var(--fs-hint);
  margin: 0;
}

.empty {
  color: var(--text-dim);
  font-size: var(--fs-small);
  margin: 0;
}
