:root {
  --paper: #f6f2e7;
  --paper-2: #efe9da;
  --ink: #14161a;
  --vermilion: #c0472a;
  --blue: #1e3a5f;
  --success: #2f6b4f;
  --amber: #b07a1e;
  --hairline: #d9d2bf;
  --muted: #6e685a;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: "Avenir Next", Avenir, "Gill Sans", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    180deg,
    transparent 0 31px,
    rgba(20, 22, 26, 0.045) 31px 32px
  );
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  color: inherit;
  font-size: 13px;
}

.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;
}

/* ===== Top bar ===== */
.topbar {
  height: 60px;
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
}

.wordmark {
  min-width: 210px;
  line-height: 1.15;
}
.wordmark .wm-title {
  font-size: 14px;
  letter-spacing: 0.22em;
  font-weight: 600;
  text-transform: uppercase;
}
.wordmark .wm-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 20px;
  height: 100%;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 2px;
  font-size: 13px;
  color: var(--muted);
  height: 100%;
}
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--vermilion);
  font-weight: 600;
}
.tab:hover {
  color: var(--ink);
}

.progress {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.progress:hover .progress-label {
  color: var(--vermilion);
}
.progress .progress-label {
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.track {
  width: 180px;
  height: 6px;
  border: 1px solid var(--hairline);
  background: var(--paper-2);
  border-radius: 3px;
  overflow: hidden;
}
.track .fill {
  height: 100%;
  background: var(--vermilion);
  width: 20%;
  transition: width 0.25s ease;
}

.stats {
  display: flex;
  align-items: center;
  gap: 22px;
}
.stat {
  text-align: right;
  line-height: 1.15;
}
.stat .stat-val {
  display: block;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat .stat-lbl {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ghost {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 7px 14px;
  color: var(--ink);
  background: transparent;
}
.ghost:hover {
  border-color: var(--ink);
}

/* ===== Shell ===== */
.shell {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ===== Left rail ===== */
.rail {
  flex: 0 0 264px;
  border-right: 1px solid var(--hairline);
  padding: 22px 18px;
  overflow-y: auto;
}
.rail .chapter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.rail .chapter-label input.scope-all {
  flex: 0 0 14px;
}
.section-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 9px 10px 9px 14px;
  border: none;
  border-left: 3px solid transparent;
  margin-bottom: 2px;
  text-align: left;
  font-size: inherit;
  line-height: inherit;
}
.section-row .sr-check {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: transparent;
  position: relative;
}
.section-row[aria-pressed="true"] .sr-check {
  background: var(--vermilion);
  border-color: var(--vermilion);
}
.section-row[aria-pressed="true"] .sr-check::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.section-row .sr-body {
  flex: 1;
  min-width: 0;
}
.section-row .sr-reco-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--vermilion);
  border-radius: 50%;
  align-self: center;
}
.section-row[aria-pressed="false"] .sr-title,
.section-row[aria-pressed="false"] .sr-count,
.section-row[aria-pressed="false"] .sr-bar {
  opacity: 0.4;
}
.section-row.current {
  border-left-color: var(--vermilion);
  background: rgba(192, 71, 42, 0.04);
}
.section-row .sr-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.section-row .sr-num {
  flex: 0 0 26px;
  width: 26px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.section-row.current .sr-num {
  color: var(--vermilion);
}
.section-row .sr-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
}
.section-row.current .sr-title {
  font-weight: 600;
}
.section-row .sr-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.section-row .sr-bar {
  display: block;
  height: 3px;
  background: var(--hairline);
  margin-top: 6px;
  border-radius: 2px;
  overflow: hidden;
}
.section-row .sr-bar i {
  display: block;
  height: 100%;
  background: var(--blue);
}

.due-block {
  margin-top: 22px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 14px;
}
.due-block .due-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}
.due-block .due-sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}
.due-block .ghost {
  width: 100%;
}

.keys {
  margin-top: 22px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.9;
}
.keys .keys-title {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.keys kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0 5px;
  font-size: 10px;
  background: var(--paper-2);
}

/* ===== Center ===== */
.center {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 30px clamp(32px, 2.5vw, 40px) 40px;
  display: flex;
  justify-content: center;
}
.center-inner {
  width: 100%;
  max-width: 1000px;
}

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

/* Problem card */
.problem-card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  box-shadow: 0 2px 14px rgba(20, 22, 26, 0.07);
  padding: 28px 30px 24px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.eyebrow .section-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip {
  font-size: 11px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 2px 8px;
  background: var(--paper-2);
  color: var(--ink);
}
.chip.skill {
  color: var(--blue);
  border-color: rgba(30, 58, 95, 0.35);
}
.chip.pretest {
  color: var(--vermilion);
  border-color: rgba(192, 71, 42, 0.45);
  letter-spacing: 0.04em;
  font-weight: 600;
}
.chip.difficulty {
  color: var(--muted);
}
.chip.difficulty.easy {
  color: var(--success);
}
.chip.difficulty.medium {
  color: var(--amber);
}
.chip.difficulty.hard {
  color: var(--vermilion);
}

.exercise-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  margin-top: 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.book-link {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-style: normal;
  color: var(--vermilion);
  text-decoration: none;
  white-space: nowrap;
}
.book-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.instruction {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.prompt {
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1.35;
  margin: 20px 0 26px;
  padding-top: 14px;
  border-top: 2px solid var(--vermilion);
  word-break: break-word;
}
.prompt .mono {
  font-family: var(--font-mono);
  font-size: 34px;
  white-space: nowrap;
}
.prompt.prose {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.55;
  max-height: 300px;
  overflow-y: auto;
}
.prompt.prose .mono {
  font-size: 17px;
  white-space: normal;
}

/* Typeset math: stacked fraction, radical, raised exponents */
.frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 34px;
  line-height: 1.15;
}
.frac .fr-num,
.frac .fr-den {
  text-align: center;
  line-height: 1.15;
  padding: 0 6px;
}
.frac .fr-bar {
  height: 1px;
  background: var(--ink);
  margin: 3px 0;
  width: 100%;
}
.frac sup {
  font-size: 19px;
  line-height: 0;
  position: relative;
  top: 0.05em;
}
.rad {
  display: inline-flex;
  align-items: flex-start;
  font-family: var(--font-mono);
  font-size: 34px;
  line-height: 1.2;
  white-space: nowrap;
  vertical-align: baseline;
}
.rad .rad-sign {
  display: inline-block;
}
.rad .rad-in {
  display: inline-block;
  border-top: 1px solid var(--ink);
  padding: 0 3px 0 1px;
}
.prompt sup {
  font-size: 18px;
  line-height: 1;
}

/* Multi-part prompts: one labelled part per line, label stays with its text. */
.prompt-lead {
  margin-bottom: 8px;
}
.prompt-lead:empty {
  display: none;
}
ol.parts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.parts .part {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
}
.parts .part-label {
  flex: none;
  margin-right: 0.25em;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.answer-row .eq {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--muted);
}
.answer-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 20px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}
textarea.answer-input {
  resize: none;
  overflow-y: auto;
  line-height: 1.35;
  min-height: 50px;
  max-height: 180px;
  align-self: stretch;
  font-size: 18px;
}
.answer-input::placeholder {
  color: #b7af9c;
}
.answer-input:focus {
  border-color: var(--vermilion);
  outline: 2px solid rgba(192, 71, 42, 0.3);
  outline-offset: 0;
}
.btn-primary {
  background: var(--vermilion);
  color: #fdfbf5;
  border: 1px solid var(--vermilion);
  border-radius: 3px;
  padding: 13px 20px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-primary:hover {
  background: #a63c23;
}

.quiet-row {
  display: flex;
  gap: 20px;
  margin-top: 12px;
}
/* Paste-question control: link-like affordance alongside the text buttons. */
.paste-question {
  display: inline-flex;
  align-items: center;
  color: var(--blue);
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.paste-question:hover {
  color: var(--vermilion);
}
.paste-question[hidden] {
  display: none;
}
.text-btn {
  color: var(--blue);
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn:hover {
  color: var(--vermilion);
}
.text-btn.muted {
  color: var(--muted);
}

/* Pre-test question counter under the quiet row. */
.pretest-progress {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}

/* Feedback strip */
.empty-scope {
  margin-top: 18px;
  padding: 40px 32px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  text-align: center;
}
.empty-scope .es-title {
  font-family: var(--font-display);
  font-size: 24px;
  margin-bottom: 6px;
}
.empty-scope .es-body {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

.feedback {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 3px;
  font-size: 14px;
  border: 1px solid var(--hairline);
}
.feedback.hidden {
  display: none;
}
.feedback.correct {
  border-left: 3px solid var(--success);
  background: rgba(47, 107, 79, 0.06);
  color: var(--success);
}
.feedback.incorrect {
  border-left: 3px solid var(--vermilion);
  background: rgba(192, 71, 42, 0.05);
}
.feedback.warn {
  border-left: 3px solid var(--amber);
  background: rgba(176, 122, 30, 0.06);
  color: var(--amber);
}
.feedback .fb-head {
  font-weight: 600;
}
.feedback.correct .fb-head {
  color: var(--success);
}
.feedback.incorrect .fb-head {
  color: var(--vermilion);
}
.feedback.warn .fb-head {
  color: var(--amber);
}
.feedback .fb-book {
  color: var(--muted);
}
.feedback .fb-answer {
  font-family: var(--font-mono);
  font-size: 15px;
  white-space: nowrap;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 3px 8px;
  margin-left: 4px;
}
.feedback .fb-answer sup {
  font-size: 0.62em;
  line-height: 1;
}
.feedback .fb-reason {
  color: var(--muted);
  margin-top: 8px;
}
.feedback .fb-pretest-line {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.feedback .next-btn {
  display: inline-block;
  margin-top: 12px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 8px 16px;
  font-weight: 600;
}
.feedback .next-btn:hover {
  background: var(--ink);
  color: var(--paper);
}
.feedback .fb-actions {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.streak-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--success);
}

/* Session sheet (closes the practice column) */
#viewPractice.active {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.session-sheet {
  margin-top: auto;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 16px 18px;
}
.session-sheet .ss-head {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.ss-pips {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}
.ss-pip {
  width: 8px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--hairline);
  cursor: pointer;
}
.ss-pip.unanswered {
  background: var(--hairline);
}
.ss-pip.correct {
  background: var(--success);
}
.ss-pip.wrong {
  background: #b4392b;
}
.ss-pip:hover {
  opacity: 0.78;
}
.ss-pip.current {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}
.session-sheet .ss-note {
  font-size: 11px;
  color: var(--muted);
}

/* Above the question: the sheet's own `margin-top: auto` would push it back to
   the foot of the column, so a two-class rule cancels it and leaves air below. */
.session-sheet.session-sheet--top {
  margin-top: 0;
  margin-bottom: 20px;
}

.session-sheet.session-sheet--top .ss-pips {
  flex-wrap: wrap;
}

/* ===== Right column ===== */
.rightcol {
  flex: 0 0 340px;
  border-left: 1px solid var(--hairline);
  padding: 22px 20px;
  overflow-y: auto;
}

.tutor-preview {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--paper);
}
.tutor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.tutor-head .tutor-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 600;
}
.tutor-head .tutor-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
}
.tutor-thread {
  flex: 0 0 auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px 18px;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
.chat-msg.tutor {
  align-items: flex-start;
  text-align: left;
}
.chat-msg.tutor .msg-body {
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.5;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.chat-msg.learner {
  align-self: flex-end;
  align-items: flex-end;
  background: var(--paper-2);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  max-width: 78%;
  padding: 8px 12px;
  word-break: break-word;
}
.msg-label {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.msg-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}
.chat-msg .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.chat-msg sup {
  font-size: 0.75em;
  line-height: 0;
  vertical-align: 0.42em;
  position: static;
}
.prompt-inline {
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
  padding: 0 2px;
}
.prompt-inline .mono,
.prompt-inline .frac,
.prompt-inline .rad {
  font-size: 13px;
}
.prompt-inline .frac .fr-num,
.prompt-inline .frac .fr-den {
  padding: 0 3px;
}
.prompt-inline .frac .fr-bar {
  margin: 1px 0;
}
.prompt-inline sup {
  font-size: 0.68em;
  line-height: 0;
  vertical-align: super;
  position: static;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 6px 0 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-blink 1s infinite;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typing-blink {
  0%,
  60%,
  100% {
    opacity: 0.25;
  }
  30% {
    opacity: 1;
  }
}
.tutor-foot {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-top: 1px solid var(--hairline);
  font-size: 11px;
  color: var(--muted);
}
.tutor-foot .mono {
  font-family: var(--font-mono);
}

.tutor-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
}
textarea.tutor-input {
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  min-height: 36px;
  max-height: 120px;
}
.tutor-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
}
.tutor-input::placeholder {
  color: #b7af9c;
}
.tutor-input:focus {
  border-color: var(--vermilion);
  outline: 2px solid rgba(192, 71, 42, 0.3);
  outline-offset: 0;
}
.tutor-send {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 0;
  background: var(--vermilion);
  color: #fdfbf5;
  border: none;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.tutor-send:hover {
  background: #a63c23;
}

/* ===== Tutor view (full tab) ===== */
#viewTutor.active {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  min-height: 0;
}
.tutor-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - 148px);
  min-height: 520px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  box-shadow: 0 2px 14px rgba(20, 22, 26, 0.07);
}

