.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--hud-h);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 var(--gutter);
  background: linear-gradient(rgb(var(--space-rgb) / 0.78), rgb(var(--space-rgb) / 0));
}

.topbar::after {
  content: "";
  position: absolute;
  left: var(--gutter); right: var(--gutter); bottom: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, rgb(255 255 255 / 0), rgb(255 255 255 / 0.11) 14%, rgb(255 255 255 / 0.11) 86%, rgb(255 255 255 / 0));
}

.brand { display: flex; align-items: center; flex-shrink: 0; color: var(--text); }
.brand img { display: block; height: var(--brand-h); width: auto; max-width: none; }

.bar-end { display: flex; align-items: center; gap: clamp(22px, 2.8vw, 44px); }
.nav { display: flex; align-items: center; }
.menu { display: flex; gap: clamp(18px, 2.2vw, 36px); margin: 0; padding: 0; list-style: none; }
.menu a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 10px 0;
  transition: color 0.2s;
}
.menu a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 2px;
  height: 1px;
  background: var(--text);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s var(--ease-out);
}
.menu a:hover, .menu a[aria-current="true"] { color: var(--text); }
.menu a[aria-current="true"]::after { transform: scaleX(1); }
.menu .menu-contact { display: none; }

.menu-btn {
  display: none;
  background: rgb(var(--space-rgb) / 0.5);
  border: 1px solid var(--hairline-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.rail {
  position: fixed;
  right: max(14px, calc(var(--gutter) - 52px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
}
.rail ol { display: grid; gap: 4px; }
.rail button {
  position: relative;
  display: block;
  width: 28px;
  height: 22px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}
.rail button::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 10px;
  height: 1.5px;
  background: rgb(255 255 255 / 0.3);
  transform: translateY(-50%);
  transition: width 0.35s var(--ease-out), background-color 0.3s;
}
.rail button:hover::before { width: 18px; background: rgb(255 255 255 / 0.6); }
.rail button[aria-current="true"]::before { width: 24px; background: var(--text); }
.rail .rail-name {
  position: absolute;
  right: 38px;
  top: 50%;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translate(6px, -50%);
  transition: opacity 0.2s, transform 0.2s;
}
.rail button:hover .rail-name, .rail button:focus-visible .rail-name { opacity: 1; transform: translate(0, -50%); }

.next-cue {
  position: fixed;
  right: max(14px, calc(var(--gutter) - 52px));
  bottom: 18px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 10px 10px;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
}
.next-cue svg { width: 20px; height: 20px; flex-shrink: 0; transition: transform 0.3s var(--ease-out); }
.next-cue:hover { color: var(--text); }
.next-cue:hover svg { transform: translateY(2px); }
.next-cue.is-up svg { transform: rotate(180deg); }
.next-cue.is-up:hover svg { transform: rotate(180deg) translateY(2px); }

.flash {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgb(255 241 214 / 0.4), rgb(255 241 214 / 0.1) 40%, rgb(255 241 214 / 0) 70%);
}
.flash.is-on { animation: flash 0.5s ease-out; }
@keyframes flash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

html.still .topbar, html.still .rail, html.still .next-cue { display: none; }

@media (max-width: 900px) {
  .next-cue { display: none; }
}

@media (max-width: 860px) {
  .btn-nav { display: none; }
  .menu-btn { display: inline-block; }
  .menu {
    position: fixed;
    inset: var(--hud-h) 0 0 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 22px;
    padding: 0 var(--gutter);
    background: var(--space);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0s 0.25s;
  }
  .menu.is-open { opacity: 1; visibility: visible; transition: opacity 0.25s, visibility 0s; }
  .menu a { font-size: 1.8rem; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
  .menu a::after { display: none; }
  .menu .menu-contact { display: block; }
  .rail { right: 6px; }
  .rail .rail-name { display: none; }
}

.menu .menu-reach { display: none; }
@media (max-width: 860px) {
  .menu .menu-reach { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 10px; }
  .menu .menu-reach a { font-size: 1rem; font-weight: 500; color: var(--muted); padding: 10px 0; }
}
