/* GrokGlyph — full-page 1px stack · slim header · footer drawer */

:root {
  --gg-header-h: 48px;
  --gg-footer-h: 40px;
  --gg-mobile-dock-h: 0px;
  --gg-gap: 1px;              /* column/row gutter between glyphs */
  --gg-cell: 100px;
  --gg-drawer-max: min(72vh, 520px);
  --gg-safe-b: env(safe-area-inset-bottom, 0px);
  --gg-safe-t: env(safe-area-inset-top, 0px);
}

html, body.gg-body {
  height: 100%;
  overflow: hidden;
}

.gg-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows:
    auto /* shared site nav */
    auto /* header — grows on wrap / mobile */
    minmax(0, 1fr) /* stage */
    var(--gg-mobile-dock-h) /* reserved for phone dock */
    calc(var(--gg-footer-h) + var(--gg-safe-b));
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  background: #050508;
  color: var(--text);
}

/* pin chrome rows so hidden media / HDRI don't steal grid cells */
.gg-body > .nav-site-slim,
.gg-body > #site-nav { grid-row: 1; grid-column: 1; }
.gg-body > .gg-header { grid-row: 2; grid-column: 1; }
.gg-body > .gg-stage-wrap { grid-row: 3; grid-column: 1; min-height: 0; }
.gg-body > .gg-mobile-dock { grid-row: 4; grid-column: 1; }
.gg-body > .gg-drawer-root { grid-row: 5; grid-column: 1; }

.noise { z-index: 0; opacity: 0.03; }

/* site-wide nav sits above app chrome */
.gg-body > .nav-site-slim,
.gg-body > #site-nav {
  position: relative;
  z-index: 40;
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  background: rgba(8, 8, 12, 0.96);
  border-bottom: 1px solid var(--border);
}
.gg-body > .nav-site-slim .brand-name,
.gg-body > #site-nav .brand-name {
  font-size: 0.9rem;
}
.gg-body > .nav-site-slim nav,
.gg-body > #site-nav nav {
  font-size: 0.78rem;
  gap: 0.3rem 0.7rem;
}

