:root {
  /* Tells the browser this page already handles its own dark styling, so
     it doesn't layer its own forced/auto-dark inversion on top of ours. */
  color-scheme: light;
  --bg: #F7F4F0;
  --surface: #FFFFFF;
  --surface-2: #F2EDE7;
  --fg: #15120F;
  --muted: #6C645C;
  --line: rgba(21, 18, 15, 0.10);
  --field: #FBF9F7;
  --shadow: 0 1px 2px rgba(21, 18, 15, 0.06), 0 18px 44px rgba(21, 18, 15, 0.10);
  --panel: #111010;
  --panel-fg: #F7F4F0;
  --accent: #F26A0C;
  --accent-strong: #D65706;
  --on-accent: #FFFFFF;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E0D0C;
  --surface: #171614;
  --surface-2: #1F1D1A;
  --fg: #F6F2ED;
  --muted: #98918A;
  --line: rgba(255, 255, 255, 0.10);
  --field: #100F0E;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 18px 44px rgba(0, 0, 0, 0.55);
  --panel: #000000;
  --panel-fg: #F6F2ED;
  --accent: #FF7A1A;
  --accent-strong: #FF9247;
  --on-accent: #14100C;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
h1, p { margin: 0; }
button { font: inherit; }

/* Any element here that sets its own `display` (flex/grid/etc.) silently
   defeats the `hidden` attribute's UA-default `display: none`, since author
   styles win ties over UA styles. registration_controller.js relies on
   `hidden` to actually hide things (the modal overlay, its code/email
   panes, error boxes) — without this, they'd render open on page load. */
[hidden] { display: none !important; }

body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--fg);
  font-family: "Manrope", sans-serif;
  padding: 24px;
  transition: background 220ms ease, color 220ms ease;
}

a { color: var(--accent); text-decoration: none; transition: color 220ms ease; }
a:hover { color: var(--accent-strong); }

.auth-flash-stack {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  width: 100%;
  max-width: 480px;
  padding: 0 24px;
}

.auth-flash {
  margin: 0;
  padding: 12px 16px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: background 220ms ease, color 220ms ease, border-color 220ms ease;
}
.auth-flash-alert { background: var(--surface); color: var(--accent-strong); border-color: var(--accent-strong); }
.auth-flash-notice { background: var(--surface); color: var(--fg); border-color: var(--line); }

.auth-card {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 220ms ease, border-color 220ms ease;
}

/* left column */

.auth-panel {
  background: var(--panel);
  color: var(--panel-fg);
  padding: 44px 40px;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  transition: background 220ms ease, color 220ms ease;
}

.auth-brand { display: flex; flex-direction: column; gap: 10px; }
.auth-brand-row { display: flex; align-items: center; gap: 10px; }

.auth-logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  flex-shrink: 0;
  transition: background 220ms ease;
}

.auth-brand-name { font-weight: 800; font-size: 17px; }

.auth-slogan {
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  transition: color 220ms ease;
}

/* headframe illustration */

.headframe { position: relative; height: 168px; overflow: hidden; flex-shrink: 0; }

.headframe .spoil-back,
.headframe .spoil-front {
  position: absolute;
  bottom: 0;
  clip-path: polygon(48% 0, 100% 100%, 0 100%);
}
.headframe .spoil-back { width: 230px; height: 100px; right: -20px; background: rgba(247, 244, 240, 0.09); }
.headframe .spoil-front { width: 150px; height: 66px; right: 84px; background: rgba(247, 244, 240, 0.16); }

.headframe .rig { position: absolute; left: 6px; bottom: 0; width: 120px; height: 164px; }

.headframe .wheel {
  position: absolute;
  left: 38px;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  transition: border-color 220ms ease;
}

.headframe .leg {
  position: absolute;
  top: 32px;
  width: 4px;
  height: 132px;
  background: rgba(247, 244, 240, 0.5);
  transform-origin: top;
}
.headframe .leg-a { left: 34px; transform: rotate(4deg); }
.headframe .leg-b { left: 74px; transform: rotate(-4deg); }

.headframe .beam { position: absolute; height: 3px; background: rgba(247, 244, 240, 0.32); }
.headframe .beam-a { top: 70px; left: 34px; width: 44px; }
.headframe .beam-b { top: 110px; left: 30px; width: 52px; }

.headframe .brace {
  position: absolute;
  left: 80px;
  top: 38px;
  width: 4px;
  height: 152px;
  background: rgba(247, 244, 240, 0.34);
  transform-origin: top left;
  transform: rotate(-34deg);
}

.headframe .base { position: absolute; left: 6px; bottom: 0; width: 100px; height: 28px; background: rgba(247, 244, 240, 0.22); }
.headframe .ground { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(247, 244, 240, 0.28); }

.auth-headline { display: flex; flex-direction: column; gap: 10px; }

