/* Student sign-in / sign-up page. Shares the checkout page's palette so the
   account surfaces read as one product. */
:root {
  color-scheme: light;
  --navy-950: #021d31;
  --navy-900: #032a44;
  --navy-800: #043e61;
  --navy-700: #07567f;
  --cyan-600: #008fbd;
  --cyan-500: #00b5e2;
  --cyan-300: #63d8f2;
  --ink: #0e2237;
  --ink-soft: #334e66;
  --muted: #62788c;
  --line: #d9e5ed;
  --line-strong: #bfd4e2;
  --surface: #ffffff;
  --surface-soft: #f5f9fb;
  --page: #edf3f7;
  --success: #16845a;
  --success-soft: #eaf8f2;
  --danger: #ac3b32;
  --danger-soft: #fff0ee;
  --shadow-md: 0 16px 44px rgba(6, 37, 59, 0.1);
  --shadow-lg: 0 28px 70px rgba(2, 29, 49, 0.17);
  --focus: 0 0 0 4px rgba(0, 181, 226, 0.22);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 14% 22%, rgba(0, 181, 226, 0.09), transparent 26rem),
    radial-gradient(circle at 88% 84%, rgba(4, 62, 97, 0.08), transparent 30rem),
    var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--navy-700); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 16px;
  background: var(--navy-900);
  color: #fff;
  border-radius: 0 0 10px 0;
  z-index: 30;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(120deg, var(--navy-950), var(--navy-800));
  color: #fff;
}
.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
/* The study app's own logo, so every account surface carries one mark. */
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: block;
}
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 17px; letter-spacing: 0.4px; }
.brand-copy small { font-size: 12px; color: rgba(226, 242, 250, 0.76); }
.secure-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(226, 242, 250, 0.86);
}
.secure-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4fd39a;
  box-shadow: 0 0 0 4px rgba(79, 211, 154, 0.2);
}

/* ---------- layout ---------- */
.auth-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: grid;
  gap: 44px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
  align-items: start;
}
@media (max-width: 900px) {
  .auth-main { grid-template-columns: minmax(0, 1fr); padding: 28px 18px 48px; gap: 28px; }
  .auth-aside { order: 2; }
}

.auth-aside { padding-top: 14px; }
.aside-kicker {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--cyan-600);
}
.auth-aside h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.6px;
  color: var(--navy-950);
}
.aside-lede {
  margin: 0 0 26px;
  max-width: 46ch;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.aside-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 16px; }
