:root {
  --bg0: #070a10;
  --bg1: #0e1522;
  --ink: #e8eef7;
  --muted: #8b9bb0;
  --accent: #4f8cff;
  --accent-hot: #7aa8ff;
  --line: rgba(120, 150, 190, 0.22);
  --panel: rgba(14, 22, 36, 0.78);
  --danger: #e35d5d;
  --ok: #4f8cff;
  --warn: #c4a35a;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "Syne", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --header-h: 3.5rem;
  --touch: 2.75rem;
  --pad-x: 1rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.45;
  overflow-x: hidden;
}

.bg {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(1000px 560px at 12% -8%, rgba(79, 140, 255, 0.22), transparent 58%),
    radial-gradient(780px 480px at 92% 8%, rgba(120, 150, 190, 0.12), transparent 55%),
    radial-gradient(640px 420px at 50% 110%, rgba(30, 50, 80, 0.45), transparent 60%),
    linear-gradient(165deg, #06080e 0%, #0c1420 42%, #080c14 100%);
  animation: drift 18s ease-in-out infinite alternate;
}
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(232, 238, 247, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 238, 247, 0.02) 1px, transparent 1px);
  background-size: 100% 5px, 5px 100%;
  mix-blend-mode: soft-light;
}

/* --- Site header: hamburger + one-line brand --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--header-h);
  padding:
    calc(0.55rem + var(--safe-top))
    calc(var(--pad-x) + var(--safe-right))
    0.55rem
    calc(var(--pad-x) + var(--safe-left));
  background: linear-gradient(180deg, rgba(7, 10, 16, 0.92) 0%, rgba(7, 10, 16, 0.72) 70%, transparent 100%);
  pointer-events: none;
}
.site-header > * { pointer-events: auto; }

.site-header .brand {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1rem, 5.4vw, 1.85rem);
  letter-spacing: -0.04em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: visible;
  background: linear-gradient(120deg, #f4f7fc 10%, #9ec0ff 55%, #6a93d9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* Extra room so clipped gradient glyphs stay visible */
  padding-right: 0.14em;
  animation: none;
}
.site-header .brand-text {
  display: inline-block;
  white-space: nowrap;
}

