:root {
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #edf3f8;
  --ink: #17324d;
  --ink-soft: #5f7185;
  --line: #dce5ed;
  --line-strong: #c7d4df;
  --navy: #17324d;
  --blue: #3f6fd9;
  --blue-soft: #e9efff;
  --coral: #f45d48;
  --coral-soft: #fff0ed;
  --mint: #1cae9b;
  --mint-soft: #e7f8f4;
  --yellow: #f2b544;
  --yellow-soft: #fff6df;
  --shadow: 0 12px 35px rgba(25, 51, 78, 0.09);
  --sidebar-width: 210px;
  --topbar-height: 76px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 50, 77, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 50, 77, 0.035) 1px, transparent 1px),
    var(--page);
  background-size: 28px 28px;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
.file-button:focus-within {
  outline: 3px solid rgba(63, 111, 217, 0.28);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template:
    "topbar topbar" var(--topbar-height)
    "sidebar main" calc(100vh - var(--topbar-height)) /
    var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  grid-area: topbar;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 20px;
  min-width: 0;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--navy);
  transform: rotate(-3deg);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 11px;
}

.topbar-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
  white-space: nowrap;
}

.context-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px var(--mint-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 14px;
}

.top-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 12px;
}

.top-stat-value {
  color: var(--coral);
  font-size: 20px;
  font-weight: 800;
}

.install-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.install-button:hover {
  border-color: #305dc4;
  background: #305dc4;
  transform: translateY(-1px);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  transform: translateY(-1px);
}

.sidebar {
  position: sticky;
  top: var(--topbar-height);
  grid-area: sidebar;
  display: flex;
  height: calc(100vh - var(--topbar-height));
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 24px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(14px);
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.nav-item.is-active {
  color: var(--blue);
  border-color: #cfdcf8;
  background: var(--blue-soft);
}

.nav-item svg {
  width: 21px;
  height: 21px;
}

.sidebar-note {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.sidebar-note-label {
  color: var(--mint);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-note p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.main-content {
  grid-area: main;
  min-width: 0;
  padding: 30px clamp(20px, 3vw, 44px) 48px;
}

.view {
  display: none;
  max-width: 1540px;
  margin: 0 auto;
  animation: view-in 220ms ease both;
}

.view.is-active {
  display: block;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 22px;
}

.view-heading h1 {
  margin: 2px 0 0;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.14;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-intro {
  max-width: 480px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
  text-align: right;
}

.daily-goal {
  width: min(340px, 36vw);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(25, 51, 78, 0.05);
}

.daily-goal-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 12px;
}

.daily-goal-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.goal-track,
.mastery-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ecf2;
}

.goal-track span,
.mastery-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--mint);
  transition: width 300ms ease;
}

.learn-layout {
  display: grid;
  grid-template-columns: minmax(400px, 1.28fr) minmax(360px, 0.92fr);
  align-items: start;
  gap: 18px;
}

.tutor-section,
.mission-section,
.drawing-section,
.insight-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tutor-section {
  padding: 20px;
}

.mission-section {
  padding: 20px;
}

.drawing-section {
  grid-column: 1 / -1;
  padding: 20px;
}

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

.section-heading.compact {
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.status-pill,
.version-pill {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.status-pill.is-ready {
  color: #0f7d70;
  border-color: #bce7df;
  background: var(--mint-soft);
}

.status-pill.is-recording {
  color: #bb3526;
  border-color: #f6c7c0;
  background: var(--coral-soft);
}

.tutor-frame {
  position: relative;
  width: 100%;
  min-height: 370px;
  overflow: hidden;
  border: 1px solid #cbd6e1;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(28, 174, 155, 0.1), rgba(63, 111, 217, 0.08)),
    #eaf0f5;
}

.tutor-frame::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 32px 32px;
  mix-blend-mode: overlay;
}

#tutorVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #cfdae5;
}

