/* Keystone hosted sign-in pages. One centered card on a plain page, in the console's look (the
   Neural Inverse Agents app's: compact 30 px fields and buttons, 13 px text, 12 px card corners): the
   colour tokens below carry the console's values (console/app/styles/tokens.css) for light and dark,
   selected by the colour-scheme media query. The markup is identical in both schemes; only these
   tokens change. Spacing is on a 4 px grid. Text uses Geist and Geist Mono, self-hosted (embedded in
   the binary, same origin, so the pages look the same air-gapped), with the system stack as the
   fallback. Organization branding may set --org-accent and --org-on-accent (validated hex,
   contrast-checked); everything else stays Neural Inverse. */

@font-face { font-family: "Geist"; font-style: normal; font-weight: 400; font-display: swap; src: url("/oauth2/assets/d8bce822db092746/fonts/Geist-Regular.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 500; font-display: swap; src: url("/oauth2/assets/b0a0867cda44efef/fonts/Geist-Medium.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/oauth2/assets/e4507fb4fb5f832f/fonts/GeistMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/oauth2/assets/85b99e603f84a47d/fonts/GeistMono-Medium.woff2") format("woff2"); }

:root {
  --ni-bg: #FFFFFF;
  --ni-card: #FAFAFC;
  --ni-surface: #F4F4F6;
  --ni-hover: #F2F2F4;
  --ni-fg: #202020;
  --ni-muted: #606060;
  --ni-border: #E2E2E4;
  --ni-input-border: #767676;
  --ni-accent: #0069CC;
  --ni-accent-strong: #0060BB;
  --ni-accent-subtle: #E6EEF8;
  --ni-on-accent: #FFFFFF;
  --ni-success: #388A34;
  --ni-danger: #C93C3C;
  --ni-warning: #A86A12;
  --ni-highlight: rgba(0, 105, 204, .2);
  --ni-font: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
  --ni-mono: "Geist Mono", ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ni-ease-out: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ni-bg: #181A1A;
    --ni-card: #1F2121;
    --ni-surface: #2A2C2C;
    --ni-hover: #262828;
    --ni-fg: #C8CACA;
    --ni-muted: #949696;
    --ni-border: #2C2E2E;
    --ni-input-border: #727474;
    --ni-accent: #4AA3CB;
    --ni-accent-strong: #6DB6D8;
    --ni-accent-subtle: #233138;
    --ni-on-accent: #111313;
    --ni-success: #86CF86;
    --ni-danger: #F48771;
    --ni-warning: #D7B54A;
    --ni-highlight: rgba(74, 163, 203, .3);
  }
}

:root {
  --accent: var(--org-accent, var(--ni-accent));
  --on-accent: var(--org-on-accent, var(--ni-on-accent));
  --link: var(--org-accent, var(--ni-accent-strong));
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ni-bg);
  color: var(--ni-fg);
  font-family: var(--ni-font);
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
p { margin: 0; }

/* Page: the card and, under it, the footer, both centered. */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 24px;
  gap: 12px;
}
.card {
  width: 100%;
  max-width: 400px;
  background: var(--ni-card);
  border: 1px solid var(--ni-border);
  border-radius: 12px;
  padding: 32px 32px 24px;
  animation: ni-enter 200ms var(--ni-ease-out) both;
}
@media (max-width: 480px) {
  body { background: var(--ni-card); }
  .shell { padding: 24px 16px; justify-content: flex-start; }
  .card { border: none; border-radius: 0; padding: 8px 8px 16px; }
}

/* The card's head: logo or organization, one heading, one short line. */
.brand { display: flex; justify-content: center; align-items: center; min-height: 32px; margin-bottom: 16px; }
.brand-mark { width: 24px; height: 32px; display: block; }
.org-logo { display: block; height: 32px; width: auto; max-width: 200px; object-fit: contain; }
.org-name { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; text-align: center; overflow-wrap: anywhere; }

