:root {
  --auth-accent: #55f4dc;
  --auth-accent-strong: #9a7cff;
  --auth-cyan: #55f4dc;
  --auth-violet: #9a7cff;
  --auth-ink: #f5f7ff;
  --auth-muted: #a7aab3;
  --auth-surface: rgba(42, 42, 42, 0.97);
  --auth-border: rgba(255, 255, 255, 0.14);
}

[hidden] {
  display: none !important;
}

html.auth-pending,
html.auth-pending body {
  background: #000;
}

body.auth-locked {
  overflow: hidden;
}

#auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  align-items: start;
  justify-items: end;
  min-width: 280px;
  min-height: 420px;
  padding: 24px;
  overflow: auto;
  color: var(--auth-ink);
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(3px);
  font-family: "Open Sans", "Helvetica Neue", Arial, sans-serif;
  isolation: isolate;
}

.auth-card {
  position: relative;
  width: min(390px, 100%);
  padding: 23px 26px 20px;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  background: linear-gradient(155deg, rgba(51, 51, 51, 0.98), var(--auth-surface));
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.52),
    0 0 0 1px rgba(255, 255, 255, 0.025) inset,
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  backdrop-filter: blur(16px);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 25%;
  width: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--auth-cyan), var(--auth-violet), transparent);
}

.auth-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(85, 244, 220, 0.34);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(85, 244, 220, 0.16), rgba(154, 124, 255, 0.12));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.16);
}

