* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0d1117;
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
}
body.launch-off-agent #btn-agent,
body.launch-off-grok #btn-grok-terminal,
body.launch-off-kbatch [data-tab="kbatch"],
body.launch-off-kbatch #mobile-tabs button[data-panel="kbatch"] {
  display: none !important;
}
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #30363d;
  background: #161b22;
  flex-shrink: 0;
  min-height: 0;
}
.header-band {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #0a0d12;
  border-bottom: 1px solid #21262d;
  position: relative;
  z-index: 4;
  contain: layout style;
}
.header-stage {
  flex-shrink: 0;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  background: linear-gradient(180deg, #0d1117 0%, #0a0d12 100%);
  border-bottom: 1px solid #21262d;
  overflow: hidden;
  position: relative;
  z-index: 2;
  contain: strict;
  isolation: isolate;
}
.header-wave-row {
  display: flex;
  flex-shrink: 0;
  align-items: stretch;
  min-height: 40px;
  border-bottom: 1px solid #21262d;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.header-waveform-stack {
  position: relative;
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 40px;
  min-height: 40px;
  overflow: hidden;
}
.header-structure-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}
.header-waveform {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
  background: transparent;
  overflow: hidden;
}
.header-play-strip {
  flex-shrink: 0;
  border-bottom: 1px solid #21262d;
  background: #0d1117;
  overflow-x: auto;
  overflow-y: hidden;
}
.hs-inner {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(160px, 1fr) minmax(200px, 1.1fr);
  gap: 0;
  height: 52px;
  max-height: 52px;
  align-items: stretch;
  overflow: hidden;
  contain: layout size;
}
.hs-snake-wrap {
  border-right: 1px solid #21262d;
  padding: 4px 6px;
  min-width: 0;
  max-height: 52px;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.hs-snake-canvas {
  display: block;
  width: 100%;
  height: 40px;
}
.hs-feeds {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #21262d;
  min-width: 0;
  max-height: 52px;
  overflow: hidden;
  padding: 2px 6px 4px;
  gap: 2px;
}
.hs-feeds-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.48rem;
  color: #6e7681;
  line-height: 1;
}
.hs-vwall-btn {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.65rem;
  padding: 1px 5px;
  line-height: 1.2;
}
.hs-vwall-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.hs-vwall-btn.live { border-color: #3fb950; color: #3fb950; box-shadow: 0 0 6px rgba(63, 185, 80, 0.25); }
.hs-vwall-cap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.hs-vwall-cap[data-level="warn"] { color: #d29922; }
.hs-vwall-cap[data-level="lag"] { color: #f85149; }
.hs-feeds-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  flex: 1;
}
.hs-feed-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
}
.hs-feed-strip .viz-thumb {
  flex-shrink: 0;
  width: 36px;
  padding: 1px;
}
.hs-feed-strip .viz-thumb-canvas { width: 32px; height: 32px; }
.hs-hex-preview {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid #30363d;
  border-radius: 3px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.hs-hex-preview.live { display: block; }
.hs-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: 52px;
  overflow: hidden;
  padding: 3px 8px 4px;
  gap: 2px;
}
.hs-chat-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.48rem;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hs-chat-to {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 3px;
  color: #8b949e;
  font: inherit;
  font-size: 0.48rem;
  max-width: 88px;
  padding: 1px 4px;
}
.hs-chat-log {
  flex: 1 1 auto;
  overflow: hidden;
  font-size: 0.52rem;
  line-height: 1.35;
  color: #8b949e;
  min-height: 0;
  max-height: 14px;
  scrollbar-width: thin;
}
.hs-chat-line {
  display: flex;
  gap: 4px;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 0;
  border-bottom: 1px solid #161b22;
}
.hs-chat-line.local { opacity: 0.9; }
.hs-chat-from { font-weight: 600; flex-shrink: 0; max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
.hs-chat-arrow { color: #484f58; flex-shrink: 0; }
.hs-chat-to { color: #6e7681; flex-shrink: 0; max-width: 48px; overflow: hidden; text-overflow: ellipsis; }
.hs-chat-text { color: #c9d1d9; overflow: hidden; text-overflow: ellipsis; }
.hs-chat-compose {
  display: flex;
  gap: 4px;
  align-items: center;
}
#hs-chat-in {
  flex: 1;
  min-width: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.55rem;
  padding: 3px 6px;
}
#hs-chat-in:focus { outline: none; border-color: #58a6ff; }
#hs-chat-send {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.65rem;
  padding: 2px 8px;
}
#hs-chat-send:hover { border-color: #58a6ff; color: #58a6ff; }

@media (max-width: 900px) {
  .header-stage { max-height: none; }
  .hs-inner {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 52px;
    max-height: 140px;
  }
  .hs-snake-wrap { grid-column: 1 / -1; border-right: none; border-bottom: 1px solid #21262d; }
  .hs-chat { grid-column: 1 / -1; border-top: 1px solid #21262d; max-height: 64px; }
  .header-wave-row { min-height: 32px; }
  .header-waveform-stack { height: 32px; min-height: 32px; }
  .hps-inner { flex-wrap: nowrap; min-height: 44px; overflow-x: auto; }
  .hps-piano { flex: 1 1 140px; min-width: 140px; order: 0; height: 40px; max-width: none; }
  .djs-inner { order: 0; flex: 0 0 140px; min-width: 120px; max-width: 180px; }
  .djs-fx { order: 0; flex: 0 0 auto; width: auto; border-left: 1px solid #21262d; border-top: none; }
  .hps-wk { height: 40px; }
  #visualizer.panel-block.active { display: flex; flex-direction: column; }
  .viz-user-rail { max-height: 160px; }
}
@media (max-width: 560px) {
  .header-band { max-height: 32vh; overflow-y: auto; }
  .header-stage { min-height: auto; max-height: 88px; }
  .hs-inner { grid-template-columns: 1fr; max-height: 100px; }
  .hs-feeds { border-right: none; border-bottom: 1px solid #21262d; }
  .header-play-strip { display: block; }
  .hps-piano,
  .hps-steps { display: none; }
  .hps-inner { min-height: 64px; padding: 4px 6px; }
  .hps-transport .hps-btn { min-width: 36px; min-height: 36px; }
  .djs-inner { flex: 1 1 100px; max-width: none; height: 56px; }
  .djs-fx { padding: 2px 4px; }
  .djs-knob-wrap { width: 36px; height: 48px; }
  .djs-knob { width: 48px; height: 36px; }
  #mobile-tabs button { flex: 1; min-height: 44px; font-size: 0.68rem; padding: 4px 2px; }
}

#header-waveform-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}
.header-dock {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#user-frame-badge.header-dock-badge {
  position: static;
  transform: none !important;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  max-width: min(560px, 52vw);
  width: auto;
  padding: 3px 8px;
  gap: 4px;
  box-shadow: none;
}
#user-frame-badge.header-dock-badge .ufb-search-row { max-width: 200px; }
#user-frame-badge.header-dock-badge .uwt-peers { max-width: 160px; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
#btn-refresh {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#btn-refresh:hover { color: #58a6ff; border-color: #58a6ff; background: #30363d; }
#btn-refresh:active { transform: rotate(-90deg); }
.title { font-weight: 700; color: #58a6ff; }
.sub { color: #8b949e; font-size: 0.75rem; }
.actions button {
  margin-left: 6px;
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}
.actions button:hover { background: #30363d; }

.app-footer {
  flex-shrink: 0;
  z-index: 30;
  background: #010409;
  border-top: 1px solid #30363d;
}
.prompt-bar {
  flex-shrink: 0;
  border-top: none;
  background: transparent;
  padding: 6px 12px 4px;
}
.grok-prompt-bar {
  border-bottom: none;
  contain: layout style;
}
.prompt-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.prompt-char {
  color: #3fb950;
  font: 600 0.72rem Menlo, monospace;
  flex-shrink: 0;
  user-select: none;
}
#prompt-search-in {
  flex: 1;
  min-height: 36px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.78rem;
  padding: 6px 4px;
}
#prompt-search-in:focus { outline: none; }
#prompt-search-in::placeholder { color: #484f58; }
#prompt-search-go, #prompt-video-ingest, #prompt-imagine {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
}
#prompt-search-go:hover, #prompt-video-ingest:hover, #prompt-imagine:hover {
  border-color: #58a6ff;
  color: #58a6ff;
}
.prompt-search-out {
  margin-top: 4px;
  max-height: 72px;
  overflow: auto;
  font-size: 0.62rem;
  color: #6e7681;
  white-space: pre-wrap;
}
.prompt-line { padding: 1px 0; }

#user-frame-badge {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  contain: layout style paint;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 6px 8px;
  background: rgba(1, 4, 9, 0.94);
  border: 1px solid #30363d;
  border-radius: 8px;
  backdrop-filter: blur(10px);
  pointer-events: auto;
  max-width: min(428px, 88vw);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.ufb-id {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.ufb-search-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
#user-search {
  flex: 1;
  min-width: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.6rem;
  padding: 4px 6px;
}
#user-search:focus { outline: none; border-color: #484f58; }
#user-search::placeholder { color: #484f58; }
#user-search-go {
  min-width: 26px;
  height: 26px;
  border: 1px solid #30363d;
  border-radius: 4px;
  background: #21262d;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
}
#user-search-go:hover { border-color: #58a6ff; color: #58a6ff; }
.ufb-dot { font-size: 0.55rem; color: #6e7681; }
.ufb-dot.sync-ok { color: #3fb950; }
.ufb-dot.sync-warn { color: #d29922; }
.ufb-dot.sync-push { color: #58a6ff; }
#uwt-handle {
  width: 72px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.62rem;
  padding: 3px 5px;
}
.ufb-cid {
  font-size: 0.52rem;
  color: #58a6ff;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.uwt-peers {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.uwt-peer {
  background: #21262d;
  border: 1px solid #58a6ff;
  border-radius: 4px;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.58rem;
  padding: 2px 6px;
  cursor: pointer;
}
.uwt-peer:hover { background: #30363d; }
.uwt-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.uwt-actions button {
  width: 26px;
  height: 26px;
  border: 1px solid #30363d;
  border-radius: 4px;
  background: #21262d;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}
.uwt-actions button:hover { border-color: #58a6ff; color: #58a6ff; }

@media (max-width: 720px) {
  #user-frame-badge {
    max-width: calc(100vw - 24px);
  }
  .float-bl, .float-br, .float-tr { max-width: 46vw; }
}

#canvas-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: hidden;
}
.frame-video-tile {
  position: absolute;
  pointer-events: auto;
  border: 2px solid #58a6ff88;
  border-radius: 6px;
  overflow: hidden;
  background: #010409;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.frame-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame-video-tile .fvt-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.5rem;
  color: #c9d1d9;
  z-index: 1;
  text-shadow: 0 1px 2px #000;
}
.frame-video-tile .fvt-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.55rem;
  color: #6e7681;
}

#workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 0;
  position: relative;
  transition: grid-template-columns 0.18s ease;
}
#workspace.right-collapsed {
  grid-template-columns: 1fr 0px;
}
#workspace.viz-expanded {
  grid-template-columns: 1fr 55%;
}
#workspace.viz-full {
  grid-template-columns: 1fr;
}
#workspace.viz-full #right-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(720px, 72vw);
  z-index: 20;
  box-shadow: -8px 0 24px rgba(0,0,0,0.45);
}

#canvas-wrap {
  --dock-rail-w: 42px;
  --canvas-ui-inset: 10px;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0a0b0d;
  padding-left: var(--dock-rail-w);
  display: grid;
  grid-template: 1fr / 1fr;
  align-items: stretch;
}
#canvas {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  touch-action: none;
  position: relative;
  z-index: 0;
}
#float-workspace {
  grid-area: 1 / 1;
  z-index: 10;
}
#canvas.pan-mode { cursor: grab; }
#canvas.pan-mode.grabbing { cursor: grabbing; }
#canvas.drag-node { cursor: move; }

#canvas-toolbar {
  position: absolute;
  top: var(--canvas-ui-inset);
  left: calc(var(--dock-rail-w) + var(--canvas-ui-inset));
  z-index: 16;
  display: flex;
  gap: 6px;
}
#canvas-toolbar button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: rgba(22, 27, 34, 0.92);
  color: #c9d1d9;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
