:root {
  color-scheme: dark;
  --bg: #040914;
  --surface: rgba(7, 16, 34, 0.86);
  --surface-raised: rgba(18, 35, 66, 0.88);
  --surface-soft: rgba(3, 10, 23, 0.72);
  --line: rgba(124, 166, 230, 0.16);
  --line-strong: rgba(115, 173, 255, 0.32);
  --text: #f2f7ff;
  --text-secondary: #a9b9d3;
  --text-muted: #687d9f;
  --accent: #3179f5;
  --accent-hover: #4a91ff;
  --accent-soft: rgba(52, 125, 246, 0.12);
  --success: #3fc58a;
  --success-soft: rgba(63, 197, 138, 0.12);
  --danger: #ee6a72;
  --danger-soft: rgba(238, 106, 114, 0.1);
  --warning: #e6b958;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -18%, rgba(45, 111, 233, 0.28), transparent 47%),
    radial-gradient(circle at 92% 36%, rgba(69, 74, 190, 0.12), transparent 36%),
    linear-gradient(180deg, #030711 0%, #061126 54%, #040a16 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(rgba(111, 156, 224, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 156, 224, 0.035) 1px, transparent 1px);
  background-size: 74px 74px;
  pointer-events: none;
}

body::after {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background: radial-gradient(circle at 50% 48%, rgba(18, 86, 198, 0.1), transparent 36%);
  pointer-events: none;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

button {
  color: inherit;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke-width: 1.9;
}

[hidden] {
  display: none !important;
}

.auth-topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: min(1184px, calc(100% - 48px));
  height: 76px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  color: var(--text);
  font-size: 18px;
  font-weight: 760;
  text-decoration: none;
}

.brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms ease;
}

.topbar-link:hover {
  color: var(--text);
}

.topbar-link:focus-visible,
.brand:focus-visible,
.auth-footer a:focus-visible,
.text-button:focus-visible,
.button:focus-visible,
.icon-button:focus-visible,
.input-action:focus-visible,
.auth-tab:focus-visible {
  outline: 3px solid rgba(52, 125, 246, 0.36);
  outline-offset: 3px;
}

.auth-main {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 148px);
  padding: 34px 24px 48px;
}

.auth-shell {
  display: block;
  width: min(100%, 520px);
  animation: auth-enter 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-intro {
  display: block;
  min-width: 0;
  padding: 0 24px 30px;
  text-align: center;
}

.intro-logo {
  width: 78px;
  height: 78px;
  margin: 0 auto 14px;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(40, 125, 255, 0.28));
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.4;
  text-transform: uppercase;
}

.auth-intro h1 {
  margin: 0;
  color: var(--text);
  font-size: 31px;
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(90deg, #e7f1ff 8%, #8dc7ff 56%, #46c7f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-copy {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.secure-note {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.secure-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid rgba(63, 197, 138, 0.2);
  border-radius: 8px;
}

.secure-note strong,
.secure-note small {
  display: block;
}

.secure-note strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.secure-note small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.auth-workspace {
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow:
    0 28px 78px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(49, 121, 245, 0.04),
    0 0 72px rgba(25, 104, 230, 0.1);
  backdrop-filter: blur(26px) saturate(135%);
  -webkit-backdrop-filter: blur(26px) saturate(135%);
}

.auth-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-heading h2,
.dialog-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  height: 64px;
  margin-bottom: 0;
  padding: 0;
  background: rgba(4, 11, 25, 0.36);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.auth-tab {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 650;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: color 160ms ease;
}

.auth-tab:hover {
  color: var(--text-secondary);
}

.auth-tab.active {
  color: #68adff;
}

.tab-indicator {
  position: absolute;
  top: auto;
  bottom: -1px;
  left: 0;
  width: 50%;
  height: 2px;
  background: linear-gradient(90deg, #3179f5, #43c6f4);
  border: 0;
  border-radius: 2px 2px 0 0;
  box-shadow: 0 -5px 18px rgba(58, 158, 255, 0.24);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-tabs[data-active="register"] .tab-indicator {
  transform: translateX(100%);
}

.auth-alert,
.dialog-alert,
.notice,
.verified-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: 8px;
}

.auth-alert,
.dialog-alert {
  margin: 22px 32px 0;
  padding: 11px 13px;
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-soft);
  border: 1px solid rgba(238, 106, 114, 0.2);
  animation: alert-enter 180ms ease-out both;
}

.auth-alert.success,
.dialog-alert.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(63, 197, 138, 0.22);
}