.auth-brand-mark::before,
.auth-brand-mark::after,
.auth-brand-mark span {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.auth-brand-mark::before {
  width: 15px;
  height: 15px;
  border: 2px solid #fff;
  transform: rotate(30deg) skew(-4deg, -4deg);
}

.auth-brand-mark::after {
  width: 2px;
  height: 12px;
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(5px);
}

.auth-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.auth-brand-copy strong {
  color: #fff;
  font-size: 17px;
  letter-spacing: 0.015em;
}

.auth-brand-copy small {
  margin-top: 4px;
  color: var(--auth-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-heading {
  margin: 24px 0 19px;
}

.auth-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--auth-cyan);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.auth-heading h1,
.auth-fatal h1 {
  margin: 0;
  color: #fff;
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.auth-heading p,
.auth-fatal p {
  margin: 8px 0 0;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.24);
}

.auth-tab {
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  color: #a7aab3;
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.auth-tab:hover,
.auth-tab:focus-visible {
  color: #f5f7ff;
  outline: none;
}

.auth-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 0 0 1px rgba(85, 244, 220, 0.2), 0 4px 12px rgba(0, 0, 0, 0.18);
}

.auth-field {
  margin-bottom: 13px;
}

.auth-field > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  color: #dedfe5;
  font-size: 10px;
  font-weight: 650;
}

.auth-field > label span {
  color: #888b94;
  font-size: 9px;
  font-weight: 500;
}

.auth-field-hint {
  display: block;
  margin: 6px 2px 0;
  color: #92949c;
  font-size: 9px;
  line-height: 1.45;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrap > i {
  position: absolute;
  left: 12px;
  width: 14px;
  color: #8d9099;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

.auth-input-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 42px 0 37px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #f5f7ff;
  background: #1e1e1e;
  caret-color: var(--auth-cyan);
  font-size: 12px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.auth-input-wrap input::placeholder {
  color: #777981;
}

.auth-input-wrap input:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.auth-input-wrap input:focus {
  border-color: rgba(85, 244, 220, 0.58);
  background: #202020;
  box-shadow: 0 0 0 3px rgba(85, 244, 220, 0.08);
}

#top-settings-bar .tsb-input[readonly] {
  cursor: default;
  color: #d8d9df;
  border-color: rgba(85, 244, 220, 0.24);
  background: rgba(85, 244, 220, 0.045);
}

.auth-upload-button.auth-uploading {
  pointer-events: none;
  opacity: 0.55;
}

.auth-password-toggle {
  position: absolute;
  right: 6px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: #92949c;
  background: transparent;
  font-size: 11px;
}

.auth-password-toggle:hover,
.auth-password-toggle:focus-visible {
  color: #f5f7ff;
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.auth-status {
  margin: 4px 0 13px;
  padding: 9px 11px;
  border: 1px solid rgba(236, 110, 116, 0.22);
  border-radius: 7px;
  color: #ffb7bb;
  background: rgba(137, 35, 43, 0.14);
  font-size: 10px;
  line-height: 1.45;
}

.auth-status.success {
  border-color: rgba(85, 244, 220, 0.24);
  color: #9ffbea;
  background: rgba(85, 244, 220, 0.07);
}

.auth-submit {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 15px;
  border: 1px solid rgba(85, 244, 220, 0.34);
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, rgba(85, 244, 220, 0.14), rgba(154, 124, 255, 0.12));
  box-shadow: 0 9px 25px rgba(0, 0, 0, 0.22), inset 0 1px rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.015em;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.auth-submit > i {
  margin-left: auto;
  font-size: 10px;
}

.auth-submit-label {
  margin-left: auto;
}

.auth-submit:hover,
.auth-submit:focus-visible {
  border-color: rgba(85, 244, 220, 0.58);
  background: linear-gradient(135deg, rgba(85, 244, 220, 0.2), rgba(154, 124, 255, 0.17));
  box-shadow: 0 11px 30px rgba(0, 0, 0, 0.3), inset 0 1px rgba(255, 255, 255, 0.16);
  outline: none;
  transform: translateY(-1px);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-submit:disabled,
.auth-text-button:disabled,
.auth-signout-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.auth-button-loader {
  width: 14px;
  height: 14px;
  display: none;
  margin-left: auto;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 700ms linear infinite;
}

.auth-submit.busy .auth-submit-label,
.auth-submit.busy > i {
  display: none;
}

.auth-submit.busy .auth-button-loader {
  display: block;
  margin-right: auto;
}

.auth-text-button {
  width: 100%;
  margin-top: 13px;
  padding: 4px;
  border: 0;
  color: #a7aab3;
  background: transparent;
  font-size: 10px;
}

.auth-text-button:hover,
.auth-text-button:focus-visible {
  color: var(--auth-cyan);
  text-decoration: none;
  outline: none;
}

.auth-loading {
  min-height: 288px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  color: var(--auth-muted);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.auth-loader {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(85, 244, 220, 0.22);
  border-radius: 50%;
}

.auth-loader::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--auth-cyan);
  border-radius: 50%;
  animation: auth-spin 800ms linear infinite;
}

.auth-fatal {
  padding: 30px 0 20px;
  text-align: center;
}

.auth-fatal-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border: 1px solid rgba(237, 144, 95, 0.23);
  border-radius: 50%;
  color: #ffb17f;
  background: rgba(151, 68, 31, 0.16);
}

.auth-fatal h1 {
  font-size: 20px;
}

.auth-fatal .auth-submit {
  margin-top: 18px;
}

.auth-card-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: #85878f;
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
}

.auth-card-footer i {
  color: var(--auth-cyan);
  font-size: 9px;
}

.auth-session {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.auth-account-controls {
  position: static;
  min-height: 0;
  margin-left: auto;
  padding: 0 0 0 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.auth-account-controls::before {
  content: none;
}

.auth-account-controls .auth-session-copy {
  min-width: 92px;
}

.auth-session-avatar {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: 0 0 25px;
  border: 1px solid rgba(85, 244, 220, 0.34);
  border-radius: 7px;
  color: #f5f7ff;
  background: linear-gradient(145deg, rgba(85, 244, 220, 0.16), rgba(154, 124, 255, 0.12));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auth-session-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.auth-session-copy strong,
.auth-session-copy small {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-session-copy strong {
  color: #f5f7ff;
  font-size: 9px;
  font-weight: 700;
}

.auth-session-copy small {
  margin-top: 2px;
  color: #a7aab3;
  font-size: 8px;
}

.auth-signout-button {
  height: 25px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #d2d3d8;
  background: transparent;
  font-size: 9px;
  font-weight: 650;
}

.auth-upload-button {
  height: 25px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid rgba(85, 244, 220, 0.32);
  border-radius: 6px;
  color: #55f4dc;
  background: rgba(85, 244, 220, 0.055);
  font-size: 9px;
  font-weight: 700;
}

.auth-upload-button:hover,
.auth-upload-button:focus-visible {
  border-color: rgba(85, 244, 220, 0.55);
  color: #fff;
  background: rgba(85, 244, 220, 0.11);
  outline: none;
}

.auth-signout-button:hover,
.auth-signout-button:focus-visible {
  border-color: rgba(154, 124, 255, 0.42);
  color: #fff;
  background: rgba(154, 124, 255, 0.08);
  outline: none;
}

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

@media (max-width: 1080px) {
  .auth-session-plan .auth-session-copy,
  .auth-session-separator {
    display: none !important;
  }

  .auth-account-controls .auth-session-copy {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  #auth-gate {
    align-items: start;
    padding: 14px;
  }

  .auth-card {
    padding: 21px 20px 18px;
    border-radius: 14px;
  }

  .auth-heading {
    margin-top: 20px;
  }

  .auth-heading h1 {
    font-size: 24px;
  }

}

@media (max-width: 520px) {
  .auth-account-controls {
    padding-left: 4px;
  }

  .auth-session-plan .auth-signout-button span,
  .auth-session-plan .auth-upload-button span {
    display: none;
  }

  .auth-session-plan .auth-signout-button,
  .auth-session-plan .auth-upload-button {
    width: 27px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-height: 680px) and (min-width: 721px) {
  #auth-gate {
    align-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-loader::before,
  .auth-button-loader {
    animation-duration: 1.6s;
  }

  .auth-submit,
  .auth-tab,
  .auth-input-wrap input {
    transition: none;
  }
}
