:root {
  --bg: #0a101c;
  --card: rgba(20, 30, 48, 0.72);
  --card-solid: #16202f;
  --border: rgba(148, 163, 184, 0.18);
  --text: #e8eef5;
  --muted: #94a3b8;
  --accent: #10a37f;
  --accent-hover: #0d8c6d;
  --accent2: #38bdf8;
  --admin: #6d5bff;
  --admin2: #a78bfa;
  --admin-hover: #5a46f0;
  --error: #f87171;
  --input-bg: rgba(148, 163, 184, 0.07);
  --input-bg-focus: rgba(148, 163, 184, 0.12);
  --grid-line: rgba(56, 189, 248, 0.05);
  --glow: rgba(16, 163, 127, 0.35);
}

:root[data-theme="light"] {
  --bg: #eef3f9;
  --card: rgba(255, 255, 255, 0.82);
  --card-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.12);
  --text: #16232f;
  --muted: #5b6b7b;
  --input-bg: rgba(15, 23, 42, 0.04);
  --input-bg-focus: #ffffff;
  --grid-line: rgba(15, 23, 42, 0.045);
  --glow: rgba(16, 163, 127, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============ 科技感动态背景 ============ */
.login-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(56, 189, 248, 0.16) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 12% 100%, rgba(16, 163, 127, 0.12) 0%, transparent 65%),
    radial-gradient(ellipse 55% 45% at 92% 85%, rgba(109, 91, 255, 0.12) 0%, transparent 65%),
    var(--bg);
  background-size: 44px 44px, 44px 44px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
}

/* 漂浮光晕 */
.login-page::before,
.login-page::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.login-page::before {
  width: 560px; height: 560px;
  left: -140px; top: -160px;
  background: radial-gradient(circle, rgba(16, 163, 127, 0.42) 0%, rgba(20, 184, 166, 0.18) 45%, transparent 70%);
  animation: orbDrift1 16s ease-in-out infinite alternate;
}
.login-page::after {
  width: 620px; height: 620px;
  right: -180px; bottom: -200px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.36) 0%, rgba(109, 91, 255, 0.24) 50%, transparent 72%);
  animation: orbDrift2 20s ease-in-out infinite alternate;
}
:root[data-theme="light"] .login-page::before { background: radial-gradient(circle, rgba(16, 163, 127, 0.26) 0%, transparent 70%); }
:root[data-theme="light"] .login-page::after { background: radial-gradient(circle, rgba(56, 189, 248, 0.24) 0%, rgba(109, 91, 255, 0.14) 50%, transparent 72%); }

@keyframes orbDrift1 {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(110px, 90px) scale(1.2); }
}
@keyframes orbDrift2 {
  from { transform: translate(0, 0) scale(1.12); }
  to { transform: translate(-100px, -80px) scale(0.92); }
}

/* 粒子连线画布（登录首页） */
.bg-net {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 极光流动带 */
.aurora {
  position: absolute;
  z-index: -1;
  left: -30%;
  top: -55%;
  width: 160%;
  height: 120%;
  pointer-events: none;
  opacity: 0.5;
  filter: blur(60px);
  background: conic-gradient(
    from 90deg at 50% 50%,
    transparent 0deg,
    rgba(16, 163, 127, 0.2) 60deg,
    rgba(56, 189, 248, 0.24) 120deg,
    rgba(109, 91, 255, 0.18) 190deg,
    transparent 260deg,
    rgba(20, 184, 166, 0.16) 320deg,
    transparent 360deg
  );
  animation: auroraSpin 36s linear infinite;
}
:root[data-theme="light"] .aurora { opacity: 0.32; }
@keyframes auroraSpin {
  from { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.15); }
  to { transform: rotate(360deg) scale(1); }
}

/* 横向扫掠光束 */
.beam {
  position: absolute;
  z-index: -1;
  left: 0;
  width: 100%;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.5), rgba(16, 163, 127, 0.5), transparent);
  opacity: 0;
  animation: beamSweep 9s ease-in-out infinite;
}
.beam.b1 { top: 22%; animation-delay: 0s; }
.beam.b2 { top: 58%; animation-delay: 3s; }
.beam.b3 { top: 82%; animation-delay: 6s; }
:root[data-theme="light"] .beam { background: linear-gradient(90deg, transparent, rgba(2, 132, 199, 0.35), rgba(13, 140, 109, 0.35), transparent); }
@keyframes beamSweep {
  0% { transform: translateX(-100%); opacity: 0; }
  12% { opacity: 1; }
  45% { transform: translateX(100%); opacity: 0; }
  100% { transform: translateX(100%); opacity: 0; }
}

