/* Theme 17: Kaca Patri (Cathedral Stained Glass) — Orbitlux
 * Visual language: Gothic cathedral stained-glass window with black lead frames (#060810)
 * and jewel-toned ruby, sapphire, and molten amber-gold light.
 * HARD RULE: Stained-glass panels NEVER move/rotate/scale. ONLY light passing through
 * and specular glints/glows across the glass surface animate.
 */

:root {
  color-scheme: dark;
  --kp-bg: #070a14;
  --kp-obsidian: rgba(8, 12, 26, 0.985);
  --kp-obsidian-deep: rgba(6, 9, 20, 0.99);
  --kp-surface: rgba(18, 25, 48, 0.78);
  --kp-surface-hover: rgba(28, 39, 72, 0.88);
  --kp-lead: #060810;

  /* Jewel palette */
  --kp-gold: #f2c45e;
  --kp-gold-bright: #ffe69a;
  --kp-gold-deep: #b8731b;
  --kp-ruby: #d9264e;
  --kp-ruby-glow: #ff4d73;
  --kp-sapphire: #2563eb;
  --kp-sapphire-glow: #60a5fa;
  --kp-emerald: #34d399;

  /* Text tokens (high contrast over midnight obsidian) */
  --kp-text: #f8fafc;
  --kp-text-soft: #cbd5e8;
  --kp-text-muted: #93a3c2;
  --kp-on-gold: #0b0f1e;

  /* Borders */
  --kp-border-gold: rgba(235, 186, 86, 0.56);
  --kp-border-subtle: rgba(235, 186, 86, 0.24);
  --kp-focus: #ffe184;

  /* Timing */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--kp-bg);
  color: var(--kp-text);
  overflow-x: clip;
}

@media (pointer: fine) {
  html {
    overscroll-behavior: none;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--kp-bg);
  color: var(--kp-text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

button,
input,
select {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--kp-focus);
  outline-offset: 2px;
}

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

/* Skip link */
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10000;
  padding: 8px 14px;
  background: var(--kp-obsidian-deep);
  color: var(--kp-gold-bright);
  border: 1.5px solid var(--kp-gold);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* ── CATHEDRAL STAINED-GLASS STAGE ──────────────────────────────────────────
 * CRITICAL: .stained-glass-svg is 100% STATIC (zero movement, zero transform).
 * ONLY .light-rays-layer and #light-canvas animate light rays, caustics & surface glints.
 */
.cathedral-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #060812;
}

.stained-glass-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Static glass — pulsing jewel backlit glow only (no geometry movement) */
  animation: glassLuminancePulse 11s ease-in-out infinite;
}

@keyframes glassLuminancePulse {
  0%, 100% {
    filter: brightness(0.94) saturate(1.12);
  }
  50% {
    filter: brightness(1.12) saturate(1.26);
  }
}

.light-rays-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mix-blend-mode: screen;
}

/* Volumetric sunbeams sweeping slowly across the stationary stained glass */
.sunbeam {
  position: absolute;
  top: -28%;
  width: 34vw;
  height: 165%;
  filter: blur(36px);
  will-change: transform, opacity;
}

.beam-gold {
  left: -12%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 214, 102, 0.34) 38%,
    rgba(255, 244, 188, 0.48) 51%,
    rgba(245, 168, 42, 0.24) 66%,
    transparent 100%
  );
  transform: rotate(22deg) translateX(-18vw);
  animation: sweepGoldRay 18s ease-in-out infinite alternate;
}

.beam-ruby {
  left: 18%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(235, 42, 86, 0.3) 44%,
    rgba(255, 128, 146, 0.34) 54%,
    transparent 100%
  );
  transform: rotate(24deg) translateX(8vw);
  animation: sweepRubyRay 23s ease-in-out infinite alternate;
}

.beam-sapphire {
  left: 52%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(56, 132, 255, 0.3) 44%,
    rgba(148, 208, 255, 0.36) 55%,
    transparent 100%
  );
  transform: rotate(20deg) translateX(-8vw);
  animation: sweepSapphireRay 21s ease-in-out infinite alternate;
}

