:root {
  color-scheme: light;
  --ink: #151a24;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --surface-soft: #f6f9fc;
  --blue: #1769e0;
  --blue-dark: #0d4faa;
  --blue-soft: #eaf2ff;
  --red: #df3d32;
  --yellow: #f4c84a;
  --green: #2f8f68;
  --danger: #c9362b;
  --shadow: 0 18px 48px rgb(20 33 61 / 12%);
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--surface-soft);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

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

:focus-visible {
  outline: 3px solid rgb(23 105 224 / 30%);
  outline-offset: 2px;
}

.auth-page {
  overflow-x: hidden;
  background: #f7fbff;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 61fr) minmax(480px, 39fr);
  min-height: 100svh;
}

.schoolyard-art {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background-color: #78c8f7;
  background-image: url("assets/schoolyard-shinchan.png");
  background-position: center 52%;
  background-size: cover;
}

.art-caption {
  position: absolute;
  z-index: 1;
  right: 36px;
  bottom: 28px;
  left: 36px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 4px rgb(10 40 64 / 55%);
}

.art-caption p {
  margin: 0;
}

.art-caption__line {
  width: 42px;
  height: 3px;
  border-radius: 2px;
  background: var(--yellow);
}

.auth-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: clamp(40px, 6vw, 92px);
  border-left: 1px solid #d8e0eb;
  background: #f9fcff;
}

.auth-panel__inner {
  width: min(100%, 470px);
}

.language-switcher {
  position: absolute;
  z-index: 2;
  top: 28px;
  right: clamp(24px, 3vw, 48px);
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 2px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: var(--muted);
  background: rgb(255 255 255 / 92%);
}

.language-switcher button {
  min-height: 30px;
  padding: 0 5px;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.language-switcher button:hover {
  color: var(--blue-dark);
}

.language-switcher button.is-active {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.language-switcher span {
  color: #a4adba;
  user-select: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--blue);
  background: var(--yellow);
  box-shadow: 4px 4px 0 var(--ink);
}

.brand__mark svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.4;
}

.auth-heading {
  margin: clamp(62px, 8vh, 94px) 0 44px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.auth-heading h1 {
  margin: 0;
  font-size: clamp(38px, 4vw, 52px);
  line-height: 1.13;
}

.auth-heading > p:last-child {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.auth-form {
  display: grid;
  gap: 24px;
}

.field {
  display: grid;
  gap: 9px;
}

.field label {
  font-size: 15px;
  font-weight: 700;
}

.field-control {
  position: relative;
}

.field-control > svg {
  position: absolute;
  top: 50%;
  left: 18px;
  width: 20px;
  height: 20px;
  color: #7b8494;
  transform: translateY(-50%);
  pointer-events: none;
}

.field-control input,
.field-control select,
.plain-input,
.plain-select {
  width: 100%;
  height: 60px;
  border: 1px solid #bbc5d2;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-control input {
  padding: 0 54px;
}

.field-control input:focus,
.field-control select:focus,
.plain-input:focus,
.plain-select:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 4px rgb(23 105 224 / 12%);
}

.field-control input::placeholder,
.plain-input::placeholder {
  color: #9ba4b3;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  background: #edf2f7;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
}

.form-options {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  cursor: pointer;
}

.checkbox input {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--blue);
}

.text-button {
  padding: 3px 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

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

.primary-button:hover:not(:disabled) {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid #aeb9c8;
  color: var(--ink);
  background: #ffffff;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--ink);
  background: #f7f9fc;
}

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

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-message {
  min-height: 23px;
  margin: -8px 0 -8px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 650;
}

.form-message:empty {
  min-height: 0;
}

.form-message.is-success {
  color: var(--green);
}

.auth-footnote {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 64px;
  color: #737d8c;
  font-size: 14px;
}

.auth-footnote svg {
  width: 19px;
  height: 19px;
  color: var(--green);
}

.dialog {
  width: min(calc(100% - 32px), 430px);
  padding: 34px;
  border: 1px solid #cbd3de;
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgb(11 22 39 / 50%);
}

.dialog__close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.dialog__icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 22px;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
}

.dialog__icon svg {
  width: 26px;
  height: 26px;
}

.dialog h2 {
  margin: 0 0 10px;
  font-size: 23px;
}

.dialog p {
  margin: 0;
  color: var(--muted);
}

.dialog__confirm {
  width: 100%;
  margin-top: 28px;
}

/* Application shell */
.app-page {
  overflow-x: hidden;
  background: #f4f7fb;
}

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.app-header .brand {
  font-size: 18px;
}

.app-header .brand__mark {
  width: 38px;
  height: 38px;
  box-shadow: 3px 3px 0 var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--red);
  font-size: 15px;
  font-weight: 800;
}

.account-avatar-button {
  padding: 0;
  border: 0;
  cursor: pointer;
  font: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.account-avatar-button:hover,
.account-avatar-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgb(25 103 210 / 22%);
}

.account-menu-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  min-width: 188px;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgb(16 35 61 / 16%);
}

