header {
  position: relative;
  z-index: 10;
  /* Flex: logo left, config right; global toolbar is position:absolute true center (see .header-stream-toolbar). */
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Tighter on short viewports so the bar does not dominate small screens (still respects --ui-scale). */
  padding-block: var(--header-pad-block);
  padding-inline: max(clamp(6px, 1.8vw, 11px), env(safe-area-inset-left, 0px)) max(clamp(6px, 1.8vw, 11px), env(safe-area-inset-right, 0px));
  min-height: var(--header-bar-height);
  height: var(--header-bar-height);
  /* Config Sidebar Scale × viewport shrink so low-res layouts are not dominated by chrome. */
  zoom: var(--header-viewport-scale, 1);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--header-radar-to-wordmark-gap);
  min-width: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  padding: 0;
  /* Full header height so the sidebar-toggle column can stretch; implied “box” uses screen edge + bar top/bottom + this rule. */
  align-self: stretch;
}

.header-stream-toolbar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  min-width: 0;
  max-width: min(100%, calc(100vw - 200px));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 8px;
  box-sizing: border-box;
  pointer-events: none;
}
.header-stream-toolbar .stream-global-toolbar {
  pointer-events: auto;
}
.stream-global-toolbar--header {
  flex-direction: row;
  flex-wrap: nowrap;
  width: auto;
  max-width: 100%;
  gap: 6px 10px;
}
.stream-global-toolbar--header .stream-global-toolbar-heading {
  display: none;
}

/* Toggle + radar — wider gap after the rule than inside the toggle (--header-rule-to-radar-gap). */
.header-logo-cluster {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: var(--header-rule-to-radar-gap);
  flex-shrink: 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: var(--header-logo-text);
  letter-spacing: 0.04em;
  color: var(--text-primary);
  cursor: default;
  user-select: none;
  /* Nudge down vs flex center — caps read high next to the circular dish. */
  transform: translateY(0.025em);
}
.logo span { color: var(--accent); }

.header-logo-sweeper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--header-radar);
  height: var(--header-radar);
  opacity: 1;
}
.header-logo-sweeper-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Poll sweep: rotate wedge + beam around dish center (translate(16,16) parent). */
.poll-radar-svg .poll-radar-sweep {
  transform-origin: 0 0;
  animation: empty-radar-spin var(--poll-radar-period, 6s) linear infinite;
}

/* Fixed contacts: opacity is driven by JS (keyframed 0→1 flash→fade); default 0 until first paint. */
.poll-radar-svg .poll-radar-blip-hit {
  --peak: 0;
  opacity: 0;
}

@keyframes poll-radar-blip-sweep-hit {
  0%, 14% { opacity: 1; }
  62% { opacity: 0.14; }
  100% { opacity: 0.14; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1;
}
.settings-btn__icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  align-self: center;
}
.settings-btn__label {
  display: inline-flex;
  align-items: center;
  height: 20px;
  line-height: 1;
}

/*
 * Global controls: fixed icon size inside a slightly larger hit box so glyphs do not fill the square.
 * (Sidebar streamers reuses .sidebar-sel-ic-btn with transform: scale(0.92) — neutralized below in sidebar CSS.)
 */
header .stream-global-toolbar .sidebar-sel-ic-btn {
  box-sizing: border-box;
  padding: 0 !important;
  width: var(--header-hit);
  height: var(--header-hit);
  min-width: 0;
  min-height: 0;
}
header .stream-global-toolbar .sidebar-sel-ic-btn svg {
  width: var(--header-glyph) !important;
  height: var(--header-glyph) !important;
  max-width: var(--header-glyph);
  max-height: var(--header-glyph);
  flex-shrink: 0;
}
header .settings-btn__icon {
  width: var(--header-glyph) !important;
  height: var(--header-glyph) !important;
  max-width: var(--header-glyph);
  max-height: var(--header-glyph);
}
header .settings-btn__label {
  height: auto;
  min-height: var(--header-glyph);
  font-size: var(--header-btn-text);
}
/*
 * Match .btn label rhythm to bar; base .btn is 13px fixed with 7px 16px padding — without this,
 * Chat/Config stay visually “stuck” while global toolbar uses --header-hit (components-chat loads after).
 */
header .settings-btn {
  font-size: var(--header-btn-text);
  box-sizing: border-box;
  min-height: var(--header-hit);
  padding-block: clamp(3px, calc(var(--header-bar-height) * 0.08), 7px);
  padding-inline: clamp(7px, calc(var(--header-bar-height) * 0.18 + 0.22vw), 13px);
  gap: clamp(4px, 0.35vw + 2px, 8px);
}

/*
 * Sidebar toggle: implied column — only a vertical rule on the right; header padding + top/bottom of
 * the bar act as the other edges (modals-config resets generic .sidebar-toggle--header).
 */
header .sidebar-toggle--header {
  box-sizing: border-box;
  position: relative;
  align-self: stretch;
  /* Definite width: only in-flow content was the SVG; abs-only patterns collapse width oddly on <button>. */
  width: calc(var(--header-toggle-inset-x) * 2 + var(--header-sidebar-tab-slot));
  min-width: calc(var(--header-toggle-inset-x) * 2 + var(--header-sidebar-tab-slot));
  height: auto;
  min-height: var(--header-hit);
  padding-inline: var(--header-toggle-inset-x);
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  display: block;
}
header .sidebar-toggle--header::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-bright);
  pointer-events: none;
  z-index: 1;
}
header .sidebar-toggle--header:hover {
  background: transparent;
}
/*
 * Header: cancel modals-config scale(1.4). Geometric center: inset 0 + margin auto in the button
 * padding box. Optical center ≠ that: non-scaling strokes, viewBox slack, and the tab art sit
 * visually up/right — nudge with translate so the painted glyph matches what the ruler implies.
 */
header .sidebar-toggle-tab-icon {
  position: absolute;
  inset: 0;
  display: block;
  width: var(--header-sidebar-tab-slot);
  height: var(--header-sidebar-tab-slot);
  margin: auto;
  transform: translate(
    calc(var(--header-glyph) * -0.3),
    calc(var(--header-glyph) * 0)
  );
  z-index: 0;
}

/* ── Chat panel button ────────────────────────────────────────────── */
