* { box-sizing: border-box; margin: 0; padding: 0; }

/* Browser-default `[hidden] { display: none }` loses to ID selectors
   below ('#login-overlay { display: flex }'), so it needs higher
   specificity to actually hide. Without this, JS setting
   `element.hidden = true` silently does nothing on these elements. */
#login-overlay[hidden],
#renderCanvas[hidden],
#event-log[hidden],
#time-display[hidden],
#stat-hud[hidden],
#inventory-panel[hidden],
#crafting-panel[hidden],
#controls-panel[hidden],
#build-banner[hidden],
#crosshair[hidden],
#capture-hint[hidden],
#death-overlay[hidden],
#console-overlay[hidden] {
  display: none;
}

#stat-hud {
  position: absolute;
  top: 1em;
  left: 1em;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 0.6em 0.8em;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  pointer-events: none;
  min-width: 180px;
}

#stat-hud .stat-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

#stat-hud .stat-label {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  color: #aaa;
  width: 4.5em;
  letter-spacing: 0.08em;
}

#stat-hud .stat-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

#stat-hud .stat-fill {
  height: 100%;
  width: 0%;
  background: #888;
  transition: width 200ms ease-out, background-color 300ms ease-out, box-shadow 300ms ease-out;
}

/* When a stat enters its danger zone (direction-aware) the JS adds
   the .stat-danger class — bright red glow + slow pulse so it's
   unmistakable regardless of the stat's normal color. */
#stat-hud .stat-row.stat-danger .stat-fill {
  background: #ff3030 !important;
  box-shadow: 0 0 6px rgba(255, 48, 48, 0.6);
  animation: stat-danger-pulse 1.2s ease-in-out infinite;
}
#stat-hud .stat-row.stat-danger .stat-label {
  color: #ff9090;
}
@keyframes stat-danger-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* Transient hit flash — added for ~220ms when PlayerDamaged arrives
   so the player gets immediate feedback on a melee landing. */
#stat-hud .stat-row.stat-hit .stat-fill {
  background: #ffffff !important;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
  transition: background 0.05s, box-shadow 0.05s;
}

#death-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5em;
  background: rgba(20, 0, 0, 0.7);
  color: #ffdada;
  font-family: ui-monospace, "SF Mono", monospace;
  z-index: 100;
  text-align: center;
}
#death-overlay h1 {
  font-size: 3.5em;
  letter-spacing: 0.15em;
  color: #ff4040;
  text-shadow: 0 0 18px rgba(255, 64, 64, 0.6);
}
#death-overlay p {
  font-size: 1em;
  opacity: 0.85;
}
#death-overlay #respawn-btn {
  font-size: 1.3em;
  padding: 0.7em 2em;
  background: #d94545;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.1em;
}
#death-overlay #respawn-btn:hover {
  background: #e85555;
}

#time-display {
  position: absolute;
  top: 1em;
  right: 1em;
  padding: 0.4em 0.8em;
  background: rgba(0, 0, 0, 0.5);
  color: #ddd;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 13px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* Full inventory panel — toggle with `I`. 4×4 grid of slots, each
   slot showing color swatch + display name + count. Center-screen,
   semi-transparent so the world stays visible behind it; pointer
   events disabled until W17's drag/drop ships. */
#inventory-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 17, 21, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 1em 1.2em;
  color: #ddd;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  /* pointer-events left as default — slots need to receive clicks
     for build-mode entry (W19+). The panel is hidden by default so
     it only intercepts world clicks while open. */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.inventory-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.8em;
  gap: 1.5em;
}
.inventory-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0;
}
.inventory-panel-hint {
  font-size: 0.7rem;
  color: #888;
  font-family: ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.05em;
}
#inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 56px);
  grid-auto-rows: 56px;
  gap: 4px;
}
.inv-slot {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 9px;
  color: #ccc;
  text-align: center;
  padding: 2px;
  overflow: hidden;
}
.inv-slot.empty {
  background: rgba(255, 255, 255, 0.02);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.06);
}
.inv-slot .icon {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  margin-bottom: 2px;
}
.inv-slot .label {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.04em;
  line-height: 1.1;
  /* Truncate long names rather than wrap chaotically. */
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-slot .count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.95);
}

/* Pointer-lock crosshair — appears center-screen while the mouse
   is captured. Targeting (placement + damage) uses this point. */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 26px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

/* Hint that shows when the canvas isn't captured — tells the user
   what to do without obscuring the world too much. */
#capture-hint {
  position: absolute;
  bottom: 1em;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4em 0.8em;
  background: rgba(0, 0, 0, 0.5);
  color: #aaa;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  border-radius: 3px;
  pointer-events: none;
}

/* Build-mode banner — shows when the player is placing a part.
   Top-center; bright accent so it's hard to miss; explains how to
   place + cancel. */
#build-banner {
  position: absolute;
  top: 1em;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6em 1.2em;
  background: rgba(70, 50, 30, 0.92);
  color: #fff8e0;
  border: 1px solid rgba(255, 220, 160, 0.4);
  border-radius: 4px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
