:root {
  --bg: #0a0d1f;
  --surface: #151a33;
  --surface-2: #232a4d;
  --text: #f1f3ff;
  --muted: #a4abd0;
  --accent: #6d6bff;
  --accent-2: #2fd6e8;
  --danger: #e5484d;
  --ok: #3ecf8e;
  --line: #333b68;
  --glass: rgb(16 20 44 / 0.94);
  --on-accent: #ffffff;
}
:root[data-theme="light"] {
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #e6e9f2;
  --text: #1d2030;
  --muted: #5d6480;
  --line: #cfd4e2;
  --glass: rgb(255 255 255 / 0.96);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); margin: 0; }
.primary {
  background: linear-gradient(100deg, var(--accent), #8f5bff 55%, var(--accent-2));
  background-size: 160% 100%;
  color: var(--on-accent);
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgb(109 107 255 / 0.35);
  transition: background-position 0.25s, box-shadow 0.25s;
}
.primary:hover { background-position: 100% 0; box-shadow: 0 6px 28px rgb(47 214 232 / 0.4); }

/* Entrada: cielo estrellado con nebulosas, siempre oscuro aunque se elija el tema claro. */
#lobby {
  --bg: #0a0d1f;
  --surface: #151a33;
  --surface-2: #232a4d;
  --text: #f1f3ff;
  --muted: #a4abd0;
  --line: #333b68;
  position: relative;
  height: 100%;
  overflow: auto;
  display: flex;
  padding: 16px;
  color: var(--text);
  background:
    radial-gradient(ellipse 60% 50% at 12% 18%, rgb(143 91 255 / 0.32), transparent 70%),
    radial-gradient(ellipse 55% 45% at 88% 82%, rgb(47 214 232 / 0.22), transparent 70%),
    radial-gradient(ellipse 40% 35% at 80% 12%, rgb(109 107 255 / 0.2), transparent 70%),
    #070919;
}
#lobby::before, #lobby::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-repeat: repeat;
}
#lobby::before {
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 140px, #dfe4ff, transparent),
    radial-gradient(1.5px 1.5px at 160px 70px, #fff, transparent),
    radial-gradient(1px 1px at 230px 200px, #bfeaff, transparent),
    radial-gradient(1px 1px at 300px 110px, #fff, transparent);
  background-size: 340px 260px;
  animation: stars-drift 120s linear infinite;
}
#lobby::after {
  background-image:
    radial-gradient(2px 2px at 60px 90px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 260px 40px, #cfd6ff, transparent),
    radial-gradient(2px 2px at 420px 240px, #bfeaff, transparent);
  background-size: 520px 380px;
  opacity: 0.8;
  animation: stars-drift 70s linear infinite, stars-twinkle 5s ease-in-out infinite alternate;
}
@keyframes stars-drift { to { background-position: -520px 380px; } }
@keyframes stars-twinkle { from { opacity: 0.45; } to { opacity: 0.95; } }
@media (prefers-reduced-motion: reduce) {
  #lobby::before, #lobby::after { animation: none; }
}
#join-form {
  position: relative;
  z-index: 1;
  margin: auto;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgb(18 23 50 / 0.72);
  backdrop-filter: blur(14px);
  border: 1px solid rgb(143 150 255 / 0.28);
  padding: 24px;
  border-radius: 18px;
  box-shadow: 0 0 60px rgb(109 107 255 / 0.22), 0 24px 60px rgb(0 0 0 / 0.5);
}
#join-form h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.16em;
  background: linear-gradient(90deg, #fff, #b9b4ff 45%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#avatar-editor { display: flex; gap: 16px; }
.avatar-stage { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
#avatar-preview {
  background: radial-gradient(circle at 50% 85%, #5a6bd8 0%, #1b2150 55%, #0c1030 100%);
  box-shadow: inset 0 0 0 1px rgb(143 150 255 / 0.3);
  border-radius: 12px;
  image-rendering: pixelated;
  width: 192px;
  height: 264px;
}
.avatar-stage-actions { display: flex; gap: 6px; }
.avatar-stage-actions button {
  flex: 1;
  background: var(--surface-2);
  border: 0;
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 13px;
}
#avatar-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.avatar-row { display: flex; gap: 8px; align-items: flex-start; }
.avatar-row > span { flex: 0 0 62px; font-size: 13px; color: var(--muted); padding-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
}
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
#join-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#join-form input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  color: var(--text);
}
#join-error { color: #ff9a9d; margin: 0; }
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.swatches button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
}
.swatches button[aria-pressed="true"] { border-color: var(--text); }

#office { position: fixed; inset: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#tiles {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  pointer-events: none;
}
.tile {
  position: relative;
  flex: 0 0 auto;
  width: 236px;
  height: 132px;
  background: #101220;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.4);
}
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.screen video { object-fit: contain; }
.tile.self video { transform: scaleX(-1); }
.tile.self.screen video { transform: none; }
.tile .initial {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: #111;
}
.tile .label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  background: rgb(0 0 0 / 0.65);
  padding: 2px 7px;
  border-radius: 6px;
}
.tile.focus {
  position: fixed;
  inset: 16px 16px 84px;
  width: auto;
  height: auto;
  z-index: 20;
}
.tile.focus video { object-fit: contain; }

