:root {
  color-scheme: dark;
  --bg: #080d19;
  --surface: rgba(18, 28, 48, 0.88);
  --surface-2: #101a2d;
  --border: rgba(148, 163, 184, 0.17);
  --text: #f3f6ff;
  --muted: #9aa8c2;
  --primary: #67e8f9;
  --primary-dark: #4f46e5;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

body {
  min-height: 100vh;
  padding: 30px 18px;
  color: var(--text);
  background:
    radial-gradient(900px circle at 8% -10%, rgba(79, 70, 229, 0.2), transparent 48%),
    radial-gradient(760px circle at 95% 8%, rgba(6, 182, 212, 0.13), transparent 42%),
    linear-gradient(155deg, #080d19 0%, #0b1323 55%, #0b1020 100%);
  background-attachment: fixed;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(103, 232, 249, 0.72);
  outline-offset: 3px;
}

.container {
  width: min(100%, 1160px);
  margin: 0 auto;
}

.hidden { display: none !important; }

.card {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 3vw, 30px);
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(22, 34, 57, 0.94), rgba(15, 24, 42, 0.9));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card h2 {
  margin-bottom: 16px;
  font-size: clamp(1.12rem, 2vw, 1.32rem);
  letter-spacing: -0.025em;
}

.card h3 {
  margin-bottom: 10px;
  font-size: 1.04rem;
  letter-spacing: -0.015em;
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 20px;
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: 20px;
  background:
    radial-gradient(450px circle at 0% 0%, rgba(79, 70, 229, 0.18), transparent 65%),
    linear-gradient(120deg, rgba(19, 30, 52, 0.97), rgba(14, 24, 43, 0.94));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2);
}

.topbar-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 2px solid rgba(103, 232, 249, 0.45);
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.profile-avatar-large {
  width: 96px;
  height: 96px;
}

.profile-image-editor {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.question-image,
.question-image-preview {
  display: block;
  width: auto;
  max-width: min(100%, 560px);
  max-height: 360px;
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  object-fit: contain;
  background: rgba(8, 15, 29, 0.78);
}

.question-image-preview {
  max-width: min(100%, 360px);
  max-height: 240px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.account-heading h2 { margin-bottom: 4px; }

.section-nav {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(15, 24, 42, 0.78);
}

.section-nav .tab-btn {
  flex: 1 1 170px;
  min-height: 44px;
}

.camera-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #050914;
}

.camera-frame video,
.camera-frame img {
  display: block;
  width: min(100%, 480px);
  max-height: 420px;
  object-fit: cover;
}

.camera-frame.face-auth-mode .face-auth-video { transform: scaleX(-1); }

.trial-face-guide {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(72vw, 300px);
  aspect-ratio: 1;
  border: 3px dashed rgba(103, 232, 249, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(3, 8, 18, 0.12), 0 0 24px rgba(103, 232, 249, 0.24);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.camera-frame.is-face-aligned .trial-face-guide {
  border-color: var(--success);
  box-shadow: 0 0 0 999px rgba(3, 8, 18, 0.08), 0 0 28px rgba(52, 211, 153, 0.36);
}

.button-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 15px 0;
  line-height: 1.5;
}

.consent-row input {
  width: auto;
  margin-top: 4px;
  flex: 0 0 auto;
}

.trial-question-card {
  padding: 16px;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(8, 15, 29, 0.48);
}

.trial-question-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.trial-question-title h3 { margin-bottom: 7px; }
.trial-account-form { min-width: 180px; }
.trial-account-form input { margin-top: 8px; }
.trial-account-form button { margin-top: 8px; }
.public-leaderboard { margin: 14px 0; }
.public-leaderboard summary { margin-bottom: 10px; }
.trial-quiz-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.trial-question { margin: 14px 0; font-size: 1.12rem; line-height: 1.6; white-space: pre-wrap; }
.trial-score { margin: 10px 0; color: var(--primary); font-size: 1.8rem; font-weight: 800; }

#top-fullname { display: inline-block; font-size: 1.12rem !important; letter-spacing: -0.02em; }
#top-extra { margin-top: 5px; }

#login-view {
  max-width: 460px !important;
  padding: 38px clamp(24px, 6vw, 44px) !important;
  margin: clamp(30px, 10vh, 100px) auto !important;
  border-color: rgba(103, 232, 249, 0.22);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.48), 0 0 60px rgba(79, 70, 229, 0.1);
}

#login-view::before {
  position: absolute;
  top: -110px;
  right: -100px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.12);
  filter: blur(55px);
  content: '';
  pointer-events: none;
}

