/* AkmaCam login / signup — CamWatch neumorphism (matches dashboard) */

html, html.theme-light {
  color-scheme: light;
  --bg-deep: #e8eaf0;
  --bg-panel: #e8eaf0;
  --bg-panel-elevated: #e8eaf0;
  --bg-panel-border: rgba(180, 185, 210, 0.28);
  --text-primary: rgba(50, 55, 85, 0.88);
  --text-secondary: rgba(100, 108, 145, 0.72);
  --text-muted: rgba(120, 128, 165, 0.55);
  --accent: #2563eb;
  --accent-deep: #0a84ff;
  --accent-dim: rgba(37, 99, 235, 0.14);
  --accent-glow: rgba(37, 99, 235, 0.28);
  --accent-mint: #7ed8c8;
  --danger: #ff3b30;
  --danger-bg: rgba(255, 59, 48, 0.08);
  --success: #1db954;
  --neu-dark: rgba(180, 185, 210, 0.55);
  --neu-light: rgba(255, 255, 255, 0.92);
  --shadow-sheet:
    0 -8px 28px rgba(180, 185, 210, 0.45),
    12px 12px 30px rgba(180, 185, 210, 0.35),
    -8px -8px 24px rgba(255, 255, 255, 0.75),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  --shadow-card:
    6px 6px 16px var(--neu-dark),
    -6px -6px 16px var(--neu-light);
  --shadow-card-sm:
    4px 4px 10px rgba(180, 185, 210, 0.5),
    -4px -4px 10px rgba(255, 255, 255, 0.9);
  --shadow-inset:
    inset 4px 4px 10px rgba(180, 185, 210, 0.5),
    inset -4px -4px 10px rgba(255, 255, 255, 0.88);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --page-pad-x: 20px;
}

html.theme-dark {
  color-scheme: dark;
  --bg-deep: #1a1c24;
  --bg-panel: #1a1c24;
  --bg-panel-elevated: #22242e;
  --bg-panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: rgba(230, 232, 245, 0.92);
  --text-secondary: rgba(170, 175, 200, 0.72);
  --text-muted: rgba(140, 145, 175, 0.55);
  --accent: #5b8def;
  --accent-deep: #0a84ff;
  --accent-dim: rgba(37, 99, 235, 0.18);
  --accent-glow: rgba(37, 99, 235, 0.35);
  --accent-mint: #7ed8c8;
  --danger: #ff453a;
  --danger-bg: rgba(255, 69, 58, 0.12);
  --success: #30d158;
  --neu-dark: rgba(0, 0, 0, 0.55);
  --neu-light: rgba(255, 255, 255, 0.06);
  --shadow-sheet:
    0 -8px 28px rgba(0, 0, 0, 0.45),
    8px 8px 24px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-card:
    6px 6px 16px rgba(0, 0, 0, 0.45),
    -4px -4px 12px rgba(255, 255, 255, 0.04);
  --shadow-card-sm:
    4px 4px 10px rgba(0, 0, 0, 0.4),
    -3px -3px 8px rgba(255, 255, 255, 0.04);
  --shadow-inset:
    inset 4px 4px 10px rgba(0, 0, 0, 0.45),
    inset -3px -3px 8px rgba(255, 255, 255, 0.04);
}


*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.hidden { display: none !important; }

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

/* ── Page ── */
.login-page {
  min-height: 100svh;
  min-height: 100dvh;
  position: relative;
  /* Avoid overflow-x:hidden — on iOS Safari it also clips Y and kills bottom-sheet slide-in. */
  overflow-x: visible;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.75;
}

.login-bg-orb--1 {
  width: 300px;
  height: 300px;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(126, 216, 200, 0.22);
}

.login-bg-orb--2 {
  width: 220px;
  height: 220px;
  top: 22%;
  right: -60px;
  background: rgba(91, 141, 239, 0.16);
}

.login-bg-orb--3 {
  width: 200px;
  height: 200px;
  bottom: 38%;
  left: -50px;
  background: rgba(143, 207, 238, 0.14);
}