#tutorVideo:not([src]) {
  display: none;
}

.tutor-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
}

.portrait {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  margin-bottom: 18px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  color: var(--surface);
  background: var(--navy);
  box-shadow: 0 10px 24px rgba(23, 50, 77, 0.18);
  font-size: 40px;
  font-weight: 900;
}

.portrait::before,
.portrait::after {
  position: absolute;
  content: "";
  background: var(--surface);
  opacity: 0.9;
}

.portrait::before {
  top: 48px;
  left: 31px;
  width: 13px;
  height: 4px;
  border-radius: 999px;
  box-shadow: 37px 0 0 var(--surface);
}

.portrait::after {
  top: 70px;
  left: 43px;
  width: 26px;
  height: 11px;
  border: 3px solid var(--surface);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: transparent;
}

.portrait i {
  position: absolute;
  right: 6px;
  bottom: 2px;
  width: 27px;
  height: 27px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--yellow);
}

.portrait span {
  transform: translateY(22px);
  opacity: 0.28;
  font-size: 18px;
}

.tutor-fallback h3 {
  margin: 0;
  font-size: 21px;
}

.tutor-fallback p {
  max-width: 400px;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.subtitle-bubble {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 3;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  color: var(--surface);
  background: rgba(23, 50, 77, 0.86);
  font-size: 14px;
  line-height: 1.6;
  backdrop-filter: blur(10px);
}

.speaking-wave {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: flex;
  height: 34px;
  align-items: center;
  gap: 4px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 7px 18px rgba(25, 51, 78, 0.12);
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 180ms ease, transform 180ms ease;
}

.speaking-wave.is-visible {
  opacity: 1;
  transform: scale(1);
}

.speaking-wave span {
  width: 4px;
  height: 8px;
  border-radius: 999px;
  background: var(--coral);
  animation: sound-wave 700ms ease-in-out infinite alternate;
}

.speaking-wave span:nth-child(2) {
  animation-delay: 100ms;
}

.speaking-wave span:nth-child(3) {
  animation-delay: 180ms;
}

.speaking-wave span:nth-child(4) {
  animation-delay: 260ms;
}

.speaking-wave span:nth-child(5) {
  animation-delay: 340ms;
}

@keyframes sound-wave {
  from {
    height: 7px;
  }
  to {
    height: 22px;
  }
}

.recording-indicator {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 4;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--coral);
  font-size: 12px;
  font-weight: 800;
}

.recording-indicator:not([hidden]) {
  display: inline-flex;
}

.recording-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: blink 850ms steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

.media-workbench {
  margin-top: 14px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: #fbfcfe;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.6;
}

.consent-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--mint);
}

.media-actions {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  opacity: 0.55;
  pointer-events: none;
}

.media-actions.is-enabled {
  opacity: 1;
  pointer-events: auto;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.action-label {
  width: 36px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.tool-button,
.secondary-button,
.primary-button,
.save-button,
.text-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.tool-button:hover,
.secondary-button:hover,
.save-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  transform: translateY(-1px);
}

.tool-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.tool-button.is-record {
  color: #b83b2d;
  border-color: #f2c8c2;
  background: var(--coral-soft);
}

.record-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.voice-mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.switch-control input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #b9c5d1;
  transition: background 160ms ease;
}

.switch-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 50, 77, 0.25);
  transition: transform 160ms ease;
}

.switch-control input:checked + .switch-track {
  background: var(--mint);
}

.switch-control input:checked + .switch-track i {
  transform: translateX(14px);
}

.media-hint {
  margin-left: auto;
}

.subject-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.subject-tab {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.subject-tab:hover {
  color: var(--ink);
}

.subject-tab.is-active {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(25, 51, 78, 0.08);
}

.subject-symbol {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
}

.subject-tab[data-subject="chinese"] .subject-symbol {
  background: var(--coral);
}

.subject-tab[data-subject="mathematics"] .subject-symbol,
.subject-tab[data-subject="math"] .subject-symbol {
  background: var(--mint);
}

.subject-tab[data-subject="english"] .subject-symbol {
  background: var(--blue);
}

.mission-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 17px 0 14px;
  color: var(--ink-soft);
  font-size: 12px;
}

