/* ============================================================
   RAKEEN ◇ AUTH — sovereign access portal
   Reads from tokens.css. Locked to cyber/dark — login is always
   a "command-center" surface regardless of page theme.
============================================================ */

:root {
  --auth-bg:        #050A1A;
  --auth-bg-2:      #08132E;
  --auth-bg-3:      #0C2144;
  --auth-fg:        #F3F8F8;
  --auth-fg-mute:   rgba(243, 248, 248, 0.62);
  --auth-fg-faint:  rgba(243, 248, 248, 0.38);
  --auth-border:    rgba(123, 224, 255, 0.10);
  --auth-border-2:  rgba(123, 224, 255, 0.22);
  --auth-grid:      rgba(123, 224, 255, 0.06);
  --auth-blue:      var(--rk-blue);
  --auth-signal:    var(--rk-signal);
  --auth-crit:      #FF5470;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  background: var(--auth-bg);
  color: var(--auth-fg);
  font-family: var(--ff-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(ellipse 70% 50% at 30% 30%, rgba(58,93,192,0.18), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(123,224,255,0.10), transparent 70%),
    var(--auth-bg);
  position: relative;
}

::selection { background: var(--auth-signal); color: var(--auth-bg-3); }

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img, svg { display: block; max-width: 100%; height: auto; }

/* =========================================================
   STAGE — background grid, particles, scan
   ========================================================= */
.auth-stage {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  overflow: hidden;
}

.auth-stage__grid {
  position: absolute; inset: -5%;
  background-image:
    linear-gradient(to right, var(--auth-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--auth-grid) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 0%, transparent 90%);
          mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 0%, transparent 90%);
  transform: translate3d(0, 0, 0);
  transition: transform 1.6s var(--ease-out);
}

/* Scan line that sweeps top→bottom every 6s */
.auth-stage__scan {
  position: absolute; left: 0; right: 0;
  height: 200px;
  background: linear-gradient(to bottom, transparent, rgba(123,224,255,0.06), transparent);
  animation: scanSweep 6s linear infinite;
  pointer-events: none;
}
@keyframes scanSweep {
  0%   { top: -20%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Constellation of slow-drifting particles */
.auth-stage__dots {
  position: absolute; inset: 0;
}
.auth-stage__dot {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--auth-signal);
  box-shadow: 0 0 8px var(--auth-signal);
  opacity: 0.4;
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.6; }
  100% { transform: translate3d(var(--dx, 80px), var(--dy, -120px), 0); opacity: 0; }
}

/* Corner brackets — frame the experience */
.auth-stage__corner {
  position: absolute;
  width: 32px; height: 32px;
  border: 1px solid var(--auth-border-2);
  opacity: 0.6;
}
.auth-stage__corner.tl { top: 24px; left: 24px; border-right: none; border-bottom: none; }
.auth-stage__corner.tr { top: 24px; right: 24px; border-left: none; border-bottom: none; }
.auth-stage__corner.bl { bottom: 24px; left: 24px; border-right: none; border-top: none; }
.auth-stage__corner.br { bottom: 24px; right: 24px; border-left: none; border-top: none; }

/* =========================================================
   TOP BAR — telemetry, brand, language switch
   ========================================================= */
.auth-top {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 4;
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 56px;
}
.auth-top__brand {
  display: flex; align-items: center;
}
.auth-top__brand svg { height: 22px; width: auto; }
.auth-top__telemetry {
  display: flex; align-items: center; gap: 20px;
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--auth-fg-mute);
}
.auth-top__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #57E0A6;
  box-shadow: 0 0 8px #57E0A6;
  animation: dotPulse 2s infinite ease-out;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}
.auth-top__sep { color: var(--auth-fg-faint); }

/* =========================================================
   LAYOUT — split screen
   ========================================================= */
.auth {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 96px 56px 56px;
  gap: 56px;
}

/* =========================================================
   LEFT — animated R-mark portal
   ========================================================= */