.modal-card.settings-card { flex-direction: row; max-width: 860px; height: min(620px, calc(100vh - 32px)); padding: 0; gap: 0; overflow: hidden; }
#settings-nav { flex: 0 0 216px; display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; background: var(--bg); overflow-y: auto; }
#settings-nav button { background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; text-align: left; font-size: 14px; }
#settings-nav button:hover { background: var(--surface-2); }
#settings-nav button[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
#settings-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.settings-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
#settings-close { background: transparent; border: 0; font-size: 18px; padding: 2px 8px; }
#settings-main section { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; }
#settings-main section button:not(.primary):not(#speaker-test) { background: var(--surface-2); border: 0; border-radius: 8px; padding: 9px 12px; align-self: flex-start; }
#settings-main section > .primary { align-self: flex-start; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.pref-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; }
.pref-row b { display: block; font-weight: 600; }
.pref-row small { color: var(--muted); }
.modal-card .pref-row input { flex: none; width: 38px; height: 20px; accent-color: var(--accent); }
.guest-new { display: flex; gap: 8px; }
.modal-card .guest-new select { width: auto; }
#guest-list, #object-list { margin: 0; padding: 0; list-style: none; }
#guest-list li, #object-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
#guest-list code { font-size: 15px; font-weight: 700; letter-spacing: 0.05em; }
#my-activity div { padding: 4px 0; font-size: 14px; }
body.no-mirror .tile.self video { transform: none; }
@media (max-width: 640px) {
  .modal-card.settings-card { flex-direction: column; height: auto; }
  #settings-nav { flex: none; flex-direction: row; flex-wrap: wrap; }
  #settings-nav .menu-title { display: none; }
}
.deco-title { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.deco-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.deco-tools button { background: var(--surface-2); border: 0; border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.deco-tools button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
#deco-search { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; color: var(--text); flex: none; }
#deco-floors { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 4px; flex: none; }
#deco-floors button { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 2px solid transparent; border-radius: 8px; padding: 4px 6px; font-size: 12px; text-align: left; }
#deco-floors button[aria-pressed="true"] { border-color: var(--accent-2); }
#deco-floors i { flex: none; width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.25); }
#pin-hint {
  position: absolute;
  left: 64px;
  top: 134px;
  max-width: calc(100% - 80px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 10px;
  background: #5b47c9;
  color: #fff;
  font-size: 13px;
}
#pin-hint button { background: rgb(255 255 255 / 0.18); color: #fff; border: 0; border-radius: 6px; padding: 2px 8px; }
#pin-error { color: #e5484d; margin: 0; }
#share-nag {
  position: absolute;
  left: 50%;
  bottom: 62px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: calc(100% - 16px);
  padding: 8px 10px 8px 14px;
  border-radius: 12px;
  background: #d9363e;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  z-index: 11;
}
#share-nag button {
  background: #fff;
  color: #b3242b;
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  font-weight: 700;
}
#rail-logo {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #1a1d3f, #4b3bd0 70%, #2fd6e8);
  color: #fff;
  font-weight: 800;
}
.rail-line { flex: none; width: 24px; height: 1px; background: rgb(0 0 0 / 0.14); }
#rail button { position: relative; flex: none; }
#rail button[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 46px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 7px;
  background: #1f2128;
  color: #fff;
  font-size: 12px;
  z-index: 50;
  pointer-events: none;
}
#rail { overflow: visible; }
#rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 52px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #eeeff1;
  box-shadow: 1px 0 0 rgb(0 0 0 / 0.08);
  z-index: 6;
}
#rail button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}
#rail button:hover { background: #ffffff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.14); }
.rail-gap { flex: 1; }
#office-name {
  position: absolute;
  left: 64px;
  top: 12px;
  padding: 7px 14px;
  border-radius: 10px;
  background: linear-gradient(100deg, #15193a, #2a2470);
  box-shadow: 0 0 18px rgb(109 107 255 / 0.45);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  pointer-events: none;
}
#zone-faces { display: inline-flex; }
#zone-faces i {
  width: 20px;
  height: 20px;
  margin-left: -5px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font: 700 10px system-ui, sans-serif;
  color: #1f2128;
  box-shadow: 0 0 0 2px #2b2d33;
}
#zone-faces i:first-child { margin-left: 0; }
#zone-label {
  position: absolute;
  left: 64px;
  top: 50px;
  max-width: calc(100% - 80px);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgb(31 33 40 / 0.9);
  color: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
}
#zone-lock {
  background: rgb(255 255 255 / 0.18);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}