.account-menu-panel strong,
.account-menu-panel > span {
  display: block;
  padding: 0 4px;
}

.account-menu-panel strong {
  color: var(--ink);
  font-size: 14px;
}

.account-menu-panel > span {
  color: var(--muted);
  font-size: 12px;
}

.account-menu-action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 8px;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.account-menu-action:hover,
.account-menu-action:focus-visible {
  color: var(--blue);
  background: #f4f7fb;
}

.account-menu-action svg {
  width: 16px;
  height: 16px;
}

.account-chip strong,
.account-chip span {
  display: block;
}

.account-chip strong {
  font-size: 14px;
}

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

.logout-button {
  color: var(--muted);
}

.page-container {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 46px 0 72px;
}

.page-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.page-title-row h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.18;
}

.page-title-row p {
  margin: 8px 0 0;
  color: var(--muted);
}

.section-title {
  margin: 0 0 18px;
  font-size: 20px;
}

.hero-band {
  position: relative;
  display: grid;
  min-height: 320px;
  overflow: hidden;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 42%);
  border: 1px solid #c7d7ea;
  border-radius: 8px;
  background: #ffffff;
}

.hero-band__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 5vw, 64px);
}

.hero-band__copy h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(31px, 5vw, 52px);
  line-height: 1.12;
}