#canvas-toolbar button:hover { background: #30363d; border-color: #58a6ff; }
#canvas-toolbar button.active { border-color: #58a6ff; color: #58a6ff; }

.device-picker {
  position: absolute;
  top: 46px;
  left: calc(var(--dock-rail-w) + var(--canvas-ui-inset));
  z-index: 17;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: rgba(1, 4, 9, 0.96);
  border: 1px solid #30363d;
  border-radius: 8px;
  backdrop-filter: blur(12px);
  max-height: min(320px, 50vh);
  overflow: auto;
  min-width: 168px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.device-picker.open { display: flex; }
.device-picker button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #161b22;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.62rem;
  padding: 6px 8px;
  cursor: pointer;
}
.device-picker button:hover { border-color: #58a6ff; background: #21262d; }
.device-picker .dp-icon { font-size: 0.9rem; width: 1.2rem; text-align: center; }
.device-picker .dp-meta { color: #6e7681; font-size: 0.52rem; margin-left: auto; }

.video-lane-picker {
  left: calc(var(--dock-rail-w) + var(--canvas-ui-inset) + 44px);
  min-width: 220px;
}
.video-lane-picker .vlp-chain {
  border-bottom: 1px solid #21262d;
  margin-bottom: 4px;
  padding-bottom: 6px;
}
.video-lane-picker .vlp-chain .dp-meta { color: #79c0ff; }

.canvas-resolution {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  font-size: 0.58rem;
  color: #6e7681;
  pointer-events: none;
  background: rgba(1, 4, 9, 0.82);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #30363d;
  max-width: min(420px, 55vw);
  text-align: right;
}
.collab-status {
  font-size: 0.68rem;
  color: #3fb950;
  margin-right: 8px;
}
#canvas-hint {
  position: absolute;
  bottom: var(--canvas-ui-inset);
  left: calc(var(--dock-rail-w) + var(--canvas-ui-inset));
  z-index: 5;
  font-size: 0.65rem;
  color: #6e7681;
  pointer-events: none;
  background: rgba(1, 4, 9, 0.7);
  padding: 4px 8px;
  border-radius: 4px;
}

#right-panel {
  position: relative;
  border-left: 1px solid #30363d;
  background: #0d1117;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  min-width: 0;
  transition: opacity 0.15s ease, transform 0.18s ease;
}
#workspace.right-collapsed #right-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(100%);
  border-left: none;
}
#workspace.right-collapsed #btn-right-expand {
  display: flex;
}
#btn-right-expand {
  display: none;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 18;
  width: 22px;
  height: 56px;
  border: 1px solid #30363d;
  border-right: none;
  border-radius: 6px 0 0 6px;
  background: rgba(22, 27, 34, 0.95);
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
#btn-right-expand:hover {
  color: #58a6ff;
  border-color: #58a6ff;
}
.right-collapse-btn {
  flex: 0 0 auto !important;
  width: 28px !important;
  min-width: 28px !important;
  padding: 0 !important;
  color: #6e7681 !important;
  font-size: 0.8rem !important;
}
.right-collapse-btn:hover,
.right-collapse-btn[aria-pressed="true"] {
  color: #d29922 !important;
  border-color: #484f58 !important;
}
.right-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid #30363d;
  background: #161b22;
  flex-shrink: 0;
}
.right-tabs button {
  flex: 1;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #8b949e;
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
  text-transform: lowercase;
}
.right-tabs button.active {
  background: #21262d;
  border-color: #30363d;
  color: #58a6ff;
}
#right-panel-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#right-panel-body .panel-block {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
#right-panel-body .panel-block.active {
  display: flex;
  flex-direction: column;
}
.panel-block {
  padding: 10px;
  border-bottom: 1px solid #30363d;
}
.panel-block:last-child { border-bottom: none; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.panel-head h2, #inspector h2 {
  font-size: 0.8rem;
  color: #8b949e;
  font-weight: 600;
}
#btn-viz-expand {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}
#btn-viz-expand:hover { color: #58a6ff; border-color: #58a6ff; }