/* ── header (main needs) ─────────────────────────────────── */
.gg-header {
  position: relative;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-height: calc(var(--gg-header-h) + var(--gg-safe-t));
  height: auto;
  padding: var(--gg-safe-t) 0.5rem 0.4rem;
  background: rgba(12, 12, 15, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.gg-header-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
}
.gg-lbl-short { display: none; }
.gg-lbl-long { display: inline; }

.gg-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.gg-brand:hover { text-decoration: none; color: var(--accent); }
.gg-brand .brand-mark { color: var(--accent); font-size: 1rem; }
.gg-brand-name { white-space: nowrap; }

/* filmmaker scene tiles */
.gg-tile.is-scene-c {
  box-shadow: inset 0 0 0 2px rgba(110, 231, 183, 0.55);
}
.gg-tile.is-selfcam .gg-name::before {
  content: "◈ ";
  color: var(--accent);
}
.gg-hbtn.is-on {
  border-color: rgba(110, 231, 183, 0.55);
  color: #6ee7b7;
}

/* HDRI probe overlay */
.gg-hdri-panel {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gg-footer-h) + var(--gg-safe-b) + 12px);
  transform: translateX(-50%);
  z-index: 50;
  width: min(96vw, 920px);
  max-height: min(42vh, 360px);
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 14, 0.94);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.gg-hdri-panel[hidden] { display: none !important; }
.gg-hdri-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}
.gg-hdri-meta {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--faint);
  margin-right: auto;
}
.gg-hdri-body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 4px;
  padding: 4px;
  overflow: auto;
  min-height: 0;
}
@media (max-width: 700px) {
  .gg-hdri-body { grid-template-columns: 1fr; }
}
.gg-hdri-eq-wrap {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gg-hdri-canvas {
  width: 100%;
  height: auto;
  max-height: 28vh;
  object-fit: contain;
  background: #050508;
  border-radius: 6px;
  image-rendering: auto;
}
.gg-hdri-mini {
  width: 100%;
  height: min(22vh, 180px);
  min-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #050508;
  overflow: hidden;
  touch-action: none;
}
.gg-hdri-mini .hdri-view-canvas {
  width: 100% !important;
  height: 100% !important;
}

.gg-header-main {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.gg-header-main::-webkit-scrollbar { height: 3px; }
.gg-status-compact {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gg-status-sep { opacity: 0.5; }

/* Mobile dock — hidden on desktop; fixed on phone so it never scrolls off */
.gg-mobile-dock {
  display: none;
  box-sizing: border-box;
}

/* Toolbar groups: device · seat · capture · ship */
.gg-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  padding: 0.15rem 0.25rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
}
.gg-tool-device {
  border-color: rgba(125, 211, 252, 0.22);
  background: rgba(125, 211, 252, 0.06);
}
.gg-tool-slots {
  border-color: rgba(192, 132, 252, 0.22);
  background: rgba(192, 132, 252, 0.05);
}
.gg-tool-capture {
  border-color: rgba(110, 231, 183, 0.18);
  background: rgba(110, 231, 183, 0.04);
}
.gg-tool-ship {
  border-color: rgba(248, 113, 113, 0.18);
  background: rgba(248, 113, 113, 0.04);
}
.gg-tool-label {
  font-family: var(--mono);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  padding: 0 0.2rem;
  user-select: none;
}
.gg-tool-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
  opacity: 0.7;
}
.gg-slot-seg {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.gg-slot-btn {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  height: 28px;
  min-width: 1.85rem;
  padding: 0 0.35rem;
  cursor: pointer;
  line-height: 1;
}
.gg-slot-btn:last-child { border-right: 0; }
.gg-slot-btn:hover { color: var(--accent); background: rgba(125, 211, 252, 0.08); }
.gg-slot-btn.is-on,
.gg-slot-btn[aria-pressed="true"] {
  background: rgba(192, 132, 252, 0.22);
  color: #e9d5ff;
}
.gg-slot-btn[data-slot="C"].is-on {
  background: rgba(110, 231, 183, 0.22);
  color: #a7f3d0;
}
.gg-hbtn.gg-role-laptop[aria-pressed="true"] {
  border-color: rgba(125, 211, 252, 0.55);
  color: #7dd3fc;
  background: rgba(125, 211, 252, 0.12);
}
.gg-hbtn.gg-role-phone[aria-pressed="true"] {
  border-color: rgba(251, 191, 36, 0.55);
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}
.gg-hbtn.gg-cam-btn[aria-pressed="true"] {
  border-color: rgba(110, 231, 183, 0.55);
  color: #6ee7b7;
}
.gg-role-chip {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: #7dd3fc;
  background: rgba(125, 211, 252, 0.08);
  white-space: nowrap;
}
.gg-role-chip.is-phone {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
}

/* Drawer device cards */
.gg-device-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin: 0.55rem 0 0.35rem;
}
.gg-device-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0a10;
  color: var(--text);
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  line-height: 1.3;
}
.gg-device-card strong { font-size: 0.82rem; }
.gg-device-card span:last-child { color: var(--faint); font-size: 0.65rem; }
.gg-device-icon { font-size: 1.1rem; line-height: 1; }
.gg-device-card.is-on {
  border-color: rgba(125, 211, 252, 0.5);
  background: rgba(125, 211, 252, 0.08);
}
.gg-device-card[data-role="phone"].is-on {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.1);
}