#build-banner .build-banner-kind { font-weight: bold; }
#build-banner .build-banner-hint {
  font-size: 0.75rem;
  color: #d4c294;
  margin-left: 0.8em;
}

/* Inventory slots that map to a building-part kind get a subtle
   highlight on hover; clicking them enters build mode. */
.inv-slot.buildable { cursor: pointer; }
.inv-slot.buildable:hover {
  background: rgba(255, 220, 160, 0.12);
  border-color: rgba(255, 220, 160, 0.4);
}

/* Crafting panel — toggle with `C`. Vertical list of recipes; each
   row shows output + arrow + inputs + time. Rows are click-to-craft
   when affordable; greyed when not. Positioned to the LEFT of the
   inventory panel so both can be open at once. */
#crafting-panel {
  position: absolute;
  top: 50%;
  left: 1.5em;
  transform: translateY(-50%);
  background: rgba(15, 17, 21, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 1em 1.2em;
  color: #ddd;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  min-width: 260px;
}
.crafting-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.8em;
  gap: 1.5em;
}
.crafting-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0;
}
.crafting-panel-hint {
  font-size: 0.7rem;
  color: #888;
  font-family: ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.05em;
}
#crafting-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.recipe-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 120ms ease;
  font-size: 0.85rem;
}
.recipe-row:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.10);
}
.recipe-row.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.recipe-output, .recipe-input {
  display: flex;
  align-items: center;
  gap: 4px;
}
.recipe-arrow {
  color: #777;
  font-family: ui-monospace, monospace;
}
.recipe-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.78rem;
  color: #aaa;
}
.recipe-row .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.recipe-time {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.7rem;
  color: #888;
  letter-spacing: 0.04em;
}

/* Controller-bindings remap panel — crafting-panel's twin, docked right. */
#controls-panel {
  position: absolute;
  top: 50%;
  right: 1.5em;
  transform: translateY(-50%);
  background: rgba(15, 17, 21, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 1em 1.2em;
  color: #ddd;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  min-width: 280px;
}
.controls-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.8em;
  gap: 1.5em;
}
.controls-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0;
}
.controls-panel-hint {
  font-size: 0.7rem;
  color: #888;
  font-family: ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.05em;
}
#controls-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 60vh;
  overflow-y: auto;
}
.ctl-row {
  display: flex;
  align-items: center;
  gap: 0.8em;
  font-size: 0.8rem;
  padding: 1px 0;
}
.ctl-btn-name {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.72rem;
  color: #aaa;
  width: 8.5em;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.ctl-locked {
  color: #8fa88f;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.75rem;
  cursor: help;
}
.ctl-row select {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  font: inherit;
  font-size: 0.75rem;
  padding: 2px 4px;
}
.ctl-row select option {
  background: #14161a;   /* native dropdowns ignore the rgba select background */
}
.controls-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-top: 0.8em;
}
#controls-status {
  font-size: 0.7rem;
  color: #888;
  font-family: ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.05em;
}
#controls-reset {
  font-size: 0.72rem;
  padding: 0.35em 0.9em;
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
}
#controls-reset:hover {
  background: rgba(255, 255, 255, 0.14);
}

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #0f1115;
  color: #ddd;
  overflow: hidden;
}

#renderCanvas {
  width: 100%;
  height: 100vh;
  display: block;
  outline: none;
}

#login-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0f1115;
  padding: 2rem;
}

#login-overlay h1 {
  font-size: 2.4rem;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

#login-overlay .subtitle {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  font-style: italic;
}

#login-overlay button {
  background: #4f6bff;
  color: white;
  border: 0;
  padding: 0.75em 2.2em;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

#login-overlay button:hover {
  background: #3d57e0;
}

#login-overlay #status {
  margin-top: 1.5rem;
  color: #c0c8d0;
  min-height: 1.2em;
  font-size: 1rem;
  font-family: ui-monospace, "SF Mono", monospace;
  text-align: center;
  max-width: 90vw;
  word-break: break-word;
}

#event-log {
  position: absolute;
  bottom: 1em;
  left: 1em;
  right: 1em;
  max-height: 30vh;
  background: rgba(0, 0, 0, 0.7);
  color: #b8c4d6;
  padding: 0.5em 0.8em;
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#console-toggle {
  position: fixed;
  left: 1em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#console-toggle:active { background: rgba(40, 48, 60, 0.95); }
#console-toggle[hidden] { display: none; }

/* Controller-panel toggle: console-toggle's twin, bottom-right. */
#controls-toggle {
  position: fixed;
  right: 1em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#controls-toggle:active { background: rgba(40, 48, 60, 0.95); }
#controls-toggle[hidden] { display: none; }

/* Web Bluetooth pair row inside #controls-panel. */
#bt-pair-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.2em 0.7em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.5em;
  flex-wrap: wrap;
}
#bt-pair-row[hidden] { display: none; }
#bt-pair-row button {
  background: #15201a;
  color: #d8e2ec;
  border: 1px solid #46c98c;
  border-radius: 6px;
  padding: 0.5em 0.9em;
  font: 600 0.9rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#bt-pair-row button:active { background: #1d2c24; }
