: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-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 {
  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;
}

.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); }

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 (max-width: 700px) {
  body { padding: 16px 12px; }
  .card { padding: 19px 16px; border-radius: 18px; }
  .topbar { padding: 15px 16px; }
  .topbar-actions { justify-content: flex-end; }
  .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; }
  .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; }
  th, td { padding: 10px 8px; }
}

@media (max-width: 420px) {
  body { padding: 12px 9px; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .topbar-actions button { white-space: nowrap; }
  .badge-card { width: 100%; }
  .account-heading { align-items: flex-start; flex-direction: column; }
}

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