/* Live link · phone ↔ laptop */
.gg-pair {
  margin-top: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(110, 231, 183, 0.28);
  background: rgba(110, 231, 183, 0.05);
}
.gg-pair .gg-h2 { margin: 0 0 0.35rem; color: #a7f3d0; font-size: 0.82rem; }
.gg-pair-status {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  margin: 0.4rem 0 0.55rem;
  word-break: break-word;
}
.gg-pair-status.is-live { color: #6ee7b7; border-color: rgba(110, 231, 183, 0.35); }
.gg-pair-status.is-err { color: #f87171; border-color: rgba(248, 113, 113, 0.4); }
.gg-pair-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
}
@media (max-width: 520px) {
  .gg-pair-grid { grid-template-columns: 1fr; }
}
.gg-pair-qr-wrap {
  background: #fff;
  padding: 8px;
  border-radius: 12px;
  line-height: 0;
  width: fit-content;
}
.gg-pair-qr-wrap img {
  display: block;
  width: 140px;
  height: 140px;
}
.gg-pair-meta .gg-hub-label { margin-bottom: 0.35rem; }
.gg-pair-meta input[readonly] {
  opacity: 0.95;
  font-size: 0.65rem;
}
.gg-pair-steps { margin-top: 0.45rem; }
#gg-pair-connect.is-on {
  background: rgba(110, 231, 183, 0.2);
  border-color: rgba(110, 231, 183, 0.5);
  color: #a7f3d0;
}

.gg-hbtn {
  appearance: none;
  flex-shrink: 0;
  height: 30px;
  min-width: 30px;
  padding: 0 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.gg-hbtn:hover {
  border-color: rgba(125, 211, 252, 0.45);
  color: var(--accent);
}
.gg-hbtn.primary {
  background: rgba(125, 211, 252, 0.12);
  border-color: rgba(125, 211, 252, 0.4);
  color: var(--accent);
  font-weight: 600;
  padding: 0 0.65rem;
}
.gg-hbtn[aria-pressed="true"] {
  border-color: rgba(74, 222, 128, 0.5);
  color: var(--live);
  background: rgba(74, 222, 128, 0.08);
}
.gg-hbtn.is-live,
.gg-hbtn#gg-cast[aria-pressed="true"] {
  border-color: rgba(248, 113, 113, 0.65);
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}
.gg-hbtn#gg-hub[aria-pressed="true"] {
  border-color: rgba(125, 211, 252, 0.55);
  color: var(--accent);
}
.gg-hbtn.danger,
.btn.danger {
  border-color: rgba(248, 113, 113, 0.45);
  color: #f87171;
}
.gg-hbtn.danger:hover,
.btn.danger:hover {
  border-color: var(--err);
  background: rgba(248, 113, 113, 0.1);
}

.gg-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* drawer tabs */
.gg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.15rem;
}
.gg-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: #12121a;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}
.gg-tab.is-on {
  border-color: rgba(125, 211, 252, 0.5);
  color: var(--accent);
  background: rgba(125, 211, 252, 0.08);
}
.gg-tab-panel[hidden] { display: none !important; }
.gg-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* region presets */
.gg-region-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.gg-region-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}
.gg-region-item {
  appearance: none;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.gg-region-item strong {
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font);
}
.gg-region-item span {
  font-size: 0.62rem;
  color: var(--faint);
}
.gg-region-item:hover {
  border-color: rgba(125, 211, 252, 0.4);
}
.gg-region-item.is-on {
  border-color: rgba(74, 222, 128, 0.55);
  background: rgba(74, 222, 128, 0.06);
}

/* geo readout */
.gg-geo-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
}
.gg-geo-readout div {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  min-width: 0;
}
.gg-geo-readout dt {
  color: var(--faint);
  margin: 0;
  flex-shrink: 0;
}
.gg-geo-readout dd {
  margin: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* hidden media used only for sampling → 25×25 */
.gg-hidden-media {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  left: -9999px !important;
}
.gg-hbtn.gg-drawer-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.gg-drawer-icon { font-size: 0.85rem; line-height: 1; }

.gg-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  margin-left: 0.15rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0a0a0e;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gg-status-sep { color: var(--faint); opacity: 0.7; }

/* ── stage: full remaining page, 1px stack ───────────────── */
.gg-stage-wrap {
  position: relative;
  z-index: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050508;
  /* no padding — edge-to-edge stack */
  padding: 0;
  border: none;
  border-radius: 0;
}

.gg-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  /* cols/rows + cell size set by JS; gap is always 1px */
  grid-template-columns: repeat(var(--gg-cols, 1), var(--gg-cell, 100px));
  grid-template-rows: repeat(var(--gg-rows, 1), var(--gg-cell, 100px));
  gap: var(--gg-gap, 1px);
  justify-content: center;
  align-content: center;
  width: 100%;
  height: 100%;
  background: #0a0a0e; /* 1px gutters show as dark lines between tiles */
}

