:root {
  --paper: #f8f6ef;
  --surface: #ffffff;
  --ink: #1d2525;
  --muted: #64706d;
  --line: #d8ded8;
  --green: #2f7d62;
  --green-dark: #215944;
  --coral: #c65d4b;
  --gold: #c9932d;
  --teacher-pastel: #fff5cf;
  --teacher-pastel-strong: #f4df94;
  --whiteboard-pastel: #e7f4ee;
  --whiteboard-pastel-strong: #b7dccb;
  --shadow: 0 18px 50px rgba(27, 38, 33, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
select,
input {
  font: inherit;
}

/* Tablet: stop the OS "copy/share" text-selection callout and blue tap flash
   on buttons, and remove the double-tap-zoom delay so taps feel immediate.
   Text inputs are intentionally excluded so typing/selection still works. */
button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  /* dvh = the *visible* viewport: full screen when installed standalone (no
     browser chrome), and the chrome-excluded area in a normal tab. Reclaims
     the space the earlier 80vh workaround gave up. */
  height: 100vh;
  height: 100dvh;
  min-height: 480px;
}

/* First-run install offer (see pwa-install.js). */
.pwa-install-banner {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 24px));
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.pwa-install-text {
  font-size: 15px;
  font-weight: 600;
}

.pwa-install-action {
  flex: none;
  padding: 8px 16px;
  border: none;
  border-radius: 9px;
  background: var(--green);
  color: #fffdf8;
  font-weight: 700;
  cursor: pointer;
}

.pwa-install-close {
  flex: none;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}

/* Landscape-only lock. A browser tab can't truly force orientation (iOS
   ignores the lock APIs), so in portrait we cover the UI with a "rotate"
   prompt — the app is only usable in landscape. */
.rotate-prompt {
  display: none;
}

@media (orientation: portrait) and (pointer: coarse) {
  .rotate-prompt {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: var(--paper);
    color: var(--ink);
  }

  .rotate-prompt-icon {
    font-size: 56px;
    margin-bottom: 12px;
  }

  .rotate-prompt-inner p {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
  }
}

.eyebrow,
.panel-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.25;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.accent-button,
.tool-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--green);
  color: white;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: #f4f2e9;
  border-color: var(--line);
  color: var(--ink);
}

.accent-button {
  background: var(--coral);
  color: white;
}

.tool-button {
  background: #f4f2e9;
  border-color: var(--line);
  color: var(--ink);
}

.tool-button.active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(47, 125, 98, 0.18);
}

.rail-talk-button {
  width: 56px;
  min-height: 58px;
  background: var(--gold);
  color: #1f1a10;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.12;
  padding: 8px 4px;
}

.rail-lesson-controls {
  display: grid;
  gap: 10px;
  width: 56px;
  margin-top: auto;
  margin-bottom: clamp(44px, 6vh, 88px);
}

.rail-control-button {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 56px;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fffdf8;
  cursor: pointer;
  padding: 6px 4px;
  font-weight: 800;
}

.rail-control-button:hover,
.rail-control-button.active {
  background: var(--green);
  border-color: rgba(255, 255, 255, 0.32);
}

.rail-control-button.stop:hover {
  background: var(--coral);
}

.rail-control-button.step-control:hover {
  background: #3d6f86;
}

.rail-control-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.rail-control-icon {
  font-size: 16px;
  line-height: 1;
}

.rail-control-text {
  font-size: 10px;
  line-height: 1.05;
}

.rail-talk-button.listening {
  background: var(--coral);
  color: white;
}

.rail-talk-button.locked {
  background: var(--green);
  color: white;
  box-shadow: 0 0 0 3px rgba(47, 125, 98, 0.28);
}

.teacher-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.main-stage {
  display: grid;
  grid-template-columns: 74px 0px minmax(0, 1fr);
  min-height: 0;
  transition: grid-template-columns 220ms ease;
}

.main-stage.panel-open {
  grid-template-columns: 74px 360px minmax(0, 1fr);
}

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 18px 10px;
  border-right: 1px solid var(--line);
  background: #273630;
}

.rail-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fffdf8;
  cursor: pointer;
  font-weight: 800;
}

.rail-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-button:hover,
.rail-button.active {
  background: var(--green);
  border-color: rgba(255, 255, 255, 0.32);
}

.teacher-status-button {
  position: relative;
  margin-bottom: 10px;
}

.teacher-status-button::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 11px;
  height: 11px;
  border: 2px solid #273630;
  border-radius: 50%;
  background: var(--coral);
}

.teacher-status-button.connecting::after {
  background: var(--gold);
}

.teacher-status-button.online::after {
  background: #4fd18b;
}