/* 漂浮代码片段（仅登录首页有此结构） */
.tech-fx { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.float-code {
  position: absolute;
  bottom: -40px;
  font-family: "Cascadia Code", ui-monospace, Consolas, monospace;
  font-size: 13px;
  color: rgba(56, 189, 248, 0.5);
  white-space: nowrap;
  animation: codeRise linear infinite;
  text-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}
.float-code:nth-child(odd) { color: rgba(16, 163, 127, 0.55); text-shadow: 0 0 14px rgba(16, 163, 127, 0.45); }
:root[data-theme="light"] .float-code { color: rgba(2, 132, 199, 0.3); text-shadow: none; }
:root[data-theme="light"] .float-code:nth-child(odd) { color: rgba(13, 140, 109, 0.32); }
.float-code.fc1 { left: 6%;  font-size: 12px; animation-duration: 26s; animation-delay: 0s; }
.float-code.fc2 { left: 18%; font-size: 15px; animation-duration: 21s; animation-delay: 6s; }
.float-code.fc3 { left: 32%; font-size: 12px; animation-duration: 30s; animation-delay: 12s; }
.float-code.fc4 { left: 55%; font-size: 13px; animation-duration: 24s; animation-delay: 3s; }
.float-code.fc5 { left: 70%; font-size: 15px; animation-duration: 19s; animation-delay: 9s; }
.float-code.fc6 { left: 84%; font-size: 12px; animation-duration: 28s; animation-delay: 15s; }
.float-code.fc7 { left: 44%; font-size: 12px; animation-duration: 32s; animation-delay: 18s; }
.float-code.fc8 { left: 92%; font-size: 13px; animation-duration: 23s; animation-delay: 1s; }

@keyframes codeRise {
  0% { transform: translateY(0); opacity: 0; }
  8% { opacity: 1; }
  85% { opacity: 0.9; }
  100% { transform: translateY(calc(-100vh - 80px)); opacity: 0; }
}

.login-home { flex-direction: column; gap: 16px; }

.icp-footer {
  width: 100%; padding: 2px 12px; color: var(--muted);
  text-align: center; font-size: 12px; line-height: 1.5;
}
.icp-footer a { color: inherit; text-decoration: none; }
.icp-footer a:hover { color: var(--text); text-decoration: underline; }

/* ============ 玻璃拟态卡片 ============ */
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--card);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px 32px;
  box-shadow:
    0 24px 64px rgba(2, 8, 20, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  animation: cardIn 0.55s cubic-bezier(0.21, 1.02, 0.73, 1) both;
}
:root[data-theme="light"] .login-card {
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.14), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}
/* 顶部渐变光条 */
.login-card::before {
  content: "";
  position: absolute;
  top: -1px; left: 24px; right: 24px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent);
  opacity: 0.85;
  animation: topbeam 4s ease-in-out infinite alternate;
}
@keyframes topbeam { from { opacity: 0.45; } to { opacity: 1; } }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.logo {
  text-align: center;
  margin-bottom: 24px;
}

