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

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  min-height: 100%;
}

html,
body,
body * {
  scrollbar-color: var(--color-bg) var(--color-bg);
  scrollbar-width: thin;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
body *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html::-webkit-scrollbar-track,
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-track,
body::-webkit-scrollbar-thumb,
body *::-webkit-scrollbar-track,
body *::-webkit-scrollbar-thumb {
  background: var(--color-bg);
}

html:has(body[data-auth-page="public"]),
body[data-auth-page="public"],
body[data-auth-page="public"] * {
  scrollbar-color: rgba(148, 163, 184, .42) var(--color-bg);
  scrollbar-width: thin;
}

html:has(body[data-auth-page="public"])::-webkit-scrollbar,
body[data-auth-page="public"]::-webkit-scrollbar,
body[data-auth-page="public"] *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html:has(body[data-auth-page="public"])::-webkit-scrollbar-track,
body[data-auth-page="public"]::-webkit-scrollbar-track,
body[data-auth-page="public"] *::-webkit-scrollbar-track {
  background: var(--color-bg);
}

html:has(body[data-auth-page="public"])::-webkit-scrollbar-thumb,
body[data-auth-page="public"]::-webkit-scrollbar-thumb,
body[data-auth-page="public"] *::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .42);
  border: 2px solid var(--color-bg);
  border-radius: 999px;
}

html:has(body[data-auth-page="public"])::-webkit-scrollbar-thumb:hover,
body[data-auth-page="public"]::-webkit-scrollbar-thumb:hover,
body[data-auth-page="public"] *::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, .62);
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

a {
  color: inherit;
}

a,
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

.footer > div:first-child,
.page-footer > div:first-child,
.reset-footer > div:first-child {
  order: 2;
  font-family: var(--font-sans, var(--font-body, "DM Sans", system-ui, sans-serif));
  font-size: .75rem;
  font-weight: 400;
  line-height: 1.4;
}

.footer > .footer-links,
.page-footer > .footer-links,
.reset-footer > .footer-links {
  order: 1;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
svg {
  max-width: 100%;
}

body.perf-light *,
body.perf-light *::before,
body.perf-light *::after {
  animation: none !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

body.perf-light .site-header,
body.perf-light .header,
body.perf-light .bg-mesh,
body.perf-light .bg,
body.perf-light .app-bg,
body.perf-light .bg-noise,
body.perf-light .app-bg-noise,
body.perf-light .modal-overlay,
body.perf-light .pricing-modal,
body.perf-light .flow-line,
body.perf-light .hero-glow,
body.perf-light .cta-glow,
body.perf-light .mini-badge,
body.perf-light .routine-scroll,
body.perf-light .pricing-card,
body.perf-light .feature-card,
body.perf-light .contact-card,
body.perf-light .metric-card,
body.perf-light .surface-card,
body.perf-light .ui-surface {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
  box-shadow: none !important;
}

body.perf-light .bg-mesh::before,
body.perf-light .bg-mesh::after,
body.perf-light .bg::before,
body.perf-light .bg::after,
body.perf-light .flow-line::before,
body.perf-light .flow-line::after {
  animation: none !important;
  filter: none !important;
}

section[id],
.section-anchor {
  scroll-margin-top: var(--public-anchor-offset, 96px);
}

.hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--color-text, #f1f5f9);
  color: var(--color-bg, #080c14);
  text-decoration: none;
  font-weight: 800;
  transition: top .2s ease;
}

.skip-link:focus {
  top: 14px;
}

/* Canonical public-auth visibility contract.  User controls are fail-closed
   until this document lifecycle has confirmed the cookie session. */
html:not([data-auth-state="authenticated"]) [data-auth-visible="user"] {
  display: none !important;
}

html[data-auth-state="authenticated"] [data-auth-visible="guest"],
html[data-auth-state="checking"] [data-auth-visible="guest"] {
  display: none !important;
}

body[data-auth-required="true"] [data-auth-visible="guest"] {
  display: none !important;
}

/* Private pages are fail-closed until /users/me confirms this document lifecycle.
   The gate remains visible even if the rest of the page or a later script fails. */
body[data-auth-required="true"]:not([data-auth-state="authenticated"]) #protected-page-root {
  visibility: hidden !important;
  pointer-events: none !important;
  user-select: none !important;
}

body[data-auth-required="true"][data-auth-state="authenticated"] #protected-page-root {
  visibility: visible;
  pointer-events: auto;
  user-select: auto;
}