.side-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-column: 2;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: #fbfaf5;
  box-shadow: 10px 0 32px rgba(27, 38, 33, 0.1);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-16px);
  transition:
    opacity 180ms ease,
    transform 220ms ease;
}

.side-panel[hidden] {
  display: none;
}

.side-panel-header,
.side-panel-body {
  width: 360px;
  max-width: 360px;
}

.main-stage.panel-open .side-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.main-stage.panel-closing {
  grid-template-columns: 74px 360px minmax(0, 1fr);
}

.main-stage.panel-closing .side-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-16px);
}

.workspace {
  grid-column: 3;
  transition: opacity 180ms ease;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.side-panel-header h2 {
  margin: 0;
  font-size: 22px;
}

.side-panel-body {
  overflow: auto;
  padding: 16px;
}

.side-panel-body label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.side-panel-body input,
.side-panel-body select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 400;
  text-transform: none;
}

.panel-wide-button {
  width: 100%;
  margin: 4px 0 14px;
}

.settings-divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

.teacher-settings {
  display: grid;
  gap: 12px;
}

.language-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.language-settings.single {
  grid-template-columns: minmax(0, 1fr);
}

.language-settings label {
  margin-bottom: 0;
}

.voice-group {
  display: grid;
  gap: 8px;
}

.voice-group h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.voice-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  cursor: pointer;
}

.voice-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.voice-option.selected {
  border-color: rgba(47, 125, 98, 0.44);
  background: rgba(47, 125, 98, 0.09);
  box-shadow: inset 0 0 0 1px rgba(47, 125, 98, 0.16);
}

.speed-control {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  text-transform: none;
}

.speed-control span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.speed-control input[type="range"] {
  width: 100%;
  padding: 0;
}

.info-list {
  display: grid;
  gap: 10px;
}

.subject-choice-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.subject-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.subject-choice.selected {
  border-color: rgba(47, 125, 98, 0.38);
  background: #eef6f1;
  box-shadow: inset 0 0 0 1px rgba(47, 125, 98, 0.12);
}

.compact-info {
  gap: 6px;
  margin-bottom: 14px;
}

