/* ============================================================
   学科試験 練習室 — visual system
   Light = warm paper / ink.  Dark = deep navy / lime (shared
   visual language with menkyo-lab).
   Fonts: Zen Old Mincho (display, JP serif) + Inter (latin/numerals),
   both with full system fallbacks so the page is unaffected offline.
   ============================================================ */

:root {
  color-scheme: light dark;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", "PingFang SC",
    "Segoe UI", sans-serif;
  --font-serif: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho",
    "Noto Serif JP", "Songti SC", serif;

  /* surfaces */
  --bg: #f1efe9;
  --bg-veil: rgba(255, 255, 255, 0.55);
  --surface: #fdfcf9;
  --surface-2: #f7f4ed;
  --surface-3: #f2eee5;
  --line: #e5e0d4;
  --line-strong: #d6cebd;

  /* type */
  --text: #17211f;
  --text-2: #3d4744;
  --muted: #7c837c;

  /* accent (olive → lime in dark) */
  --accent: #4b681f;
  --accent-soft: #edf3dc;
  --accent-line: #c9dda0;

  /* primary action */
  --primary: #16232a;
  --primary-hi: #22323a;
  --primary-text: #f6f7f1;

  /* verdicts */
  --ok: #2c6a49;
  --ok-soft: #e9f2eb;
  --ok-line: #c0dac8;
  --bad: #a4332a;
  --bad-soft: #f9ece9;
  --bad-line: #e7c7c0;

  --shadow-sm: 0 1px 2px rgba(23, 33, 31, 0.05);
  --shadow-md: 0 1px 2px rgba(23, 33, 31, 0.04), 0 10px 24px -16px rgba(23, 33, 31, 0.22);
  --shadow-lg: 0 2px 4px rgba(23, 33, 31, 0.05), 0 22px 44px -26px rgba(23, 33, 31, 0.32);
  --ring: rgba(75, 104, 31, 0.35);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --ease: cubic-bezier(0.22, 0.7, 0.26, 1);
}

:root[data-theme="dark"] {
    --bg: #0f171c;
    --bg-veil: rgba(255, 255, 255, 0.03);
    --surface: #16212a;
    --surface-2: #1b2831;
    --surface-3: #202e38;
    --line: #29363e;
    --line-strong: #3a4a54;

    --text: #e9efe9;
    --text-2: #c2ccc8;
    --muted: #8d9ba0;

    --accent: #c8ee7d;
    --accent-soft: rgba(200, 238, 125, 0.11);
    --accent-line: rgba(200, 238, 125, 0.32);

    --primary: #c8ee7d;
    --primary-hi: #d6f394;
    --primary-text: #14201a;

    --ok: #83d5a2;
    --ok-soft: rgba(131, 213, 162, 0.12);
    --ok-line: rgba(131, 213, 162, 0.3);
    --bad: #f0928a;
    --bad-soft: rgba(240, 146, 138, 0.12);
    --bad-line: rgba(240, 146, 138, 0.3);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 30px -20px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 26px 50px -30px rgba(0, 0, 0, 0.9);
    --ring: rgba(200, 238, 125, 0.4);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  /* two very soft light pools — gives the page depth without any texture file */
  background-image:
    radial-gradient(120% 60% at 12% -10%, var(--bg-veil), transparent 60%),
    radial-gradient(100% 50% at 100% 0%, var(--accent-soft), transparent 55%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "palt" 1;
  letter-spacing: 0.01em;
}

button, input, select, textarea { font: inherit; color: inherit; }
button, a, label, input { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
}

.topbar-inner {
  max-width: 660px;
  margin: 0 auto;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brandmark {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 36px;
  background: var(--primary);
  color: var(--primary-text);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1;
  padding-bottom: 2px;
  clip-path: polygon(0 0, 100% 0, 100% 80%, 76% 100%, 0 100%);
}

.brandtext { min-width: 0; }

.topbar h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.25;
}

.eyebrow {
  display: block;
  font-family: "Inter", var(--font-sans);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.4;
}

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

#app {
  max-width: 660px;
  margin: 0 auto;
  padding: 20px 16px calc(56px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13.5px; }

.view { animation: viewIn 0.32s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.loading-msg {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}

/* ---------------- cards / panels ---------------- */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
}

/* hairline of light along the top edge = subtle "lift" */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  pointer-events: none;
}
[data-theme="dark"] .card::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-num {
  flex: none;
  font-family: "Inter", var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 3px 8px;
  line-height: 1;
}

.panel-title { flex: 1; min-width: 0; }
.panel-title strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.35;
}

.panel-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.link-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

.link-btn {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  border: none;
  background: none;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s var(--ease), opacity 0.18s var(--ease);
}
.link-btn:hover { border-bottom-color: var(--accent-line); }
.link-btn:active { opacity: 0.6; }