h1 { margin: 0 0 6px; font-size: 18px; line-height: 26px; font-weight: 500; text-align: center; overflow-wrap: anywhere; }
.lead { margin: 0 0 20px; font-size: 13px; line-height: 20px; text-align: center; overflow-wrap: anywhere; }
h1 + .alert, h1 + .actions, h1 + .form { margin-top: 24px; }
.lead strong, .alert strong { font-weight: 500; }
.screen-reader { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Fields: a label over the input, a hint or the error under it. */
.form { display: flex; flex-direction: column; gap: 16px; margin: 0 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label, legend, .label { font-size: 12px; line-height: 18px; font-weight: 500; color: var(--ni-fg); }
input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--ni-input-border);
  border-radius: 6px;
  background: var(--ni-card);
  color: var(--ni-fg);
  font: inherit;
  font-size: 13px;
  line-height: 20px;
  transition: border-color 150ms var(--ni-ease-out), box-shadow 150ms var(--ni-ease-out);
}
textarea { resize: vertical; }
input[readonly] { background: var(--ni-surface); color: var(--ni-muted); border-color: var(--ni-border); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--ni-danger); box-shadow: inset 0 0 0 1px var(--ni-danger); }
.mono, code { font-family: var(--ni-mono); }
input.mono { letter-spacing: 0.08em; }
code { font-size: 13px; overflow-wrap: anywhere; }
.hint { color: var(--ni-muted); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.form > .hint, .card > .hint { margin: 0 0 16px; }
.field-error { display: flex; gap: 6px; align-items: flex-start; color: var(--ni-danger); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.field-error .icon { flex: none; width: 14px; height: 14px; margin-top: 2px; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--ni-border);
  border-radius: 6px;
  font-weight: 400;
  cursor: pointer;
}
.choice + .choice { margin-top: 8px; }
.choice:hover { background: var(--ni-hover); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--ni-accent-subtle); }
.choice input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.choice span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.choice .mono { color: var(--ni-muted); font-size: 12px; }

/* The account a step is for: the email as a chip, and the way to change it. */
.account { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; }
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 28px;
  padding: 0 10px 0 3px;
  border: 1px solid var(--ni-border);
  border-radius: 999px;
}
.account-chip .avatar { flex: none; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ni-surface); color: var(--ni-muted); }
.account-chip input[readonly] {
  min-height: 0;
  width: auto;
  min-width: 0;
  max-width: 100%;
  field-sizing: content;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ni-fg);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-overflow: ellipsis;
}
.account-chip input[readonly]:focus-visible { box-shadow: none; outline: none; }
.account-chip:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Links are underlined, never told apart by colour alone (WCAG 1.4.1). Real buttons stay plain. */
a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
a:hover { text-decoration-thickness: 2px; }
a.button-primary, a.button-secondary { text-decoration: none; }
a.button-text { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Buttons: one filled primary on the right, text actions on the left. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: normal;
  text-align: center;
  cursor: pointer;
  transition: background-color 150ms var(--ni-ease-out), opacity 150ms var(--ni-ease-out);
}
.button-primary:hover, .button-secondary:hover { text-decoration: none; }
.button[disabled] { cursor: default; opacity: .6; }
.button-primary { background: var(--accent); color: var(--on-accent); }
.button-primary:hover { opacity: .9; }
.button-secondary { color: var(--ni-fg); border-color: var(--ni-input-border); }
.button-secondary:hover { background: var(--ni-hover); }
.button-text { color: var(--link); padding: 0 8px; margin-left: -8px; }
.button-text:hover { background: var(--ni-accent-subtle); }
.button .icon { flex: none; }

/* The action row of every step. The primary action comes first in the markup, so it is the form's
   default and the next stop after the fields, and it is shown at the right edge; the secondary
   action (a text link, or two of them) is at the left edge of the same row. The secondary takes
   all the free space, so both sit on the card's content edges. When they do not fit one row
   (a long button label), they wrap and each takes the full row, the primary on top. Up to
   480 px they always stack that way. */
.actions {
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 0 0 16px;
}
.form .actions { margin: 4px 0 0; }
.actions > .button-primary { flex: 1 1 auto; }
.actions > .button-primary:only-child { flex-grow: 0; }
.actions > .button-text, .actions > .actions-alt { flex: 1000 1 auto; justify-content: flex-start; }
.actions-alt { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
@media (max-width: 480px) {
  .actions { flex-direction: column; align-items: stretch; }
  .actions > .button-primary, .actions > .button-primary:only-child { flex: none; }
  .actions > .button-text, .actions > .actions-alt { flex: none; }
}
.passkey .button { width: 100%; }
.form > .button-text { align-self: flex-start; }

/* Messages inside the card, in the console's notice style. */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px 12px 14px;
  margin: 0 0 20px;
  border-radius: 4px;
  border: 1px solid var(--ni-border);
  border-left-width: 3px;
  background: var(--ni-card);
  color: var(--ni-fg);
  overflow-wrap: anywhere;
}
.alert .icon { flex: none; margin-top: 2px; }
.alert:focus { outline: 2px solid var(--ni-danger); outline-offset: 2px; }
.alert-error { border-left-color: var(--ni-danger); }
.alert-error .icon { color: var(--ni-danger); }
.alert-error a { color: var(--ni-fg); }
.alert-success { border-left-color: var(--ni-success); }
.alert-success .icon { color: var(--ni-success); }
.alert-info { border-left-color: var(--accent); }
.alert-info .icon { color: var(--accent); }