html.theme-dark .login-bg-orb--1 { background: rgba(126, 216, 200, 0.1); }
html.theme-dark .login-bg-orb--2 { background: rgba(91, 141, 239, 0.12); }
html.theme-dark .login-bg-orb--3 { background: rgba(143, 207, 238, 0.08); }

/* ── Shell ── */
.login-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  /* Grow with content so signup never clips the hero; page scrolls instead. */
  box-sizing: border-box;
}

/* ── Hero ── */
.login-hero {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(28px + var(--safe-top)) var(--page-pad-x) 24px;
  min-height: 0;
  /* Keep brand fully on-screen even when the sheet is tall. */
  overflow: visible;
  animation: loginHeroIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.login-logo-wrap {
  position: relative;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: inherit;
  --logo-size: clamp(72px, 18vmin, 108px);
  /* Keep ring/glow tight to the logo frame so they never spill awkwardly. */
  --logo-ring-outset: 5px;
  --logo-glow-outset: 12px;
  --logo-radius: 22%;
  width: var(--logo-size);
  height: var(--logo-size);
  margin-bottom: clamp(12px, 2.5vmin, 20px);
  flex-shrink: 0;
  overflow: visible;
}

.login-logo-wrap .logo-frame {
  position: relative;
  z-index: 3;
  grid-area: 1 / 1;
  width: var(--logo-size);
  height: var(--logo-size);
  margin: 0;
  border-radius: var(--logo-radius);
  box-shadow:
    8px 8px 20px rgba(180, 185, 210, 0.55),
    -6px -6px 16px rgba(255, 255, 255, 0.9);
}

.login-logo-wrap .logo-frame--108 {
  width: var(--logo-size);
  height: var(--logo-size);
}

.login-logo-wrap .logo-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
}

.login-logo-glow {
  grid-area: 1 / 1;
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% + (var(--logo-glow-outset) * 2));
  height: calc(100% + (var(--logo-glow-outset) * 2));
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    rgba(126, 216, 200, 0.28) 0%,
    rgba(91, 141, 239, 0.12) 42%,
    transparent 70%
  );
  z-index: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.login-logo-ring {
  grid-area: 1 / 1;
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% + (var(--logo-ring-outset) * 2));
  height: calc(100% + (var(--logo-ring-outset) * 2));
  /* Match logo squircle so the ring frames the icon, not a looser shape. */
  border-radius: calc(var(--logo-radius) + 2%);
  border: 1.5px solid rgba(10, 132, 255, 0.38);
  box-sizing: border-box;
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  animation: loginRingPulse 3.2s ease-in-out infinite;
}

@keyframes loginRingPulse {
  0%, 100% {
    opacity: 0.4;
    border-color: rgba(10, 132, 255, 0.28);
  }
  50% {
    opacity: 1;
    border-color: rgba(10, 132, 255, 0.55);
  }
}

.login-title {
  font-size: clamp(1.75rem, 7vw, 2.125rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: 10px;
}

html.theme-dark .login-title {
  background: linear-gradient(180deg, #ffffff 0%, #9ec5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-tagline {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.login-features {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 8px;
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 100%;
}

.login-features li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  box-shadow: var(--shadow-card-sm);
}

html.theme-dark .login-features li {
  background: var(--bg-panel);
  box-shadow: var(--shadow-card-sm);
}

.login-feature-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a8edda, #7ed8c8);
  box-shadow: 0 0 8px rgba(126, 216, 200, 0.45);
  flex-shrink: 0;
}

/* ── Bottom sheet ── */
/* Animate transform on the sheet itself; keep backdrop-filter on ::before.
   iOS Safari often skips/ignores transform animation when both are on one element. */
