@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-thai-400.ttf") format("truetype");
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-thai-500.ttf") format("truetype");
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-thai-600.ttf") format("truetype");
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-thai-700.ttf") format("truetype");
}

:root {
  color-scheme: light;
  --navy: #17324d;
  --navy-deep: #102a43;
  --navy-soft: #2f516f;
  --mustard: #e2a72e;
  --mustard-soft: #f7e7b4;
  --brick: #b6543e;
  --brick-soft: #f4ddd6;
  --sage: #6f856b;
  --sage-soft: #dfe8dc;
  --ink: #1b2d3c;
  --muted: #68737a;
  --paper: #f4f0e6;
  --paper-deep: #e9e1d2;
  --paper-light: #fffcf6;
  --surface: #fffefd;
  --line: #d8cfbf;
  --line-strong: #b9ae9d;
  --success: #416a4a;
  --success-soft: #e2ecdf;
  --warning: #8a5b00;
  --warning-soft: #f9ebc5;
  --danger: #9f3f35;
  --danger-soft: #f6e0dc;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-paper: 0 16px 38px rgba(38, 43, 43, 0.08), 0 2px 0 rgba(23, 50, 77, 0.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, rgba(23, 50, 77, 0.018) 0, rgba(23, 50, 77, 0.018) 1px, transparent 1px, transparent 5px),
    radial-gradient(circle at 14% 8%, rgba(255, 255, 255, 0.9), transparent 34rem);
  font-family: "IBM Plex Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 99;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: var(--radius-sm);
  color: white;
  background: var(--navy);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px max(20px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.95);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 52px;
  height: 46px;
  place-items: center;
  border: 1px solid #d7c8aa;
  border-radius: 3px 7px 5px 4px;
  color: var(--navy);
  background: #efe3c9;
  box-shadow: -7px 0 0 var(--navy), 0 4px 10px rgba(38, 43, 43, 0.08);
  font-weight: 700;
  letter-spacing: -0.04em;
  transform: rotate(-1deg);
}

.brand-mark::after {
  position: absolute;
  top: -7px;
  left: 14px;
  width: 25px;
  height: 10px;
  background: rgba(226, 167, 46, 0.34);
  content: "";
  transform: rotate(2deg);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.12rem; line-height: 1.25; }
.brand small { color: var(--muted); font-size: 0.78rem; }

main {
  width: min(1240px, calc(100% - 32px));
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: 34px 0 64px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}
.button:hover { transform: translateY(-1px); }

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.teacher-card:focus-visible,
.star-button:focus-visible,
.favorite-filter:focus-visible {
  outline: 3px solid rgba(226, 167, 46, 0.45);
  outline-offset: 2px;
}