/* Soft moving caustic light pool */
.caustic-wash {
  position: absolute;
  inset: -12%;
  background:
    radial-gradient(42% 38% at 24% 34%, rgba(255, 198, 72, 0.22), transparent 68%),
    radial-gradient(38% 36% at 76% 42%, rgba(72, 148, 255, 0.2), transparent 68%),
    radial-gradient(36% 36% at 48% 72%, rgba(228, 44, 88, 0.18), transparent 68%);
  animation: driftCaustics 16s ease-in-out infinite alternate;
  will-change: transform, opacity;
}

@keyframes sweepGoldRay {
  0% {
    transform: rotate(22deg) translateX(-14vw);
    opacity: 0.52;
  }
  50% {
    opacity: 0.92;
  }
  100% {
    transform: rotate(22deg) translateX(78vw);
    opacity: 0.58;
  }
}

@keyframes sweepRubyRay {
  0% {
    transform: rotate(24deg) translateX(36vw);
    opacity: 0.45;
  }
  50% {
    opacity: 0.85;
  }
  100% {
    transform: rotate(24deg) translateX(-34vw);
    opacity: 0.52;
  }
}

@keyframes sweepSapphireRay {
  0% {
    transform: rotate(20deg) translateX(-28vw);
    opacity: 0.48;
  }
  50% {
    opacity: 0.88;
  }
  100% {
    transform: rotate(20deg) translateX(36vw);
    opacity: 0.52;
  }
}

@keyframes driftCaustics {
  0% {
    transform: translate(-3%, -2%);
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translate(3.5%, 2.5%);
    opacity: 0.72;
  }
}

#light-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.cathedral-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(6, 9, 20, 0.18) 0%, rgba(5, 7, 16, 0.58) 100%);
}

/* Pause light motion (accessibility toggle) */
body.is-light-paused .stained-glass-svg,
body.is-light-paused .sunbeam,
body.is-light-paused .caustic-wash,
body.is-light-paused .stained-frame::after,
body.is-light-paused .kp-btn-primary::after {
  animation-play-state: paused !important;
}

/* Login <-> Dashboard golden veil transition */
.view-veil {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 224, 130, 0.42), rgba(14, 24, 58, 0.86) 65%, rgba(7, 10, 20, 0.96) 100%);
  transition: opacity 280ms var(--ease-out);
}

.view-veil.is-active {
  opacity: 1;
}

/* ── STAINED-GLASS MOSAIC FRAME (STATIC GLASS, SHINING GLINT OVERLAY) ─────── */
.stained-frame {
  position: relative;
  padding: 9px;
  border-radius: 16px;
  background:
    /* Black lead mortar grid */
    repeating-linear-gradient(90deg, rgba(6, 8, 16, 0.94) 0 2px, transparent 2px 24px),
    repeating-linear-gradient(0deg, rgba(6, 8, 16, 0.94) 0 2px, transparent 2px 24px),
    /* Jewel-toned ruby / sapphire / amber-gold mosaic tiles */
    linear-gradient(
      128deg,
      #b91c3a 0%,
      #ef4444 10%,
      #eab308 19%,
      #1d4ed8 31%,
      #60a5fa 41%,
      #991b1b 52%,
      #f59e0b 63%,
      #1e3a8a 74%,
      #e11d48 85%,
      #facc15 94%,
      #2563eb 100%
    );
  border: 2.5px solid var(--kp-lead);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.78),
    0 0 36px rgba(242, 184, 75, 0.22),
    0 0 70px rgba(37, 99, 235, 0.16),
    inset 0 0 0 1px rgba(255, 235, 168, 0.35);
  overflow: hidden;
}

/* Travelling specular glint across the stationary stained-glass frame */
.stained-frame::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    115deg,
    transparent 42%,
    rgba(255, 248, 210, 0.42) 49.5%,
    rgba(255, 255, 255, 0.65) 50.5%,
    rgba(255, 224, 130, 0.22) 53%,
    transparent 59%
  );
  transform: translateX(-65%);
  animation: frameGlintSweep 7.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