/* Context strip above the thread (scrolls with the page) */
.tutor-context {
  flex: 0 0 auto;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--hairline);
}
.tc-top {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.tc-prompt {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.3;
  margin: 8px 0 10px;
  word-break: break-word;
}
.tc-prompt .frac {
  font-size: 20px;
}
.tc-prompt .frac sup {
  font-size: 12px;
}
.tc-prompt .rad {
  font-size: 20px;
}
.tc-prompt .mono {
  font-family: var(--font-mono);
  font-size: 20px;
}
.tc-prompt.prose {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.5;
  max-height: 110px;
  overflow-y: auto;
}
.tc-prompt.prose .mono {
  font-size: 14px;
  white-space: normal;
}
.tc-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  text-align: right;
}
.tc-book {
  text-align: right;
  margin-top: 4px;
}

/* Stacked tutor sections with sticky headers */
.tutor-block {
  flex: 0 0 auto;
}
.tutor-block-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 12px 20px 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

/* Tutor panels */
.tutor-panel {
  flex: 0 0 auto;
  padding: 14px 20px 16px;
  border-bottom: 1px solid var(--hairline);
}
.tutor-panel sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: 0.42em;
  position: static;
}
.panel-lead {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink);
  margin: 0 0 4px;
}
.need-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.need-row:last-child {
  border-bottom: none;
}
.need-name {
  display: block;
  font-family: var(--font-display);
  font-size: 14.5px;
  margin-bottom: 2px;
}
.need-rule {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.panel-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}
.need-rule.muted {
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-ui);
}
.solve-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.solve-step:last-child {
  border-bottom: none;
}
.solve-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  flex: 0 0 16px;
  text-align: right;
}
.solve-text {
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
  min-width: 0;
}
.solve-text .mono {
  font-family: var(--font-mono);
  font-size: 13px;
}
.solve-book {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

/* Practice-side compact transcript preview */
.tutor-preview-thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
}
.tutor-preview-thread .chat-msg.tutor .msg-body {
  font-size: 12px;
}
.tutor-preview-thread .chat-msg.learner {
  font-size: 11px;
}
.tutor-preview-thread .chat-msg .mono {
  font-size: 10.5px;
}
.tutor-preview-thread .msg-label {
  font-size: 8px;
}
.tutor-preview-thread .msg-time {
  font-size: 8.5px;
}

.tutor-open-btn {
  display: block;
  width: calc(100% - 28px);
  margin: 12px 14px 14px;
  padding: 9px 0;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
.tutor-open-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

/* ===== Ask-the-tutor pill (narrow widths) ===== */
.tutor-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  height: 34px;
  display: none;
  align-items: center;
  padding: 0 18px;
  border: 1px solid var(--vermilion);
  border-radius: 17px;
  background: var(--paper-2);
  color: var(--vermilion);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(20, 22, 26, 0.14);
}
.tutor-fab:hover {
  background: var(--vermilion);
  color: #fdfbf5;
}
body.tutor-active .tutor-fab {
  display: none;
}
@media (max-width: 1200px) {
  .tutor-fab {
    display: inline-flex;
  }
}

.skills-mini {
  margin-top: 18px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
}
.skills-mini .sm-head {
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
}
.skills-mini .sm-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
}
.skills-mini .sm-row:last-child {
  border-bottom: none;
}
.skills-mini .sm-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.skills-mini .sm-name {
  font-size: 12px;
  font-weight: 500;
}
.state-chip {
  font-size: 10px;
  letter-spacing: 0.05em;
  border-radius: 3px;
  padding: 1px 7px;
  margin-left: auto;
}
.state-chip.learning {
  color: var(--amber);
  background: rgba(176, 122, 30, 0.12);
}
.state-chip.fluent {
  color: var(--blue);
  background: rgba(30, 58, 95, 0.1);
}
.state-chip.mastered {
  color: var(--success);
  background: rgba(47, 107, 79, 0.12);
}
.pips {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
}
.pip.on {
  background: var(--blue);
  border-color: var(--blue);
}
.skills-mini .sm-review {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ===== Progress view ===== */
.sheet {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 24px 26px;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 2px;
}
.sheet-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 18px;
}
.skills-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.skills-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
}
.skills-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.skills-table tr:last-child td {
  border-bottom: none;
}
.skills-table .skill-name {
  font-weight: 500;
}
.acc-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: var(--hairline);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}
.acc-bar i {
  display: block;
  height: 100%;
  background: var(--blue);
}
.acc-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* Progress view sub-tabs (Skills / Rules) */
.progress-tabs {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 18px;
}
.progress-tab {
  border: none;
  background: transparent;
  padding: 0 0 9px;
  margin-bottom: -1px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.progress-tab:hover {
  color: var(--ink);
}
.progress-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--vermilion);
  font-weight: 600;
}
#progressSkillsPanel[hidden],
#progressRulesPanel[hidden] {
  display: none;
}

/* Rules panel */
.rules-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.rules-select {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
}
.rules-summary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}
.rules-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.rules-chip {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.rules-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.rules-chip[aria-pressed="true"] {
  background: var(--vermilion);
  color: #fdfbf5;
  border-color: var(--vermilion);
}
.rules-section-head {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 5px;
  margin: 18px 0 8px;
}
.rules-section-head:first-child {
  margin-top: 0;
}
.rules-skill-head {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 14px 0 6px;
}
.rule-card {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--vermilion);
  border-radius: 3px;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--paper);
}
.rule-card .rule-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.rule-card .rule-html {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.rule-card .rule-html sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: 0.42em;
  position: static;
}

/* ===== Summary view ===== */
.summary-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 24px;
}
.summary-sheet {
  width: 100%;
  max-width: 620px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  box-shadow: 0 2px 14px rgba(20, 22, 26, 0.06);
  padding: 28px 36px;
  text-align: center;
}
.summary-sheet .sum-title {
  font-family: var(--font-display);
  font-size: 28px;
  margin: 0;
}
.summary-sheet .sum-breakdown {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
}
.summary-sheet .sum-pct {
  font-family: var(--font-display);
  font-size: 56px;
  line-height: 1;
  margin: 12px 0 6px;
}
.sum-section {
  text-align: left;
  margin-top: 18px;
}
.sum-section .sum-h {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 5px;
  margin-bottom: 8px;
}
.sum-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.sum-row .sum-name {
  flex: 1;
}
.sum-row .sum-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  width: 38px;
  text-align: right;
}
.sum-row .bar {
  flex: 0 0 140px;
  height: 6px;
  background: var(--hairline);
  border-radius: 3px;
  overflow: hidden;
}
.sum-row .bar i {
  display: block;
  height: 100%;
  background: var(--blue);
}
.sum-row.due .sum-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.summary-sheet .btn-primary {
  margin-top: 20px;
  font-size: 14px;
  padding: 13px 26px;
}
.summary-sheet .sum-row.missed {
  justify-content: center;
}
.summary-sheet .sum-row.missed .sum-name {
  flex: none;
}
.summary-sheet .pretest-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
}
.summary-sheet #retakePretest {
  margin-top: 18px;
}

