:root {
  color-scheme: dark;
  --bg: #171717;
  --surface: #202124;
  --surface-2: #27292d;
  --surface-3: #303237;
  --line: #3b3e45;
  --text: #f3f4f6;
  --muted: #a9afb8;
  --green: #5ecf8b;
  --cyan: #65c7d8;
  --amber: #d6a84c;
  --danger: #d96a6a;
  --rail: #111;
  --shadow: 0 1.125rem 2.875rem rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #eceff3;
  --line: #d7dce3;
  --text: #1f2328;
  --muted: #667085;
  --green: #2f9d68;
  --cyan: #237c91;
  --amber: #a66f00;
  --danger: #c64b4b;
  --rail: #202327;
  --shadow: 0 1.125rem 2.875rem rgba(31, 35, 40, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 20rem;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  padding: 0;
  margin: -0.0625rem;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100vh;
  display: block;
  overflow: hidden;
}

.view-selector {
  position: relative;
  min-width: 0;
}

.view-heading {
  margin: 0;
}

.view-switcher {
  min-width: 7rem;
  height: 2.375rem;
  padding: 0 0.75rem;
  border: 0.0625rem solid transparent;
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.view-switcher:hover,
.view-switcher:focus-visible,
.view-switcher[aria-expanded="true"] {
  border-color: var(--line);
  background: var(--surface-2);
  outline: none;
}

.view-switcher-chevron {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: transform 120ms ease;
}

.view-switcher[aria-expanded="true"] .view-switcher-chevron {
  transform: rotate(180deg);
}

.view-menu {
  position: absolute;
  inset: calc(100% + 0.375rem) auto auto 0;
  z-index: 50;
  width: 10.5rem;
  padding: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.activity-button {
  position: relative;
  width: 100%;
  min-height: 2.5rem;
  padding: 0 2rem 0 0.625rem;
  border: 0;
  border-radius: 0.375rem;
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition:
    color 120ms ease,
    background 120ms ease;
}

.activity-button:hover,
.activity-button:focus-visible {
  color: var(--text);
  background: var(--surface-3);
  outline: none;
}

.activity-button.is-active {
  color: var(--green);
  background: rgba(94, 207, 139, 0.16);
}

.activity-button svg,
.icon-action svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.activity-button:first-child svg path {
  fill: currentColor;
  stroke: none;
}

.activity-button span {
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1;
  white-space: nowrap;
}

.activity-button .mail-entry-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.35rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999rem;
  color: #fff;
  background: #ef4444;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.workspace {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  position: relative;
  min-height: 3.25rem;
  padding: 0.4375rem clamp(0.875rem, 2vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  border-bottom: 0.0625rem solid var(--line);
  background: var(--surface);
  transition:
    min-height 160ms ease,
    padding 160ms ease,
    opacity 160ms ease;
}

.app-shell.is-topbar-collapsed[data-view="classroom"] .topbar {
  min-height: 0;
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
}

.topbar-collapse-handle,
.topbar-expand-button {
  width: 2.125rem;
  height: 1rem;
  padding: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem 0.375rem 0 0;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.topbar-collapse-handle:hover,
.topbar-collapse-handle:focus-visible,
.topbar-expand-button:hover,
.topbar-expand-button:focus-visible {
  background: var(--surface-3);
  outline: 0.125rem solid rgba(101, 199, 216, 0.24);
  outline-offset: 0.125rem;
}

.topbar-collapse-handle svg,
.topbar-expand-button svg {
  width: 0.875rem;
  height: 0.875rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-collapse-handle {
  position: absolute;
  left: 50%;
  bottom: -0.0625rem;
  z-index: 30;
  transform: translateX(-50%);
}

.topbar-expand-button {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 28;
  display: none;
  border-radius: 0 0 0.375rem 0.375rem;
  transform: translateX(-50%);
}

.app-shell.is-topbar-collapsed[data-view="classroom"] .topbar-expand-button {
  display: grid;
}

.classroom-session-controls {
  min-width: 0;
  margin-left: 0.75rem;
  margin-right: auto;
  display: none;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.app-shell[data-view="classroom"] .classroom-session-controls {
  display: inline-flex;
}

.session-action {
  min-height: 2.25rem;
  padding: 0 0.875rem;
  border: 0.0625rem solid rgba(94, 207, 139, 0.42);
  border-radius: 0.375rem;
  color: #ffffff;
  background: var(--green);
  cursor: pointer;
  font-weight: 650;
}

.session-action:hover,
.session-action:focus-visible {
  filter: brightness(1.05);
  outline: 0.125rem solid rgba(94, 207, 139, 0.28);
  outline-offset: 0.125rem;
}

.session-action[aria-pressed="true"] {
  border-color: rgba(217, 106, 106, 0.48);
  background: var(--danger);
}

.session-action:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.session-timer {
  min-width: 4.25rem;
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.topbar-class-group {
  width: clamp(8.75rem, 15vw, 11rem);
  min-height: 2.25rem;
  padding: 0 0.625rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.topbar-control-switch {
  width: 2.375rem;
  height: 2.375rem;
  padding: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.topbar-control-switch:hover,
.topbar-control-switch:focus-within {
  background: var(--surface-3);
  outline: 0.125rem solid rgba(101, 199, 216, 0.24);
  outline-offset: 0.125rem;
}

.topbar-control-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.topbar-control-switch svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-control-switch:has(input:checked) {
  border-color: rgba(94, 207, 139, 0.58);
  color: #102016;
  background: var(--green);
}

.icon-action {
  width: 2.375rem;
  height: 2.375rem;
  padding: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.icon-action:hover,
.icon-action:focus-visible {
  background: var(--surface-3);
  outline: 0.125rem solid rgba(101, 199, 216, 0.24);
  outline-offset: 0.125rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--cyan);
  font-size: 0.8125rem;
}

.topbar .eyebrow {
  display: none;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 680;
}

h2 {
  margin-bottom: 0;
  font-size: 1.125rem;
  font-weight: 650;
}

h3 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2.625rem);
  font-weight: 720;
}

.teacher-chip {
  height: 2.125rem;
  padding: 0 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5625rem;
  border: 0.0625rem solid var(--line);
  border-radius: 62.44rem;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 62.44rem;
  background: var(--green);
  box-shadow: 0 0 0 0.25rem rgba(94, 207, 139, 0.12);
}

.logout-action {
  height: 2.125rem;
  padding: 0 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 62.44rem;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

.logout-action:hover {
  color: var(--text);
  border-color: var(--accent);
}

.sync-chip {
  height: 2.125rem;
  padding: 0 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 62.44rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.sync-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 62.44rem;
  background: var(--amber);
  box-shadow: 0 0 0 0.25rem rgba(214, 168, 76, 0.12);
}

.sync-chip[data-status="success"] .sync-dot {
  background: var(--green);
  box-shadow: 0 0 0 0.25rem rgba(94, 207, 139, 0.12);
}

.sync-chip[data-status="error"] .sync-dot {
  background: var(--danger);
  box-shadow: 0 0 0 0.25rem rgba(217, 106, 106, 0.12);
}

.content-grid {
  min-height: 0;
  padding: clamp(1.125rem, 4vw, 2.625rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16.25rem, 21.25rem);
  gap: 1.125rem;
}

.classroom-workbench {
  --classroom-outline-width: clamp(15rem, 28vw, 21rem);
  position: relative;
  min-height: 0;
  padding: clamp(1.125rem, 4vw, 2.625rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.classroom-edge-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 25;
  width: 1rem;
}

.classroom-left-zone {
  left: 0;
}

.classroom-outline-panel {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 26;
  width: var(--classroom-outline-width);
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 0.0625rem solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transform: translateX(0);
  transition: transform 180ms ease;
}

.classroom-workbench.is-outline-collapsed .classroom-outline-panel {
  transform: translateX(calc(-100% - 0.75rem));
  pointer-events: none;
}

.classroom-outline-scroll {
  min-height: 0;
  padding: 0.75rem;
  overflow: auto;
}

.classroom-main-panel {
  min-height: 0;
  height: 100%;
  padding: 0;
  padding-top: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.classroom-corner-zone {
  position: absolute;
  bottom: 0;
  z-index: 24;
  width: clamp(3rem, 8vw, 5rem);
  height: clamp(3rem, 8vw, 5rem);
}

.classroom-prev-zone {
  left: 0;
}

.classroom-next-zone {
  right: 0;
}

.classroom-nav-button {
  position: absolute;
  bottom: 1rem;
  z-index: 27;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 62.44rem;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.75rem);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    background 120ms ease;
}

.classroom-prev-button {
  left: 1rem;
}

.classroom-next-button {
  right: 1rem;
}

.classroom-nav-button svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.classroom-nav-button:hover,
.classroom-nav-button:focus-visible {
  background: var(--surface-3);
  outline: 0.125rem solid rgba(101, 199, 216, 0.24);
  outline-offset: 0.125rem;
}

.classroom-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0;
}

.app-shell[data-view="classroom"] .classroom-workbench.is-prev-nav-open .classroom-prev-button:not(:disabled),
.app-shell[data-view="classroom"] .classroom-workbench.is-next-nav-open .classroom-next-button:not(:disabled),
.classroom-nav-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.is-hidden {
  display: none !important;
}

.primary-panel,
.side-panel {
  min-width: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.primary-panel {
  min-height: 30rem;
  padding: clamp(1.125rem, 3vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: 1.375rem;
}

.side-panel {
  padding: 1.375rem;
  align-self: start;
}

.class-group-workspace {
  min-height: 0;
  padding: clamp(1.125rem, 4vw, 2.625rem);
  display: grid;
  grid-template-columns: minmax(11.5rem, 14rem) minmax(0, 1fr);
  gap: 1rem;
  overflow: hidden;
}

.class-group-nav,
.class-group-main {
  min-width: 0;
  min-height: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.class-group-nav {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.class-group-nav-head {
  padding: 0 0.25rem 0.75rem;
}

.mail-workspace {
  min-height: 0;
  padding: clamp(1.125rem, 4vw, 2.625rem);
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 1rem;
  overflow: hidden;
}

.mail-list-panel,
.mail-detail-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
  overflow: hidden;
}

.mail-thread-list,
.mail-message-list {
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
}

.mail-student-search {
  padding: 0.75rem;
  border-bottom: 0.0625rem solid var(--line);
}

.mail-student-search input {
  width: 100%;
}

.mail-student-results {
  max-height: 13rem;
  overflow: auto;
  margin-top: 0.5rem;
  display: grid;
  gap: 0.35rem;
}

.mail-student-result {
  width: 100%;
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.45rem;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.mail-student-result:hover {
  border-color: var(--accent);
}

.mail-student-result small {
  color: var(--muted);
}

.mail-thread-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.625rem;
  padding: 0.75rem;
  border: 0;
  border-radius: 0.45rem;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.mail-thread-item:hover,
.mail-thread-item.is-active {
  background: var(--surface-3);
}

.mail-unread-dot {
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.3rem;
  border-radius: 999px;
  background: transparent;
}

.mail-thread-item.is-unread .mail-unread-dot {
  background: #ef4444;
}

.mail-thread-title {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 700;
}

.mail-thread-meta,
.mail-message-time {
  color: var(--muted);
  font-size: 0.82rem;
}

.mail-detail-head {
  padding: 0.95rem 1rem;
  border-bottom: 0.0625rem solid var(--line);
}

.mail-message {
  max-width: min(44rem, 86%);
  margin: 0 0 0.75rem;
  padding: 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.mail-message.is-mine {
  margin-left: auto;
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
}

.mail-message:not(.is-mine) {
  margin-right: auto;
}

.mail-message-body {
  overflow-wrap: anywhere;
}

.mail-message-body img {
  max-width: 100%;
  border-radius: 0.375rem;
}

.mail-resizable-media {
  position: relative;
  display: block;
  width: 70%;
  max-width: 100%;
  margin: 0.5rem 0;
  line-height: 0;
}

.mail-resizable-media img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 0.375rem;
}

.mail-resizable-media.is-resizing {
  outline: 0.12rem solid rgba(37, 99, 235, 0.35);
  outline-offset: 0.15rem;
}

.mail-composer {
  padding: 0.75rem;
  border-top: 0.0625rem solid var(--line);
  background: var(--surface-2);
}

.mail-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.mail-editor-toolbar button {
  min-width: 2rem;
  height: 2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.mail-rich-editor {
  min-height: 6rem;
  max-height: 13rem;
  overflow: auto;
  padding: 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  outline: none;
}

.mail-rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.mail-compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.class-group-nav-head h2 {
  margin: 0;
  font-size: 1rem;
}

.class-group-tab {
  min-height: 2.375rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 0.375rem;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.class-group-tab:hover,
.class-group-tab:focus-visible {
  color: var(--text);
  background: var(--surface-3);
  outline: none;
}

.class-group-tab.is-active {
  color: var(--green);
  background: rgba(94, 207, 139, 0.16);
}

.class-group-main {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
  overflow: hidden;
}

.class-group-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 1rem;
  overflow: auto;
}

.class-group-panel-tools {
  display: grid;
  grid-template-columns: minmax(14rem, 24rem);
  gap: 0.875rem;
}

.class-group-panel-tools label {
  display: grid;
  gap: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.class-group-panel-tools select {
  min-height: 2.375rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  padding: 0 0.75rem;
  color: var(--text);
  background: var(--surface);
}

.class-group-management-list,
.class-group-member-list,
.class-group-member-rows {
  display: grid;
  gap: 0.75rem;
}

.class-group-management-row,
.class-group-member-row,
.member-list-head {
  min-height: 3.25rem;
  padding: 0.625rem 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  display: grid;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
}

.class-group-management-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.class-group-row-main {
  min-width: 0;
  min-height: 2.25rem;
  padding: 0;
  border: 0;
  display: grid;
  gap: 0.25rem;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.class-group-management-row.is-selected {
  border-color: rgba(94, 207, 139, 0.45);
  background: rgba(94, 207, 139, 0.08);
}

.class-group-row-main span,
.member-list-head span,
.class-group-member-row small {
  color: var(--muted);
  font-size: 0.8125rem;
}

.member-list-head {
  grid-template-columns: minmax(0, 1fr) auto;
}

.class-group-member-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.class-group-member-row > span:first-child {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.danger-action {
  min-height: 2.25rem;
  padding: 0 0.8125rem;
  border: 0.0625rem solid rgba(217, 106, 106, 0.35);
  border-radius: 0.375rem;
  color: var(--danger);
  background: var(--surface);
  cursor: pointer;
}

.danger-action:hover,
.danger-action:focus-visible {
  background: rgba(217, 106, 106, 0.12);
  outline: 0.125rem solid rgba(217, 106, 106, 0.2);
  outline-offset: 0.125rem;
}

.prep-workbench {
  --prep-tree-width: clamp(16rem, 30vw, 22rem);
  --component-width: clamp(15rem, 26vw, 21rem);
  position: relative;
  min-height: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.prep-workbench.is-tree-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.prep-workbench.is-components-collapsed .prep-content-layout {
  grid-template-columns: minmax(0, 1fr);
}

.prep-sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 26;
  width: var(--prep-tree-width);
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 0.0625rem solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transform: translateX(0);
  transition: transform 180ms ease;
}

.prep-workbench.is-tree-collapsed .prep-sidebar {
  transform: translateX(calc(-100% - 0.75rem));
  pointer-events: none;
}

.prep-edge-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 25;
  width: 1rem;
}

.prep-left-zone {
  left: 0;
}

.prep-right-zone {
  right: 0;
}

.explorer-header,
.explorer-footer {
  min-height: 3rem;
  padding: 0 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  border-bottom: 0.0625rem solid var(--line);
}

.explorer-footer {
  min-height: 2.25rem;
  border-top: 0.0625rem solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.explorer-header h2 {
  font-size: 0.8125rem;
  text-transform: uppercase;
}

.explorer-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.mini-action {
  width: 1.875rem;
  height: 1.875rem;
  padding: 0;
  border: 0;
  border-radius: 0.3125rem;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mini-action:hover,
.mini-action:focus-visible,
.mini-action[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-3);
  outline: none;
}

.mini-action svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.prep-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: clamp(0.75rem, 1.5vw, 1.125rem);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.prep-editor-head {
  display: none;
}

.prep-editor-head > div:first-child {
  display: none;
}

.prep-editor-placeholder {
  margin-top: 1.125rem;
  min-height: 16.25rem;
  padding: clamp(1.25rem, 4vw, 2.125rem);
  border: 0.0625rem dashed var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.prep-editor-placeholder h3 {
  font-size: clamp(1.375rem, 3vw, 2rem);
}

.prep-content-layout {
  position: relative;
  min-height: 0;
  height: 100%;
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  overflow: hidden;
}

.lesson-editor-panel,
.component-panel {
  min-width: 0;
  min-height: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

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

.editor-toolbar {
  position: relative;
  min-height: 3rem;
  padding: 0.625rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 0.0625rem solid var(--line);
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding-right: 0.5rem;
  border-right: 0.0625rem solid var(--line);
}

.toolbar-group:last-child {
  border-right: 0;
}

.editor-toolbar button,
.editor-toolbar select,
.editor-toolbar input[type="color"] {
  min-width: 2.125rem;
  min-height: 2rem;
  padding: 0 0.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.3125rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
}

.editor-toolbar select {
  min-width: 3.75rem;
}

.editor-toolbar input[type="color"] {
  width: 2.375rem;
  padding: 0.1875rem;
}

.editor-toolbar button:hover,
.editor-toolbar button:focus-visible,
.editor-toolbar select:hover,
.editor-toolbar select:focus-visible {
  background: var(--surface-3);
  outline: none;
}

.toolbar-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.5rem);
  left: 50%;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.table-picker-popover {
  display: grid;
  gap: 0.625rem;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(8, 1.625rem);
  gap: 0.25rem;
  justify-content: center;
}

.table-grid-cell {
  width: 1.625rem;
  height: 1.625rem;
  padding: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.25rem;
  background: var(--surface);
  cursor: pointer;
}

.table-grid-cell.is-active {
  border-color: var(--cyan);
  background: rgba(101, 199, 216, 0.22);
}

.table-size-label {
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.formula-popover {
  width: min(32rem, calc(100vw - 2rem));
  display: grid;
  gap: 0.75rem;
}

.formula-popover math-field,
.formula-popover textarea {
  width: 100%;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  padding: 0.55rem 0.625rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.formula-popover math-field,
.formula-popover textarea {
  min-height: 4.8rem;
}

.formula-preview,
.math-formula {
  border: 0.0625rem solid rgba(101, 199, 216, 0.35);
  border-radius: 0.375rem;
  color: var(--cyan);
  background: rgba(101, 199, 216, 0.12);
  font-family: "Times New Roman", serif;
}

.formula-preview {
  min-height: 3rem;
  padding: 0.65rem 0.75rem;
  overflow-x: auto;
  text-align: center;
}

.formula-preview.compact {
  min-height: 2.5rem;
  font-size: 0.92rem;
}

.formula-render {
  color: inherit;
  font-family: "Times New Roman", Georgia, serif;
  font-size: 1.15em;
  line-height: 1.45;
}

.formula-fraction {
  min-width: 1.5em;
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: center;
  vertical-align: middle;
}

.formula-fraction > span:first-child {
  padding: 0 0.25em 0.08em;
  border-bottom: 0.08em solid currentColor;
}

.formula-fraction > span:last-child {
  padding: 0.08em 0.25em 0;
}

.formula-sqrt {
  display: inline-flex;
  align-items: stretch;
  gap: 0.08em;
  vertical-align: middle;
}

.formula-sqrt::before {
  content: "√";
  font-size: 1.25em;
  line-height: 1;
}

.formula-sqrt > span {
  padding: 0 0.18em;
  border-top: 0.08em solid currentColor;
}

.formula-cases {
  display: inline-block;
  padding-left: 0.45em;
  border-left: 0.12em solid currentColor;
  text-align: left;
  vertical-align: middle;
}

.formula-tool-section {
  display: grid;
  gap: 0.35rem;
}

.formula-tool-section > span {
  color: var(--muted);
  font-size: 0.72rem;
}

.formula-actions {
  display: flex;
  gap: 0.5rem;
}

.formula-actions {
  align-items: center;
  justify-content: flex-end;
}

.formula-template-grid,
.formula-symbol-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.formula-template-grid button,
.formula-symbol-grid button {
  min-height: 2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.35rem;
  padding: 0.25rem 0.5rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-family: "Times New Roman", Georgia, serif;
}

.formula-template-grid button:hover,
.formula-template-grid button:focus-visible,
.formula-symbol-grid button:hover,
.formula-symbol-grid button:focus-visible {
  border-color: var(--cyan);
  outline: none;
  background: rgba(101, 199, 216, 0.14);
}

.math-formula {
  display: inline-grid;
  min-height: 1.7em;
  padding: 0 0.35em;
  place-items: center;
  vertical-align: middle;
  white-space: nowrap;
}

.math-formula.is-editing {
  outline: 0.125rem solid var(--cyan);
  outline-offset: 0.125rem;
}

.math-formula[data-display="block"] {
  display: grid;
  margin: 0.75rem auto;
  padding: 0.55rem 0.75rem;
  width: fit-content;
  max-width: 100%;
  font-size: 1.15em;
}

.editor-scroll {
  min-height: 0;
  overflow: auto;
}

.lesson-editor,
.section-preview {
  width: min(100%, 54rem);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
  color: var(--text);
  background: var(--surface);
  outline: none;
  line-height: 1.75;
}

.lesson-editor:focus {
  box-shadow: inset 0 0 0 0.0625rem rgba(101, 199, 216, 0.55);
}

.lesson-editor blockquote,
.section-preview blockquote {
  margin: 1rem 0;
  padding: 0.5rem 0.875rem;
  border-left: 0.25rem solid var(--cyan);
  color: var(--muted);
  background: var(--surface-2);
}

.lesson-editor hr,
.section-preview hr {
  border: 0;
  border-top: 0.0625rem solid var(--line);
  margin: 1.25rem 0;
}

.lesson-editor:empty::before {
  content: "在这里编辑小节内容。可输入文字，也可从右侧拖入组件。";
  color: var(--muted);
}

.lesson-editor[contenteditable="false"] {
  color: var(--muted);
  cursor: not-allowed;
}

.lesson-editor h3,
.section-preview h3 {
  margin: 0.75rem 0 0.5rem;
  font-size: 1.25rem;
}

.lesson-editor p,
.section-preview p {
  margin: 0.5rem 0;
}

.component-panel {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 24;
  width: var(--component-width);
  height: 100%;
  overflow: hidden;
  padding: 0.875rem;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.75rem;
  box-shadow: var(--shadow);
  transform: translateX(0);
  transition: transform 180ms ease;
}

.prep-workbench.is-components-collapsed .component-panel {
  transform: translateX(calc(100% + 0.75rem));
  pointer-events: none;
}

.component-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.component-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.component-panel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.component-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.625rem;
}

.component-item.drop-before {
  box-shadow: 0 -0.18rem 0 var(--primary);
}

.component-item.drop-after {
  box-shadow: 0 0.18rem 0 var(--primary);
}

.ai-generate-action {
  min-height: 2.25rem;
  border: 0.0625rem solid rgba(94, 207, 139, 0.42);
  border-radius: 0.375rem;
  color: #102016;
  background: var(--green);
  cursor: pointer;
  font-weight: 650;
}

.component-item {
  padding: 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  cursor: grab;
}

.component-item:hover,
.component-item:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.component-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
}

.component-item-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.375rem;
}

.component-name {
  margin-bottom: 0.25rem;
  font-weight: 650;
}

.component-kind {
  padding: 0.125rem 0.375rem;
  border: 0.0625rem solid var(--line);
  border-radius: 62.44rem;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.6875rem;
  line-height: 1.2;
}

.component-item.is-system .component-kind {
  color: var(--cyan);
}

.component-item.is-custom .component-kind {
  color: var(--green);
}

.component-delete-button {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  border: 0.0625rem solid rgba(217, 106, 106, 0.38);
  border-radius: 50%;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.component-delete-button:hover,
.component-delete-button:focus-visible {
  background: rgba(217, 106, 106, 0.12);
  outline: none;
}

.component-meta,
.component-empty {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.component-form {
  padding-top: 0.75rem;
  display: grid;
  gap: 0.625rem;
  border-top: 0.0625rem solid var(--line);
}

.component-edit-popover,
.response-popover {
  position: fixed;
  z-index: 56;
  right: clamp(1rem, 3vw, 2rem);
  top: clamp(4.5rem, 14vh, 7rem);
  width: min(27rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100vh - 8rem));
  padding: 1rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  color: var(--text);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.response-popover {
  width: min(34rem, calc(100vw - 2rem));
}

.component-edit-popover label,
.component-edit-popover .rich-config-field {
  display: grid;
  gap: 0.3125rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.component-edit-popover .config-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.component-edit-popover input,
.component-edit-popover textarea {
  width: 100%;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.component-edit-popover input {
  min-height: 2.125rem;
  padding: 0 0.625rem;
}

.component-edit-popover textarea,
.rich-input-editor {
  min-height: 5.5rem;
  max-height: min(18rem, 34vh);
  padding: 0.5rem 0.625rem;
  line-height: 1.5;
  overflow: auto;
}

.component-edit-popover textarea {
  resize: vertical;
}

.component-edit-popover lexiang-rich-input.cfg-rich-field {
  position: relative;
  width: 100%;
  display: block;
  color: var(--text);
}

.rich-input-shell {
  position: relative;
  display: grid;
  gap: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  background: var(--surface);
  overflow: visible;
}

.rich-input-shell:focus-within {
  border-color: var(--cyan);
}

.rich-input-toolbar {
  min-height: 2.25rem;
  padding: 0.3125rem;
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  border-bottom: 0.0625rem solid var(--line);
  background: var(--surface-2);
}

.rich-input-tool,
.rich-formula-actions button,
.rich-formula-template-grid button,
.rich-formula-symbol-grid button,
.rich-formula-close {
  min-width: 2rem;
  min-height: 1.875rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.3125rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.rich-input-tool:hover,
.rich-formula-actions button:hover,
.rich-formula-template-grid button:hover,
.rich-formula-symbol-grid button:hover,
.rich-formula-close:hover {
  border-color: var(--cyan);
}

.rich-input-editor {
  width: 100%;
  border: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
  outline: none;
}

lexiang-rich-input.is-single-line .rich-input-editor {
  min-height: 2.125rem;
  max-height: 5rem;
  padding: 0.35rem 0.625rem;
  white-space: nowrap;
}

.component-edit-popover input:focus,
.component-edit-popover textarea:focus {
  border-color: var(--cyan);
  outline: none;
}

.rich-formula-popover {
  position: absolute;
  z-index: 40;
  top: 2.5rem;
  right: 0.375rem;
  width: min(25rem, calc(100vw - 3rem));
  padding: 0.75rem;
  display: grid;
  gap: 0.625rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rich-formula-popover.is-hidden {
  display: none;
}

.rich-formula-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.rich-formula-field {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.375rem 0.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  background: var(--surface-2);
}

.rich-formula-template-grid,
.rich-formula-symbol-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3125rem;
}

.rich-formula-symbol-grid button {
  min-width: 2.25rem;
}

.rich-formula-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.rich-formula-actions button:last-child {
  color: #fff;
  border-color: transparent;
  background: var(--green);
}

.rich-input-image {
  max-width: 100%;
  max-height: 12rem;
  display: inline-block;
  vertical-align: middle;
  border-radius: 0.25rem;
}

.component-config-content {
  min-height: 0;
  display: grid;
  gap: 0.625rem;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
}

.component-config-content label,
.component-config-content .rich-config-field {
  display: grid;
  gap: 0.3125rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.component-config-content .checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem;
}

.image-config-card {
  display: grid;
  gap: 0.75rem;
}

.config-field {
  display: grid;
  gap: 0.375rem;
}

.config-field label {
  display: flex;
  justify-content: space-between;
  gap: 0.625rem;
}

.config-value {
  color: var(--cyan);
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.375rem;
}

.segmented-control.is-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented-control button {
  min-height: 2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.segmented-control button.is-active {
  border-color: rgba(101, 199, 216, 0.72);
  color: var(--text);
  background: rgba(101, 199, 216, 0.2);
}

.custom-code-field {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
}

.component-edit-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  padding-top: 0.25rem;
  background: var(--surface-2);
}

.popover-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.component-form label {
  display: grid;
  gap: 0.3125rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.component-form input,
.component-form textarea,
.control-form input,
.control-form select {
  width: 100%;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.component-form input,
.control-form input,
.control-form select {
  min-height: 2.125rem;
  padding: 0 0.625rem;
}

.component-form textarea {
  min-height: 5.75rem;
  padding: 0.5rem 0.625rem;
  resize: vertical;
}

.lesson-component {
  margin: 0.875rem 0;
  padding: 0.875rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.interactive-card {
  margin: 0.5rem 0;
  padding: 0.875rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.choice-mode-line {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.component-edit-popover .choice-mode-line input,
.component-edit-popover .choice-correct-control {
  width: auto;
}

.choice-option-editor {
  display: grid;
  gap: 0.45rem;
}

.choice-option-head,
.choice-option-row {
  display: grid;
  grid-template-columns: 2.8rem 1.5rem minmax(0, 1fr) 1.75rem;
  align-items: center;
  gap: 0.45rem;
}

.choice-option-head {
  grid-template-columns: 4.75rem minmax(0, 1fr);
  color: var(--muted);
  font-size: 0.75rem;
}

.choice-option-letter {
  color: var(--cyan);
  font-weight: 800;
  text-align: center;
}

.choice-option-remove {
  display: inline-grid;
  place-items: center;
}

.secondary-btn {
  min-height: 2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.interactive-card h3 {
  margin: 0 0 0.625rem;
  color: var(--cyan);
  font-size: 1rem;
}

.option-line {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.5rem 0;
  cursor: pointer;
}

.fill-input {
  width: min(22rem, 100%);
  min-height: 2.125rem;
  margin: 0.5rem 0;
  padding: 0 0.625rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface-2);
}

.submit-btn {
  min-height: 2rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 0.375rem;
  color: #102016;
  background: var(--green);
  cursor: pointer;
  font-weight: 650;
}

.feedback {
  margin: 0.5rem 0 0;
  font-weight: 700;
}

.plot-canvas {
  width: 100%;
  max-width: 32.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
}

.plot-expression {
  color: var(--muted);
  font-size: 0.8125rem;
}

.component-block {
  position: relative;
  width: min(100%, var(--component-width, 100%));
  min-height: var(--component-height, auto);
  max-width: 100%;
  margin: 1rem 0;
  padding: 0.75rem;
  border: 0.125rem dashed rgba(101, 199, 216, 0.55);
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--surface-2) 82%, var(--cyan));
  cursor: grab;
  user-select: none;
}

.component-block[data-align="left"] {
  margin-left: 0;
  margin-right: auto;
}

.component-block[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.component-block[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.component-block:active {
  cursor: grabbing;
}

.component-block.is-selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 0.0625rem rgba(94, 207, 139, 0.4);
}

.component-block.is-dragging {
  opacity: 0.45;
}

.component-block.is-resizing {
  cursor: nwse-resize;
  box-shadow: inset 0 0 0 0.0625rem rgba(37, 99, 235, 0.5), 0 0 0 0.18rem rgba(37, 99, 235, 0.14);
}

.component-resize-handle,
.mail-media-resize-handle {
  position: absolute;
  right: -0.35rem;
  bottom: -0.35rem;
  width: 0.9rem;
  height: 0.9rem;
  border: 0.12rem solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0.18rem 0.5rem rgba(15, 23, 42, 0.28);
  cursor: nwse-resize;
  touch-action: none;
}

.component-block-head {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.component-block-tools {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.component-align-button,
.component-remove {
  min-width: 1.7rem;
  min-height: 1.7rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.3rem;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}

.component-align-button.is-active {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

.component-badge {
  display: none;
  align-items: center;
  min-height: 1.375rem;
  padding: 0 0.5rem;
  border-radius: 62.44rem;
  color: #102016;
  background: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
}

.component-remove {
  width: 1.75rem;
  height: 1.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.3125rem;
  color: var(--danger);
  background: var(--surface);
  cursor: pointer;
}

.component-response-button {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 1.875rem;
  height: 1.875rem;
  padding: 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.3125rem;
  display: none;
  place-items: center;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.component-response-button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.classroom-preview .component-block,
.classroom-preview .runtime-component {
  position: relative;
  cursor: default;
}

.classroom-preview .component-remove {
  display: none;
}

.classroom-preview .component-response-button {
  display: grid;
}

.classroom-preview [data-classroom-focus-id] {
  transition: background 160ms ease, outline-color 160ms ease, box-shadow 160ms ease;
}

.classroom-preview .is-classroom-focus {
  outline: 0.18rem solid #f59e0b;
  outline-offset: 0.2rem;
  background: color-mix(in srgb, #f59e0b 14%, transparent);
  box-shadow: 0 0.35rem 1rem rgba(245, 158, 11, 0.18);
}

.component-preview-title {
  margin-bottom: 0.375rem;
  color: var(--cyan);
  font-weight: 700;
}

.image-block {
  display: block;
  width: var(--image-width, 70%);
  max-width: 100%;
  margin: 1.25rem auto;
  line-height: 0;
  clear: both;
  position: relative;
  cursor: pointer;
}

.image-block[data-align="left"] {
  margin-left: 0;
  margin-right: auto;
}

.image-block[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.image-block[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.image-block[data-wrap="inline"] {
  display: inline-block;
  margin: 0 0.5rem;
  clear: none;
  vertical-align: middle;
}

.image-block[data-wrap="inline"][data-align="left"] {
  margin-left: 0;
  margin-right: 0.5rem;
}

.image-block[data-wrap="inline"][data-align="center"] {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.image-block[data-wrap="inline"][data-align="right"] {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

.image-block[data-wrap="square-left"] {
  float: left;
  clear: none;
  margin: 0.5rem 1rem 0.75rem 0;
}

.image-block[data-wrap="square-right"] {
  float: right;
  clear: none;
  margin: 0.5rem 0 0.75rem 1rem;
}

.image-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--image-aspect, 1.3333);
  line-height: 0;
  overflow: hidden;
  border-radius: 0.5rem;
}

.image-block[data-quarter-turn="true"] .image-frame {
  aspect-ratio: var(--image-inverse-aspect, 0.75);
}

.image-block.is-selected .image-frame {
  outline: 0.1875rem solid var(--cyan);
  outline-offset: 0.25rem;
}

.image-block.is-selected .image-frame::after {
  content: "";
  position: absolute;
  right: -0.5rem;
  bottom: -0.5rem;
  width: 0.75rem;
  height: 0.75rem;
  border: 0.125rem solid var(--surface);
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: var(--shadow);
}

.editor-image {
  max-width: 100%;
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0.5rem;
  transform-origin: center center;
  object-fit: cover;
  translate: -50% -50%;
}

.image-block[data-fit="contain"] .editor-image {
  object-fit: contain;
  background: var(--surface);
}

.image-block[data-quarter-turn="true"] .editor-image {
  max-width: none;
}

.editor-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.editor-table th,
.editor-table td {
  border: 0.0625rem solid var(--line);
  padding: 0.5rem 0.625rem;
  min-width: 5rem;
  vertical-align: top;
}

.editor-table th {
  background: var(--surface-2);
  color: var(--cyan);
}

.ai-builder-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2rem);
  background: rgba(0, 0, 0, 0.58);
}

.ai-builder-mask.is-open {
  display: flex;
}

.ai-builder {
  width: min(90rem, 96vw);
  height: min(45rem, 90vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.ai-builder-header {
  min-height: 3.25rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.0625rem solid var(--line);
}

.ai-builder-header button {
  min-height: 2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.ai-builder-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(13rem, 0.7fr) minmax(20rem, 1fr) minmax(24rem, 1.15fr);
}

.ai-builder-settings,
.ai-chat-panel,
.ai-preview-panel {
  min-height: 0;
  padding: 1rem;
  overflow: auto;
}

.ai-builder-settings,
.ai-preview-panel {
  background: var(--surface);
}

.ai-builder-settings {
  border-right: 0.0625rem solid var(--line);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.75rem;
}

.ai-preview-panel {
  border-left: 0.0625rem solid var(--line);
}

.ai-builder label {
  display: grid;
  gap: 0.375rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.ai-builder textarea {
  width: 100%;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface-2);
  font: inherit;
}

.ai-builder textarea {
  min-height: 8rem;
  padding: 0.625rem;
  resize: vertical;
}

.ai-chat-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto auto;
  gap: 0.75rem;
}

.ai-image-attachment {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-image-attachment[hidden] {
  display: none;
}

.ai-image-attachment img {
  width: 7.5rem;
  height: 5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  object-fit: cover;
  background: var(--surface);
}

.ai-history-head,
.ai-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ai-history-head h3,
.ai-preview-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.ai-model-summary {
  padding: 0.55rem 0.65rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.8125rem;
}

.ai-conversation-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 0.5rem;
  overflow: auto;
}

.ai-conversation-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2rem;
  gap: 0.35rem;
  align-items: stretch;
}

.ai-conversation-item {
  min-width: 0;
  padding: 0.6rem 0.65rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}

.ai-conversation-delete {
  width: 2rem;
  min-height: 2rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--muted);
  background: var(--surface-2);
  cursor: pointer;
}

.ai-conversation-delete:hover {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.35);
}

.ai-conversation-item.is-active {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: inset 0 0 0 0.0625rem rgba(34, 211, 238, 0.18);
}

.ai-conversation-item strong,
.ai-conversation-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-conversation-item span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.ai-conversation-empty {
  color: var(--muted);
  font-size: 0.8125rem;
}

.ai-conversation-messages {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 0.65rem;
  overflow: auto;
}

.ai-conversation-message {
  max-width: 92%;
  padding: 0.65rem 0.75rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  white-space: pre-wrap;
  line-height: 1.55;
}

.ai-conversation-message.user {
  justify-self: end;
  border-color: rgba(37, 99, 235, 0.36);
  background: rgba(37, 99, 235, 0.12);
}

.ai-conversation-message.assistant {
  justify-self: start;
  background: var(--surface);
}

.ai-status {
  min-height: 1.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.ai-preview-list {
  display: grid;
  gap: 0.75rem;
}

.ai-preview-card {
  padding: 0.875rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.ai-preview-card h4 {
  margin: 0 0 0.375rem;
}

.ai-preview-card iframe {
  width: 100%;
  height: 14rem;
  margin: 0.625rem 0;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  background: #fff;
}

.lesson-component strong {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--cyan);
}

.lesson-component.info-card {
  border-left: 0.25rem solid var(--green);
}

.lesson-component.choice-card {
  border-left: 0.25rem solid var(--amber);
}

.lesson-component.steps-card {
  border-left: 0.25rem solid var(--cyan);
}

.section-subsection {
  padding: 1rem 0;
  border-bottom: 0.0625rem solid var(--line);
}

.section-subsection:last-child {
  border-bottom: 0;
}

.section-subsection-title {
  margin: 0 0 0.625rem;
  color: var(--cyan);
  font-size: 1.125rem;
}

.section-empty {
  color: var(--muted);
}

.selected-card {
  display: none;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
}

.primary-action {
  min-height: 2.375rem;
  padding: 0 0.9375rem;
  border: 0.0625rem solid rgba(94, 207, 139, 0.42);
  border-radius: 0.375rem;
  color: #102016;
  background: var(--green);
  cursor: pointer;
}

.secondary-action {
  min-height: 2.25rem;
  padding: 0 0.8125rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.secondary-action:hover,
.secondary-action:focus-visible {
  background: var(--surface-3);
  outline: 0.125rem solid rgba(101, 199, 216, 0.22);
  outline-offset: 0.125rem;
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-action.danger {
  color: var(--danger);
}

.primary-action:hover,
.primary-action:focus-visible {
  filter: brightness(1.06);
  outline: 0.125rem solid rgba(94, 207, 139, 0.35);
  outline-offset: 0.125rem;
}

.lesson-board {
  min-height: 0;
  flex: 1;
  padding: clamp(0.75rem, 3vw, 1.5rem);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.lesson-board p:last-child,
.muted {
  color: var(--muted);
}

.classroom-preview {
  min-height: 18rem;
  max-height: none;
  flex: 1;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.response-content {
  max-height: min(34rem, calc(100vh - 11rem));
  overflow: auto;
  display: grid;
  gap: 0.75rem;
}

.response-summary {
  color: var(--muted);
  font-size: 0.8125rem;
}

.response-table {
  display: grid;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
}

.response-row {
  display: grid;
  grid-template-columns: minmax(5rem, 0.9fr) minmax(5rem, 0.8fr) minmax(6rem, 1.4fr) minmax(7rem, 1fr);
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 0.0625rem solid var(--line);
  align-items: center;
  font-size: 0.8125rem;
}

.response-row:last-child {
  border-bottom: 0;
}

.response-row.is-head {
  color: var(--muted);
  background: var(--surface);
  font-weight: 700;
}

.response-content-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.classroom-outline-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.classroom-outline-list .classroom-outline-list {
  padding-left: 0.75rem;
}

.classroom-node,
.classroom-node-label {
  width: 100%;
  min-height: 2rem;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 0.3125rem;
  display: flex;
  align-items: center;
  color: var(--text);
  background: transparent;
  font-size: 0.8125rem;
  text-align: left;
}

.classroom-node {
  cursor: pointer;
}

.classroom-node:hover,
.classroom-node:focus-visible,
.classroom-node.is-selected {
  background: var(--surface-3);
  outline: none;
}

.classroom-preview {
  padding: 0;
}

.field-label {
  display: grid;
  gap: 0.375rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.field-label select {
  width: 100%;
  min-height: 2.25rem;
  padding: 0 0.625rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.switch-row {
  margin-top: 0.875rem;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
}

.switch-row input {
  width: 1.125rem;
  height: 1.125rem;
}

.status-list {
  margin: 1.125rem 0 0;
}

.status-list div {
  padding: 0.875rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1.125rem;
  border-bottom: 0.0625rem solid var(--line);
}

.status-list div:last-child {
  border-bottom: 0;
}

.status-list.compact div {
  padding: 0.625rem 0;
}

.status-list dt {
  color: var(--muted);
}

.status-list dd {
  margin: 0;
  text-align: right;
}

.status-list.classroom-status-strip {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  flex: 1;
  min-width: 14rem;
  max-width: 27rem;
}

.status-list.classroom-status-strip div {
  min-width: 0;
  min-height: 2.25rem;
  padding: 0.375rem 0.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.375rem;
  background: var(--surface-2);
}

.status-list.classroom-status-strip dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prep-explorer {
  position: relative;
  min-height: 0;
  padding: 0.5rem;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.loading-layer {
  position: absolute;
  inset: 0.5rem;
  z-index: 3;
  display: grid;
  place-content: center;
  gap: 0.625rem;
  border-radius: 0.4375rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}

.app-loading-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 120;
  width: min(24rem, calc(100vw - 2rem));
  padding: 0.75rem 0.875rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.625rem;
  align-items: center;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.app-loading-toast small {
  grid-column: 2;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.loader {
  width: 1.625rem;
  height: 1.625rem;
  justify-self: center;
  border: 0.1875rem solid color-mix(in srgb, var(--line) 72%, transparent);
  border-top-color: var(--green);
  border-radius: 62.44rem;
  animation: spin 780ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.tree-root {
  min-height: 100%;
}

.tree-placeholder {
  min-height: 5.75rem;
  padding: 0.75rem;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 0.0625rem dashed var(--line);
  border-radius: 0.5rem;
}

.tree-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-list .tree-list {
  padding-left: 1.125rem;
}

.tree-item {
  min-width: 13.75rem;
}

.tree-row {
  height: 2rem;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.3125rem;
  color: var(--text);
  cursor: default;
  user-select: none;
}

.tree-row:hover,
.tree-row.is-selected {
  background: var(--surface-3);
}

.tree-row.is-draggable {
  cursor: grab;
}

.tree-row.is-dragging {
  opacity: 0.46;
}

.tree-row.drop-before {
  box-shadow: inset 0 0.125rem 0 var(--green);
}

.tree-row.drop-after {
  box-shadow: inset 0 -0.125rem 0 var(--green);
}

.inline-edit-row {
  background: var(--surface-3);
}

.tree-toggle {
  width: 1rem;
  height: 1.375rem;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  text-align: center;
  cursor: pointer;
}

.tree-icon {
  width: 1.125rem;
  color: var(--amber);
  text-align: center;
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
}

.tree-publish-toggle {
  min-width: 2.625rem;
  height: 1.375rem;
  padding: 0 0.375rem;
  border: 0.0625rem solid var(--line);
  border-radius: 62.44rem;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.6875rem;
  line-height: 1;
}

.tree-publish-toggle.is-published {
  border-color: rgba(94, 207, 139, 0.42);
  color: var(--green);
  background: rgba(94, 207, 139, 0.12);
}

.tree-publish-toggle:hover,
.tree-publish-toggle:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.tree-inline-input {
  width: 100%;
  min-width: 5rem;
  height: 1.5rem;
  padding: 0 0.375rem;
  border: 0.0625rem solid var(--cyan);
  border-radius: 0.1875rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 0.875rem;
  outline: none;
}

.tree-type {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.tree-children.is-collapsed {
  display: none;
}

.tree-delete-confirm {
  margin: 0.125rem 0 0.375rem 2.625rem;
  padding: 0.4375rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.3125rem;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.75rem;
}

.tree-delete-confirm span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-delete-confirm button {
  min-height: 1.5rem;
  padding: 0 0.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.25rem;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}

.tree-delete-confirm button:hover,
.tree-delete-confirm button:focus-visible {
  background: var(--surface-3);
  outline: none;
}

.tree-delete-confirm .inline-danger {
  color: var(--danger);
}

.selected-card {
  min-height: 6rem;
  margin-top: 1.125rem;
  padding: 0.875rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.selected-empty {
  color: var(--muted);
}

.selected-type {
  margin-bottom: 0.5rem;
  color: var(--cyan);
  font-size: 0.8125rem;
}

.selected-name {
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
  font-size: 1.125rem;
  font-weight: 650;
}

.selected-path {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.context-menu {
  position: fixed;
  z-index: 80;
  min-width: 9.5rem;
  padding: 0.375rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.context-menu button {
  width: 100%;
  min-height: 2rem;
  padding: 0 0.625rem;
  border: 0;
  border-radius: 0.3125rem;
  display: flex;
  align-items: center;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background: var(--surface-3);
  outline: none;
}

.context-menu button.danger {
  color: var(--danger);
}

.device-table {
  width: 100%;
  overflow: hidden;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.device-groups {
  display: grid;
  gap: 1rem;
}

.device-group {
  display: grid;
  gap: 0.625rem;
  padding: 0.75rem;
  border: 0.0625rem solid transparent;
  border-radius: 0.5rem;
  cursor: pointer;
}

.device-group.is-selected {
  border-color: rgba(94, 207, 139, 0.45);
  background: rgba(94, 207, 139, 0.08);
}

.device-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.device-group-head h3 {
  margin: 0;
  font-size: 1rem;
}

.device-group-head span {
  color: var(--muted);
  font-size: 0.8125rem;
}

.table-row {
  min-height: 3.375rem;
  display: grid;
  grid-template-columns: minmax(7.5rem, 1.1fr) minmax(5.625rem, 0.7fr) minmax(9.375rem, 1.2fr);
  align-items: center;
  gap: 0.875rem;
  padding: 0 1.125rem;
  border-bottom: 0.0625rem solid var(--line);
}

.table-row:last-child {
  border-bottom: 0;
}

.table-head {
  min-height: 2.75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8125rem;
}

.device-table .table-row {
  grid-template-columns: minmax(5.5rem, 0.8fr) minmax(8rem, 1.1fr) minmax(4.25rem, 0.5fr) minmax(7rem, 1fr);
}

.device-status {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0 0.5rem;
  border-radius: 62.44rem;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.75rem;
}

.device-status.is-online {
  color: var(--green);
  background: rgba(94, 207, 139, 0.12);
}

.student-summary-button {
  min-width: 3.75rem;
  min-height: 1.75rem;
  padding: 0 0.5rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.student-summary-button[data-empty="false"] {
  border-color: rgba(94, 207, 139, 0.42);
  color: var(--green);
}

.class-group-tools {
  display: grid;
  gap: 0.875rem;
  margin-top: 1rem;
}

.class-group-tools label {
  display: grid;
  gap: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.class-group-tools input {
  min-height: 2.375rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  padding: 0 0.75rem;
  color: var(--text);
  background: var(--surface);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.student-search-results {
  display: grid;
  max-height: 22rem;
  overflow: auto;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.student-search-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 0.0625rem solid var(--line);
}

.student-search-row:last-child {
  border-bottom: 0;
}

.student-search-row span {
  display: grid;
  gap: 0.125rem;
}

.student-search-row small {
  color: var(--muted);
}

.student-search-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.8125rem;
}

.student-search-row.is-disabled {
  opacity: 0.68;
}

.student-detail-popover {
  position: fixed;
  top: 5rem;
  right: 2rem;
  z-index: 40;
  width: min(24rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.student-detail-head,
.student-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
}

.student-detail-head {
  margin-bottom: 0.75rem;
  color: var(--muted);
}

.student-detail-list {
  display: grid;
  gap: 0.5rem;
}

.student-detail-row {
  min-height: 2.5rem;
  padding: 0 0.625rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.375rem;
  background: var(--surface-2);
}

.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  background: rgba(15, 23, 42, 0.56);
}

.camera-dialog {
  width: min(68rem, 100%);
  max-height: calc(100vh - 2rem);
  display: grid;
  grid-template-rows: auto minmax(18rem, 1fr) auto;
  border: 0.0625rem solid rgba(255, 255, 255, 0.14);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.camera-head {
  min-height: 3rem;
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: var(--topbar);
}

.camera-head button {
  border: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
  font-size: 1.25rem;
}

.camera-body {
  min-height: 0;
  overflow: auto;
  padding: 0.85rem;
  background: var(--surface-3);
}

.camera-preview-panel {
  min-height: min(28rem, calc(100vh - 12rem));
  display: grid;
  place-items: center;
  background: #0f172a;
}

.camera-preview-panel video,
.camera-preview-panel canvas {
  width: 100%;
  max-height: min(34rem, calc(100vh - 12rem));
  object-fit: contain;
}

.camera-edit-panel {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(14rem, 0.78fr) minmax(24rem, 1.22fr);
  gap: 0.85rem;
}

.scan-source-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(12rem, 0.82fr) auto;
  gap: 0.75rem;
}

.scan-source-wrap,
.scan-result-wrap {
  min-width: 0;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border: 0.0625rem solid var(--line);
  border-radius: 0.45rem;
  background: #111827;
}

.scan-source-wrap {
  min-height: 0;
  align-self: start;
}

.scan-result-wrap {
  min-height: min(34rem, calc(100vh - 10rem));
}

.scan-source-wrap canvas,
.scan-result-wrap canvas {
  width: 100%;
  height: 100%;
  max-height: min(34rem, calc(100vh - 14rem));
  object-fit: contain;
}

.scan-corner {
  position: absolute;
  width: 1.35rem;
  height: 1.35rem;
  border: 0.16rem solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.3), 0 0.25rem 0.7rem rgba(15, 23, 42, 0.35);
  cursor: grab;
  transform: translate(-50%, -50%);
  touch-action: none;
}

.scan-corner:active {
  cursor: grabbing;
}

.scan-magnifier {
  position: absolute;
  z-index: 4;
  width: 7.5rem;
  height: 7.5rem;
  overflow: hidden;
  border: 0.18rem solid #fff;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.5rem 1.2rem rgba(15, 23, 42, 0.36);
  pointer-events: none;
}

.scan-magnifier canvas {
  width: 100%;
  height: 100%;
}

.camera-adjustments {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  border: 0.0625rem solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface-2);
}

.camera-adjustments label {
  min-width: 0;
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.camera-mirror-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.camera-mirror-actions .is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.camera-actions {
  padding: 0.75rem 0.9rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  border-top: 0.0625rem solid var(--line);
  background: var(--surface-2);
}

.mobile-photo-dialog {
  width: min(34rem, 100%);
  grid-template-rows: auto auto auto;
}

.mobile-photo-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
}

.mobile-photo-qr {
  width: 12rem;
  height: 12rem;
  display: grid;
  place-items: center;
  border: 0.0625rem solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
}

.mobile-photo-qr img {
  width: 11rem;
  height: 11rem;
}

.mobile-photo-info {
  min-width: 0;
  display: grid;
  gap: 0.5rem;
}

.mobile-photo-info p,
.mobile-photo-info a {
  margin: 0;
  overflow-wrap: anywhere;
}

.mobile-photo-info p {
  color: var(--muted);
}

@media (max-width: 51.25rem) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .class-group-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .class-group-nav {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .class-group-nav-head {
    padding: 0 0.75rem 0 0;
  }

  .classroom-session-controls {
    flex-wrap: wrap;
  }

  .prep-workbench {
    grid-template-columns: 1fr;
    grid-template-rows: clamp(9rem, 24vh, 12rem) minmax(0, 1fr);
  }

  .prep-workbench.is-tree-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: 2.75rem minmax(0, 1fr);
  }

  .prep-content-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(12rem, 1fr) minmax(13rem, 1fr);
  }

  .prep-workbench.is-components-collapsed .prep-content-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 2.75rem;
  }

  .prep-sidebar {
    min-height: 0;
    border-right: 0;
    border-bottom: 0.0625rem solid var(--line);
  }

  .prep-main {
    padding: 0.75rem;
  }

  .side-panel {
    align-self: stretch;
  }
}

@media (max-width: 35rem) {
  .topbar,
  .panel-title-row,
  .prep-editor-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-actions,
  .teacher-chip,
  .secondary-action,
  .primary-action {
    width: 100%;
  }

  .teacher-chip,
  .panel-actions,
  .secondary-action,
  .primary-action {
    justify-content: center;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .classroom-session-controls,
  .classroom-status-strip {
    width: 100%;
  }

  .classroom-status-strip {
    grid-template-columns: 1fr;
  }

  .table-row {
    grid-template-columns: 1fr;
    gap: 0.3125rem;
    padding: 0.8125rem 1rem;
  }

  .class-group-panel-tools,
  .class-group-management-row,
  .class-group-member-row,
  .member-list-head {
    grid-template-columns: 1fr;
  }

  .table-head {
    display: none;
  }
}

@media (max-width: 51.25rem) {
  .prep-workbench,
  .prep-workbench.is-tree-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .prep-content-layout,
  .prep-workbench.is-components-collapsed .prep-content-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .prep-sidebar {
    width: min(86vw, 22rem);
    border-right: 0.0625rem solid var(--line);
    border-bottom: 0;
  }

  .component-panel {
    width: min(86vw, 21rem);
  }

  .component-edit-actions {
    flex-direction: column-reverse;
  }
}