@keyframes frameGlintSweep {
  0%, 16% {
    transform: translateX(-68%);
    opacity: 0;
  }
  24% {
    opacity: 0.95;
  }
  44% {
    transform: translateX(68%);
    opacity: 0.85;
  }
  50%, 100% {
    transform: translateX(68%);
    opacity: 0;
  }
}

/* ── PAGE SHELL & 500x500 CENTERED AUTH CARD ──────────────────────────────── */
.page-shell {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  animation: shellFadeIn 520ms var(--ease-out) both;
}

.page-shell[hidden] {
  display: none;
}

@keyframes shellFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Floating top-right entry link to Dashboard */
.dash-entry-link {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  background: var(--kp-obsidian);
  color: var(--kp-gold-bright);
  border: 1.5px solid var(--kp-border-gold);
  border-radius: 11px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 0 18px rgba(242, 196, 94, 0.16);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms var(--ease-out), border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.dash-entry-link:hover {
  background: rgba(24, 34, 66, 0.96);
  border-color: var(--kp-gold-bright);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.65),
    0 0 24px rgba(242, 196, 94, 0.34);
  transform: translateY(-2px);
}

.dash-entry-link:active {
  transform: translateY(0) scale(0.98);
}

/* Subtle bottom-left ambient light toggle */
.light-motion-btn {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  background: rgba(9, 13, 27, 0.84);
  color: var(--kp-text-soft);
  border: 1px solid var(--kp-border-subtle);
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.light-motion-btn:hover {
  border-color: var(--kp-border-gold);
  color: var(--kp-gold-bright);
  background: rgba(18, 25, 48, 0.92);
}

/* Exact 500x500 centered login card (matching Theme 1 & Theme 2 proportions) */
.auth-card {
  width: 500px;
  height: 500px;
  max-width: 100%;
  display: flex;
  animation: cardEntrance 580ms var(--ease-out) both;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card-inner {
  position: relative;
  z-index: 3;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 15px 26px 12px;
  background:
    radial-gradient(ellipse 85% 45% at 50% 0%, rgba(45, 76, 168, 0.22), transparent 72%),
    var(--kp-obsidian);
  border: 1.5px solid var(--kp-border-gold);
  border-radius: 10px;
  box-shadow: inset 0 0 32px rgba(242, 184, 75, 0.08);
  overflow: hidden;
}

/* Brand Lockup */
.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.brand-emblem {
  display: grid;
  place-items: center;
  filter: drop-shadow(0 0 10px rgba(242, 184, 75, 0.45));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-name {
  font-family: "Outfit", "Inter", sans-serif;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff4c6 0%, #f5c660 55%, #d6932a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(242, 184, 75, 0.28));
}

.brand-tagline {
  margin-top: 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--kp-text-muted);
}

/* Form Container */
.form-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  scroll-margin-top: 24px;
}

.form-pane:focus:not(:focus-visible) {
  outline: none;
}

/* Segmented Tabs */
.tabs-wrap {
  margin-bottom: 11px;
  flex-shrink: 0;
}

.tabs-wrap[hidden] {
  display: none;
}

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  background: rgba(15, 23, 44, 0.92);
  border: 1px solid rgba(235, 186, 86, 0.28);
  border-radius: 9px;
}

.tab-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 5px);
  height: calc(100% - 6px);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(46, 73, 134, 0.92) 0%, rgba(28, 46, 92, 0.95) 100%);
  border: 1px solid rgba(126, 178, 255, 0.4);
  box-shadow:
    inset 0 -2px 0 var(--kp-gold),
    0 2px 12px rgba(37, 99, 235, 0.35);
  pointer-events: none;
  transition: transform 280ms var(--ease-out);
  will-change: transform;
}

.tab-btn {
  position: relative;
  z-index: 1;
  height: 33px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-family: "Outfit", "Inter", sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--kp-text-muted);
  cursor: pointer;
  transition: color 180ms ease;
}