.mission-dots {
  display: flex;
  gap: 5px;
}

.mission-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ccd6df;
}

.mission-dots span.is-done {
  background: var(--mint);
}

.mission-dots span.is-current {
  width: 19px;
  border-radius: 999px;
  background: var(--blue);
}

.knowledge-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--yellow);
  color: var(--ink-soft);
  background: var(--yellow-soft);
  font-size: 12px;
}

.knowledge-label strong {
  color: var(--ink);
  font-size: 14px;
}

.question-area {
  min-height: 300px;
  padding-top: 18px;
}

.story-line {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
}

.question-area h3 {
  margin: 10px 0 16px;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.5;
}

.answer-options {
  display: grid;
  gap: 9px;
}

.answer-option {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.answer-option:hover {
  border-color: #b8c8d7;
  background: var(--surface-muted);
  transform: translateX(2px);
}

.answer-option.is-selected {
  color: var(--blue);
  border-color: #9eb5eb;
  background: var(--blue-soft);
}

.answer-option.is-correct {
  color: #0d776b;
  border-color: #8dd6ca;
  background: var(--mint-soft);
}

.answer-option.is-wrong {
  color: #ae382a;
  border-color: #efb8b0;
  background: var(--coral-soft);
}

.option-key {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.answer-feedback {
  margin-top: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.7;
}

.answer-feedback.is-correct {
  color: #0b6c62;
  border-left-color: var(--mint);
  background: var(--mint-soft);
}

.answer-feedback.is-wrong {
  color: #9d3327;
  border-left-color: var(--coral);
  background: var(--coral-soft);
}

.reasoning-block {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid #c9dcf8;
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.reasoning-block label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.reasoning-block textarea {
  display: block;
  width: 100%;
  min-height: 82px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid #b8c9e8;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.6;
}

.reasoning-block textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(63, 111, 217, 0.15);
}

.reasoning-block p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.mission-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

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

.primary-button:hover:not(:disabled) {
  border-color: #305dc4;
  background: #305dc4;
  transform: translateY(-1px);
}

.secondary-button {
  background: var(--surface-muted);
}

.text-button {
  min-height: 32px;
  padding: 0 10px;
  border-color: transparent;
  color: var(--blue);
  background: transparent;
}

.text-button:hover {
  background: var(--blue-soft);
}

.mastery-strip {
  margin-top: 17px;
  padding: 13px;
  border-top: 1px solid var(--line);
}

.mastery-strip > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.mastery-strip strong {
  color: var(--ink);
  font-size: 17px;
}

.mastery-strip p {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.mastery-gate {
  margin-top: 4px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.mastery-gate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mastery-gate-head > div {
  min-width: 0;
}

.mastery-gate-head span,
.mastery-gate-head strong {
  display: block;
}

.mastery-gate-head span {
  color: var(--ink-soft);
  font-size: 11px;
}

.mastery-gate-head strong {
  margin-top: 2px;
  font-size: 15px;
}

.gate-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 11px;
}

.gate-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 10px;
}

.gate-chip::before {
  display: grid;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  content: "";
  background: var(--surface-muted);
}

.gate-chip.is-passed {
  color: #0d776b;
  border-color: #bce7df;
  background: var(--mint-soft);
}

.gate-chip.is-passed::before {
  border-color: var(--mint);
  background: var(--mint);
  box-shadow: inset 0 0 0 4px var(--mint-soft);
}

.gate-note {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.6;
}

.drawing-body {
  display: grid;
  grid-template-columns: minmax(180px, 0.28fr) minmax(420px, 1fr) auto;
  align-items: start;
  gap: 16px;
}

.drawing-body.is-collapsed {
  display: none;
}

.drawing-prompt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid #f1d795;
  border-radius: var(--radius);
  background: var(--yellow-soft);
}

.prompt-number {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--yellow);
  font-size: 13px;
  font-weight: 900;
}

