:root {
  --auth-bg: #02070d;
  --auth-surface: #08111a;
  --auth-surface-raised: #0d1823;
  --auth-border: #263848;
  --auth-text: #f3f8fb;
  --auth-muted: #a7b7c4;
  --auth-accent: #7ce8d9;
  --auth-accent-strong: #a8f3e8;
  --auth-danger: #ff9584;
  --auth-success: #8be1b7;
}

.auth-gate[hidden],
.auth-form[hidden],
.auth-link[hidden],
.auth-description[hidden],
.auth-pending[hidden],
.auth-actions[hidden] { display: none !important; }

.auth-locked { overflow: hidden; }
.auth-locked > .topbar,
.auth-locked > .shell { visibility: hidden; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  overflow-y: auto;
  padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  color: var(--auth-text);
  background:
    radial-gradient(circle at 50% 12%, rgba(55, 126, 137, .14), transparent 34%),
    linear-gradient(135deg, rgba(4, 12, 19, .82), rgba(2, 7, 13, .98)),
    repeating-linear-gradient(90deg, transparent 0 63px, rgba(124, 232, 217, .027) 64px),
    repeating-linear-gradient(0deg, transparent 0 63px, rgba(124, 232, 217, .021) 64px),
    var(--auth-bg);
}

.auth-gate::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 8%, rgba(124, 232, 217, .08) 50%, transparent 92%) 0 50% / 100% 1px no-repeat;
}

.auth-shell {
  position: relative;
  width: min(100%, 500px);
  overflow: hidden;
  border: 1px solid rgba(78, 105, 123, .66);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(13, 25, 36, .985), rgba(5, 14, 22, .995));
  box-shadow: 0 36px 110px rgba(0, 0, 0, .62), inset 0 1px rgba(255, 255, 255, .035);
}
.auth-shell::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 2px;
  background: linear-gradient(90deg, transparent 5%, rgba(124, 232, 217, .42) 30%, var(--auth-accent) 50%, rgba(124, 232, 217, .42) 70%, transparent 95%);
}
.auth-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  margin: 0;
  padding: 34px 38px 0;
}

.auth-brand > img {
  width: 54px;
  height: 54px;
  padding: 5px;
  border: 1px solid rgba(124, 232, 217, .2);
  border-radius: 14px;
  background: rgba(124, 232, 217, .035);
  object-fit: contain;
}

.auth-brand-copy { display: grid; gap: 4px; }
.auth-brand-copy .auth-brand-wordmark {
  display: block;
  width: 90px;
  height: auto;
}
.auth-brand-edition {
  color: #8fa5b4;
  font: 500 9px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.auth-panel {
  position: relative;
  z-index: 1;
  padding: 38px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.auth-panel::before {
  content: '';
  display: block;
  width: 100%;
  height: 1px;
  margin: -12px 0 30px;
  background: linear-gradient(90deg, rgba(124, 232, 217, .24), rgba(78, 105, 123, .28) 45%, transparent);
}

.auth-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 11px;
  color: var(--auth-accent);
  font: 600 10px/1.4 "IBM Plex Mono", monospace;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.auth-kicker::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--auth-accent);
  box-shadow: 0 0 14px rgba(124, 232, 217, .55);
}

.auth-panel h1 {
  margin: 0;
  color: var(--auth-text);
  font: 650 clamp(30px, 7vw, 38px)/1.08 "Space Grotesk", sans-serif;
  letter-spacing: -.035em;
}

.auth-description {
  max-width: 38ch;
  margin: 12px 0 28px;
  color: var(--auth-muted);
  font-size: 15px;
  line-height: 1.55;
}

.auth-description[hidden] + .auth-status[hidden] + .auth-form:not([hidden]) {
  margin-top: 28px;
}

.auth-form { display: grid; gap: 20px; }
.auth-field { display: grid; gap: 9px; }
.auth-field label {
  color: #c8d7df;
  font: 600 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: .06em;
}

.auth-input-wrap { position: relative; }
.auth-input-wrap input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid #2c4354;
  border-radius: 11px;
  outline: none;
  color: var(--auth-text);
  background: rgba(2, 10, 16, .76);
  box-shadow: inset 0 1px rgba(255, 255, 255, .015);
  font: 500 16px/1.2 "Space Grotesk", sans-serif;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.auth-input-wrap.has-action input { padding-right: 86px; }
.auth-input-wrap input::placeholder { color: #647889; }
.auth-input-wrap input:hover { border-color: #496276; }
.auth-input-wrap input:focus-visible {
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 3px rgba(124, 232, 217, .17);
  background: #07121b;
}

.auth-password-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 76px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--auth-accent);
  background: transparent;
  cursor: pointer;
  font: 600 11px/1 "IBM Plex Mono", monospace;
}
.auth-password-toggle:hover { background: rgba(124, 232, 217, .07); }
.auth-password-toggle:focus-visible { outline: 2px solid var(--auth-accent); outline-offset: -3px; }

