:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0b1220;
  --card-bg: rgba(17, 28, 48, .91);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --input-bg: #0b1628;
  --input-text: #f8fafc;
  --input-placeholder: #94a3b8;
  --input-border: #334155;
  --primary: #2563eb;
  --primary-hover: #3b82f6;
  --accent: #ec4899;
  --divider: #334155;
  --card-border: rgba(148, 163, 184, .24);
  --card-shadow: rgba(0, 0, 0, .38);
  --theme-bg: rgba(17, 28, 48, .88);
  --theme-selected: rgba(59, 130, 246, .24);
  --error: #fda4af;
  --modal-bg: #111c30;
  --backdrop: rgba(2, 6, 15, .76);
}
:root[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f1f5f9;
  --card-bg: rgba(255, 255, 255, .96);
  --text-primary: #172554;
  --text-secondary: #334155;
  --text-muted: #475569;
  --input-bg: #fff;
  --input-text: #172554;
  --input-placeholder: #64748b;
  --input-border: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #be185d;
  --divider: #e2e8f0;
  --card-border: rgba(71, 85, 105, .2);
  --card-shadow: rgba(23, 37, 84, .14);
  --theme-bg: rgba(255, 255, 255, .94);
  --theme-selected: #dbeafe;
  --error: #b91c1c;
  --modal-bg: #fff;
  --backdrop: rgba(15, 23, 42, .48);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --page-bg: #f1f5f9; --card-bg: rgba(255,255,255,.96); --text-primary: #172554;
    --text-secondary: #334155; --text-muted: #475569; --input-bg: #fff; --input-text: #172554;
    --input-placeholder: #64748b; --input-border: #cbd5e1; --primary: #2563eb;
    --primary-hover: #1d4ed8; --accent: #be185d; --divider: #e2e8f0;
    --card-border: rgba(71,85,105,.2); --card-shadow: rgba(23,37,84,.14);
    --theme-bg: rgba(255,255,255,.94); --theme-selected: #dbeafe; --error: #b91c1c;
    --modal-bg: #fff; --backdrop: rgba(15,23,42,.48);
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page-bg); }
body {
  min-height: 100vh; min-height: 100dvh; margin: 0; padding: 32px 24px; display: grid; place-items: center;
  overflow-x: hidden; color: var(--text-primary); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--page-bg);
}
button, input { font: inherit; }
button { color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.theme-switcher { position: fixed; z-index: 5; top: 18px; right: 20px; display: flex; gap: 3px; padding: 4px; border: 1px solid var(--card-border); border-radius: 11px; background: var(--theme-bg); box-shadow: 0 5px 18px var(--card-shadow); backdrop-filter: blur(12px); }
.theme-option { display: grid; place-items: center; width: 34px; height: 32px; padding: 7px; border: 0; border-radius: 7px; color: var(--text-secondary); background: transparent; cursor: pointer; }
.theme-option svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-option[aria-pressed="true"] { color: var(--text-primary); background: var(--theme-selected); }
.theme-option:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.ambient-background { position: fixed; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; background: radial-gradient(ellipse at 18% 18%, rgba(37, 99, 235, .30), transparent 42%), radial-gradient(ellipse at 84% 78%, rgba(216, 27, 135, .13), transparent 38%), linear-gradient(135deg, #0b1220, #101c31 55%, #0b1220); }
.page-glow { position: absolute; display: block; border-radius: 50%; filter: blur(70px); will-change: transform; }
.page-glow-one { width: min(40vw, 430px); aspect-ratio: 1; left: -10%; top: 8%; background: rgba(37, 99, 235, .30); animation: drift-one 26s ease-in-out infinite alternate; }
.page-glow-two { width: min(34vw, 360px); aspect-ratio: 1; right: -8%; bottom: 4%; background: rgba(216, 27, 135, .17); animation: drift-two 32s ease-in-out infinite alternate; }
.network-grid { position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(rgba(147, 197, 253, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(147, 197, 253, .08) 1px, transparent 1px); background-size: 68px 68px; mask-image: radial-gradient(ellipse at center, #000 5%, transparent 78%); }
.network-points { position: absolute; inset: 0; opacity: .35; background-image: radial-gradient(circle, rgba(191, 219, 254, .8) 1px, transparent 2px), radial-gradient(circle, rgba(244, 114, 182, .7) 1px, transparent 2px); background-size: 113px 127px, 173px 181px; background-position: 19px 31px, 73px 82px; animation: points-drift 38s linear infinite; }
@keyframes drift-one { to { transform: translate3d(8vw, 5vh, 0) scale(1.08); } }
@keyframes drift-two { to { transform: translate3d(-7vw, -5vh, 0) scale(1.12); } }
@keyframes points-drift { to { background-position: 132px 158px, -100px 263px; } }

.portal-shell { position: relative; z-index: 1; width: min(100%, 420px); margin: auto; }
.login-panel { display: flex; flex-direction: column; align-items: stretch; padding: 36px 34px 32px; border: 1px solid var(--card-border); border-radius: 22px; color: var(--text-primary); background: var(--card-bg); box-shadow: 0 24px 72px var(--card-shadow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.college-logo { display: block; width: min(190px, 70%); height: auto; margin: 0 auto 27px; object-fit: contain; }
.panel-heading { margin: 0 0 24px; text-align: center; }
.panel-heading h2, .dialog-header h2 { margin: 0; color: var(--text-primary); font-size: 26px; font-weight: 700; line-height: 1.2; letter-spacing: -.025em; }
.field-group { margin-bottom: 15px; }
.rj-input { display: block; width: 100%; min-width: 0; height: 52px; padding: 0 15px; border: 1px solid var(--input-border); border-radius: 10px; outline: none; color: var(--input-text); background: var(--input-bg); transition: border-color .15s, box-shadow .15s; }
.rj-input::placeholder { color: var(--input-placeholder); opacity: 1; }
.rj-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .16); }
.password-wrap { position: relative; }
.password-wrap .rj-input { padding-right: 66px; }
.show-password { position: absolute; top: 50%; right: 11px; transform: translateY(-50%); padding: 5px; border: 0; border-radius: 5px; color: var(--text-secondary); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.show-password:hover { color: var(--primary); }
.terms-box { margin: 10px 0 13px; padding: 13px; border: 1px solid var(--divider); border-radius: 10px; background: color-mix(in srgb, var(--card-bg) 88%, var(--page-bg)); }
.terms-check { display: flex; align-items: flex-start; gap: 10px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; cursor: pointer; }
.terms-check input { flex: 0 0 auto; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--primary); }
.text-link { display: inline; padding: 0; border: 0; color: var(--primary); background: none; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.text-link:hover { color: var(--primary-hover); }
.terms-summary { margin: 9px 0 0 27px; color: var(--text-muted); font-size: 12px; }
.login-msg { min-height: 20px; margin: 0 0 9px; color: var(--error); font-size: 13px; }
.connect-btn { width: 100%; min-height: 51px; border: 0; border-radius: 10px; color: #fff; background: var(--primary); font-weight: 700; cursor: pointer; box-shadow: 0 7px 18px rgba(37, 99, 235, .22); transition: background .15s, transform .15s, opacity .15s; }
.connect-btn:not(:disabled):hover { background: var(--primary-hover); transform: translateY(-1px); }
.connect-btn:disabled { color: #fff; background: #64748b; opacity: .72; cursor: not-allowed; box-shadow: none; }
:root[data-theme="light"] .connect-btn:disabled { background: #64748b; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .connect-btn:disabled { background: #64748b; } }

.terms-dialog { width: min(560px, calc(100% - 28px)); max-height: min(86vh, 720px); padding: 0; border: 1px solid var(--card-border); border-radius: 16px; color: var(--text-primary); background: var(--modal-bg); box-shadow: 0 25px 80px var(--card-shadow); }
.terms-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px 18px; border-bottom: 1px solid var(--divider); }
.dialog-header h2 { font-size: 22px; }
.dialog-close { width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid var(--divider); border-radius: 50%; color: var(--text-primary); background: var(--card-bg); font-size: 23px; line-height: 1; cursor: pointer; }
.terms-content { max-height: min(52vh, 430px); overflow-y: auto; padding: 20px 26px; color: var(--text-secondary); font-size: 14px; }
.terms-content p { margin: 0 0 14px; }
.terms-content ol { padding-left: 20px; }
.terms-content li { margin: 0 0 12px; padding-left: 3px; }
.dialog-done { display: block; width: calc(100% - 48px); margin: 0 24px 22px; }
.body-loading { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--page-bg); transition: opacity .2s; }
.body-loading.hide { opacity: 0; pointer-events: none; }
.loader { width: 32px; height: 32px; border: 3px solid var(--divider); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  body { padding: max(70px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom)); }
  .portal-shell { width: min(100%, 390px); }
  .login-panel { padding: 30px 24px 25px; border-radius: 19px; }
  .college-logo { width: min(170px, 72%); margin-bottom: 23px; }
  .panel-heading { margin-bottom: 21px; }
  .panel-heading h2 { font-size: 24px; }
  .field-group { margin-bottom: 13px; }
  .terms-box { margin-top: 8px; }
  .terms-summary { display: none; }
  .theme-switcher { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
  .page-glow-one { width: 65vw; filter: blur(55px); }
  .page-glow-two { width: 52vw; filter: blur(55px); }
  .network-points { opacity: .22; }
}
@media (max-width: 360px) {
  body { padding-left: 20px; padding-right: 20px; }
  .login-panel { padding: 26px 20px 22px; }
  .college-logo { width: min(155px, 72%); }
}
@media (max-height: 650px) {
  body { align-items: start; padding-top: 72px; }
  .terms-dialog { max-height: calc(100dvh - 24px); }
  .terms-content { max-height: calc(100dvh - 190px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .page-glow, .network-points { transform: none !important; }
}