.drawing-prompt p {
  margin: 1px 0 0;
  color: #70591d;
  font-size: 12px;
  line-height: 1.7;
}

.canvas-shell {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: #fff;
  background-image:
    linear-gradient(rgba(23, 50, 77, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 50, 77, 0.055) 1px, transparent 1px);
  background-size: 18px 18px;
}

#drawingCanvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
  aspect-ratio: 16 / 9;
  cursor: crosshair;
  touch-action: none;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: #8b9cab;
  pointer-events: none;
  font-size: 12px;
}

.canvas-empty svg {
  width: 28px;
  height: 28px;
}

.canvas-empty.is-hidden {
  display: none;
}

.canvas-toolbar {
  display: flex;
  min-width: 160px;
  flex-direction: column;
  gap: 15px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.color-swatches,
.brush-sizes,
.canvas-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.swatch {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--swatch);
  cursor: pointer;
}

.swatch.is-active {
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--ink);
}

.brush-sizes button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.brush-sizes button.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.brush-sizes i {
  display: block;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--ink);
}

.eraser-glyph {
  display: block;
  width: 17px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-35deg);
}

.save-button {
  width: 100%;
  color: #fff;
  border-color: var(--mint);
  background: var(--mint);
}

.save-button:hover {
  border-color: #148e80;
  background: #148e80;
}

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

.subject-map {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.subject-map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}

.subject-map-head h2 {
  margin: 0;
  font-size: 18px;
}

.subject-map-head p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.map-score {
  display: grid;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  place-items: center;
  border: 5px solid var(--line);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.subject-map[data-subject="chinese"] .map-score {
  color: var(--coral);
  border-color: #f7aaa0;
}

.subject-map[data-subject="math"] .map-score {
  color: var(--mint);
  border-color: #88d5ca;
}

.subject-map[data-subject="english"] .map-score {
  color: var(--blue);
  border-color: #9eb5eb;
}

.map-nodes {
  display: grid;
  gap: 0;
  padding: 8px 18px 18px;
}

.map-node {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 66px;
  padding: 10px 0;
}

.map-node:not(:last-child)::after {
  position: absolute;
  bottom: -8px;
  left: 16px;
  width: 2px;
  height: 22px;
  content: "";
  background: var(--line);
}

.node-dot {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 11px;
  font-weight: 900;
}

.map-node.is-mastered .node-dot {
  color: #fff;
  border-color: var(--mint);
  background: var(--mint);
}

.map-node.is-learning .node-dot {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.map-node.is-review .node-dot {
  color: #7e5a0d;
  border-color: #efc866;
  background: var(--yellow-soft);
}

.node-copy strong,
.node-copy span {
  display: block;
}

.node-copy strong {
  font-size: 13px;
}

.node-copy span {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 11px;
}

.node-state {
  color: var(--ink-soft);
  font-size: 10px;
  white-space: nowrap;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.gallery-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 320px;
  place-content: center;
  justify-items: center;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.gallery-empty svg {
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  color: var(--blue);
}

.gallery-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-muted);
}

.gallery-meta {
  padding: 12px;
}

.gallery-meta strong,
.gallery-meta span {
  display: block;
}

.gallery-meta strong {
  font-size: 13px;
}

.gallery-meta span {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 11px;
}

.parent-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.insight-panel {
  padding: 20px;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--ink-soft);
  font-size: 11px;
}

.metric strong {
  margin-top: 6px;
  font-size: 24px;
}

.next-step {
  margin-top: 14px;
  padding: 14px;
  border-left: 4px solid var(--blue);
  color: var(--ink-soft);
  background: var(--blue-soft);
  font-size: 13px;
  line-height: 1.7;
}