.login-sheet {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  background: transparent;
  border-radius: 36px 36px 0 0;
  border-top: none;
  box-shadow: none;
  padding: 14px var(--page-pad-x) calc(22px + var(--safe-bottom));
  isolation: isolate;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translate3d(0, 100%, 0);
  transform: translate3d(0, 100%, 0);
  opacity: 0;
  animation: loginSheetIn 0.65s cubic-bezier(0.32, 0.72, 0, 1) 0.06s forwards;
}

.login-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--bg-panel);
  border-top: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-sheet);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}

.login-sheet > * {
  position: relative;
  z-index: 1;
}

@keyframes loginSheetIn {
  from {
    opacity: 0;
    -webkit-transform: translate3d(0, 100%, 0);
    transform: translate3d(0, 100%, 0);
  }
  to {
    opacity: 1;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
}

/* Viewport units are more reliable than % height on iPhone before layout settles. */
@media (max-width: 519px) {
  .login-sheet {
    -webkit-transform: translate3d(0, 100svh, 0);
    transform: translate3d(0, 100svh, 0);
  }

  @keyframes loginSheetIn {
    from {
      opacity: 0;
      -webkit-transform: translate3d(0, 100svh, 0);
      transform: translate3d(0, 100svh, 0);
    }
    to {
      opacity: 1;
      -webkit-transform: translate3d(0, 0, 0);
      transform: translate3d(0, 0, 0);
    }
  }
}

@keyframes loginSheetContentIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

#login-content.login-content--in > .device-badge.visible,
#login-content.login-content--in > .auth-success-banner:not(.hidden),
#login-content.login-content--in > .auth-error-banner:not(.hidden),
#login-content.login-content--in > .auth-method-picker:not(.hidden),
#login-content.login-content--in > .firebase-auth-section:not(.hidden),
#login-content.login-content--in > .login-fine {
  animation: loginSheetContentIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#login-content.login-content--in > .device-badge.visible { animation-delay: 0.08s; }
#login-content.login-content--in > .auth-success-banner:not(.hidden) { animation-delay: 0.12s; }
#login-content.login-content--in > .auth-error-banner:not(.hidden) { animation-delay: 0.18s; }
#login-content.login-content--in > .auth-method-picker:not(.hidden) { animation-delay: 0.22s; }
#login-content.login-content--in > .firebase-auth-section:not(.hidden) { animation-delay: 0.22s; }
#login-content.login-content--in > .login-fine { animation-delay: 0.3s; }

html.theme-light .login-sheet::before {
  background: #e8eaf0;
}

html.theme-dark .login-sheet::before {
  background: #1a1c24;
  border-top-color: rgba(255, 255, 255, 0.06);
}

.login-sheet-handle {
  width: 42px;
  height: 5px;
  margin: 2px auto 20px;
  border-radius: 999px;
  background: var(--bg-panel);
  opacity: 1;
  box-shadow: var(--shadow-inset);
}

.login-checking {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 8px 0;
}

.device-badge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 16px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: none;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  box-shadow: var(--shadow-card-sm);
}

.device-badge.visible { display: inline-flex; }

/* Email mode — hero sizes to content; page scrolls if the form is taller than the viewport */
.login-shell--email .login-hero {
  flex: 0 0 auto;
  min-height: 0;
  justify-content: flex-end;
  padding: calc(14px + var(--safe-top)) var(--page-pad-x) clamp(12px, 2dvh, 20px);
}

.login-shell--email .login-logo-wrap {
  --logo-size: clamp(56px, 12vmin, 88px);
  margin-bottom: clamp(8px, 1.8vmin, 16px);
  flex-shrink: 0;
}

.login-shell--email .login-logo-wrap .logo-frame,
.login-shell--email .login-logo-wrap .logo-frame--108 {
  width: var(--logo-size);
  height: var(--logo-size);
}

.login-shell--email .login-logo-wrap .logo-img {
  width: 100%;
  height: 100%;
}

.login-shell--email .login-logo-glow {
  --logo-glow-outset: 10px;
}

.login-shell--email .login-logo-ring {
  --logo-ring-outset: 4px;
}