.aside-points li { display: flex; gap: 14px; align-items: flex-start; }
.aside-points li > span {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: 17px;
}
.aside-points div { display: grid; gap: 3px; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.aside-points strong { font-size: 15px; color: var(--navy-900); }

/* ---------- ECG signal panel ----------
   Same component as the checkout hero (billing.css .learning-signal), carrying
   its own dark surface because this column sits on the light page. */
.learning-signal {
  position: relative;
  margin-top: 26px;
  min-height: 190px;
  padding: 24px 22px 20px;
  overflow: hidden;
  border: 1px solid rgba(132, 211, 239, 0.18);
  border-radius: 19px;
  background:
    radial-gradient(760px 340px at 10% -20%, rgba(0, 181, 226, 0.22), transparent 60%),
    linear-gradient(158deg, #07344f 0%, #032a44 45%, #021d31 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06), var(--shadow-md);
}
.signal-caption,
.signal-modules {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.signal-caption {
  color: #80aabd;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.signal-line {
  position: relative;
  height: 74px;
  margin: 7px -22px 5px;
  overflow: hidden;
}
.signal-line::before {
  content: "";
  position: absolute;
  top: 37px;
  right: 0;
  left: 0;
  height: 1px;
  background: rgba(99, 216, 242, 0.22);
}
.signal-line::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: -18px;
  width: 24px;
  background: linear-gradient(90deg, transparent, rgba(99, 216, 242, 0.16), transparent);
  filter: blur(2px);
  animation: signal-scan 4.2s linear infinite;
}
.signal-line i {
  position: absolute;
  z-index: 1;
  display: block;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, #009dc8, #6de1f7);
  box-shadow: 0 0 8px rgba(0, 181, 226, 0.66);
  transform-origin: left center;
}
.signal-line .line-a { top: 36px; left: 0; width: 24%; }
.signal-line .line-b { top: 36px; left: 24%; width: 25px; transform: rotate(-47deg); }
.signal-line .line-c { top: 18px; left: calc(24% + 17px); width: 49px; transform: rotate(67deg); }
.signal-line .line-d { top: 63px; left: calc(24% + 37px); width: 58px; transform: rotate(-69deg); }
.signal-line .line-e { top: 9px; left: calc(24% + 58px); width: 43px; transform: rotate(66deg); }
.signal-line .line-f { top: 48px; left: calc(24% + 75px); width: 19px; transform: rotate(-39deg); }
.signal-line .line-g { top: 36px; left: calc(24% + 89px); right: 0; }
.signal-modules {
  color: #8aaebe;
  font-size: 9.5px;
  font-weight: 700;
}
.signal-modules span { display: flex; align-items: center; gap: 6px; }
.signal-modules b {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(99, 216, 242, 0.22);
  border-radius: 7px;
  background: rgba(0, 181, 226, 0.07);
  color: #8ae2f5;
  font-size: 8.5px;
}
@keyframes signal-scan {
  to { transform: translateX(430px); }
}

/* ---------- card ---------- */
.auth-panel { display: grid; gap: 14px; }
.auth-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
}
@media (max-width: 480px) { .auth-card { padding: 22px 18px; } }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.auth-tabs .tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.auth-tabs .tab.on {
  background: var(--surface);
  color: var(--navy-900);
  box-shadow: 0 1px 4px rgba(12, 42, 63, 0.14);
}
.auth-tabs .tab:focus-visible { outline: 0; box-shadow: var(--focus); }

.view-title { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.3px; color: var(--navy-950); }
.view-sub { margin: 0 0 20px; font-size: 14px; line-height: 1.55; color: var(--ink-soft); }
.view-icon {
  width: 54px;
  height: 54px;
  margin: 4px auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 24px;
}
.view-icon.success { background: var(--success-soft); border-color: #b8e6d1; color: var(--success); }
.auth-view[data-view="already"],
.auth-view[data-view="linksent"],
.auth-view[data-view="done"] { text-align: center; display: grid; gap: 10px; }

/* ---------- fields ---------- */
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-900);
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
}
.field input::placeholder { color: #9db0c1; }
.field input:focus { outline: 0; border-color: var(--cyan-500); box-shadow: var(--focus); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-link, .link {
  border: 0;
  background: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-700);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.field-link:hover, .link:hover { color: var(--cyan-600); }
.field-link:focus-visible, .link:focus-visible { outline: 0; box-shadow: var(--focus); border-radius: 4px; }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 68px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--navy-700);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.pw-toggle:hover { background: #e8f1f7; }
.pw-toggle:focus-visible { outline: 0; box-shadow: var(--focus); }

.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 2px; }
.pw-meter i { height: 4px; border-radius: 3px; background: var(--line); }
.pw-meter[data-score="1"] i:nth-child(-n+1) { background: #d9534f; }
.pw-meter[data-score="2"] i:nth-child(-n+2) { background: #e6a23c; }
.pw-meter[data-score="3"] i:nth-child(-n+3) { background: #2f9e6b; }
.pw-meter[data-score="4"] i { background: var(--success); }

/* ---------- buttons ---------- */
.btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn + .btn { margin-top: 10px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:focus-visible { outline: 0; box-shadow: var(--focus); }
.btn-primary { background: linear-gradient(120deg, var(--navy-800), var(--cyan-600)); color: #fff; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(120deg, var(--navy-700), var(--cyan-500)); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--navy-800); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 600; }
.btn-ghost:hover:not(:disabled) { color: var(--navy-800); }

.or-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.or-rule::before, .or-rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.view-foot { margin: 16px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.legal-foot { margin-top: 12px; }
.panel-foot { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.panel-legal {
  margin: 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.55;
  color: #8298aa;
}
.panel-legal b { font-weight: 700; color: #6d8296; }

/* ---------- messages ---------- */
.auth-alert, .auth-note {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid;
}
.auth-alert { background: var(--danger-soft); border-color: #f2c4bf; color: var(--danger); }
.auth-note { background: var(--success-soft); border-color: #b8e6d1; color: var(--success); }

/* ---------- code entry ---------- */
.code-inputs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.code-inputs input {
  width: 100%;
  padding: 14px 0;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--navy-950);
}
.code-inputs input:focus {
  outline: 0;
  background: var(--surface);
  border-color: var(--cyan-500);
  box-shadow: var(--focus);
}
.code-inputs.invalid input { border-color: var(--danger); }
.code-once {
  margin: -8px 0 18px;
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.code-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.dev-hint {
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-soft);
}

/* ---------- busy ---------- */
.card-busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(1px);
  z-index: 5;
}
.spinner {
  width: 26px;
  height: 26px;
  display: inline-block;
  border-radius: 50%;
  border: 3px solid rgba(4, 62, 97, 0.18);
  border-top-color: var(--cyan-600);
  animation: spin 0.7s linear infinite;
  margin: 4px auto 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .btn:active:not(:disabled) { transform: none; }
  .signal-line::after { animation: none; opacity: 0; }
}

/* Nothing flashes before the script decides which view to show. */
.auth-page.is-booting .auth-card > *:not(.card-busy) { visibility: hidden; }
.auth-page.is-booting .card-busy { display: grid !important; }