/* ---------------- option rows (radio / checkbox) ---------------- */

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

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease), transform 0.12s var(--ease);
}
.option:active { transform: scale(0.994); }
.option input {
  flex: none;
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--accent);
}
.option-label {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-2);
}
.option .cat-count {
  flex: none;
  font-family: "Inter", var(--font-sans);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* selected state (progressive enhancement: :has) */
.option:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.option:has(input:checked) .option-label {
  color: var(--text);
  font-weight: 600;
}

.mode-toggle { margin-top: 2px; }

/* ---------------- category list ---------------- */

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.category-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  transition: background 0.16s var(--ease);
}
.category-list li:last-child { border-bottom: none; }
.category-list label {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
  -webkit-user-select: none;
  color: var(--muted);
  transition: color 0.16s var(--ease);
}
.category-list li:has(input:checked) label { color: var(--text); }
.category-list input[type="checkbox"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}
.cat-count {
  color: var(--muted);
  font-size: 12px;
  font-family: "Inter", var(--font-sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---------------- buttons ---------------- */

.btn-primary, .btn-secondary {
  position: relative;
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 15px 18px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
    border-color 0.18s var(--ease), box-shadow 0.22s var(--ease),
    transform 0.12s var(--ease);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { background: var(--primary-hi); box-shadow: var(--shadow-lg); }
.btn-primary:active { transform: translateY(1px) scale(0.995); box-shadow: var(--shadow-sm); }
.btn-primary:disabled {
  background: var(--surface-3);
  color: var(--muted);
  box-shadow: none;
  border-color: var(--line);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--accent-line); background: var(--surface-3); }
.btn-secondary:active { transform: translateY(1px) scale(0.995); }
.btn-secondary:disabled { cursor: not-allowed; }

.btn-block { margin-bottom: 12px; }

.btn-link {
  display: block;
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  padding: 14px 16px;
  margin-bottom: 0;
}

/* the one hero action on the home screen */
.start-block { margin: 20px 0 22px; }
.btn-start {
  padding: 18px;
  font-size: 17px;
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0.08em;
  border-radius: var(--r-lg);
}
.btn-start #selected-count {
  font-family: "Inter", var(--font-sans);
  font-variant-numeric: tabular-nums;
}

.badge {
  flex: none;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid var(--bad-line);
  border-radius: 999px;
  padding: 2px 10px;
  font-family: "Inter", var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: center;
}

.wrongbook-card .panel-head { margin-bottom: 14px; }

/* ---------------- quiz: progress ---------------- */

.quiz-head { margin-bottom: 16px; }

.quiz-progress {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
#progress-text {
  font-family: "Inter", var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
#accuracy-text {
  font-family: "Inter", var(--font-sans);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 5px;
  overflow: hidden;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s var(--ease);
}

/* ---------------- quiz: question ---------------- */

.question-card {
  padding: 20px 18px 18px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--r-xl);
  /* no text selection while swiping across the card */
  user-select: none;
  -webkit-user-select: none;
}
.question-card::before { border-radius: var(--r-xl) var(--r-xl) 0 0; }

.category-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 3px 11px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.question-image {
  display: block;
  max-width: 170px;
  max-height: 170px;
  margin: 2px auto 16px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.question-text {
  font-size: 17.5px;
  line-height: 1.85;
  letter-spacing: 0.015em;
  color: var(--text);
  margin-bottom: 22px;
  text-wrap: pretty;
}

.question-text-zh {
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 10px 14px;
  margin: -14px 0 22px;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}

/* 〇 / ✕ — the two buttons that matter most on a phone */
.tf-buttons {
  display: flex;
  gap: 12px;
}
.tf-btn {
  flex: 1;
  min-height: 78px;
  font-size: 34px;
  font-weight: 400;
  line-height: 1;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    box-shadow 0.2s var(--ease), transform 0.1s var(--ease), color 0.16s var(--ease);
}
[data-theme="dark"] .tf-btn { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.tf-maru { color: var(--ok); }
.tf-batsu { color: var(--bad); }
.tf-maru:hover:not(:disabled) { background: var(--ok-soft); border-color: var(--ok-line); }
.tf-batsu:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad-line); }
.tf-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}
.tf-maru:active:not(:disabled) { background: var(--ok-soft); border-color: var(--ok); }
.tf-batsu:active:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }
.tf-btn:disabled { cursor: default; box-shadow: none; }

/* multiple-choice options */
.mc-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mc-btn {
  text-align: left;
  font-size: 15px;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    transform 0.1s var(--ease);
}
.mc-btn:hover:not(:disabled) { border-color: var(--accent-line); background: var(--surface-3); }
.mc-btn:active:not(:disabled) { transform: translateY(1px) scale(0.995); }
.mc-btn:disabled { cursor: default; color: var(--text-2); }

/* keyboard / swipe hint */
.shortcut-hint {
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 14px;
}
.shortcut-hint .mobile-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .shortcut-hint .desktop-only { display: none; }
  .shortcut-hint .mobile-only { display: inline; }
}

/* ---------------- quiz: feedback ---------------- */