.auth-headline h1 {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.03em;
}

.auth-headline p {
  font-size: 15px;
  color: rgba(247, 244, 240, 0.62);
  max-width: 30ch;
}

.auth-footer { display: flex; flex-direction: column; gap: 12px; }
.auth-footer-rule { width: 56px; height: 3px; border-radius: 2px; background: var(--accent); transition: background 220ms ease; }
.auth-footer-line { font-size: 14px; color: rgba(247, 244, 240, 0.72); }
.auth-footer-line a { font-weight: 600; }

/* right column */

.auth-form-col {
  background: var(--surface);
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: background 220ms ease;
}

.auth-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.auth-eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  transition: color 220ms ease;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 220ms ease, color 220ms ease, background 220ms ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.theme-toggle-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); flex-shrink: 0; transition: background 220ms ease; }

.auth-errors {
  border: 1px solid var(--accent-strong);
  background: rgba(214, 87, 6, 0.08);
  color: var(--accent-strong);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: color 220ms ease, border-color 220ms ease;
}

.auth-form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); transition: color 220ms ease; }

.field input {
  font-family: inherit;
  font-size: 14px;
  color: var(--fg);
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--field);
  border: 1px solid var(--line);
  outline: none;
  transition: background 220ms ease, color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}
.field input::placeholder { color: var(--muted); }
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 106, 12, 0.16);
}

.field-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
}
.field-checkbox input { accent-color: var(--accent); width: 16px; height: 16px; }

.auth-submit {
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 700;
  padding: 15px 18px;
  border-radius: 11px;
  border: none;
  cursor: pointer;
  transition: background 220ms ease, color 220ms ease, transform 100ms ease;
}
.auth-submit:hover { background: var(--accent-strong); }
.auth-submit:active { transform: translateY(1px); }

.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; transition: color 220ms ease; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); transition: background 220ms ease; }

.oauth-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.oauth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 220ms ease, background 220ms ease, color 220ms ease;
}
.oauth-btn:hover { border-color: var(--accent); }

.oauth-badge {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  color: #FFFFFF;
  flex-shrink: 0;
}

.auth-legal { font-size: 12px; color: var(--muted); line-height: 1.5; transition: color 220ms ease; }

@media (max-width: 720px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-panel { min-height: auto; }
  .oauth-grid { grid-template-columns: repeat(2, 1fr); }
}

/* confirmation modal (pending / edit email) */

.confirm-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: background 220ms ease, color 220ms ease, border-color 220ms ease;
}

.confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 220ms ease, color 220ms ease;
}

.confirm-card h1 { font-size: 22px; font-weight: 800; }
.confirm-card p { font-size: 14px; color: var(--muted); line-height: 1.5; transition: color 220ms ease; }
.confirm-card p strong { color: var(--fg); font-weight: 600; }
.confirm-card p a.confirm-email-link { color: var(--fg); font-weight: 600; transition: color 220ms ease; }
.confirm-card p a.confirm-email-link:hover { color: var(--accent); }

/* codeView/emailView (registration_controller.js's two swappable panes)
   are one level deeper than confirm-card's other direct children — without
   their own flex column + gap, everything inside would collapse together. */
.confirm-view { display: flex; flex-direction: column; gap: 18px; }

.confirm-code-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--field);
  border: 1px solid var(--line);
  transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}
.confirm-code-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 106, 12, 0.16); }

.confirm-code-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 220ms ease;
}

.confirm-code-input {
  flex: 1;
  min-width: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  letter-spacing: 0.3em;
  background: transparent;
  border: none;
  color: var(--fg);
  outline: none;
  padding: 0;
  transition: color 220ms ease;
}

.confirm-secondary {
  display: block;
  text-align: center;
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 220ms ease, background 220ms ease, color 220ms ease;
}
.confirm-secondary:hover { border-color: var(--accent); }

.confirm-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); transition: color 220ms ease; }
.confirm-meta a { font-weight: 600; }
.confirm-resend-btn { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; }
.confirm-resend-btn:hover { color: var(--accent-strong); }

/* modal overlay — the confirm-card sits on top of a dimmed registration
   backdrop (shared/_registration_backdrop), matching the reference design */

body.auth-page { position: relative; }

.auth-card[inert] {
  filter: blur(1px) brightness(0.85);
  transition: filter 220ms ease;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.confirm-card { position: relative; }

.confirm-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: border-color 220ms ease, color 220ms ease;
}
.confirm-close:hover { border-color: var(--accent); color: var(--accent); }

.confirm-backdrop-input {
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

/* Minimal centered message card — DepartmentInvitations#show's invalid/
   wrong_account states, reached without the full auth-card two-column
   form (no registration/session form belongs on either page). */
.auth-message-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  text-align: center;
}
.auth-message-card h1 { font-size: 21px; font-weight: 800; margin-bottom: 12px; }
.auth-message-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