#bt-pair-status { color: #9aa3ad; font-size: 0.85rem; }

#console-overlay {
  position: absolute;
  left: 1em;
  right: 1em;
  bottom: 1em;
  display: flex;
  flex-direction: column;
  font-family: ui-monospace, "SF Mono", monospace;
  background: rgba(0, 0, 0, 0.78);
  color: #d8e2ec;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  font-size: 13px;
  z-index: 50;
}
#console-output {
  max-height: 30vh;
  overflow-y: auto;
  padding: 0.5em 0.8em;
  line-height: 1.45;
}
#console-output .err { color: #ff7a7a; }
#console-output .ok  { color: #8ad07a; }
#console-output .echo { color: #888; }
.console-input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding: 0.4em 0.6em;
}
.console-prompt {
  color: #6ab0ff;
  margin-right: 0.5em;
}
#console-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font: inherit;
}
#console-input::placeholder { color: #6b7682; }

/* Wayland Surfaces P1 — on-screen keyboard for driving an in-world
   screen, + its toggle button (twin of console/controls toggles). */
#screen-keyboard-toggle {
  position: fixed;
  right: 4.2em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#screen-keyboard-toggle:active { background: rgba(40, 48, 60, 0.95); }
/* 🖱 mouse-passthrough toggle — mirrors the ⌨ button, sits just left of it. */
#screen-mouse-toggle {
  position: fixed;
  right: 7.2em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#screen-mouse-toggle:active { background: rgba(40, 48, 60, 0.95); }
#screen-mouse-toggle.on { background: rgba(58, 92, 74, 0.92); border-color: #5e8f6f; color: #eafff0; }
#screen-mouse-pill {
  position: fixed;
  left: 50%;
  bottom: 3.4em;          /* stacks above the ⌨ driving pill if both are on */
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(28, 44, 36, 0.92);
  color: #d6f0e0;
  border: 1px solid #3e6e54;
  border-radius: 999px;
  padding: 0.4em 0.95em;
  font: 500 12px/1.2 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
#screen-mouse-pill[hidden] { display: none; }
#screen-keyboard,
#chat-keyboard {
  position: fixed;
  left: 50%;
  bottom: 1em;
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(14, 16, 22, 0.96);
  border: 1px solid #2c3440;
  border-radius: 10px;
  padding: 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  width: min(92vw, 720px);
}
/* The chat keyboard rides above the chat panel's input row. */
#chat-keyboard { bottom: 4.5em; }
#screen-keyboard[hidden],
#chat-keyboard[hidden] { display: none; }

/* Compact "you're driving the screen" pill — desktop drive mode (physical
   keyboard), shown instead of the space-hogging soft keyboard. */
#screen-driving-pill {
  position: fixed;
  left: 50%;
  bottom: 1em;
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(14, 16, 22, 0.92);
  color: #cdd6e0;
  border: 1px solid #2c3440;
  border-radius: 999px;
  padding: 0.4em 0.95em;
  font: 500 12px/1.2 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
#screen-driving-pill:hover { background: rgba(28, 34, 44, 0.96); }
#screen-driving-pill[hidden] { display: none; }
#screen-keyboard .kbd-head,
#chat-keyboard .kbd-head {
  color: #8fa3b8;
  font: 600 0.8rem ui-monospace, monospace;
  text-align: center;
  padding-bottom: 0.2em;
}
#screen-keyboard .kbd-row,
#chat-keyboard .kbd-row {
  display: flex;
  gap: 0.3em;
  justify-content: center;
}
#screen-keyboard .kbd-key,
#chat-keyboard .kbd-key {
  flex: 1 1 0;
  min-width: 1.6em;
  padding: 0.6em 0;
  background: #1c2430;
  color: #e3eaf2;
  border: 1px solid #38424f;
  border-radius: 6px;
  font: 600 1rem ui-monospace, monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#screen-keyboard .kbd-key:active,
#chat-keyboard .kbd-key:active { background: #2a3644; }
#screen-keyboard .kbd-key.kbd-wide,
#chat-keyboard .kbd-key.kbd-wide { flex: 2.4 1 0; }
#screen-keyboard .kbd-key.kbd-active,
#chat-keyboard .kbd-key.kbd-active {
  background: #1d3a2c;
  border-color: #46c98c;
  color: #bff3da;
}

/* Hearth chat (docs/MUSHMOOR.md M1) — the commons say/who panel + its
   toggle (third in the bottom-right toggle row). */
#chat-toggle {
  position: fixed;
  right: 7.4em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#chat-toggle:active { background: rgba(40, 48, 60, 0.95); }
#chat-toggle[hidden] { display: none; }

/* Nook toggle + panel (docs/MUSHMOOR.md §§3-4, M2). */
#nook-toggle {
  position: fixed;
  right: 10.8em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#nook-toggle:active { background: rgba(40, 48, 60, 0.95); }
#nook-toggle[hidden] { display: none; }

/* Background-music mute toggle (music.js) — next in the bottom-right row. */
#music-toggle {
  position: fixed;
  right: 14.2em;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#music-toggle:active { background: rgba(40, 48, 60, 0.95); }
#music-toggle[hidden] { display: none; }