.tab-btn:hover {
  color: var(--kp-gold-bright);
}

.tab-btn.is-active {
  color: #ffffff;
}

/* Panes + Animated Pane Transitions */
.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane[hidden] {
  display: none;
}

.pane.is-entering-right {
  animation: paneEnterRight 280ms var(--ease-out) both;
}

.pane.is-entering-left {
  animation: paneEnterLeft 280ms var(--ease-out) both;
}

.pane.is-entering-fade {
  animation: paneEnterFade 300ms var(--ease-out) both;
}

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

@keyframes paneEnterLeft {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes paneEnterFade {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Google Button */
.kp-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: transform 150ms var(--ease-out), border-color 160ms ease, background-color 160ms ease, box-shadow 180ms ease;
}

.kp-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.kp-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.kp-btn-google {
  background: rgba(15, 22, 42, 0.86);
  color: var(--kp-text);
  border: 1px solid var(--kp-border-gold);
  box-shadow: inset 0 1px 0 rgba(255, 232, 160, 0.14);
}

.kp-btn-google:hover:not(:disabled) {
  background: rgba(25, 36, 68, 0.94);
  border-color: var(--kp-gold-bright);
  box-shadow: 0 0 18px rgba(242, 196, 94, 0.22);
  transform: translateY(-1px);
}

/* Amber Stained-Glass Primary CTA Button */
.kp-btn-primary {
  height: 40px;
  font-family: "Outfit", "Inter", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--kp-on-gold);
  border: 1.5px solid #fde68a;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.24) 0%, transparent 32%, rgba(120, 53, 15, 0.22) 55%, rgba(255, 240, 175, 0.24) 100%),
    linear-gradient(180deg, #f8cf6a 0%, #e09b2d 52%, #b96e14 100%);
  box-shadow:
    0 6px 20px rgba(224, 155, 45, 0.34),
    inset 0 1px 1px rgba(255, 250, 220, 0.68);
}

.kp-btn-primary::after {
  content: "";
  position: absolute;
  top: -30%;
  left: -40%;
  width: 36%;
  height: 160%;
  background: linear-gradient(90deg, transparent, rgba(255, 252, 230, 0.56), transparent);
  transform: skewX(-24deg);
  animation: btnGlint 5.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes btnGlint {
  0%, 62% {
    transform: translateX(-120%) skewX(-24deg);
  }
  82%, 100% {
    transform: translateX(460%) skewX(-24deg);
  }
}

.kp-btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
  box-shadow:
    0 8px 26px rgba(242, 184, 75, 0.48),
    inset 0 1px 2px rgba(255, 252, 226, 0.85);
  transform: translateY(-1px);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 9px 0;
  color: var(--kp-text-muted);
  font-size: 11.5px;
  font-weight: 500;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(235, 186, 86, 0.35), transparent);
}

/* Form & Inputs */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--kp-text-soft);
}

.input-wrap {
  position: relative;
}

.kp-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: rgba(24, 31, 52, 0.78);
  color: var(--kp-text);
  border: 1px solid rgba(235, 186, 86, 0.44);
  border-radius: 7px;
  font-size: 13.5px;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.kp-input::placeholder {
  color: rgba(173, 186, 214, 0.62);
}

.kp-input:hover {
  border-color: rgba(245, 202, 109, 0.75);
}

.kp-input:focus {
  outline: none;
  border-color: var(--kp-gold-bright);
  background: rgba(28, 38, 66, 0.92);
  box-shadow: 0 0 0 3px rgba(242, 196, 94, 0.2);
}

.kp-input.has-eye {
  padding-right: 38px;
}

.kp-input.is-error {
  border-color: var(--kp-ruby-glow);
  box-shadow: 0 0 0 3px rgba(217, 38, 78, 0.28);
}

.eye-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--kp-gold);
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease;
}

.eye-btn:hover {
  color: var(--kp-gold-bright);
  background: rgba(242, 196, 94, 0.12);
}

.eye-btn .icon-eye-off {
  display: none;
}