#viz-canvas {
  width: 100%;
  height: 140px;
  display: block;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
}
#workspace.viz-expanded #viz-canvas,
#workspace.viz-full #viz-canvas {
  height: min(42vh, 360px);
}
.viz-stream-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 6px;
  min-height: 44px;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 4px;
  align-items: flex-start;
}
.viz-thumb-empty {
  font-size: 0.55rem;
  color: #484f58;
}
.viz-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 40px;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 2px;
  background: #161b22;
}
.viz-thumb-canvas {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 2px;
  background: #010409;
  image-rendering: pixelated;
}
.viz-thumb-cap {
  font-size: 0.42rem;
  color: #d29922;
  line-height: 1;
}
.viz-thumb-name {
  font-size: 0.4rem;
  color: #6e7681;
  max-width: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}
.viz-thumb-pinned {
  border-style: dashed;
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.15);
}
.viz-thumb-pinned.live {
  border-style: solid;
  box-shadow: 0 0 6px rgba(63, 185, 80, 0.25);
}
.viz-thumb-pinned.offline .viz-thumb-canvas {
  opacity: 0.72;
}
.viz-thumb-pinned.offline .viz-thumb-name {
  color: #d29922;
  text-transform: uppercase;
  font-size: 0.38rem;
  letter-spacing: 0.04em;
}