/* Remaining bottom-right dock toggles — hall (P2), home-access (P3.2), the
   flat-screen Go-Home (🏠) and the dashboard/Menu (☰). Twins of the toggles
   above; they share everything but their horizontal slot, so they're grouped.
   (hall/home previously had no rule at all and fell into document flow — this
   docks them properly.) */
#hall-toggle,
#home-toggle,
#gohome-toggle,
#dashboard-toggle {
  position: fixed;
  bottom: 1em;
  z-index: 50;
  background: rgba(20, 24, 32, 0.85);
  color: #d8e2ec;
  border: 1px solid #3a4554;
  border-radius: 6px;
  padding: 0.55em 0.8em;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#hall-toggle { right: 17.6em; }
#home-toggle { right: 21em; }
#gohome-toggle { right: 24.4em; }
#dashboard-toggle { right: 27.8em; }
#hall-toggle:active,
#home-toggle:active,
#gohome-toggle:active,
#dashboard-toggle:active { background: rgba(40, 48, 60, 0.95); }
#hall-toggle[hidden],
#home-toggle[hidden],
#gohome-toggle[hidden],
#dashboard-toggle[hidden] { display: none; }

/* In-VR launcher (docs/MUSHMOOR.md). Only ever shown inside an XR session,
   where it's rasterized onto a world plane by xr-surfaces.js — so this is
   tuned for legibility at ~1 m in a headset (big high-contrast targets),
   not for the flat screen. Fixed off to the left so it has a real layout
   box to rasterize; its on-screen position is irrelevant in VR (the GL
   layer is all the headset composites). */
#vr-launcher {
  position: fixed;
  left: 1em;
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
  width: 13em;
  background: rgba(16, 20, 28, 0.95);
  border: 2px solid #4a586c;
  border-radius: 12px;
  padding: 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}
#vr-launcher[hidden] { display: none; }
#vr-launcher .vrl-title {
  color: #8fa3bd;
  font: 600 0.85rem ui-monospace, "SF Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
  padding: 0.1em 0 0.2em;
}
#vr-launcher button {
  display: flex;
  align-items: center;
  gap: 0.55em;
  width: 100%;
  background: rgba(30, 38, 50, 0.95);
  color: #e6edf5;
  border: 1px solid #46566a;
  border-radius: 8px;
  padding: 0.7em 0.8em;
  font: 600 1.15rem ui-monospace, "SF Mono", monospace;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
#vr-launcher button:active { background: rgba(58, 72, 92, 0.98); }
#vr-launcher .vrl-ico { font-size: 1.35rem; line-height: 1; }

/* Guided profiling run (xr-profile.js): fills the launcher panel with the
   current instruction. min-height ≈ the menu it replaces, so the rasterized
   panel's aspect doesn't jump when the swap happens. */
#vrl-profile-run {
  min-height: 24em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.8em;
  text-align: center;
  cursor: pointer;
}
#vrl-profile-run[hidden] { display: none; }
#vrl-profile-run .vrp-step {
  color: #8fa3bd;
  font: 600 1rem ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.12em;
}
#vrl-profile-run .vrp-title {
  color: #ffd88a;
  font: 700 1.6rem ui-monospace, "SF Mono", monospace;
  line-height: 1.25;
}
#vrl-profile-run .vrp-detail {
  color: #e6edf5;
  font: 500 1.05rem system-ui, sans-serif;
  line-height: 1.45;
  padding: 0 0.4em;
}
#vrl-profile-run .vrp-cancel {
  color: #7a8aa0;
  font: 500 0.85rem system-ui, sans-serif;
  margin-top: 0.6em;
}

/* VR-only gaze-clickable scroll controls (vr-scroll.js). Hidden on flat
   (the wheel/touch scroll the panels already have is enough); shown only in
   immersive VR, where there's no wheel and OS scrollbars aren't hit-testable
   through the gaze→synthesize pipeline. Pinned to the panel's right edge,
   vertically over the scroll region (clear of the header + input rows). They
   rasterize with the panel (absolute children of it) and the gaze-click path
   targets them like any button. */
.vr-scroll-btn { display: none; }
body.xr-immersive .vr-scroll-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 4px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(20, 24, 30, 0.9);
  color: #cfe3ff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 6;
}
body.xr-immersive .vr-scroll-up { top: 38%; }
body.xr-immersive .vr-scroll-down { top: 56%; }
body.xr-immersive .vr-scroll-btn:active { background: rgba(40, 52, 68, 0.95); }