#zone-lock:hover { background: rgb(255 255 255 / 0.28); }
#follow-label {
  position: absolute;
  left: 64px;
  top: 92px;
  background: rgb(79 86 200 / 0.92);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}
#map-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 5;
}
#zoom-controls {
  display: flex;
  flex-direction: column;
  background: #1f2128;
  color: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}
#zoom-controls button {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 0;
  font-size: 20px;
  line-height: 1;
}
#zoom-controls button:hover { background: rgb(255 255 255 / 0.14); }
#minimap {
  position: fixed;
  left: 62px;
  bottom: 12px;
  width: 120px;
  height: 84px;
  display: block;
  border-radius: 14px;
  background: #2b2d33;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
}

#dock {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  background: #24262c;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  z-index: 10;
  max-width: calc(100% - 16px);
}
#dock button {
  width: 42px;
  height: 38px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 0;
  display: grid;
  place-items: center;
  position: relative;
}
#dock button:hover { background: rgb(255 255 255 / 0.12); }
#dock .icon { font-size: 18px; line-height: 1; }
/* El texto queda para lectores de pantalla; a la vista se usa el aviso del botón. */
#dock .tag {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#dock button.off .icon { filter: grayscale(1); opacity: 0.65; }
#dock button.off::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 2px;
  background: #ff6066;
  transform: rotate(-45deg);
}
#dock button.on { background: rgb(62 207 142 / 0.24); }
#dock button.danger { color: #ff6066; }
#dock button.dock-caret { width: 18px; color: #b9bcc6; }
.dock-line { width: 1px; height: 24px; margin: 0 4px; background: rgb(255 255 255 / 0.18); }
#me-icon {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #a5e8b6;
  color: #17331f;
  font: 700 14px system-ui, sans-serif;
}
#me-icon::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #24262c;
  background: var(--ok);
}
#me-icon[data-status="focus"]::after { background: #e39b2d; }
#me-icon[data-status="away"]::after { background: #8f93a3; }
#btn-hand[aria-pressed="true"] { background: rgb(227 155 45 / 0.35); }
#btn-rec[aria-pressed="true"] { background: var(--danger); }
#dock button.danger:hover { background: var(--danger); }

#reactions {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  background: var(--glass);
  padding: 6px;
  border-radius: 12px;
  z-index: 10;
  max-width: calc(100% - 16px);
  flex-wrap: wrap;
  justify-content: center;
}
#reactions button[aria-pressed="true"] { background: var(--accent); }
#reactions button { background: transparent; border: 0; font-size: 22px; padding: 4px 6px; border-radius: 8px; }
#reactions button:hover { background: var(--surface-2); }