/* Legacy/public brand (secure pages still use .brand in hero) */
.brand {
  font-family: var(--display);
  font-size: clamp(1.35rem, 11.5vw, 5.2rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  margin: 0 0 1.1rem;
  line-height: 0.95;
  text-transform: uppercase;
  max-width: 100%;
  background: linear-gradient(120deg, #f4f7fc 10%, #9ec0ff 55%, #6a93d9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rise 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 100ms;
}
.brand-sm {
  font-size: clamp(1.35rem, 5vw, 2.4rem);
  text-transform: none;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: visible;
}

.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding:
    calc(var(--header-h) + var(--safe-top) + 1.25rem)
    calc(var(--pad-x) + var(--safe-right))
    calc(10vh + var(--safe-bottom))
    calc(var(--pad-x) + var(--safe-left));
  animation: rise 800ms cubic-bezier(0.22, 1, 0.36, 1) both;
  box-sizing: border-box;
}

body.public .stage {
  container-type: inline-size;
  container-name: stage;
  /* Public landing is header + empty stage (scanner via menu) */
  justify-content: flex-start;
  min-height: 0;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

.hero {
  max-width: 920px;
  margin: 0 auto;
  padding:
    calc(var(--header-h) + var(--safe-top) + 1.25rem)
    calc(var(--pad-x) + var(--safe-right))
    1.5rem
    calc(var(--pad-x) + var(--safe-left));
  animation: rise 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero.compact { padding-top: calc(var(--header-h) + var(--safe-top) + 0.75rem); }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-hot);
  margin: 0 0 0.85rem;
  animation: rise 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 60ms;
}

.lede {
  max-width: 28rem;
  color: var(--muted);
  font-size: 1.08rem;
  margin: 0 0 1.6rem;
  animation: rise 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 160ms;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  animation: rise 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 80ms;
}
body.public .cta-row {
  /* Keep CTA visible even if first paint is early */
  animation: rise 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0ms;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0.85rem 1.35rem;
  border-radius: 0.35rem;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary {
  background: var(--accent);
  color: #061018;
  box-shadow: 0 0 0 0 rgba(79, 140, 255, 0.35);
}
.btn.primary:hover {
  background: var(--accent-hot);
  box-shadow: 0 10px 28px rgba(79, 140, 255, 0.22);
}
.btn.ghost {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255,255,255,0.03);
}
.btn.ghost:hover { border-color: var(--accent); }

.admin-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 calc(var(--pad-x) + var(--safe-right)) calc(3rem + var(--safe-bottom)) calc(var(--pad-x) + var(--safe-left));
  display: grid;
  gap: 1.25rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 1.1rem 1.15rem 1.2rem;
  backdrop-filter: blur(10px);
  animation: rise 800ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 120ms;
}
.section-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.9rem;
}
.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
}
.muted { color: var(--muted); margin: 0; font-size: 0.88rem; }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}
.metric {
  padding: 0.7rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.4rem;
  background: rgba(0,0,0,0.22);
}
.metric .label {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.metric .value {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
}

.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { border-top: 1px solid rgba(255,255,255,0.06); }
.link-list li:first-child { border-top: 0; }
.link-list a {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.85rem 0.1rem;
  color: inherit; text-decoration: none;
  min-height: var(--touch);
}
.link-list a:hover strong { color: var(--accent-hot); }
.link-list span { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }

footer {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 calc(var(--pad-x) + var(--safe-right)) calc(2.5rem + var(--safe-bottom)) calc(var(--pad-x) + var(--safe-left));
  color: var(--muted);
  font-size: 0.85rem;
}
footer code {
  font-family: var(--mono);
  color: var(--accent-hot);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes drift {
  from { filter: hue-rotate(0deg) saturate(1); }
  to { filter: hue-rotate(-8deg) saturate(1.08); }
}

/* --- Slide-out nav --- */
.nav-toggle {
  flex: 0 0 auto;
  position: relative;
  top: auto;
  left: auto;
  z-index: 60;
  width: var(--touch);
  height: var(--touch);
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: rgba(8, 12, 20, 0.72);
  backdrop-filter: blur(8px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 160ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-toggle:hover,
.nav-toggle:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform 180ms ease, opacity 180ms ease;
  content: "";
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before { position: absolute; top: -6px; left: 0; }
.nav-toggle-bars::after { position: absolute; top: 6px; left: 0; }
body.nav-open .nav-toggle-bars { background: transparent; }
body.nav-open .nav-toggle-bars::before { top: 0; transform: rotate(45deg); }
body.nav-open .nav-toggle-bars::after { top: 0; transform: rotate(-45deg); }

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(3, 6, 12, 0.55);
  border: 0;
  padding: 0;
  cursor: pointer;
}

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 70;
  width: min(18.5rem, 86vw);
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: linear-gradient(180deg, #0d1524 0%, #0a101a 100%);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  padding:
    calc(1rem + var(--safe-top))
    1rem
    calc(1.5rem + var(--safe-bottom))
    calc(1rem + var(--safe-left));
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 220ms;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.site-nav.is-closed {
  transform: translateX(-105%);
  pointer-events: none;
  visibility: hidden;
}
.site-nav:not(.is-closed) {
  transform: translateX(0);
  visibility: visible;
}
.nav-backdrop.is-closed {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.nav-backdrop:not(.is-closed) {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease;
}

.site-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.15rem;
}
.site-nav-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-close {
  width: var(--touch);
  height: var(--touch);
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-close:hover,
.nav-close:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.site-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}
.site-nav-list a {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0.85rem 0.7rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 0.35rem;
  font-weight: 500;
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.site-nav-list a:hover,
.site-nav-list a:focus-visible {
  background: rgba(79, 140, 255, 0.1);
  border-color: rgba(79, 140, 255, 0.28);
  outline: none;
}

/* --- Phone / narrow --- */
@media (max-width: 480px) {
  :root {
    --header-h: 3.25rem;
    --pad-x: 0.85rem;
  }
  .site-header .brand {
    font-size: clamp(1rem, 6.6vw, 1.4rem);
    letter-spacing: -0.05em;
  }
  .btn.primary {
    width: 100%;
    max-width: 20rem;
  }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lede { font-size: 1rem; }
}

@media (max-width: 360px) {
  .site-header .brand {
    font-size: clamp(0.95rem, 6.2vw, 1.2rem);
  }
}

@media (min-width: 641px) {
  .site-header .brand {
    font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  }
}

@media (max-width: 640px) {
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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