.auth-helper {
  margin: 0;
  color: #8498a8;
  font-size: 12px;
  line-height: 1.45;
}

.auth-submit {
  min-height: 52px;
  border: 1px solid #a0f3e7;
  border-radius: 11px;
  color: #03100f;
  background: var(--auth-accent);
  cursor: pointer;
  font: 700 13px/1 "Space Grotesk", sans-serif;
  letter-spacing: .025em;
  transition: background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}
.auth-submit:hover { background: var(--auth-accent-strong); box-shadow: 0 8px 24px rgba(124, 232, 217, .16); }
.auth-submit:active { background: #66d5c6; }
.auth-submit:focus-visible { outline: 3px solid rgba(168, 243, 232, .45); outline-offset: 3px; }
.auth-submit:disabled { cursor: wait; opacity: .58; box-shadow: none; }
.auth-submit.is-loading { color: #17302d; }

.auth-status {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 3px solid #6d8292;
  border-radius: 4px;
  color: #dce7ed;
  background: rgba(111, 132, 148, .1);
  font-size: 13px;
  line-height: 1.45;
}
.auth-status.is-error { border-color: var(--auth-danger); color: #ffd2ca; background: rgba(255, 118, 95, .1); }
.auth-status.is-success { border-color: var(--auth-success); color: #c8f3dd; background: rgba(79, 209, 161, .09); }

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.auth-panel[data-mode="login"] .auth-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}
.auth-panel[data-mode="login"] #auth-register {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid #324b5d;
  border-radius: 10px;
  color: #d6e3e9;
  background: rgba(20, 37, 49, .48);
  text-align: center;
  text-decoration: none;
}
.auth-panel[data-mode="login"] #auth-register:hover {
  border-color: rgba(124, 232, 217, .55);
  color: var(--auth-accent);
  background: rgba(124, 232, 217, .055);
}
.auth-link {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  color: var(--auth-muted);
  background: transparent;
  cursor: pointer;
  font: 600 12px/1.2 "Space Grotesk", sans-serif;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}
.auth-link:hover { color: var(--auth-accent); text-decoration-color: currentColor; }
.auth-link:focus-visible { outline: 2px solid var(--auth-accent); outline-offset: 3px; }

.auth-pending {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}
.auth-pending-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 4px;
  border: 1px solid rgba(241, 197, 106, .42);
  border-radius: 50%;
  color: #f1c56a;
  background: rgba(241, 197, 106, .08);
}
.auth-pending-icon svg {
  width: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.auth-pending.is-rejected .auth-pending-icon {
  border-color: rgba(255, 149, 132, .45);
  color: var(--auth-danger);
  background: rgba(255, 149, 132, .08);
}
.auth-pending strong {
  color: var(--auth-text);
  font: 650 18px/1.25 "Space Grotesk", sans-serif;
}
.auth-pending p {
  max-width: 34ch;
  margin: 0 0 8px;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.55;
}
.auth-pending .auth-submit { width: 100%; }


.auth-session-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.auth-user {
  max-width: 220px;
  overflow: hidden;
  color: #aebfca;
  font: 500 11px/1.2 "IBM Plex Mono", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-logout {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid #33495b;
  border-radius: 6px;
  color: #c9d6de;
  background: #0b141d;
  cursor: pointer;
  font: 600 11px/1 "Space Grotesk", sans-serif;
}
.auth-logout:hover { border-color: #607789; color: #fff; }
.auth-logout:focus-visible { outline: 2px solid var(--auth-accent); outline-offset: 2px; }
.auth-logout:disabled { cursor: wait; opacity: .5; }

@media (max-width: 720px) {
  .auth-gate { padding-inline: 14px; }
  .auth-shell { border-radius: 18px; }
  .auth-brand { padding: 26px 24px 0; }
  .auth-brand > img { width: 48px; height: 48px; border-radius: 12px; }
  .auth-brand-copy .auth-brand-wordmark { width: 82px; }
  .auth-panel { padding: 32px 24px 30px; }
  .auth-panel::before { margin-top: -10px; margin-bottom: 26px; }
  .auth-user { display: none; }
  .auth-session-controls { margin-left: 0; }
}

@media (max-width: 420px) {
  .auth-panel[data-mode="login"] .auth-actions { grid-template-columns: 1fr; gap: 6px; }
  .auth-panel[data-mode="login"] #auth-forgot { justify-self: center; }
  .auth-actions { align-items: stretch; flex-direction: column; gap: 4px; }
  .auth-link { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-input-wrap input,
  .auth-submit,
  .auth-link { transition: none; }
}