#panel {
  position: absolute;
  top: 0;
  left: 52px;
  bottom: 0;
  width: min(320px, 100%);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  z-index: 15;
}
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); }
.panel-tabs button { flex: 1; background: transparent; border: 0; padding: 12px 8px; color: var(--muted); }
.panel-tabs button.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
#panel-close { flex: 0 0 44px; }
#tab-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-line b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.chat-line span { overflow-wrap: anywhere; }
#chat-form { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-row { display: flex; gap: 6px; }
.chat-line.direct { background: var(--surface-2); padding: 6px 8px; border-radius: 8px; }
#chat-input, #chat-to {
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
  font: inherit;
}
#chat-input { flex: 1; }
#people-search { margin: 10px 12px 0; padding: 8px 10px; flex: none; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; color: var(--text); }
#active-areas { padding: 8px 12px 0; flex: none; font-size: 13px; }
#active-areas h4, .people-head { margin: 4px 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
#active-areas div { padding: 6px 8px; margin-bottom: 4px; border-radius: 8px; background: var(--surface-2); }
.room-sign-input { width: 100%; margin-top: 6px; padding: 5px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; color: var(--text); font-size: 12px; }
#tab-people, #tab-rooms { flex: 1; margin: 0; padding: 8px 12px; list-style: none; overflow-y: auto; }
#tab-people li, #tab-rooms li { padding: 8px 0; border-bottom: 1px solid var(--line); }
#tab-people small, #tab-rooms small { display: block; color: var(--muted); }
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.modal-card.perms-card { max-width: 1180px; }
.modal-card select.perm-team { width: auto; min-width: 112px; padding: 4px 6px; }
#rail button { color: #3a3d46; }
#dock .icon { display: grid; place-items: center; }
#zoom-controls svg { display: block; margin: auto; }
#perms-table, #log-table { overflow-x: auto; max-height: 60vh; }
#perms-table table, #log-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
#perms-table th, #log-table th { position: sticky; top: 0; background: var(--surface); font-weight: 600; font-size: 12px; padding: 6px 8px; text-align: center; vertical-align: bottom; }
#perms-table th:first-child, #log-table th { text-align: left; }
#perms-table td, #log-table td { padding: 8px; border-top: 1px solid var(--line); }
#perms-table td { text-align: center; }
#perms-table td.perm-who { text-align: left; min-width: 150px; }
#perms-table td.perm-who small { display: block; color: var(--muted); }
#perms-table td.muted { text-align: left; }
#perms-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.perm-actions { white-space: nowrap; }
.perm-actions button { background: var(--surface-2); border: 0; border-radius: 6px; padding: 3px 7px; margin-left: 4px; }
.log-date { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.modal-card .log-date input { width: auto; }
#desk-preview { align-self: center; width: 288px; height: 192px; border-radius: 12px; background: #f3e2d3; image-rendering: pixelated; max-width: 100%; }
#desk-controls { display: flex; flex-direction: column; gap: 8px; }
.modal-card #desk-controls .avatar-row > span { flex-basis: 96px; }
.person-actions button {
  background: var(--surface-2);
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}
.person-actions button:hover { background: var(--line); }

#me-menu {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 100px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: var(--glass);
  border-radius: 12px;
  z-index: 10;
}
#me-menu button { background: transparent; border: 0; border-radius: 8px; padding: 7px 8px; text-align: left; }
#me-menu button:hover { background: var(--surface-2); }
#me-menu button[aria-pressed="true"] { background: var(--surface-2); font-weight: 600; }
.menu-title { margin: 6px 8px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

body.mini { background: var(--bg); overflow: auto; }
body.mini #tiles {
  position: static;
  flex-wrap: wrap;
  padding: 8px;
  overflow: visible;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  background: #111322;
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 30;
  max-width: calc(100% - 32px);
}

#world { cursor: grab; }
#world.dragging { cursor: grabbing; }
#minimap { cursor: pointer; }

.tile-stop {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--danger);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12px;
}
#screens-toggle {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.4);
  white-space: nowrap;
  z-index: 25;
}
#screens-toggle.open { top: 8px; }
#tiles.screens-view {
  position: fixed;
  inset: 0 0 72px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  grid-auto-rows: minmax(200px, 1fr);
  gap: 8px;
  padding: 48px 12px 12px;
  overflow-y: auto;
  background: rgb(10 12 22 / 0.94);
  pointer-events: auto;
  z-index: 20;
}
#tiles.screens-view .tile { width: auto; height: auto; }
#tiles.screens-view .tile:not(.screen) { display: none; }
#tiles.screens-view .tile video { object-fit: contain; }

.tile-volume {
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  width: calc(100% - 16px);
  opacity: 0;
  transition: opacity 0.12s;
}
.tile:hover .tile-volume, .tile-volume:focus-visible { opacity: 1; }

