:root {
  color-scheme: light;
  --ink: #152033;
  --muted: #607083;
  --line: #cdd6e1;
  --line-strong: #9aaabe;
  --paper: #ffffff;
  --surface: #f4f7fb;
  --surface-deep: #e7edf5;
  --accent: #0f6fb5;
  --accent-dark: #0a548a;
  --good: #167243;
  --bad: #b3261e;
  --warning: #8a5a00;
  --shadow: 0 10px 24px rgba(21, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #fff;
  color: var(--ink);
  font-family:
    Arial,
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: default;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.exam-bar {
  min-height: 62px;
  padding: 10px clamp(18px, 4vw, 44px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  background: #172b45;
  border-bottom: 4px solid #0f6fb5;
}

.exam-bar h1,
.section-title h2,
.section-title h3 {
  margin: 0;
  letter-spacing: 0;
}

.exam-bar h1 {
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.72;
}

.timer-panel {
  min-width: 150px;
  padding: 8px 14px;
  display: grid;
  gap: 2px;
  text-align: right;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.timer-panel span {
  font-size: 12px;
  opacity: 0.82;
}

.timer-panel strong {
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

.mode-tabs {
  display: flex;
  gap: 0;
  padding: 0 clamp(18px, 4vw, 44px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 48px;
  padding: 0 22px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  font-weight: 700;
}

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main {
  flex: 1;
}

[hidden] {
  display: none !important;
}

.view {
  display: none;
}

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

#studentView {
  min-height: calc(100vh - 115px);
  grid-template-columns: minmax(300px, 360px) 1fr;
}

.sidebar {
  display: block;
  padding: 22px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  max-height: calc(100vh - 115px);
  overflow: auto;
}

.workspace {
  padding: 0 0 clamp(20px, 3vw, 36px);
  display: grid;
  align-content: start;
  gap: 0;
}

.question-strip {
  min-height: 58px;
  padding: 0 clamp(18px, 6vw, 76px);
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  align-items: center;
  gap: 12px;
  color: #fff;
  background: #0878b8;
}

.question-strip strong {
  justify-self: center;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  letter-spacing: 0;
}

.nav-btn {
  min-height: 34px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  font-weight: 700;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.exam-card {
  width: min(100%, 1180px);
  min-height: 560px;
  margin: 0 auto;
  padding: clamp(54px, 9vw, 132px) clamp(22px, 6vw, 78px) 38px;
  background: #fff;
}

.question-meta {
  margin: 0 0 42px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.dialogue-line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin-bottom: 22px;
}

.dialogue-line.sentence-line {
  align-items: center;
  margin-bottom: 56px;
}

.speaker {
  padding-top: 4px;
  color: #151515;
  font-size: 18px;
}

.sentence-frame {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 4px 0 8px;
  color: #151515;
  font-size: 19px;
  line-height: 1.6;
  white-space: nowrap;
}

.section-title {
  margin-bottom: 16px;
}

.section-title .eyebrow {
  color: var(--accent);
}

.section-title h2 {
  font-size: 24px;
}

.section-title h3 {
  font-size: 18px;
}

.section-title.compact {
  margin-bottom: 10px;
}

.student-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.student-identity {
  min-width: 0;
  padding: 4px 0;
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--accent-dark);
  text-align: right;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.student-identity span {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-identity small {
  color: var(--muted);
  font-size: 11px;
}

.exercise-list,
.saved-list {
  display: grid;
  gap: 10px;
}

.exercise-list {
  gap: 4px;
  cursor: default;
}

.phase-filter {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #405268;
  font-size: 12px;
  font-weight: 700;
}

.filter-header strong {
  color: var(--accent-dark);
  font-size: 12px;
}

.practice-nav {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.practice-breadcrumb {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.phase-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: #eef3f8;
  border: 1px solid #d6e0eb;
  border-radius: 8px;
}

.phase-switch--filter {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.phase-segment {
  min-width: 0;
  min-height: 44px;
  padding: 7px 8px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  color: #405268;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.phase-switch--form .phase-segment {
  min-height: 40px;
}

.phase-segment:hover {
  color: var(--accent-dark);
  background: #fff;
  border-color: #ccd9e6;
}

.phase-segment:active {
  transform: translateY(1px);
}

.phase-segment:focus-visible {
  outline: 3px solid rgba(15, 111, 181, 0.22);
  outline-offset: 2px;
}

.phase-segment-code {
  font-size: 14px;
}

.phase-segment-meta {
  max-width: 100%;
  overflow: hidden;
  color: #718296;
  font-size: 11px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-segment.is-active {
  color: #fff;
  background: #172b45;
  border-color: #172b45;
}

.phase-segment.is-active .phase-segment-meta {
  color: rgba(255, 255, 255, 0.78);
}

.practice-group {
  display: grid;
  gap: 7px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.practice-group h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.practice-option {
  min-height: 36px;
  padding: 7px 10px;
  color: var(--muted);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.practice-option.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.back-link {
  justify-self: start;
  min-height: 30px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 700;
}

.nav-note {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.practice-filter-row {
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.practice-listbox {
  position: relative;
  width: 112px;
  display: block;
  flex: 0 0 auto;
  cursor: default;
}

.practice-listbox--minor {
  width: 158px;
}

.practice-listbox--status {
  width: 126px;
}

.practice-listbox-trigger {
  width: 100%;
  min-height: 36px;
  padding: 0 11px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 12px;
  align-items: center;
  gap: 8px;
  color: #405268;
  background: #fff;
  border: 1px solid #cad6e2;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(21, 32, 51, 0.03);
  cursor: default;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.practice-listbox-prefix {
  padding-right: 8px;
  color: #8a99a9;
  border-right: 1px solid #dce4ec;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.practice-listbox-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-listbox-chevron {
  width: 7px;
  height: 7px;
  justify-self: end;
  border-right: 2px solid #718296;
  border-bottom: 2px solid #718296;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.18s ease;
}

.practice-listbox-trigger:hover {
  background: #f8fbfe;
  border-color: #9fb4c9;
}

.practice-listbox-trigger:focus-visible {
  outline: 3px solid rgba(15, 111, 181, 0.18);
  outline-offset: 2px;
  border-color: var(--accent);
}

.practice-listbox-trigger:active {
  transform: translateY(1px);
}

.practice-listbox.is-open .practice-listbox-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 181, 0.12);
}

.practice-listbox.is-open .practice-listbox-chevron {
  transform: translateY(2px) rotate(225deg);
}

.practice-listbox-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 12;
  width: max(100%, 176px);
  max-height: min(320px, calc(100vh - 170px));
  overflow-y: auto;
  padding: 5px;
  background: #fff;
  border: 1px solid #c7d3df;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(21, 32, 51, 0.14);
  animation: practice-listbox-in 0.16s ease both;
}

.practice-listbox--status .practice-listbox-menu {
  right: 0;
  left: auto;
  width: max(100%, 140px);
}

.practice-listbox-option {
  min-height: 34px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #405268;
  border-radius: 4px;
  cursor: default;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  outline: 0;
}

.practice-listbox-option:hover,
.practice-listbox-option:focus-visible {
  color: var(--accent-dark);
  background: #eef5fb;
}

.practice-listbox-option.is-selected {
  color: var(--accent-dark);
  background: #e7f1f9;
}

.practice-listbox-check {
  width: 14px;
  height: 14px;
  position: relative;
  flex: 0 0 14px;
}

.practice-listbox-option.is-selected .practice-listbox-check::after {
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  content: "";
  transform: rotate(45deg);
}

@keyframes practice-listbox-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.list-status {
  margin: 8px 0 0;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  cursor: default;
}

.exercise-section {
  display: grid;
  gap: 8px;
}

.exercise-section + .exercise-section {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.exercise-section h3 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1.35;
}

.exercise-card,
.saved-card {
  width: 100%;
  padding: 14px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.exercise-card {
  min-height: 40px;
  padding: 8px 10px;
}

.exercise-card:hover,
.exercise-card.is-active {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.exercise-card strong,
.saved-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}

.exercise-card strong {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.35;
}

.exercise-card .question-title-row,
.saved-card .question-title-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.exercise-card .question-title-row {
  align-items: center;
}

.question-title-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-minor {
  flex: 0 0 auto;
  margin-left: auto;
  color: #9aa6b2;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.practice-result {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-grid;
  place-items: center;
  position: relative;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.practice-result svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.practice-result.is-correct {
  color: #2f855a;
  background: #f0faf4;
}

.practice-result.is-incorrect {
  color: #c0564a;
  background: #fff5f3;
}

.practice-result-tooltip {
  position: absolute;
  right: -5px;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  color: #fff;
  background: #26384d;
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(38, 56, 77, 0.16);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  visibility: hidden;
  white-space: nowrap;
  z-index: 4;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    visibility 0.16s ease;
}

.practice-result-tooltip::after {
  position: absolute;
  top: 100%;
  right: 9px;
  width: 0;
  height: 0;
  content: "";
  border: 4px solid transparent;
  border-top-color: #26384d;
}

.practice-result:hover .practice-result-tooltip {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.exercise-card p,
.saved-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.prompt-block,
.answer-panel,
.word-panel,
.teacher-form,
.teacher-list,
.teacher-settings {
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.prompt-block {
  display: grid;
  gap: 12px;
}

.prompt-text {
  margin: 0;
  color: #151515;
  font-size: 18px;
  line-height: 1.55;
  white-space: pre-wrap;
}

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

.tool-row.right {
  justify-content: flex-end;
}

.action,
.file-action,
.icon-action {
  min-height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-weight: 700;
}

.action.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

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

.icon-action {
  width: 44px;
  padding: 0;
}

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

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: default;
}

.drop-zone {
  min-height: 94px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px;
  border: 1px dashed var(--line-strong);
  background: var(--surface);
}

.answer-zone {
  min-height: 132px;
}

.drop-zone.is-over {
  border-color: var(--accent);
  background: #eaf5ff;
}

.word-token {
  min-height: 38px;
  padding: 5px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
}

.word-bank {
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding-left: 34px;
  border-radius: 6px;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.word-bank.is-over {
  background: #eef7ff;
  box-shadow: inset 0 0 0 1px #b9dbf3;
}

.blank-slot {
  min-width: 0;
  max-width: none;
  min-height: 42px;
  margin: 0 2px;
  padding: 4px 6px;
  flex: 1 1 auto;
  overflow: hidden;
  vertical-align: middle;
  color: #151515;
  background: #fff;
  border: 1px solid #c9d0d8;
  border-radius: 5px;
  box-shadow: inset 0 1px 2px rgba(21, 32, 51, 0.08);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blank-slot.is-filled {
  background: #f8fafc;
  cursor: grab;
}

.blank-slot.is-over {
  border-color: var(--accent);
  background: #eaf5ff;
}

.blank-slot.is-correct {
  color: #0f5132;
  background: #ecf7f1;
  border-color: #62b884;
  box-shadow:
    inset 0 1px 2px rgba(21, 32, 51, 0.06),
    0 0 0 2px rgba(22, 114, 67, 0.08);
}

.blank-slot.is-incorrect {
  color: #842029;
  background: #fff1f1;
  border-color: #d07171;
  box-shadow:
    inset 0 1px 2px rgba(21, 32, 51, 0.06),
    0 0 0 2px rgba(179, 38, 30, 0.08);
}

.word-token:focus {
  outline: 3px solid rgba(15, 111, 181, 0.25);
  outline-offset: 2px;
}

.word-token.is-dragging,
.blank-slot.is-dragging {
  opacity: 0.45;
}

.word-token.hint {
  color: var(--accent-dark);
  background: #edf7ff;
}

.feedback {
  min-height: 24px;
  margin: 18px 0 0 34px;
  font-weight: 700;
  line-height: 1.5;
}

.exam-actions {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 0 clamp(22px, 6vw, 78px);
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.feedback.warn {
  color: var(--warning);
}

#teacherView {
  padding: clamp(20px, 3vw, 36px);
  grid-template-columns: minmax(360px, 480px) minmax(340px, 1fr) minmax(220px, 260px);
  gap: 18px;
  align-items: start;
}

.teacher-settings {
  position: sticky;
  top: 18px;
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #26374a;
  font-size: 14px;
  font-weight: 700;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: #26374a;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  line-height: 1.45;
}

select {
  appearance: none;
  padding-right: 38px;
  font-weight: 700;
}

textarea {
  resize: vertical;
}

.title-row {
  display: grid;
  grid-template-columns: minmax(190px, 238px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.type-field {
  min-width: 0;
}

.select-shell {
  position: relative;
  display: block;
}

.select-shell::after {
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #405268;
  border-bottom: 2px solid #405268;
  content: "";
  pointer-events: none;
  transform: translateY(-65%) rotate(45deg);
}

.select-shell select {
  background: #f8fbfe;
  border-color: #d6e0eb;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.select-shell select:hover {
  background: #fff;
  border-color: #c7d5e4;
}

.select-shell select:focus {
  outline: 3px solid rgba(15, 111, 181, 0.22);
  outline-offset: 2px;
}

.select-shell select:active {
  transform: translateY(1px);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 14px;
}

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

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
}

.settings-form {
  gap: 0;
}

.setting-row {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.settings-form .action {
  width: 100%;
  margin-top: 18px;
}

.settings-feedback {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.settings-feedback.is-error {
  color: var(--bad);
}

.settings-feedback.is-success {
  color: var(--good);
}

.toggle-control {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: #b7c1cc;
  border-radius: 13px;
  cursor: default;
  transition: background 0.18s ease;
}

.toggle-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(21, 32, 51, 0.3);
  content: "";
  transition: transform 0.18s ease;
}

.toggle-control input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(20px);
}

.toggle-control input:focus-visible + .toggle-track {
  outline: 3px solid rgba(15, 111, 181, 0.22);
  outline-offset: 2px;
}

#knowledgePointBlock {
  transition: opacity 0.18s ease;
}

#knowledgePointBlock.is-disabled {
  opacity: 0.48;
}

#knowledgePointBlock.is-disabled .knowledge-options {
  pointer-events: none;
}

.knowledge-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  background: #f1f5f9;
  border: 1px solid #d8e1ec;
  border-radius: 8px;
}

.knowledge-option {
  position: relative;
  min-height: 46px;
  padding: 9px 11px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  color: #405268;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1.25;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.knowledge-option:hover {
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border-color: #c9d6e3;
}

.knowledge-option:active {
  transform: translateY(1px);
}

.knowledge-option:focus-visible {
  outline: 3px solid rgba(15, 111, 181, 0.22);
  outline-offset: 2px;
}

.knowledge-option.is-active {
  color: #fff;
  background: #172b45;
  border-color: #172b45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.knowledge-option-index {
  min-width: 30px;
  color: #728198;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.knowledge-option-text {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-option.is-active .knowledge-option-index {
  color: rgba(255, 255, 255, 0.66);
}

.saved-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

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

.small-btn {
  min-height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
}

.empty-state {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: default;
  line-height: 1.5;
}

.modal-layer {
  position: fixed;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(21, 32, 51, 0.42);
}

.modal-panel {
  width: min(100%, 420px);
  padding: 22px;
  background: #fff;
  border: 1px solid rgba(205, 214, 225, 0.9);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(21, 32, 51, 0.24);
}

.modal-header {
  margin-bottom: 18px;
}

.modal-header .eyebrow {
  color: var(--accent);
}

.modal-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  letter-spacing: 0;
}

.version-panel {
  width: min(100%, 460px);
}

.version-copy {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.passcode-form {
  gap: 12px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--bad);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}

@media (max-width: 1180px) {
  #teacherView {
    grid-template-columns: minmax(340px, 480px) minmax(340px, 1fr);
  }

  .teacher-settings {
    position: static;
    grid-column: 1 / -1;
  }
}

@media (max-width: 1023px) {
  #studentView {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  #studentView .sidebar {
    position: relative;
    z-index: 2;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
    overflow: visible;
  }

  #studentView .workspace {
    position: relative;
    z-index: 1;
  }

  #studentView .exercise-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 860px) {
  .exam-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .timer-panel {
    width: 100%;
    text-align: left;
  }

  #studentView,
  #teacherView {
    grid-template-columns: 1fr;
  }

  #studentView {
    min-height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .exercise-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

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

  .tab {
    flex: 1;
    padding: 0 10px;
  }

  .sidebar,
  .workspace,
  #teacherView {
    width: 100%;
    min-width: 0;
    padding: 14px;
  }

  .question-strip {
    padding: 0;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
  }

  .question-strip .nav-btn {
    min-width: 0;
    padding: 0 8px;
  }

  .prompt-block,
  .answer-panel,
  .word-panel,
  .teacher-form,
  .teacher-list,
  .teacher-settings {
    padding: 16px;
  }

  .form-grid,
  .title-row,
  .taxonomy-grid,
  .saved-card,
  .knowledge-options {
    grid-template-columns: 1fr;
  }

  .phase-switch--filter {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-note {
    align-items: stretch;
    flex-direction: column;
  }

  .practice-listbox {
    width: 100%;
  }

  .practice-filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .practice-filter-row .practice-listbox:only-child {
    grid-column: 1 / -1;
  }

  .tool-row.right {
    justify-content: stretch;
  }

  .tool-row.right .action {
    flex: 1;
  }
}