/* ===== Scope block (rail) ===== */
.scope-block {
  margin-top: 18px;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 12px 14px;
}
.scope-block .scope-title {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.scope-block .scope-count {
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.3;
}
.scope-block .scope-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ===== Scope modal ===== */
.scope-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 22, 26, 0.28);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 20px 24px;
}
.scope-backdrop[hidden] {
  display: none;
}
.scope-sheet {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  box-shadow: 0 18px 48px rgba(20, 22, 26, 0.22);
  width: 100%;
  max-width: 700px;
  padding: 26px 30px 22px;
  animation: scope-in 180ms ease;
}
@keyframes scope-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.scope-eyebrow {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.scope-sheet .scope-title {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.1;
  margin: 4px 0 2px;
}
.scope-subline {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* Step 1 pre-test block at the top of the scope sheet. */
.pretest-block {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--paper-2);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.pretest-step {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.pretest-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pretest-main {
  flex: 1;
  min-width: 0;
}
.pretest-title {
  font-family: var(--font-display);
  font-size: 15.5px;
}
.pretest-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.pretest-chip {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.08em;
  border-radius: 3px;
  padding: 2px 8px;
  white-space: nowrap;
}
.pretest-chip.required {
  color: var(--vermilion);
  border: 1px solid rgba(192, 71, 42, 0.45);
}
.pretest-block .seg {
  margin-top: 10px;
}
.pretest-chip.passed {
  color: var(--success);
  border: 1px solid rgba(47, 107, 79, 0.45);
}

.scope-rows {
  border-top: 1px solid var(--hairline);
}
.scope-suggested {
  font-size: 11px;
  color: var(--muted);
  margin: 14px 0 8px;
}
.scope-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
}
.scope-row:hover {
  background: var(--paper-2);
}
.scope-row:focus-within {
  background: var(--paper-2);
}
.scope-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.scope-row input[type="checkbox"]:checked {
  background: var(--vermilion);
  border-color: var(--vermilion);
}
.scope-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.scope-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scope-row-line1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.scope-row .scope-row-num {
  flex: 0 0 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.scope-row .scope-row-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 14.5px;
}
.scope-row .scope-row-meta {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}
.scope-row-line2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scope-row .scope-reason {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}
.scope-row .scope-reco {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--vermilion);
  border: 1px solid rgba(192, 71, 42, 0.45);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.scope-row.locked {
  cursor: default;
  opacity: 0.55;
}
.scope-row.locked:hover,
.scope-row.locked:focus-within {
  background: transparent;
}
.scope-row.locked .scope-row-title,
.scope-row.locked .scope-row-meta,
.scope-row.locked .scope-row-num,
.scope-row.locked .scope-reason {
  color: var(--muted);
}
.scope-lock-label {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.scope-lock-note {
  font-size: 11px;
  color: var(--vermilion);
  margin: 10px 2px 0;
}

/* Master select/clear all (scope sheet + rail) */
input.scope-all {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  position: relative;
}
input.scope-all:checked {
  background: var(--vermilion);
  border-color: var(--vermilion);
}
input.scope-all:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input.scope-all:indeterminate {
  background: var(--vermilion);
  border-color: var(--vermilion);
}
input.scope-all:indeterminate::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 5px;
  width: 8px;
  height: 2px;
  background: var(--paper);
}
.scope-master {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 10px;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
}
.scope-master:hover,
.scope-master:focus-within {
  background: var(--paper-2);
}
.scope-master-label {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 14.5px;
}
.scope-master-count {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.scope-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.scope-quick-btn {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.scope-quick-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.scope-quick-btn.clear-all {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #4a4e57;
  border-color: #d9d2bf;
}
.scope-quick-btn.clear-all:hover {
  border-color: var(--vermilion);
  color: var(--vermilion);
}

.scope-length {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.scope-length-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  overflow: hidden;
}
.seg-btn {
  padding: 5px 14px;
  border: none;
  border-right: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
}
.seg-btn:last-child {
  border-right: none;
}
.seg-btn.active {
  background: var(--vermilion);
  color: #fdfbf5;
}

.scope-live {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
}
.scope-live.empty {
  color: var(--vermilion);
}

.scope-footer {
  display: flex;
  align-items: center;
  gap: 18px;
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary:disabled:hover {
  background: var(--vermilion);
}
.scope-cancel {
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  border: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.scope-cancel:hover {
  color: var(--ink);
}

/* ===== Book viewer modal ===== */
.book-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 22, 26, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.book-backdrop[hidden] {
  display: none;
}
.book-sheet {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  box-shadow: 0 18px 48px rgba(20, 22, 26, 0.22);
  width: 100%;
  max-width: 760px;
  height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scope-in 180ms ease;
}
.book-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  flex: 0 0 auto;
}
.book-head .book-label {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}
.book-head .book-section {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.book-head .book-close {
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 2px 7px;
  flex: 0 0 auto;
}
.book-head .book-close:hover {
  color: var(--ink);
}
.book-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--paper-2);
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.book-body img {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
  border: 1px solid var(--hairline);
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(20, 22, 26, 0.14);
}
.book-foot {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  flex: 0 0 auto;
}
.book-foot .book-open-pdf {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--vermilion);
  text-decoration: none;
}
.book-foot .book-open-pdf:hover {
  text-decoration: underline;
}
.book-foot .book-close-btn {
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.book-foot .book-close-btn:hover {
  color: var(--ink);
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .rightcol {
    display: none;
  }
  .rail {
    flex-basis: 210px;
  }
  .prompt {
    font-size: 32px;
  }
  .prompt .mono {
    font-size: 28px;
  }
}
@media (max-width: 1024px) {
  .wordmark {
    min-width: 150px;
  }
  .progress .track {
    width: 110px;
  }
  .stats {
    gap: 14px;
  }
}

/* ===== Mobile-only chrome (hidden on desktop) ===== */
.mobile-tabs,
.mobile-scope-chip,
.rail-handle,
.rail-head,
.mobile-backdrop {
  display: none;
}

/* ===== Mobile layout — applies at every viewport ===== */
:root {
  --tabbar-h: calc(49px + env(safe-area-inset-bottom));
}

body {
  overflow-x: hidden;
}

/* Top bar → compact grid: wordmark+counter / progress bar / scope chip+stats */
.topbar {
  height: auto;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "wordmark counter"
    "track    track"
    "scope    stats";
  align-items: center;
  column-gap: 14px;
  row-gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
}
.topbar .tabs {
  display: none;
}
.topbar .progress {
  display: contents;
}
.topbar .progress .progress-label {
  grid-area: counter;
  justify-self: end;
}
.topbar .track {
  grid-area: track;
  width: 100%;
}
.wordmark {
  grid-area: wordmark;
  min-width: 0;
}
.wordmark .wm-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wordmark .wm-sub {
  display: none;
}
.stats {
  grid-area: stats;
  justify-self: end;
  gap: 12px;
}
.stats .stat-val {
  font-size: 13px;
}
#endSession {
  display: none;
}

.mobile-scope-chip {
  grid-area: scope;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--paper-2);
  color: var(--ink);
}
.mobile-scope-chip .msc-title {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.mobile-scope-chip .msc-value {
  flex: 0 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Single column */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rightcol {
  display: none;
}

/* Rail → fixed bottom sheet */
.rail {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  flex: none;
  background: var(--paper);
  border-right: none;
  border-top: 1px solid var(--hairline);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  max-height: 85dvh;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -8px 30px rgba(20, 22, 26, 0.18);
  transform: translateY(105%);
  transition: transform 220ms ease;
  visibility: hidden;
}
body.rail-open .rail {
  transform: translateY(0);
  visibility: visible;
}
.rail-handle {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline);
  margin: 4px auto 10px;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.rail-head .rail-head-title {
  font-family: var(--font-display);
  font-size: 18px;
}
.rail-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  border-radius: 3px;
}
.rail-close:hover {
  color: var(--ink);
}
.keys {
  display: none;
}

/* Center */
.center {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  padding: 16px 16px calc(64px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}
.center-inner {
  max-width: none;
}
.problem-card {
  padding: 18px 16px;
}
.prompt {
  font-size: clamp(22px, 7vw, 30px);
  margin: 14px 0 18px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.prompt .mono {
  font-size: clamp(22px, 7vw, 30px);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.prompt.prose {
  max-height: none;
}
.frac {
  font-size: clamp(22px, 6vw, 28px);
}
.rad {
  font-size: clamp(22px, 6vw, 28px);
}

/* Answer controls stack, ≥44px touch targets, 16px inputs */
.answer-row {
  flex-wrap: wrap;
  align-items: stretch;
}
.answer-row .eq {
  display: none;
}
.answer-input,
textarea.answer-input {
  flex: 1 1 100%;
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}
#checkBtn {
  flex: 1 1 100%;
  width: 100%;
  min-height: 48px;
}
.quiet-row {
  gap: 12px;
  margin-top: 12px;
}
#explainBtn,
#skipBtn {
  min-height: 44px;
  font-size: 14px;
}
.text-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Progress → stacked cards */
.skills-table {
  display: block;
}
.skills-table thead {
  display: none;
}
.skills-table tbody {
  display: block;
}
.skills-table tr {
  display: block;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  margin-bottom: 12px;
  padding: 4px 14px 8px;
}
.skills-table td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}
.skills-table tr td:last-child {
  border-bottom: none;
}
.skills-table td::before {
  content: attr(data-label);
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.skills-table td.skill-name {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  padding: 10px 0 2px;
  border-bottom: none;
}
.skills-table td.skill-name::before {
  content: none;
}

/* Sheets fluid / full width */
.sheet {
  padding: 18px 16px;
}
.summary-wrap {
  padding: 12px 12px;
}
.summary-sheet {
  max-width: none;
  padding: 20px 16px;
}

/* Rules panel (mobile) */
.progress-tabs {
  gap: 16px;
}
.progress-tab {
  min-height: 44px;
}
.rules-head {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.rules-select {
  width: 100%;
  min-height: 44px;
}
.rules-summary {
  margin-left: 0;
  text-align: left;
  white-space: normal;
}
.rules-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
}
.rules-chip {
  flex: 0 0 auto;
  min-height: 44px;
}
.rule-card {
  width: 100%;
}

.scope-backdrop {
  padding: 0;
  align-items: flex-end;
}
.scope-sheet {
  max-width: none;
  border-radius: 16px 16px 0 0;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

.book-backdrop {
  padding: 0;
}
.book-sheet {
  max-width: none;
  height: 100dvh;
  border-radius: 0;
}

/* Tutor */
#viewTutor.active {
  max-width: none;
  width: 100%;
}
.tutor-sheet {
  height: calc(var(--vvh, 100dvh) - var(--topbar-h, 0px) - var(--tabbar-h, 0px) - 16px);
  min-height: 0;
}
.tutor-thread {
  min-height: 0;
}
.tutor-panel {
  flex: 0 0 auto;
  min-height: 0;
}
.tutor-context {
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
}
.tutor-foot {
  display: none;
}
/* When the on-screen keyboard is open, collapse the context chrome so the
       thread and composer get the (smaller) visible viewport; the two stacked
       sections stay in the scrolling sheet. */
body.kb-open .tutor-context {
  display: none;
}
body.kb-open .tutor-sheet {
  height: calc(var(--vvh, 100dvh) - var(--topbar-h, 0px) - 16px);
}
.tutor-composer {
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
textarea.tutor-input,
.tutor-input {
  font-size: 16px;
}
.tutor-send {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
}

/* Bottom tab bar */
.mobile-tabs {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  border-top: 1px solid var(--hairline);
  background: var(--paper);
  box-shadow: 0 -2px 10px rgba(20, 22, 26, 0.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tabs .mtab {
  flex: 1 1 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 0;
}
.mobile-tabs .mtab[aria-selected="true"] {
  color: var(--vermilion);
  font-weight: 600;
}

/* Mobile backdrop (rail sheet) */
.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(20, 22, 26, 0.32);
  display: block;
}
.mobile-backdrop[hidden] {
  display: none;
}

/* FAB above the tab bar */
.tutor-fab {
  display: inline-flex;
  bottom: calc(64px + env(safe-area-inset-bottom));
}

/* Touch targets */
.seg-btn {
  min-height: 44px;
  padding: 5px 12px;
}
.scope-quick-btn {
  min-height: 44px;
}

.pretest-retake {
  margin: 18px 0 6px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}
.pretest-retake-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.pretest-retake .seg {
  margin-bottom: 10px;
}

.summary-sheet .pretest-verdict {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.2;
  margin-top: 18px;
}
.summary-sheet .pretest-verdict.passed {
  color: var(--success);
}
.summary-sheet .pretest-verdict.failed {
  color: var(--vermilion);
}
.summary-sheet .pretest-sentence {
  font-size: 14px;
  color: var(--ink);
  margin-top: 6px;
}

.summary-sheet .pretest-counts {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

/* Shared bits added with the mobile page structure. */
.ss-count,
.practice-note,
.app-meta,
.scope-head,
.scope-close,
.scope-show-sections,
.empty-glyph {
  display: none;
}
.scope-body {
  display: contents;
}
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 8px 16px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}
.btn-outline:hover {
  background: var(--ink);
  color: var(--paper);
}
.sum-eyebrow {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.score-line {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink);
  margin-top: 8px;
}
.sum-hairline {
  height: 1px;
  background: var(--hairline);
  margin: 16px 0;
}
.sum-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.summary-sheet .sum-stack .btn-primary,
.summary-sheet .sum-stack .btn-outline {
  width: 100%;
  min-height: 44px;
  margin-top: 0;
  font-size: 14px;
}
.wrong-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-bottom: 3px;
}
.wrong-count {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.wrong-row {
  padding: 9px 0 10px;
  border-top: 1px solid var(--hairline);
  min-width: 0;
}
.wrong-section {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.wrong-prompt {
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.35;
}
.feedback .fb-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.feedback .fb-formula {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.feedback .fb-alt {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.feedback .fb-quiet {
  margin-top: 6px;
  border-top: 1px solid var(--hairline);
}
.rules-skill-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.rule-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== Phone layout (≤600px) =============================================
   The unconditional rules above define the desktop look at every width.
   Everything below refines it for phones only; desktop is untouched. */
@media (max-width: 600px) {
  :root {
    --tabbar-h: calc(56px + env(safe-area-inset-bottom));
  }

  /* -- App bar: wordmark | scope chip | item counter, full-bleed progress -- */
  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 8px;
    row-gap: 4px;
    height: auto;
    flex: 0 0 auto;
    padding: calc(8px + env(safe-area-inset-top)) 16px 6px;
    border-bottom: none;
  }
  .topbar .wordmark {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
  }
  .topbar .wordmark .wm-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-transform: none;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .mobile-scope-chip {
    order: 2;
    flex: 0 0 auto;
    gap: 0;
    padding: 0 12px;
    min-width: 0;
    min-height: 34px;
    height: 34px;
    border-radius: 999px;
  }
  .topbar .mobile-scope-chip .msc-title {
    font-size: 10px;
    letter-spacing: 0.1em;
    line-height: 1;
  }
  .topbar .mobile-scope-chip .msc-value {
    display: none;
  }
  .topbar .progress .progress-label {
    order: 3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
  }
  .topbar .track {
    order: 4;
    flex: 0 0 calc(100% + 32px);
    width: calc(100% + 32px);
    margin: 0 -16px;
    height: 3px;
    border: 0;
    border-radius: 0;
    background: var(--hairline);
    overflow: hidden;
  }
  .topbar .stats {
    display: none;
  }
  #endSession {
    display: none;
  }

  /* -- Session strip: bare row of 8px pips -------------------------------- */
  .session-sheet.session-sheet--top {
    padding: 0;
    margin: 10px 0 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .session-sheet.session-sheet--top .ss-head,
  .session-sheet.session-sheet--top .ss-note {
    display: none;
  }
  .session-sheet.session-sheet--top .ss-pips {
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 0;
    padding: 8px 0;
    min-height: 24px;
  }
  .ss-pip {
    position: relative;
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--hairline);
  }
  /* 24px tap target without widening the visible dot. */
  .ss-pip::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
  }
  .ss-pip.unanswered {
    background: var(--hairline);
  }
  .ss-pip.correct {
    background: var(--success);
  }
  .ss-pip.wrong {
    background: #b4392b;
  }
  .ss-pip.current {
    outline: 1.5px solid var(--ink);
    outline-offset: 1px;
  }

  /* -- Problem card ------------------------------------------------------- */
  .problem-card {
    padding: 18px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(20, 22, 26, 0.05);
  }
  .problem-card .eyebrow .section-title,
  .problem-card .chip {
    font-size: 10px;
  }
  .problem-card .prompt,
  .problem-card .prompt .mono {
    font-size: clamp(13.2px, 4.08vw, 15.6px);
    margin: 12px 0 16px;
  }
  .problem-card .prompt .mono {
    margin: 0;
  }
  .problem-card .prompt .frac,
  .problem-card .prompt .rad {
    font-size: clamp(12px, 3.6vw, 14.4px);
  }
  .problem-card .book-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  /* -- Composer ----------------------------------------------------------- */
  #answerInput,
  textarea.answer-input {
    min-height: 88px;
    padding: 12px 14px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    font-size: 16px;
    background: var(--paper);
  }
  #checkBtn {
    width: 100%;
    height: 48px;
    min-height: 48px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
  }
  .quiet-row {
    display: flex;
    gap: 0;
    align-items: stretch;
    margin-top: 6px;
    padding-top: 0;
    border-top: 1px solid var(--hairline);
    margin-bottom: 0;
  }
  #pasteQuestion,
  .quiet-row > .paste-question {
    display: none !important;
  }
  .quiet-row > .text-btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 0 2px;
    font-size: 13px;
    white-space: nowrap;
    text-decoration: none;
    border-right: 1px solid var(--hairline);
  }
  .quiet-row > :last-child {
    border-right: 0;
  }
  .quiet-row > .text-btn.muted {
    color: var(--muted);
  }

  /* -- Feedback ----------------------------------------------------------- */
  #feedback:not([hidden]) {
    margin-top: 12px;
    padding: 14px 16px;
    border: 1px solid var(--hairline);
    border-left-width: 4px;
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
  }
  #feedback.correct {
    border-left-color: var(--success);
    background: var(--paper);
    color: var(--ink);
  }
  #feedback:not(.correct) {
    border-left-color: var(--vermilion);
    background: var(--paper);
    color: var(--ink);
  }
  #feedback .fb-head {
    font-weight: 600;
  }
  #feedback .fb-answer {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
  }
  #feedback .fb-actions {
    flex-wrap: wrap;
    gap: 10px;
  }
  #feedback .next-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    border-radius: 6px;
    margin-top: 12px;
  }

  /* -- Bottom tabs -------------------------------------------------------- */
  .mobile-tabs {
    z-index: 40;
    height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: none;
  }
  .mobile-tabs .mtab {
    flex-direction: column;
    gap: 3px;
    min-height: 56px;
    height: 100%;
    font-size: 11px;
    line-height: 1.1;
  }
  .mobile-tabs .mtab svg {
    display: block !important;
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
  }
  .mobile-tabs .mtab[aria-selected="true"] {
    color: var(--vermilion);
  }
  .tutor-fab {
    display: none;
  }

  /* -- Scope sheet -------------------------------------------------------- */
  .scope-sheet {
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    padding: 18px 16px 0;
  }
  .scope-sheet .scope-eyebrow {
    font-size: 10px;
  }
  .scope-sheet .scope-title {
    font-size: 24px;
    margin: 2px 0 2px;
  }
  .scope-subline {
    margin-bottom: 14px;
  }
  .pretest-block {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 14px;
  }
  .pretest-block .pretest-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
  }
  .pretest-block .pretest-main {
    grid-column: 1 / -1;
  }
  .pretest-block .pretest-title {
    font-size: 15px;
    line-height: 1.25;
  }
  .pretest-block .pretest-sub {
    font-size: 10.5px;
  }
  .pretest-block #startPretestBtn {
    min-height: 44px;
    padding: 0 14px;
    font-size: 14px;
  }
  .pretest-block .pretest-chip {
    justify-self: start;
    align-self: center;
  }
  .scope-suggested {
    margin: 10px 0 6px;
  }
  .scope-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 0;
  }
  .scope-row {
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
  }
  .scope-row input[type="checkbox"] {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    border-radius: 3px;
  }
  .scope-row input[type="checkbox"]:checked::after {
    left: 4px;
    top: 2px;
    width: 5px;
    height: 9px;
  }
  .scope-row .scope-row-line1 {
    align-items: center;
    gap: 8px;
  }
  .scope-row .scope-row-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    font-size: 13.5px;
    line-height: 1.25;
  }
  .scope-row .scope-row-meta {
    font-size: 10px;
  }
  .section-row {
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--hairline);
    border-left: 1px solid var(--hairline);
    border-radius: 12px;
    margin-bottom: 0;
  }
  .section-row.current {
    border-left-color: var(--vermilion);
  }
  .section-row .sr-check {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin-top: 0;
    border-radius: 3px;
  }
  .section-row[aria-pressed="true"] .sr-check::after {
    left: 4px;
    top: 2px;
    width: 5px;
    height: 9px;
  }
  .section-row .sr-top {
    align-items: center;
  }
  .section-row .sr-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    font-size: 13.5px;
    line-height: 1.25;
  }
  .section-row .sr-count {
    margin-left: 8px;
    font-size: 10px;
  }
  .section-row .sr-bar {
    width: 100%;
    height: 3px;
  }
  .scope-row:hover {
    background: transparent;
  }
  .scope-master {
    min-height: 48px;
  }
  .scope-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  .scope-quick-btn {
    min-height: 44px;
  }
  .scope-length {
    margin-bottom: 12px;
  }
  .scope-live {
    margin-bottom: 0;
  }
  .scope-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 12px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--hairline);
  }
  .scope-footer .btn-primary {
    width: 100%;
    height: 48px;
  }
  .scope-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    text-align: center;
    text-decoration: none;
    color: var(--muted);
  }

  /* -- Tutor -------------------------------------------------------------- */
  .tutor-sheet {
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(20, 22, 26, 0.05);
    overflow: hidden;
  }
  .tutor-thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
  .tutor-context {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--hairline);
  }
  .tutor-context .tc-top {
    flex: 0 0 auto;
    font-size: 10px;
    letter-spacing: 0.12em;
    margin: 0;
  }
  .tutor-context .tc-prompt,
  .tutor-context .tc-prompt.prose {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: hidden;
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.35;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .tutor-context .tc-prompt .mono,
  .tutor-context .tc-prompt.prose .mono {
    margin: 0;
    font-size: 13px;
    white-space: nowrap;
  }
  .tutor-context .tc-meta,
  .tutor-context .tc-book {
    display: none;
  }
  .tutor-composer {
    flex: 0 0 auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .tutor-input {
    border-radius: 8px;
    min-height: 44px;
    font-size: 16px;
  }
  .tutor-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--vermilion);
    color: var(--paper);
  }

  /* -- Progress ----------------------------------------------------------- */
  .skills-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 16px;
    row-gap: 6px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
  }
  .skills-table td {
    display: inline-flex;
    align-items: center;
    column-gap: 5px;
    margin: 0;
    padding: 0;
    border: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink);
  }
  .skills-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .skills-table td.skill-name {
    display: block;
    flex: 0 0 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
  }
  .progress-tab {
    height: 44px;
    min-height: 44px;
    padding-bottom: 0;
  }
  .progress-tab[aria-selected="true"] {
    border-bottom-color: var(--vermilion);
  }

  /* -- Summary ------------------------------------------------------------ */
  .summary-wrap {
    padding: 0;
  }
  .summary-sheet {
    padding: 20px 16px;
    border-radius: 12px;
  }
  .summary-sheet .pretest-verdict {
    font-size: 36px;
  }
  .pretest-retake .seg {
    display: flex;
    width: 100%;
    margin-bottom: 10px;
  }
  .pretest-retake .seg .seg-btn {
    flex: 1 1 0;
  }
  .pretest-retake #retakePretest {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 10px 0 0;
    border-top: 1px solid var(--hairline);
    text-decoration: none;
  }
}