#login-view > * { position: relative; }
#login-view h1 {
  margin-bottom: 9px;
  color: transparent;
  font-size: clamp(1.6rem, 5vw, 2rem);
  font-weight: 850;
  letter-spacing: -0.055em;
  background: linear-gradient(100deg, #f8fafc 12%, #a5b4fc 55%, #67e8f9 100%);
  background-clip: text;
  -webkit-background-clip: text;
}

h1 { color: var(--text); }
h2 { color: #f0f4ff; }
h3 { color: #e6ecff; }
.muted { color: var(--muted); font-size: 0.9rem; line-height: 1.55; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-box {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  padding: 18px 19px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(24, 37, 63, 0.95), rgba(16, 26, 46, 0.92));
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.stat-box::after {
  position: absolute;
  right: -26px;
  bottom: -44px;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(103, 232, 249, 0.13);
  border-radius: 50%;
  box-shadow: 0 0 0 14px rgba(103, 232, 249, 0.025), 0 0 0 28px rgba(103, 232, 249, 0.02);
  content: '';
}

.stat-box:hover {
  transform: translateY(-3px);
  border-color: rgba(103, 232, 249, 0.38);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.stat-box .muted { position: relative; z-index: 1; }
.stat-num {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  color: var(--primary);
  font-size: 2rem;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.06em;
}
.stat-box:nth-child(2) .stat-num { color: #a5b4fc; }
.stat-box:nth-child(3) .stat-num { color: #fbbf24; }
.stat-box:nth-child(4) .stat-num { color: #6ee7b7; }

.tabs {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-btn {
  width: auto;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #b6c1d6;
  background: rgba(19, 30, 51, 0.86);
  cursor: pointer;
  font-weight: 650;
  transition: 160ms ease;
}

.tab-btn:hover {
  border-color: rgba(129, 140, 248, 0.42);
  color: var(--text);
  background: rgba(43, 54, 91, 0.8);
}

.tab-btn.active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(105deg, #4f46e5, #0891b2);
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.26);
}

.admin-managed-record {
  margin: 10px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 24, 42, 0.7);
}
.admin-managed-record summary { cursor: pointer; overflow-wrap: anywhere; }
.admin-managed-record summary .muted { margin-left: 8px; }
.admin-managed-record .admin-managed-json {
  min-height: 260px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.86rem;
  tab-size: 2;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-group { margin-bottom: 14px; }
label {
  display: block;
  margin-bottom: 7px;
  color: #b8c5dc;
  font-size: 0.84rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 11px;
  color: var(--text);
  background: rgba(8, 15, 29, 0.78);
  font-size: 0.95rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder { color: #71809a; }
input:hover, select:hover, textarea:hover { border-color: rgba(148, 163, 184, 0.38); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(103, 232, 249, 0.65);
  outline: none;
  background: rgba(8, 15, 29, 0.98);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.1);
}
textarea { min-height: 86px; resize: vertical; line-height: 1.55; }

button {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(105deg, #4f46e5, #0891b2);
  box-shadow: 0 8px 20px rgba(49, 46, 129, 0.2);
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 12px 25px rgba(49, 46, 129, 0.32);
}

button:active { transform: translateY(0); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 7px 11px; font-size: 0.82rem; }
.btn-success { color: #042f2e; background: linear-gradient(110deg, #6ee7b7, #34d399); box-shadow: 0 7px 18px rgba(16, 185, 129, 0.16); }
.btn-danger { color: #fff; background: linear-gradient(110deg, #f43f5e, #e11d48); }
.btn-secondary { color: #e5eaf5; border-color: var(--border); background: linear-gradient(145deg, #283650, #1a2840); box-shadow: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
}
.badge-green { border-color: rgba(52, 211, 153, 0.2); color: #6ee7b7; background: rgba(16, 185, 129, 0.12); }
.badge-yellow { border-color: rgba(251, 191, 36, 0.22); color: #fcd34d; background: rgba(245, 158, 11, 0.12); }
.badge-red { border-color: rgba(251, 113, 133, 0.22); color: #fda4af; background: rgba(244, 63, 94, 0.12); }
.badge-blue { border-color: rgba(103, 232, 249, 0.2); color: #8be9f5; background: rgba(8, 145, 178, 0.14); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 12px 10px; border-bottom: 1px solid rgba(148, 163, 184, 0.13); text-align: left; vertical-align: middle; }
th { color: #aebbd2; font-size: 0.78rem; font-weight: 750; letter-spacing: 0.045em; text-transform: uppercase; }
tbody tr { transition: background 140ms ease; }
tbody tr:hover { background: rgba(148, 163, 184, 0.045); }
.table-wrap { overflow-x: auto; border: 1px solid rgba(148, 163, 184, 0.12); border-radius: 13px; }

.lesson-box {
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  background: linear-gradient(140deg, rgba(13, 23, 41, 0.96), rgba(16, 27, 47, 0.86));
  transition: border-color 160ms ease, transform 160ms ease;
}
.lesson-box:hover { border-color: rgba(129, 140, 248, 0.34); }
.lesson-content { margin: 12px 0; color: #d7e1f3; line-height: 1.7; white-space: pre-wrap; }
.lesson-editor { width: 100%; margin-top: 10px; }
.lesson-editor summary, details summary { color: #8be9f5; cursor: pointer; font-weight: 650; }
.lesson-editor[open] { padding: 14px; border: 1px solid var(--border); border-radius: 13px; background: rgba(8, 15, 29, 0.45); }

.assignment-card,
.question-bank-item,
.parent-child {
  padding: 16px;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(8, 15, 29, 0.4);
}
.assignment-card > p { margin: 10px 0; white-space: pre-wrap; }
.assignment-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.assignment-heading > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assignment-response { margin: 14px 0; }
.assignment-question { min-width: 0; padding: 12px; margin: 10px 0; border: 1px solid var(--border); border-radius: 12px; }
.assignment-question legend { padding: 0 6px; line-height: 1.5; }
.assignment-answer { display: flex; align-items: flex-start; gap: 10px; padding: 7px 4px; cursor: pointer; }
.assignment-answer input { width: auto; margin-top: 3px; }
.assignment-question-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px; margin: 6px 0; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.assignment-question-option input { width: auto; margin-top: 3px; }
.assignment-question-option span { display: grid; gap: 4px; }
.assignment-question-option small { color: var(--muted); }
.question-bank-item summary { overflow-wrap: anywhere; }
.question-bank-item p { margin: 8px 0; line-height: 1.55; }
.grade-form { margin-top: 8px; grid-template-columns: minmax(80px, 100px) minmax(140px, 1fr) auto; align-items: center; }
.parent-child h3,
.parent-child h4 { margin: 0 0 12px; }
.parent-child h4 { margin-top: 18px; }

.notification-item {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 2fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}
.notification-item:last-child { border-bottom: 0; }
.notification-item strong { color: #dbeafe; }

.badge-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 215px;
  padding: 13px 15px;
  margin: 0 8px 8px 0;
  border: 1px solid rgba(129, 140, 248, 0.22);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.13), rgba(8, 145, 178, 0.1));
}
.badge-card > span { font-size: 1.7rem; }
.badge-card p { margin-top: 3px; }

.option-btn {
  width: 100%;
  padding: 13px 15px;
  margin-bottom: 9px;
  border: 1px solid rgba(148, 163, 184, 0.17);
  color: #e9efff;
  background: rgba(10, 19, 35, 0.84);
  box-shadow: none;
  text-align: left;
}
.option-btn:hover { border-color: rgba(103, 232, 249, 0.5); background: rgba(30, 52, 78, 0.9); }
.option-btn.selected { border-color: #67e8f9; background: linear-gradient(100deg, rgba(79, 70, 229, 0.32), rgba(8, 145, 178, 0.2)); }

.alert { padding: 13px 15px; border: 1px solid transparent; border-radius: 13px; margin-bottom: 14px; font-size: 0.92rem; line-height: 1.5; }
.alert-warn { border-color: rgba(251, 191, 36, 0.25); color: #fde68a; background: rgba(245, 158, 11, 0.09); }
.alert-danger { border-color: rgba(251, 113, 133, 0.25); color: #fecdd3; background: rgba(244, 63, 94, 0.1); }
.alert-success { border-color: rgba(52, 211, 153, 0.25); color: #a7f3d0; background: rgba(16, 185, 129, 0.1); }

.public-updates-card { max-width: 1160px; margin: 0 auto 20px; }
.public-updates-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.public-updates-heading h2 { margin-bottom: 12px; }
.site-update-item {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.site-update-item p { margin: 4px 0 3px; line-height: 1.45; }
.site-update-item time { display: block; font-size: 0.8rem; }
.site-update-admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.site-update-admin-item p { margin: 4px 0 8px; }
.badge-danger { border-color: rgba(251, 113, 133, 0.25); color: #fecdd3; background: rgba(244, 63, 94, 0.12); }
.site-update-comments { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.site-update-comments h3 { margin-bottom: 8px; }
.site-update-comment { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: rgba(8, 13, 25, 0.32); }
.site-update-comment-head { display: grid; grid-template-columns: minmax(120px, auto) 1fr auto; align-items: center; gap: 8px; }
.site-update-comment-head time { font-size: 0.78rem; }
.site-update-comment p { margin-top: 6px; white-space: pre-wrap; line-height: 1.45; }
.site-update-comment-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 12px; }
.site-update-comment-form label { grid-column: 1 / -1; font-size: 0.86rem; font-weight: 600; }
.site-update-comment-form textarea { width: 100%; resize: vertical; }

.error-report-open {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  box-shadow: var(--shadow);
}
.error-report-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.78);
}
.error-report-dialog {
  position: relative;
  width: min(100%, 520px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.error-report-dialog h2 { padding-right: 36px; margin-bottom: 8px; }
.error-report-dialog label { display: block; margin: 18px 0 7px; font-weight: 600; }
.error-report-dialog textarea { width: 100%; resize: vertical; }
.error-report-dialog input[type="file"] { width: 100%; margin-top: 6px; }
.error-report-preview { display: block; max-width: 100%; max-height: 260px; margin: 10px 0; border: 1px solid var(--border); border-radius: 12px; object-fit: contain; }
.admin-error-screenshot { display: block; max-width: min(100%, 720px); max-height: 480px; margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; object-fit: contain; }
.error-report-close { position: absolute; top: 16px; right: 16px; }
.error-report-dialog .button-row { margin-top: 16px; }

ol { padding-left: 22px; }
ol li { padding: 7px 0 7px 4px; line-height: 1.5; }
details { min-width: 70px; }
details summary { padding: 4px 0; }

@media (min-width: 701px) {
  body {
    padding: clamp(18px, 2vw, 36px);
    font-size: clamp(16px, 1vw, 19px);
  }
  main,
  .container { width: 100%; max-width: none; }
  .public-updates-card { max-width: none; }
}

@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  body {
    padding: 16px 12px env(safe-area-inset-bottom, 0);
  }
  body, main, .container { max-width: 100%; }
  .container { width: 100%; }
  .card { padding: 19px 16px; border-radius: 18px; }
  .topbar { padding: 15px 16px; flex-wrap: wrap; }
  .topbar-person { width: 100%; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .topbar-actions button,
  .topbar-actions .btn-sm { flex: 1 1 140px; min-height: 44px; }
  button, .btn-sm, .tab-btn { min-height: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .trial-question-title { align-items: flex-start; flex-direction: column; }
  .trial-account-form { min-width: 0; }
  .trial-quiz-heading { align-items: flex-start; }
  .notification-item { grid-template-columns: 1fr; gap: 4px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-btn { width: 100%; padding: 10px 8px; font-size: 0.8rem; }
  .section-nav { padding: 6px; }
  .section-nav .tab-btn { flex-basis: calc(50% - 4px); margin: 2px; }
  .button-row { display: grid; grid-template-columns: 1fr; }
  .button-row button, .button-row a { width: 100%; min-height: 44px; }
  .site-update-item { grid-template-columns: 1fr; gap: 6px; }
  .site-update-admin-item { align-items: flex-start; flex-direction: column; }
  .site-update-comment-head { grid-template-columns: 1fr auto; }
  .site-update-comment-head time { grid-column: 1 / -1; grid-row: 2; }
  .site-update-comment-form { grid-template-columns: 1fr; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-box { min-height: 94px; padding: 14px; }
  .stat-num { font-size: 1.65rem; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .profile-image-editor { align-items: flex-start; flex-direction: column; }
  .profile-avatar-large { width: 72px; height: 72px; }
  .assignment-heading { flex-direction: column; }
  .assignment-heading > div { width: 100%; }
  .assignment-heading button { width: 100%; }
  .grade-form { grid-template-columns: 1fr; }
  .grade-form input, .grade-form button { width: 100%; }
  .camera-frame { min-height: 150px; }
  .camera-frame video, .camera-frame img { max-height: 52vh; }
  .table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
  table { min-width: 680px; }
  .badge-card { min-width: 0; width: calc(50% - 8px); }
  th, td { padding: 10px 8px; }
}

@media (max-width: 420px) {
  body { padding: 9px 7px env(safe-area-inset-bottom, 0); }
  .card { padding: 15px 12px; border-radius: 16px; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; }
  .topbar-actions { display: grid; grid-template-columns: 1fr; }
  .topbar-actions button { width: 100%; white-space: normal; }
  .tabs { grid-template-columns: 1fr; }
  .section-nav .tab-btn { flex-basis: 100%; }
  .badge-card { width: 100%; margin-right: 0; }
  .account-heading { align-items: flex-start; flex-direction: column; }
  .form-group { margin-bottom: 13px; }
  .consent-row { gap: 8px; }
  .consent-row input { flex: 0 0 20px; width: 20px; min-height: 20px; }
  .lesson-box, .assignment-card, .question-bank-item, .parent-child { padding: 12px; }
  details { min-width: 0; }
  img, video { max-width: 100%; }
}

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