.video-float-bar {
  position: relative;
  height: 44px;
  z-index: 120;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.92), rgba(13, 17, 23, 0.55));
  border-bottom: 1px solid #21262d;
}
.video-float-bar .vfb-inner {
  position: absolute;
  top: 4px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(22, 27, 34, 0.94);
  border: 1px solid #30363d;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  touch-action: none;
}
.video-float-bar .vfb-inner.dragging {
  border-color: #58a6ff;
  cursor: grabbing;
}
.vfb-drag {
  background: transparent;
  border: none;
  color: #6e7681;
  cursor: grab;
  font-size: 0.85rem;
  padding: 2px 4px;
  line-height: 1;
}
.vfb-pins {
  display: flex;
  gap: 8px;
}
.vfb-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: #0d1117;
  border: 1px dashed #484f58;
  border-radius: 6px;
  cursor: pointer;
  min-width: 40px;
}
.vfb-pin.live {
  border-style: solid;
  border-color: var(--pin-color, #3fb950);
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.2);
}
.vfb-pin.offline {
  opacity: 0.85;
}
.vfb-pin-canvas {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 3px;
  image-rendering: pixelated;
  background: #010409;
}
.vfb-pin-lbl {
  font-size: 0.45rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.vfb-hint {
  font-size: 0.5rem;
  color: #484f58;
  white-space: nowrap;
}

.ml-daw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
  min-height: 22px;
}
.ml-daw-ph {
  font-size: 0.55rem;
  color: #484f58;
}
.ml-daw-chip.linked {
  border-color: #3fb950;
  color: #3fb950;
}
.ml-audio-tools {
  margin-top: 4px;
}
.ml-audio-tools .qb-chip.active,
#ml-autotune.active {
  border-color: #d29922;
  color: #d29922;
  background: rgba(210, 153, 34, 0.12);
}
.frame-video-tile .fvt-cap {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 0.42rem;
  color: #d29922;
  z-index: 1;
  text-shadow: 0 1px 2px #000;
}
.viz-groups-rail {
  flex-shrink: 0;
  margin-bottom: 6px;
  border: 1px solid #21262d;
  border-radius: 4px;
  background: #0a0d12;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.vgr-root { padding: 2px; }
.vgr-panel summary { list-style: none; cursor: pointer; }
.vgr-panel summary::-webkit-details-marker { display: none; }
.vgr-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-size: 0.55rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #21262d;
  background: #161b22;
  position: sticky;
  top: 0;
  z-index: 1;
}
.vgr-title { font-weight: 600; color: #c9d1d9; }
.vgr-count { margin-left: auto; color: #6e7681; font-size: 0.5rem; text-transform: none; }
.vgr-body { padding: 4px 6px 6px; }
.vgr-mod-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  padding: 3px 4px;
  background: #161b22;
  border-radius: 3px;
  border: 1px solid #30363d;
}
.vgr-mod-bar.vgr-mod-hint { font-size: 0.48rem; color: #6e7681; }
.vgr-mod-lbl { color: #d29922; font-size: 0.5rem; font-weight: 600; }
.vgr-host { color: #8b949e; margin-left: auto; }
.vgr-section { margin-bottom: 4px; }
.vgr-section-hd {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.48rem;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.vgr-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.vgr-chip {
  border: 1px solid #30363d;
  border-radius: 10px;
  background: #21262d;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.5rem;
  padding: 2px 7px;
  line-height: 1.3;
}
.vgr-chip.on {
  border-color: var(--vgr-c, #58a6ff);
  color: var(--vgr-c, #58a6ff);
  background: color-mix(in srgb, var(--vgr-c, #58a6ff) 12%, #21262d);
}
.vgr-chip .vgr-n { margin-left: 3px; opacity: 0.65; font-size: 0.45rem; }
.vgr-btn {
  border: 1px solid #30363d;
  border-radius: 3px;
  background: #21262d;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.5rem;
  padding: 2px 6px;
}
.vgr-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.vgr-btn.vgr-mod { border-color: #d29922; color: #d29922; }
.vgr-btn.vgr-mod:hover { color: #e3b341; }
.vgr-btn.vgr-mini { padding: 0 4px; font-size: 0.48rem; margin-left: auto; }
.vgr-ph { font-size: 0.48rem; color: #484f58; }
.vgr-assign { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.vgr-sel {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 3px;
  color: #8b949e;
  font: inherit;
  font-size: 0.48rem;
  max-width: 100px;
  padding: 2px 4px;
}

.viz-views-rail {
  flex-shrink: 0;
  margin-bottom: 6px;
  border: 1px solid #21262d;
  border-radius: 4px;
  background: #0a0d12;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.vvr-root { padding: 2px; }
.vvr-panel { border-radius: 4px; }
.vvr-panel summary { list-style: none; cursor: pointer; }
.vvr-panel summary::-webkit-details-marker { display: none; }
.vvr-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-size: 0.55rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #21262d;
  background: #161b22;
  position: sticky;
  top: 0;
  z-index: 1;
}
.vvr-title { font-weight: 600; color: #c9d1d9; }
.vvr-count { margin-left: auto; color: #6e7681; font-size: 0.5rem; text-transform: none; }
.vvr-body { padding: 4px 6px 6px; }
.vvr-actions { display: flex; gap: 4px; margin-bottom: 4px; }
.vvr-btn {
  border: 1px solid #30363d;
  border-radius: 3px;
  background: #21262d;
  color: #8b949e;
  font: inherit;
  font-size: 0.5rem;
  padding: 2px 6px;
  cursor: pointer;
}
.vvr-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.vvr-section { margin-bottom: 4px; }
.vvr-section-hd {
  font-size: 0.48rem;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.vvr-list { list-style: none; margin: 0; padding: 0; }
.vvr-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  font-size: 0.52rem;
  border-bottom: 1px solid #161b22;
}
.vvr-item.active { background: rgba(88, 166, 255, 0.08); }
.vvr-hop {
  border: 1px solid #30363d;
  border-radius: 3px;
  background: #21262d;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.55rem;
  padding: 0 4px;
  line-height: 1.3;
  flex-shrink: 0;
}
.vvr-hop:hover { border-color: #3fb950; color: #3fb950; }
.vvr-label {
  border: none;
  background: transparent;
  color: #58a6ff;
  cursor: pointer;
  font: inherit;
  font-size: 0.52rem;
  padding: 0;
  text-align: left;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vvr-meta { color: #6e7681; font-size: 0.48rem; flex-shrink: 0; max-width: 42%; overflow: hidden; text-overflow: ellipsis; }
.vvr-ph { font-size: 0.5rem; color: #484f58; padding: 2px 0; }
.vvr-peer .vvr-label { cursor: default; }

.vur-session {
  border-bottom: 1px solid #21262d;
  padding: 4px 6px 6px;
  margin-bottom: 4px;
}
.vur-session-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.55rem;
}
.vur-session-lbl {
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.48rem;
}
.vur-session-count { color: #8b949e; flex: 1; }
.vur-session-count[data-level="live"] { color: #3fb950; }
.vur-add-user {
  border: 1px solid #3fb950;
  border-radius: 4px;
  background: #21262d;
  color: #3fb950;
  cursor: pointer;
  font: inherit;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 2px 8px;
  flex-shrink: 0;
}
.vur-add-user:hover { background: #2d333b; color: #56d364; }
.vur-invite {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}
.vur-invite-url {
  flex: 1;
  min-width: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 3px;
  color: #8b949e;
  font: inherit;
  font-size: 0.48rem;
  padding: 3px 5px;
}
.vur-copy { flex-shrink: 0; }

#viz-log {
  margin-top: 8px;
  padding: 8px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  font-size: 0.65rem;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: auto;
  flex-shrink: 0;
}
.viz-user-rail {
  margin-top: 6px;
  flex: 1;
  min-height: 80px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #21262d;
  border-radius: 4px;
  background: #0a0d12;
}
.vur-root { display: flex; flex-direction: column; gap: 4px; padding: 4px; }
.vur-ph { font-size: 0.55rem; color: #484f58; padding: 4px; }
.vur-user { border: 1px solid #21262d; border-radius: 4px; background: #161b22; }
.vur-user summary { list-style: none; cursor: pointer; }
.vur-user summary::-webkit-details-marker { display: none; }
.vur-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-size: 0.58rem;
  color: #c9d1d9;
}
.vur-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--vur-c, #58a6ff); flex-shrink: 0; }
.vur-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.vur-count { color: #6e7681; font-size: 0.52rem; }
.vur-body { padding: 0 6px 6px; }
.vur-actions { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
.vur-btn {
  border: 1px solid #30363d;
  border-radius: 3px;
  background: #21262d;
  color: #8b949e;
  font: inherit;
  font-size: 0.5rem;
  padding: 2px 5px;
  cursor: pointer;
}
.vur-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.vur-btn.vur-clear:hover { border-color: #f85149; color: #f85149; }
.vur-nodes { list-style: none; margin: 0; padding: 0; }
.vur-node { display: flex; align-items: center; gap: 4px; padding: 2px 0; font-size: 0.52rem; border-bottom: 1px solid #21262d; }
.vur-node-btn {
  border: none;
  background: transparent;
  color: #58a6ff;
  cursor: pointer;
  font: inherit;
  font-size: 0.52rem;
  padding: 0;
}
.vur-type { color: #6e7681; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.vur-run { color: #3fb950; }
.vur-idle { color: #484f58; }

.hps-inner {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 4px 8px;
  min-height: 52px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.hps-transport { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.hps-btn {
  border: 1px solid #30363d;
  border-radius: 4px;
  background: #161b22;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.65rem;
  padding: 4px 6px;
  min-width: 28px;
  min-height: 28px;
}
.hps-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.hps-btn.active { border-color: #f85149; color: #f85149; }
.hps-rec-lbl { font-size: 0.48rem; color: #f85149; }
.hps-steps {
  display: grid;
  grid-template-columns: repeat(16, 12px);
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
}
.hps-step {
  width: 12px;
  height: 22px;
  border: 1px solid #30363d;
  border-radius: 2px;
  background: #161b22;
  cursor: pointer;
  padding: 0;
}
.hps-step.on { background: #388bfd; }
.hps-step.playhead { outline: 1px solid #f0883e; }
.hps-piano {
  position: relative;
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 320px;
  height: 44px;
  overflow: hidden;
}
.hps-white {
  display: flex;
  gap: 1px;
  height: 44px;
  position: relative;
  z-index: 0;
}
.hps-black {
  position: absolute;
  inset: 0;
  height: 28px;
  pointer-events: none;
  z-index: 1;
}
.hps-wk {
  flex: 1;
  min-width: 4px;
  max-width: 14px;
  height: 44px;
  border: 1px solid #30363d;
  border-radius: 0 0 2px 2px;
  background: #e6edf3;
  cursor: pointer;
  padding: 0;
}
.hps-bk {
  position: absolute;
  width: 58%;
  max-width: 11px;
  min-width: 6px;
  height: 28px;
  border: 1px solid #21262d;
  background: #21262d;
  border-radius: 0 0 2px 2px;
  cursor: pointer;
  padding: 0;
  pointer-events: auto;
  transform: translateX(-50%);
}
.hps-key.active { filter: brightness(0.85); }

.hps-inner .djs-inner {
  display: flex;
  align-items: stretch;
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 220px;
  height: 44px;
  border: 1px solid #21262d;
  border-radius: 4px;
  background: #0a0d12;
  overflow: hidden;
}
.hps-inner .djs-wave {
  flex: 1;
  min-width: 0;
  display: block;
  cursor: ew-resize;
  touch-action: none;
  height: 100%;
}
.hps-inner .djs-fx {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 2px 6px;
  border-left: 1px solid #21262d;
  font-size: 0.38rem;
  color: #6e7681;
  flex: 0 0 auto;
  min-width: 0;
  background: #0d1117;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  touch-action: pan-x;
}
.djs-knob-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  min-width: 34px;
  padding: 0 1px;
  cursor: ns-resize;
}
.djs-knob-col.djs-knob-active .djs-knob-lbl { color: #58a6ff; }
.djs-knob-lbl {
  font-size: 0.42rem;
  line-height: 1;
  text-transform: uppercase;
  color: #6e7681;
  user-select: none;
  pointer-events: none;
}
.djs-knob-wrap {
  width: 32px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.djs-knob {
  width: 52px;
  height: 28px;
  margin: 0;
  padding: 0;
  transform: rotate(-90deg);
  transform-origin: center center;
  accent-color: #58a6ff;
  cursor: ns-resize;
  touch-action: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.djs-knob::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #21262d;
  border: 1px solid #30363d;
}
.djs-knob::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 16px;
  margin-top: -5px;
  border-radius: 4px;
  background: linear-gradient(180deg, #79c0ff 0%, #388bfd 100%);
  border: 1px solid #58a6ff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.djs-knob::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #21262d;
  border: 1px solid #30363d;
}
.djs-knob::-moz-range-thumb {
  width: 22px;
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(180deg, #79c0ff 0%, #388bfd 100%);
  border: 1px solid #58a6ff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.djs-tools {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px;
  border-left: 1px solid #21262d;
  flex-shrink: 0;
}
.djs-btn {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 3px;
  color: #8b949e;
  cursor: pointer;
  font: inherit;
  font-size: 0.55rem;
  padding: 1px 4px;
  line-height: 1.1;
}
.djs-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.djs-btn.active { border-color: #3fb950; color: #3fb950; }

.live-node-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  overflow: visible;
}
.live-node-panel {
  position: absolute;
  pointer-events: auto;
  background: #0d1117ee;
  border: 2px solid #58a6ff;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(4px);
}
.live-node-panel .lnp-hd {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 6px;
  font-size: 0.52rem;
  color: #8b949e;
  border-bottom: 1px solid #21262d;
  background: #161b22;
  flex-shrink: 0;
}
.live-node-panel .lnp-id { color: #c9d1d9; font-weight: 600; }
.live-node-panel .lnp-type { color: #d29922; text-transform: uppercase; }
.live-node-panel .lnp-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}
#workspace.viz-expanded #viz-log,
#workspace.viz-full #viz-log {
  max-height: none;
  flex: 1;
}

#inspector label { display: block; font-size: 0.7rem; color: #8b949e; margin-bottom: 8px; }
#inspector input, #inspector select, #inspector textarea {
  width: 100%;
  margin-top: 4px;
  background: #161b22;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  padding: 6px;
  font: inherit;
  font-size: 0.72rem;
}
#insp-code { resize: vertical; min-height: 100px; }

.insp-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.insp-tab {
  flex: 1;
  min-height: 28px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #161b22;
  color: #8b949e;
  font: 600 0.62rem Menlo, monospace;
  cursor: pointer;
}
.insp-tab.active,
.insp-tab:hover {
  border-color: #58a6ff;
  color: #c9d1d9;
}
.insp-panel { display: none; }
.insp-panel.active { display: block; }
.insp-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.insp-btn {
  flex: 1;
  min-height: 30px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #21262d;
  color: #c9d1d9;
  font: 600 0.64rem Menlo, monospace;
  cursor: pointer;
}
.insp-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.insp-cmd-help {
  margin-top: 10px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
}
.insp-cmd-help > summary {
  padding: 8px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #8b949e;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.insp-cmd-help > summary::-webkit-details-marker { display: none; }
.insp-cmd-help > summary::before {
  content: "▸ ";
  color: #58a6ff;
}
.insp-cmd-help[open] > summary::before { content: "▾ "; }
.insp-cmd-help-body {
  max-height: 220px;
  overflow: auto;
  padding: 0 10px 10px;
  border-top: 1px solid #21262d;
}
.insp-cmd-group { margin-top: 8px; }
.insp-cmd-group-hd {
  font-size: 0.58rem;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.insp-cmd-list {
  margin: 0;
  display: grid;
  gap: 4px;
}
.insp-cmd-list dt {
  margin: 0;
  font-size: 0.62rem;
}
.insp-cmd-list dt code {
  color: #e3b341;
  font-size: 0.62rem;
}
.insp-cmd-list dd {
  margin: 0 0 4px 0;
  font-size: 0.58rem;
  color: #8b949e;
  line-height: 1.35;
}

/* Grok terminal */
#grok-terminal-out {
  min-height: 120px;
  max-height: 200px;
  overflow: auto;
  padding: 8px;
  background: #010409;
  border: 1px solid #30363d;
  border-radius: 4px;
  font-size: 0.68rem;
  white-space: pre-wrap;
  color: #8b949e;
}
.grok-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.grok-prompt { color: #a371f7; font-weight: 700; }
#grok-terminal-in {
  flex: 1;
  min-height: 44px;
  padding: 8px 10px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.8rem;
}
#grok-terminal-send, #grok-terminal-clear {
  min-width: 44px;
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #c9d1d9;
  font: inherit;
  cursor: pointer;
}
#grok-terminal-send:hover, #grok-terminal-clear:hover { border-color: #a371f7; }
.grok-hint {
  margin-top: 8px;
  font-size: 0.62rem;
  color: #6e7681;
  line-height: 1.4;
}
.grok-hint code { color: #58a6ff; }

#piano-panel .piano-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
#piano-panel-body .app.piano-buddy {
  min-height: 100%;
}
#workspace.right-piano {
  grid-template-columns: 1fr min(480px, 42vw);
}
#workspace.right-tools {
  grid-template-columns: 1fr min(540px, 48vw);
}
#workspace.right-kbatch {
  grid-template-columns: 1fr min(560px, 50vw);
}
#kbatch-panel {
  padding: 0;
  overflow: hidden;
}
#kbatch-panel .panel-head {
  margin: 0;
  padding: 6px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid #21262d;
}
#kbatch-panel .kbatch-toolbar-panel {
  border-bottom: none;
  background: transparent;
  padding: 0;
}
#kbatch-panel .kbatch-frame {
  flex: 1;
  min-height: 0;
  min-height: 280px;
}
#tools-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tools-hub-actions {
  display: flex;
  gap: 4px;
}
.tools-hub-actions button {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 4px;
  width: 26px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
}
.tools-hub-actions button:hover { color: #58a6ff; border-color: #58a6ff; }
.tools-accordion {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
}
.tool-section {
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
  overflow: hidden;
}
.tool-section.open { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.tool-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: #161b22;
  color: #c9d1d9;
  font: inherit;
  font-size: 0.68rem;
  text-align: left;
  cursor: pointer;
}
.tool-section-head:hover { background: #1c2129; }
.tool-chevron {
  color: #58a6ff;
  font-size: 0.6rem;
  transition: transform 0.15s;
}
.tool-section.open .tool-chevron { transform: rotate(90deg); }
.tool-label { font-weight: 700; }
.tool-cat {
  font-size: 0.55rem;
  color: #6e7681;
  padding: 1px 5px;
  border-radius: 4px;
  background: #21262d;
}
.tool-status {
  margin-left: auto;
  font-size: 0.55rem;
  color: #6e7681;
}
.tool-status.active { color: #3fb950; }
.tool-status.error { color: #f85149; }
.tool-section-actions { display: flex; gap: 2px; margin-left: 6px; }
.tool-act {
  background: transparent;
  border: 1px solid transparent;
  color: #8b949e;
  border-radius: 3px;
  width: 22px;
  height: 18px;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.65rem;
}
.tool-act:hover { color: #f0883e; border-color: #30363d; }
.tool-section-body {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.tool-section.open .tool-section-body { display: flex; }
.kbatch-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 6px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
}
.kbatch-toolbar-title {
  font-weight: 700;
  color: #f0883e;
  font-size: 0.65rem;
}
.kbatch-tab-pick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.58rem;
  color: #8b949e;
}
.kbatch-tab-pick select {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  font: inherit;
  font-size: 0.58rem;
  max-width: 110px;
}
.kbatch-toolbar button {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 4px;
  min-width: 26px;
  height: 22px;
  padding: 0 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.65rem;
}
.kbatch-toolbar button:hover { color: #f0883e; border-color: #f0883e; }
.kbatch-tools-hint {
  margin: 0;
  padding: 3px 8px;
  font-size: 0.55rem;
  color: #6e7681;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
}

.jam-hub-mission { font-size: 0.62rem; color: #8b949e; margin: 0 0 6px; }
.jam-hub-stacks { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.jam-stack-tag {
  font-size: 0.52rem;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #30363d;
  color: #6e7681;
  background: #161b22;
}
.jam-hub-hint { font-size: 0.55rem; color: #484f58; margin: 0 0 8px; }
.jam-eco-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 200px;
  overflow: auto;
}
.jam-eco-link {
  font-size: 0.55rem;
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid #30363d;
  color: #58a6ff;
  text-decoration: none;
  background: #0d1117;
}
.jam-eco-link:hover { border-color: #58a6ff; background: #161b22; }
.kbatch-frame,
.tool-embed-frame,
.tool-iframe {
  flex: 1;
  width: 100%;
  min-height: 320px;
  border: none;
  background: #010409;
}
.tool-iframe { min-height: 160px; }
.live-status {
  font-size: 0.62rem;
  color: #6e7681;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-status.active { color: #3fb950; }
.live-status.error { color: #f85149; }
.kbatch-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.kbatch-toolbar button {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 4px;
  width: 26px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
}
.kbatch-toolbar button:hover { color: #f0883e; border-color: #f0883e; }
.kbatch-frame.loading { opacity: 0.55; }
#btn-grok-terminal[aria-pressed="true"] {
  border-color: #a371f7;
  color: #a371f7;
}

.mobile-only { display: none; }
.hide-mobile { display: inline; }

#mobile-tabs {
  display: none;
  border-top: 1px solid #21262d;
  background: #161b22;
  padding: 4px 6px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  gap: 4px;
  flex-shrink: 0;
}
#mobile-tabs button {
  flex: 1;
  min-height: 44px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #8b949e;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#mobile-tabs button.active {
  background: #21262d;
  border-color: #30363d;
  color: #58a6ff;
  font-weight: 600;
}
#mobile-tabs button:active {
  background: #30363d;
  transform: scale(0.97);
}

@supports (padding: env(safe-area-inset-top)) {
  #header { padding-top: max(8px, env(safe-area-inset-top)); }
}

@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }
  .hide-mobile { display: none !important; }
  #mobile-tabs { display: flex; }

  #header {
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 4px 6px;
  }
  .brand { flex: 0 1 auto; min-width: 0; }
  .brand .title { font-size: 0.85rem; }
  #btn-refresh { width: 36px; height: 36px; }
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
  }
  .actions button { margin-left: 0; padding: 6px 10px; font-size: 0.68rem; }
  .collab-status { font-size: 0.62rem; padding: 4px 6px; }
  #header-dock {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 2px;
  }
  #user-frame-badge.header-dock-badge {
    max-width: none;
    flex-wrap: nowrap;
  }

  .app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
  }
  .prompt-search-out { max-height: 48px; }

  #workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    padding-bottom: var(--mobile-footer-h, 118px);
  }
  #right-panel {
    display: none;
    position: absolute;
    left: 0; right: 0;
    bottom: var(--mobile-footer-h, 118px);
    top: auto;
    max-height: min(52vh, calc(100% - var(--mobile-footer-h, 118px)));
    border-left: none;
    border-top: 1px solid #30363d;
    border-radius: 12px 12px 0 0;
    z-index: 25;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  }
  #workspace.panel-viz #right-panel,
  #workspace.panel-inspector #right-panel,
  #workspace.panel-kbatch #right-panel,
  #workspace.panel-tools #right-panel,
  #workspace.panel-piano #right-panel,
  #workspace.panel-terminal #right-panel {
    display: flex;
  }
  #workspace.panel-viz #canvas-wrap,
  #workspace.panel-inspector #canvas-wrap,
  #workspace.panel-kbatch #canvas-wrap,
  #workspace.panel-tools #canvas-wrap,
  #workspace.panel-piano #canvas-wrap,
  #workspace.panel-terminal #canvas-wrap {
    display: none;
  }
  #workspace:not(.panel-viz):not(.panel-inspector):not(.panel-kbatch):not(.panel-tools):not(.panel-piano):not(.panel-terminal) #canvas-wrap {
    display: block;
  }
  .right-tabs { display: none; }

  #canvas-toolbar button {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
  .actions button {
    min-height: 44px;
    padding: 8px 12px;
  }
  #viz-canvas { height: 120px; }
  #grok-terminal-out { max-height: 28vh; }
}

@media (pointer: coarse) {
  #btn-refresh,
  #canvas-toolbar button,
  .actions button,
  #grok-terminal-send,
  #mobile-tabs button {
    min-width: 44px;
    min-height: 44px;
  }
  .djs-knob-wrap { width: 36px; height: 56px; }
  .djs-knob { width: 56px; height: 32px; }
  .djs-knob::-webkit-slider-thumb {
    width: 28px;
    height: 20px;
    margin-top: -7px;
  }
  .djs-knob::-moz-range-thumb {
    width: 28px;
    height: 20px;
  }
}

/* node ±0 controls are drawn on canvas — larger hit targets via NODE_BTN in qbpm.js */