/* ===== MOBILE DESIGN ALIGNMENT (≤600px) =================================
   Matches design/pages-mobile.html at 412×915. Every rule here is inside the
   phone breakpoint, so the desktop layout above is untouched. */
@media (max-width: 600px) {
  :root {
    --tabbar-h: calc(72px + env(safe-area-inset-bottom));
  }

  body {
    background-image: none;
  }

  /* -- One-row app bar + full-width session line ------------------------- */
  .topbar {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    height: calc(56px + env(safe-area-inset-top));
    min-height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    border-bottom: 1px solid var(--hairline);
  }
  .topbar .wordmark {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar .wordmark .wm-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1;
    text-transform: none;
  }
  .topbar .wm-sub,
  .topbar .tabs {
    display: none;
  }
  .topbar .mobile-scope-chip {
    position: relative;
    order: 2;
    flex: 0 0 auto;
    height: 27px;
    min-height: 27px;
    padding: 0 8px;
    border: 1px solid #c9c0ad;
    border-radius: 999px;
    background: var(--paper);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
  }
  .topbar .mobile-scope-chip::before {
    content: "";
    position: absolute;
    inset: -9px -6px;
  }
  .topbar .mobile-scope-chip .msc-title {
    font-size: 10px;
    letter-spacing: 0.09em;
  }
  .topbar .progress {
    order: 3;
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin-left: 0;
    padding: 0;
    min-height: 44px;
  }
  .topbar .progress .progress-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.01em;
    color: var(--muted);
    white-space: nowrap;
  }
  .topbar .track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    width: 100%;
    height: 3px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--hairline);
    z-index: 2;
  }
  .topbar .track .fill {
    background: var(--vermilion);
  }
  .topbar .track.is-empty {
    display: none;
  }
  .topbar .app-meta {
    display: none;
    order: 3;
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.01em;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  body:not([data-view="practice"]) .topbar .progress,
  body:not([data-view="practice"]) .topbar .mobile-scope-chip,
  body:not([data-view="practice"]) .topbar .track {
    display: none;
  }
  body:not([data-view="practice"]) .topbar .app-meta {
    display: inline-block;
  }
  .topbar .stats,
  #endSession {
    display: none;
  }

  /* -- Practice: pips row ------------------------------------------------ */
  .session-sheet[hidden],
  .practice-note[hidden] {
    display: none;
  }
  .session-sheet.session-sheet--top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 11px 0 10px;
    border: 0;
    border-bottom: 1px solid var(--hairline);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .session-sheet.session-sheet--top .ss-head,
  .session-sheet.session-sheet--top .ss-note {
    display: none;
  }
  .session-sheet.session-sheet--top .ss-pips {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    min-height: 0;
    overflow: hidden;
  }
  .ss-pip {
    position: relative;
    width: 8px;
    height: 8px;
    flex: none;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--hairline);
  }
  .ss-pip::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
  }
  .ss-pip.unanswered {
    background: var(--hairline);
  }
  .ss-pip.correct {
    background: var(--success);
  }
  .ss-pip.wrong {
    background: var(--vermilion);
  }
  .ss-pip.current {
    background: transparent;
    border: 2px solid var(--vermilion);
    outline: 0;
  }
  .ss-count {
    display: block;
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.05em;
    color: var(--muted);
    white-space: nowrap;
  }

  /* -- Practice: card ---------------------------------------------------- */
  body[data-view="practice"] .center {
    padding: 0 16px calc(88px + env(safe-area-inset-bottom));
  }
  .problem-card {
    padding: 14px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--paper-2);
    box-shadow: none;
  }
  .problem-card .eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  .problem-card .eyebrow .section-title {
    order: 2;
    flex: 1 1 100%;
    margin: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.3;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .problem-card .eyebrow .chip[hidden] {
    display: none;
  }
  .problem-card .eyebrow .chip {
    order: 3;
    display: inline-flex;
    align-items: center;
    height: 21px;
    padding: 0 6px;
    border: 1px solid var(--hairline);
    border-radius: 3px;
    background: transparent;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .problem-card .chip.skill {
    max-width: calc(100% - 70px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--blue);
    border-color: rgba(30, 58, 95, 0.34);
    background: rgba(30, 58, 95, 0.04);
  }
  .problem-card .chip.difficulty.medium {
    color: var(--amber);
    border-color: rgba(176, 122, 30, 0.45);
    background: rgba(176, 122, 30, 0.07);
  }
  .problem-card .chip.difficulty.easy {
    color: var(--success);
    border-color: rgba(47, 107, 79, 0.4);
    background: rgba(47, 107, 79, 0.07);
  }
  .problem-card .chip.difficulty.hard,
  .problem-card .chip.pretest {
    color: var(--vermilion);
    border-color: rgba(192, 71, 42, 0.45);
    background: rgba(192, 71, 42, 0.06);
  }
  body.pretest-mode .problem-card .chip.pretest {
    order: 0;
    border-color: var(--vermilion);
  }
  body.pretest-mode .problem-card .eyebrow .section-title {
    order: 1;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: 2px;
  }
  body.pretest-mode .problem-card .chip.skill,
  body.pretest-mode .problem-card .chip.difficulty {
    display: none;
  }
  .exercise-num {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-top: 9px;
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 11px;
    letter-spacing: 0.03em;
    color: var(--muted);
  }
  .problem-card .book-link {
    display: inline-flex;
    align-items: center;
    min-height: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    font-style: normal;
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .problem-card .instruction {
    display: none;
  }
  .problem-card .prompt,
  .problem-card .prompt.prose {
    margin: 10px 0 12px;
    padding-top: 0;
    border-top: 0;
    font-family: var(--font-display);
    font-size: clamp(13.2px, 4.08vw, 15.6px);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.005em;
    max-height: none;
    overflow: visible;
  }
  .problem-card .prompt .mono {
    margin: 0;
    font-family: var(--font-mono);
    font-size: clamp(13.2px, 4.08vw, 15.6px);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .problem-card .prompt sup {
    font-size: 0.68em;
    line-height: 0;
  }
  .problem-card .prompt .frac,
  .problem-card .prompt .rad {
    font-size: clamp(12px, 3.6vw, 14.4px);
  }

  /* -- Practice: answer, actions, note ---------------------------------- */
  .answer-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    margin-top: 10px;
  }
  .answer-row .eq {
    display: block;
    font-family: var(--font-mono);
    font-size: 17px;
    color: var(--muted);
    padding-top: 12px;
  }
  #answerInput,
  textarea.answer-input {
    flex: 1 1 auto;
    width: auto;
    min-height: 48px;
    height: 48px;
    padding: 8px 12px;
    border: 1px solid #cdc4b0;
    border-radius: 6px;
    background: var(--paper);
    font-size: 15px;
    line-height: 1.3;
  }
  #checkBtn {
    flex: 0 0 104px;
    width: 104px;
    height: 48px;
    min-height: 48px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 700;
  }
  body.pretest-mode .answer-row {
    flex-wrap: wrap;
  }
  body.pretest-mode .answer-row .eq {
    display: none;
  }
  body.pretest-mode #answerInput,
  body.pretest-mode textarea.answer-input {
    flex: 1 1 100%;
    width: 100%;
    height: auto;
    min-height: 56px;
    padding: 12px;
    font-size: 16px;
  }
  body.pretest-mode #checkBtn {
    flex: 1 1 100%;
    width: 100%;
    margin-top: 2px;
    font-size: 15px;
  }
  .quiet-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin: 8px 0 0;
    padding-top: 0;
    border-top: 1px solid var(--hairline);
  }
  .quiet-row > .text-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 2px;
    border-right: 1px solid var(--hairline);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
  }
  .quiet-row > :last-child {
    border-right: 0;
  }
  .quiet-row > .text-btn.muted {
    color: var(--muted);
  }
  .pretest-progress {
    display: none;
  }
  .practice-note {
    display: block;
    margin-top: 12px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.03em;
    color: var(--muted);
  }

  /* -- Feedback ---------------------------------------------------------- */
  #feedback:not([hidden]) {
    margin-top: 12px;
    padding: 11px 12px 12px;
    border: 1px solid var(--hairline);
    border-left: 4px solid var(--vermilion);
    border-radius: 8px;
    background: var(--paper-2);
    color: var(--ink);
  }
  #feedback.correct {
    border-left-color: var(--success);
    background: var(--paper-2);
    color: var(--ink);
  }
  #feedback .fb-head {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--success);
  }
  #feedback.correct .fb-head {
    color: var(--success);
  }
  #feedback.incorrect .fb-head {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 3px;
  }
  #feedback .fb-label {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
  }
  #feedback .fb-formula {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    white-space: normal;
  }
  #feedback .fb-reason {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--muted);
  }
  #feedback .fb-actions {
    margin-top: 10px;
    display: block;
  }
  #feedback .next-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    min-height: 48px;
    margin-top: 0;
    padding: 0 16px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
  }
  #feedback .fb-quiet {
    margin-top: 6px;
    border-top: 1px solid var(--hairline);
  }
  #feedback .fb-quiet .text-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    font-size: 13px;
    color: var(--ink);
    text-decoration: none;
  }
  .streak-note {
    display: block;
    margin-top: 2px;
  }

  /* -- Empty scope ------------------------------------------------------- */
  .empty-scope:not([hidden]) {
    display: block;
    margin: clamp(48px, 26vh, 240px) 0 0;
    padding: 24px 18px 20px;
    background: var(--paper-2);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    text-align: center;
  }
  .empty-glyph {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    border: 1px dashed #b9af9a;
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--muted);
  }
  .empty-scope .es-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0;
  }
  .empty-scope .es-body {
    max-width: 30ch;
    margin: 8px auto 16px;
    font-size: 13.5px;
    color: var(--muted);
  }
  .empty-scope .btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    border-radius: 6px;
  }

  /* -- Tutor ------------------------------------------------------------- */
  body[data-view="tutor"] .center {
    display: block;
    padding: 0 0 calc(76px + env(safe-area-inset-bottom));
  }
  body[data-view="tutor"] #viewTutor.active {
    width: 100%;
    max-width: none;
  }
  body[data-view="tutor"] .tutor-sheet {
    height: calc(100dvh - 56px - 72px - env(safe-area-inset-top));
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--paper);
  }
  #viewTutor .tutor-context {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 16px;
    background: var(--paper-2);
    border-bottom: 1px solid var(--hairline);
    overflow: hidden;
  }
  #viewTutor .tc-top {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #viewTutor .tc-prompt,
  #viewTutor .tc-prompt.prose {
    margin: 0;
    padding: 0;
    max-height: none;
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.35;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #viewTutor .tc-prompt .mono,
  #viewTutor .tc-prompt.prose .mono {
    margin: 0;
    font-size: 13px;
    white-space: nowrap;
  }
  #viewTutor .tc-meta,
  #viewTutor .tc-book {
    display: none;
  }
  #viewTutor .tutor-block {
    margin: 12px 16px 0;
    padding: 9px 11px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: var(--paper-2);
  }
  #viewTutor .tutor-block-head {
    position: static;
    margin: 0 0 4px;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--muted);
  }
  #viewTutor .tutor-panel {
    padding: 0;
    border: 0;
    background: transparent;
  }
  #viewTutor .panel-lead {
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.42;
    margin: 0 0 4px;
  }
  #viewTutor .need-row {
    padding: 2px 0;
    border: 0;
  }
  #viewTutor .need-name {
    display: inline;
    margin: 0;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
  }
  #viewTutor .need-name::after {
    content: ": ";
    font-weight: 400;
  }
  #viewTutor .need-rule {
    display: inline;
    font-family: var(--font-mono);
    font-size: 12.5px;
  }
  #viewTutor .solve-step {
    padding: 2px 0;
    border: 0;
    gap: 8px;
  }
  #viewTutor .solve-num {
    flex-basis: 12px;
    font-size: 12px;
  }
  #viewTutor .solve-text {
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.42;
  }
  #viewTutor .tutor-thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
    gap: 10px;
  }
  #viewTutor .chat-msg.tutor {
    align-self: flex-start;
    max-width: 90%;
    padding: 10px 12px;
    background: var(--paper-2);
    border: 1px solid var(--hairline);
    border-radius: 4px 14px 14px 14px;
  }
  #viewTutor .chat-msg.tutor .msg-label {
    margin-bottom: 4px;
    font-size: 9px;
    letter-spacing: 0.13em;
  }
  #viewTutor .chat-msg.tutor .msg-body {
    font-family: var(--font-ui);
    font-size: 13.5px;
    line-height: 1.5;
    width: auto;
  }
  #viewTutor .chat-msg.learner {
    align-self: flex-end;
    max-width: 90%;
    padding: 10px 12px;
    background: #f0dfd6;
    border: 1px solid rgba(192, 71, 42, 0.26);
    border-radius: 14px 4px 14px 14px;
    font-family: var(--font-ui);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink);
    word-break: break-word;
  }
  #viewTutor .tutor-composer {
    padding: 9px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--hairline);
  }
  #viewTutor .tutor-input {
    min-height: 44px;
    height: 44px;
    padding: 10px 12px;
    border: 1px solid #cdc4b0;
    border-radius: 8px;
    background: var(--paper-2);
    font-size: 13.5px;
  }
  #viewTutor .tutor-send {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    background: var(--vermilion);
    color: #fbf6ea;
  }
  #viewTutor .tutor-foot {
    display: block;
    flex: none;
    padding: 0 16px 8px;
    border: 0;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-align: center;
    text-transform: uppercase;
  }

  /* -- Progress: segmented tabs + cards ---------------------------------- */
  body[data-view="progress"] .center {
    display: block;
    padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
  }
  .progress-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 46px;
    margin: 0 0 12px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    overflow: hidden;
    gap: 0;
  }
  .progress-tab {
    height: 46px;
    min-height: 46px;
    margin: 0;
    padding: 0;
    border: 0;
    border-bottom: 0;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
  }
  .progress-tab + .progress-tab {
    border-left: 1px solid var(--hairline);
  }
  .progress-tab[aria-selected="true"] {
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    border-bottom: 0;
  }
  #progressSkillsPanel .sheet-title {
    display: none;
  }
  .sheet {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .sheet-sub {
    margin: 0 0 12px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--muted);
  }
  .skills-table {
    display: block;
  }
  .skills-table thead {
    display: none;
  }
  .skills-table tbody {
    display: block;
  }
  .skills-table td.skill-name,
  .rules-skill-head .rule-name,
  .rule-card .rule-name {
    text-transform: capitalize;
  }
  .skills-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 0 0 10px;
    padding: 12px 13px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--paper-2);
  }
  .skills-table td {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: var(--font-ui);
    font-size: 10.5px;
    color: var(--muted);
  }
  .skills-table td::before {
    display: none;
  }
  .skills-table td.skill-name {
    display: block;
    flex: 0 0 100%;
    margin: 0 0 3px;
    padding: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--ink);
  }
  .skills-table .state-chip {
    display: inline-flex;
    align-items: center;
    height: 21px;
    margin: 0;
    padding: 0 6px;
    border: 1px solid var(--hairline);
    border-radius: 3px;
    font-size: 0;
    font-weight: 600;
    letter-spacing: 0.03em;
  }
  .skills-table .state-chip::after {
    content: "needs work";
    font-size: 10.5px;
  }
  .skills-table .state-chip.fluent::after {
    content: "fluent";
  }
  .skills-table .state-chip.mastered::after {
    content: "solid";
  }
  .skills-table .state-chip.learning {
    color: var(--amber);
    border-color: rgba(176, 122, 30, 0.45);
    background: rgba(176, 122, 30, 0.07);
  }
  .skills-table .state-chip.fluent {
    color: var(--blue);
    border-color: rgba(30, 58, 95, 0.34);
    background: rgba(30, 58, 95, 0.04);
  }
  .skills-table .state-chip.mastered {
    color: var(--success);
    border-color: rgba(47, 107, 79, 0.4);
    background: rgba(47, 107, 79, 0.07);
  }
  .skills-table td[data-label="Streak"],
  .skills-table td[data-label="Accuracy"] {
    height: 21px;
    padding: 0 6px;
    border: 1px solid var(--hairline);
    border-radius: 3px;
    font-size: 10.5px;
    color: var(--muted);
  }
  .skills-table td[data-label="Streak"]::before {
    display: inline;
    content: "streak ";
    font-family: var(--font-ui);
    font-size: 10.5px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
  }
  .skills-table td[data-label="Accuracy"]::before {
    display: inline;
    content: "accuracy ";
    font-family: var(--font-ui);
    font-size: 10.5px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
  }
  .skills-table td[data-label="Accuracy"] .acc-bar {
    display: none;
  }
  .skills-table .acc-pct {
    font-family: var(--font-ui);
    font-size: 10.5px;
    color: var(--muted);
  }
  .skills-table td[data-label="Distinct"] {
    display: none;
  }
  .skills-table td[data-label="Next review"] {
    display: block;
    flex: 0 0 100%;
    margin-top: 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
  }
  .skills-table td[data-label="Next review"]::before {
    display: inline;
    content: "next review ";
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
  }

  /* -- Progress: rules --------------------------------------------------- */
  #progressRulesPanel .rules-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 10px;
  }
  .rules-select {
    width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #cdc4b0;
    border-radius: 6px;
    background: var(--paper);
    font-size: 13px;
    font-weight: 600;
  }
  .rules-summary {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--muted);
    text-align: left;
    white-space: normal;
  }
  .rules-chips {
    display: none;
  }
  .rules-section-head {
    margin: 0;
    padding: 12px 0 0;
    border: 0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .rules-skill-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 10px 0;
    border-top: 1px solid var(--hairline);
  }
  .rules-skill-head .rule-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
  }
  .rules-skill-head .rule-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
  }
  .rule-card {
    margin: 0;
    padding: 9px 0 10px;
    border: 0;
    border-top: 1px solid var(--hairline);
    border-radius: 0;
    background: transparent;
  }
  .rule-card .rule-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: 14.5px;
    font-weight: 600;
  }
  .rule-card .rule-html {
    display: none;
  }

  /* -- Summary ----------------------------------------------------------- */
  body[data-view="summary"] .center {
    display: block;
    padding: 0 16px calc(88px + env(safe-area-inset-bottom));
  }
  .summary-wrap {
    padding: 0;
  }
  .summary-sheet {
    width: 100%;
    max-width: none;
    padding: 18px 0 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    text-align: left;
  }
  .summary-sheet .sum-eyebrow {
    margin: 0;
  }
  .summary-sheet .sum-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
  }
  .summary-sheet .pretest-verdict {
    margin: 2px 0 0;
    font-family: var(--font-display);
    font-size: 46px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.015em;
  }
  .summary-sheet .pretest-verdict.passed {
    color: var(--success);
  }
  .summary-sheet .pretest-verdict.failed {
    color: var(--vermilion);
  }
  .summary-sheet .score-line {
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    color: var(--ink);
  }
  .summary-sheet .sum-hairline {
    margin: 16px 0;
  }
  .summary-sheet .sum-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .summary-sheet .sum-stack .btn-outline,
  .summary-sheet .sum-stack .btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    min-height: 48px;
    margin: 0;
    border-radius: 6px;
    font-size: 14.5px;
    font-weight: 600;
  }
  .summary-sheet .sum-stack .btn-primary,
  .summary-sheet #startAnother {
    background: var(--vermilion);
    border-color: var(--vermilion);
    color: #fbf6ea;
  }
  .summary-sheet .btn-primary {
    width: 100%;
    height: 48px;
    margin-top: 16px;
    font-size: 14.5px;
  }
  .summary-sheet .wrong-head {
    margin-top: 16px;
    padding-bottom: 3px;
  }
  .summary-sheet .wrong-head .sum-eyebrow {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .summary-sheet .wrong-count {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--muted);
  }
  .summary-sheet .wrong-row {
    padding: 9px 0 10px;
    border-top: 1px solid var(--hairline);
  }
  .summary-sheet .wrong-section {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .summary-sheet .wrong-prompt {
    margin-top: 2px;
    font-family: var(--font-display);
    font-size: 14px;
    line-height: 1.35;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .summary-sheet .sum-section {
    text-align: left;
    margin-top: 16px;
  }
  .summary-sheet .sum-section .sum-h {
    font-size: 9.5px;
    letter-spacing: 0.12em;
    color: var(--muted);
  }
  .summary-sheet .sum-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
  }
  .summary-sheet .sum-row .bar {
    flex: 0 0 120px;
  }
  .summary-sheet .pretest-note {
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
  }
  .summary-sheet .pretest-retake {
    display: none;
  }

  /* -- Scope sheet ------------------------------------------------------- */
  .scope-backdrop {
    padding: 0;
    align-items: flex-end;
    background: rgba(20, 22, 26, 0.42);
  }
  body:has(#scopeBackdrop:not([hidden])) .topbar {
    visibility: hidden;
  }
  .scope-sheet {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: calc(100dvh - 28px);
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(20, 22, 26, 0.24);
    overflow: hidden;
  }
  .scope-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--hairline);
    border-radius: 50%;
    background: var(--paper-2);
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
  }
  .scope-eyebrow {
    padding: 16px 62px 0 16px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--vermilion);
  }
  .scope-sheet .scope-title {
    margin: 3px 0;
    padding: 0 62px 0 16px;
    font-size: 26px;
    line-height: 1.15;
  }
  .scope-subline {
    margin: 0;
    padding: 0 16px 10px;
    border-bottom: 1px solid var(--hairline);
    font-size: 12.5px;
    color: var(--muted);
  }
  .scope-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 9px;
    padding: 10px 16px 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .pretest-block {
    order: 1;
    margin: 0;
    padding: 10px 11px;
    border-radius: 10px;
    background: var(--paper-2);
  }
  .pretest-step {
    display: none;
  }
  .pretest-block .pretest-row {
    display: block;
  }
  .pretest-block .pretest-main {
    display: block;
  }
  .pretest-block .pretest-title {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
  }
  .pretest-block .pretest-sub {
    margin-top: 1px;
    font-family: var(--font-mono);
    font-size: 11px;
  }
  .pretest-block .pretest-chip {
    display: none;
  }
  .pretest-block.is-passed .pretest-chip {
    display: inline-flex;
    align-items: center;
    height: 18px;
    margin-top: 6px;
    padding: 0 5px;
    border: 1px solid rgba(47, 107, 79, 0.45);
    border-radius: 3px;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .pretest-block .seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 40px;
    margin-top: 8px;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    overflow: hidden;
  }
  .pretest-block .seg-btn {
    height: 40px;
    padding: 0;
    border: 0;
    border-right: 1px solid var(--hairline);
    background: transparent;
    font-family: var(--font-ui);
    font-size: 12.5px;
    color: var(--muted);
  }
  .pretest-block .seg-btn:last-child {
    border-right: 0;
  }
  .pretest-block .seg-btn.active {
    background: var(--ink);
    color: var(--paper);
    font-weight: 700;
  }
  .pretest-block:not(.is-passed) #startPretestBtn {
    display: none;
  }
  .pretest-block.is-passed #startPretestBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    margin-top: 8px;
    padding: 0 12px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
  }
  .scope-suggested,
  .scope-master {
    display: none;
  }
  .scope-quick {
    order: 2;
    display: flex;
    gap: 6px;
    margin: 0;
  }
  .scope-quick-btn {
    flex: 1 1 0;
    height: 36px;
    min-height: 36px;
    padding: 0 4px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .scope-quick-btn.clear-all {
    display: none;
  }
  .scope-quick-btn[data-quick="all"] {
    border-color: var(--ink);
    color: var(--ink);
  }
  .scope-head {
    order: 3;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-top: 1px;
  }
  .scope-head-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .scope-selected-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
  }
  .scope-rows {
    order: 4;
    display: block;
    border-top: 0;
  }
  .scope-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: start;
    gap: 9px;
    min-height: 54px;
    padding: 8px 0;
    border: 0;
    border-top: 1px solid var(--hairline);
    border-radius: 0;
    background: transparent;
  }
  .scope-row:first-child {
    border-top: 0;
  }
  .scope-row:hover,
  .scope-row:focus-within {
    background: transparent;
  }
  .scope-row input[type="checkbox"] {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 1px solid #b5ab96;
    border-radius: 4px;
    background: var(--paper);
  }
  .scope-row input[type="checkbox"]:checked {
    background: var(--vermilion);
    border-color: var(--vermilion);
  }
  .scope-row input[type="checkbox"]:checked::after {
    left: 6px;
    top: 3px;
    width: 5px;
    height: 10px;
    border-width: 0 2px 2px 0;
  }
  .scope-row-main {
    display: block;
    min-width: 0;
  }
  .scope-row-line1 {
    display: flex;
    align-items: baseline;
    gap: 5px;
  }
  .scope-row .scope-row-num {
    display: inline;
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
  }
  .scope-row .scope-row-title {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.28;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .scope-row .scope-row-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
  }
  .scope-row-line2 {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
  }
  .scope-row .scope-reason {
    display: none;
  }
  .scope-row .scope-reco {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 5px;
    border: 1px solid rgba(176, 122, 30, 0.45);
    border-radius: 3px;
    background: rgba(176, 122, 30, 0.07);
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--amber);
  }
  .scope-lock-label {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 5px;
    border: 1px dashed var(--hairline);
    border-radius: 3px;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .scope-row.locked {
    opacity: 0.75;
  }
  .scope-lock-note {
    order: 5;
    margin: 0;
    font-size: 11px;
    color: var(--vermilion);
  }
  .scope-length {
    order: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding-top: 6px;
    border-top: 1px solid var(--hairline);
  }
  .scope-length-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
  }
  .scope-length .seg {
    height: 36px;
  }
  .scope-length .seg-btn {
    min-height: 36px;
    padding: 0 12px;
    font-family: var(--font-ui);
    font-size: 12px;
  }
  .scope-length .seg-btn.active {
    background: var(--ink);
  }
  .scope-live {
    order: 7;
    margin: 0;
    font-size: 10px;
  }
  .scope-footer {
    position: static;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 9px 16px calc(14px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--hairline);
  }
  .scope-footer .btn-primary {
    width: 100%;
    height: 48px;
    min-height: 48px;
    border-radius: 6px;
    font-size: 14.5px;
  }
  .scope-foot-links {
    display: flex;
    margin-top: 0;
  }
  .scope-show-sections,
  .scope-cancel {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 12.5px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
  }
  .scope-show-sections {
    border-right: 1px solid var(--hairline);
  }

  /* -- Book viewer ------------------------------------------------------- */
  .book-backdrop {
    padding: 0;
    align-items: flex-end;
    background: rgba(20, 22, 26, 0.42);
  }
  .book-sheet {
    height: calc(100dvh - 28px);
    max-width: none;
    margin-top: 28px;
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(20, 22, 26, 0.24);
  }
  .book-head {
    position: relative;
    display: block;
    padding: 14px 58px 11px 16px;
    border-bottom: 1px solid var(--hairline);
  }
  .book-head .book-label {
    display: block;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.005em;
    white-space: normal;
  }
  .book-head .book-section {
    display: block;
    margin: 2px 0 0;
    font-family: var(--font-ui);
    font-style: normal;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    white-space: normal;
    overflow: visible;
  }
  .book-head .book-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--hairline);
    border-radius: 50%;
    background: var(--paper-2);
    color: var(--ink);
    font-size: 18px;
  }
  .book-body {
    padding: 14px 16px;
    display: flex;
  }
  .book-body img {
    width: 100%;
    max-width: none;
    border: 1px solid #c9c0ad;
    border-radius: 8px;
  }
  .book-foot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 9px 16px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--hairline);
  }
  .book-foot .book-open-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 46px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
  }
  .book-foot .book-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    background: transparent;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
  }

  /* -- Bottom tab bar ---------------------------------------------------- */
  .mobile-tabs {
    height: calc(72px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs .mtab {
    height: 56px;
    min-height: 56px;
    font-size: 11.5px;
  }
  .tutor-fab {
    display: none;
  }
  .session-sheet[hidden] {
    display: none !important;
  }
}

/* ===== Voice input (all widths) =========================================
   The mic is the primary input everywhere. The textarea is a quiet fallback
   that only appears after an explicit "Type instead" / "Fix" / "Type" tap. */
.voice-tray {
  margin-top: 10px;
  min-height: 136px;
  padding: 12px;
  border: 1.5px dashed #b9af9b;
  border-radius: 10px;
  background: rgba(246, 242, 231, 0.66);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.voice-tray[hidden],
.voice-tray [hidden],
.tutor-type-row[hidden],
.voice-unsupported[hidden] {
  display: none !important;
}
body.voice-typing .voice-tray {
  display: none;
}
body:not(.voice-typing) .answer-form .answer-row {
  display: none;
}
.voice-tray .vt-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.voice-tray[data-state="idle"] .vt-idle,
.voice-tray[data-state="listening"] .vt-listen,
.voice-tray[data-state="confirm"] .vt-confirm,
.voice-tray[data-state="error"] .vt-error {
  display: flex;
}
.vt-idle {
  align-items: center;
  text-align: center;
  gap: 5px;
}
.vt-mic-glyph {
  color: var(--vermilion);
  display: block;
}
.vt-hint {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}
.vt-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
.vt-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.vt-type:hover {
  color: var(--ink);
}
.vt-listen {
  align-items: center;
  text-align: center;
}
.vt-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
  color: var(--vermilion);
}
.vt-wave span {
  width: 3px;
  height: 22px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  animation: vt-wave 1s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.11s);
}
.vt-wave span:nth-child(2n) {
  height: 12px;
}
.vt-wave span:nth-child(3n) {
  height: 17px;
}
@keyframes vt-wave {
  0%,
  100% {
    transform: scaleY(0.28);
  }
  50% {
    transform: scaleY(1);
  }
}
.vt-listen-cap {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--vermilion);
}
.vt-interim {
  margin: 0;
  min-height: 20px;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.3;
  color: rgba(20, 22, 26, 0.55);
  overflow-wrap: anywhere;
}
.vt-confirm {
  gap: 6px;
}
.vt-heard {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.vt-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}
.vt-heard q {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-style: italic;
  line-height: 1.3;
  quotes: "\201C" "\201D";
  overflow-wrap: anywhere;
}
.vt-parsed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.vt-was {
  font-size: 11.5px;
  font-style: italic;
  color: var(--muted);
  white-space: nowrap;
}
.vt-parsed {
  white-space: pre-line;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.vt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}
