:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #172126;
  --muted: #66757f;
  --subtle: #8c99a1;
  --border: #dce3e7;
  --border-strong: #c7d2d8;
  --primary: #126b5b;
  --primary-dark: #0d5146;
  --primary-soft: #e7f3f0;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --amber: #b7791f;
  --amber-soft: #fff5df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 16px 38px rgba(18, 38, 49, 0.08);
  --radius: 8px;
  --sidebar: 280px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 780;
}

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

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

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.role-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.role-button.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(18, 38, 49, 0.1);
}

.sidebar-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-label {
  display: block;
  margin-bottom: 9px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 760;
}

.class-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.class-block strong {
  font-size: 14px;
}

.class-block span {
  color: var(--muted);
  font-size: 12px;
}

.class-block code {
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid #c7ddff;
  border-radius: 6px;
  background: var(--blue-soft);
  color: #174ea6;
  font-size: 13px;
  font-weight: 760;
}

.demo-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sidebar-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.crumb {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.topbar h1 {
  margin-bottom: 7px;
  font-size: 28px;
  line-height: 1.22;
}

.topbar p:not(.crumb) {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 330px;
}

.live-pill,
.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.live-pill span {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 999px;
  background: #13a876;
  box-shadow: 0 0 0 4px rgba(19, 168, 118, 0.15);
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 760;
}

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

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

.secondary-button,
.ghost-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.ghost-button {
  width: 100%;
  margin-top: 12px;
}

.compact {
  min-height: 34px;
  padding: 0 11px;
}

.view {
  display: none;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-panel,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-panel {
  padding: 15px 16px;
}

.metric-panel span,
.metric-panel small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-panel strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1.05;
}

.teacher-grid,
.student-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.84fr) minmax(340px, 1.22fr) minmax(280px, 0.94fr);
  gap: 14px;
}

.student-grid {
  grid-template-columns: minmax(320px, 0.9fr) minmax(390px, 1.1fr);
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.lesson-outline,
.heat-list,
.insight-list,
.question-table,
.suggestions {
  display: grid;
  gap: 10px;
}

.outline-item {
  display: grid;
  gap: 7px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.outline-item:last-child {
  border-bottom: 0;
}

.outline-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.outline-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f4;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 220ms ease;
}

.chat-panel,
.student-chat-panel {
  display: flex;
  min-height: 520px;
  flex-direction: column;
}

.chat-stream {
  display: flex;
  min-height: 0;
  max-height: 465px;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.message {
  width: min(92%, 620px);
  padding: 12px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.58;
}

.message.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
}

.message.assistant {
  align-self: flex-start;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.message-meta {
  display: block;
  margin-top: 7px;
  color: var(--subtle);
  font-size: 12px;
}

.heat-row {
  display: grid;
  gap: 7px;
}

.heat-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.insight-list {
  margin-top: 16px;
}

.insight-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.insight-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.insight-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.table-panel {
  margin-top: 14px;
}

.question-row {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1fr) 138px 118px;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.question-row:first-child {
  border-top: 0;
}

.question-row strong {
  color: var(--ink);
}

.tag {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.tag.ok {
  border-color: #bfe5d6;
  background: var(--primary-soft);
  color: var(--primary);
}

.tag.warn {
  border-color: #f0d08f;
  background: var(--amber-soft);
  color: var(--amber);
}

.reader-panel {
  min-height: 620px;
}

.lesson-reader {
  max-height: 520px;
  overflow: auto;
  padding-right: 8px;
  color: var(--ink);
}

.lesson-reader h3 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.lesson-reader h3:first-child {
  margin-top: 0;
}

.lesson-reader p {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.suggestions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.suggestion-button {
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.suggestion-button:hover {
  border-color: #bed5cd;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.ask-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.ask-form input {
  min-height: 42px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  outline: none;
}

.ask-form input:focus {
  border-color: #85b9aa;
  box-shadow: 0 0 0 3px rgba(18, 107, 91, 0.12);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid #bfe5d6;
  border-radius: var(--radius);
  background: var(--primary-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .teacher-grid,
  .student-grid {
    grid-template-columns: 1fr;
  }

  .chat-panel,
  .student-chat-panel,
  .reader-panel {
    min-height: 0;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: flex-start;
    min-width: 0;
  }

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

  .question-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 14px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .metric-grid,
  .suggestions,
  .ask-form {
    grid-template-columns: 1fr;
  }

  .topbar-actions > *,
  .ask-form button {
    width: 100%;
  }
}

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