.portal {
  position: relative;
  display: grid; place-items: center;
  min-height: 600px;
  perspective: 1200px;
}
.portal__inner {
  position: relative;
  width: 480px; height: 480px;
  max-width: 80vmin; max-height: 80vmin;
  display: grid; place-items: center;
}

/* The R-mark center, with idle breathe */
.portal__mark {
  position: relative;
  z-index: 3;
  width: 56%;
  filter: drop-shadow(0 0 32px rgba(123,224,255,0.4));
  animation: markBreathe 4s infinite ease-in-out;
  transition:
    filter 600ms var(--ease-out),
    transform 600ms var(--ease-out);
  transform-origin: center;
  will-change: transform, filter;
}
.portal__mark svg { width: 100%; height: auto; }
.portal__mark svg path { fill: var(--auth-signal); transition: fill 400ms var(--ease-out); }

@keyframes markBreathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 32px rgba(123,224,255,0.4)); }
  50%      { transform: scale(1.04); filter: drop-shadow(0 0 48px rgba(123,224,255,0.7)); }
}

/* Concentric rings — idle slow pulse + bursts on success */
.portal__ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--auth-border-2);
  pointer-events: none;
  transition: opacity 400ms var(--ease-out);
}
.portal__ring.r1 { width: 70%;  height: 70%;  animation: ringPulse 4s infinite ease-in-out; }
.portal__ring.r2 { width: 85%;  height: 85%;  animation: ringPulse 4s infinite ease-in-out 0.6s; }
.portal__ring.r3 { width: 100%; height: 100%; animation: ringPulse 4s infinite ease-in-out 1.2s; }
@keyframes ringPulse {
  0%, 100% { opacity: 0.18; transform: scale(0.96); }
  50%      { opacity: 0.45; transform: scale(1); }
}

/* Orbiting telemetry tag — small monospace label on outer ring */
.portal__tag {
  position: absolute;
  top: 50%; left: 50%;
  width: 130%; height: 130%;
  margin: -65% 0 0 -65%;
  animation: orbit 20s linear infinite;
  pointer-events: none;
}
.portal__tag-text {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  background: var(--auth-bg-2);
  padding: 6px 12px;
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--auth-signal);
  border: 1px solid var(--auth-border-2);
}
@keyframes orbit {
  to { transform: rotate(360deg); }
}
.portal__tag-text { animation: counter-orbit 20s linear infinite; }
@keyframes counter-orbit {
  to { transform: translateX(-50%) rotate(-360deg); }
}

/* Crosshair lines */
.portal__cross {
  position: absolute;
  background: var(--auth-border-2);
}
.portal__cross.h { left: -10%; right: -10%; height: 1px; top: 50%; }
.portal__cross.v { top: -10%; bottom: -10%; width: 1px; left: 50%; }

/* Internal scan-line that sweeps across the mark */
.portal__scan {
  position: absolute;
  top: 25%; bottom: 25%;
  left: 50%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--auth-signal), transparent);
  box-shadow: 0 0 12px var(--auth-signal);
  animation: portalScan 3s infinite ease-in-out;
  pointer-events: none;
  z-index: 2;
  opacity: 0.7;
}
@keyframes portalScan {
  0%, 100% { left: 25%; opacity: 0; }
  20%      { opacity: 0.7; }
  80%      { opacity: 0.7; }
  50%      { left: 75%; opacity: 1; }
}

/* Burst rings — fired on success */
.portal__burst {
  position: absolute;
  top: 50%; left: 50%;
  width: 100px; height: 100px;
  margin: -50px 0 0 -50px;
  border-radius: 50%;
  border: 2px solid var(--auth-signal);
  pointer-events: none;
  opacity: 0;
}
.auth.is-success .portal__burst {
  animation: portalBurst 1.6s var(--ease-out) forwards;
}
.auth.is-success .portal__burst.b2 { animation-delay: 0.18s; }
.auth.is-success .portal__burst.b3 { animation-delay: 0.36s; }
@keyframes portalBurst {
  0%   { opacity: 0.9; transform: scale(0); }
  100% { opacity: 0; transform: scale(8); }
}

