@font-face {
  font-family: Lato;
  src: url("fonts/Lato-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Lato;
  src: url("fonts/Lato-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f7f7f2;
  --surface: #fff;
  --ink: #18213d;
  --muted: #56617a;
  --violet: #6657e8;
  --lilac: #f2f0fd;
  --lime: #cbef43;
  --line: #e1e3ec;
  --error: #822840;
  --error-bg: #f9ebec;
  --radius: 16px;
  --content: 1060px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.52 Lato, system-ui, sans-serif;
}
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.55rem, 4vw, 2.15rem); line-height: 1.17; margin-bottom: 1.05rem; }
h2 { font-size: 1.15rem; line-height: 1.25; margin-bottom: .5rem; }
a { color: inherit; text-underline-offset: .18em; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}
.skip-link {
  position: absolute;
  inset: -100px auto auto 1rem;
  z-index: 2;
  padding: .5rem .8rem;
  background: var(--surface);
}
.skip-link:focus { top: .6rem; }
.muted, .meta, small { color: var(--muted); }
.meta { font-size: .875rem; }
.notice, .error-box {
  margin-bottom: 1rem;
  padding: .8rem 1rem;
  background: var(--lilac);
  border-radius: 10px;
}
.notice.error, .error-box { background: var(--error-bg); color: var(--error); }

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner, .page, .site-footer { width: min(100%, var(--content)); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }
.header-inner {
  min-height: 66px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-block: .65rem;
}
.brand { display: inline-flex; width: fit-content; gap: .46rem; align-items: flex-start; color: var(--ink); text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { line-height: 1.08; font-size: 1.08rem; letter-spacing: .075em; }
.brand small { color: var(--ink); font-size: .625rem; letter-spacing: .21em; line-height: 1.55; }
.brand-mark { color: var(--violet); line-height: 1; }
.header-label { justify-self: end; color: var(--muted); font-size: .875rem; text-align: right; }
.nav { display: flex; flex-wrap: wrap; gap: .2rem; }
.nav a {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: .5rem .73rem;
  border-radius: 9px;
  text-decoration: none;
  color: var(--muted);
}
.nav a[aria-current="page"] { background: var(--lilac); color: var(--ink); font-weight: 700; }
.nav a:hover { color: var(--ink); }
.page { flex: 1; padding-block: clamp(1.4rem, 4vw, 2.15rem) 3rem; }
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem 1rem;
  align-items: center;
  padding-block: .6rem 1rem;
  color: var(--muted);
  font-size: .875rem;
}
.site-footer a, .text-button { padding-block: .55rem; }
.text-button { background: none; border: 0; color: inherit; padding-inline: 0; text-decoration: underline; }
.back-link { display: inline-flex; color: var(--muted); padding: .35rem 0; margin-bottom: .55rem; }