.gg-mesh-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.gg-mesh-svg line {
  stroke: rgba(125, 211, 252, 0.4);
  stroke-width: 1;
  stroke-linecap: square;
}
.gg-mesh-svg line.gg-mesh-strong {
  stroke: rgba(74, 222, 128, 0.55);
  stroke-width: 1.5;
}

/* tile = pure matrix canvas; meta is overlay */
.gg-tile {
  position: relative;
  width: var(--gg-cell, 100px);
  height: var(--gg-cell, 100px);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #050508;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gg-tile.is-you {
  outline: 1px solid rgba(74, 222, 128, 0.55);
  outline-offset: -1px;
  z-index: 1;
}
.gg-tile.is-talking {
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.85),
    0 0 18px rgba(251, 191, 36, 0.35);
}
.gg-tile.is-mocap:not(.is-talking) {
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.55);
}
.gg-dir-badge.is-talking {
  background: rgba(251, 191, 36, 0.9);
  color: #1a1200;
  animation: gg-talk-pulse 0.7s ease-in-out infinite alternate;
}
@keyframes gg-talk-pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.25); }
}
.gg-tile.is-casting {
  outline: 1px solid rgba(248, 113, 113, 0.7);
  outline-offset: -1px;
  z-index: 2;
}
.gg-tile.is-rx {
  outline: 1px solid rgba(125, 211, 252, 0.45);
  outline-offset: -1px;
}
.gg-tile.is-video .gg-dir-badge.gg-live-badge {
  color: #f87171;
  background: rgba(248, 113, 113, 0.2);
}
.gg-tile.is-off {
  opacity: 0.22;
  filter: grayscale(0.7);
}
.gg-tile.is-focus,
.gg-tile:focus-visible {
  outline: 1px solid rgba(125, 211, 252, 0.7);
  outline-offset: -1px;
  z-index: 2;
}

.gg-tile canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #050508;
  border: none;
  border-radius: 0;
}

/* compact overlay chrome (hover / selected) */
.gg-tile-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  padding: 2px 3px;
  font-family: var(--mono);
  font-size: clamp(7px, 1.6vw, 10px);
  line-height: 1.1;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.gg-tile:hover .gg-tile-meta,
.gg-tile:focus-within .gg-tile-meta,
.gg-tile.is-focus .gg-tile-meta,
.gg-tile.is-you .gg-tile-meta {
  opacity: 1;
  pointer-events: auto;
}
.gg-tile-meta .gg-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 80%;
  color: rgba(236, 236, 241, 0.9);
}
.gg-tile.is-you .gg-name { color: #4ade80; }

.gg-tile-del {
  appearance: none;
  border: none;
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 2px;
  pointer-events: auto;
}
.gg-tile-del:hover { background: rgba(248, 113, 113, 0.4); }

.gg-dir-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-family: var(--mono);
  font-size: clamp(7px, 1.4vw, 9px);
  color: var(--accent);
  background: rgba(5, 5, 8, 0.75);
  padding: 0 2px;
  line-height: 1.2;
  opacity: 0.85;
  pointer-events: none;
}