/* Success: mark scales up + halo */
.auth.is-success .portal__mark {
  transform: scale(1.18);
  filter: drop-shadow(0 0 64px var(--auth-signal)) drop-shadow(0 0 120px rgba(123,224,255,0.6));
  animation: none;
}
.auth.is-fail .portal__mark {
  animation: markGlitch 0.6s ease-in-out 3;
}
.auth.is-fail .portal__mark svg path { fill: var(--auth-crit); }
@keyframes markGlitch {
  0%   { transform: translate(0, 0); filter: hue-rotate(0deg); }
  20%  { transform: translate(-6px, 2px); filter: hue-rotate(60deg) blur(1px); }
  40%  { transform: translate(4px, -2px); filter: hue-rotate(-30deg); }
  60%  { transform: translate(-2px, 3px); filter: none; }
  80%  { transform: translate(2px, -1px); filter: blur(0.5px); }
  100% { transform: translate(0, 0); filter: none; }
}

/* Stat tickers below portal */
.portal__stats {
  position: absolute;
  bottom: -40px; left: 0; right: 0;
  display: flex; justify-content: space-around;
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--auth-fg-faint);
}
.portal__stats span { white-space: nowrap; }
.portal__stats strong { color: var(--auth-signal); font-weight: 500; }

/* =========================================================
   RIGHT — form panel
   ========================================================= */
.auth-form {
  width: 100%; max-width: 460px;
  margin-left: auto;
}

.auth-form__eyebrow {
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--auth-signal);
  margin-bottom: 16px;
  display: inline-flex; align-items: center; gap: 8px;
}
.auth-form__eyebrow::before {
  content: '';
  width: 24px; height: 1px;
  background: var(--auth-signal);
}

.auth-form__h {
  font-family: var(--ff-display);
  font-size: clamp(32px, 4vw, 56px);
  letter-spacing: 0.02em;
  line-height: 1.0;
  text-transform: uppercase;
  margin: 0 0 12px;
  color: var(--auth-fg);
}
.auth-form__sub {
  font-family: var(--ff-body);
  font-size: 1rem;
  color: var(--auth-fg-mute);
  margin: 0 0 36px;
  max-width: 380px;
}
.auth-form__sub em { color: var(--auth-signal); font-style: normal; }

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

.field {
  display: flex; flex-direction: column; gap: 8px;
}
.field__label {
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--auth-fg-mute);
}
.field__wrap {
  position: relative;
}
.field__icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--auth-fg-faint);
  transition: color 200ms var(--ease-out);
  pointer-events: none;
}
.field__wrap:focus-within .field__icon { color: var(--auth-signal); }
.field input {
  width: 100%;
  background: var(--auth-bg-2);
  border: 1px solid var(--auth-border);
  border-radius: 6px;
  padding: 14px 16px 14px 42px;
  color: var(--auth-fg);
  font-family: var(--ff-body);
  font-size: 0.9375rem;
  transition: all 200ms var(--ease-out);
}
.field input::placeholder { color: var(--auth-fg-faint); }
.field input:focus {
  outline: none;
  border-color: var(--auth-signal);
  box-shadow: 0 0 0 3px rgba(123,224,255,0.18);
}
.field--error input {
  border-color: var(--auth-crit);
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.field__eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--auth-fg-faint);
  border-radius: 4px;
}
.field__eye:hover { color: var(--auth-signal); background: rgba(123,224,255,0.08); }
.field__eye svg { width: 16px; height: 16px; }