#nook-panel {
  position: fixed;
  right: 1em;
  bottom: 3.4em;
  z-index: 60;
  width: 17em;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: rgba(14, 16, 22, 0.96);
  border: 1px solid #2c3440;
  border-radius: 8px;
  color: #d7e0ea;
  font: 14px/1.45 ui-monospace, "SF Mono", Menlo, monospace;
  overflow: hidden;
}
#nook-panel[hidden] { display: none; }
#nook-panel .nook-head {
  padding: 0.5em 0.7em;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid #2c3440;
  color: #cdd9e5;
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: baseline;
  gap: 0.4em;
}
#nook-panel .nook-where { color: #7d8a99; font-weight: 400; font-size: 0.78rem; }
#nook-panel .nook-quota { margin-left: auto; color: #9cc4ff; font-size: 0.8rem; }
#nook-panel .nook-quota.full { color: #e0b070; }
#nook-panel .nook-objects {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.4em 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}
#nook-panel .nook-empty { color: #6f7d8c; font-style: italic; font-size: 0.82rem; padding: 0.4em 0; }
#nook-panel .nook-object {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.2em 0;
}
#nook-panel .nook-object-label { flex: 1; }
#nook-panel .nook-remove {
  background: none; border: none; color: #c98a8a; cursor: pointer;
  font: 600 0.9rem ui-monospace, monospace; padding: 0 0.3em;
}
#nook-panel .nook-add {
  border-top: 1px solid #2c3440;
  padding: 0.5em 0.6em;
  flex: 0 0 auto;
}
#nook-panel .nook-add-label { color: #7d8a99; font-size: 0.76rem; }
#nook-panel .nook-catalog { display: flex; flex-wrap: wrap; gap: 0.3em; margin-top: 0.4em; }
#nook-panel .nook-relic {
  background: #1c2430; color: #e3eaf2; border: 1px solid #38424f;
  border-radius: 6px; padding: 0.3em 0.55em; font: 0.8rem ui-monospace, monospace; cursor: pointer;
}
#nook-panel .nook-relic:active { background: #2a3644; }
#nook-panel .nook-relic:disabled { opacity: 0.4; cursor: not-allowed; }
#nook-panel .nook-vis {
  padding: 0.4em 0.6em;
  border-bottom: 1px solid #2c3440;
  color: #7d8a99;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  gap: 0.35em;
  flex: 0 0 auto;
}
#nook-panel .nook-vis-btn {
  background: #1c2430; color: #aeb8c4; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.2em 0.6em; font: 0.76rem ui-monospace, monospace; cursor: pointer;
}
#nook-panel .nook-vis-btn.on { background: #1d3a2c; color: #bff3da; border-color: #46c98c; }

/* Personal-space theme picker (docs/SUBSCRIBER_SPACES.md P1). */
#nook-panel .nook-theme {
  padding: 0.4em 0.6em;
  border-bottom: 1px solid #2c3440;
  color: #7d8a99;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35em 0.5em;
  flex: 0 0 auto;
}
#nook-panel .nook-theme[hidden] { display: none; }
#nook-panel .nook-theme select {
  background: #1c2430; color: #cdd7e2; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.2em 0.4em; font: 0.76rem ui-monospace, monospace; cursor: pointer;
}
#nook-panel .space-field-label { color: #7d8a99; text-transform: capitalize; }

/* Hall panel (docs/SUBSCRIBER_SPACES.md P2 — group spaces). Mirrors the
   nook panel; sits left of it so both can be open at once. */