.modal {
  position: fixed;
  inset: 0;
  background: rgb(10 12 22 / 0.65);
  display: flex;
  padding: 16px;
  overflow: auto;
  z-index: 40;
}
.modal-card {
  margin: auto;
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  border-radius: 14px;
}
.modal-card h2 { margin: 0; font-size: 20px; }
.modal-card input, .modal-card select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
  width: 100%;
}
.modal-card input[type="range"] { padding: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button:not(.primary), #speaker-test, #board-clear, #deco-cancel, #deco-erase {
  background: var(--surface-2);
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
}
#admin-error { color: #e5484d; margin: 0; }

.settings-grid { display: flex; gap: 14px; flex-wrap: wrap; }
#settings-video {
  flex: 1 1 260px;
  min-width: 0;
  aspect-ratio: 16 / 9;
  background: #101220;
  border-radius: 10px;
  transform: scaleX(-1);
  object-fit: cover;
}
.settings-fields { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.settings-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#mic-meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
#mic-meter-bar { height: 100%; width: 0; background: var(--ok); transition: width 0.08s; }
#settings-status { min-height: 1.4em; }

.board-card { max-width: 1100px; }
.board-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.board-tools h2 { flex: 1 1 auto; }
#board-colors { display: flex; gap: 6px; }
#board-colors button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
}
#board-colors button[aria-pressed="true"] { border-color: var(--accent); }
#board-canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #fff;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}

