.guide-masthead {
  --menu-height: 68px;
  --menu-edge: #d9d3c9;
  position: sticky;
  top: 0;
  z-index: 25;
  color: var(--ink);
  background: var(--paper);
  border-bottom: 1px solid var(--menu-edge);
}

.guide-menu-row.wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--menu-height);
  padding-right: calc(48px + env(safe-area-inset-right, 0px));
}

.guide-masthead nav {
  position: static;
  z-index: auto;
  background: transparent;
  backdrop-filter: none;
  border: 0;
}

.guide-masthead details {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.guide-masthead a { text-decoration: none; }

.guide-menu-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-right: auto;
}

.guide-menu-brand img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 25%;
}

.guide-menu-title {
  font: 600 25px/1 Fraunces, Georgia, serif;
  letter-spacing: -.045em;
  white-space: nowrap;
}

.guide-masthead summary,
.guide-menu-install {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--menu-edge);
  border-radius: 999px;
  font: 600 14px/1.2 Inter, system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.guide-masthead summary { list-style: none; }
.guide-masthead summary::-webkit-details-marker { display: none; }

.guide-masthead details > summary::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  color: inherit;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
}

.guide-masthead details[open] > summary::after {
  transform: translateY(1px) rotate(225deg);
}

.guide-masthead details[open] > summary { border-color: var(--ink); }

.guide-menu-install {
  color: var(--studio-on-accent);
  background: var(--studio-accent);
  border-color: color-mix(in srgb, var(--studio-accent) 80%, var(--ink));
}

.guide-menu-arrow {
  position: relative;
  display: inline-block;
  width: 9px;
  height: 9px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
}

.guide-menu-arrow::before {
  content: "";
  position: absolute;
  top: -1px;
  right: 0;
  width: 11px;
  border-top: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transform-origin: right center;
}

.guide-menu-kicker,
.guide-menu-group h2 {
  color: var(--muted);
  font: 600 10px/1.4 Inter, system-ui, sans-serif;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.guide-masthead .guide-menu-sections,
.guide-menu-explore,
.guide-masthead details:not([open]) > .guide-menu-popover { display: none; }

.guide-masthead .guide-menu-popover {
  position: absolute;
  top: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: calc(100vh - var(--menu-height) - 12px);
  max-height: calc(100dvh - var(--menu-height) - 12px);
  background: var(--paper);
  border: 1px solid var(--menu-edge);
  box-shadow: 0 12px 24px rgb(27 27 31 / 9%);
}

.guide-masthead .guide-menu-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 20px;
  right: calc(48px + env(safe-area-inset-right, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  max-width: 520px;
  margin-left: auto;
  padding: 18px 16px 12px;
  border-radius: 0 0 14px 14px;
}

.guide-menu-group + .guide-menu-group {
  padding-left: 18px;
  border-left: 1px solid var(--menu-edge);
}

.guide-menu-group h2 { margin: 0 0 7px; }

.guide-menu-popover a,
.guide-menu-sections a {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font: 500 14px/1.4 Inter, system-ui, sans-serif;
}

.guide-menu-sections a { justify-content: center; }

.guide-menu-group:first-child a {
  font: 600 17px/1.2 Fraunces, Georgia, serif;
  letter-spacing: -.02em;
}

.guide-masthead a[aria-current="location"] {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--studio-accent) 65%, var(--ink));
  text-underline-offset: .32em;
  text-decoration-thickness: 2px;
}

@media (hover: hover) {
  .guide-masthead summary:hover { border-color: var(--ink); }
  .guide-menu-install:hover { box-shadow: inset 0 0 0 1px currentColor; }
  .guide-menu-popover a:hover,
  .guide-menu-sections a:hover { text-decoration: underline; text-underline-offset: .25em; }
}

.guide-masthead :is(a, summary):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .guide-menu-row.wrap { gap: 6px; padding-left: max(12px, env(safe-area-inset-left, 0px)); }
  .guide-menu-brand { gap: 6px; }
  .guide-menu-brand img { width: 34px; height: 34px; }
  .guide-menu-title { font-size: 20px; }
  .guide-masthead summary, .guide-menu-install { gap: 6px; padding-inline: 9px; font-size: 13px; }
  .guide-menu-install .guide-menu-arrow { display: none; }
}

@media (max-width: 369px) {
  .guide-masthead .guide-menu-panel { grid-template-columns: 1fr; gap: 12px; }
  .guide-menu-group + .guide-menu-group { padding: 12px 0 0; border: 0; border-top: 1px solid var(--menu-edge); }
}

@media (max-width: 345px) {
  .guide-menu-row.wrap, .guide-menu-brand { gap: 4px; }
  .guide-menu-brand img { width: 32px; height: 32px; }
  .guide-menu-title { font-size: 18px; }
  .guide-masthead summary, .guide-menu-install { padding-inline: 6px; }
}

/* Keep native-only navigation in the document flow so fragment jumps reveal the destination. */
@media (max-width: 999px) {
  .guide-masthead:has(.guide-menu-mobile > summary:not([aria-expanded])) { position: relative; }
}

@media (min-width: 1000px) {
  .guide-masthead { --menu-height: 76px; }
  .guide-menu-row.wrap { gap: 18px; padding-right: 24px; }
  .guide-menu-brand img { width: 44px; height: 44px; }
  .guide-menu-mobile { display: none; }
  .guide-masthead .guide-menu-sections { display: flex; align-items: center; gap: 18px; }
  .guide-menu-sections a { min-width: 44px; white-space: nowrap; }
  .guide-menu-explore { display: block; position: relative; }
  .guide-menu-explore > summary { border-color: transparent; }
  .guide-masthead .guide-menu-sites { right: 0; width: max-content; min-width: 194px; padding: 6px 16px; border-radius: 12px; }
  .guide-menu-kicker { padding-left: 16px; border-left: 1px solid var(--menu-edge); }
}

@media (min-width: 1000px) and (pointer: coarse), (min-width: 1000px) and (max-width: 1024px) and (max-height: 540px) {
  .guide-menu-row.wrap { padding-right: calc(48px + env(safe-area-inset-right, 0px)); }
}