.logo-icon {
  position: relative;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--accent) 0%, #0ea5a0 55%, var(--accent2) 130%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 16px;
  box-shadow: 0 8px 28px var(--glow), 0 1px 0 rgba(255, 255, 255, 0.25) inset;
  animation: logoFloat 5s ease-in-out infinite;
}
/* 呼吸光环 */
.logo-icon::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 20px;
  border: 1px solid rgba(16, 163, 127, 0.45);
  animation: ringPulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes ringPulse {
  0% { transform: scale(0.92); opacity: 0.9; }
  70% { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

.logo h1 {
  font-size: 22px;
  font-weight: 650;
  margin-bottom: 6px;
  background: linear-gradient(92deg, var(--text) 30%, var(--accent2) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.logo p {
  font-size: 14px;
  color: var(--muted);
}

/* ============ 角色切换 ============ */
.role-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}

.role-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.role-tab:hover {
  color: var(--text);
}

.role-tab.active {
  background: linear-gradient(135deg, rgba(16, 163, 127, 0.22), rgba(56, 189, 248, 0.16));
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(16, 163, 127, 0.35) inset, 0 2px 10px rgba(16, 163, 127, 0.15);
}
:root[data-theme="light"] .role-tab.active {
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(16, 163, 127, 0.35) inset, 0 2px 8px rgba(15, 23, 42, 0.1);
}

.login-form {
  display: none;
}

.login-form.active {
  display: block;
  animation: formIn 0.3s ease both;
}
@keyframes formIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

form label {
  display: block;
  margin-bottom: 16px;
}

form label span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
form input::placeholder { color: var(--muted); opacity: 0.75; }

form input:focus {
  border-color: var(--accent);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.18);
}

#adminForm input:focus,
#teacherForm input:focus {
  border-color: var(--admin);
  box-shadow: 0 0 0 3px rgba(109, 91, 255, 0.18);
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.field-hint-ok {
  color: #10a37f;
}

.field-hint-bad {
  color: #ef4444;
}

.error {
  color: var(--error);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}

button[type="submit"] {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--accent) 0%, #0ba98c 60%, #14b8a6 100%);
  color: #fff;
  border: none;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 550;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(16, 163, 127, 0.3);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
/* 扫光 */
button[type="submit"]::after {
  content: "";
  position: absolute;
  top: 0; left: -75%;
  width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
  pointer-events: none;
}
button[type="submit"]:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(16, 163, 127, 0.4); }
button[type="submit"]:hover::after { left: 125%; }
button[type="submit"]:active { transform: translateY(0); }
button[type="submit"]:disabled { opacity: 0.6; cursor: default; transform: none; filter: none; }

button.btn-admin {
  background: linear-gradient(135deg, var(--admin) 0%, #7c66ff 60%, var(--admin2) 100%);
  box-shadow: 0 6px 20px rgba(109, 91, 255, 0.3);
}

button.btn-admin:hover {
  box-shadow: 0 8px 24px rgba(109, 91, 255, 0.4);
}

.hint {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
}

.admin-hint {
  font-size: 12px;
}

.hint .link {
  color: var(--accent);
  text-decoration: none;
}

.hint .link:hover {
  text-decoration: underline;
}

.consent-hint {
  margin: 0 0 14px;
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}

.consent-hint-action {
  display: block;
  margin-top: 6px;
}

.consent-hint-action .link {
  white-space: nowrap;
}

.pw-field {
  display: block;
  position: relative;
}
.pw-field input {
  padding-right: 56px;
}
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
}
.pw-toggle:hover { color: var(--text); }

.remember-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px !important;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.remember-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.register-card {
  max-width: 440px;
}

.consent-details {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  overflow: hidden;
}

.consent-details summary {
  padding: 12px 14px;
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
  user-select: none;
}

.consent-details summary::-webkit-details-marker {
  display: none;
}

.consent-details summary::before {
  content: '▸ ';
  color: var(--muted);
}

.consent-details[open] summary::before {
  content: '▾ ';
}

.consent-details-body {
  padding: 0 14px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}

.consent-page-card {
  max-width: 520px;
}

.consent-page-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  text-align: left;
}

.consent-check {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px !important;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.consent-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

body.consent-modal-open {
  overflow: hidden;
}

.consent-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2, 8, 20, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.consent-modal.open {
  display: flex !important;
}

.consent-modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(2, 8, 20, 0.5);
  animation: cardIn 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) both;
}

.consent-modal-box h2 {
  font-size: 18px;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--border);
}

.consent-modal-body {
  padding: 16px 22px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.consent-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}

.btn-consent-primary,
.btn-consent-secondary {
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.btn-consent-primary {
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 163, 127, 0.3);
}

.btn-consent-primary:hover {
  filter: brightness(1.06);
}

.btn-consent-secondary {
  background: transparent;
  color: var(--muted);
}

.btn-consent-secondary:hover {
  color: var(--text);
  background: var(--input-bg);
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.45); }

/* 动效偏好：减少动态 */
@media (prefers-reduced-motion: reduce) {
  .login-page::before,
  .login-page::after,
  .float-code,
  .aurora,
  .beam,
  .logo-icon,
  .logo-icon::after,
  .login-card,
  .login-card::before,
  .login-form.active {
    animation: none !important;
  }
  .float-code, .beam, .bg-net { display: none; }
}

@media (max-width: 480px) {
  .login-page { min-height: 100dvh; padding: 16px; }
  .login-page::before { width: 360px; height: 360px; filter: blur(60px); }
  .login-page::after { width: 380px; height: 380px; filter: blur(60px); }
  .float-code { display: none; }
  .aurora { filter: blur(46px); opacity: 0.42; }
  .login-card { padding: 24px 20px; border-radius: 16px; }
  .logo { margin-bottom: 18px; }
  .logo-icon { width: 50px; height: 50px; margin-bottom: 12px; font-size: 26px; }
  .logo h1 { font-size: 20px; }
  .role-tabs { gap: 4px; margin-bottom: 18px; }
  .role-tab { min-height: 44px; padding: 10px 2px; font-size: 12px; white-space: nowrap; }
  form input, button[type="submit"] { min-height: 44px; }
  .consent-modal { padding: 12px; }
  .consent-modal-box { max-height: 92dvh; border-radius: 12px; }
  .consent-modal-box h2 { padding: 16px 18px 10px; }
  .consent-modal-body { padding: 14px 18px; }
  .consent-modal-actions { padding: 12px 18px 16px; }
}