/* on-air caption overlay (program bus / chat-bridge) */
.gg-caption-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  padding: 0.45rem 0.65rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, rgba(5, 5, 8, 0.88) 28%);
  font-family: var(--mono);
  pointer-events: none;
}
.gg-caption-bar[hidden] { display: none !important; }
.gg-caption-meta {
  font-size: 0.58rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.gg-caption-text {
  font-size: clamp(0.75rem, 2.4vw, 0.95rem);
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

/* ── footer drawer ───────────────────────────────────────── */
.gg-drawer-root {
  position: relative;
  z-index: 40;
  height: calc(var(--gg-footer-h) + var(--gg-safe-b));
  /* drawer peeks as footer bar; expands upward when open */
}

.gg-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.gg-drawer-scrim[hidden] { display: none !important; }

.gg-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  max-height: calc(var(--gg-footer-h) + var(--gg-safe-b));
  display: flex;
  flex-direction: column;
  background: rgba(14, 14, 18, 0.98);
  border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  transition: max-height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  padding-bottom: var(--gg-safe-b);
}

.gg-drawer.is-open {
  max-height: calc(var(--gg-drawer-max) + var(--gg-safe-b));
}

.gg-drawer-handle {
  flex-shrink: 0;
  height: var(--gg-footer-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.gg-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--faint);
}
.gg-handle-text {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.gg-drawer.is-open .gg-handle-text::after {
  content: " · swipe down";
  color: var(--faint);
}

.gg-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.25rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  -webkit-overflow-scrolling: touch;
}

.gg-drawer-sec {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.gg-h2 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}
.gg-muted {
  font-weight: 400;
  color: var(--faint);
  font-size: 0.72rem;
  font-family: var(--mono);
}

.gg-nick-label,
.gg-hub-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  width: 100%;
}
.gg-nick-label input,
.gg-hub-label input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
}
.gg-nick-label input { max-width: 10rem; }
.gg-file-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  width: fit-content;
}

/* compass (drawer) */
.gg-compass {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
}
.gg-compass-pad {
  display: grid;
  grid-template-columns: 2.4rem 2.6rem 2.4rem;
  grid-template-rows: 2.4rem 2.6rem 2.4rem;
  gap: 0.2rem;
  place-items: center;
}
.gg-compass-pad .gg-cbtn[data-dir="n"] { grid-column: 2; grid-row: 1; }
.gg-compass-pad .gg-cbtn[data-dir="w"] { grid-column: 1; grid-row: 2; }
.gg-compass-pad .gg-compass-core { grid-column: 2; grid-row: 2; }
.gg-compass-pad .gg-cbtn[data-dir="e"] { grid-column: 3; grid-row: 2; }
.gg-compass-pad .gg-cbtn[data-dir="s"] { grid-column: 2; grid-row: 3; }

.gg-cbtn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(125, 211, 252, 0.35);
  background: #12121a;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
}
.gg-cbtn:hover {
  background: rgba(125, 211, 252, 0.12);
  border-color: var(--accent);
}
.gg-compass-core {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--live);
  border: 1px solid rgba(74, 222, 128, 0.45);
  background: radial-gradient(circle at 40% 35%, rgba(74, 222, 128, 0.15), #0a0a0e 70%);
}
.gg-compass-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.gg-sub {
  min-width: 2.6rem;
  padding: 0.3rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
}

/* roster + search */
.gg-roster-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.gg-roster-count {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--faint);
  white-space: nowrap;
}

.gg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.gg-search-label {
  position: relative;
  display: block;
  width: 100%;
}
.gg-search {
  width: 100%;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
}
.gg-search:focus {
  outline: none;
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.12);
}
.gg-search-clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
}
.gg-search-clear:hover { color: var(--err); }

.gg-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}
.gg-sort-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.15rem;
}
.gg-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #12121a;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  padding: 0.22rem 0.45rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}
.gg-chip:hover {
  border-color: rgba(125, 211, 252, 0.4);
  color: var(--accent);
}
.gg-chip.is-on {
  border-color: rgba(74, 222, 128, 0.5);
  color: var(--live);
  background: rgba(74, 222, 128, 0.08);
}