.eye-btn[aria-pressed="true"] .icon-eye-open {
  display: none;
}

.eye-btn[aria-pressed="true"] .icon-eye-off {
  display: block;
}

.field-error {
  margin: 0;
  min-height: 14px;
  font-size: 11.5px;
  font-weight: 500;
  color: #ff859d;
}

/* Row between */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
}

.kp-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--kp-text-soft);
  cursor: pointer;
  user-select: none;
}

.kp-check-native {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.kp-check-box {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  border: 1.5px solid var(--kp-border-gold);
  background: rgba(18, 25, 48, 0.85);
  color: transparent;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.kp-check-native:checked + .kp-check-box {
  background: var(--kp-gold);
  border-color: var(--kp-gold-bright);
  color: var(--kp-on-gold);
}

.kp-check-native:focus-visible + .kp-check-box {
  outline: 2px solid var(--kp-focus);
  outline-offset: 2px;
}

/* Switch Toggle (Sign Up Show Password) */
.toggle-row {
  margin: 1px 0 6px;
}

.kp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 2px 0;
  background: transparent;
  border: 0;
  font-size: 12.5px;
  color: var(--kp-text-soft);
  cursor: pointer;
}

.kp-toggle-track {
  width: 36px;
  height: 20px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(30, 41, 74, 0.95);
  border: 1px solid var(--kp-border-gold);
  display: flex;
  align-items: center;
  transition: background-color 180ms ease;
}

.kp-toggle-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--kp-gold-bright);
  transition: transform 200ms var(--ease-out);
}

.kp-toggle[aria-checked="true"] .kp-toggle-track {
  background: rgba(37, 99, 235, 0.85);
}

.kp-toggle[aria-checked="true"] .kp-toggle-knob {
  transform: translateX(16px);
}

/* Text Buttons */
.text-btn {
  padding: 2px 4px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--kp-sapphire-glow);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms ease;
}

.text-btn:hover:not(:disabled) {
  color: var(--kp-gold-bright);
  text-decoration: underline;
}

.text-btn:disabled {
  color: var(--kp-text-muted);
  cursor: not-allowed;
  font-variant-numeric: tabular-nums;
}

.text-btn.strong {
  color: var(--kp-gold);
}

.pane-footer {
  margin: auto 0 0;
  padding-top: 7px;
  text-align: center;
  font-size: 12px;
  color: var(--kp-text-muted);
}

/* Auth Progress Bar */
.auth-progress {
  margin-top: 6px;
}

.auth-progress[hidden] {
  display: none;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--kp-gold-bright);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(30, 41, 72, 0.9);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb 0%, #f2c45e 60%, #ffe69a 100%);
  box-shadow: 0 0 10px rgba(242, 196, 94, 0.65);
}

/* ── PANE 3: OTP ──────────────────────────────────────────────────────────── */
.pane-top-nav {
  margin-bottom: 6px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 2px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--kp-sapphire-glow);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms ease, transform 150ms var(--ease-out);
}

.back-btn:hover {
  color: var(--kp-gold-bright);
  transform: translateX(-2px);
}

.pane-head {
  text-align: center;
  margin-bottom: 10px;
}

.pane-title {
  margin: 0 0 4px;
  font-family: "Outfit", "Inter", sans-serif;
  font-size: 21px;
  font-weight: 700;
  color: var(--kp-gold-bright);
  text-wrap: balance;
}

.pane-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--kp-text-soft);
}

.demo-chip {
  align-self: center;
  margin: 0 auto 14px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.45);
  font-size: 12px;
  color: var(--kp-text-soft);
}

.demo-chip strong {
  color: var(--kp-gold-bright);
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}

.otp-form {
  flex: 1;
  justify-content: center;
  gap: 10px;
}