.deadline { display: flex; gap: .3rem; align-items: baseline; flex-wrap: wrap; font-size: .904rem; font-weight: 700; }
.deadline::before { content: ""; align-self: center; width: 16px; height: 4px; border-radius: 4px; background: var(--lime); margin-right: .22rem; }
.deadline time { white-space: nowrap; }
.worksheet-grid, .teacher-grid { display: grid; gap: .9rem; align-items: stretch; }
.worksheet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1rem; }
.teacher-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: clamp(.95rem, 3vw, 1.3rem); }
.narrow { max-width: 720px; }
.section { margin-top: 1rem; }
.file-row {
  display: grid;
  width: 100%;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: center;
  min-height: 46px;
  padding: .54rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.file-row:last-child { border-bottom: 0; }
.file-row:hover { color: var(--violet); }
.file-row > small { font-size: .83rem; }
.file-row + .meta { margin-top: .25rem; }
.line-icon { width: 14px; height: 14px; position: relative; display: inline-block; color: var(--violet); }
.paper-icon { width: 11px; height: 14px; border: 1px solid currentColor; border-radius: 2px; }
.paper-icon::before { content: ""; position: absolute; inset: 5px 2px auto; height: 1px; background: currentColor; box-shadow: 0 3px 0 currentColor; }
.calendar-icon { border: 1px solid currentColor; border-radius: 2px; }
.calendar-icon::before { content: ""; position: absolute; inset: 3px 0 auto; border-top: 1px solid currentColor; }
.play-icon { border: 1px solid currentColor; border-radius: 50%; }
.play-icon::before { content: ""; position: absolute; inset: 3px auto auto 4px; border-left: 5px solid currentColor; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.instructions { margin-top: 1rem; overflow-wrap: anywhere; }
.instructions p + p { margin-top: .65rem; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 44px;
  gap: .35rem;
  padding: .52rem .87rem;
  border: 1px solid transparent;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 700;
}
.button.primary { background: var(--violet); color: var(--surface); }
.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button:hover { filter: brightness(.96); }
.full { width: 100%; }
.actions, .row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.row-actions, .top-actions, .page-heading .actions, .stack .actions { margin-top: 0; }
.top-actions { margin-bottom: .8rem; }
.page-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1rem; align-items: center; margin-bottom: 1rem; }
.page-heading h1 { margin: 0; }
.text-link { display: inline-block; margin-top: .55rem; color: var(--ink); }
.plain-list { margin: 0; padding: 0; list-style: none; }
.manage-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .65rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.manage-row:last-child { border-bottom: 0; padding-bottom: 0; }
.manage-row .row-title, .recipient-list { overflow-wrap: anywhere; }
.row-title { font-weight: 700; }
.recipient-list { margin: .5rem 0; padding-left: 1.3rem; }
.status { font-size: .83rem; color: var(--muted); padding: .25rem .45rem; border-radius: 6px; white-space: nowrap; }
.status-published { background: #f1f5d9; color: var(--ink); }
.credentials { margin: 0 0 1rem; overflow-wrap: anywhere; }
.credentials dd { margin: .15rem 0 .72rem; font-weight: 700; }
.credentials dt { color: var(--muted); font-size: .94rem; }

.auth-page { width: min(100%, 460px); margin: clamp(1.5rem, 8vh, 5.25rem) auto 1.5rem; padding-inline: 1rem; }
.auth-card { border-radius: var(--radius); border: 1px solid var(--line); padding: clamp(1rem, 5vw, 1.7rem); background: var(--surface); }
.auth-card .brand { margin-bottom: 1.2rem; }
.auth-card .auth-help { margin-top: 1rem; font-size: .94rem; }
.auth-card > p + form { margin-top: 1rem; }
.stack { display: grid; gap: .9rem; }
.field > label { display: block; margin-bottom: .3rem; font-weight: 700; }
.field input:not([type="checkbox"]), .field select, .field textarea, .filter select {
  min-width: 0; width: 100%; padding: .56rem .65rem;
  min-height: 44px; border: 1px solid #d2d6e2; border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.field textarea { display: block; resize: vertical; }
.field input[type="file"] { padding: .43rem; }
.field input[type="checkbox"] { width: 1.18rem; height: 1.18rem; margin-right: .45rem; accent-color: var(--violet); vertical-align: middle; }
.field label:has(input[type="checkbox"]) { display: flex; align-items: center; min-height: 39px; }
.help-text, .field-error { margin-top: .35rem; font-size: .875rem; color: var(--muted); }
.help-text ul, .errorlist { margin: .25rem 0; padding-left: 1.2rem; }
.field-error, .errorlist { color: var(--error); }
.filter { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filter label { color: var(--muted); font-size: .9rem; }
.filter select { width: auto; }
.video-shell { margin: 1rem 0 .25rem; }
.video-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: var(--ink); }
.card > .video-frame { margin-top: 1rem; }

.watch-topic { margin: -.55rem 0 1.2rem; color: var(--student-muted, var(--muted)); }
.watch-layout { display: grid; gap: 1rem; align-items: start; }
.watch-layout.with-resources { grid-template-columns: minmax(0, 1fr) minmax(15rem, .47fr); }
.watch-player { min-width: 0; }
.watch-player .video-shell { margin: 0 0 .6rem; }
.watch-player .video-shell:has([data-load-video]:not([hidden])) {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: linear-gradient(140deg, #382582, #5538bd);
  border-radius: 17px;
}
.watch-player .video-shell button { background: var(--student-lime, var(--lime)); color: #232339; }
.watch-player .video-shell button:focus-visible { outline-color: #fff; }
.watch-player .video-frame { border-radius: 17px; }
.watch-resources { display: grid; gap: .7rem; min-width: 0; }
.watch-resources h2 { font-size: 1.14rem; }
.watch-resources .study-panel {
  padding: 1rem 1.15rem;
  border: 1px solid var(--student-border, var(--line));
  border-radius: 19px;
  background: var(--surface);
}
.watch-resources .instructions { margin-top: 0; }
.watch-resources .practice-panel { background: #edf5e2; border-color: #e0ebd1; }
.watch-resources .practice-panel .button { border-color: #cbd9b8; }

.homework-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .55rem;
  margin-bottom: .55rem;
}
.homework-heading h2 { margin: 0; }
.homework-status {
  display: inline-block;
  border-radius: 99px;
  padding: .24rem .64rem;
  background: #eee7fa;
  color: #4b3688;
  font-size: .875rem;
  font-weight: 700;
}
.homework-status--reviewed { background: #e7f2db; color: #36551e; }
.homework-status--returned { background: #faebda; color: #74471d; }
.homework-files {
  margin: .35rem 0 0;
  padding: 0;
  list-style: none;
}
.homework-files li + li { border-top: 1px solid var(--line); }
.homework-row { min-height: 60px; }
.homework-row small { display: block; }
.homework-upload { margin-top: 1rem; max-width: 42rem; }
.homework-feedback {
  display: grid;
  gap: .7rem;
  margin-top: .95rem;
  padding: 1rem;
  border-radius: 13px;
  background: var(--student-lilac, var(--lilac));
}
.homework-feedback h3 { font-size: 1.05rem; }
.homework-grade { max-width: 27rem; }
.homework-grade-label, .homework-scale {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .7rem;
}
.homework-grade-label strong { font-size: 1.15rem; }
.homework-scale { color: var(--muted); font-size: .85rem; }
.homework-meter { display: block; width: 100%; height: .85rem; margin: .3rem 0; }
.homework-meter::-webkit-meter-bar {
  border: 0;
  border-radius: 10px;
  background: #dcd2f3;
}
.homework-meter::-webkit-meter-optimum-value { background: var(--student-violet, var(--violet)); }
.homework-meter::-moz-meter-bar { background: var(--student-violet, var(--violet)); }

@media (max-width: 66rem) {
  .watch-layout.with-resources { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 740px) {
  .teacher-header .header-inner { grid-template-columns: 1fr auto; column-gap: .45rem; row-gap: .25rem; }
  .teacher-header .nav { grid-row: 2; grid-column: 1 / -1; }
  .teacher-grid { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
  .header-inner { grid-template-columns: minmax(0, 1fr) auto; column-gap: .45rem; row-gap: .3rem; }
  .nav { grid-row: 2; grid-column: 1 / -1; }
  .nav a { min-height: 44px; }
  .header-label { max-width: 155px; }
  .worksheet-grid { grid-template-columns: 1fr; gap: .65rem; }
  .status { white-space: normal; }
  .file-row { gap: .45rem; }
  .filter label { width: 100%; }
}