.gg-roster-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  max-height: min(40vh, 280px);
  overflow-y: auto;
}
.gg-roster-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.gg-roster-list li:hover {
  border-color: rgba(125, 211, 252, 0.35);
}
.gg-roster-list li.is-focus {
  border-color: rgba(125, 211, 252, 0.65);
  background: rgba(125, 211, 252, 0.08);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.15);
}
.gg-roster-list li.is-match-dim {
  opacity: 0.45;
}
.gg-roster-list .gg-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.gg-roster-list li.on .gg-dot { background: var(--live); }
.gg-roster-list li.is-live .gg-dot {
  background: #f87171;
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.5);
}
.gg-roster-list .gg-rlabel {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gg-roster-list .gg-rid {
  color: var(--faint);
  font-size: 0.62rem;
  flex-shrink: 0;
}
.gg-roster-list .gg-ractions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.gg-roster-list button {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  padding: 0.18rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
}
.gg-roster-list button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.gg-roster-list button.danger:hover {
  border-color: var(--err);
  color: var(--err);
}

/* focused glyph on stage */
.gg-tile.is-focus {
  outline: 1px solid rgba(125, 211, 252, 0.85);
  outline-offset: -1px;
  z-index: 3;
  box-shadow: 0 0 16px rgba(125, 211, 252, 0.2);
}
.gg-tile.is-search-miss {
  opacity: 0.2;
  filter: grayscale(0.8);
}

.gg-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--faint);
  line-height: 1.4;
}