.login-shell--email .login-title {
  font-size: clamp(1.25rem, 4.5vmin, 1.875rem);
  margin-bottom: clamp(4px, 1vmin, 8px);
}

.login-shell--email .login-tagline {
  margin-bottom: clamp(8px, 1.5vmin, 14px);
  font-size: clamp(0.75rem, 2vmin, 0.8125rem);
}

.login-shell--email .login-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
}

.login-shell--email .login-features li {
  padding: 4px 8px;
  font-size: clamp(0.5625rem, 1.6vmin, 0.6875rem);
}

/* Signup — taller form; keep logo fully visible and compact */
.login-shell--email.login-shell--signup .login-hero {
  padding-top: calc(10px + var(--safe-top));
  padding-bottom: clamp(8px, 1.5vmin, 14px);
}

.login-shell--email.login-shell--signup .login-logo-wrap {
  --logo-size: clamp(48px, 10vmin, 72px);
  margin-bottom: clamp(6px, 1.2vmin, 12px);
}

.login-shell--email.login-shell--signup .login-title {
  font-size: clamp(1.125rem, 3.8vmin, 1.5rem);
}

.login-shell--email.login-shell--signup .login-tagline {
  margin-bottom: clamp(6px, 1.2vmin, 10px);
}

.login-shell--email.login-shell--signup .login-features {
  display: none;
}

.login-shell--email .login-fine {
  display: none;
}

.login-shell--email .login-sheet {
  padding-top: 6px;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.auth-success-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 20px;
  background: var(--bg-panel);
  border: none;
  text-align: left;
  box-shadow: var(--shadow-card-sm);
}

html.theme-dark .auth-success-banner {
  background: var(--bg-panel);
}

.auth-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-panel);
  color: var(--success);
  box-shadow: var(--shadow-card-sm);
}

.auth-success-text strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-success-text p {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
}

.auth-error-banner {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 18px;
  background: var(--bg-panel);
  border: none;
  color: var(--danger);
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--shadow-inset);
}

/* ── Sign-in options ── */
.auth-method-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-method-picker.hidden { display: none; }

.btn-auth-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border-radius: 20px;
  border: none;
  background: var(--bg-panel);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-card);
  -webkit-appearance: none;
  appearance: none;
}

html.theme-light .btn-auth-option,
html.theme-dark .btn-auth-option {
  background: var(--bg-panel);
  border: none;
}

.btn-auth-option:hover,
.btn-auth-option:focus-visible {
  box-shadow: var(--shadow-card), 0 0 0 3px var(--accent-dim);
  outline: none;
}

.btn-auth-option:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-inset);
}

.btn-auth-option--device {
  box-shadow:
    var(--shadow-card-sm),
    inset 0 0 0 1px rgba(91, 141, 239, 0.28);
}

.btn-auth-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  flex-shrink: 0;
  background: var(--bg-panel);
  box-shadow: var(--shadow-card-sm);
}

.btn-auth-option-icon--google {
  background: var(--bg-panel);
}

.btn-auth-option-icon--email {
  background: var(--bg-panel);
  color: var(--accent);
}

.btn-auth-option-text {
  flex: 1;
  min-width: 0;
}

.btn-auth-option-label {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-auth-option-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
}

/* ── Email form ── */
.firebase-auth-section {
  animation: loginSheetContentIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.firebase-auth-section.hidden { display: none; }

.auth-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 0 0 16px;
  padding: 0;
  border: none;
  border-radius: 14px;
  background: var(--bg-panel);
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-card-sm);
  transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

html.theme-light .auth-back-btn,
html.theme-dark .auth-back-btn {
  background: var(--bg-panel);
}

.auth-back-btn:hover,
.auth-back-btn:focus-visible {
  color: var(--accent);
  outline: none;
}

.auth-back-btn:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-inset);
}

.firebase-auth-form .field {
  margin-bottom: 14px;
}

.firebase-auth-section--signup .field-signup-only:not(.hidden) {
  animation: signup-field-in 0.28s ease both;
}

