/* Ghostmode authentication surface. This intentionally owns the entire launch
   viewport; the application shell remains mounted but cannot show through. */
body.launch-active {
  overflow: hidden;
}

body.launch-active .topbar,
body.launch-active .bottom-nav {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.launch-splash {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100;
  display: block !important;
  padding: 0 !important;
  overflow: hidden;
  background: #f6f9fd !important;
  opacity: 1;
  visibility: visible;
  transition: opacity 620ms ease, visibility 620ms ease, background-color 450ms ease;
  isolation: isolate;
}

.launch-splash::before,
.launch-splash::after {
  content: none !important;
  display: none !important;
}

html[data-theme="dark"] .launch-splash {
  background: #050a16 !important;
}

.launch-splash.launch-hiding {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.launch-smoke {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 1;
  pointer-events: auto;
  touch-action: none;
  filter: saturate(1.22) contrast(1.08);
}

html[data-theme="dark"] .launch-smoke {
  filter: saturate(1.24) brightness(1.1) contrast(1.05);
}

.launch-theme-toggle,
.launch-language-toggle {
  position: fixed;
  z-index: 104;
  top: calc(22px + env(safe-area-inset-top));
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(50, 92, 160, .15);
  color: #51709c;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 2px 7px rgba(24, 58, 107, .08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform 180ms ease, background-color 450ms ease, border-color 450ms ease, color 450ms ease;
}

/* Keep these controls in physical corners even when the interface switches
   to RTL. Language direction must not mirror the launch composition. */
html[dir] .launch-theme-toggle {
  left: calc(16px + env(safe-area-inset-left)) !important;
  right: auto !important;
}

html[dir] .launch-language-toggle {
  left: auto !important;
  right: calc(16px + env(safe-area-inset-right)) !important;
}

.launch-theme-toggle:hover,
.launch-language-toggle:hover {
  transform: translateY(-1px) scale(1.04);
}

.launch-theme-toggle:active,
.launch-language-toggle:active {
  transform: scale(.94);
}

.launch-theme-toggle {
  left: calc(16px + env(safe-area-inset-left));
  width: 30px;
  padding: 0;
  border-radius: 50%;
  font: 700 13px/1 "Cairo", sans-serif;
}

.launch-language-toggle {
  right: calc(16px + env(safe-area-inset-right));
  min-width: 47px;
  padding: 0 12px;
  border-radius: 999px;
  font: 700 11px/1 "Cairo", sans-serif;
}

html[data-theme="dark"] .launch-theme-toggle,
html[data-theme="dark"] .launch-language-toggle {
  color: #dbe9ff;
  border-color: rgba(96, 157, 255, .24);
  background: rgba(10, 19, 37, .66);
  box-shadow: inset 0 0 0 1px rgba(83, 137, 229, .04), 0 4px 16px rgba(0, 0, 0, .18);
}

.smoke-tuner {
  position: fixed;
  z-index: 106;
  top: calc(72px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: min(330px, calc(100vw - 32px));
  max-height: calc(100dvh - 96px - env(safe-area-inset-top));
  padding: 15px;
  overflow-y: auto;
  border: 1px solid rgba(58, 107, 186, .16);
  border-radius: 16px;
  color: #203858;
  background: rgba(247, 251, 255, .86);
  box-shadow: 0 18px 48px rgba(35, 77, 136, .14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 220ms ease, transform 220ms ease, background-color 450ms ease;
}

html[data-theme="dark"] .smoke-tuner {
  color: #e8f1ff;
  border-color: rgba(84, 145, 247, .24);
  background: rgba(7, 16, 33, .82);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.smoke-tuner.is-collapsed { opacity: 0; transform: translateY(-8px) scale(.98); pointer-events: none; }
.smoke-tuner-head,
.smoke-tuner label > span { display: flex; align-items: center; justify-content: space-between; }
.smoke-tuner-head { margin-bottom: 11px; }
.smoke-tuner-head strong { font: 700 14px/1 "Cairo", sans-serif; }
.smoke-tuner-head > span { color: #347cf4; font: 800 8px/1 "Cairo", sans-serif; letter-spacing: .14em; }
.smoke-tuner label { display: grid; gap: 4px; margin-top: 7px; font: 600 10px/1.1 "Cairo", sans-serif; }
.smoke-tuner output { color: #4774b7; font: 700 9px/1 monospace; }
html[data-theme="dark"] .smoke-tuner output { color: #76a8ff; }
.smoke-tuner input[type="range"] { width: 100%; height: 14px; margin: 0; accent-color: #397df4; cursor: ew-resize; }
.smoke-tuner details { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(57, 103, 170, .14); }
.smoke-tuner summary { color: #3566a7; font: 800 9px/1.2 "Cairo", sans-serif; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; user-select: none; }
html[data-theme="dark"] .smoke-tuner summary { color: #80acfa; }
.smoke-tuner select,
.smoke-tuner input[type="text"] {
  width: 100%; height: 30px; padding: 0 9px; border: 1px solid rgba(61, 113, 194, .2); border-radius: 8px;
  color: inherit; background: rgba(255, 255, 255, .48); font: 600 10px/1 "Cairo", sans-serif;
}
html[data-theme="dark"] .smoke-tuner select,
html[data-theme="dark"] .smoke-tuner input[type="text"] { background: rgba(20, 39, 70, .66); color-scheme: dark; }
.smoke-tuner .smoke-color { grid-template-columns: 1fr auto; align-items: center; }
.smoke-tuner .smoke-color input[type="color"] { width: 44px; height: 25px; padding: 2px; border: 1px solid rgba(61, 113, 194, .24); border-radius: 7px; background: transparent; cursor: pointer; }

.smoke-tuner-confirm,
.smoke-tuner-reference,
.smoke-tuner-open {
  border: 1px solid rgba(53, 116, 224, .28);
  color: #fff;
  background: #367df5;
  box-shadow: 0 7px 18px rgba(36, 101, 215, .2);
  font: 700 10px/1 "Cairo", sans-serif;
  cursor: pointer;
}

.smoke-tuner-confirm { width: 100%; height: 36px; margin-top: 13px; border-radius: 10px; }
.smoke-tuner-reference {
  width: 100%;
  height: 32px;
  margin-top: 12px;
  border-radius: 10px;
  color: #2d64b8;
  background: rgba(55, 124, 245, .08);
  box-shadow: none;
}
html[data-theme="dark"] .smoke-tuner-reference { color: #a8c8ff; background: rgba(69, 135, 248, .1); }
.smoke-tuner-open {
  position: fixed;
  z-index: 106;
  top: calc(72px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  min-width: 88px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
}

@media (max-width: 560px) {
  .smoke-tuner { top: calc(64px + env(safe-area-inset-top)); right: 50%; width: min(340px, calc(100vw - 32px)); max-height: calc(100dvh - 92px); transform: translateX(50%); }
  .smoke-tuner.is-collapsed { transform: translateX(50%) translateY(-8px) scale(.98); }
}

body.launch-active #onboarding.is-open:has(.auth-step.is-active) {
  position: fixed;
  inset: 0;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 103;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none !important;
  pointer-events: none;
}

body.launch-active #onboarding.is-open:has(.auth-step.is-active) > .close-button {
  display: none;
}

body.launch-active #onboarding.is-open:has(.auth-step.is-active) .auth-step {
  display: block;
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.auth-step .auth-actions {
  position: fixed;
  z-index: 105;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: min(292px, calc(100vw - 48px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

body.launch-active #onboarding.is-open:has(.auth-step.is-active) .auth-actions {
  width: min(292px, calc(100vw - 48px)) !important;
  gap: 8px !important;
}

.google-control {
  position: relative;
  width: 100%;
  height: 42px;
}

.google-button {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 42px;
  min-height: 42px !important;
  margin: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  border: 1px solid rgba(66, 111, 180, .18);
  border-radius: 10px;
  color: #0d1728;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 5px 18px rgba(35, 74, 130, .09);
  font: 800 11px/1 "Cairo", sans-serif;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 450ms ease, color 450ms ease, border-color 450ms ease;
}

.google-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(34, 85, 165, .14);
}

.google-button:active {
  transform: scale(.985);
}

.google-g {
  display: block;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  margin: 0 !important;
}

.google-label {
  display: block;
  margin: 0 !important;
  color: inherit !important;
  font: inherit !important;
  line-height: 1.2 !important;
  text-transform: none;
  white-space: nowrap;
}

html[dir="rtl"] .google-button {
  direction: rtl;
  gap: 10px;
  padding-inline: 16px;
  font-size: 12px;
  letter-spacing: 0;
}

html[dir="rtl"] .google-label {
  direction: rtl;
  unicode-bidi: plaintext;
}

html[data-theme="dark"] .google-button {
  color: #f4f8ff;
  border-color: rgba(75, 139, 247, .28);
  background: rgba(10, 20, 39, .64);
  box-shadow: inset 0 0 0 1px rgba(41, 103, 211, .05), 0 8px 28px rgba(0, 0, 0, .16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.google-button-host {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 42px;
  min-height: 42px !important;
  margin: 0 !important;
  overflow: hidden;
  opacity: .001;
  cursor: pointer;
}

.google-button-host > div,
.google-button-host iframe {
  width: 100% !important;
  min-width: 100% !important;
  height: 42px !important;
}

.google-login-status {
  display: none;
  max-width: 100%;
  color: #537099;
  font: 600 8px/1.35 "Cairo", sans-serif;
  text-align: center;
}

.google-login-status:not(:empty) {
  display: block;
}

.launch-legal {
  margin: 0;
  color: #71819a;
  font: 700 6px/1.4 "Cairo", sans-serif;
  letter-spacing: .17em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

html[data-theme="dark"] .google-login-status,
html[data-theme="dark"] .launch-legal {
  color: rgba(188, 207, 238, .58);
}

@media (min-width: 768px) {
  .launch-theme-toggle,
  .launch-language-toggle {
    top: calc(26px + env(safe-area-inset-top));
  }

  html[dir] .launch-theme-toggle {
    left: calc(28px + env(safe-area-inset-left));
  }

  html[dir] .launch-language-toggle {
    right: calc(28px + env(safe-area-inset-right));
  }

  .auth-step .auth-actions {
    bottom: calc(26px + env(safe-area-inset-bottom));
    width: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .launch-splash,
  .launch-theme-toggle,
  .launch-language-toggle,
  .google-button {
    transition-duration: 1ms !important;
  }
}