body[data-auth-required="true"][data-protected-bootstrap="true"]:not([data-protected-page-mounted="true"]) #protected-page-root {
  visibility: hidden !important;
  pointer-events: none !important;
  user-select: none !important;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #07101f;
  color: #f8fafc;
}

.auth-gate[hidden],
body[data-auth-required="true"][data-auth-state="authenticated"] .auth-gate {
  display: none !important;
}

.auth-gate__panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 20px;
  background: #0f172a;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
  text-align: center;
}

.auth-gate__brand {
  margin-bottom: 18px;
  color: #a5b4fc;
  font: 800 1.1rem/1 "Syne", system-ui, sans-serif;
  letter-spacing: .04em;
}

.auth-gate__panel h1 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  line-height: 1.3;
}

.auth-gate__panel p {
  margin: 0;
  color: #cbd5e1;
  font-size: .96rem;
  line-height: 1.55;
}

.auth-gate__actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

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

.auth-gate__actions button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  font: 700 .95rem/1.2 inherit;
  cursor: pointer;
}

.auth-gate__actions button.auth-gate__secondary {
  border: 1px solid rgba(148, 163, 184, .35);
  background: transparent;
  color: #e2e8f0;
}

/* Checking is deliberately distinct from the confirmed guest state. */
.auth-gate--warm {
  align-items: flex-start;
  justify-content: flex-end;
  padding: 16px;
  background: transparent;
  pointer-events: none;
}

.auth-gate--warm .auth-gate__panel {
  width: auto;
  min-width: 0;
  padding: 10px 14px;
  border-color: rgba(148, 163, 184, .18);
  border-radius: 12px;
  background: rgba(15, 23, 42, .82);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}

.auth-gate--warm .auth-gate__brand,
.auth-gate--warm .auth-gate__panel p {
  display: none;
}

.auth-gate--warm .auth-gate__panel h1 {
  margin: 0;
  font-size: .85rem;
}

[data-internal-route-root][aria-busy="true"] {
  min-height: 42vh;
}

[data-internal-route-root] {
  width: 100%;
  min-width: 0;
}

.internal-route-skeleton {
  display: grid;
  gap: 14px;
  max-width: 1120px;
  min-height: 42vh;
  margin: 28px auto;
  padding: 28px;
}

.internal-route-skeleton span {
  display: block;
  height: 72px;
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(148, 163, 184, .12), rgba(148, 163, 184, .24), rgba(148, 163, 184, .12));
  background-size: 200% 100%;
  animation: internal-route-shimmer 1.2s linear infinite;
}

.internal-route-skeleton span:first-child { height: 112px; }

.internal-route-error {
  max-width: 620px;
  margin: 64px auto;
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 16px;
  background: rgba(15, 23, 42, .84);
  color: #f8fafc;
  text-align: center;
}

@keyframes internal-route-shimmer {
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 768px) {
  .bg-mesh,
  .bg,
  .app-bg,
  .flow-line,
  .modal-overlay,
  .pricing-modal,
  .site-header,
  .header,
  .feature-card,
  .pricing-card,
  .contact-card,
  .metric-card,
  .surface-card,
  .ui-surface {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
  }

  .bg-mesh::before,
  .bg-mesh::after,
  .bg::before,
  .bg::after,
  .flow-line::before,
  .flow-line::after {
    animation: none !important;
    filter: none !important;
  }
}


/* Public shared footer alignment v301 */
.footer.container {
  width: min(100%, 1160px) !important;
  box-sizing: border-box !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
  justify-content: center !important;
}

.page-footer,
.reset-footer {
  justify-content: center !important;
}

.footer.container > * {
  min-width: 0;
}

@media (max-width: 900px) {
  .footer.container {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    text-align: center !important;
  }

  .footer.container .footer-links {
    justify-content: center !important;
  }

  .page-footer,
  .reset-footer {
    justify-content: center !important;
  }
}

@media (max-width: 430px) {
  .footer.container {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
}


/* Public clipped animation overflow guard v302 */
@media (max-width: 1080px) {
  .reveal-left,
  .reveal-right {
    transform: translateY(18px) !important;
  }

  .reveal-left.visible,
  .reveal-right.visible {
    transform: none !important;
  }
}