@keyframes signup-field-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.firebase-auth-form label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field-label-row label {
  margin-bottom: 0;
}

.password-strength-text {
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  transition: color 0.2s ease;
}

.password-strength-text.strength-1 { color: var(--danger); }
.password-strength-text.strength-2 { color: #e68600; }
.password-strength-text.strength-3 { color: #b8860b; }
.password-strength-text.strength-4 { color: var(--success); }
.password-strength-text.strength-5 { color: var(--accent); }

html.theme-dark .password-strength-text.strength-2 { color: #ff9f0a; }
html.theme-dark .password-strength-text.strength-3 { color: #ffd60a; }

.firebase-auth-form input {
  width: 100%;
  min-height: 50px;
  padding: 0 44px 0 16px;
  border-radius: 16px;
  border: none;
  background: var(--bg-panel);
  color: var(--text-primary);
  font: inherit;
  font-size: 1rem;
  box-shadow: var(--shadow-inset);
  transition: box-shadow 0.2s ease;
}

.firebase-auth-form input:not([type="password"]) {
  padding-right: 16px;
}

.field-password-wrap {
  position: relative;
}

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

.field-password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.field-password-toggle:hover,
.field-password-toggle:focus-visible {
  color: var(--accent);
  background: var(--accent-dim);
  outline: none;
}

.field-error {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--danger);
  line-height: 1.35;
}

.firebase-auth-form .field--invalid input {
  box-shadow:
    var(--shadow-inset),
    0 0 0 1.5px rgba(255, 59, 48, 0.45);
}

.firebase-auth-form .field--invalid input:focus {
  box-shadow:
    var(--shadow-inset),
    0 0 0 3px rgba(255, 59, 48, 0.16);
}

.auth-mode-switch {
  margin-top: 14px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.link-btn--inline {
  display: inline;
  padding: 0;
  vertical-align: baseline;
}

html.theme-light .firebase-auth-form input,
html.theme-dark .firebase-auth-form input {
  background: var(--bg-panel);
  border: none;
}

.firebase-auth-form input:focus {
  outline: none;
  box-shadow:
    var(--shadow-inset),
    0 0 0 3px var(--accent-dim);
}

.btn-email-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 6px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(145deg, #5b8def 0%, #2563eb 100%);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow:
    5px 5px 14px rgba(37, 99, 235, 0.28),
    -3px -3px 10px rgba(255, 255, 255, 0.7);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-email-submit:active:not(:disabled) {
  transform: scale(0.985);
  box-shadow: inset 3px 3px 8px rgba(20, 60, 160, 0.35);
}

.btn-email-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.firebase-auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 0 2px;
}

.link-btn {
  border: none;
  background: none;
  padding: 6px 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
}

.link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.firebase-setup-note {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--bg-panel);
  border: none;
  color: #c93400;
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--shadow-inset);
}

.firebase-setup-note code {
  font-size: 0.75rem;
  word-break: break-all;
}

html.theme-dark .firebase-setup-note {
  color: #ff9f0a;
  background: rgba(255, 159, 10, 0.12);
}

.firebase-auth-form input:disabled,
.btn-email-submit:disabled,
.link-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.login-fine {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: none;
  box-shadow: inset 0 1px 0 rgba(180, 185, 210, 0.28);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.35;
}

html.theme-dark .login-fine {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.login-fine svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  opacity: 0.85;
}

.status-bar {
  margin-top: 8px;
  min-height: 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.status-bar:not(:empty) {
  min-height: 18px;
  margin-top: 10px;
}

.status-bar.error { color: var(--danger); }
.status-bar.success { color: var(--success); }

.akma-loader-host {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.akma-loader-host--compact { min-height: 96px; }

@media (max-height: 740px) {
  .login-shell--email .login-logo-wrap {
    --logo-size: clamp(52px, 11vmin, 80px);
  }

  .login-shell--email.login-shell--signup .login-logo-wrap {
    --logo-size: clamp(44px, 9vmin, 64px);
  }

  .login-shell--email .login-features {
    display: none;
  }
}

@media (max-height: 640px) {
  .login-hero {
    padding-top: calc(14px + var(--safe-top));
    padding-bottom: 16px;
    justify-content: center;
  }

  .login-logo-wrap {
    --logo-size: clamp(64px, 14vmin, 84px);
    margin-bottom: 12px;
  }

  .login-sheet-handle {
    margin-bottom: 12px;
  }

  .login-shell--email .login-hero {
    padding-bottom: clamp(6px, 1.5vmin, 12px);
  }

  .login-shell--email .login-logo-wrap {
    --logo-size: clamp(48px, 10vmin, 72px);
  }

  .login-shell--email.login-shell--signup .login-logo-wrap {
    --logo-size: clamp(44px, 9vmin, 60px);
  }

  .login-shell--email .login-logo-glow,
  .login-shell--email .login-logo-ring {
    display: none;
  }

  .login-features {
    display: none;
  }
}

@media (max-width: 519px) {
  .login-shell {
    max-width: none;
    /* Top-first layout so the logo is never pushed off-screen by a tall sheet. */
    justify-content: flex-start;
  }

  .login-hero {
    flex: 1 1 auto;
    min-height: clamp(160px, 34svh, 320px);
    padding-bottom: 22px;
    justify-content: center;
  }

  .login-shell--email .login-hero,
  .login-shell--email.login-shell--signup .login-hero {
    flex: 0 0 auto;
    min-height: 0;
  }

  .login-logo-wrap {
    --logo-size: clamp(72px, 20vmin, 96px);
  }

  .login-sheet {
    flex: 0 0 auto;
    border-radius: 36px 36px 0 0;
    padding-left: var(--page-pad-x);
    padding-right: var(--page-pad-x);
  }
}

@media (min-width: 520px) {
  .login-page {
    display: flex;
    align-items: safe center;
    justify-content: center;
    padding: clamp(24px, 4vh, 48px) 20px;
  }

  .login-shell {
    min-height: auto;
    width: min(420px, 100%);
    max-height: none;
    border-radius: 36px;
    overflow: visible;
    box-shadow:
      12px 12px 30px rgba(180, 185, 210, 0.55),
      -12px -12px 30px rgba(255, 255, 255, 0.9),
      inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    border: none;
    background: var(--bg-panel);
  }

  html.theme-dark .login-shell {
    box-shadow:
      12px 12px 30px rgba(0, 0, 0, 0.45),
      -6px -6px 16px rgba(255, 255, 255, 0.03),
      inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  }

  .login-hero {
    flex: 0 0 auto;
    min-height: 0;
    padding-top: clamp(28px, 4vh, 40px);
    padding-bottom: clamp(18px, 3vh, 28px);
  }

  .login-sheet {
    border-radius: 0 0 36px 36px;
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 28px;
  }

  .login-sheet::before {
    border-top: none;
    box-shadow: inset 0 1px 0 rgba(180, 185, 210, 0.28);
    background: transparent;
  }

  html.theme-dark .login-sheet::before {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .login-shell--email .login-hero {
    padding-top: clamp(20px, 3vh, 32px);
  }
}

/* Large monitors / TV — keep form readable without cropping brand */
@media (min-width: 1100px) {
  .login-shell {
    max-width: 520px;
  }

  .login-logo-wrap {
    --logo-size: clamp(88px, 10vmin, 120px);
  }

  .login-title {
    font-size: clamp(1.75rem, 2.4vw, 2.125rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-logo-ring { animation: none; }
  .login-hero,
  .login-sheet,
  .firebase-auth-section,
  #login-content.login-content--in > * {
    animation: none !important;
  }
  .login-sheet {
    opacity: 1;
    -webkit-transform: none;
    transform: none;
  }
  .btn-auth-option:active,
  .btn-email-submit:active:not(:disabled) { transform: none; }
}