.hero-band__copy p {
  max-width: 580px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-band__art {
  min-height: 320px;
  background-image: url("assets/schoolyard-shinchan.png");
  background-position: center 58%;
  background-size: cover;
}

.info-strip {
  display: grid;
  margin-top: 34px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.info-item {
  min-width: 0;
  padding: 24px;
}

.info-item + .info-item {
  border-left: 1px solid var(--line);
}

.info-item span,
.info-item strong {
  display: block;
}

.info-item span {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.info-item strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

/* Admin */
.admin-layout {
  display: grid;
  min-height: calc(100svh - 72px);
  grid-template-columns: 232px minmax(0, 1fr);
}

.admin-sidebar {
  padding: 30px 18px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.sidebar-label {
  margin: 0 12px 12px;
  color: #8a94a3;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
}

.sidebar-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 6px;
  color: #556070;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-link svg {
  width: 19px;
  height: 19px;
}

.sidebar-link.is-active {
  color: #0f55b8;
  background: var(--blue-soft);
}

.admin-main {
  min-width: 0;
  padding: 40px clamp(20px, 4vw, 52px) 72px;
}

.admin-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.admin-topline h1 {
  margin: 0;
  font-size: 32px;
}

.admin-topline p {
  margin: 6px 0 0;
  color: var(--muted);
}

.admin-topline .primary-button svg {
  width: 18px;
  height: 18px;
}

.topline-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.topline-actions .primary-button,
.topline-actions .secondary-button {
  min-height: 44px;
}

.stats-row {
  display: grid;
  margin-bottom: 28px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.app-page[data-management-mode="teacher"] .stats-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat {
  min-width: 0;
  padding: 22px;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.stat + .stat {
  border-left: 1px solid var(--line);
}

.stat:hover {
  background: #f7faff;
}

.stat:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgb(34 102 204 / 24%);
  outline-offset: -3px;
}

.stat.is-active {
  background: var(--blue-soft);
  box-shadow: inset 0 -3px 0 var(--blue);
}

.stat__label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat__label svg {
  width: 17px;
  height: 17px;
}

.stat strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.table-section,
.audit-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.search-control {
  position: relative;
  flex: 1 1 300px;
  max-width: 380px;
}

.search-control svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-control input {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 41px;
  border: 1px solid #c2cad5;
  border-radius: 6px;
}

.filter-group {
  display: flex;
  gap: 10px;
}

.plain-select {
  width: auto;
  min-width: 120px;
  height: 42px;
  padding: 0 34px 0 12px;
}

.table-scroll {
  overflow-x: auto;
}

.bulk-toolbar {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 18px;
  border-bottom: 1px solid #b9cff0;
  color: #123f7a;
  background: #edf5ff;
}

.bulk-toolbar[hidden] {
  display: none;
}

.bulk-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-toolbar .plain-select {
  height: 34px;
  font-size: 12px;
}

.user-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

.user-table .select-column {
  width: 48px;
  padding-right: 6px;
  text-align: center;
}

.user-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
  cursor: pointer;
}

.user-table th,
.user-table td {
  padding: 15px 18px;
  border-bottom: 1px solid #e7ebf0;
  text-align: left;
  vertical-align: middle;
}

.user-table th {
  color: var(--muted);
  background: #f9fafc;
  font-size: 12px;
  font-weight: 800;
}

.user-table td {
  font-size: 14px;
}

.muted-cell {
  color: var(--muted);
}

.user-table tbody tr:last-child td {
  border-bottom: 0;
}

.user-identity {
  display: flex;
  min-width: 190px;
  align-items: center;
  gap: 11px;
}

.user-identity .avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  font-size: 13px;
}

.user-identity strong,
.user-identity span {
  display: block;
}

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

.role-badge,
.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.role-badge {
  color: #274f83;
  background: #eaf2ff;
}

.status-badge.is-active {
  color: #17633f;
  background: #e4f6ed;
}

.status-badge.is-inactive {
  color: #8b302a;
  background: #fce8e6;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.table-actions .icon-button {
  color: #596579;
}

.table-actions .icon-button:hover {
  color: var(--blue);
}

.small-action {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #c3cbd6;
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.small-action:hover {
  border-color: var(--ink);
}

.small-action.is-danger {
  border-color: #e3aaa5;
  color: #9a2922;
}

.small-action.is-danger:hover {
  border-color: #b63b32;
  background: #fff5f4;
}

.empty-state {
  padding: 54px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
}

.audit-section {
  margin-top: 28px;
  padding: 24px;
}

.audit-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  border-top: 1px solid #edf0f4;
  font-size: 14px;
}

.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

.audit-item time {
  color: var(--muted);
  font-size: 12px;
}

.dialog-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.dialog-form .plain-input,
.dialog-form .plain-select {
  height: 48px;
  padding: 0 13px;
}

.dialog-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.dialog-form__actions .primary-button,
.dialog-form__actions .secondary-button {
  min-height: 44px;
}

.credential-box {
  margin: 24px 0 8px;
  padding: 18px;
  border: 1px dashed #90a0b5;
  border-radius: 7px;
  background: #f7f9fc;
}

.credential-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.credential-row + .credential-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #dfe5ec;
}

.credential-row span {
  color: var(--muted);
  font-size: 13px;
}

.credential-row code {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 750;
}

.student-qr-dialog {
  width: min(calc(100% - 32px), 480px);
}

.student-qr-preview {
  display: grid;
  margin: 22px 0 6px;
  place-items: center;
}

.student-qr-preview img {
  display: block;
  width: min(100%, 252px);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid #d7dde6;
  background: #ffffff;
}

.student-qr-account {
  margin-top: 18px;
}

.student-qr-account strong {
  text-align: right;
}

.student-qr-link {
  margin-top: 16px;
}

.student-qr-link label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.student-qr-link__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.student-qr-link input,
.student-qr-link textarea {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid #cdd6e2;
  border-radius: 6px;
  outline: none;
  background: #f7f9fc;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-all;
  resize: vertical;
}

.student-qr-link input:focus,
.student-qr-link textarea:focus {
  border-color: #3671c9;
  box-shadow: 0 0 0 3px rgb(54 113 201 / 14%);
}

.student-qr-link .secondary-button {
  min-height: 44px;
  padding: 0 14px;
  white-space: nowrap;
}

.student-qr-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.student-qr-actions .primary-button,
.student-qr-actions .secondary-button {
  min-height: 46px;
  padding: 0 14px;
  text-decoration: none;
}

.student-qr-actions svg {
  width: 18px;
  height: 18px;
}

.qr-error-page {
  display: grid;
  min-height: 100vh;
  padding: 32px;
  place-items: center;
}

.qr-error-panel {
  width: min(100%, 430px);
  text-align: center;
}

.qr-error-panel .dialog__icon {
  margin-right: auto;
  margin-left: auto;
}

.qr-error-panel h1 {
  margin: 0 0 12px;
  font-size: 28px;
}

.qr-error-panel p {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.7;
}

.qr-error-panel .primary-button {
  text-decoration: none;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  padding: 13px 16px;
  border: 1px solid #bfc8d4;
  border-radius: 7px;
  color: #ffffff;
  background: #202938;
  box-shadow: var(--shadow);
  font-size: 14px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

/* Student profile */
.profile-avatar-link {
  display: inline-flex;
  border-radius: 50%;
  text-decoration: none;
}

.profile-avatar-link:not(.is-static):focus-visible {
  outline: 3px solid rgb(34 102 204 / 26%);
  outline-offset: 3px;
}

.profile-avatar-link:not(.is-static):hover .avatar {
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.avatar.has-image,
.avatar.has-preset {
  background-color: #ffffff;
  background-repeat: no-repeat;
}

.profile-page {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.profile-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.profile-title-row h1 {
  margin: 3px 0 0;
  font-size: 36px;
}

.profile-title-row > div > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.save-status {
  min-height: 22px;
  font-size: 14px;
  font-weight: 750;
}

.save-status.is-success {
  color: #17633f;
}

.save-status.is-error {
  color: #a33b35;
}

.profile-layout {
  display: grid;
  overflow: hidden;
  grid-template-columns: 310px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.profile-avatar-panel,
.profile-form-panel {
  min-width: 0;
  padding: 30px;
}

.profile-avatar-panel {
  border-right: 1px solid var(--line);
  background: #f9fbfd;
}

.profile-avatar-panel h2,
.profile-form-panel h2 {
  margin: 0 0 24px;
  font-size: 19px;
}

.profile-avatar-preview {
  display: grid;
  width: 156px;
  height: 156px;
  margin: 0 auto 24px;
  place-items: center;
  overflow: hidden;
  border: 4px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  background-color: var(--red);
  background-repeat: no-repeat;
  box-shadow: 0 0 0 1px #cbd5e1, 0 10px 24px rgb(32 47 67 / 12%);
  font-size: 42px;
  font-weight: 850;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.profile-avatar-preview:hover,
.profile-avatar-preview:focus-visible {
  box-shadow: 0 0 0 3px var(--blue), 0 10px 24px rgb(32 47 67 / 12%);
  transform: translateY(-1px);
}

.avatar-options {
  margin-top: 18px;
}

.profile-avatar-preview.has-preset {
  background-size: 400% 200%;
}

.profile-avatar-preview.has-image {
  background-size: cover;
}

.avatar-mode-control {
  display: grid;
  overflow: hidden;
  border: 1px solid #c5ceda;
  border-radius: 6px;
  background: #ffffff;
}

.avatar-mode-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 0;
  color: #566276;
  background: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.avatar-mode-button + .avatar-mode-button {
  border-top: 1px solid #dce3ec;
}

.avatar-mode-button svg {
  width: 17px;
  height: 17px;
}

.avatar-mode-button.is-active {
  color: #124f9d;
  background: var(--blue-soft);
}

.avatar-choice-panel {
  margin-top: 18px;
}

.preset-avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.preset-avatar-button {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background-color: #ffffff;
  background-repeat: no-repeat;
  background-size: 400% 200%;
  box-shadow: 0 0 0 1px #c8d1dc;
  cursor: pointer;
}

.preset-avatar-button.is-selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px var(--blue);
}

.avatar-upload-control {
  display: grid;
  min-height: 112px;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 15px;
  border: 1px dashed #9baabc;
  border-radius: 6px;
  color: #244a78;
  background: #ffffff;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  cursor: pointer;
}

.avatar-upload-control svg {
  width: 22px;
  height: 22px;
}

.avatar-upload-control small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

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

.profile-fields .field {
  margin: 0;
}

.profile-fields .field label span,
.field-label-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.profile-select {
  width: 100%;
}

.plain-input.is-readonly {
  color: #6f7b8b;
  border-color: #dce2e9;
  background: #f3f5f7;
  cursor: default;
}

.profile-bio-field {
  grid-column: 1 / -1;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-textarea {
  min-height: 126px;
  padding-top: 11px;
  resize: vertical;
}

/* Homework */
.homework-page {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.homework-page__title {
  margin-bottom: 26px;
}

.homework-page__title h1,
.student-homework-section h2 {
  margin: 3px 0 0;
  font-size: 32px;
}

.homework-page__title p:last-child,
.section-heading p {
  margin: 8px 0 0;
  color: var(--muted);
}

.homework-create,
.homework-list-section,
.student-homework-section {
  padding: 26px 0;
  border-top: 1px solid var(--line);
}

.homework-create h2,
.homework-list-section h2 {
  margin: 0 0 20px;
  font-size: 21px;
}

.homework-create-form {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(240px, 1.4fr) minmax(190px, 1fr) minmax(100px, 0.5fr) auto;
  align-items: end;
  gap: 14px;
}

.homework-create-form .field,
.homework-create-form .form-message {
  margin: 0;
}

.homework-create-form .form-message {
  grid-column: 1 / -1;
  min-height: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading h2,
.section-heading p {
  margin-top: 0;
  margin-bottom: 0;
}

.homework-list {
  display: grid;
  gap: 12px;
}

.homework-item {
  display: grid;
  gap: 15px;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  background: #ffffff;
}

.homework-item--completed {
  border-left-color: #2f8b61;
}

.homework-item--overdue {
  border-left-color: #c95750;
}

.homework-item__top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.homework-item h3 {
  margin: 8px 0 5px;
  font-size: 18px;
}

.homework-item__top p,
.homework-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.subject-badge,
.homework-status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.subject-badge {
  color: #154f96;
  background: var(--blue-soft);
}

.homework-status--not_started {
  color: #5b6574;
  background: #eef1f5;
}

.homework-status--in_progress {
  color: #7c5800;
  background: #fff1bd;
}

.homework-status--completed {
  color: #17633f;
  background: #dff3e8;
}

.homework-status--overdue {
  color: #9c3732;
  background: #fbe2e0;
}

.homework-progress {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #e7ebf0;
}

.homework-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2474d4;
  transition: width 180ms ease;
}

.homework-numbers {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 9px;
}

.homework-numbers strong {
  font-size: 20px;
}

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

.homework-numbers b,
.homework-percent {
  color: #1454a1;
  font-size: 18px;
}

.homework-continue {
  width: fit-content;
  justify-self: end;
}

.student-homework-section {
  margin-top: 34px;
}

@media (max-width: 820px) {
  .homework-create-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .homework-create-form .primary-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .homework-page {
    width: min(100% - 28px, 1080px);
    padding-top: 28px;
  }

  .homework-create-form {
    grid-template-columns: 1fr;
  }

  .homework-item__top {
    align-items: start;
  }

  .homework-numbers {
    grid-template-columns: auto 1fr;
  }

  .homework-numbers b {
    grid-column: 1 / -1;
  }

  .homework-continue {
    width: 100%;
  }
}

.field-error {
  min-height: 18px;
  margin: 5px 0 0;
  color: #a33b35;
  font-size: 12px;
}

.profile-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.profile-form-actions .primary-button svg {
  width: 17px;
  height: 17px;
}

.profile-form-actions .primary-button,
.profile-form-actions .secondary-button {
  white-space: nowrap;
}

@media (max-width: 800px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }

  .profile-avatar-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .avatar-mode-control {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .avatar-mode-button {
    justify-content: center;
    padding: 8px;
    flex-direction: column;
    text-align: center;
  }

  .avatar-mode-button + .avatar-mode-button {
    border-top: 0;
    border-left: 1px solid #dce3ec;
  }

  .preset-avatar-grid {
    max-width: 340px;
    margin: 0 auto;
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 600px) {
  .profile-page {
    width: min(100% - 28px, 520px);
    padding-top: 28px;
  }

  .profile-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .profile-title-row h1 {
    font-size: 30px;
  }

  .profile-avatar-panel,
  .profile-form-panel {
    padding: 24px 18px;
  }

  .profile-fields {
    grid-template-columns: 1fr;
  }

  .profile-bio-field {
    grid-column: auto;
  }

  .preset-avatar-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .profile-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .profile-form-actions .primary-button,
  .profile-form-actions .secondary-button {
    width: 100%;
  }
}

@media (max-width: 1000px) {
  .auth-shell {
    grid-template-columns: minmax(0, 48fr) minmax(440px, 52fr);
  }

  .auth-panel {
    padding: 44px;
  }

  .language-switcher {
    top: 22px;
    right: 24px;
  }

  .stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-layout {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .admin-sidebar {
    padding: 24px 10px;
  }

  .sidebar-label,
  .sidebar-link span {
    display: none;
  }

  .sidebar-link {
    justify-content: center;
    padding: 0;
  }
}

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

  .schoolyard-art {
    min-height: 330px;
    background-position: center 65%;
  }

  .auth-panel {
    min-width: 0;
    padding: 38px 24px 44px;
    border-top: 1px solid #d8e0eb;
    border-left: 0;
  }

  .language-switcher {
    right: 18px;
  }

  .auth-panel__inner {
    width: min(100%, 520px);
  }

  .auth-heading {
    margin: 48px 0 34px;
  }

  .auth-heading h1 {
    font-size: 39px;
  }

  .auth-footnote {
    margin-top: 44px;
  }

  .art-caption {
    right: 20px;
    bottom: 18px;
    left: 20px;
  }

  .app-header {
    min-height: 64px;
    padding: 0 16px;
  }

  .account-chip > div:not(.account-menu-panel) {
    display: none;
  }

  .page-container {
    width: min(100% - 28px, 680px);
    padding-top: 28px;
  }

  .hero-band {
    display: flex;
    flex-direction: column-reverse;
  }

  .hero-band__copy {
    padding: 30px 24px 34px;
  }

  .hero-band__art {
    min-height: 250px;
    background-position: center 62%;
  }

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

  .info-item + .info-item {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .admin-layout {
    display: block;
  }

  .admin-sidebar {
    position: sticky;
    z-index: 9;
    top: 64px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-nav {
    display: flex;
  }

  .sidebar-link {
    width: 44px;
  }

  .admin-main {
    padding: 28px 14px 56px;
  }

  .teacher-accounts-page .admin-layout--teacher .admin-main { width: min(100% - 28px, 1180px); padding: 28px 0 56px; }

  .admin-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-topline .primary-button {
    width: 100%;
  }

  .topline-actions {
    width: 100%;
  }

  .topline-actions .primary-button,
  .topline-actions .secondary-button {
    flex: 1 1 0;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-control {
    flex-basis: auto;
    max-width: none;
  }

  .filter-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .plain-select {
    width: 100%;
    min-width: 0;
  }

  .bulk-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .bulk-toolbar > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audit-item {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .audit-item time {
    grid-column: 2;
  }
}

@media (max-width: 480px) {
  .schoolyard-art {
    min-height: 285px;
  }

  .auth-panel {
    padding-top: 82px;
    padding-inline: 18px;
  }

  .language-switcher {
    top: 22px;
    right: 18px;
  }

  .form-options {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
  }

  .auth-heading h1 {
    font-size: 36px;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .stat + .stat {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .dialog {
    padding: 30px 22px 22px;
  }

  .student-qr-actions {
    grid-template-columns: 1fr;
  }

  .student-qr-link__controls {
    grid-template-columns: 1fr;
  }
}

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

/* Paper homework workflow */
.homework-create-form--new {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.homework-create-form--new .homework-instructions-field,
.homework-create-form--new .recipient-picker,
.homework-create-form--new .form-message {
  grid-column: 1 / -1;
}

.plain-input.homework-textarea {
  min-height: 86px;
  padding: 10px 13px;
  resize: vertical;
}

.field label span,
.recipient-picker legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.recipient-picker {
  display: grid;
  gap: 11px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.recipient-picker legend {
  padding: 0 5px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.recipient-picker__choice,
.recipient-picker__students {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.recipient-picker label,
.recipient-student {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
}

.recipient-picker input,
.progress-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
}

.recipient-picker__students {
  max-height: 142px;
  overflow: auto;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.homework-item--link {
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.homework-item--link:hover,
.homework-item--link:focus-visible {
  border-color: #9fbde8;
  box-shadow: 0 9px 22px rgb(20 50 92 / 10%);
  transform: translateY(-1px);
}

.homework-state-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.homework-state-counts span {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}

.homework-state-counts b {
  color: var(--ink);
  font-size: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover { color: var(--blue-dark); }
.back-link svg { width: 17px; height: 17px; }

.task-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 22px 0 26px;
  border-bottom: 1px solid var(--line);
}

.task-summary h1 {
  width: 100%;
  margin: 0;
  font-size: 29px;
}

.task-summary p { margin: 0; }
.task-summary__instructions { width: 100%; color: var(--muted); white-space: pre-wrap; }
.task-summary__meta { color: var(--muted); font-size: 14px; }
.submission-status-message { width: 100%; color: #245a9c; font-weight: 700; }

.progress-section,
.student-submission-section {
  padding-top: 26px;
}

.search-field {
  position: relative;
  display: block;
  width: min(100%, 260px);
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-field .plain-input { height: 40px; padding-left: 36px; }

.state-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.state-filter {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.state-filter.is-active { border-color: var(--blue); color: var(--blue-dark); background: var(--blue-soft); }

.progress-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.progress-table {
  width: 100%;
  min-width: 790px;
  border-collapse: collapse;
}

.progress-table th,
.progress-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.progress-table th { color: var(--muted); background: var(--surface-soft); font-size: 12px; }
.progress-table tbody tr:last-child td { border-bottom: 0; }
.progress-table .select-cell { width: 45px; text-align: center; }
.progress-table .homework-status + .late-badge { margin-left: 6px; }

.late-badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  border-radius: 5px;
  color: #9a342d;
  background: #fbe3e0;
  font-size: 11px;
  font-weight: 800;
}

.photo-thumbnails,
.review-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.photo-thumbnail {
  width: 38px;
  height: 38px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: zoom-in;
}

.photo-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-count { display: grid; width: 38px; height: 38px; place-items: center; color: var(--muted); background: var(--surface-soft); font-size: 12px; font-weight: 800; }
.readonly-label { color: var(--muted); font-size: 13px; }

.batch-review-toolbar {
  position: sticky;
  z-index: 5;
  bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid #98bae7;
  border-radius: 7px;
  background: #eef6ff;
  box-shadow: 0 10px 20px rgb(22 74 138 / 12%);
}

.batch-review-toolbar > div { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; }
.batch-review-toolbar label { display: grid; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 700; }
.batch-review-toolbar .plain-input { height: 35px; padding: 0 8px; font-size: 13px; }
.compact-number { width: 72px; }
.compact-feedback { width: 170px; }

.review-dialog { width: min(calc(100% - 32px), 600px); }
.review-student { margin-bottom: 15px; font-size: 18px; font-weight: 800; }
.review-submission-text { margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #f8fafc; white-space: pre-wrap; }
.review-images { margin-bottom: 4px; }
.review-images .photo-thumbnail { width: 82px; height: 82px; }

.student-submission-form { display: grid; gap: 16px; max-width: 650px; }
.submission-note { margin: 0; color: var(--muted); font-size: 14px; }
.file-input { width: 100%; padding: 10px; border: 1px dashed #9eb2cd; border-radius: 7px; background: #f9fbfe; }
.submission-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 10px; }
.submission-preview { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.submission-preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-remove { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; color: #8f302a; background: rgb(255 255 255 / 92%); }

@media (max-width: 760px) {
  .homework-create-form--new { grid-template-columns: 1fr; }
  .homework-create-form--new .homework-instructions-field,
  .homework-create-form--new .recipient-picker,
  .homework-create-form--new .form-message { grid-column: auto; }
  .homework-state-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .progress-table-wrap { overflow: visible; border: 0; background: transparent; }
  .progress-table, .progress-table tbody, .progress-table tr, .progress-table td { display: block; min-width: 0; width: 100%; }
  .progress-table thead { display: none; }
  .progress-table tr { display: grid; grid-template-columns: 32px 1fr; gap: 8px 12px; margin-bottom: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
  .progress-table td { min-height: 0; padding: 0; border: 0; }
  .progress-table .select-cell { grid-row: 1 / span 5; width: auto; padding-top: 3px; text-align: left; }
  .progress-table td:not(.select-cell)::before { display: block; margin-bottom: 2px; color: var(--muted); content: attr(data-label); font-size: 11px; font-weight: 700; }
  .progress-table td:last-child { grid-column: 2; }
  .batch-review-toolbar { position: static; align-items: stretch; flex-direction: column; }
  .batch-review-toolbar > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-review-toolbar label:last-of-type, .batch-review-toolbar .primary-button { grid-column: 1 / -1; }
  .compact-feedback { width: 100%; }
  .review-dialog { width: 100%; max-width: none; min-height: 100svh; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .review-dialog .dialog-form { min-height: calc(100svh - 50px); }
  .review-dialog .dialog-form__actions { margin-top: auto; flex-direction: column-reverse; }
  .review-dialog .dialog-form__actions button { width: 100%; }
}

/* Blooket */
.teacher-page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.teacher-page-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.teacher-page-nav a:hover,
.teacher-page-nav a.is-active {
  border-color: #bcd2f2;
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.teacher-page-nav svg { width: 16px; height: 16px; }

.teacher-accounts-page .admin-layout--teacher { display: block; min-height: auto; }
.teacher-accounts-page .admin-layout--teacher .admin-sidebar { display: none; }
.teacher-accounts-page .admin-layout--teacher .admin-main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 72px; }

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

.blooket-editor {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(20 33 61 / 5%);
}

.blooket-editor__heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.blooket-editor__heading h2 {
  margin: 1px 0 0;
  font-size: 21px;
}

.blooket-editor__heading .eyebrow { margin: 0; }

.blooket-editor__icon,
.blooket-student-item__icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 7px;
  color: #805d00;
  background: #fff2bd;
}

.blooket-editor__icon svg,
.blooket-student-item__icon svg { width: 21px; height: 21px; }

.blooket-editor__description {
  min-height: 46px;
  margin: 17px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.blooket-form { display: grid; gap: 15px; }
.blooket-form .field { margin: 0; }
.blooket-form .form-hint { margin: -4px 0 0; }

.form-hint {
  color: var(--muted);
  font-size: 12px;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.toggle-field input { width: 17px; height: 17px; accent-color: var(--blue); }

.blooket-form__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 3px;
}

.blooket-form__actions .primary-button,
.blooket-form__actions .secondary-button { min-height: 38px; }

.student-blooket-section {
  margin-top: 34px;
  padding: 26px 0;
  border-top: 1px solid var(--line);
}

.student-blooket-section h2 { margin: 3px 0 0; font-size: 28px; }

.blooket-student-grid { display: grid; gap: 12px; }

.blooket-student-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  background: var(--surface);
}

.blooket-student-item--homework { border-left-color: var(--green); }
.blooket-student-item h3 { margin: 5px 0 2px; font-size: 17px; }
.blooket-student-item p { margin: 0; color: var(--muted); font-size: 13px; }
.blooket-student-item__open { color: var(--blue-dark); }

/* Teaching arrangements and student dashboard */
.schedule-main {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 38px 0 72px;
}
.schedule-topline,
.schedule-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}
.schedule-topline { margin-bottom: 24px; }
.schedule-topline h1 { margin: 3px 0 0; font-size: 32px; }
.schedule-topline p,
.schedule-toolbar p { margin: 7px 0 0; color: var(--muted); }
.schedule-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.schedule-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 13px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font: inherit; font-weight: 800; cursor: pointer; }
.schedule-tab.is-active { border-bottom-color: var(--blue); color: var(--blue-dark); }
.schedule-tab svg { width: 17px; height: 17px; }
.schedule-panel { padding-top: 18px; }
.schedule-toolbar { align-items: center; margin-bottom: 18px; }
.schedule-toolbar h2 { margin: 0; font-size: 22px; }
.schedule-toolbar .primary-button { margin-left: auto; }
.course-week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.course-day-column { min-width: 0; min-height: 300px; border-right: 1px solid var(--line); }
.course-day-column:last-child { border-right: 0; }
.course-day-heading { display: grid; gap: 3px; padding: 13px 10px; border-bottom: 1px solid var(--line); background: #f7f9fc; }
.course-day-heading span { color: var(--muted); font-size: 12px; }
.course-day-list { display: grid; gap: 8px; padding: 9px; }
.course-day-empty { margin: 15px 2px; color: #a0a9b5; font-size: 12px; text-align: center; }
.course-item { display: grid; gap: 5px; padding: 11px; border-left: 3px solid var(--blue); background: #f7faff; }
.course-item--rescheduled { border-left-color: #b67d00; background: #fff9e7; }
.course-item--cancelled { border-left-color: #b1b7c1; color: #8b939f; background: #f0f2f5; text-decoration: line-through; }
.course-item time { color: var(--blue-dark); font-size: 12px; font-weight: 800; }
.course-item h3 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.course-item p { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.course-feedback-button { width: fit-content; min-height: 30px; padding: 0 8px; font-size: 12px; }
.schedule-dialog { width: min(620px, calc(100% - 32px)); }
.schedule-dialog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.student-picker { display: grid; gap: 9px; }
.student-picker__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.student-picker__top label { color: var(--ink); font-size: 14px; font-weight: 700; }
.student-picker__count { color: var(--muted); font-size: 12px; font-weight: 700; }
.student-picker__actions { display: flex; flex-wrap: wrap; gap: 7px; }
.student-picker__actions .small-action { min-height: 30px; padding: 0 9px; }
.student-checklist { display: grid; max-height: 190px; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.student-checklist__item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 11px; border-bottom: 1px solid var(--line); cursor: pointer; }
.student-checklist__item:last-child { border-bottom: 0; }
.student-checklist__item:hover { background: var(--blue-soft); }
.student-checklist__item input { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--blue); }
.student-checklist:empty::before { padding: 14px 11px; color: var(--muted); content: "目前没有可选择的学生"; font-size: 13px; }
.teacher-todo-list { display: grid; gap: 12px; }
.teacher-todo-item { padding: 18px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 7px; background: var(--surface); }
.teacher-todo-item__top { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.teacher-todo-item h3 { margin: 0; font-size: 17px; }
.teacher-todo-item p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.teacher-todo-assignments { display: grid; gap: 7px; margin-top: 14px; }
.teacher-todo-assignment { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.todo-status { display: inline-flex; min-height: 24px; align-items: center; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.todo-status--pending { color: #735400; background: #fff1bd; }
.todo-status--completed { color: #17633f; background: #dff3e8; }
.todo-status--overdue { color: #9c3732; background: #fbe2e0; }
.todo-status--late { color: #805700; background: #ffedcf; }
.student-today-section,
.student-todo-section,
.student-week-section,
.student-feedback-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.today-course-list,
.student-week-list,
.student-todo-list,
.student-feedback-list { display: grid; gap: 10px; }
.student-course-item { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 15px; padding: 16px 18px; border-left: 4px solid var(--blue); background: var(--surface); }
.student-course-item--rescheduled { border-left-color: #b67d00; background: #fff9e7; }
.student-course-item--cancelled { border-left-color: #b1b7c1; color: #7d8793; background: #f0f2f5; text-decoration: line-through; }
.student-course-item time { color: var(--blue-dark); font-size: 13px; font-weight: 800; }
.student-course-item h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.student-course-item p { margin: 5px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.student-week-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.student-todo-item { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-left: 4px solid #b67d00; background: var(--surface); }
.student-todo-item--homework { border-left-color: var(--blue); }
.student-todo-item--completed,
.student-todo-item--late { border-left-color: var(--green); }
.student-todo-item input { flex: 0 0 auto; width: 20px; height: 20px; accent-color: var(--green); }
.student-todo-item > div { min-width: 0; flex: 1; }
.student-todo-item h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.student-todo-item p { margin: 5px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.student-todo-action { flex: 0 0 auto; }
.student-feedback-item { padding: 16px 18px; border-left: 4px solid #2f8b61; background: var(--surface); }
.student-feedback-item p { margin: 0; overflow-wrap: anywhere; }
.student-feedback-item p:first-child { color: var(--muted); font-size: 12px; }
.student-feedback-item p + p { margin-top: 8px; font-size: 15px; line-height: 1.6; }
.course-item__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.course-item__actions .icon-button { min-width: 30px; min-height: 30px; }
.schedule-student-filter { min-width: 120px; }
.page-container .hero-band { min-height: 230px; }
.page-container .hero-band__art { min-height: 230px; }

@media (max-width: 920px) {
  .course-week-grid { overflow-x: auto; grid-template-columns: repeat(7, minmax(145px, 1fr)); }
  .course-day-column { min-height: 240px; }
}

@media (max-width: 620px) {
  .schedule-main { width: min(100% - 28px, 1240px); padding-top: 26px; }
  .schedule-topline, .schedule-toolbar { align-items: stretch; flex-direction: column; }
  .schedule-tabs { width: 100%; }
  .schedule-tab { flex: 1; justify-content: center; }
  .schedule-toolbar .primary-button { margin-left: 0; }
  .schedule-dialog-grid { grid-template-columns: 1fr; }
  .student-week-list { grid-template-columns: 1fr; }
  .student-course-item { grid-template-columns: 1fr; gap: 6px; }
  .student-todo-item { align-items: start; }
  .student-todo-action { align-self: center; }
  .page-container .hero-band { min-height: 190px; grid-template-columns: 1fr; }
  .page-container .hero-band__copy { padding: 26px; }
  .page-container .hero-band__copy h1 { font-size: 30px; }
  .page-container .hero-band__art { display: none; }
  .page-container .info-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-container .info-item { padding: 16px 11px; }
  .page-container .info-item + .info-item { border-top: 0; border-left: 1px solid var(--line); }
  .page-container .info-item span { font-size: 11px; }
  .page-container .info-item strong { font-size: 13px; }
}

@media (max-width: 760px) {
  .blooket-slot-grid { grid-template-columns: 1fr; }
  .blooket-editor { padding: 20px; }
  .blooket-editor__description { min-height: 0; }
  .blooket-form__actions { justify-content: stretch; }
  .blooket-form__actions > * { flex: 1 1 180px; justify-content: center; }
  .blooket-student-item { grid-template-columns: auto 1fr; }
  .blooket-student-item__open { grid-column: 2; justify-self: end; }
}
