:root {
  color-scheme: dark;
  font: 16px/1.5 system-ui, sans-serif;
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 32px;
  --s6: 48px;
  --s8: 64px;
  --canvas: #111219;
  --surface: #181a24;
  --surface-raised: #1d2030;
  --field: #12141e;
  --hover: #242738;
  --line: #383b4d;
  --ink: #f0eff7;
  --muted: #b0b3c5;
  --accent: #695bdb;
  --accent-hover: #594bc5;
  --accent-ink: #fff;
  --focus: #aca2ff;
  --published: #92dec8;
  --danger: #ffaaab;
  --danger-line: #79434f;
  --danger-fill: #b92740;
  --danger-active: #971b31;
  --danger-glow: rgb(185 39 64 / 35%);
  --shadow: rgb(4 5 10 / 24%);
  --motion: 160ms cubic-bezier(.2, .75, .3, 1);
  color: var(--ink);
  background: var(--canvas);
}

:root:not([data-theme=dark]) {
  color-scheme: light;
  --canvas: #f5f6fb;
  --surface: #fff;
  --surface-raised: #efedfa;
  --field: #fafaff;
  --hover: #e9e5fa;
  --line: #c4c5d5;
  --ink: #242439;
  --muted: #56566d;
  --accent: #5543b9;
  --accent-hover: #45339f;
  --focus: #5543b9;
  --published: #226754;
  --danger: #942638;
  --danger-line: #d997a5;
  --shadow: rgb(46 34 92 / 9%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; --layout-width: 1120px; }
body:has(main.narrow) { --layout-width: 768px; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner, main {
  width: min(var(--layout-width), calc(100% - var(--s6)));
  margin-inline: auto;
}
.top-inner {
  min-height: var(--s8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}
.top-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s1);
}
.top-controls label {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-size: .875rem;
}
.top-controls select { width: auto; }
.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-weight: 720;
}
.mark {
  display: block;
  width: var(--s4);
  height: var(--s4);
  flex: none;
}
.brand-name { font-weight: 780; letter-spacing: .12em; }
main { padding-block: var(--s6) var(--s8); }
h1, h2, h3, p { margin: 0 0 var(--s1); overflow-wrap: anywhere; }
h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -.04em;
}
h2 { font-size: 1.375rem; letter-spacing: -.02em; }
:root:not(.student) main :is(h1, h2) { text-transform: uppercase; letter-spacing: .01em; }
h3 { font-size: 1.125rem; }
p { white-space: pre-wrap; }
.muted { color: var(--muted); }
.hero, .panel, .library {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--s2);
  min-width: 0;
  box-shadow: 0 var(--s1) var(--s3) var(--shadow);
}
.hero {
  padding: var(--s4);
  margin-block-end: var(--s3);
  background: linear-gradient(135deg, var(--surface-raised), var(--surface) 72%);
}
.panel { padding: var(--s3); margin-block: var(--s4); }
.task-heading { margin-block-end: var(--s3); }
.task-heading h3 { margin: 0; font-size: 1.5rem; line-height: 1.3; }
.task-fields, .choice-section, .choice-prompt, .choice-group { display: grid; }
.task-fields { gap: var(--s3); }
.choice-prompt, .choice-group { gap: var(--s2); }
.choice-section { gap: var(--s1); }
.choice-section h4 { margin: 0; font-size: 1rem; }
.folder-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(448px, calc(100% - var(--s4)));
  max-height: calc(100% - var(--s4));
  overflow: auto;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--s2);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 var(--s3) var(--s8) var(--shadow);
}
.folder-dialog::backdrop { background: rgb(12 13 22 / 55%); }
.folder-dialog h2 { margin: 0; }
.dialog-actions { justify-content: flex-end; }
.accepted-answer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s2);
  align-items: end;
}
.choice-group {
  padding: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--s2);
  background: var(--field);
}
.choice-option {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s2);
  padding: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--s1);
  background: var(--surface);
}
.choice-radio {
  display: flex;
  align-items: center;
  min-height: var(--s6);
  gap: var(--s1);
  cursor: pointer;
  font-size: .875rem;
}
.choice-option:has(:checked) {
  color: #a7f3cf;
  background: #19392f;
  border-color: #3b8c6b;
}
.choice-option:has(:checked) :where(input:not([type=radio], [type=checkbox])) {
  background: #122e25;
  border-color: #3b8c6b;
  color: #d7fcec;
}
.choice-radio :is(input[type=radio], input[type=checkbox]) { accent-color: #75d6ac; }
:root:not([data-theme=dark]) .choice-option:has(:checked) {
  color: #15583f;
  background: #e2f5ea;
  border-color: #7bb799;
}
:root:not([data-theme=dark]) .choice-option:has(:checked) :where(input:not([type=radio], [type=checkbox])) {
  background: #f8fffb;
  color: #15583f;
}
.task-sentence {
  padding: var(--s2);
  margin-block: var(--s2);
  border-inline-start: 2px solid var(--accent);
  background: var(--surface-raised);
  border-radius: var(--s1);
  font-size: 1.125rem;
  font-weight: 600;
}
.answer-feedback {
  margin-block-start: var(--s2);
  padding: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--s1);
  background: var(--surface-raised);
}
.answer-feedback p { margin: var(--s1) 0 0; }
.lesson-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--s1);
  background: #111219;
  margin-block-end: var(--s1);
}
.file-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s1);
  list-style: none;
}
.file-list a { overflow-wrap: anywhere; }
.file-list:empty { display: none; }
.task-files { margin-block-start: var(--s2); }
.task-files > .stack { margin-block-start: var(--s1); }
.reading {
  display: grid;
  gap: var(--s2);
  margin-block-start: var(--s2);
  line-height: 1.65;
}
.reading :is(p, h3), .reading-help { margin: 0; }
.reading strong { color: var(--ink); font-weight: 750; }
.reading mark {
  color: #b6f3df;
  background: #19392f;
  padding-inline: var(--s1);
  border-radius: var(--s1);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.reading-rule, .reading-key {
  padding: var(--s2);
  border-inline-start: 2px solid var(--focus);
  border-radius: var(--s1);
  background: var(--surface-raised);
}
.reading-rule { display: grid; gap: var(--s1); }
.reading .reading-key { border-inline-start-color: #e7b565; color: #f8dca9; }
.reading-example { color: var(--muted); font-style: italic; }
.reading-bullet { display: flex; align-items: baseline; gap: var(--s1); }
.reading-bullet > :first-child { color: var(--focus); flex: none; }
.reading-help { font-size: .875rem; }
:root:not([data-theme=dark]) .reading mark { background: #d7eee3; color: #165440; }
:root:not([data-theme=dark]) .reading .reading-key { background: #fff4dc; color: #704316; }
.reading-formula { font-weight: 750; }
.word-picker { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 2; }
button.word-toggle {
  display: inline;
  min-height: var(--s4);
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: underline dotted var(--muted);
  text-underline-offset: .2em;
}
button.word-toggle:is([aria-pressed=true], :hover) { background: var(--hover); color: var(--focus); }
button.word-toggle[aria-pressed=true] { border-color: var(--focus); }
.match-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s6);
  align-items: start;
}
.match-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  color: var(--focus);
}
.match-lines [data-color="1"] { color: #278b78; }
.match-lines [data-color="2"] { color: #b16a32; }
.match-lines [data-color="3"] { color: #5479c3; }
.match-lines path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.match-lines circle { fill: currentColor; }
button.match-option { display: grid; gap: var(--s1); overflow-wrap: anywhere; }
.match-option[aria-pressed=true] { border-color: var(--focus); background: var(--hover); }
.match-option[data-linked=true]:disabled { opacity: 1; }
.match-option small { color: var(--muted); }
.hero > :last-child, .panel > :last-child { margin-block-end: 0; }
.library-heading { margin-block-end: var(--s3); }
.library-heading h1 { margin: 0; }
.library-tools {
  padding: var(--s2);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
  border-start-start-radius: inherit;
  border-start-end-radius: inherit;
}
.library-tools input { max-width: 384px; }
.material-list { list-style: none; padding: 0; margin: 0; }
.material-row, .material-empty { padding: var(--s2); }
.material-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s2);
  transition: background-color var(--motion);
}
.material-row:last-child { border-end-start-radius: inherit; border-end-end-radius: inherit; }
.material-list { border-radius: inherit; }
.material-row:focus-within { background: var(--surface-raised); }
.material-row + .material-row { border-top: 1px solid var(--line); }
.material-row > label { grid-column: 1 / -1; max-width: 384px; }
.material-info p { margin: 0; font-size: .875rem; }
.material-info h3 { margin: 0; }
.material-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.material-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-size: .875rem;
  color: var(--muted);
}
.material-status::before {
  content: '';
  border: 1px solid currentColor;
  border-radius: 50%;
  width: var(--s1);
  height: var(--s1);
}
.material-status.is-published { color: var(--published); }
.material-status.is-published::before { background: currentColor; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 288px), 1fr));
  gap: var(--s2);
}
.actions, .row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.row { justify-content: space-between; }
.spaced { margin-block: var(--s2); }
button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  min-height: var(--s6);
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  border-radius: var(--s1);
  padding: var(--s1) var(--s2);
  text-decoration: none;
  transition: background-color var(--motion), border-color var(--motion),
    color var(--motion), box-shadow var(--motion), transform var(--motion);
}
.action-icon {
  width: var(--s2);
  height: var(--s2);
  flex: none;
  margin-inline-end: var(--s1);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button.alt, .button.alt, button.danger {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
}
button.danger { color: var(--danger); border-color: var(--danger-line); }
button:not(:disabled):active, .button:active { transform: scale(.97); }
button.danger:not(:disabled):is(:hover, :focus-visible) {
  background: var(--danger-fill);
  border-color: var(--danger-fill);
  color: #fff;
  box-shadow: 0 0 var(--s2) var(--danger-glow);
}
button.danger:not(:disabled):active {
  background: var(--danger-active);
  border-color: var(--danger-active);
}
button.material-title {
  color: var(--ink);
  min-height: var(--s4);
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
}
@media (hover: hover) {
  button:not(:disabled):hover, .button:hover { background: var(--accent-hover); }
  button.alt:not(:disabled):hover, .button.alt:hover { background: var(--hover); border-color: var(--muted); }
  button.material-title:not(:disabled):hover {
    background: transparent;
    color: var(--focus);
    text-decoration: underline;
    text-underline-offset: .2em;
  }
  .material-row:hover { background: var(--surface-raised); }
}
button:disabled, fieldset:disabled { opacity: .64; cursor: default; }
a { color: var(--focus); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: var(--s1); }
label { display: grid; gap: var(--s1); font-weight: 600; min-width: 0; }
input, textarea, select {
  width: 100%;
  min-height: var(--s6);
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--s1);
  padding: var(--s1) var(--s2);
}
.select-control { position: relative; display: block; min-width: 0; }
.select-control select {
  appearance: none;
  padding-inline-end: calc(var(--s4) + var(--s1));
}
.select-control::after {
  content: '';
  position: absolute;
  inset-inline-end: var(--s2);
  top: 50%;
  width: var(--s1);
  height: var(--s1);
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
:is(input:not([type=radio], [type=checkbox]), textarea, select):focus {
  outline: none;
  border-color: var(--focus);
}
textarea { min-height: calc(2 * var(--s6)); resize: vertical; }
input:is([type=radio], [type=checkbox]) { width: var(--s2); min-height: var(--s2); margin: 0; accent-color: var(--accent); }
.radio {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--s6);
  padding: var(--s1) var(--s2);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--s1);
  margin-block: var(--s1);
  overflow-wrap: anywhere;
}
.radio:has(:checked) { background: var(--hover); border-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.stack { display: grid; gap: var(--s2); }
.tag {
  display: inline-block;
  background: var(--hover);
  color: var(--ink);
  border-radius: var(--s1);
  padding-inline: var(--s1);
  font-size: .875rem;
  font-weight: 650;
  margin-block-end: var(--s1);
}
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
details summary { cursor: pointer; font-weight: 650; min-height: var(--s4); overflow-wrap: anywhere; }
#notice {
  position: fixed;
  inset: auto var(--s2) var(--s2);
  margin: auto;
  width: fit-content;
  max-width: calc(100% - var(--s4));
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: var(--s1) var(--s2);
  border-radius: var(--s1);
  z-index: 2;
  pointer-events: none;
}
#notice:empty { display: none; }
@media (max-width: 560px) {
  .top-inner, main { width: calc(100% - var(--s4)); }
  main { padding-block-start: var(--s3); }
  .brand { font-size: .875rem; }
  .top-inner { flex-wrap: wrap; padding-block: var(--s1); }
  .match-grid { gap: var(--s4); }
  button.match-option { padding-inline: var(--s1); }
  .wide-mobile, .wide-mobile > *, .library-tools input { width: 100%; }
  .hero, .panel { padding: var(--s2); }
  .choice-option { grid-template-columns: 1fr; }
  .choice-option { gap: var(--s1); }
  .choice-radio { min-height: var(--s4); justify-self: start; }
  .accepted-answer { grid-template-columns: 1fr; gap: var(--s1); }
  .accepted-answer > button { justify-self: start; }
  .material-row { grid-template-columns: 1fr; gap: var(--s1); }
  .material-actions { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  button, .button, .material-row { transition: none; }
  button:not(:disabled):active, .button:active { transform: none; }
}

@media (forced-colors: active) {
  :is(input:not([type=radio], [type=checkbox]), textarea, select):focus { border-color: Highlight; }
}