.auth-alert svg,
.dialog-alert svg,
.notice svg,
.verified-line svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.auth-panel,
.register-step,
.reset-step {
  animation: panel-enter 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-panels {
  padding: 30px 32px 32px;
}

.field-group {
  margin-bottom: 18px;
}

.field-group > label,
.label-row label {
  display: block;
  margin: 0 0 7px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 620;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.optional {
  margin-left: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.input-shell {
  position: relative;
}

.input-shell > svg {
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 1;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transform: translateY(-50%);
  transition: color 150ms ease;
}

.input-shell:focus-within > svg {
  color: var(--accent-hover);
}

.input-shell input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 44px;
  color: var(--text);
  caret-color: var(--accent-hover);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.input-shell.has-action input {
  padding-right: 48px;
}

.input-shell input::placeholder {
  color: #616975;
}

.input-shell input:hover {
  border-color: var(--line-strong);
}

.input-shell input:focus {
  background: #12151a;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 125, 246, 0.15);
}

.input-shell input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(238, 106, 114, 0.11);
}

.input-action,
.icon-button {
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, transform 100ms ease;
}

.input-action {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.input-action:hover,
.icon-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.input-action:active,
.icon-button:active {
  transform: scale(0.94);
}

.field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

.text-button {
  min-height: 32px;
  padding: 0;
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 150ms ease;
}

.text-button:hover {
  color: #72a8ff;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 680;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease, opacity 150ms ease;
}

.button.primary {
  color: #fff;
  background: linear-gradient(135deg, #285fe8, #347fff);
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(38, 107, 239, 0.28);
}

.button.primary:hover {
  background: linear-gradient(135deg, #3470f0, #4490ff);
  border-color: var(--accent-hover);
}

.button:active {
  transform: scale(0.985);
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.submit-button {
  position: relative;
  width: 100%;
}

.submit-button .button-arrow {
  width: 18px;
  height: 18px;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.submit-button:not(:disabled):hover .button-arrow {
  transform: translateX(2px);
}

.spinner {
  position: absolute;
  width: 19px;
  height: 19px;
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: spin 700ms linear infinite;
  pointer-events: none;
}

.submit-button.loading .button-label,
.submit-button.loading .button-arrow {
  opacity: 0;
}

.submit-button.loading .spinner {
  opacity: 1;
}

.step-head,
.dialog-progress {
  margin-bottom: 24px;
}

.step-head > span,
.dialog-progress > span {
  display: block;
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.step-track {
  height: 3px;
  overflow: hidden;
  background: var(--line);
  border-radius: 3px;
}

.step-track span {
  display: block;
  width: 33.333%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transition: width 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.register-step h3,
.reset-step h3 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 680;
  line-height: 1.3;
}

.step-copy {
  margin: 6px 0 22px;
  color: var(--text-secondary);
  font-size: 14px;
}

.notice {
  margin: -4px 0 18px;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.notice svg {
  color: var(--warning);
}

.code-input {
  color: var(--text) !important;
  font-size: 20px !important;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: center;
}

.resend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 8px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.button.quiet {
  color: var(--text-secondary);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.resend-row .text-button { min-height: 44px; padding: 0 10px; }
#recoverCodeWrap .resend-row { margin-bottom: 0; }

.button.quiet:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.back-button {
  width: 100%;
  margin-top: 8px;
}

.verified-line {
  width: fit-content;
  margin-bottom: 18px;
  padding: 7px 10px;
  color: var(--success);
  font-size: 12px;
  font-weight: 650;
  background: var(--success-soft);
  border: 1px solid rgba(63, 197, 138, 0.2);
}

.password-strength {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.password-strength span {
  height: 3px;
  background: var(--line);
  border-radius: 3px;
  transition: background-color 150ms ease;
}

.password-strength span.weak {
  background: var(--danger);
}

.password-strength span.medium {
  background: var(--warning);
}

.password-strength span.strong {
  background: var(--success);
}

.strength-label {
  min-height: 17px;
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  margin: 2px 0 20px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  cursor: pointer;
}

.check-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.check-box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: transparent;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.check-box svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.check-row:hover .check-box {
  border-color: #565e69;
}

.check-row input:focus-visible + .check-box {
  outline: 3px solid rgba(52, 125, 246, 0.36);
  outline-offset: 2px;
}

.check-row input:checked + .check-box {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.check-row input:checked + .check-box:active {
  transform: scale(0.92);
}

.check-row a {
  color: var(--text);
  text-decoration-color: #515966;
  text-underline-offset: 2px;
}

.check-row a:hover {
  text-decoration-color: var(--text);
}

.check-row.error .check-box {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(238, 106, 114, 0.1);
}

.check-row.error {
  color: var(--danger);
  animation: check-shake 260ms ease-out both;
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: min(520px, calc(100% - 48px));
  min-height: 72px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 12px;
}

.auth-footer nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.auth-footer a {
  text-decoration: none;
  transition: color 150ms ease;
}

.auth-footer a:hover {
  color: var(--text-secondary);
}

.reset-dialog {
  width: min(calc(100% - 32px), 480px);
  max-height: min(760px, calc(100vh - 48px));
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}

.reset-dialog[open] {
  animation: dialog-enter 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.reset-dialog::backdrop {
  background: rgba(5, 6, 8, 0.78);
  backdrop-filter: blur(8px);
  animation: backdrop-enter 180ms ease-out both;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 28px 22px;
  border-bottom: 1px solid var(--line);
}

.dialog-header .eyebrow {
  margin-bottom: 7px;
}

.dialog-header h2 {
  font-size: 23px;
}

.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dialog-progress,
.dialog-alert,
.reset-step {
  margin-right: 28px;
  margin-left: 28px;
}

.dialog-progress {
  margin-top: 22px;
}

.reset-step {
  padding-bottom: 28px;
}

@keyframes auth-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes alert-enter {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes check-shake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-4px); }
  70% { transform: translateX(3px); }
}

@media (max-width: 820px) {
  .auth-main {
    min-height: calc(100vh - 132px);
    padding-top: 18px;
    padding-bottom: 40px;
  }

  .auth-shell {
    width: min(100%, 520px);
  }
}

@media (max-height: 800px) and (min-width: 561px) {
  .auth-main {
    padding-top: 16px;
    padding-bottom: 26px;
  }

  .auth-intro {
    padding-bottom: 22px;
  }

  .intro-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
  }

  .auth-footer {
    min-height: 58px;
  }
}

@media (max-width: 560px) {
  .auth-topbar {
    width: calc(100% - 32px);
    height: 66px;
  }

  .brand {
    font-size: 17px;
  }

  .brand img {
    width: 32px;
    height: 32px;
  }

  .topbar-link span {
    display: none;
  }

  .topbar-link {
    justify-content: center;
    width: 44px;
  }

  .auth-main {
    display: block;
    min-height: calc(100vh - 122px);
    padding: 4px 16px 36px;
  }

  .auth-shell {
    width: 100%;
  }

  .auth-intro {
    padding: 0 16px 22px;
  }

  .intro-logo {
    width: 62px;
    height: 62px;
    margin-bottom: 10px;
  }

  .auth-intro h1 {
    font-size: 27px;
  }

  .intro-copy {
    font-size: 13px;
  }

  .auth-workspace {
    padding: 0;
  }

  .auth-heading {
    margin-bottom: 0;
  }

  .auth-heading h2 {
    font-size: 25px;
  }

  .auth-tabs {
    height: 58px;
    margin-bottom: 0;
  }

  .auth-panels {
    padding: 24px 20px 22px;
  }

  .auth-alert {
    margin: 18px 20px 0;
  }

  .input-shell input,
  .button {
    min-height: 48px;
  }

  .auth-footer {
    align-items: flex-start;
    width: calc(100% - 32px);
    min-height: 56px;
  }

  .auth-footer nav {
    gap: 16px;
  }

  .reset-dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 12px);
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .reset-dialog[open] {
    animation-name: sheet-enter;
  }

  .dialog-header {
    padding: 22px 20px 18px;
  }

  .dialog-header h2 {
    font-size: 21px;
  }

  .dialog-progress,
  .dialog-alert,
  .reset-step {
    margin-right: 20px;
    margin-left: 20px;
  }

  .reset-step {
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }
}

@keyframes sheet-enter {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 380px) {
  .auth-workspace {
    padding-right: 0;
    padding-left: 0;
  }

  .auth-footer {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