.disclosure summary { cursor: pointer; color: var(--link); font-weight: 500; width: fit-content; }
.disclosure[open] summary { margin-bottom: 12px; }

.scopes { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--ni-border); }
.scopes li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--ni-border); }
.scopes .icon { flex: none; margin-top: 2px; color: var(--ni-muted); }

.aside { margin: 16px 0 0; color: var(--ni-muted); }
.reference { margin: 16px 0 0; color: var(--ni-muted); font-size: 12px; }
.status { display: flex; align-items: center; gap: 8px; color: var(--ni-muted); font-size: 13px; }
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--ni-border); border-top-color: var(--accent);
  animation: ni-spin 800ms linear infinite;
}

/* Multi-factor authentication setup (mfa_enroll, recovery_codes). */
h2 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--ni-accent-subtle); color: var(--ni-accent-strong); font-size: 12px; line-height: 16px; font-weight: 500; }
.method { display: flex; flex-direction: column; gap: 12px; }
.method .form { margin: 0; }
.divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--ni-muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--ni-border); }
.qr { display: flex; justify-content: center; }
.qr-code { display: block; width: 184px; max-width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--ni-border); }
.app-link { display: none; text-align: center; }
@media (hover: none) and (pointer: coarse) { .app-link { display: block; } }
.setup-key { display: flex; gap: 8px; align-items: stretch; }
.setup-key code {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 8px 12px;
  border: 1px solid var(--ni-border);
  border-radius: 4px;
  background: var(--ni-surface);
  color: var(--ni-fg);
  font-size: 14px;
  line-height: 22px;
  letter-spacing: 0.06em;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  -webkit-user-select: all;
  user-select: all;
}
.button-compact { flex: none; padding: 0 12px; }
.defer { margin: 24px 0 0; }
.codes {
  list-style: none;
  margin: 0 0 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  border: 1px solid var(--ni-border);
  border-radius: 4px;
  background: var(--ni-surface);
}
.codes code { font-size: 14px; line-height: 20px; color: var(--ni-fg); white-space: nowrap; }
@media (max-width: 380px) { .codes { grid-template-columns: minmax(0, 1fr); } }
.code-actions { display: flex; gap: 8px; margin: 0 0 8px; }
.code-actions .button { flex: 1; padding: 0 8px; }
.check { display: flex; gap: 12px; align-items: flex-start; }
.check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.check input[aria-invalid="true"] { outline: 2px solid var(--ni-danger); outline-offset: 2px; }
.check label { font-weight: 400; }

/* Under the card: who secures the page and the organization's links. The text lines up with the
   card's left and right edges (on a phone, with its content, which has no border). */
.footer {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  padding: 0;
  color: var(--ni-muted);
  font-size: 12px;
  line-height: 16px;
}
@media (max-width: 480px) { .footer { padding: 0 8px; } }
.secured { display: inline-flex; align-items: center; gap: 6px; }
.footer-mark { width: 9px; height: 12px; display: block; }
.org-links { display: flex; flex-wrap: wrap; gap: 4px 4px; margin-right: -8px; }
.org-links a { color: var(--ni-muted); font-weight: 400; padding: 4px 8px; border-radius: 4px; }
.org-links a:hover { background: var(--ni-hover); }

@media print {
  body { background: none; }
  .shell { padding: 0; min-height: 0; display: block; }
  .card { border: none; padding: 0; animation: none; max-width: none; }
  .brand, .footer, .form, .code-actions, .hint, .aside, .alert { display: none !important; }
  .codes { background: none; }
}

@keyframes ni-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ni-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-property: opacity !important;
    transition-duration: 150ms !important;
  }
}

@media (forced-colors: active) {
  .button-primary { border-color: ButtonText; }
  .alert, .account-chip, .choice { border-color: CanvasText; }
}
.social { margin-top: 8px; }
.social-form { margin: 0 0 12px; }
.social-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.social-icon { width: 18px; height: 18px; flex: none; }
.button-block { width: 100%; justify-content: center; }