.field__hint {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px;
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.field__hint--caps { color: #FFC857; }
.field__hint--strength { color: var(--auth-fg-mute); }
.field__hint .meter {
  flex: 1; height: 2px;
  background: var(--auth-border);
  border-radius: 1px;
  overflow: hidden;
}
.field__hint .meter__bar {
  height: 100%;
  background: var(--auth-signal);
  width: 0;
  transition: width 200ms var(--ease-out), background 200ms var(--ease-out);
}

/* Specific inline error — appears under the field with a red icon + message */
.field__error {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 6px;
  padding: 6px 0;
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  line-height: 1.45;
  letter-spacing: 0.06em;
  color: var(--auth-crit);
  animation: errSlide 280ms cubic-bezier(0.22, 1, 0.36, 1);
}
.field__error svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
@keyframes errSlide {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Row: remember + forgot */
.auth-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px;
  margin-bottom: 4px;
}
.auth-check {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--ff-body);
  font-size: 0.8125rem;
  color: var(--auth-fg-mute);
  cursor: pointer;
  user-select: none;
}
.auth-check__box {
  width: 16px; height: 16px;
  border: 1px solid var(--auth-border-2);
  border-radius: 3px;
  background: var(--auth-bg-2);
  display: grid; place-items: center;
  transition: all 200ms var(--ease-out);
}
.auth-check__box svg { width: 10px; height: 10px; color: var(--auth-bg-3); opacity: 0; }
.auth-check input { display: none; }
.auth-check input:checked + .auth-check__box {
  background: var(--auth-signal); border-color: var(--auth-signal);
}
.auth-check input:checked + .auth-check__box svg { opacity: 1; }
.auth-link {
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--auth-fg-mute);
  transition: color 200ms var(--ease-out);
}
.auth-link:hover { color: var(--auth-signal); }

/* Submit button */
.auth-submit {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 16px 24px;
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--auth-blue);
  color: var(--auth-fg);
  border-radius: 6px;
  margin-top: 8px;
  overflow: hidden;
  transition: all 200ms var(--ease-out);
  font-weight: 500;
}
.auth-submit:not(:disabled):hover {
  background: color-mix(in oklab, var(--auth-blue) 86%, white);
  box-shadow: 0 0 0 1px var(--auth-signal), 0 0 32px rgba(123,224,255,0.32);
  transform: translateY(-1px);
}
.auth-submit svg { width: 16px; height: 16px; }
.auth-submit:disabled { cursor: not-allowed; opacity: 0.5; }

.auth-submit__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 200ms var(--ease-out);
}
.auth-submit__label svg { width: 16px; height: 16px; flex-shrink: 0; }
.auth-submit.is-loading .auth-submit__label,
.auth-submit.is-success .auth-submit__label,
.auth-submit.is-fail .auth-submit__label { opacity: 0; }

.auth-submit__spinner {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  border: 2px solid rgba(243,248,248,0.3);
  border-top-color: var(--auth-fg);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.8s linear infinite;
}
.auth-submit.is-loading .auth-submit__spinner { opacity: 1; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.auth-submit__check {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0);
  width: 22px; height: 22px;
  color: var(--auth-fg);
  opacity: 0;
}
.auth-submit.is-success {
  background: #1B7C4F;
  box-shadow: 0 0 0 1px #57E0A6, 0 0 32px rgba(87,224,166,0.42);
}
.auth-submit.is-success .auth-submit__check {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  transition: all 300ms var(--ease-spring);
}
.auth-submit.is-fail {
  background: #8A2230;
  box-shadow: 0 0 0 1px var(--auth-crit), 0 0 32px rgba(255,84,112,0.32);
  animation: shake 0.4s ease-in-out;
}

/* SSO link */
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 0;
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--auth-fg-faint);
}
.auth-divider::before,
.auth-divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--auth-border);
}
.auth-sso {
  width: 100%;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: transparent;
  border: 1px solid var(--auth-border-2);
  border-radius: 6px;
  color: var(--auth-fg-mute);
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: all 200ms var(--ease-out);
}
.auth-sso:hover { border-color: var(--auth-signal); color: var(--auth-signal); }
.auth-sso svg { width: 14px; height: 14px; }