#hall-panel {
  position: fixed;
  right: 19.5em;
  bottom: 3.4em;
  z-index: 60;
  width: 17em;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: rgba(14, 16, 22, 0.96);
  border: 1px solid #2c3440;
  border-radius: 8px;
  color: #d7e0ea;
  font: 14px/1.45 ui-monospace, "SF Mono", Menlo, monospace;
  overflow: hidden;
}
#hall-panel[hidden] { display: none; }
#hall-panel .hall-head {
  padding: 0.5em 0.7em;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid #2c3440;
  color: #cdd9e5;
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: baseline;
  gap: 0.4em;
}
#hall-panel .hall-where { color: #7d8a99; font-weight: 400; font-size: 0.78rem; }
#hall-panel .hall-quota { margin-left: auto; color: #9cc4ff; font-size: 0.8rem; }
#hall-panel .hall-quota.full { color: #e0b070; }
#hall-panel .hall-nav {
  display: flex; align-items: center; gap: 0.35em;
  padding: 0.4em 0.6em;
  border-bottom: 1px solid #2c3440;
  flex: 0 0 auto;
}
#hall-panel .hall-nav-btn {
  background: #1c2430; color: #aeb8c4; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.2em 0.55em;
  font: 0.76rem ui-monospace, monospace; cursor: pointer; white-space: nowrap;
}
#hall-panel .hall-nav-btn.on { background: #1d2e3a; color: #bfe0ff; border-color: #4690c9; }
#hall-panel .hall-input {
  flex: 1 1 4em; min-width: 0;
  background: #11161d; color: #d7e0ea; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.2em 0.4em; font: 0.76rem ui-monospace, monospace;
}
#hall-panel .hall-members {
  padding: 0.4em 0.6em;
  border-bottom: 1px solid #2c3440;
  flex: 0 0 auto;
}
#hall-panel .hall-members[hidden] { display: none; }
#hall-panel .hall-section-label { color: #7d8a99; font-size: 0.72rem; margin-bottom: 0.25em; }
#hall-panel .hall-member, #hall-panel .hall-member-add {
  display: flex; align-items: center; gap: 0.4em; padding: 0.12em 0;
}
#hall-panel .hall-member-name { flex: 1; font-size: 0.82rem; }
#hall-panel .hall-objects {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.4em 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}
#hall-panel .hall-empty { color: #6f7d8c; font-style: italic; font-size: 0.82rem; padding: 0.4em 0; }
#hall-panel .hall-note { color: #6f7d8c; font-size: 0.72rem; margin-top: 0.3em; }
#hall-panel .hall-object {
  display: flex; align-items: center; gap: 0.4em; padding: 0.2em 0;
}
#hall-panel .hall-object-label { flex: 1; }
#hall-panel .hall-object-by { color: #6f7d8c; font-size: 0.72rem; }
#hall-panel .hall-remove {
  background: none; border: none; color: #c98a8a; cursor: pointer;
  font: 600 0.9rem ui-monospace, monospace; padding: 0 0.3em;
}
#hall-panel .hall-found {
  margin-top: 0.4em;
  background: #1d3a2c; color: #bff3da; border: 1px solid #46c98c;
  border-radius: 6px; padding: 0.35em 0.7em; font: 0.82rem ui-monospace, monospace; cursor: pointer;
}
#hall-panel .hall-found:active { background: #234a38; }
#hall-panel .hall-add {
  border-top: 1px solid #2c3440;
  padding: 0.5em 0.6em;
  flex: 0 0 auto;
}
#hall-panel .hall-add[hidden] { display: none; }
#hall-panel .hall-add-label { color: #7d8a99; font-size: 0.76rem; }
#hall-panel .hall-catalog { display: flex; flex-wrap: wrap; gap: 0.3em; margin-top: 0.4em; }
#hall-panel .hall-relic {
  background: #1c2430; color: #e3eaf2; border: 1px solid #38424f;
  border-radius: 6px; padding: 0.3em 0.55em; font: 0.8rem ui-monospace, monospace; cursor: pointer;
}
#hall-panel .hall-relic:active { background: #2a3644; }
#hall-panel .hall-relic:disabled { opacity: 0.4; cursor: not-allowed; }
#hall-panel .hall-move {
  background: none; border: none; color: #8aa6c9; cursor: pointer;
  font: 600 0.9rem ui-monospace, monospace; padding: 0 0.2em;
}
/* Halls-you-belong-to (discovery) + theme picker. */
#hall-panel .hall-memberships {
  padding: 0.4em 0.6em; border-bottom: 1px solid #2c3440; flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3em;
}
#hall-panel .hall-memberships[hidden] { display: none; }
#hall-panel .hall-memberships .hall-section-label { width: 100%; }
#hall-panel .hall-membership {
  background: #1c2430; color: #cfe0f2; border: 1px solid #38424f;
  border-radius: 6px; padding: 0.25em 0.55em; font: 0.78rem ui-monospace, monospace; cursor: pointer;
}
#hall-panel .hall-membership:active { background: #2a3644; }
#hall-panel .hall-theme {
  padding: 0.4em 0.6em; border-bottom: 1px solid #2c3440; flex: 0 0 auto;
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.35em 0.5em;
  color: #7d8a99; font-size: 0.76rem;
}
#hall-panel .hall-theme[hidden] { display: none; }
#hall-panel .hall-theme-select {
  background: #1c2430; color: #cdd7e2; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.2em 0.4em; font: 0.76rem ui-monospace, monospace; cursor: pointer;
}
#hall-panel .hall-field-label { color: #7d8a99; text-transform: capitalize; }

/* Home access panel (docs/SUBSCRIBER_SPACES.md §14.1 — P3.2). */
#home-panel {
  position: fixed; right: 1em; bottom: 3.4em; z-index: 60; width: 16em;
  display: flex; flex-direction: column;
  background: rgba(14, 16, 22, 0.96); border: 1px solid #2c3440; border-radius: 8px;
  color: #d7e0ea; font: 14px/1.45 ui-monospace, "SF Mono", Menlo, monospace; overflow: hidden;
}
#home-panel[hidden] { display: none; }
#home-panel .home-head {
  padding: 0.5em 0.7em; background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid #2c3440; color: #cdd9e5; font-weight: 600; font-size: 0.85rem;
}
#home-panel .home-access {
  padding: 0.5em 0.6em; border-bottom: 1px solid #2c3440; color: #7d8a99; font-size: 0.76rem;
  display: flex; align-items: center; gap: 0.35em; flex-wrap: wrap;
}
#home-panel .home-acc-btn {
  background: #1c2430; color: #aeb8c4; border: 1px solid #38424f; border-radius: 5px;
  padding: 0.2em 0.6em; font: 0.76rem ui-monospace, monospace; cursor: pointer;
}
#home-panel .home-acc-btn.on { background: #1d3a2c; color: #bff3da; border-color: #46c98c; }
#home-panel .home-guests { padding: 0.4em 0.6em; border-bottom: 1px solid #2c3440; }
#home-panel .home-guests[hidden] { display: none; }
#home-panel .home-section-label { color: #7d8a99; font-size: 0.72rem; margin-bottom: 0.25em; }
#home-panel .home-empty { color: #6f7d8c; font-style: italic; font-size: 0.8rem; padding: 0.2em 0; }
#home-panel .home-guest, #home-panel .home-guest-add {
  display: flex; align-items: center; gap: 0.4em; padding: 0.12em 0;
}
#home-panel .home-guest-name { flex: 1; font-size: 0.82rem; }
#home-panel .home-remove {
  background: none; border: none; color: #c98a8a; cursor: pointer;
  font: 600 0.9rem ui-monospace, monospace; padding: 0 0.3em;
}
#home-panel .home-invites {
  padding: 0.4em 0.6em; border-bottom: 1px solid #2c3440;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3em;
}
#home-panel .home-invites[hidden] { display: none; }
#home-panel .home-invites .home-section-label { width: 100%; }
#home-panel .home-invite {
  background: #1c2430; color: #cfe0f2; border: 1px solid #38424f;
  border-radius: 6px; padding: 0.25em 0.55em; font: 0.78rem ui-monospace, monospace; cursor: pointer;
}
#home-panel .home-invite:active { background: #2a3644; }
#home-panel .home-visit {
  padding: 0.5em 0.6em; display: flex; align-items: center; gap: 0.35em; flex-wrap: wrap;
}
#home-panel .home-visit-label { color: #7d8a99; font-size: 0.72rem; width: 100%; }
#home-panel .home-input {
  flex: 1 1 4em; min-width: 0; background: #11161d; color: #d7e0ea; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.2em 0.4em; font: 0.76rem ui-monospace, monospace;
}
#home-panel .home-nav-btn {
  background: #1c2430; color: #aeb8c4; border: 1px solid #38424f; border-radius: 5px;
  padding: 0.2em 0.55em; font: 0.76rem ui-monospace, monospace; cursor: pointer; white-space: nowrap;
}