.otp-group {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.otp-group.is-shaking {
  animation: otpShakeRed 460ms ease-in-out both;
}

@keyframes otpShakeRed {
  0%, 100% { transform: translateX(0); }
  16% { transform: translateX(-9px); }
  32% { transform: translateX(8px); }
  48% { transform: translateX(-6px); }
  64% { transform: translateX(5px); }
  80% { transform: translateX(-3px); }
}

.otp-box {
  width: 56px;
  height: 58px;
  padding: 0;
  text-align: center;
  font-family: "Outfit", "Inter", sans-serif;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: 9px;
}

.kp-input.otp-box.is-error,
.kp-input.otp-box.is-error:focus {
  border-color: var(--kp-ruby-glow);
  background: rgba(168, 24, 58, 0.48);
  color: #ffd9e0;
  box-shadow: 0 0 18px rgba(255, 77, 115, 0.55);
}

.otp-error {
  text-align: center;
  margin-top: 6px;
}

.otp-resend-row {
  margin: 0 0 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--kp-text-soft);
}

/* ── PANE 4: SUCCESS ──────────────────────────────────────────────────────── */
.pane-success {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.success-crest {
  margin-bottom: 4px;
  filter: drop-shadow(0 0 18px rgba(242, 196, 94, 0.55));
  animation: crestPop 420ms var(--ease-out) both;
}

@keyframes crestPop {
  from {
    opacity: 0;
    transform: scale(0.76);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.success-card {
  width: 100%;
  margin: 8px 0 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(20, 30, 58, 0.85);
  border: 1px solid var(--kp-border-gold);
}

.success-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--kp-emerald);
}

.success-identity {
  margin: 4px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--kp-text);
  overflow-wrap: anywhere;
}

.success-auto-note {
  width: 100%;
  margin-top: 6px;
  font-size: 12px;
  color: var(--kp-text-soft);
}

.success-auto-track {
  margin-top: 6px;
  height: 4px;
  border-radius: 999px;
  background: rgba(30, 41, 72, 0.9);
  overflow: hidden;
}

.success-auto-bar {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #2563eb, #f2c45e, #ffe69a);
}

.success-auto-bar.is-running {
  animation: autoReturnBar 1.85s linear forwards;
}

@keyframes autoReturnBar {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ── TOAST ────────────────────────────────────────────────────────────────── */
.toast-region {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  right: max(18px, env(safe-area-inset-right));
  z-index: 950;
  pointer-events: none;
}

.kp-toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  background: var(--kp-obsidian-deep);
  color: var(--kp-text);
  border: 1.5px solid var(--kp-border-gold);
  border-radius: 11px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65), 0 0 20px rgba(242, 196, 94, 0.2);
  font-size: 13px;
  animation: toastIn 240ms var(--ease-out) both;
}

.kp-toast[hidden] {
  display: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.kp-toast-gem {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  transform: rotate(45deg);
  background: var(--kp-gold);
  box-shadow: 0 0 10px rgba(242, 196, 94, 0.85);
}

.kp-toast-close {
  margin-left: 4px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--kp-text-muted);
  font-size: 17px;
  cursor: pointer;
}

.kp-toast-close:hover {
  color: var(--kp-gold-bright);
  background: rgba(255, 255, 255, 0.08);
}

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .auth-card {
    width: 100%;
    height: auto;
    min-height: 492px;
  }

  .auth-card-inner {
    padding: 14px 18px 12px;
  }

  .field-pair {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .otp-box {
    width: 50px;
    height: 54px;
  }

  .dash-entry-link {
    top: max(10px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    padding: 7px 11px;
    font-size: 12px;
  }
}

/* ── REDUCED MOTION ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .stained-glass-svg,
  .sunbeam,
  .caustic-wash,
  .stained-frame::after,
  .kp-btn-primary::after,
  .auth-card,
  .page-shell,
  .pane.is-entering-right,
  .pane.is-entering-left,
  .pane.is-entering-fade,
  .otp-group.is-shaking,
  .success-crest,
  .kp-toast {
    animation: none !important;
  }

  .success-auto-bar.is-running {
    animation-duration: 0.7s;
  }

  .tab-indicator,
  .kp-btn,
  .dash-entry-link,
  .view-veil {
    transition-duration: 0.01ms !important;
  }
}
