:root {
  --bg-deep: #060910;
  --accent: #ff4757;
  --accent-strong: #ff2b3a;
  --auth-font: "Varela Round", "Segoe UI", Arial, sans-serif;
  --auth-muted: #98a1aa;
  --auth-line: rgba(78, 98, 108, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: #e9edf1;
  font: 14px/1.4 var(--auth-font);
}

body.auth-locked {
  padding: 0;
}

#app-shared-ambient {
  position: fixed;
  inset: 0;
  z-index: 13900;
  overflow: hidden;
  pointer-events: none;
  background: rgba(5, 8, 12, 0.52);
}

#app-shared-ambient::after,
.app-auth-gate::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 43, 58, 0.1), transparent 42%),
    rgba(5, 8, 12, 0.32);
}

.app-shared-ambient-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg-deep);
  filter: saturate(1.05) brightness(0.92);
}

.app-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 15000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  overflow: hidden;
  background: transparent;
}

.app-ambient-gate-inner,
.app-auth-gate-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
}

.auth-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 360px;
  padding: 32px 28px 26px;
  border: 1px solid rgba(255, 43, 58, 0.3);
  border-radius: 16px;
  background: rgba(12, 8, 10, 0.62);
  backdrop-filter: blur(10px) saturate(1.08);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 43, 58, 0.1),
    0 0 32px rgba(255, 43, 58, 0.07);
}

.app-auth-gate-busy .auth-card {
  pointer-events: none;
}

.auth-logo {
  display: none !important;
}

.auth-title {
  margin: 0 0 6px;
  text-align: center;
  color: #f8fbff;
  font: 700 24px/1.2 var(--auth-font);
  letter-spacing: -0.02em;
}

.auth-hint {
  margin: 0;
  text-align: center;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.45;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 22px;
}

.auth-field {
  position: relative;
}

.auth-field input {
  width: 100%;
  min-height: 48px;
  padding: 18px 14px 8px;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  background: rgba(13, 19, 23, 0.72);
  color: #e9edf1;
  font: 14px/1.2 var(--auth-font);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  border-color: rgba(255, 43, 58, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 43, 58, 0.12);
  background: rgba(16, 10, 12, 0.9);
}

.auth-field label {
  position: absolute;
  top: -8px;
  left: 12px;
  padding: 0 6px;
  background: rgba(12, 8, 10, 0.95);
  color: var(--auth-muted);
  font: 500 12px/1 var(--auth-font);
  pointer-events: none;
}

.auth-field--password input {
  padding-right: 44px;
}

.auth-eye {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transform: translateY(-50%);
}

.auth-eye:hover {
  background: rgba(255, 43, 58, 0.14);
}

.auth-eye svg {
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
  fill: currentColor;
}

.auth-submit,
.auth-save-credentials {
  width: 100%;
  cursor: pointer;
  font-family: var(--auth-font);
}

.auth-submit {
  min-height: 36px;
  margin-top: 4px;
  border: 1px solid rgba(255, 43, 58, 0.55);
  border-radius: 7px;
  background: #180d0f;
  color: #fff;
  font: 800 13px/1 var(--auth-font);
}

.auth-submit:hover:not(:disabled) {
  background: #221114;
  border-color: rgba(255, 43, 58, 0.8);
}

.auth-submit:disabled {
  opacity: 0.45;
  cursor: wait;
}

.auth-submit.is-busy:disabled {
  opacity: 1;
}

.auth-save-credentials {
  min-height: 34px;
  border: 1px solid rgba(255, 43, 58, 0.35);
  border-radius: 7px;
  background: #140a0c;
  color: #fff;
  font: 800 12px/1 var(--auth-font);
}

.auth-save-credentials:hover:not(:disabled) {
  background: rgba(255, 43, 58, 0.12);
}

.auth-save-credentials:disabled {
  opacity: 0.6;
  cursor: wait;
}

.auth-save-credentials.is-saved {
  border-color: rgba(255, 43, 58, 0.7);
  color: #ff6b78;
  background: rgba(255, 43, 58, 0.12);
}

.auth-status {
  min-height: 18px;
  margin: 12px 0 0;
  text-align: center;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.4;
}

.auth-status.is-error {
  color: #ff5b68;
}

.auth-extension-version {
  margin: 16px 0 0;
  text-align: center;
  color: rgba(233, 237, 241, 0.35);
  font-size: 11px;
}

.loading-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

.loading-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: loading-dot-pulse 1.1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loading-dot-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Hide login card while restoring an existing session. */
html.auth-checking .auth-card {
  visibility: hidden;
  pointer-events: none;
}

#auth-session-spinner {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 16000;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  pointer-events: none;
}

html.auth-checking #auth-session-spinner {
  display: flex;
}

.auth-session-spinner-ring {
  width: 52px;
  height: 52px;
  border: 3.5px solid rgba(255, 43, 58, 0.14);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: auth-session-spin 0.85s linear infinite;
  box-shadow: 0 0 28px rgba(255, 43, 58, 0.12);
}

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

@media (prefers-reduced-motion: reduce) {
  .auth-session-spinner-ring {
    animation: none;
    border-top-color: rgba(255, 43, 58, 0.55);
  }
}