/* =========================================================
   TERMINAL — auth telemetry below form
   ========================================================= */
.terminal {
  margin-top: 32px;
  background: var(--auth-bg);
  border: 1px solid var(--auth-border);
  border-radius: 6px;
  padding: 12px 16px;
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  line-height: 1.7;
  color: var(--auth-fg-mute);
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
  position: relative;
}
.terminal__header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.5625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--auth-fg-faint);
  border-bottom: 1px solid var(--auth-border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.terminal__dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--auth-fg-faint);
  margin-right: 8px;
  transition: background 200ms;
}
.terminal__dot.is-live { background: var(--auth-signal); box-shadow: 0 0 8px var(--auth-signal); animation: dotPulse 1.4s infinite; }
.terminal__line {
  display: flex; align-items: baseline; gap: 8px;
  white-space: pre;
  opacity: 0;
  animation: termIn 0.18s ease-out forwards;
}
@keyframes termIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}
.terminal__line .t-prompt { color: var(--auth-fg-faint); }
.terminal__line .t-ok { color: #57E0A6; }
.terminal__line .t-warn { color: #FFC857; }
.terminal__line .t-err { color: var(--auth-crit); }
.terminal__line.is-typing::after {
  content: '';
  display: inline-block;
  width: 6px; height: 12px;
  background: var(--auth-signal);
  margin-left: 4px;
  animation: blink 0.7s steps(1) infinite;
}
@keyframes blink { 0%,50% { opacity:1 } 50.01%,100% { opacity:0 } }

/* =========================================================
   BANNER — appears on success/fail
   ========================================================= */
.auth-banner {
  margin-top: 24px;
  padding: 16px 20px;
  border-radius: 6px;
  border-left: 3px solid var(--auth-signal);
  background: rgba(123,224,255,0.06);
  display: flex; align-items: flex-start; gap: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 400ms var(--ease-out), transform 400ms var(--ease-out);
  pointer-events: none;
}
.auth-banner.is-on { opacity: 1; transform: translateY(0); pointer-events: auto; }
.auth-banner--ok { border-color: #57E0A6; background: rgba(87,224,166,0.08); }
.auth-banner--fail { border-color: var(--auth-crit); background: rgba(255,84,112,0.08); }
.auth-banner__icon { color: var(--auth-signal); flex-shrink: 0; }
.auth-banner--ok .auth-banner__icon { color: #57E0A6; }
.auth-banner--fail .auth-banner__icon { color: var(--auth-crit); }
.auth-banner__icon svg { width: 24px; height: 24px; }
.auth-banner__title {
  font-family: var(--ff-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--auth-fg);
  margin-bottom: 4px;
}
.auth-banner__msg {
  font-size: 0.8125rem;
  color: var(--auth-fg-mute);
  line-height: 1.5;
}
.auth-banner__msg strong { color: var(--auth-fg); font-weight: 500; }

/* =========================================================
   BOTTOM — secondary metadata + lang switch
   ========================================================= */
.auth-bottom {
  position: fixed; bottom: 24px; left: 56px; right: 56px;
  z-index: 4;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--auth-fg-faint);
}
.auth-bottom__lang {
  display: inline-flex; align-items: center; gap: 8px;
}
.auth-bottom__lang button {
  font-family: var(--ff-mono);
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--auth-fg-faint);
  padding: 4px 8px;
  transition: color 200ms var(--ease-out);
}
.auth-bottom__lang button.active { color: var(--auth-signal); }
.auth-bottom__lang button:hover { color: var(--auth-fg); }
.auth-bottom__lang .sep { color: var(--auth-fg-faint); opacity: 0.4; }

/* =========================================================
   PORTAL TRANSITION (success → brand kit)
   ========================================================= */
.portal-transition {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(circle at center, var(--auth-signal) 0%, var(--auth-bg) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms var(--ease-out);
}
.auth.is-transition .portal-transition { opacity: 1; pointer-events: auto; }
.portal-transition::after {
  content: '';
  position: absolute; inset: 0;
  background: white;
  opacity: 0;
}
.auth.is-transition .portal-transition::after {
  animation: whiteOut 800ms 400ms ease-out forwards;
}
@keyframes whiteOut {
  to { opacity: 1; }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1180px) {
  .auth { padding: 88px 40px 72px; gap: 40px; }
  .auth-top { padding: 20px 40px; }
  .auth-bottom { left: 40px; right: 40px; }
  .portal__inner { width: 420px; height: 420px; }
}

@media (max-width: 980px) {
  .auth {
    grid-template-columns: 1fr;
    padding: 88px 24px 96px;
    gap: 24px;
  }
  .portal { min-height: 340px; order: -1; }
  .portal__inner { width: 300px; height: 300px; }
  .portal__stats { bottom: -32px; gap: 14px; flex-wrap: wrap; justify-content: center; }
  .auth-form { max-width: 100%; margin: 0 auto; }
  .auth-form__h { font-size: clamp(28px, 7vw, 44px); }
  .auth-form__sub { font-size: 0.9375rem; margin-bottom: 24px; }
  .auth-top { padding: 16px 24px; }
  .auth-bottom { left: 24px; right: 24px; bottom: 16px; gap: 12px; }
  .auth-stage__corner { width: 20px; height: 20px; }
  .auth-stage__corner.tl, .auth-stage__corner.tr { top: 12px; }
  .auth-stage__corner.bl, .auth-stage__corner.br { bottom: 12px; }
  .auth-stage__corner.tl, .auth-stage__corner.bl { left: 12px; }
  .auth-stage__corner.tr, .auth-stage__corner.br { right: 12px; }
  .terminal { min-height: 100px; max-height: 160px; font-size: 0.66rem; }
}

@media (max-width: 720px) {
  .auth { padding: 84px 18px 24px; gap: 20px; }
  .portal { min-height: 280px; }
  .portal__inner { width: 240px; height: 240px; max-width: 70vmin; max-height: 70vmin; }
  .portal__tag { display: none; }   /* orbiting tag clips at very small widths */
  .portal__stats { font-size: 0.5625rem; gap: 10px; }
  .auth-top { padding: 12px 18px; }
  .auth-top__brand svg { height: 18px; }
  .auth-form__eyebrow { font-size: 0.625rem; margin-bottom: 12px; }
  .auth-form__h { font-size: clamp(26px, 8vw, 38px); }
  .field input { padding: 13px 14px 13px 38px; font-size: 0.9rem; }
  .field__icon { left: 12px; width: 15px; height: 15px; }
  .auth-submit { padding: 15px 20px; }
  .auth-sso { padding: 13px 18px; font-size: 0.625rem; }
  /* Footer flows in document order on mobile (no longer fixed-overlay) */
  .auth-bottom {
    position: static;
    margin: 28px 0 0;
    padding: 16px 4px 0;
    border-top: 1px solid var(--auth-border);
    flex-wrap: wrap; row-gap: 8px; column-gap: 14px;
    font-size: 0.5625rem;
  }
}

@media (max-width: 560px) {
  .auth-top__telemetry { display: none; }
  .auth-bottom__lang { order: -1; }
  .auth-bottom span:nth-child(2) {        /* hint line: keep at the end */
    flex-basis: 100%;
    color: var(--auth-fg-faint);
    opacity: 0.85;
  }
  .auth-divider { margin: 6px 0; }
  .portal__inner { width: 220px; height: 220px; }
}

/* Touch targets: bump on coarse-pointer devices for thumb-friendliness */
@media (pointer: coarse) {
  .auth-submit { padding: 17px 24px; }
  .field__eye { width: 36px; height: 36px; }
  .auth-bottom__lang button { padding: 6px 10px; }
}

/* Reduce idle motion on small + low-power viewports if user prefers */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
