html, body { caret-color: transparent; }
input, textarea, select, [contenteditable="true"] { caret-color: auto; }
.hint, .lead, .formula, .eq-line, .katex, h1, h2, h3, .part-title {
  -webkit-user-select: text; user-select: text; caret-color: transparent;
}
.chip, .jm-tab, .subnav, .slider-row, input[type=range], svg, button {
  caret-color: transparent;
}

:root {
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #1e293b;
  --muted: #64748b;
  --line: rgba(30, 41, 59, 0.12);
  --accent: #4FC3F7;
  --glow: #29B6F6;
  --good: #15803d;
  --warn: #a16207;
  --bad: #be123c;
}
.jm-page {
  position: relative; z-index: 1; width: min(860px, 100%);
  margin: 0 auto; padding: 28px 22px 80px;
}
.jm-back {
  display: inline-flex; margin-bottom: 18px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  text-decoration: none; font-size: 13px; font-weight: 600;
}
.jm-back:hover { border-color: var(--accent); color: var(--accent); }
.jm-eyebrow {
  margin: 0 0 6px; color: var(--glow); font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
}
.jm-page h1 {
  margin: 0 0 8px;
  font-size: clamp(1.65rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  font-family: "Hanken Grotesk", system-ui, sans-serif;
}
.jm-page .lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.jm-tabs {
  display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 14px;
  border-bottom: 1px solid var(--line);
}
.jm-tab, .chip, .btn {
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.jm-tab {
  background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 12px; cursor: pointer; border-radius: 10px 10px 0 0;
}
.jm-tab:hover { color: var(--text); }
.jm-tab.active {
  color: var(--text); background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--accent);
}
/* Legacy topic shells share JM29 tab chrome */
.tabs, .main-tabs { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tab, .main-tab {
  background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 12px; cursor: pointer; border-radius: 10px 10px 0 0;
}
.tab:hover, .main-tab:hover { color: var(--text); }
.tab.active, .main-tab.is-active, .main-tab.active {
  color: var(--text); background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.back, a.back, .back-link {
  display: inline-flex; margin-bottom: 18px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  text-decoration: none; font-size: 13px; font-weight: 600;
}
.eyebrow, .lesson-kicker {
  margin: 0 0 6px; color: var(--glow); font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
}
main.page { position: relative; z-index: 1; width: min(860px, 100%); margin: 0 auto; padding: 28px 22px 80px; }
.jm-panel.hidden, .panel.hidden, .mode-panel.hidden, .view.hidden { display: none; }
.part-title {
  margin: 4px 0 12px; font-size: 13px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
}
section.block {
  margin-bottom: 16px; padding: 18px 16px 20px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
section.block h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.35; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.formula { margin: 14px 0 0; text-align: center; color: var(--accent); font-size: 1.15em; }
.step-frame {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 10px;
  min-width: 0; min-height: 200px; padding: 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2);
}
@media (max-width: 640px) {
  .step-frame { grid-template-columns: minmax(0, 1fr); }
  .nav-btn.prev { order: 2; justify-self: start; }
  .nav-btn.next { order: 3; justify-self: end; margin-top: -44px; }
  .step-body { order: 1; }
}
.nav-btn {
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2);
  color: var(--text); font-size: 22px; font-weight: 700; cursor: pointer;
  width: 48px; height: 48px; min-height: 48px; align-self: center;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); transform: scale(1.05); }
.nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.step-body { display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 0 !important; min-height: 170px; overflow: hidden !important; min-width: 0; max-width: 100%; box-sizing: border-box; }
.step-viewport { overflow: hidden !important; padding: 0 !important; min-width: 0; max-width: 100%; min-height: 170px; box-sizing: border-box; }
.step-track { display: flex; width: 100%; transition: transform 0.35s ease; will-change: transform; }
.step-panel { display: none; }
.step-panel.active { display: block; }
.step-track > .step-panel { display: block; flex: 0 0 100%; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; padding: 8px 12px; }
.step-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--glow); }
.step-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; }
.step-text { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.step-math { margin: 6px 0 0; font-size: 1.25em; color: var(--accent); text-align: center; }
.step-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.step-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(79, 195, 247, .25); cursor: pointer; transition: transform 0.2s ease, background 0.2s ease; }
.step-dots span.on { background: var(--accent); transform: scale(1.25); }
.task-box {
  margin-top: 12px; padding: 14px; border-radius: 12px;
  border: 1px dashed rgba(79, 195, 247, .35); background: #f8fafc;
}
.count-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.count-row label { color: var(--muted); font-size: 15px; }
.count-row input {
  width: 88px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: 16px; font-weight: 700; text-align: center;
}
.btn {
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 13px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.feedback { margin-top: 10px; min-height: 1.4em; font-size: 15px; color: var(--muted); line-height: 1.45; }
.feedback.ok { color: var(--good); }
.feedback.bad { color: var(--bad); }
#comics-series-nav,
#comics-subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
#comics-series-nav .chip,
#comics-subnav .chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  cursor: pointer; font-size: 13px;
}
#comics-series-nav .chip.active,
#comics-subnav .chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.comic-caption {
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 15px;
  line-height: 1.6;
}
.comic-page { display: grid; gap: 16px; }
.comic-page-head { text-align: center; }
.comic-chapter { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.comic-page-head h2 { margin: 4px 0 0; font-size: 22px; }
.comic-body {
  padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 15px; line-height: 1.6; color: var(--text);
}
.comic-checks h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.quiz-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 12px;
}
.quiz-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.quiz-num { font-weight: 700; color: var(--accent); flex: none; }
.quiz-prompt { flex: 1; font-size: 15px; line-height: 1.5; }
.quiz-mark { font-weight: 700; margin-left: auto; }
.quiz-mark.ok { color: var(--good); }
.quiz-mark.bad { color: var(--bad); }
.quiz-mc { display: flex; flex-direction: column; gap: 8px; }
#panel-comics,
#view-comics {
  width: min(860px, 100%);
  max-width: min(860px, 100%);
  margin-left: auto;
  margin-right: auto;
}
.comic-figure {
  margin: 0 auto;
  max-width: 860px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0f172a;
  overflow: hidden;
}
.comic-figure img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}
.quiz-mc-opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 15px;
}
.quiz-mc-opt:hover:not(.locked) { border-color: var(--accent); }
.quiz-mc-opt.locked { cursor: default; }
.quiz-mc-opt.reveal-ok { border-color: var(--good); background: rgba(21, 128, 61, .08); }
.quiz-mc-opt.reveal-bad { border-color: var(--bad); background: rgba(190, 18, 60, .06); }
.quiz-result { margin-top: 10px; font-size: 14px; color: var(--muted); }
.comic-chapter-nav { text-align: center; margin-top: 8px; }
.comic-chapter-next {
  border: none; border-radius: 999px; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; font-size: 14px; padding: 10px 18px; cursor: pointer;
}
.tool-toggle-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lab-svg {
  width: 100%; max-width: 520px; display: block; margin: 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(30, 42, 50, 0.1);
  background: linear-gradient(180deg, #fffefb 0%, #fffaf3 100%);
  box-shadow: 0 10px 28px rgba(30, 50, 60, 0.08);
  overflow: hidden;
  clip-path: inset(0 round 18px);
  touch-action: none;
}
.slider-row {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; margin: 12px 0;
}
.slider-row label { font-size: 14px; color: var(--muted); min-width: 120px; }
.slider-row input[type="range"] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-top: 12px;
}
.stat-card {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); text-align: center;
}
.stat-card .val { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-card .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.badge {
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface-2);
}
.badge.on { color: #fff; background: var(--good); border-color: var(--good); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; min-height: 36px; }
.data-chip {
  padding: 6px 12px; border-radius: 999px; background: rgba(79, 195, 247, .12);
  border: 1px solid rgba(79, 195, 247, .35); font-weight: 600; cursor: pointer; font-size: 14px;
}
.data-chip:hover { background: rgba(190, 18, 60, .1); border-color: var(--bad); color: var(--bad); }
.bar-chart { width: 100%; max-width: 520px; height: 120px; margin: 12px auto 0; display: block; }
.subnav {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; align-items: center;
}
.subnav .chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 10px;
  cursor: pointer; font-size: 14px;
}
.subnav .chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.lab { display: none; }
.lab.active { display: block; }