.feedback {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  animation: feedbackIn 0.3s var(--ease) both;
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.feedback-verdict {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.feedback-verdict.correct { color: var(--ok); }
.feedback-verdict.wrong { color: var(--bad); }

.feedback-explain {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}
.feedback-explain.empty { color: var(--muted); font-style: italic; }

.feedback-explain-zh {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 12px 14px;
  margin: -6px 0 16px;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}

.btn-next { margin-bottom: 0; }

.quit-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: none;
}
.quit-btn:hover { color: var(--text-2); border-bottom: none; }

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

.result-summary {
  text-align: center;
  padding: 30px 20px 26px;
  margin-bottom: 20px;
}
.result-summary .eyebrow { margin-bottom: 10px; }
.result-summary h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.result-rate {
  margin-top: 10px;
  display: inline-block;
  font-family: "Inter", var(--font-sans);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 4px 14px;
}

.wrong-list { margin-top: 22px; }
.wrong-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--bad-line);
  border-radius: var(--r-md);
  padding: 15px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.wrong-item .wq-cat {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.wrong-item .wq-text {
  font-size: 15px;
  line-height: 1.75;
  margin-bottom: 8px;
}
.wrong-item .wq-text-zh {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  background: var(--surface-2);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.wrong-item .wq-answer {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ok);
  margin-bottom: 6px;
}
.wrong-item .wq-explain {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.75;
}
.wrong-item .wq-explain-zh {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  background: var(--surface-2);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 10px 12px;
  margin-top: 10px;
}

/* ---------------- swipe feedback (class names used by app.js) ---------------- */

.question-card.swipe-flash-right { animation: swipeFlashOk 0.45s var(--ease); }
.question-card.swipe-flash-left  { animation: swipeFlashBad 0.45s var(--ease); }

@keyframes swipeFlashOk {
  0%   { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft), var(--shadow-lg); transform: translateX(7px); }
  45%  { border-color: var(--ok-line); box-shadow: 0 0 0 6px transparent, var(--shadow-lg); transform: translateX(0); }
  100% { border-color: var(--line); box-shadow: 0 0 0 0 transparent, var(--shadow-lg); transform: none; }
}
@keyframes swipeFlashBad {
  0%   { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft), var(--shadow-lg); transform: translateX(-7px); }
  45%  { border-color: var(--bad-line); box-shadow: 0 0 0 6px transparent, var(--shadow-lg); transform: translateX(0); }
  100% { border-color: var(--line); box-shadow: 0 0 0 0 transparent, var(--shadow-lg); transform: none; }
}

/* ---------------- phones ---------------- */

@media (max-width: 480px) {
  body { font-size: 15px; }
  #app { padding: 16px 13px calc(48px + env(safe-area-inset-bottom)); }
  .card { padding: 15px 15px; border-radius: var(--r-md); }
  .card::before { border-radius: var(--r-md) var(--r-md) 0 0; }
  .question-card { padding: 18px 15px 16px; border-radius: var(--r-lg); }
  .question-card::before { border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .question-text { font-size: 17px; line-height: 1.8; }
  .panel-head { gap: 10px; }
  .panel-title strong { font-size: 15.5px; }
  .topbar h1 { font-size: 17px; }
  .option { min-height: 50px; padding: 8px 12px; }
  .option-label { font-size: 14.5px; }
  .tf-btn { min-height: 84px; font-size: 36px; }
  .tf-buttons { gap: 10px; }
  .btn-start { padding: 17px; font-size: 16.5px; }
  .result-summary { padding: 26px 16px 22px; }
  .result-summary h2 { font-size: 38px; }
  .panel-actions { gap: 8px; }
  .link-btn { font-size: 12.5px; }
}

/* very small phones: keep the panel head from wrapping badly */
@media (max-width: 360px) {
  .panel-num { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.mock-set-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px 14px; flex-wrap: wrap; }
.mock-set-row select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface, #fff); color: inherit; max-width: 100%; }

.random-info-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px 14px; font-size: 13px; }

/* ---------- account / paywall ---------- */
.acct-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 4px 2px 2px; }
.acct-status { flex: 1 1 200px; font-size: 14px; line-height: 1.5; word-break: break-all; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mq-btn { width: auto; padding: 10px 16px; font-size: 14px; }
.mq-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 16, 18, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.mq-box { position: relative; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 24px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.mq-x { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.mq-h { margin: 0; font-family: var(--font-serif); font-size: 20px; }
.mq-p { margin: 0; font-size: 14px; line-height: 1.6; }
.mq-reason { color: var(--accent); font-weight: 600; }
.mq-small { font-size: 12px; color: var(--muted); }
.mq-input { width: 100%; box-sizing: border-box; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg); color: var(--text); }
.mq-msg { min-height: 1.2em; font-size: 13px; color: var(--bad); }
.mq-plan { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-2, var(--surface)); color: var(--text); font-size: 15px; cursor: pointer; }
.mq-plan:hover { border-color: var(--accent); background: var(--accent-soft); }
.mq-plan-price { font-weight: 600; font-variant-numeric: tabular-nums; }