.button-primary { color: white; background: var(--navy); box-shadow: 0 6px 0 var(--navy-deep); }
.button-primary:hover { background: var(--navy-deep); }
.button-secondary { color: var(--navy); border-color: var(--line-strong); background: var(--paper-light); }
.button-quiet { min-height: 40px; color: var(--navy); border-color: var(--line); background: transparent; }
.button-open { min-width: 108px; color: var(--navy-deep); border-color: #cf961e; background: var(--mustard); box-shadow: 0 3px 0 #bf8611; }
.button-open:hover { background: #edb83d; }
.button-open[aria-disabled="true"] { pointer-events: none; opacity: 0.45; }

.gate-panel {
  position: relative;
  width: min(650px, 100%);
  margin: 6vh auto 0;
  padding: clamp(30px, 6vw, 54px);
  border: 1px solid var(--line-strong);
  border-left: 10px solid var(--navy);
  border-radius: 5px var(--radius-lg) var(--radius-lg) 5px;
  background: var(--paper-light);
  box-shadow: var(--shadow-paper);
  text-align: center;
}

.gate-panel::after {
  position: absolute;
  top: -10px;
  right: 58px;
  width: 76px;
  height: 21px;
  background: rgba(226, 167, 46, 0.30);
  content: "";
  transform: rotate(1.5deg);
}

.gate-icon {
  display: grid;
  width: 74px;
  height: 64px;
  margin: 0 auto 22px;
  place-items: center;
  border: 1px solid #c9b987;
  border-radius: 4px;
  color: var(--navy);
  background: var(--mustard-soft);
  box-shadow: -8px 0 0 var(--navy);
  font-size: 1.25rem;
  font-weight: 700;
  transform: rotate(-1deg);
}
.gate-icon-closed { color: var(--brick); box-shadow: -8px 0 0 var(--brick); }
.gate-panel h1 { margin: 7px 0 10px; color: var(--navy); font-size: clamp(1.7rem, 5vw, 2.45rem); line-height: 1.2; }
.gate-copy { max-width: 480px; margin: 0 auto; color: var(--muted); font-size: 1.05rem; }
.gate-help { margin: 24px 0 0; color: var(--muted); font-size: 0.9rem; }

.eyebrow { margin: 0; color: var(--brick); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; }

.notice {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid #dfc67e;
  border-radius: 5px;
  color: #654900;
  background: #fbefcb;
  text-align: left;
}

.notice-wide {
  display: flex;
  gap: 13px;
  align-items: baseline;
  margin: 17px 0;
  border-left: 5px solid var(--brick);
  color: #623a31;
  background: var(--brick-soft);
}
.notice-wide strong { flex: 0 0 auto; color: var(--brick); }
.notice-wide strong span { font-size: 0.65rem; }

.login-form { margin-top: 27px; text-align: left; }
.login-form label, .filters label > span:first-child, .admin-form label > span { display: block; margin-bottom: 7px; font-weight: 600; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
}
textarea { min-height: 116px; resize: vertical; }
input::placeholder { color: #8a908f; }

.form-message { margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 600; }
.form-message-error { color: var(--danger); background: var(--danger-soft); }
.form-message-success { color: var(--success); background: var(--success-soft); }

.portal-intro, .admin-heading {
  position: relative;
  display: flex;
  min-height: 216px;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: clamp(28px, 5vw, 54px) clamp(24px, 6vw, 70px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-left: 12px solid var(--navy);
  border-radius: 5px var(--radius-lg) var(--radius-lg) 5px;
  color: var(--navy);
  background-color: #eee6d7;
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(23, 50, 77, 0.04) 31px, rgba(23, 50, 77, 0.04) 32px);
  box-shadow: var(--shadow-paper);
}

.portal-intro::before, .admin-heading::before {
  position: absolute;
  top: -15px;
  left: 38%;
  width: 120px;
  height: 30px;
  background: rgba(226, 167, 46, 0.28);
  content: "";
  transform: rotate(-1deg);
}

.portal-intro > div:first-child, .admin-heading > div:first-child { position: relative; z-index: 1; }
.portal-intro h1, .admin-heading h1 { margin: 7px 0 8px; color: var(--navy); font-size: clamp(2.35rem, 6vw, 4.25rem); line-height: 1.04; letter-spacing: -0.035em; }
.portal-intro p:last-child, .admin-heading p:last-child { max-width: 650px; margin: 0; color: var(--navy-soft); font-size: 1.03rem; }

.term-badge {
  position: relative;
  z-index: 2;
  min-width: 154px;
  padding: 18px 24px;
  border: 1px solid #c8b77f;
  border-radius: 4px;
  background: #f3df9d;
  box-shadow: 7px 7px 0 rgba(23, 50, 77, 0.12);
  text-align: center;
  transform: rotate(1deg);
}
.term-badge span, .term-badge strong { display: block; }
.term-badge span { color: #715414; font-size: 0.82rem; }
.term-badge strong { color: var(--navy); font-size: 2.15rem; line-height: 1.1; }

.hero-sprig {
  position: absolute;
  z-index: 0;
  right: 205px;
  bottom: -58px;
  width: 126px;
  height: auto;
  opacity: 0.58;
  pointer-events: none;
  transform: rotate(-7deg);
}

.deadline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 17px 0;
  padding: 13px 17px;
  border: 1px solid #dfc67e;
  border-left: 5px solid var(--mustard);
  border-radius: 5px;
  color: #654900;
  background: var(--warning-soft);
}

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 17px 0; }
.summary-grid article {
  position: relative;
  min-height: 104px;
  padding: 18px 20px 16px 24px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: 0 5px 15px rgba(38, 43, 43, 0.05);
}
.summary-grid article::before { position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--navy); content: ""; }
.summary-grid .summary-ready::before { background: var(--sage); }
.summary-grid .summary-teachers::before { background: var(--mustard); }
.summary-grid .summary-pending::before { background: var(--brick); }
.summary-grid span, .summary-grid small { display: block; color: var(--muted); }
.summary-grid strong { display: inline-block; margin: 3px 6px 0 0; color: var(--navy); font-size: 2.2rem; line-height: 1.1; }
.summary-grid small { display: inline; font-size: 0.8rem; }

.workspace, .admin-form {
  position: relative;
  margin-top: 18px;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 254, 253, 0.96);
  box-shadow: var(--shadow-paper);
}
.workspace::before { position: absolute; top: 28px; right: -9px; width: 9px; height: 72px; border-radius: 0 5px 5px 0; background: var(--mustard); content: ""; }

.workspace-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.workspace-heading h2 { margin: 4px 0 2px; color: var(--navy); font-size: clamp(1.55rem, 3vw, 2rem); line-height: 1.2; }
.workspace-heading p:last-child { max-width: 680px; margin: 0; color: var(--muted); font-size: 0.92rem; }