.vt-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #b7ad99;
  border-radius: 5px;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
}
.vt-mini:hover {
  border-color: var(--ink);
}
.vt-fix {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 4px;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.vt-fix:hover {
  color: var(--ink);
}
.vt-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--vermilion);
  border-radius: 6px;
  background: var(--vermilion);
  color: #fdfbf5;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.vt-check:hover {
  background: #ad3f25;
  border-color: #ad3f25;
}
.vt-error {
  gap: 6px;
}
.vt-err-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}
.vt-err-body {
  margin: 0 0 2px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.vt-err-help {
  display: grid;
  gap: 6px;
  margin: 2px 0 4px;
  padding: 9px 11px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.03);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}
.vt-err-help p {
  margin: 0;
}
/* Mic-off error: a compact card over the practice screen, as in the design. */
body.voice-error::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(20, 22, 26, 0.2);
}
body.voice-error .voice-tray[data-state="error"] {
  position: fixed;
  z-index: 90;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 40px));
  min-height: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 18px 44px rgba(20, 22, 26, 0.2);
}
.vt-err-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 9px;
  border-radius: 50%;
  background: rgba(192, 71, 42, 0.08);
  color: var(--vermilion);
}
.vt-err-icon svg {
  width: 22px;
  height: 22px;
}
body.voice-error .vt-error {
  gap: 0;
}
body.voice-error .vt-err-title {
  margin: 0 0 4px;
}
body.voice-error .vt-err-body {
  margin: 0 0 12px;
}
body.voice-error .vt-check,
body.voice-error .vt-soft {
  min-height: 42px;
  font-size: 13.5px;
}
.vt-soft {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  padding: 0 14px;
  border: 1px solid #b7ad99;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.vt-soft:hover {
  border-color: var(--ink);
}
body.voice-error .vt-err-help {
  margin: 9px 0 0;
}
#practiceErrSettings[hidden],
#practiceErrRetry[hidden],
.vt-err-help[hidden] {
  display: none;
}
.voice-unsupported {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* Mic FAB: fixed bottom-right on every width; above the phone tab bar below. */
.practice-mic {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 45;
  display: none;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--vermilion);
  border-radius: 50%;
  background: var(--vermilion);
  color: #fdfbf5;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(192, 71, 42, 0.26);
}
body[data-view="practice"] .practice-mic {
  display: grid;
}
/* The mic owns the bottom-right corner in practice; the tutor tab is the door. */
body[data-view="practice"] .tutor-fab {
  display: none;
}
.practice-mic[hidden] {
  display: none !important;
}
.practice-mic:hover {
  background: #ad3f25;
}
.practice-mic .pm-ico {
  width: 26px;
  height: 26px;
}
.practice-mic .pm-stop {
  display: none;
}
.practice-mic.is-listening .pm-mic {
  display: none;
}
.practice-mic.is-listening .pm-stop {
  display: block;
}
.pm-pulse {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1.5px solid rgba(192, 71, 42, 0.45);
  pointer-events: none;
  animation: pm-pulse 2.6s ease-out infinite;
}
.pm-pulse::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px solid rgba(192, 71, 42, 0.22);
  animation: pm-pulse 2.6s 1.3s ease-out infinite;
}
.practice-mic.is-listening .pm-pulse {
  animation-duration: 1.5s;
  border-color: rgba(192, 71, 42, 0.6);
}
@keyframes pm-pulse {
  0% {
    transform: scale(0.94);
    opacity: 1;
  }
  100% {
    transform: scale(1.22);
    opacity: 0;
  }
}

