:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #345fe2;
  --accent-dark: #2448bc;
  --ok: #35c76f;
  --bad: #ff5c5c;
  --border: #e5e7eb;
  --soft-ok: #e8f9ef;
  --soft-bad: #ffeded;
}

/* Typed answers share the trainer's theme and remain usable at 320px. */
.answer-interaction { margin: 0; padding: 0; border: 0; min-width: 0; }
.answer-interaction legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.answer-field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.answer-field input { width: 100%; min-width: 0; min-height: 52px; border: 2px solid var(--border); border-radius: 14px; padding: 10px; color: var(--text); background: var(--surface); text-align: center; font-size: 26px; }
.answer-field input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.answer-field input[readonly] { background: var(--bg); }
.numeric-answer { display: flex; align-items: end; justify-content: center; gap: 8px; }
.numeric-answer .answer-field { flex: 1; }
.answer-suffix { font-size: 28px; padding-bottom: 10px; }
.fraction-answer { display: grid; gap: 8px; width: min(100%, 210px); margin: 0 auto; }
.fraction-rule { height: 2px; background: var(--text); }
.input-instruction { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0 0 12px; }
.answer-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.answer-keypad button, .pair-button { min-height: 48px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 10px; }
.answer-keypad button:focus-visible, .pair-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.answer-keypad button:active { background: var(--bg); }
.interaction-submit { width: 100%; margin-top: 8px; }
.interaction-submit:disabled { opacity: .55; }
.interaction-submit.correct { background: var(--ok); }
.interaction-error { color: var(--bad); font-size: 14px; line-height: 1.45; margin: 8px 0 0; }
.interaction-error:empty { display: none; }
.matching-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }
.matching-column { display: grid; align-content: start; gap: 10px; }
.pair-button { display: grid; gap: 4px; min-height: 84px; text-align: left; overflow-wrap: anywhere; font-size: 16px; }
.pair-button small { font-size: 12px; color: var(--muted); }
.pair-button[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: 1px; }
.pair-button.is-linked { border-color: var(--accent); }
.pair-index { font-size: 12px; color: var(--muted); }
.answer-feedback-value { white-space: pre-line; }
.trainer.has-interaction .question { font-size: clamp(22px, 6vw, 30px); line-height: 1.25; hyphens: none; }
.trainer.has-interaction .question-area { min-height: 100px; flex: 0; padding: 12px 0; }

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

body.dark {
  color-scheme: dark;
  --bg: #101827;
  --surface: #172235;
  --text: #f8fafc;
  --muted: #a8b3c7;
  --border: #2b3850;
  --soft-ok: #153d2a;
  --soft-bad: #482022;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.home {
  justify-content: center;
  text-align: center;
}

.brand {
  margin-bottom: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin: 10px 0 0;
  color: var(--muted);
}

.daily-goal-panel {
  text-align: left;
}

.daily-goal-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.daily-goal-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.daily-goal-head p {
  margin-top: 4px;
}

.select-wrap select {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 0 34px 0 12px;
  font-weight: 700;
}

.goal-meter {
  height: 8px;
  margin-top: 14px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.goal-meter span {
  display: block;
  width: var(--goal-progress);
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.topbar {
  min-height: 44px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
}

.topbar-title {
  text-align: center;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.report-button {
  color: var(--muted);
}

.report-button.reported {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok), transparent 40%);
  background: var(--soft-ok);
}

.quality-actions { display: flex; gap: 8px; }
.quality-like { color: var(--muted); }
.quality-like.selected { color: var(--ok); border-color: color-mix(in srgb, var(--ok), transparent 40%); background: var(--soft-ok); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(3px);
}

.report-popup {
  position: fixed;
  inset: 0;
}

.modal-panel {
  width: min(100%, 380px);
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.24);
}

.modal-panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
  text-align: center;
}

.modal-panel p {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
}

.modal-handle {
  display: none;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-actions .compact-button {
  margin-top: 0;
}

.report-comment-field {
  display: grid;
  gap: 8px;
  text-align: left;
}

.report-comment-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.report-comment-field textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
}

.report-comment-field textarea:focus {
  border-color: color-mix(in srgb, var(--accent), transparent 30%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 86%);
}

.primary-button,
.secondary-button,
.answer-button,
.subject-button,
.danger-button {
  width: 100%;
  min-height: 62px;
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
}

.compact-button {
  min-height: 48px;
  border-radius: 14px;
  margin-top: 10px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:active {
  background: var(--accent-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.danger-button {
  background: var(--soft-bad);
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad), transparent 72%);
}

.trainer {
  justify-content: space-between;
  gap: 12px;
}

.trainer-route-progress {
  display: grid;
  gap: 7px;
  padding: 0 8px;
}

.trainer-route-progress > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
}

.trainer-route-progress strong {
  color: var(--text);
}

.trainer-route-progress span {
  color: var(--muted);
  text-align: right;
}

.trainer-route-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.trainer-route-track span {
  display: block;
  width: var(--route-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

@media (max-width: 520px) {
  .trainer-route-progress > div:first-child {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .trainer-route-progress span {
    text-align: left;
  }
}

.topic-button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px;
  font-weight: 800;
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1.18;
  overflow-wrap: break-word;
  hyphens: auto;
}

.admin-screen {
  gap: 14px;
}

.admin-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
}

.admin-head p,
.admin-head h1 {
  margin: 0;
}

.admin-head p {
  color: var(--muted);
  font-size: 13px;
}

.admin-head h1 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.admin-small-button {
  width: auto;
  min-height: 42px;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
}

.admin-token-panel,
.admin-controls,
.admin-report-controls {
  display: grid;
  gap: 12px;
}

.admin-token-panel label,
.admin-controls label,
.admin-report-controls label {
  display: grid;
  gap: 7px;
  text-align: left;
}

.admin-token-panel span,
.admin-controls span,
.admin-report-controls span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-token-panel input,
.admin-controls input,
.admin-controls select,
.admin-report-controls select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 0 12px;
}

.admin-controls input[type="search"] {
  margin-bottom: 7px;
}