.filters {
  display: grid;
  grid-template-columns: minmax(250px, 1.6fr) repeat(3, minmax(150px, 0.75fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}
.filters label > span:first-child { color: var(--muted); font-size: 0.79rem; }
.input-with-icon { position: relative; display: block; }
.input-with-icon > span { position: absolute; z-index: 1; top: 7px; left: 13px; color: var(--navy); font-size: 1.45rem; line-height: 1; }
.input-with-icon input { padding-left: 42px; background: var(--paper-light); }

.explorer-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 0;
  margin-top: 22px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.teacher-panel { min-width: 0; padding: 18px 14px 16px; border-right: 1px solid var(--line-strong); background: #f7f2e8; }
.records-panel { min-width: 0; padding: 18px 20px 20px; background: var(--surface); }

.panel-heading { display: flex; min-height: 58px; align-items: center; gap: 11px; padding: 0 4px 13px; border-bottom: 1px solid var(--line); }
.panel-heading p, .panel-heading h3 { margin: 0; }
.panel-heading p { color: var(--muted); font-size: 0.75rem; }
.panel-heading h3 { color: var(--navy); font-size: 1.12rem; line-height: 1.25; }
.records-panel-heading { position: relative; }
.records-panel-heading > div { flex: 1; }

.step-number { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--navy); background: var(--mustard-soft); font-size: 0.76rem; font-weight: 700; }

.teacher-directory {
  display: grid;
  max-height: 620px;
  gap: 3px;
  margin-top: 10px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #b9ae9d transparent;
  scrollbar-width: thin;
}

.teacher-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.teacher-card:hover { border-color: var(--line); background: var(--paper-light); transform: translateX(2px); }
.teacher-card.is-selected { border-color: #c88e15; background: var(--mustard); box-shadow: 3px 3px 0 rgba(23, 50, 77, 0.12); }
.teacher-avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: white; background: var(--navy); font-weight: 600; }
.teacher-card.is-selected .teacher-avatar { color: var(--navy); background: var(--paper-light); }
.teacher-card-copy { min-width: 0; }
.teacher-card-copy strong, .teacher-card-copy small { display: block; }
.teacher-card-copy strong { overflow: hidden; font-size: 0.9rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.teacher-card-copy small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.teacher-card.is-selected .teacher-card-copy small { color: #5f480f; }
.teacher-arrow { color: var(--navy); font-size: 1.25rem; }

.result-toolbar { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.result-toolbar p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.favorite-filter { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--paper-light); cursor: pointer; font-size: 0.8rem; }
.favorite-filter[aria-pressed="true"] { color: #624500; border-color: #cf961e; background: var(--mustard-soft); }

.selection-state, .loading-state, .empty-state {
  display: flex;
  min-height: 310px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: #fffcf7;
  text-align: center;
}
.selection-state strong, .empty-state strong { color: var(--navy); font-size: 1.08rem; }
.selection-illustration { width: min(178px, 48%); height: auto; margin-bottom: 8px; }

.record-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.record-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 104px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.record-card:last-child { border-bottom: 0; }
.record-card::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--sage); content: ""; }
.record-card:hover { background: #fffaf0; }
.record-card.is-pending { background: #fffbef; }
.record-card.is-pending::before { background: var(--mustard); }
.star-button { align-self: start; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: #8b8c84; background: var(--paper); cursor: pointer; font-size: 1.18rem; }
.star-button.is-active { color: #795600; border-color: #d2a039; background: var(--mustard-soft); }
.record-copy { min-width: 0; }
.record-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.class-pill { padding: 2px 8px; border: 1px solid #aabca6; border-radius: 4px; color: #36533b; background: var(--sage-soft); font-size: 0.76rem; font-weight: 700; }
.group-label { color: var(--muted); font-size: 0.76rem; }
.record-copy h3 { margin: 7px 0 0; color: var(--navy); font-size: 1.02rem; line-height: 1.2; }
.subject-name { margin: 1px 0; color: var(--ink); font-size: 0.94rem; }
.teacher-name { margin: 0; color: var(--muted); font-size: 0.79rem; }
.record-status { padding: 7px 10px; border: 1px solid #d8b75c; border-radius: 5px; color: var(--warning); background: var(--warning-soft); font-size: 0.78rem; font-weight: 600; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--paper-deep); border-top-color: var(--navy); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-teacher-change { display: none; }

.admin-heading { min-height: 190px; align-items: center; }
.admin-heading .button-secondary { position: relative; z-index: 2; flex: 0 0 auto; }
.admin-summary .status-card.status-open { border-color: #9bb297; background: var(--success-soft); }
.admin-summary .status-card.status-closed, .status-warning { border-color: #d8b75c !important; background: var(--warning-soft) !important; }
.warning-banner { display: grid; gap: 2px; margin: 18px 0; padding: 15px 18px; border: 1px solid #d8b75c; border-left: 5px solid var(--mustard); border-radius: 5px; color: #704900; background: var(--warning-soft); }

.admin-form { display: grid; gap: 18px; }
.admin-form::before { position: absolute; top: 25px; right: -9px; width: 9px; height: 72px; border-radius: 0 5px 5px 0; background: var(--sage); content: ""; }
.settings-card { margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-light); }
.settings-card legend { padding: 0 8px; color: var(--navy); font-size: 1.05rem; font-weight: 700; }
.settings-card label + label { margin-top: 18px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 3px; color: var(--muted); }
.switch { position: relative; flex: 0 0 auto; width: 58px; height: 34px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #a9aaa3; transition: background 160ms ease; }
.switch span::after { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: white; box-shadow: 0 2px 7px rgba(0,0,0,0.2); content: ""; transition: transform 160ms ease; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid rgba(226,167,46,0.4); outline-offset: 3px; }
.admin-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-actions span { color: var(--muted); font-size: 0.84rem; }

.site-footer {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px max(20px, calc((100vw - 1240px) / 2));
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #e9e1d2;
  font-size: 0.84rem;
}
.site-footer a { color: var(--navy); font-weight: 600; }

@media (max-width: 980px) {
  .filters { grid-template-columns: repeat(2, 1fr); }
  .search-field { grid-column: 1 / -1; }
  .explorer-grid { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
  .record-card { grid-template-columns: 36px minmax(0, 1fr); }
  .record-card .button-open, .record-card .record-status { grid-column: 2; justify-self: start; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .site-header { min-height: 66px; padding-block: 9px; }
  .brand-mark { width: 44px; height: 40px; box-shadow: -5px 0 0 var(--navy), 0 3px 8px rgba(38, 43, 43, 0.08); }
  .brand strong { font-size: 1rem; }
  .brand small { display: none; }
  main { width: min(100% - 20px, 1240px); padding-top: 16px; }
  .gate-panel { margin-top: 14px; padding: 29px 20px; }
  .password-row { grid-template-columns: 1fr; }

  .portal-intro, .admin-heading { min-height: 0; align-items: flex-start; flex-direction: column; padding: 28px 22px; }
  .portal-intro h1, .admin-heading h1 { font-size: clamp(2.2rem, 11vw, 3.2rem); }
  .hero-sprig { display: none; }
  .term-badge { display: flex; min-width: 0; width: 100%; align-items: baseline; justify-content: space-between; padding: 12px 16px; box-shadow: 5px 5px 0 rgba(23, 50, 77, 0.10); }
  .term-badge strong { font-size: 1.65rem; }
  .notice-wide, .deadline { align-items: flex-start; flex-direction: column; }

  .summary-grid { gap: 6px; }
  .summary-grid article { min-height: 96px; padding: 13px 8px 11px 14px; }
  .summary-grid article::before { width: 5px; }
  .summary-grid span { font-size: 0.72rem; line-height: 1.25; }
  .summary-grid strong { display: block; margin: 5px 0 0; font-size: 1.75rem; }
  .summary-grid small { font-size: 0.7rem; }

  .workspace { padding: 18px 13px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .workspace-heading .button { align-self: stretch; }
  .filters { grid-template-columns: 1fr; padding: 11px; }
  .search-field { grid-column: auto; }
  .explorer-grid { grid-template-columns: 1fr; overflow: visible; border: 0; background: transparent; }
  .teacher-panel, .records-panel { border: 1px solid var(--line-strong); border-radius: var(--radius-md); }
  .teacher-panel { padding: 15px 11px; background: #f7f2e8; }
  .records-panel { margin-top: 12px; padding: 15px 11px; scroll-margin-top: 78px; }
  .teacher-directory { max-height: none; }
  .teacher-card { min-height: 62px; }
  .workspace.has-selected-teacher .teacher-panel { display: none; }
  .workspace.has-selected-teacher .records-panel { margin-top: 0; }
  .workspace.has-selected-teacher .mobile-teacher-change { display: inline-flex; }
  .records-panel-heading { flex-wrap: wrap; }
  .mobile-teacher-change { width: 100%; margin-top: 5px; }
  .result-toolbar { align-items: flex-start; flex-direction: column; }
  .selection-state, .loading-state, .empty-state { min-height: 220px; padding: 20px; }
  .record-card { min-height: 0; padding: 13px 11px; }
  .record-card .button-open { width: 100%; }

  .admin-heading .button-secondary { width: 100%; }
  .admin-actions { align-items: stretch; flex-direction: column; }
  .toggle-row { align-items: flex-start; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 410px) {
  .logout-form .button { min-height: 38px; padding-inline: 11px; font-size: 0.82rem; }
  .summary-grid span { min-height: 32px; }
}

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