/* Tutor voice composer. */
.tutor-composer {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.tutor-voice {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
}
.tutor-talk {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--vermilion);
  border-radius: 50%;
  background: var(--vermilion);
  color: #fdfbf5;
  cursor: pointer;
}
.tutor-talk:hover {
  background: #ad3f25;
}
.tutor-talk .tv-stop {
  display: none;
}
.tutor-talk.is-listening .tv-mic {
  display: none;
}
.tutor-talk.is-listening .tv-stop {
  display: block;
}
.tutor-talk-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.tutor-talk-label b {
  font-size: 13.5px;
  font-weight: 600;
}
.tutor-talk-label span {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.tutor-type-link {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 36px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.tutor-type-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
}

.practice-mic:focus-visible,
.vt-type:focus-visible,
.vt-mini:focus-visible,
.vt-fix:focus-visible,
.vt-check:focus-visible,
.tutor-talk:focus-visible,
.tutor-type-link:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .vt-wave span,
  .pm-pulse,
  .pm-pulse::after {
    animation: none !important;
  }
  .pm-pulse {
    opacity: 0.35;
  }
}

@media (max-width: 600px) {
  .practice-mic {
    bottom: calc(56px + env(safe-area-inset-bottom) + 16px);
  }
  body[data-view="practice"] .center {
    padding-bottom: calc(156px + env(safe-area-inset-bottom));
  }
  .vt-type,
  .vt-mini,
  .vt-fix {
    min-height: 44px;
  }
  .vt-check {
    min-height: 48px;
  }
  .vt-parsed {
    font-size: 26px;
  }
  .tutor-composer {
    padding: 0 0 env(safe-area-inset-bottom);
  }
  .tutor-voice,
  .tutor-type-row {
    padding-left: 12px;
    padding-right: 12px;
  }
  .tutor-voice {
    padding-bottom: 8px;
  }
  .tutor-type-row {
    padding-bottom: 10px;
  }
}

.build-tag {
  position: fixed;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  max-width: calc(100% - 16px);
  padding: 3px 7px;
  border: 1px solid var(--vermilion);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vermilion);
}