.release-gate {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #f0c9c3;
  border-left: 4px solid var(--coral);
  border-radius: var(--radius);
  background: var(--coral-soft);
}

.release-gate strong,
.release-gate span {
  display: block;
}

.release-gate strong {
  color: #a73529;
  font-size: 14px;
}

.release-gate p {
  margin: 7px 0 0;
  color: #7a4c45;
  font-size: 12px;
  line-height: 1.7;
}

.release-gate ul {
  margin: 9px 0 0;
  padding-left: 18px;
  color: #7a4c45;
  font-size: 11px;
  line-height: 1.75;
}

.curriculum-list {
  margin: 0;
}

.curriculum-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.curriculum-list dt {
  font-weight: 800;
}

.curriculum-list dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: right;
}

.curriculum-note {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.7;
}

.setup-dialog {
  width: min(600px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(23, 50, 77, 0.24);
}

.setup-dialog::backdrop {
  background: rgba(16, 34, 51, 0.48);
  backdrop-filter: blur(5px);
}

.setup-dialog form {
  padding: 22px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-heading h2 {
  margin: 4px 0 0;
  font-size: 23px;
}

.setup-steps {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.setup-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.setup-step > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.setup-step strong {
  font-size: 14px;
}

.setup-step p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.install-guide {
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid #c9dcf8;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.install-guide strong {
  display: block;
  font-size: 14px;
}

.install-guide p {
  margin: 6px 0 12px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.download-link {
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 38px rgba(23, 50, 77, 0.18);
  font-size: 13px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .learn-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .drawing-section {
    grid-column: auto;
  }

  .drawing-body {
    grid-template-columns: 1fr;
  }

  .canvas-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .save-button {
    width: auto;
  }
}

@media (max-width: 900px) {
  :root {
    --topbar-height: 68px;
  }

  .app-shell {
    grid-template:
      "topbar" var(--topbar-height)
      "main" auto
      "sidebar" auto /
      1fr;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    padding: 0 16px;
  }

  .topbar-context,
  .top-stat {
    display: none;
  }

  .sidebar {
    position: fixed;
    right: 14px;
    bottom: 12px;
    left: 14px;
    top: auto;
    z-index: 25;
    height: auto;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 34px rgba(23, 50, 77, 0.18);
  }

  .main-nav {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .nav-item {
    min-height: 50px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px;
    font-size: 10px;
  }

  .nav-item svg {
    width: 19px;
    height: 19px;
  }

  .sidebar-note {
    display: none;
  }

  .main-content {
    padding: 22px 16px 96px;
  }

  .view-heading {
    align-items: flex-start;
  }

  .daily-goal {
    width: 260px;
  }

  .map-grid,
  .parent-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 16px;
  }

  .install-button {
    min-height: 38px;
    padding: 0 10px;
  }

  .view-heading {
    display: grid;
    gap: 14px;
  }

  .daily-goal {
    width: 100%;
  }

  .view-intro {
    text-align: left;
  }

  .tutor-section,
  .mission-section,
  .drawing-section,
  .insight-panel {
    padding: 15px;
  }

  .section-heading {
    align-items: flex-start;
    gap: 10px;
  }

  .section-heading .status-pill {
    display: none;
  }

  .section-heading h2 {
    font-size: 18px;
  }

  .tutor-frame {
    min-height: 300px;
  }

  .action-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-label {
    grid-column: 1 / -1;
    width: auto;
  }

  .tool-button {
    width: 100%;
    padding: 0 8px;
  }

  .voice-mode-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .media-hint {
    margin-left: 0;
  }

  .mission-actions {
    grid-template-columns: 1fr;
  }

  .canvas-toolbar {
    align-items: stretch;
  }

  .save-button {
    width: 100%;
  }

  .summary-metrics {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }
}

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