.site-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-5);
  min-height: var(--header-h);
  height: auto;
  padding: 0 var(--page-gutter);
  background: var(--surface-header);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-glyph {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  align-items: end;
  gap: 3px;
  height: 17px;
}

.brand-glyph i {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: bottom;
  animation: brand-glyph var(--motion-ambient) var(--ease-in-out) infinite;
}

.brand-glyph i:nth-child(1) {
  height: 9px;
  animation-delay: -0.2s;
}

.brand-glyph i:nth-child(2) {
  height: 16px;
  animation-delay: -0.05s;
}

.brand-glyph i:nth-child(3) {
  height: 12px;
  animation-delay: -0.35s;
}

@keyframes brand-glyph {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.45);
  }
}

.brand-name {
  font-size: var(--type-small-size);
  white-space: nowrap;
}

.site-nav {
  justify-self: center;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.045);
  border-radius: var(--r-pill);
}

.site-nav a {
  padding: 7px 16px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  font-size: var(--type-small-size);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--motion-switch) var(--motion-ease), background-color var(--motion-switch) var(--motion-ease);
}

.site-nav a:hover {
  color: var(--ink);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.header-note {
  justify-self: end;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
}

.site-main {
  flex: 1;
  padding-top: var(--header-h);
  outline: none;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-6) var(--page-gutter) var(--space-7);
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--text-xs);
}

.site-footer p {
  max-width: 52ch;
}

.site-footer code {
  font-size: 0.95em;
}

@media (max-width: 720px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .header-note {
    display: none;
  }

  .site-footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-glyph i {
    animation: none;
  }
}
/* Primary destinations stay reachable on narrow screens. */
.site-nav { position:relative; isolation:isolate; }
.site-nav a { padding-inline:14px; transition:color var(--motion-switch),background-color var(--motion-switch),box-shadow var(--motion-switch); }
.site-nav a:active { transform:scale(.97); }
.site-nav a[aria-current="page"] { box-shadow:0 1px 4px #0000000d; }
@media(max-width:1100px) {
 .site-header { grid-template-columns:1fr auto; gap:8px 14px; padding-block:8px; }
 .site-nav { grid-column:1/-1; grid-row:2; justify-self:center; flex-wrap:wrap; justify-content:center; margin-bottom:0; }
}
@media(max-width:880px) {
 .site-header { grid-template-columns:1fr auto; gap:8px 12px; }
 .site-header .motion-setting { justify-self:end; max-width:180px; }
 .site-nav { grid-column:1/-1; grid-row:2; justify-self:center; margin-bottom:0; }
 :root { --header-h:118px; }
 .site-header { align-content:center; }
}
@media(max-width:480px) {
 .site-header { padding-inline:16px; }
 .brand-name { font-size:var(--type-meta-size); }
 .site-header .motion-setting { font-size:var(--type-eyebrow-size); width:142px; }
 .site-nav { width:100%; gap:2px; }
 .site-nav a { flex:0 0 auto; padding:6px 9px; font-size:var(--type-meta-size); }
}
.nav-selection { position:absolute; top:0; left:0; border-radius:var(--r-pill); background:var(--surface); box-shadow:0 1px 5px #0000000e; pointer-events:none; z-index:0; }
.site-nav.has-selection a { position:relative; z-index:1; }
.site-nav.has-selection a[aria-current="page"] { background:transparent; box-shadow:none; }
.back-to-top {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 60;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-translucent);
  color: var(--ink-2);
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: var(--type-body-size);
  cursor: pointer;
}
.back-to-top:hover { color: var(--ink); transform: translateY(-2px); }
.back-to-top[hidden] { display: none; }