.admin-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.admin-action-grid .compact-button {
  margin-top: 0;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.admin-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  padding: 6px 4px;
  overflow-wrap: anywhere;
}

.admin-tabs button.active {
  background: var(--accent);
  color: #fff;
}

.admin-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-metric {
  min-height: 96px;
  display: grid;
  align-content: center;
  gap: 7px;
  text-align: left;
}

.admin-metric strong {
  font-size: 30px;
  line-height: 1;
}

.admin-metric span,
.admin-overview-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.admin-overview-note strong {
  color: var(--text);
}

.admin-user-list {
  display: grid;
  gap: 12px;
}

.admin-user-card {
  display: grid;
  gap: 12px;
  text-align: left;
}

.admin-user-head {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 10px;
}

.admin-user-head img {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
}

.admin-user-head strong,
.admin-user-head span {
  display: block;
  overflow-wrap: anywhere;
}

.admin-user-head strong {
  font-size: 16px;
  line-height: 1.2;
}

.admin-user-head span,
.admin-user-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.admin-user-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.admin-user-stats div {
  display: grid;
  gap: 3px;
  min-height: 58px;
  align-content: center;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.admin-user-stats strong {
  font-size: 16px;
  line-height: 1;
}

.admin-user-stats span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.admin-progress-line {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.admin-progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.admin-user-note {
  margin: 0;
}

.admin-approval-toggle {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 10px;
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.admin-approval-toggle span,
.admin-approval-toggle strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-approval-toggle span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-approval-toggle strong {
  font-size: 14px;
  line-height: 1.25;
}

.admin-approval-toggle em {
  grid-row: 1 / span 2;
  grid-column: 2;
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.admin-topic-approval-list {
  display: grid;
  gap: 12px;
}

.admin-topic-level {
  display: grid;
  gap: 10px;
  text-align: left;
}

.admin-topic-level-head,
.admin-topic-approval-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.admin-topic-level-head strong,
.admin-topic-approval-row strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.admin-topic-level-head span,
.admin-topic-approval-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.admin-topic-approval-row {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.admin-topic-approval-row .admin-progress-line {
  margin-top: 7px;
}

.admin-topic-approval-side {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.admin-topic-approval-side .compact-button {
  width: auto;
  min-height: 36px;
  margin-top: 0;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

.admin-message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.admin-preview-list {
  display: grid;
  gap: 12px;
}

.admin-review-stack {
  display: grid;
  min-height: 420px;
  align-items: start;
}

.admin-review-card {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
}

.admin-question-card {
  display: grid;
  gap: 12px;
  text-align: left;
}

.admin-question-meta {
  display: grid;
  gap: 3px;
}

.admin-question-meta span {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.admin-question-meta strong {
  font-size: 16px;
  line-height: 1.25;
}

.admin-question-meta em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.admin-approval-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.admin-approval-row .compact-button {
  width: auto;
  min-height: 38px;
  margin-top: 0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.admin-approval-badge {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  padding: 6px 9px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.admin-approval-badge.confirmed {
  background: var(--soft-ok);
  color: var(--ok);
}

.admin-approval-badge.stale {
  background: var(--soft-bad);
  color: var(--bad);
}

.admin-question-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.admin-answer-grid {
  display: grid;
  gap: 8px;
}

.admin-answer {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg);
}

.admin-answer > span {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
}

.admin-answer p {
  margin: 0;
  min-width: 0;
  overflow-wrap: normal;
}

.admin-answer p > span {
  display: inline;
}

.admin-answer .katex {
  white-space: nowrap;
}

.admin-answer.correct {
  border-color: color-mix(in srgb, var(--ok), transparent 45%);
  background: var(--soft-ok);
}

.admin-report-card .admin-question-meta span {
  width: auto;
  min-width: 38px;
  padding: 0 7px;
}

.admin-report-comment {
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 70%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent), transparent 92%);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-report-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-report-actions .compact-button {
  min-height: 42px;
  margin-top: 0;
  padding: 10px;
  font-size: 13px;
}

.admin-report-actions .active {
  border-color: color-mix(in srgb, var(--accent), transparent 35%);
  background: color-mix(in srgb, var(--accent), transparent 88%);
  color: var(--accent-dark);
}

.admin-correct,
.admin-algorithm {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.admin-algorithm {
  color: var(--muted);
}

.admin-error-trace {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.progress-text {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.question-area {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: clamp(140px, 30svh, 220px);
  text-align: center;
}

.question {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  font-size: var(--question-size, clamp(26px, 7.4vw, 40px));
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 0;
  overflow-wrap: break-word;
  hyphens: auto;
}

.info-card-text {
  max-width: 100%;
  font-size: var(--question-size, clamp(20px, 5.8vw, 24px));
  line-height: 1.35;
  font-weight: 750;
  text-align: left;
}

.detailed-explanation-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.detailed-explanation-link:active {
  transform: scale(0.98);
}

.answers {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.answer-button {
  min-width: 0;
  max-width: 100%;
  min-height: 68px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: var(--answer-size, clamp(18px, 5.8vw, 24px));
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: auto;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.answer-button.visual-answer {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  justify-items: start;
}

.answer-button.visual-answer .logic-token {
  margin: 0;
}

.answer-button:active {
  transform: scale(0.99);
}

.answer-button.correct {
  background: var(--soft-ok);
  border-color: var(--ok);
}

.answer-button.wrong {
  background: var(--soft-bad);
  border-color: var(--bad);
}

.answer-button:disabled {
  cursor: default;
}

.answer-feedback-popup {
  position: fixed;
  inset: 0;
}

.answer-feedback {
  width: min(100%, 390px);
  gap: 14px;
  border-color: var(--border);
}

.answer-feedback.is-wrong {
  border-color: var(--bad);
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--soft-bad), transparent 55%), color-mix(in srgb, var(--soft-bad), transparent 55%)),
    var(--surface);
}

.answer-feedback.is-correct {
  border-color: var(--ok);
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--soft-ok), transparent 50%), color-mix(in srgb, var(--soft-ok), transparent 50%)),
    var(--surface);
}

.answer-feedback h2 {
  margin-bottom: -2px;
}

.answer-feedback-icon {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.answer-feedback-icon.is-wrong {
  color: var(--bad);
}

.answer-feedback-icon.is-correct {
  color: var(--ok);
}

.answer-feedback-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.answer-feedback-question {
  max-height: 26svh;
  color: var(--text);
  font-size: clamp(18px, 4.8vw, 24px);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  overflow: auto;
  overflow-wrap: anywhere;
}

.answer-feedback-question .katex {
  font-size: 1em;
}

.answer-feedback-value {
  color: var(--text);
  font-size: clamp(22px, 5.6vw, 30px);
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

.answer-feedback-diagnostic {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, #ffb84f 14%, transparent);
  line-height: 1.45;
}

.answer-feedback-remediation {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.remediation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, #4f7cff 30%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, #4f7cff 8%, transparent);
  color: var(--text);
  font-size: 14px;
}

.remediation-banner strong {
  color: #4f7cff;
  font-variant-numeric: tabular-nums;
}

.answer-feedback-value .katex {
  font-size: 1em;
}

.answer-feedback p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.answer-feedback .primary-button {
  min-height: 58px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 20px;
  letter-spacing: 0;
}

.panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.account-panel {
  display: grid;
  gap: 12px;
}

.account-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 14px;
}

.account-row.guest {
  grid-template-columns: 1fr;
}

.profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 2px solid var(--border);
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.avatar-upload-button {
  display: grid;
  place-items: center;
  text-align: center;
}

.avatar-upload-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.subject-list,
.settings-list,
.examples,
.auth-form,
.leaderboard {
  display: grid;
  gap: 10px;
}

.topic-rating-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 10px 2px 0 0;
  border-top: 1px solid var(--border);
}

.subject-check {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 0 0 auto;
}

.topic-rating-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
}

.topic-rating-row span {
  overflow-wrap: anywhere;
}

.topic-position {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topic-rating-row strong {
  color: var(--accent);
  font-size: 14px;
}

.topic-rating-row.locked {
  opacity: 0.58;
}

.topic-rating-row.locked strong {
  color: var(--muted);
}

.auth-form {
  margin-top: 12px;
}

.auth-form input,
.inline-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.auth-form input:focus,
.inline-form input:focus {
  border-color: var(--accent);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.form-message {
  min-height: 20px;
  margin-top: 10px !important;
  font-size: 14px;
}

.leader-row {
  min-height: 46px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.leader-row.me {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), transparent 92%);
}

.leader-row strong {
  overflow-wrap: anywhere;
}

.leader-row span {
  color: var(--muted);
  font-size: 14px;
}

.subject-button {
  position: relative;
  overflow: hidden;
  min-height: 54px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.subject-button::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--subject-progress-visible, var(--subject-progress, 0%));
  background: color-mix(in srgb, var(--accent), transparent 84%);
  pointer-events: none;
}

.subject-button > span {
  position: relative;
  z-index: 1;
}

.subject-button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.subject-button.active .subject-check {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface);
}

.subject-button:disabled {
  color: var(--muted);
  opacity: 0.7;
}

.setting-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle {
  position: relative;
  width: 54px;
  height: 32px;
  flex: 0 0 auto;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border);
}

.toggle span::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.toggle input:checked + span {
  background: var(--accent);
}

.toggle input:checked + span::after {
  transform: translateX(22px);
}

.topic-screen {
  gap: 14px;
}

.topic-panel {
  display: grid;
  gap: 18px;
}

.topic-hero {
  display: grid;
  gap: 8px;
}

.topic-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.topic-hero h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 36px);
  line-height: 1.08;
}

.topic-hero p,
.topic-section p {
  margin: 0;
  color: var(--text);
  line-height: 1.58;
}

.topic-section {
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.topic-section h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.topic-examples {
  display: grid;
  gap: 10px;
}

.topic-example {
  min-height: 50px;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.35;
  font-size: clamp(16px, 4.8vw, 19px);
  font-weight: 750;
  overflow-wrap: break-word;
}

.topic-actions {
  display: grid;
  gap: 10px;
}

.topic-wiki-link {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  text-decoration: none;
}

.katex {
  white-space: nowrap;
}

.logic-visual {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-bottom: 10px;
}

.logic-visual-prompt {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 750;
}

.logic-visual-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.triangle-visual {
  width: min(100%, 390px);
  margin: -2px auto 12px;
  padding: 4px 8px 0;
  color: var(--text);
}

.triangle-visual svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.geometry-visual {
  width: min(100%, 360px);
  margin: -2px auto 12px;
  padding: 4px 8px 0;
  color: var(--text);
}

.geometry-visual svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.geometry-fill {
  fill: rgba(79, 124, 255, 0.08);
}

.geometry-edge,
.geometry-helper,
.geometry-arc,
.geometry-parallel-mark,
.geometry-grid,
.geometry-right-mark,
.geometry-axis,
.geometry-vector {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.geometry-helper,
.geometry-arc,
.geometry-parallel-mark,
.geometry-grid,
.geometry-right-mark,
.geometry-axis {
  stroke-width: 2.4;
}

.geometry-axis {
  opacity: 0.38;
  stroke-width: 1.5;
}

.geometry-vector {
  stroke: #4f7cff;
  stroke-width: 4;
}

.geometry-vector-alt {
  stroke: #ff8a4f;
}

.geometry-vector-sum {
  stroke: #2dbf7f;
}

.geometry-grid {
  stroke: color-mix(in srgb, currentColor 24%, transparent);
  stroke-width: 1.2;
}

.geometry-faint {
  opacity: 0.34;
}

.geometry-point {
  fill: currentColor;
}

.ten-frame-cell,
.place-value-cell {
  fill: rgba(79, 124, 255, 0.04);
  stroke: color-mix(in srgb, currentColor 65%, transparent);
  stroke-width: 2;
}

.ten-frame-cell.filled {
  fill: #4f7cff;
}

.place-value-heading,
.place-value-digit {
  fill: currentColor;
  text-anchor: middle;
}

.number-line-jump {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 4;
  stroke-linecap: round;
}

.trig-graph-line {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.coordinate-main-axis {
  opacity: 0.85;
  stroke-width: 2.2;
}

.coordinate-point {
  fill: #4f7cff;
}

.coordinate-segment,
.coordinate-reflection-axis {
  fill: none;
  stroke: #ff8a4f;
  stroke-width: 2.4;
  stroke-dasharray: 5 4;
}

.coordinate-reflection-axis {
  stroke: #2dbf7f;
  stroke-width: 3.2;
}

.coordinate-tick-label,
.coordinate-quadrant-label {
  fill: currentColor;
  font-size: 9px;
  text-anchor: middle;
  opacity: 0.72;
}

.coordinate-quadrant-label {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.36;
}

.function-plot-line {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 3.4;
  stroke-linecap: round;
}

.function-plot-line-alt {
  stroke: #ff8a4f;
}

.function-plot-line-third {
  stroke: #2dbf7f;
}

.function-plot-point {
  fill: #2dbf7f;
}

.function-plot-legend {
  fill: currentColor;
  font-size: 10px;
  text-anchor: end;
  paint-order: stroke;
  stroke: var(--card, #fff);
  stroke-width: 3px;
}

.function-rise-run {
  fill: none;
  stroke: #2dbf7f;
  stroke-width: 2.8;
  stroke-dasharray: 5 4;
}

.function-rise-run-label {
  fill: currentColor;
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
}

.function-symmetry-axis {
  fill: none;
  stroke: #2dbf7f;
  stroke-width: 2.4;
  stroke-dasharray: 6 5;
}

.function-asymptote {
  fill: none;
  stroke: #ff8a4f;
  stroke-width: 2.2;
  stroke-dasharray: 6 5;
}

.number-line-label {
  fill: currentColor;
  font-size: 12px;
  text-anchor: middle;
}

.equal-group-box {
  fill: rgba(79, 124, 255, 0.04);
  stroke: color-mix(in srgb, currentColor 45%, transparent);
  stroke-width: 2;
}

.equal-group-dot {
  fill: #4f7cff;
}

.data-bar {
  fill: color-mix(in srgb, #4f7cff 78%, #8da8ff);
}

.data-value,
.data-label,
.data-title {
  fill: currentColor;
  font-family: inherit;
  text-anchor: middle;
}

.data-value {
  font-size: 11px;
  font-weight: 800;
}

.data-label {
  font-size: 11px;
  opacity: 0.78;
}

.data-title {
  font-size: 10px;
  opacity: 0.66;
}

.place-value-heading {
  font-size: 13px;
  opacity: 0.72;
}

.place-value-digit {
  font-size: 32px;
  font-weight: 800;
}

.fraction-fill {
  fill: rgba(79, 124, 255, 0.34);
}

.fraction-point {
  fill: #4f7cff;
  stroke: var(--bg);
  stroke-width: 3px;
}

.percent-cell {
  fill: transparent;
  stroke: color-mix(in srgb, currentColor 35%, transparent);
  stroke-width: 1px;
}

.percent-cell.filled {
  fill: rgba(79, 124, 255, 0.55);
}

.geometry-label,
.geometry-scale {
  fill: currentColor;
  font-family: inherit;
  font-size: 16px;
  font-weight: 820;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 6px;
  stroke-linejoin: round;
}

.geometry-scale {
  fill: var(--muted);
  font-size: 15px;
}

.data-dot {
  fill: #4f7cff;
  stroke: var(--bg);
  stroke-width: 2px;
}

.data-dot-alt {
  fill: #ff8a4f;
}

.data-marker-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
}

.data-missing-dot {
  fill: color-mix(in srgb, #ff8a4f 18%, transparent);
  stroke: #ff8a4f;
  stroke-width: 2px;
  stroke-dasharray: 3 3;
}

.data-deviation-line {
  fill: none;
  stroke: #ff8a4f;
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-dasharray: 4 3;
}

.data-deviation-label,
.data-measure-label {
  fill: #ff8a4f;
  font-family: inherit;
  font-size: 10px;
  font-weight: 850;
  text-anchor: middle;
}

.data-measure-label {
  font-size: 13px;
  text-anchor: end;
}

.probability-urn,
.probability-set {
  fill: color-mix(in srgb, currentColor 4%, transparent);
  stroke: currentColor;
  stroke-width: 2.5px;
}

.probability-ball {
  stroke: var(--bg);
  stroke-width: 2px;
}

.probability-ball-0 {
  fill: #ff6868;
}

.probability-ball-1 {
  fill: #4f7cff;
}

.probability-outcome {
  fill: color-mix(in srgb, currentColor 7%, transparent);
  stroke: color-mix(in srgb, currentColor 45%, transparent);
  stroke-width: 1.8px;
}

.probability-outcome.favorable,
.probability-set.favorable {
  fill: color-mix(in srgb, #2dbf7f 30%, transparent);
  stroke: #2dbf7f;
}

.probability-set.conditioned {
  fill: color-mix(in srgb, #4f7cff 14%, transparent);
  stroke: #4f7cff;
}

.probability-person {
  fill: color-mix(in srgb, #4f7cff 24%, var(--bg));
  stroke: #4f7cff;
  stroke-width: 2px;
}

.distribution-mass {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 5px;
}

.distribution-mass.alt {
  stroke: #ff8a4f;
}

.distribution-warning {
  fill: #ff6868;
  font-family: inherit;
  font-size: 13px;
  font-weight: 850;
  text-anchor: middle;
}

.distribution-binomial-bar {
  fill: color-mix(in srgb, #4f7cff 55%, transparent);
}

.normal-curve {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 3.5px;
}

.normal-curve.alt {
  stroke: #ff8a4f;
}

.normal-shade {
  fill: color-mix(in srgb, #2dbf7f 30%, transparent);
}

.sample-dot {
  fill: color-mix(in srgb, currentColor 14%, var(--bg));
  stroke: color-mix(in srgb, currentColor 35%, transparent);
}

.sample-dot.selected {
  fill: #2dbf7f;
  stroke: #168f5c;
}

.interval-line {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 4px;
  stroke-linecap: round;
}

.scatter-point {
  fill: #4f7cff;
  opacity: 0.82;
}

.scatter-trend {
  fill: none;
  stroke: #ff8a4f;
  stroke-width: 2.5px;
  stroke-dasharray: 6 4;
}

.calculus-curve,
.calculus-tangent,
.calculus-secant,
.calculus-approach {
  fill: none;
  stroke: #4f7cff;
  stroke-width: 3.5px;
  stroke-linecap: round;
}

.calculus-tangent {
  stroke: #ff8a4f;
}

.calculus-secant,
.calculus-approach {
  stroke: color-mix(in srgb, currentColor 50%, transparent);
  stroke-width: 2px;
  stroke-dasharray: 6 4;
}

.calculus-open-point {
  fill: var(--bg);
  stroke: #4f7cff;
  stroke-width: 3px;
}

.calculus-open-point.alt {
  stroke: #ff8a4f;
}

.calculus-card {
  fill: color-mix(in srgb, #4f7cff 10%, transparent);
  stroke: #4f7cff;
  stroke-width: 2px;
}

.calculus-check {
  fill: color-mix(in srgb, #2dbf7f 30%, transparent);
  stroke: #2dbf7f;
  stroke-width: 2px;
}

.calculus-result-card {
  fill: color-mix(in srgb, #2dbf7f 18%, transparent);
  stroke: #2dbf7f;
}

.calculus-chain-layer {
  fill: color-mix(in srgb, #4f7cff 8%, transparent);
  stroke: #4f7cff;
  stroke-width: 2px;
}

.calculus-sign {
  fill: var(--muted);
  font-family: inherit;
  font-size: 24px;
  font-weight: 900;
  text-anchor: middle;
}

.calculus-sign.positive {
  fill: #2dbf7f;
}

.calculus-sign.negative {
  fill: #ff6868;
}

.calculus-direction {
  fill: none;
  stroke: color-mix(in srgb, currentColor 55%, transparent);
  stroke-width: 2.5px;
}

.trig-identity-expression {
  fill: currentColor;
  font-family: inherit;
  font-size: 15px;
  font-weight: 850;
  text-anchor: middle;
}

.trig-identity-operation {
  fill: color-mix(in srgb, #ff8a4f 14%, var(--bg));
  stroke: #ff8a4f;
  stroke-width: 1.5px;
}

.trig-identity-operation-text {
  fill: #d9672d;
  font-family: inherit;
  font-size: 11px;
  font-weight: 850;
  text-anchor: middle;
}

.data-axis-break {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.triangle-fill {
  fill: rgba(79, 124, 255, 0.08);
}

.triangle-edge,
.triangle-right-angle,
.triangle-angle {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.triangle-right-angle {
  stroke-width: 3.2;
}

.triangle-angle {
  stroke: currentColor;
  stroke-width: 2.4;
}

.triangle-label,
.triangle-alpha {
  fill: currentColor;
  font-family: inherit;
  font-weight: 820;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 7px;
  stroke-linejoin: round;
}

.triangle-label {
  font-size: 14px;
}

.triangle-alpha {
  fill: currentColor;
  font-size: 18px;
  font-style: italic;
  stroke-width: 5px;
}

.triangle-label-left {
  text-anchor: end;
}

.triangle-label-bottom,
.triangle-label-hyp {
  text-anchor: middle;
}

.triangle-function {
  display: none;
}

.logic-token {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 2px solid var(--text);
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  vertical-align: middle;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.answer-button .logic-token {
  width: 32px;
  height: 32px;
  margin-right: 8px;
}

.logic-token.circle {
  border-radius: 50%;
}

.logic-token.square {
  border-radius: 8px;
}

.logic-token.triangle {
  width: 0;
  height: 0;
  border-left: 23px solid transparent;
  border-right: 23px solid transparent;
  border-bottom: 42px solid var(--logic-color, #4f7cff);
  background: transparent;
  border-top: 0;
}

.answer-button .logic-token.triangle {
  border-left-width: 17px;
  border-right-width: 17px;
  border-bottom-width: 30px;
}

.logic-token.arrow-up,
.logic-token.arrow-right,
.logic-token.arrow-down {
  border-radius: 8px;
}

.logic-token.arrow-up::before {
  content: "↑";
  font-size: 26px;
}

.logic-token.arrow-right::before {
  content: "→";
  font-size: 26px;
}

.logic-token.arrow-down::before {
  content: "↓";
  font-size: 26px;
}

.logic-token.placeholder {
  border-style: dashed;
  border-radius: 10px;
  color: var(--muted);
}

.logic-token.icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  padding: 0;
}

.logic-token.icon svg {
  width: 34px;
  height: 34px;
  display: block;
  fill: var(--logic-color);
  stroke: none;
}

.answer-button.visual-answer .logic-token.icon {
  width: 62px;
  height: 44px;
}

.answer-button.visual-answer .logic-token.icon svg {
  width: 31px;
  height: 31px;
}

.logic-token.blue {
  --logic-color: #4f7cff;
  border-color: #4f7cff;
  background: rgba(79, 124, 255, 0.12);
}

.logic-token.green {
  --logic-color: #20a66a;
  border-color: #20a66a;
  background: rgba(32, 166, 106, 0.12);
}

.logic-token.purple {
  --logic-color: #8b5cf6;
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.12);
}

.logic-token.red {
  --logic-color: #e5484d;
  border-color: #e5484d;
  background: rgba(229, 72, 77, 0.12);
}

.error {
  margin: auto 0;
  text-align: center;
}

.error p {
  color: var(--muted);
}

@media (min-height: 740px) {
  .answers {
    gap: 14px;
  }

  .answer-button {
    min-height: 74px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
    background: rgba(15, 23, 42, 0.48);
  }

  .modal-panel {
    width: 100%;
    max-width: none;
    gap: 14px;
    padding: 10px 16px max(16px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 50px rgba(15, 23, 42, 0.26);
  }

  .modal-handle {
    display: block;
    justify-self: center;
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted), transparent 45%);
  }

  .modal-panel h2 {
    max-width: 310px;
    justify-self: center;
    font-size: 18px;
  }

  .modal-panel p {
    max-width: 310px;
    justify-self: center;
    font-size: 13px;
  }

  .modal-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modal-actions .primary-button,
  .modal-actions .secondary-button {
    min-height: 54px;
    border-radius: 14px;
  }

  .topbar {
    grid-template-columns: 42px 1fr 42px;
    gap: 6px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

.question-area {
    min-height: clamp(124px, 27svh, 180px);
  }

  .question {
    line-height: 1.12;
  }

  .answer-button,
  .primary-button,
  .secondary-button,
  .subject-button,
  .danger-button {
    border-radius: 14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .answer-button {
    min-height: 60px;
  }
}
.math-graph {
  width: min(100%, 720px);
  margin: 10px auto;
  color: var(--text);
}

.math-graph svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  filter: drop-shadow(0 7px 14px rgba(56, 47, 32, 0.09));
}

.math-graph-title {
  margin-bottom: 7px;
  font-weight: 750;
  text-align: center;
}

.math-graph-paper { fill: #fffdf5; stroke: #c9bfaa; stroke-width: 1.5; }
.math-graph-grid-minor { fill: none; stroke: #d9e2e7; stroke-width: 0.8; }
.math-graph-grid-major { fill: none; stroke: #b8c8d0; stroke-width: 1.25; }
.math-graph-axis { fill: none; stroke: #20252a; stroke-width: 2.6; }
.math-graph-axis + .math-graph-axis { marker-end: inherit; }
.math-graph-axis-label, .math-graph-label { fill: #20252a; font: 600 16px Georgia, serif; }
.math-graph-label.collision-managed {
  paint-order: stroke fill;
  stroke: #fffdf5;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.math-graph-curve { fill: none; stroke: #111820; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.math-graph-curve.curve-1 { stroke: #285f9d; }
.math-graph-curve.curve-2 { stroke: #b34b3d; }
.math-graph-curve.curve-3 { stroke: #497a4c; }
.math-graph-curve.contextual-extension { stroke: #68737d; stroke-width: 2.25; stroke-dasharray: 9 8; opacity: .72; }
.math-graph-curve.domain-focus { stroke: #111820; stroke-width: 5; }
.math-graph-guide { fill: none; stroke: #596773; stroke-width: 1.7; stroke-dasharray: 8 7; }
.math-graph-point { fill: #111820; stroke: #111820; stroke-width: 2.5; }
.math-graph-point.open { fill: #fffdf5; }

@media (prefers-color-scheme: dark) {
  .math-graph-paper { fill: #fbf8ed; }
}

/* Algorithm task diagrams inside the existing trainer card. */
.qv-visual { display:flex; justify-content:center; align-items:center; gap:28px; min-height:128px; margin:12px 0; padding:18px; border:2px solid #cddde7; border-radius:12px; background:#fffdf5; }
.qv-row { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:22px; }
.qv-token { display:inline-grid; place-items:center; width:74px; height:74px; }
.qv-shape { border:4px solid currentColor; background:currentColor; }
.qv-circle { border-radius:50%; } .qv-square { border-radius:8px; }
.qv-triangle { width:0; height:0; border-left:38px solid transparent; border-right:38px solid transparent; border-bottom:70px solid currentColor; background:transparent; }
.qv-blue { color:#2563eb; } .qv-red { color:#dc2626; } .qv-green { color:#16a34a; } .qv-yellow { color:#eab308; } .qv-purple { color:#7c3aed; }
.qv-icon svg { width:66px; height:66px; fill:currentColor; }
.qv-ten-frame { display:grid; grid-template-columns:repeat(5,44px); grid-template-rows:repeat(2,44px); border:3px solid var(--ink); background:#fff; }
.qv-ten-cell { display:grid; place-items:center; border:1px solid #6b7f90; }
.qv-ten-cell i { width:27px; height:27px; border-radius:50%; background:#2563eb; }
.qv-ten-cell.target { background:#fff0c7; }
.qv-compare > div { text-align:center; } .qv-frame-label { display:block; margin-bottom:7px; color:var(--muted); font-weight:700; }
.qv-place { display:grid; grid-auto-flow:column; border:3px solid var(--ink); background:#fff; }
.qv-place > div { min-width:110px; text-align:center; border-right:2px solid var(--ink); }
.qv-place > div:last-child { border-right:0; } .qv-place strong,.qv-place span { display:block; padding:9px; }
.qv-place strong { border-bottom:2px solid var(--ink); background:#edf4f8; } .qv-place span { font-size:32px; font-weight:800; }
.qv-geometry { width:min(100%,520px); height:auto; display:block; }
.qv-data-table { border-collapse:collapse; min-width:min(100%,420px); font-size:22px; background:#fff; }
.qv-data-table th,.qv-data-table td { border:2px solid var(--ink); padding:12px 18px; text-align:center; }
.qv-data-table th { background:#edf4f8; }
.qv-number-line { display:block; width:min(100%,560px); height:auto; }
.qv-number-line .qv-base,.qv-number-line path { fill:none; stroke:var(--ink); stroke-width:2; }
.qv-number-line text { fill:var(--ink); text-anchor:middle; font:700 14px Inter,Segoe UI,sans-serif; }
.qv-number-line .qv-jump,.qv-number-line .qv-arrow { stroke:#2563eb; stroke-width:3; }
.qv-number-line .qv-jump-label { fill:#2563eb; font-size:17px; }
.trainer .qv-visual { max-width:100%; padding:10px; gap:12px; border:0; background:transparent; }
.trainer .qv-token { width:44px; height:44px; }
.trainer .qv-row { gap:10px; }
.trainer .qv-icon svg { width:40px; height:40px; }

.trainer .qv-visual { --ink: #213047; flex-wrap:wrap; }
.trainer .qv-ten-frame { grid-template-columns:repeat(5,30px); grid-template-rows:repeat(2,30px); }
.trainer .qv-ten-cell i { width:19px; height:19px; }
.trainer .qv-place > div { min-width:80px; }
.trainer .qv-triangle { border-left-width:22px; border-right-width:22px; border-bottom-width:40px; }

@media (max-height: 760px) {
  .trainer.has-interaction .question { font-size:22px; }
  .trainer.has-interaction .question-area { min-height:0; padding:6px 0; }
  .trainer.has-interaction .answer-keypad { gap:5px; margin:8px 0; }
  .trainer.has-interaction .answer-keypad button { min-height:42px; padding:6px; }
}

/* Quick complaint categories inside the existing report dialog. */
.report-popup-panel { max-height:calc(100dvh - 32px); overflow-y:auto; }
.report-categories { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:0;border:0;margin:16px 0; }
.report-category { position:relative;cursor:pointer; }
.report-category input { position:absolute;opacity:0; }
.report-category span { display:flex;align-items:center;min-height:54px;height:100%;padding:10px 12px;border:1px solid var(--border);border-radius:12px;background:var(--surface);color:var(--text);font-size:14px;line-height:1.3; }
.report-category input:checked + span { border-color:var(--accent);background:var(--bg);box-shadow:inset 0 0 0 1px var(--accent); }
.report-category input:focus-visible + span { outline:3px solid var(--accent);outline-offset:2px; }
.report-categories:disabled { opacity:.65; }
.report-counts { display:flex;flex-wrap:wrap;gap:8px; }
.report-counts > span { padding:8px 10px;border:1px solid var(--border);border-radius:10px; }
.report-summary h2 { font-size:20px; }.report-summary h3 { font-size:16px;margin-top:20px; }
.report-summary li { margin:12px 0; }.report-summary small { display:block;color:var(--muted);overflow-wrap:anywhere; }

/* Mathematical expressions move as a whole; prose still wraps normally. */
.math-expression { display:inline-block;max-width:100%;min-width:0;vertical-align:middle;overflow-x:auto;overflow-y:hidden;white-space:nowrap;word-break:normal;overflow-wrap:normal;hyphens:none; }
.math-expression-content { display:inline-block;white-space:nowrap;word-break:normal;overflow-wrap:normal;hyphens:none; }
.math-expression-block { display:block;width:100%;margin-top:.55em;margin-bottom:.2em;text-align:center; font-weight:400; }
.math-expression .katex,.math-expression .katex-html { white-space:nowrap; }
.math-expression .katex-display { margin:.15em 0; }
.answer-button > span { min-width:0;max-width:100%; }

/* Keep diagrams complete inside narrow task cards. */
.qv-visual { min-width:0;box-sizing:border-box;max-width:100%;color:#213047; }
.qv-compare { flex-wrap:wrap; }
.qv-compare > div { max-width:100%; }
.qv-place { width:100%;max-width:350px;grid-auto-columns:minmax(0,1fr); }
.qv-place > div,.trainer .qv-place > div { min-width:0; }
.qv-place strong { padding:7px 3px;font-size:clamp(11px,3vw,16px);overflow-wrap:normal; }
.qv-array { width:100%;max-width:350px;box-sizing:border-box;grid-template-columns:repeat(var(--qv-columns),minmax(0,1fr));gap:8px;padding:10px; }
.qv-dot { width:min(100%,25px);height:auto;aspect-ratio:1;justify-self:center; }
.qv-row,.trainer .qv-row { display:grid;width:100%;grid-template-columns:repeat(var(--qv-items),minmax(0,1fr));gap:6px; }
.qv-row .qv-token,.trainer .qv-row .qv-token { width:100%;max-width:74px;height:auto;aspect-ratio:1;box-sizing:border-box;justify-self:center; }
.qv-row .qv-triangle,.trainer .qv-row .qv-triangle { border:0;clip-path:polygon(50% 0,100% 100%,0 100%);background:currentColor; }
.qv-row .qv-placeholder { border:2px dashed #64748b;border-radius:5px;color:#213047;font-size:26px;line-height:1; }
.qv-row .qv-icon svg,.trainer .qv-row .qv-icon svg { width:100%;height:auto; }

/* Reported task diagrams need complete drawing styles in the learner app. */
.qv-array { display:grid; }
.qv-dot { display:block;flex:none;border-radius:50%;background:#2563eb; }
.qv-groups { display:flex;flex-wrap:wrap;justify-content:center;gap:8px;max-width:100%; }
.qv-groups > span { display:grid;grid-template-columns:repeat(2,18px);align-content:center;justify-content:center;gap:5px;padding:7px;border:2px solid #64748b;border-radius:10px; }
.qv-groups .qv-dot { width:18px;height:18px; }
.qv-fraction-pair { display:grid;width:100%;gap:8px; }
body.dark .trainer .qv-fraction-visual { --fraction-fill:#4f7cff;--fraction-empty:#172235;--fraction-line:#b3c3e0;background:var(--surface);color:var(--text);border-color:var(--border); }
.trainer .qv-visual { width:100%;min-height:0;margin:0;padding:8px;background:#fffdf5;color:#213047;border:1px solid #cddde7; }
.trainer .qv-place { color:#213047; }
.trainer .qv-frame-label { color:#475569;font-size:13px; }
.trainer .qv-compare { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px; }
.trainer .qv-ten-frame { width:100%;grid-template-columns:repeat(5,minmax(0,1fr));grid-template-rows:repeat(2,24px); }
.trainer .qv-ten-cell i { width:16px;height:16px; }
.trainer .qv-array { width:auto;max-width:100%;grid-template-columns:repeat(var(--qv-columns),minmax(0,18px));gap:5px;padding:5px; }
.trainer .qv-array .qv-dot { width:18px;height:18px; }
.numeric-keypad { grid-template-columns:repeat(4,minmax(0,1fr)); }
.numeric-keypad [data-input-key="Очистить"] { font-size:12px;padding-left:2px;padding-right:2px; }
.numeric-keypad [data-input-key="0"] { grid-column:span 2; }
.trainer .topbar { grid-template-columns:42px minmax(0,1fr) auto; }
@media (max-height:760px) {
  .app-shell:has(> .trainer) { padding-top:max(10px,env(safe-area-inset-top));padding-bottom:max(10px,env(safe-area-inset-bottom)); }
  .trainer.has-interaction { gap:8px; }
  .trainer.has-interaction .question-area { gap:8px;padding:0; }
  .trainer.has-interaction .numeric-keypad button { min-height:44px; }
  .trainer.has-interaction .interaction-submit { min-height:48px;padding:10px;margin-top:0; }
}
@media (max-height:700px) {
  .app-shell:has(> .trainer) { padding-top:max(6px,env(safe-area-inset-top));padding-bottom:max(6px,env(safe-area-inset-bottom)); }
  .trainer.has-interaction { gap:6px; }
  .trainer.has-interaction .numeric-keypad { gap:3px;margin:4px 0; }
  .trainer .topic-button { font-size:14px;line-height:1.15;padding:4px; }
  .trainer .qv-visual { padding:4px; }
  .trainer .qv-groups > span { padding:5px; }
  .trainer.has-interaction .question-area { gap:6px; }
  .trainer.has-interaction .question { font-size:20px;line-height:1.2; }
  .trainer.has-interaction .numeric-answer .answer-field { display:flex;align-items:center;gap:8px; }
  .trainer.has-interaction .numeric-answer .answer-field > span { flex:0 0 48px;font-size:12px; }
  .trainer.has-interaction .numeric-answer input { flex:1;width:0;min-height:44px;height:44px;padding:4px;font-size:24px; }
  .trainer .trainer-route-progress { gap:4px; }
  .trainer .trainer-route-progress > div:first-child { font-size:12px; }
}

.break-puzzle { width: 100%; max-width: 760px; margin: auto; }
.puzzle-answer { margin-top: 24px; font-size: clamp(18px, 2.5vw, 24px); line-height: 1.5; text-align: left; }
.puzzle-answer summary { cursor: pointer; color: var(--accent, #4e78ff); padding: 12px 0; font-weight: 700; }
.puzzle-answer summary:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 4px; }
.puzzle-answer p { margin: 12px 0 0; overflow-wrap: anywhere; }

.algorithm-streak { display:flex; align-items:center; gap:12px; padding:10px 12px; border:1px solid var(--border); border-radius:14px; background:var(--surface, transparent); }
.algorithm-streak strong { font-size:14px; line-height:1.35; }
.algorithm-streak-steps { display:flex; gap:7px; flex-shrink:0; }
.algorithm-streak .algorithm-streak-step { display:grid; place-items:center; width:30px; height:30px; border:2px solid var(--border); border-radius:50%; font-size:16px; font-weight:800; color:var(--muted); }
.algorithm-streak .algorithm-streak-step.is-done { background:var(--accent); border-color:var(--accent); color:#fff; }
.algorithm-streak.is-active { border-color:var(--accent); background:color-mix(in srgb, var(--accent) 12%, transparent); }
.algorithm-streak.is-active .is-next { border-color:var(--accent); color:var(--text); box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent); }
.algorithm-streak.is-complete { border-color:var(--accent); background:color-mix(in srgb,var(--accent) 18%,transparent); }
@media(max-width:360px) { .algorithm-streak { gap:9px; padding:8px; } .algorithm-streak strong { font-size:12px; } }

.feedback-ai-link { display:grid; gap:8px; color:var(--text); text-decoration:none; cursor:pointer; }
.feedback-ai-link:hover { filter:brightness(1.12); }
.feedback-ai-link:focus-visible { outline:3px solid var(--accent); outline-offset:4px; }
.feedback-ai-link span { font-size:.9em; }

.puzzle-grid { display:grid; grid-template-columns:repeat(var(--puzzle-columns),minmax(0,1fr)); gap:8px; max-width:430px; margin:24px auto; }
.puzzle-cell { display:grid; place-items:center; min-height:52px; border:1px solid var(--border); border-radius:12px; font-family:Arial,sans-serif; font-size:clamp(24px,5vw,36px); color:var(--text); }
.puzzle-cell.is-missing { color:var(--accent); border:2px solid var(--accent); }
.puzzle-options { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.puzzle-options button { font-family:Arial,sans-serif; font-size:28px; min-height:54px; padding:8px; }
.puzzle-options button.is-correct { border-color:var(--accent); background:var(--accent); color:#fff; }
.puzzle-options button.is-selected { outline:2px solid var(--accent); }
.puzzle-result { font-size:16px; line-height:1.4; }
/* A persisted story marker, shared by trainer and review cards. */
.legendary-heading { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:6px 12px; margin:0 0 10px; text-align:center; }
.legendary-heading strong { font-size:16px; line-height:1.3; }
.legendary-badge { display:inline-block; border:1px solid #d9aa3e; border-radius:999px; padding:4px 10px; color:#704200; background:#fff3cd; font-size:12px; font-weight:700; line-height:1.3; white-space:nowrap; }
.legendary-history { flex-basis:100%; min-width:0; font-size:14px; line-height:1.5; }
.legendary-history summary { cursor:pointer; padding:6px; color:var(--accent,#2448bc); }
.legendary-history summary:focus-visible { outline:2px solid currentColor; outline-offset:2px; border-radius:5px; }
.legendary-history-content { margin-top:6px; padding:12px 16px; border:1px solid var(--border,#dbe3ed); border-radius:12px; text-align:left; overflow-wrap:anywhere; }
.legendary-history-content p { margin:0 0 10px; font-size:14px; line-height:1.5; }
.legendary-history-era { font-weight:700; }
.legendary-history-status { color:var(--muted,#52627b); }
.legendary-history-content ul { margin:0; padding-left:18px; }
.legendary-history-content a { color:var(--accent,#2448bc); text-decoration:underline; }
.dark .legendary-history summary, .dark .legendary-history-content a { color:#9bbcff; }
.legendary-scope { color:var(--muted,#52627b); font-size:13px; line-height:1.45; text-align:center; margin:8px auto; max-width:600px; }
.legendary-diagram { width:100%; max-width:360px; margin:8px auto; }
.legendary-diagram svg { display:block; width:100%; height:auto; max-height:160px; }
.trainer:has(.legendary-heading) .question { font-size:clamp(17px,5vw,23px); line-height:1.35; }
@media(max-width:480px) { .legendary-heading { gap:5px; margin-bottom:7px; } .legendary-heading strong { font-size:14px; } .legendary-diagram { max-width:300px; } }