/* Asset preload screen (visual-quality overhaul — download everything first). */
#asset-loading {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(circle at 50% 40%, #1c2330, #0b0d12 70%);
  color: #e8eaed; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  font: 16px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
}
#asset-loading[hidden] { display: none; }
#asset-loading .al-title { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; }
#asset-loading .al-bar {
  width: min(70vw, 360px); height: 10px; background: #1b2230;
  border: 1px solid #2c3440; border-radius: 6px; overflow: hidden;
}
#asset-loading .al-fill {
  height: 100%; width: 0%; border-radius: 6px;
  background: linear-gradient(90deg, #46c98c, #6fd1ff); transition: width 0.2s ease;
}
#asset-loading .al-label { color: #8a93a0; font-size: 13px; }

#chat-panel {
  position: fixed;
  left: 1em;
  bottom: 3.4em;
  z-index: 60;
  width: min(92vw, 420px);
  height: min(50vh, 360px);
  display: flex;
  flex-direction: column;
  background: rgba(14, 16, 22, 0.94);
  border: 1px solid #2c3440;
  border-radius: 10px;
  overflow: hidden;
  font: 13px system-ui, -apple-system, "Segoe UI", sans-serif;
}
#chat-panel[hidden] { display: none; }
#chat-panel .chat-head {
  padding: 0.5em 0.7em;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid #2c3440;
  color: #cdd9e5;
  font-weight: 600;
  font-size: 0.85rem;
  flex: 0 0 auto;
}
#chat-panel .chat-who { color: #7d8a99; font-weight: 400; font-size: 0.78rem; }
#chat-panel .chat-nook {
  margin-left: auto;
  background: #1c2430; color: #cdd9e5; border: 1px solid #38424f;
  border-radius: 5px; padding: 0.15em 0.55em; font: 600 0.76rem ui-monospace, monospace; cursor: pointer;
}
#chat-panel .chat-nook:active { background: #2a3644; }
#chat-panel .chat-priv {
  padding: 0.3em 0.7em;
  background: rgba(200, 169, 107, 0.08);
  border-bottom: 1px solid #2c3440;
  color: #c8a96b;
  font-size: 0.76rem;
  flex: 0 0 auto;
  cursor: help;
}
#chat-panel .chat-priv[hidden] { display: none; }
#chat-panel .chat-me {
  padding: 0.3em 0.7em;
  background: rgba(111, 182, 255, 0.08);
  border-bottom: 1px solid #2c3440;
  color: #9cc4ff;
  font-size: 0.78rem;
  font-weight: 600;
  flex: 0 0 auto;
  cursor: help;
}
#chat-panel .chat-me[hidden] { display: none; }
#chat-panel .chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.4em 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.18em;
}
#chat-panel .chat-line { line-height: 1.35; word-wrap: break-word; }
#chat-panel .chat-line.sys { color: #6f7d8c; font-style: italic; font-size: 0.82rem; }
#chat-panel .chat-name {
  background: none; border: none; padding: 0; cursor: pointer;
  color: #6fb6ff; font: inherit; font-weight: 600;
}
#chat-panel .chat-name.muted { color: #6b7682; text-decoration: line-through; }
#chat-panel .chat-flag {
  background: none; border: none; cursor: pointer; color: #5a6573;
  font-size: 0.8em; padding: 0 0.25em;
}
#chat-panel .chat-flag:hover { color: #d98a8a; }
#chat-panel .chat-body { color: #dfe6ee; margin-left: 0.2em; }
#chat-panel .chat-input-row {
  display: flex;
  gap: 0.4em;
  padding: 0.5em;
  border-top: 1px solid #2c3440;
  flex: 0 0 auto;
}
#chat-panel #chat-input {
  flex: 1;
  background: #0c0e13;
  border: 1px solid #38424f;
  border-radius: 6px;
  color: #e3eaf2;
  padding: 0.5em 0.6em;
  font: inherit;
}
#chat-panel #chat-input::placeholder { color: #5a6573; }
#chat-panel #chat-send {
  background: #1d3a2c; color: #bff3da; border: 1px solid #46c98c;
  border-radius: 6px; padding: 0 0.9em; font: 600 0.9rem inherit; cursor: pointer;
}
#chat-panel #chat-kbd {
  background: #1c2430; color: #cdd9e5; border: 1px solid #38424f;
  border-radius: 6px; padding: 0 0.7em; font: 600 1rem inherit; cursor: pointer;
}
#chat-panel #chat-kbd:active { background: #2a3644; }