.info-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.info-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.recipe-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.recipe-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 4px 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.curriculum-tree {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.curriculum-strand {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.curriculum-strand > summary,
.curriculum-topic-node > summary,
.curriculum-unit-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.curriculum-strand > summary::-webkit-details-marker,
.curriculum-topic-node > summary::-webkit-details-marker,
.curriculum-unit-group > summary::-webkit-details-marker {
  display: none;
}

.curriculum-strand > summary {
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.curriculum-strand > summary::before,
.curriculum-topic-node > summary::before,
.curriculum-unit-group > summary::before {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eef3ef;
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
}

.curriculum-unit-group {
  border-top: 1px solid var(--line);
  background: #fbfaf5;
}

.curriculum-unit-group:first-child {
  border-top: 0;
}

.curriculum-unit-group > summary {
  min-height: 38px;
  padding: 9px 12px 9px 18px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.curriculum-unit-group > summary::before {
  width: 16px;
  height: 16px;
  font-size: 13px;
}

.curriculum-strand[open] > summary::before,
.curriculum-topic-node[open] > summary::before,
.curriculum-unit-group[open] > summary::before {
  content: "-";
}

.curriculum-strand > summary span,
.curriculum-topic-node > summary span {
  flex: 1 1 auto;
}

.curriculum-strand > summary small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.curriculum-topic-list {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px 28px;
}

.curriculum-topic-node {
  border-radius: 8px;
  background: #f4f2e9;
  color: var(--muted);
}

.curriculum-topic-node > summary {
  min-height: 36px;
  padding: 8px 10px;
  color: #40504b;
  font-size: 13px;
  font-weight: 700;
}

.curriculum-topic-node.selected {
  background: rgba(47, 125, 98, 0.12);
  color: var(--ink);
}

.curriculum-topic-node summary strong {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 11px;
  text-transform: uppercase;
}

.curriculum-meta {
  margin: 0;
  padding: 0 10px 8px 38px;
  color: var(--muted);
  font-size: 12px;
}

.curriculum-open-topic {
  margin: 0 10px 10px 38px;
  min-height: 30px;
  border: 1px solid rgba(47, 125, 98, 0.28);
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.curriculum-open-topic:hover {
  background: rgba(47, 125, 98, 0.08);
}

.curriculum-node-section {
  padding: 0 10px 10px 38px;
}

.curriculum-node-section h4 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
}

.curriculum-node-section ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.curriculum-node-section li {
  padding-left: 10px;
  border-left: 2px solid rgba(47, 125, 98, 0.18);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.curriculum-node-section li small {
  display: block;
  color: var(--green);
  font-size: 11px;
}

.curriculum-skill-list {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.topic-choice-list {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
}

.topic-lesson-tree {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
}

.topic-lesson-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px 28px;
}

.topic-lesson-group .curriculum-topic-choice {
  margin: 0;
}

.curriculum-topic-choice {
  position: relative;
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.curriculum-topic-choice.selected {
  border-color: rgba(47, 125, 98, 0.35);
  background: rgba(47, 125, 98, 0.08);
  padding-left: 16px;
}

.curriculum-topic-choice.selected::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 7px;
  width: 4px;
  border-radius: 999px;
  background: var(--green);
}

.curriculum-topic-choice small,
.panel-help {
  color: var(--muted);
  font-size: 12px;
}

.selection-badge {
  justify-self: start;
  border-radius: 999px;
  background: var(--green);
  padding: 3px 7px;
  color: #fff;
  font-size: 10px;
  text-transform: uppercase;
}

.panel-help {
  margin: 0 0 12px;
}

.panel-section-title {
  margin: 6px 0 10px;
  color: var(--ink);
  font-size: 15px;
}

.curriculum-skill {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.curriculum-skill.selected {
  border-color: rgba(47, 125, 98, 0.32);
  background: #f7faf6;
  box-shadow: inset 0 0 0 1px rgba(47, 125, 98, 0.12);
}

.curriculum-skill:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.curriculum-skill small {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 40%) minmax(480px, 60%);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "lesson board"
    "entry entry";
  min-height: 0;
}

.lesson-panel {
  grid-area: lesson;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--teacher-pastel);
}

.topic-card,
.teacher-card,
.transcript {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.teacher-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
}

.topic-card {
  padding: 14px;
}

.topic-card h1 {
  font-size: 25px;
}

.teacher-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.teacher-state {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 700;
}

.transcript {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.notes-section {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.notes-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.notes-section h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.notes-section p,
.notes-section li {
  color: #2d3835;
  line-height: 1.4;
}

.transcript-log {
  display: grid;
  gap: 10px;
}

.message {
  border-left: 4px solid var(--line);
  padding: 8px 10px;
  background: #fbfaf5;
}

.message.teacher {
  border-left-color: var(--green);
}

.message.student {
  border-left-color: var(--gold);
}

.message.error {
  border-left-color: var(--coral);
}

.message-role {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.35;
}

.message-text mjx-container {
  margin: 4px 0;
}

.whiteboard-panel {
  grid-area: board;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 18px;
  background: var(--whiteboard-pastel);
}

.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

#questionTitle {
  margin: 0;
  font-size: 22px;
}

.board-stack {
  position: relative;
  min-height: 0;
}

.work-surface {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  border: 1px solid #c6d1c8;
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.work-surface[hidden] {
  display: none;
}

.teacher-working {
  z-index: 4;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.whiteboard-surface {
  z-index: 2;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.whiteboard-canvas-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.whiteboard-canvas-scroll canvas {
  display: block;
  width: 100%;
  min-height: 0;
}

.math-entry-bar {
  grid-area: entry;
  display: grid;
  grid-template-columns: minmax(380px, 48%) minmax(0, 52%);
  grid-template-areas:
    "target symbols"
    "compose symbols"
    "hint symbols";
  gap: 8px;
  border-top: 2px solid var(--teacher-pastel-strong);
  background: var(--teacher-pastel);
  padding: 12px 18px;
  transition: background 160ms ease, border-color 160ms ease;
}

.workspace.input-target-whiteboard .math-entry-bar {
  border-color: var(--whiteboard-pastel-strong);
  background: var(--whiteboard-pastel);
}

.input-target-row,
.math-entry-compose-row,
.math-entry-key-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.input-target-row {
  grid-area: target;
}

.math-entry-compose-row {
  grid-area: compose;
}

.math-entry-key-hint {
  grid-area: hint;
}

.input-target-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.input-target-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

.input-target-button.active {
  border-color: var(--green);
  background: rgba(47, 125, 98, 0.11);
  box-shadow: inset 0 0 0 1px rgba(47, 125, 98, 0.2);
}

.input-target-status {
  margin-left: auto;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.math-entry-compose-row textarea {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font-size: 16px;
}

.math-entry-action {
  min-width: 84px;
}

.math-symbol-row {
  grid-area: symbols;
  display: grid;
  grid-template-columns: repeat(10, minmax(38px, 1fr));
  align-content: center;
  justify-self: end;
  gap: 6px;
  width: 80%;
}

.math-symbol-button {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.whiteboard-submit-button {
  position: absolute;
  right: 28px;
  bottom: 18px;
  z-index: 5;
  min-width: 96px;
  min-height: 44px;
  text-transform: uppercase;
}

.math-symbol-button:hover,
.math-symbol-button:focus-visible {
  border-color: var(--green);
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(47, 125, 98, 0.18);
}

.math-entry-key-hint {
  margin: 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.math-entry-key-hint span + span::before {
  content: "|";
  margin: 0 8px;
  color: var(--line);
}

.workspace.input-target-teacher .lesson-panel,
.workspace.input-target-whiteboard .whiteboard-panel {
  box-shadow: inset 0 0 0 2px rgba(47, 125, 98, 0.34);
}

.photo-work-surface {
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
}

.photo-work-placeholder {
  max-width: 360px;
  color: var(--muted);
  text-align: center;
}

.photo-work-placeholder h2 {
  color: var(--ink);
}

.teacher-working-lines {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding: 14px;
}

.working-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 7px 10px;
  border-left: 4px solid var(--green);
  background: #f8f6ef;
  line-height: 1.35;
}

.working-line-index {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.working-line-content {
  display: block;
  width: 100%;
  min-width: 0;
}

.working-line.has-asset {
  align-items: stretch;
  min-height: 132px;
}

.working-line.has-asset .working-line-index {
  align-self: center;
}

.working-line.has-asset .working-line-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: center;
  gap: 16px;
}

.working-line-text {
  min-width: 0;
}

.working-line-text p {
  margin: 0;
}

.working-asset {
  justify-self: end;
  display: grid;
  align-items: center;
  justify-items: end;
  width: 340px;
  margin: 0;
}

.working-asset img {
  display: block;
  width: 100%;
  height: 128px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.working-asset-img {
  cursor: zoom-in;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.working-asset-img:hover,
.working-asset-img:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(47, 125, 98, 0.25);
  outline: none;
}

/* ---- Full-screen image viewer (see ui/lightbox.js) ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(20, 28, 25, 0.78);
  backdrop-filter: blur(2px);
}

.lightbox-overlay[hidden] {
  display: none;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.lightbox-button {
  min-width: 44px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.lightbox-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.lightbox-zoom-label {
  min-width: 56px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lightbox-stage {
  width: 75vw;
  height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  touch-action: none;
}

.lightbox-stage.zoomed {
  cursor: grab;
}

.lightbox-stage.panning {
  cursor: grabbing;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

body.lightbox-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .working-asset-img {
    transition: none;
  }
}

.working-asset-caption {
  width: 100%;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.teacher-working.empty .teacher-working-lines {
  color: var(--muted);
}

#whiteboard {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: #fffdf8;
  touch-action: none;
}

@media (prefers-reduced-motion: reduce) {
  .main-stage,
  .side-panel,
  .workspace {
    transition: none;
  }
}

@media (max-width: 1180px) {
  .math-symbol-row {
    width: 100%;
  }

  .working-line.has-asset .working-line-content {
    grid-template-columns: minmax(0, 1fr);
  }

  .working-asset {
    width: min(100%, 340px);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .main-stage {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .main-stage.panel-open {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .side-panel {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    max-height: 42vh;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    grid-column: 2;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38%) minmax(0, 1fr) auto;
    grid-template-areas:
      "lesson"
      "board"
      "entry";
  }

  .lesson-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .math-entry-bar {
    padding: 10px;
  }

  .input-target-status {
    display: none;
  }

}

/* Account section in the User panel */
.account-section {
  margin-bottom: 1rem;
}
.account-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.account-actions .tool-button {
  text-decoration: none;
  text-align: center;
}
.account-error {
  color: #c0392b;
  font-size: 0.85rem;
  min-height: 1em;
  margin-top: 0.5rem;
}

.rail-help-button {
  font-size: 24px;
  font-weight: 800;
}

.onboarding-tour {
  position: fixed;
  inset: 0;
  z-index: 12000;
  pointer-events: none;
}

.tour-highlight {
  position: fixed;
  z-index: 12001;
  border: 3px solid #56c596;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(21, 35, 31, 0.68), 0 0 0 7px rgba(86, 197, 150, 0.24);
  transition: left 180ms ease, top 180ms ease, width 180ms ease, height 180ms ease;
}

.tour-card {
  position: fixed;
  z-index: 12002;
  width: min(340px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid #cbd8d2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 16px 44px rgba(15, 35, 29, 0.28);
  pointer-events: auto;
}

.tour-progress {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.tour-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.tour-text {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.tour-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 650;
}

.tour-remember input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.tour-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.tour-button,
.tour-skip {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.tour-skip {
  justify-self: start;
  border-color: transparent;
  color: var(--muted);
}

.tour-button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.tour-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.tour-button:focus-visible,
.tour-skip:focus-visible {
  outline: 3px solid rgba(47, 125, 98, 0.3);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tour-highlight {
    transition: none;
  }
}
