/* The access portal owns its colors; dashboard and browser themes must not
   leave light surfaces with inherited light text (or dark inputs). */
#auth {
  color-scheme: light;
  --auth-page: #edf5fa;
  --auth-surface: #ffffff;
  --auth-text: #102a43;
  --auth-muted: #486176;
  --auth-input: #f7fafc;
  --auth-placeholder: #52677a;
  --auth-border: #71859a;
  --auth-accent: #1769b0;
  --auth-button: #1769b0;
  --auth-button-text: #ffffff;
  --auth-disabled: #dce8f2;
  --auth-disabled-text: #334a60;
  --auth-error-bg: #fff1f2;
  --auth-error-text: #9f1239;
  --auth-success-bg: #eaf8ef;
  --auth-success-text: #166534;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--auth-page);
  color: var(--auth-text);
}

/* System preference is the default. An explicit portal/Bootstrap theme wins. */
@media (prefers-color-scheme: dark) {
  html:not([data-bs-theme="light"]):not([data-theme="light"])
  body:not([data-bs-theme="light"]):not([data-theme="light"]) #auth,
  html:not([data-bs-theme="light"]):not([data-theme="light"])
  body#auth:not([data-bs-theme="light"]):not([data-theme="light"]) {
    color-scheme: dark;
    --auth-page: #0b1724;
    --auth-surface: #142638;
    --auth-text: #edf5fc;
    --auth-muted: #b8cbdc;
    --auth-input: #0a1d30;
    --auth-placeholder: #b0c3d5;
    --auth-border: #71859a;
    --auth-accent: #8ac7ff;
    --auth-button: #8ac7ff;
    --auth-button-text: #08223a;
    --auth-disabled: #344c63;
    --auth-disabled-text: #e3edf5;
    --auth-error-bg: #461e2b;
    --auth-error-text: #fecdd3;
    --auth-success-bg: #123526;
    --auth-success-text: #b7f2ce;
  }
}

html[data-bs-theme="dark"] #auth,
html[data-theme="dark"] #auth,
body[data-bs-theme="dark"] #auth,
body[data-theme="dark"] #auth,
body#auth[data-bs-theme="dark"],
body#auth[data-theme="dark"] {
  color-scheme: dark;
  --auth-page: #0b1724;
  --auth-surface: #142638;
  --auth-text: #edf5fc;
  --auth-muted: #b8cbdc;
  --auth-input: #0a1d30;
  --auth-placeholder: #b0c3d5;
  --auth-border: #71859a;
  --auth-accent: #8ac7ff;
  --auth-button: #8ac7ff;
  --auth-button-text: #08223a;
  --auth-disabled: #344c63;
  --auth-disabled-text: #e3edf5;
  --auth-error-bg: #461e2b;
  --auth-error-text: #fecdd3;
  --auth-success-bg: #123526;
  --auth-success-text: #b7f2ce;
}

#auth .brand {
  color-scheme: dark;
  color: #ffffff;
}
#auth .brand h1 { color: #ffffff; }
#auth .brand small { color: #8ed5f2; }
#auth .brand p { color: #d7ecf7; }
#auth .form-side { min-width: 0; background: var(--auth-page); }
#auth .card {
  min-width: 0;
  max-width: 100%;
  background: var(--auth-surface);
  color: var(--auth-text);
  border: 1px solid var(--auth-border);
}
#auth .card h1,
#auth .card h2,
#auth .card label { color: var(--auth-text); }
#auth .card h1,
#auth .card h2 { font-size: clamp(24px, 3vw, 30px); overflow-wrap: anywhere; }
#auth .card .intro,
#auth .card .rules { color: var(--auth-muted); }
#auth .card .eyebrow { color: var(--auth-accent); }
#auth .card input {
  min-width: 0;
  min-height: 48px;
  background: var(--auth-input);
  color: var(--auth-text);
  caret-color: var(--auth-text);
  border-color: var(--auth-border);
}
#auth .card input::placeholder { color: var(--auth-placeholder); opacity: 1; }
#auth .card input:focus {
  border-color: var(--auth-accent);
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
  box-shadow: none;
}
#auth .card input:-webkit-autofill {
  -webkit-text-fill-color: var(--auth-text);
  -webkit-box-shadow: 0 0 0 1000px var(--auth-input) inset;
  caret-color: var(--auth-text);
}
#auth .card .primary,
#auth.auth-reset .card button {
  min-height: 48px;
  background: var(--auth-button);
  color: var(--auth-button-text);
  white-space: normal;
}
#auth .card .primary:disabled,
#auth.auth-reset .card button:disabled {
  background: var(--auth-disabled);
  color: var(--auth-disabled-text);
  opacity: 1;
  cursor: wait;
}
#auth .card .link,
#auth .card .back { color: var(--auth-accent); min-height: 44px; }
#auth .card button:focus-visible,
#auth .card a:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 3px;
}
#auth .card .error { background: var(--auth-error-bg); color: var(--auth-error-text); }
#auth .card .success { background: var(--auth-success-bg); color: var(--auth-success-text); }
#auth .card .status { overflow-wrap: anywhere; }

@media (max-width: 800px) {
  #auth .form-side { min-height: 100vh; min-height: 100dvh; padding: 16px; }
  #auth .card { padding: clamp(20px, 6vw, 28px); }
  #auth .card label { margin-top: 20px; }
}
@media (forced-colors: active) {
  #auth, #auth .brand, #auth .form-side, #auth .card,
  #auth .card .error, #auth .card .success {
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }
  #auth .brand :is(h1, p, small), #auth .card :is(h1, h2, label, .intro, .rules, .eyebrow) { color: CanvasText; }
  #auth .card input { background: Field; color: FieldText; border-color: FieldText; }
  #auth .card input::placeholder { color: GrayText; }
  #auth .card input:-webkit-autofill { -webkit-text-fill-color: FieldText; -webkit-box-shadow: none; }
  #auth .card .primary, #auth.auth-reset .card button { background: ButtonFace; color: ButtonText; border: 1px solid ButtonText; }
  #auth .card .link, #auth .card .back { color: LinkText; }
}