#deco {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(290px, 100%);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  z-index: 15;
}
#deco h2 { margin: 0; font-size: 18px; }
.deco-tabs { display: flex; gap: 4px; flex: none; padding: 3px; border-radius: 10px; background: var(--bg); }
.deco-tabs button { flex: 1; padding: 7px 4px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; }
.deco-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.deco-section { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
#deco-selected { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent-2); }
#deco-rooms { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
#deco-rooms li { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 8px; background: var(--surface-2); }
#deco-rooms li.selected { box-shadow: inset 0 0 0 2px var(--accent-2); }
#deco-rooms input { flex: 1; min-width: 0; padding: 5px 7px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 13px; }
#deco-rooms small { color: var(--muted); font-size: 11px; }
.deco-room-remove { background: transparent; border: 0; padding: 2px 4px; }
#desk-pop {
  position: absolute;
  z-index: 20;
  width: 220px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: 12px;
  background: var(--glass);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  font-size: 13px;
}
#desk-pop[hidden] { display: none; }
#desk-pop b { font-size: 14px; }
#desk-pop button { text-align: left; background: var(--surface-2); color: var(--text); border: 0; border-radius: 8px; padding: 7px 9px; }
#desk-pop button:hover { background: var(--line); }
#desk-pop button.primary { background: var(--accent); color: var(--on-accent); }
#desk-pop select { width: 100%; padding: 6px; border-radius: 8px; background: var(--surface-2); color: var(--text); border: 0; }
#zone-mute { background: rgb(255 255 255 / 0.14); color: inherit; border: 0; border-radius: 7px; padding: 2px 8px; margin-left: 6px; font-size: 12px; }
#zone-mute[aria-pressed="true"] { background: #d9363e; color: #fff; }
#btn-deafen[aria-pressed="true"] .icon { background: #d9363e; color: #fff; border-radius: 10px; }
.tile-mute {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  font-size: 14px;
  opacity: 0;
}
.tile:hover .tile-mute, .tile-mute:focus-visible, .tile-mute[aria-pressed="true"] { opacity: 1; }
.tile-mute[aria-pressed="true"] { background: #d9363e; }
#alerts-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #d9363e;
  color: #fff;
  font: 700 10px/16px system-ui, sans-serif;
}
#alerts-badge[hidden] { display: none; }
#roster-cred { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--ok); font-size: 13px; }
#roster-cred[hidden] { display: none; }
#roster-cred span { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
#roster-cred button { background: var(--surface); color: var(--text); border: 0; border-radius: 6px; padding: 4px 8px; }
#password-error { color: #e5484d; margin: 0; }
.show-code { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.show-code input { width: auto; }
#telegram-box { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
#telegram-box[hidden], #telegram-box > [hidden] { display: none; }
#telegram-box button { background: var(--surface); color: var(--text); border: 0; border-radius: 6px; padding: 5px 9px; }
#telegram-box button.primary { background: var(--accent); color: var(--on-accent); }
#telegram-box a { color: var(--accent-2); }
.modal-card .roster-row #telegram-token { flex: 1; min-width: 180px; }
#meeting-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
#meeting-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
#meeting-list li span { flex: 1; min-width: 180px; }
#meeting-list small { display: block; color: var(--muted); }
#meeting-list button { background: var(--surface); color: var(--text); border: 0; border-radius: 6px; padding: 4px 8px; }
.modal-card .roster-row #meeting-title { flex: 1; min-width: 180px; }
/* En portátiles pequeños caben todos los botones de la barra. */
@media (max-height: 760px) {
  #rail { gap: 3px; padding: 6px; }
  #rail button { width: 34px; height: 31px; }
  #rail-logo { width: 30px; height: 30px; }
}
@media (max-height: 560px) {
  #rail { overflow-y: auto; }
}
#alerts-desktop { background: var(--surface-2); color: var(--text); border: 0; border-radius: 8px; padding: 8px 10px; }
#alerts-list, #recs-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
#alerts-list li { padding: 7px 9px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--line); }
#alerts-list li small { display: block; color: var(--muted); }
#alerts-list li[data-level="bad"] { border-left-color: #d9363e; }
#alerts-list li[data-level="warn"] { border-left-color: #e39b2d; }
#alerts-list li[data-level="ok"] { border-left-color: var(--ok); }
.roster-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 13px; }
.roster-row label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.modal-card .roster-row input, .modal-card .roster-row select { width: auto; }
.modal-card .roster-row #roster-email, .modal-card .roster-row #mail-key, .modal-card .roster-row #mail-from { flex: 1; min-width: 200px; }
#mail-box { font-size: 13px; }
#mail-box summary { cursor: pointer; }
#mail-box form { margin-top: 6px; }
#roster-table { overflow: auto; max-height: 52vh; }
#roster-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
#roster-table th { position: sticky; top: 0; background: var(--surface); padding: 6px 4px; font-size: 12px; font-weight: 600; z-index: 1; }
#roster-table td { padding: 5px 4px; border-top: 1px solid var(--line); text-align: center; }
#roster-table td.perm-who { text-align: left; min-width: 150px; }
#roster-table td.perm-who small { display: block; color: var(--muted); }
.modal-card #roster-table input.shift { width: 92px; padding: 5px; text-align: center; font-size: 12px; }
#roster-table input.shift.bad { outline: 2px solid #d9363e; }
#roster-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
#roster-table button { background: var(--surface-2); color: var(--text); border: 0; border-radius: 6px; padding: 4px 7px; white-space: nowrap; }
#roster-table .perm-actions button { display: block; width: 100%; margin: 2px 0; }
#recs-player { width: 100%; max-height: 50vh; border-radius: 10px; background: #000; }
#recs-list li { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
#recs-list .rec-parts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
#recs-list button, #recs-list a { background: var(--surface); color: var(--text); border: 0; border-radius: 6px; padding: 3px 7px; font-size: 12px; text-decoration: none; }
#recs-list button.playing { background: var(--accent); color: var(--on-accent); }
.recs-switch input { accent-color: var(--accent); }
.help-list { margin: 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
#deco-catalog h4 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
#deco .muted { font-size: 13px; }
.deco-tools { display: flex; gap: 6px; }
#deco-erase[aria-pressed="true"] { background: var(--danger); color: #fff; }
#deco-catalog {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-content: start;
}
#deco-catalog button {
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  line-height: 1.15;
}
#deco-catalog button[aria-pressed="true"] { border-color: var(--accent); }
#deco-catalog canvas { image-rendering: pixelated; }
.deco-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 640px) {
  #avatar-editor { flex-direction: column; align-items: stretch; }
  .avatar-stage { align-self: center; }
}

@media (max-width: 700px) {
  #minimap, #zone-label { display: none; }
  #map-tools { bottom: 76px; right: 8px; }
  #dock { max-width: calc(100% - 16px); }
  #dock button { min-width: 44px; padding: 5px 2px; }
  #dock .tag { display: none; }
  .tile { width: 128px; height: 84px; }
  #tiles { justify-content: flex-start; }
}
body.editing #pin-hint { display: none; }