.gg-drawer-links {
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem !important;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.gg-drawer-links a { color: var(--muted); }
.gg-drawer-links a:hover { color: var(--accent); }

/* narrow header */
@media (max-width: 420px) {
  .gg-brand-name { display: none; }
  .gg-drawer-label { display: none; }
  .gg-hide-narrow { display: none !important; }
  .gg-hbtn { padding: 0 0.4rem; }
}

/* ── mobile: controls stay on-screen ─────────────────────── */
@media (max-width: 820px) {
  :root {
    /* footer already includes safe-area; dock is a fixed bar above it */
    --gg-mobile-dock-h: 56px;
  }

  /* collapse site nav links to free vertical space */
  .gg-body > .nav-site-slim nav,
  .gg-body > #site-nav nav {
    display: none;
  }
  .gg-body > .nav-site-slim,
  .gg-body > #site-nav {
    min-height: 34px;
    padding: 0.3rem 0.55rem;
  }

  .gg-header {
    flex-wrap: nowrap;
    gap: 0.35rem;
    min-height: calc(44px + var(--gg-safe-t));
    padding: var(--gg-safe-t) 0.4rem 0.35rem;
    padding-left: max(0.4rem, env(safe-area-inset-left));
    padding-right: max(0.4rem, env(safe-area-inset-right));
  }
  .gg-brand-name { display: none; }
  .gg-drawer-label { display: none; }

  /* full toolbar off header — bottom dock instead */
  .gg-header-main {
    display: none !important;
  }
  .gg-header-top {
    flex: 1;
    min-width: 0;
  }

  .gg-lbl-long { display: none; }
  .gg-lbl-short { display: inline; }

  /*
   * Fixed dock (not sticky): body is overflow:hidden so sticky never pins.
   * Sits above the footer drawer handle; grid row 4 reserves the same height.
   */
  .gg-mobile-dock {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.28rem;
    z-index: 46;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--gg-footer-h) + var(--gg-safe-b));
    width: 100%;
    max-width: 100vw;
    height: var(--gg-mobile-dock-h);
    min-height: 56px;
    padding: 0.3rem 0.35rem;
    padding-left: max(0.35rem, env(safe-area-inset-left));
    padding-right: max(0.35rem, env(safe-area-inset-right));
    background: rgba(10, 10, 14, 0.98);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .gg-mobile-dock::-webkit-scrollbar { display: none; }

  .gg-dock-btn {
    appearance: none;
    flex: 0 0 auto;
    min-width: 2.4rem;
    height: 2.45rem;
    padding: 0 0.38rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #14141c;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .gg-dock-btn:active { transform: scale(0.96); }
  .gg-dock-btn.is-on {
    border-color: rgba(125, 211, 252, 0.5);
    color: #7dd3fc;
    background: rgba(125, 211, 252, 0.12);
  }
  .gg-dock-btn.is-phone-on {
    border-color: rgba(251, 191, 36, 0.55);
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
  }
  .gg-dock-primary.is-on {
    border-color: rgba(110, 231, 183, 0.55);
    color: #6ee7b7;
  }
  .gg-dock-cast.is-live,
  .gg-dock-cast[aria-pressed="true"] {
    border-color: rgba(248, 113, 113, 0.65);
    color: #f87171;
    background: rgba(248, 113, 113, 0.12);
  }
  .gg-dock-slots {
    display: flex;
    flex: 0 0 auto;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    width: 7.2rem;
    min-width: 7.2rem;
  }
  .gg-dock-slot {
    appearance: none;
    flex: 1;
    border: 0;
    border-right: 1px solid var(--border);
    background: #12121a;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 700;
    height: 2.45rem;
    min-width: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .gg-dock-slot:last-child { border-right: 0; }
  .gg-dock-slot.is-on {
    background: rgba(192, 132, 252, 0.28);
    color: #e9d5ff;
  }
  .gg-dock-slot[data-slot="C"].is-on {
    background: rgba(110, 231, 183, 0.25);
    color: #a7f3d0;
  }

  /* HDRI panel above fixed dock + footer */
  .gg-hdri-panel {
    bottom: calc(var(--gg-mobile-dock-h) + var(--gg-footer-h) + var(--gg-safe-b) + 8px);
    width: calc(100vw - 0.75rem);
    max-height: min(38vh, 280px);
  }

  /* footer drawer under dock; open drawer stacks above stage, below dock chrome */
  .gg-drawer-root {
    z-index: 40;
  }
  .gg-drawer {
    z-index: 45;
  }
  .gg-drawer-handle {
    min-height: 36px;
  }
}

/* very narrow phones: drop hub from dock (still in ☰ drawer) */
@media (max-width: 380px) {
  .gg-mobile-dock .gg-dock-hub { display: none; }
  .gg-dock-btn {
    min-width: 2.2rem;
    height: 2.35rem;
    padding: 0 0.28rem;
    font-size: 0.66rem;
  }
  .gg-dock-slots {
    width: 6.4rem;
    min-width: 6.4rem;
  }
  .gg-dock-slot { height: 2.35rem; font-size: 0.66rem; }
}

@media (min-width: 821px) {
  .gg-mobile-dock { display: none !important; }
  :root { --gg-mobile-dock-h: 0px; }
}

@media (display-mode: standalone) {
  .gg-header {
    padding-left: max(0.55rem, env(safe-area-inset-left));
    padding-right: max(0.55rem, env(safe-area-inset-right));
  }
}

/* ── social handle · mobile double-stack ──────────────────── */
.gg-social-lazy {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 9rem;
  overflow: auto;
}
.gg-social-lazy li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.28rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
}
.gg-social-lazy li.is-live { border-color: rgba(240, 70, 70, 0.45); }
.gg-social-lazy li button {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
}
.gg-social-lazy .gg-lazy-kind {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  min-width: 2.4rem;
}
.gg-social-lazy .gg-lazy-kind.live { color: #f05555; }

/* double-stack: portrait 1:2 tiles (two glyph faces tall) */
.gg-body.is-mobile-stack .gg-stage {
  --gg-aspect: 1 / 2;
}
.gg-body.is-mobile-stack .gg-tile {
  aspect-ratio: 1 / 2;
}
.gg-body.is-mobile-stack .gg-tile canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