/* Tuning-gallery knob panel (tuning-knobs.js) — built per gallery world. */
#tuning-knobs-panel {
  position: fixed; left: 1em; top: 1em; z-index: 60;
  width: 16em; max-height: 88vh;
  background: rgba(14, 16, 22, 0.96); border: 1px solid #2c3440; border-radius: 8px;
  color: #d7e0ea; font: 12px ui-monospace, monospace;
  display: flex; flex-direction: column;
}
#tuning-knobs-panel[hidden] { display: none; }
#tuning-knobs-panel .ak-head {
  padding: 0.5em 0.7em; background: rgba(255,255,255,0.04);
  border-bottom: 1px solid #2c3440; font-weight: 600;
}
#tuning-knobs-panel .ak-status { color: #9cc4ff; font-weight: 600; margin-left: 0.4em; }
#tuning-knobs-panel .ak-body { padding: 0.5em 0.6em; overflow-y: auto; display: flex; flex-direction: column; gap: 0.45em; }
#tuning-knobs-panel .ak-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25em 0.4em; }
#tuning-knobs-panel .ak-name { width: 100%; color: #9fb0c4; font-size: 0.92em; }
#tuning-knobs-panel .ak-range { flex: 1; min-width: 6em; cursor: pointer; }
#tuning-knobs-panel .ak-val { width: 3.4em; text-align: right; color: #9cc4ff; font-weight: 600; }
#tuning-knobs-panel .ak-check { justify-content: space-between; }
#tuning-knobs-panel .ak-check .ak-name { width: auto; }
#tuning-knobs-panel .ak-foot { display: flex; gap: 0.4em; padding: 0.5em 0.6em; border-top: 1px solid #2c3440; }
#tuning-knobs-panel button { flex: 1; padding: 0.45em; background: #1c222c; color: #d7e0ea; border: 1px solid #2c3440; border-radius: 5px; cursor: pointer; font: inherit; }
#tuning-knobs-panel .ak-apply { background: #2a3a28; border-color: #3a5a36; color: #cfe9cb; }

/* Atelier "Live" toggle (tuning-knobs.js) — animate one tile at a time. */
#tuning-knobs-panel .ak-live-row { display: flex; align-items: center; gap: 0.5em; padding: 0.45em 0.6em; border-top: 1px solid #2c3440; }
#tuning-knobs-panel .ak-livebtn { padding: 0.35em 0.7em; background: #1c222c; color: #9cc4ff; border: 1px solid #3a4658; border-radius: 5px; cursor: pointer; font: inherit; }
#tuning-knobs-panel .ak-livebtn.on { background: #2a3a52; color: #cfe3ff; border-color: #5a7aa8; }
#tuning-knobs-panel .ak-live-hint { color: #6b7787; font-size: 0.82em; }

/* Atelier "Move mode" button + hint (tuning-knobs.js). */
#tuning-knobs-panel .ak-movebtn { padding: 0.35em 0.7em; background: #1c222c; color: #b8c4d4; border: 1px solid #3a4658; border-radius: 5px; cursor: pointer; font: inherit; }
#tuning-knobs-panel .ak-movebtn:active { background: #2a3340; }
#tuning-knobs-panel .ak-live-hint { display: block; padding: 0 0.6em 0.4em; }

/* Atelier: the keyboard/Stream-Deck "active knob" highlight (tuning-knobs.js cycleKnob/nudgeKnob). */
#tuning-knobs-panel .ak-row.ak-active { background: rgba(80,140,230,0.22); box-shadow: inset 3px 0 0 #5aa0ff; border-radius: 4px; }

/* Stream Deck action toast (engine.js global shortcuts) — a brief centred confirmation. */
#deck-toast {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%) translateY(8px);
  background: rgba(18,22,30,0.92); color: #dce6f4; border: 1px solid #3a4658;
  padding: 0.4em 0.95em; border-radius: 999px; font: 600 0.95rem ui-monospace, monospace;
  pointer-events: none; opacity: 0; transition: opacity 0.18s, transform 0.18s; z-index: 2147483646;
}
#deck-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
