/* ============================================================
   Nearlo — map-first workspace
   Part 1: tokens, base, landing, auth, lobby
   ============================================================ */
:root {
  --ink: #fafafa;
  --tx: #171717;
  --tx-2: #505050;
  --tx-3: #656565;
  --dark: #171717;
  --dark-2: #505050;
  --ac: #202020;
  --ac-2: #3a3a3a;
  --on-ac: #fff;
  --ac-soft: #ededed;
  --warn: #815015;
  --danger: #a02626;
  --status-online: #278251;
  --line: #e3e3e3;
  --line-2: #cdcdcd;
  --line-d: #d9d9d9;
  --wash: rgba(0, 0, 0, .06);

  --r-md: 12px;
  --r-lg: 18px;

  --shadow-1: 0 2px 8px rgba(0, 0, 0, .09);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .15);
  --shadow-3: 0 20px 52px rgba(0, 0, 0, .23);
  --workspace-page: #fafafa;
  --workspace-surface: #fff;
  --workspace-raised: #eaeaea;
  --workspace-inset: #f5f5f5;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, "Noto Sans Thai", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  color: var(--tx);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--tx-2); }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn.small { height: 32px; padding: 0 13px; font-size: 12.5px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--ac); color: var(--on-ac); }
.btn-primary:hover { background: var(--ac-2); }
.btn-outline { border: 1px solid var(--line-d); color: var(--dark); }
.btn-outline:hover { background: var(--wash); }
.btn-ghost { color: var(--dark-2); }
.btn-ghost:hover { background: var(--wash); color: var(--dark); }
.btn:disabled { opacity: .55; cursor: default; }

:is(.landing, .auth, .lobby, .office-entry, .app) .btn-ghost { color: var(--tx-2); }
:is(.landing, .auth, .lobby, .office-entry, .app) .btn-ghost:hover {
  background: var(--ac-soft);
  color: var(--tx);
}
:is(.landing, .auth, .lobby, .app) .btn-outline { border-color: var(--line-2); color: var(--tx); }
:is(.landing, .auth, .lobby, .app) .btn-outline:hover { background: var(--ac-soft); }

.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 15px; line-height: 1;
  color: inherit;
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--wash); }
.icon-btn.danger:hover { background: rgba(236, 91, 91, .18); color: var(--danger); }
.link-btn { font-size: 13px; font-weight: 700; color: var(--ac); padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------------- brand ---------------- */
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-mark {
  display: block; flex: none;
  width: 30px; height: 30px;
  object-fit: contain;
}
.brand-name {
  font-family: "Bricolage Grotesque", Inter, system-ui, sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1;
}
.auth-brand { margin-bottom: 20px; }
.auth-brand .brand-mark { width: 34px; height: 34px; }

/* ============================================================
   AUTH
   ============================================================ */
.auth, .lobby {
  position: fixed; inset: 0;
  display: grid;
  overflow: auto;
  padding: clamp(12px, 4vw, 48px);
  background: var(--workspace-page);
}
.entry-layout {
  width: min(390px, 100%);
  margin: auto;
}
.auth-card { position: relative; min-width: 0; }
.auth-back { position: absolute; top: 0; right: 0; color: var(--tx-2); }
.auth-card h2 { margin: 0 0 10px; padding-right: 42px; font-size: clamp(26px, 3.3vw, 38px); letter-spacing: -.025em; line-height: 1.2; }
.auth-card > .muted { margin: 0 0 22px; font-size: 14px; }
.auth-card form { display: grid; gap: 13px; text-align: left; }
.entry-layout .btn { border-radius: 10px; }
.entry-layout .field input { background: var(--workspace-inset); }
.entry-layout .btn-primary { min-height: 44px; }

.field { display: grid; gap: 6px; }
.field > span, .join-code-form .field > label {
  font-size: 14px; font-weight: 600;
  color: var(--tx-2);
}
.field > span em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--tx-3); }
.field input, .field select, .input {
  height: 42px; padding: 0 13px;
  border-radius: 8px;
  background: var(--workspace-inset);
  border: 1px solid var(--line-2);
  color: var(--tx);
  font-size: 14.5px;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.field input::placeholder { color: var(--tx-3); }
.field input:focus, .field select:focus, .input:focus {
  border-color: var(--ac-2);
  box-shadow: 0 0 0 3px var(--ac-soft);
}

.form-error { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--danger); }
.form-error:empty { display: none; }
.auth-switch { margin: 18px 0 0; font-size: 13px; color: var(--tx-2); display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   LOBBY
   ============================================================ */
.lobby-shell { width: min(1060px, 100%); min-width: 0; margin: 0 auto auto; }
.lobby-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.lobby-account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lobby-title {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: clamp(24px, 5vw, 52px) 0 22px;
}
.lobby-title h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); line-height: 1.15; }
.lobby-shell .btn { border-radius: 10px; }
.lobby-layout {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 22px; align-items: start;
}
.lobby-lists, .lobby-actions { display: grid; gap: 14px; min-width: 0; }
.join-form { min-width: 0; }
.lobby-office-card, .lobby-preview, .join-code-form {
  min-width: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--workspace-surface, #fff);
}
.lobby-office-card, .join-code-form { padding: clamp(12px, 2.2vw, 20px); }
.lobby-office-card h2, #joinCodeLabel { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
#joinCodeLabel { display: block; }
.lobby-preview { overflow: hidden; }
.lobby-preview-map {
  background: var(--workspace-inset);
  border-bottom: 1px solid var(--line);
  display: grid; place-items: center;
  padding: 14px;
}
.lobby-preview-map canvas {
  display: block; width: min(100%, 310px); height: auto;
  border-radius: 8px; image-rendering: pixelated;
}
.lobby-preview-body { display: grid; gap: 12px; padding: 16px; }
.lobby-preview-body h2 { font-size: 19px; margin: 0; overflow-wrap: anywhere; }
.lobby-preview-body .btn { min-height: 44px; justify-content: space-between; }
@media (max-width: 720px) {
  .lobby-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .lobby-preview-map canvas { width: min(100%, 240px); }
}
@media (max-width: 390px) {
  .lobby-head { gap: 8px; }
  .lobby-account { gap: 2px; }
  .lobby-head > .brand .brand-name { display: none; }
}
.lobby-profile { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 4px 8px 4px 4px; border-radius: 12px; }
.lobby-profile:hover { background: var(--wash); }
.lobby-profile > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-head #logoutBtn { flex: none; }
.join-code-form .field input { background: var(--workspace-inset); }
.join-code-form .form-error, .join-form .form-error { margin-top: 6px; }
.join-code-row { display: flex; align-items: center; gap: 8px; }
.join-code-row input { min-width: 0; flex: 1; }
.join-code-row input { text-transform: uppercase; }
.join-code-row input::placeholder { text-transform: none; }
.join-code-row button { min-height: 42px; }
.workspace-code { grid-template-columns: minmax(0, 1fr); margin: 0 0 8px; }
.workspace-code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.workspace-code-row input { width: 100%; min-width: 0; }
#copyCode { height: 42px; border-radius: 10px; white-space: nowrap; }
#workspaceCode { font-family: ui-monospace, monospace; letter-spacing: .1em; }

.office-pick { display: grid; gap: 2px; }
.office-pick .empty { margin: 0; padding: 10px 0; font-size: 13px; color: var(--tx-3); }
button.office-pick {
  width: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color .14s, background .14s;
}
button.office-pick:hover { background: var(--wash); }
button.office-pick.active {
  border-color: var(--line-2);
  background: var(--ac-soft);
}
.op-icon {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--wash);
  font-size: 11px; font-weight: 800; color: var(--tx);
}
button.office-pick.active .op-icon { background: var(--ac); color: var(--on-ac); }
.op-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.op-heading { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; min-width: 0; }
.op-code { flex: none; color: var(--tx-2); font: 500 .72rem ui-monospace, monospace; }
.op-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-meta { font-size: 12px; color: var(--tx-2); }
.op-pick-mark { width: 12px; height: 12px; flex: none; margin-left: auto; border: 1px solid var(--tx-3); border-radius: 50%; }
.office-pick.active .op-pick-mark { border: 3px solid var(--workspace-raised); outline: 1px solid var(--ac); background: var(--ac); }

/* ---------------- before entering an office ---------------- */
.office-entry {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: minmax(68px, 1fr) auto minmax(0, 1fr);
  overflow: auto;
  padding: 0 clamp(16px, 5vw, 64px);
  background: var(--workspace-page);
}
.office-entry-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 68px; align-self: start;
  border-bottom: 1px solid var(--line);
}
.office-entry-header .btn { border-radius: 9px; }
.office-entry-main {
  width: min(850px, 100%);
  margin-inline: auto;
  padding-block: clamp(28px, 6vh, 64px);
}
.office-entry-main h1 {
  margin: 0 0 clamp(26px, 5vh, 50px);
  text-align: center;
}
.office-entry-main h1:focus { outline: none; }
.office-entry-main h1 span {
  display: block;
  margin-bottom: 5px;
  font-size: .875rem; font-weight: 600;
  color: var(--tx-2);
}
.office-entry-main h1 strong {
  display: block;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.22;
  overflow-wrap: anywhere;
}
.office-entry-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(28px, 6vw, 84px);
}
.preview-media {
  position: relative;
  width: 100%; aspect-ratio: 16 / 10;
  border-radius: 16px;
  overflow: hidden;
  background: #171717;
  border: 1px solid var(--line-2);
  display: grid; place-items: center;
}
.preview-media video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
}
.preview-media.has-video video { opacity: 1; }
.preview-media.has-video .preview-ph { display: none; }
.preview-ph { display: grid; justify-items: center; gap: 10px; font-size: .875rem; color: #ccc; }
.preview-ph .icon { width: 28px; height: 28px; color: #fff; }
.entry-device-controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  min-width: 0; padding: 0; border: 0; margin: 12px 0 0;
}
.entry-device {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--workspace-inset);
  font-size: .875rem; font-weight: 600;
}
.entry-device span { display: grid; place-items: center; }
.entry-device[data-on="false"] .icon { color: var(--tx-2); }
.entry-device[data-on="true"] { background: var(--ac-soft); border-color: var(--ac); }
.entry-device:hover:not(:disabled), .entry-character:hover:not(:disabled) { background: var(--workspace-raised); }
.entry-device:disabled, .entry-character:disabled { opacity: .6; cursor: default; }
.entry-device[data-on="true"] .off, .entry-device[data-on="false"] .on { display: none; }
.entry-profile { display: grid; gap: 12px; min-width: 0; }
.entry-character {
  display: grid; place-items: center;
  justify-self: center;
  padding: 8px 14px 10px;
  margin-bottom: 4px;
  border-radius: 12px;
  font-size: .875rem; color: var(--tx-2);
}
.entry-character-stage {
  display: grid; place-items: center;
  width: 96px; height: 96px;
  background: radial-gradient(circle at center, #e5e5e5 0 60%, transparent 61%);
}
.entry-character canvas { display: block; width: 84px; height: auto; image-rendering: pixelated; }
.entry-profile .field input { height: 48px; width: 100%; background: var(--workspace-inset); }
.entry-profile .field input:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-soft); }
.entry-profile .btn { border-radius: 10px; }

@media (max-width: 620px) {
  .office-entry-main { max-width: 420px; }
  .office-entry-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .entry-profile { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px 14px; }
  .entry-character { padding-inline: 6px; margin: 0; }
  .entry-character-stage { width: 64px; height: 64px; }
  .entry-character canvas { width: 62px; }
  .entry-profile .btn, .entry-profile .form-error { grid-column: 1 / -1; }
}


/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  --tools-top: 12px;
  --panel-top: 64px;
  --dock-height: 64px;
  --corner-buttons: 36px;
  --corner-gap: 14px;
  --corner-bottom: calc(var(--footer-height) + 4px);
  --dock-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  --footer-height: calc(var(--dock-height) + var(--dock-bottom));
  --panel-inset: 12px;
  --panel-width: 282px;
  --chat-width: 334px;
  --hud-bottom: 12px;
  --minimap-width: clamp(134px, 14vw, 184px);
  position: fixed; inset: 0; overflow: hidden;
  background: var(--workspace-page);
}
.map-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #252c34;
  touch-action: none;
}

#game { display: block; width: 100%; height: 100%; }
#phaserWorld { position: absolute; inset: 0; pointer-events: none; visibility: hidden; }
#phaserWorld canvas { display: block; width: 100% !important; height: 100% !important; image-rendering: pixelated; }
#phaserWorld[data-active="true"] { visibility: visible; }
#phaserWorld[data-active="true"] + #game { opacity: 0; }

.minimap {
  position: absolute; left: 16px; bottom: var(--hud-bottom);
  width: var(--minimap-width);
  margin: 0; padding: 5px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--workspace-surface);
  box-shadow: var(--shadow-1);
  pointer-events: none;
}
.minimap-map { position: relative; border-radius: 7px; overflow: hidden; }
.minimap-map canvas { display: block; width: 100%; height: auto; }
.minimap-viewport {
  position: absolute; border: 1px solid rgba(255, 255, 255, .82);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .28) inset; border-radius: 2px;
}
.minimap-peer {
  position: absolute; width: 6px; height: 6px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: #343434; border: 1px solid #fff;
}
.map-zoom {
  position: absolute; right: 16px; bottom: var(--hud-bottom);
  display: grid; padding: 3px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--workspace-surface); box-shadow: var(--shadow-1);
}
.map-zoom button { width: 42px; height: 34px; font-size: 22px; font-weight: 400; }
#mapZoomReset { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.map-zoom button + button { border-top: 1px solid var(--line); }
.map-zoom button:disabled, #shareBtn[aria-disabled="true"] { opacity: .5; }
.room-card {
  position: absolute; top: var(--panel-top); right: 14px; z-index: 20;
  width: min(250px, calc(100% - 32px)); padding: 12px;
  display: grid; gap: 10px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--workspace-surface); box-shadow: var(--shadow-1);
}
.room-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.room-card small { display: block; margin-top: 3px; color: var(--tx-2); }
.room-card .btn { justify-content: center; }
#shareBtn[data-on="false"] { background: var(--wash); }
#shareBtn[data-on="true"] { background: var(--ac); color: var(--on-ac); }
.minimap-position {
  position: absolute; left: 50%; top: 50%;
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff; border: 1px solid #262626;
  box-shadow: 0 0 0 2px rgba(28, 28, 28, .58);
  transform: translate(-50%, -50%);
}
.minimap-location {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 3px 2px;
  font-size: 12px; font-weight: 600;
}
.minimap-location span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* camera bubbles over players */
.bubble-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cam-bubble.meeting-dimmed { filter: brightness(var(--meeting-brightness, 1)); }
.cam-bubble {
  position: absolute; top: 0; left: 0;
  width: 108px;
  border-radius: 12px; overflow: hidden;
  background: #141414;
  border: 2px solid rgba(255, 255, 255, .8);
  box-shadow: var(--shadow-2);
}
.cam-bubble[hidden] { display: none; }
.cam-bubble video { display: block; width: 100%; height: 68px; object-fit: cover; transform: scaleX(-1); }
.cam-bubble.self { border-color: var(--ac); }
.cam-bubble-name {
  display: block; padding: 3px 7px;
  font-size: 10.5px; font-weight: 700;
  background: rgba(17, 17, 17, .92); color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.peers-media { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

.map-zoom {
  right: var(--panel-inset);
  bottom: calc(var(--corner-bottom) + var(--corner-buttons) + 10px + var(--corner-gap));
}

/* ---------------- workspace navigation ---------------- */
.workspace-tools {
  position: absolute; z-index: 52;
  display: flex; align-items: center; gap: 3px;
  padding: 4px;
  background: var(--workspace-surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
}
.workspace-tools-map { top: var(--tools-top); left: 12px; }
.workspace-tools-team { top: var(--tools-top); right: 12px; }
.workspace-tools-session {
  right: var(--panel-inset);
  bottom: var(--corner-bottom);
}
.workspace-tools .icon-btn { width: var(--corner-buttons); height: var(--corner-buttons); }
@media (min-width: 1050px) {
  .app:not([data-panel="chatView"], [data-panel="meetingChat"], [data-panel="membersPanel"]) {
    --corner-bottom: var(--dock-bottom);
    --dock-edge-clearance: 150px;
  }
}
.workspace-tools .icon-btn:is([aria-expanded="true"], [aria-pressed="true"]) {
  color: var(--tx); background: var(--workspace-raised);
}
.tb-live { display: flex; align-items: center; gap: 5px; padding: 0 4px; font-size: 12px; }
.tb-live > span { color: var(--status-online); font-size: 9px; }
.net-status { font-size: 11px; color: var(--tx-3); }
.net-status.ok { color: var(--tx-2); }
.net-status.bad { color: var(--danger); }

/* ---------------- floating workspace panels ---------------- */
.panel {
  position: absolute;
  top: var(--panel-top);
  bottom: var(--footer-height);
  height: auto;
  max-height: 600px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--workspace-surface);
  box-shadow: var(--shadow-3);
  z-index: 45;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: workspace-panel-in .18s ease-out;
}
@keyframes workspace-panel-in {
  from { opacity: 0; transform: translateY(-6px) scale(.99); }
}
@keyframes panelIn { from { opacity: 0; } }
.panel-head {
  min-height: 50px; flex: none;
  display: flex; align-items: center; gap: 9px;
  padding: 0 10px 0 16px;
  background: var(--workspace-page);
  border-bottom: 1px solid var(--line);
}
.panel-head b { font-size: 13.5px; font-weight: 700; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; }
.panel-body::-webkit-scrollbar, .chat-log::-webkit-scrollbar, .office-pick::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb, .chat-log::-webkit-scrollbar-thumb { background: var(--wash); border-radius: 8px; }

/* sidebar: rooms */
.sidebar, .members { width: min(var(--panel-width), calc(100% - 2 * var(--panel-inset))); }
.sidebar { left: var(--panel-inset); width: min(320px, calc(100% - 2 * var(--panel-inset))); }
.members { right: var(--panel-inset); }
.workspace-panel-head {
  align-items: flex-start;
  gap: 11px;
  padding: 13px 10px 13px 14px;
  background: var(--workspace-surface);
}
.workspace-panel-head .office-icon { width: 40px; height: 40px; font-size: 13px; border-radius: 11px; }
.workspace-heading h2 {
  margin: 0; font-size: 16px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.workspace-status { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.workspace-status .tb-live { padding: 0; color: var(--tx-2); }
.workspace-status .tb-live b { font-size: inherit; }
.workspace-panel-body { padding: 13px 14px; }
.workspace-switch { display: flex; align-items: end; gap: 7px; }
.workspace-switch .workspace-picker { flex: 1; min-width: 0; margin: 0; }
.workspace-switch .workspace-create { width: 42px; min-height: 42px; padding: 0; font-size: 19px; }
.workspace-invite {
  display: grid; gap: 7px;
  padding: 10px; margin: 12px 0 16px;
  background: var(--workspace-page);
  border: 1px solid var(--line); border-radius: 12px;
}
.workspace-invite .workspace-code { margin: 0; }
.workspace-invite #workspaceCode { font-size: .75rem; letter-spacing: .04em; }
.workspace-invite-link {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 32px; padding: 5px 8px;
  border-radius: 7px; text-align: left; font-size: .75rem; font-weight: 650;
}
.workspace-invite-link:hover:not(:disabled) { background: var(--wash); }
.workspace-invite-link:disabled { opacity: .5; cursor: default; }
.workspace-section-heading { display: flex; align-items: center; justify-content: space-between; }
.workspace-section-heading .side-group-head { margin: 0; padding: 4px 0; font-size: .78rem; letter-spacing: normal; }
.workspace-section-heading .workspace-add { width: 29px; height: 29px; font-size: 17px; }
.sidebar .ch-item { min-height: 34px; padding: 5px 8px; }
.sidebar .ch-item.active { box-shadow: none; background: var(--ac-soft); }

.sidebar .field input, .sidebar .field select { background: var(--workspace-inset); }
.sidebar .field select { width: 100%; min-width: 0; }
.app .field input:focus, .app .field select:focus, #modalRoot .field input:focus, #modalRoot .field select:focus {
  border-color: var(--ac-2);
  box-shadow: 0 0 0 2px var(--ac-soft);
}
.office-icon {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--ac); color: var(--on-ac);
  font-size: 10px; font-weight: 800;
}
.side-group { margin-bottom: 14px; }
.side-group-head {
  padding: 2px 8px 7px;
  font-size: 10.5px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--tx-3);
}
.ch-list { display: grid; gap: 2px; }
.ch-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  border-radius: 10px;
  color: var(--tx-2);
  font-size: 13px; font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
}
.ch-item:hover { background: var(--wash); color: var(--tx); }
.ch-item.active { background: var(--workspace-raised); color: var(--tx); font-weight: 600; box-shadow: inset 2px 0 0 var(--ac); }
.ch-ico { width: 16px; flex: none; text-align: center; font-size: 12.5px; opacity: .8; }
.ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-live { margin-left: auto; font-size: 10.5px; font-weight: 800; color: var(--ac-2); }
.ch-unread {
  margin-left: auto;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800;
  display: grid; place-items: center;
}
.ch-add {
  width: 100%; margin-top: 2px;
  padding: 7px 10px; border-radius: 10px;
  text-align: left;
  font-size: 12px; color: var(--tx-3);
}
.ch-add:hover { background: var(--wash); color: var(--tx); }

.me-bar {
  flex: none;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  background: var(--workspace-inset);
}
:is(.me-avatar, .member-av, .msg-avatar, .dt-initials) {
  color: var(--tx);
}
:is(.me-avatar, .member-av, .msg-avatar, .dt-initials):not(:has(> .avatar-photo)) {
  background: var(--workspace-raised);
}
.me-avatar {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 11.5px; font-weight: 800;
}
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-state { font-size: 10.5px; color: var(--tx-2); }
.me-btn { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; opacity: .5; }
.me-btn:hover { background: var(--wash); opacity: .9; }
.me-btn[data-on="true"] { opacity: 1; background: rgba(236, 91, 91, .2); }

/* members */
.members-list { padding: 8px; display: grid; gap: 2px; align-content: start; }
.m-group {
  padding: 10px 8px 5px;
  font-size: 10px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--tx-3);
}
.member {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 10px;
}
.member:hover { background: var(--wash); }
.member-av {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 11px; font-weight: 800;
}
.member.speaking .member-av { box-shadow: 0 0 0 2px var(--ac); }
.member-info { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.member-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-name i { font-style: normal; color: var(--tx-3); font-weight: 500; }
.member-room { font-size: 10.5px; color: var(--tx-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-icons { display: flex; gap: 3px; font-size: 10.5px; flex: none; }
.member-icons .off { opacity: .3; }
.member:not(.live) { opacity: .68; }

/* chat */
.chat {
  right: var(--panel-inset);
  width: min(var(--chat-width), calc(100% - 2 * var(--panel-inset)));
  max-height: 720px;
}
#meetingChat { top: calc(var(--panel-top) + 50px); }
@media (min-width: 821px) {
  .chat { bottom: var(--dock-bottom); }
  .app[data-panel="membersPanel"] .workspace-tools-session {
    right: calc(var(--panel-width) + 2 * var(--panel-inset));
  }
  .app:is([data-panel="chatView"], [data-panel="meetingChat"]) .workspace-tools-session {
    right: calc(var(--chat-width) + 2 * var(--panel-inset));
  }
  .app:is([data-panel="chatView"], [data-panel="meetingChat"]) .workspace-footer {
    right: calc(var(--chat-width) + var(--panel-inset));
  }
}
.ch-hash { font-size: 17px; color: var(--tx-3); }
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-empty { margin: 0; padding: 34px 10px; text-align: center; font-size: 12.5px; color: var(--tx-3); }
.msg { display: flex; gap: 10px; }
.msg-avatar {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 12px; font-weight: 800;
}
.msg-body { min-width: 0; flex: 1; }
.msg-top { display: flex; align-items: baseline; gap: 7px; }
.msg-name { font-size: 12.5px; font-weight: 700; }
.msg-time { font-size: 10.5px; color: var(--tx-3); }
.msg-text { font-size: 13.5px; line-height: 1.6; color: var(--tx); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text code { padding: 1px 5px; border-radius: 5px; background: var(--wash); font-size: 12.5px; }
.msg.compact { margin-top: -6px; }
.msg-gutter { width: 34px; flex: none; text-align: right; font-size: 10px; color: var(--tx-3); opacity: 0; }
.msg:hover .msg-gutter { opacity: 1; }

.day-divider { display: flex; align-items: center; gap: 10px; font-size: 10.5px; font-weight: 700; color: var(--tx-3); }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.empty-channel { text-align: center; padding: 30px 8px; color: var(--tx-2); }
.empty-hash {
  width: 52px; height: 52px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--wash);
  font-size: 24px; font-weight: 800; color: var(--tx-3);
}
.empty-channel h3 { margin: 0 0 4px; font-size: 14.5px; color: var(--tx); }
.empty-channel p { margin: 0; font-size: 12.5px; }

.typing-bar { flex: none; height: 18px; padding: 0 16px; font-size: 11px; color: var(--tx-3); }
.chat-form {
  flex: none;
  display: flex; align-items: flex-end; gap: 6px;
  margin: 0 10px 10px;
  padding: 6px 6px 6px 12px;
  border-radius: 14px;
  background: var(--workspace-inset);
  border: 1px solid var(--line);
}
.chat-form textarea {
  flex: 1; min-width: 0;
  height: 32px; max-height: 130px;
  padding: 7px 0;
  background: none; border: 0; outline: none; resize: none;
  color: var(--tx); font-size: 13.5px; line-height: 1.4;
}
.chat-form textarea::placeholder { color: var(--tx-3); }
.chat-emoji { width: 32px; height: 32px; flex: none; border-radius: 9px; font-size: 15px; }
.chat-emoji:hover { background: var(--wash); }
.chat-send {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--ac); color: var(--on-ac);
  font-size: 13px;
}
.chat-send:hover { background: var(--ac-2); }

/* ---------------- call bar ---------------- */
.workspace-footer {
  position: absolute; inset: auto 0 var(--dock-bottom);
  height: var(--dock-height); z-index: 50;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.stage-mini {
  color-scheme: dark;
  --workspace-surface: #222;
  --workspace-inset: #181818;
  --workspace-raised: #3c3c3c;
  --tx: #f7f7f7;
  --tx-2: #c7c7c7;
  --tx-3: #aaa;
  --ac: #fff;
  --ac-2: #d6d6d6;
  --on-ac: #191919;
  --ac-soft: #363636;
  --line: #3c3c3c;
  --line-2: #595959;
  --wash: rgba(255, 255, 255, .12);
  color: var(--tx);
}
.call-bar {
  position: relative;
  pointer-events: auto;
  box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 2 * var(--dock-edge-clearance, 8px));
  padding: 4px 7px;
  border-radius: 12px;
  background: var(--workspace-surface);
  border: 1px solid var(--line);
}
.resume-office-audio {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  box-shadow: var(--shadow-2);
}
.resume-office-audio:active { transform: translate(-50%, 1px); }
.bar-tiles { display: flex; align-items: center; gap: 7px; min-width: 0; overflow-x: auto; }
.bar-tiles::-webkit-scrollbar { height: 0; }
.bar-tile {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 11px 5px 5px;
  border-radius: 14px;
  background: var(--wash);
  border: 1px solid transparent;
  flex: none; max-width: 196px;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.bar-tile.speaking { border-color: var(--ac-2); background: var(--ac-soft); }
.bar-tile.action { cursor: pointer; }
.bar-tile.action:hover { background: var(--wash); }
.bar-tile .dt-av {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 12px; font-weight: 800;
}
.bar-tile .dt-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.bar-tile .dt-name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-tile .dt-sub { font-size: 10.5px; color: var(--tx-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-tile .dt-icons { display: flex; flex: none; gap: 3px; color: var(--tx-2); }
.dt-presence { position: absolute; inset: auto -3px -2px auto; display: flex; }
.dt-presence .presence-badge {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--workspace-surface);
  font-size: 10px;
}
.bar-tile .dt-icons[hidden] { display: none; }

.bar-share {
  position: relative;
  width: 82px; height: 42px; flex: none;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: #141414;
}
.bar-share video { display: block; width: 100%; height: 100%; object-fit: cover; }
.bar-share span {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 7px;
  font-size: 10px; font-weight: 700;
  background: rgba(17, 17, 17, .9);
  color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-share-play {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-style: normal; font-size: 15px; color: #fff;
  background: rgba(17, 17, 17, .34);
  pointer-events: none;
}
.bar-share:hover .bar-share-play { background: rgba(17, 17, 17, .1); }

.cb-controls { display: flex; align-items: center; gap: 5px; flex: none; padding-left: 6px; border-left: 1px solid var(--line); }
.device-control { display: flex; align-items: stretch; border-radius: 13px; background: var(--wash); }
.device-control .ctrl { border-radius: 13px 0 0 13px; }
.device-dropdown { display: grid; place-items: center; width: 23px; padding: 0; border-radius: 0 13px 13px 0; color: var(--tx-2); }
.device-dropdown .icon { width: 13px; height: 13px; }
.device-dropdown:hover, .device-dropdown[aria-expanded="true"] { background: var(--workspace-raised); color: var(--tx); }
.device-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  width: min(270px, calc(100vw - 24px)); padding: 12px;
  display: grid; gap: 8px; color: var(--tx); font-size: .8rem;
  background: var(--workspace-surface); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow-3);
}
.device-menu select { min-width: 0; width: 100%; }
.device-menu span:empty { display: none; }
.ctrl {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--wash);
  font-size: 16px;
  transition: background .14s, color .14s;
}
.ctrl:hover { background: var(--wash); }
.ctrl[data-on="true"] { background: var(--workspace-raised); box-shadow: inset 0 0 0 1px var(--line-2); }
.ctrl[data-on="false"] { color: var(--tx-2); background: var(--workspace-inset); }
.ctrl[data-on="true"] .off, .ctrl[data-on="false"] .on { display: none; }

/* ---------------- meeting view ---------------- */
.meeting-open .map-layer { visibility: hidden; }
.meeting-open :is(.move-pad, #barShare, #barTiles .bar-tile:not(.own)) { display: none; }
.meeting-open :is(.bar-tile, .device-control, .ctrl, .ctrl[data-on="false"]) { background: transparent; }
.meeting-open #shareBtn[aria-disabled="true"] { background: transparent; }
.meeting-open :is(.bar-tile, .ctrl):hover { background: var(--wash); }
.meeting-open :is(.bar-tile.speaking, .ctrl[data-on="true"]) { background: var(--ac-soft); }
.meeting-open :is(.device-control, .ctrl) { border-radius: 8px; }
.meeting-open .device-control .ctrl { border-radius: 8px 0 0 8px; }
.meeting-open .device-dropdown { border-radius: 0 8px 8px 0; }
.stage {
  --meeting-frame-line: #c8c8c8;
  position: absolute;
  inset: 0;
  padding-top: var(--panel-top);
  display: flex; flex-direction: column;
  background: var(--workspace-surface);
  overflow: hidden;
  z-index: 35;
}
.stage-head {
  min-height: 46px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 14px;
  border-bottom: 1px solid var(--line);
}
.stage-head b { min-width: 0; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-count { color: var(--tx-2); font-size: .75rem; white-space: nowrap; }
.stage-head [hidden] { display: none; }
.stage-head .btn { height: 34px; padding-inline: 9px; border-radius: 8px; }
.stage-head [aria-pressed="true"] { background: var(--workspace-raised); }
.stage-head .meeting-leave { color: var(--danger); }
.meeting-share-options { min-width: 0; display: flex; gap: 4px; overflow-x: auto; }
.meeting-share-options:empty { display: none; }
.meeting-share-options button { flex: none; max-width: 140px; overflow: hidden; text-overflow: ellipsis; padding-inline: 7px; }
.stage-body {
  position: relative;
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--meeting-columns, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(155px, 1fr);
  gap: 12px; padding: 12px 12px var(--footer-height); overflow: auto;
}
.meeting-people { display: contents; }
.stage.has-share:not(.big) .stage-body {
  grid-template-columns: minmax(175px, 1fr) minmax(0, 2fr);
  grid-auto-rows: minmax(0, 1fr);
}
.stage.has-share:not(.big) .meeting-people {
  display: grid; grid-template-columns: repeat(var(--participant-columns, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(138px, 1fr);
  gap: 12px; overflow: auto;
}
.meeting-tile {
  position: relative; display: grid;
  min-width: 0; min-height: 0; margin: 0; overflow: hidden;
}
.meeting-person {
  place-items: center; align-content: center; gap: 8px;
  border: 1px solid var(--meeting-frame-line); border-radius: 8px;
  background: var(--workspace-inset);
}
.meeting-person.speaking:not(.has-video) .meeting-avatar { outline: 2px solid var(--ac-2); outline-offset: 3px; }
.meeting-person.speaking.has-video::after {
  content: ""; position: absolute; inset: 0;
  border: 2px solid var(--ac-2); border-radius: inherit; pointer-events: none;
}
.meeting-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.meeting-tile:not(.has-video) video { opacity: 0; }
.meeting-tile .meeting-avatar { width: 76px; height: 76px; background: var(--workspace-raised); font-size: 20px; }
.meeting-tile.has-video .meeting-avatar, .meeting-tile.has-video .meeting-waiting { visibility: hidden; }
.meeting-self video { transform: scaleX(-1); }
.meeting-share { grid-template-rows: minmax(0, 1fr) auto; }
.meeting-share-frame {
  position: relative;
  grid-area: 1 / 1;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--workspace-inset);
  box-shadow: inset 0 0 0 1px var(--meeting-frame-line);
}
.meeting-share-frame :is(video, .meeting-waiting) { grid-area: 1 / 1; }
.meeting-share video { object-fit: contain; padding: 1px; }
.meeting-share .meeting-waiting { place-self: center; }
.meeting-share .meeting-label { grid-row: 2; justify-self: center; }
.meeting-label {
  display: flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 4px 8px;
  font-size: .75rem; font-weight: 600;
}
.meeting-person.has-video .meeting-label {
  position: absolute; left: 8px; bottom: 8px;
  max-width: calc(100% - 16px);
  border-radius: 5px; background: #fffffff0;
}
.meeting-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting-waiting { color: var(--tx-2); padding: 12px; text-align: center; font-size: .875rem; }
.meeting-reaction { position: absolute; right: 10px; bottom: 8px; font-size: 25px; }
.meeting-reaction:not(:empty) { animation: panelIn .16s ease; }
.meeting-chat-scope { margin: 0 14px 8px; color: var(--tx-3); font-size: .72rem; }
.stage-head [aria-expanded="true"] { background: var(--workspace-raised); }
.stage.big .stage-body {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}
.stage.big .meeting-share { grid-row: 1; width: 100%; justify-self: center; }
.stage.big .meeting-people {
  grid-row: 2;
  display: flex; justify-content: safe center; gap: 8px; overflow-x: auto;
}
.stage.big .meeting-person {
  width: clamp(108px, 12vw, 152px); height: 90px;
  flex: none; gap: 2px;
}
.stage.big .meeting-avatar { width: 38px; height: 38px; font-size: 12px; }

#streamFullscreen {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 12px;
  border-radius: 8px;
  cursor: zoom-in;
}
#streamFullscreen .icon {
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 6px;
  color: var(--tx);
  background: var(--workspace-surface);
  border: 1px solid var(--line);
  opacity: 0;
}
#streamFullscreen:is(:hover, :focus-visible) .icon,
.stage.big #streamFullscreen .icon { opacity: 1; }
.stage.big #streamFullscreen { cursor: zoom-out; }

.stage-mini {
  position: absolute; top: var(--panel-top); left: 50%;
  transform: translateX(-50%);
  width: clamp(160px, 23vw, 310px); padding: 0;
  border-radius: 13px;
  overflow: hidden;
  background: #141414;
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  z-index: 55;
}
.stage-mini:hover { border-color: var(--ac); }
.stage-mini video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; }
.stage-mini-label {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  font-size: 10.5px; font-weight: 700;
  background: var(--workspace-surface);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stage-mini-label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- emote picker ---------------- */
.emote-picker {
  position: absolute; left: 50%; bottom: calc(var(--footer-height) + 8px);
  transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(5, 40px);
  gap: 4px; padding: 8px;
  border-radius: var(--r-md);
  background: var(--workspace-surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  z-index: 70;
}
.emote-picker button { width: 40px; height: 40px; border-radius: 10px; font-size: 19px; }
.emote-picker button:hover { background: var(--wash); }

/* ============================================================
   MODALS / TOASTS
   ============================================================ */
.modal-card {
  width: min(430px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: clamp(14px, 4vw, 22px);
  border-radius: var(--r-lg);
  background: var(--workspace-surface);
  color: var(--tx);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  overflow: auto;
  overscroll-behavior: contain;
  animation: panelIn .17s ease;
}
dialog.modal-card {
  position: fixed; inset: 0;
  margin: auto;
  display: block;
  height: fit-content;
}
dialog.modal-card:not([open]) { display: none; }
.modal-card::backdrop { background: rgba(0, 0, 0, .52); backdrop-filter: blur(3px); }
.modal-content { display: grid; gap: 12px; }
.modal-card h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-card p { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--tx-2); }
.modal-card p.form-error { color: var(--danger); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.modal-card .btn-outline { border-color: var(--line-2); color: var(--tx); }

.mini-btn {
  height: 34px; padding: 0 15px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--tx);
  font-size: 13px; font-weight: 600;
}
.mini-btn:hover { background: var(--wash); }
.mini-btn:disabled { opacity: .6; cursor: default; }
.join-btn.small {
  height: 34px; padding: 0 17px;
  border-radius: 999px;
  background: var(--ac); color: var(--on-ac);
  font-size: 13px; font-weight: 700;
}
.join-btn.small:hover { background: var(--ac-2); }
.join-btn:disabled { opacity: .6; cursor: default; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; height: 36px;
  border-radius: 10px;
  background: var(--wash);
  border: 1px solid var(--line);
  color: var(--tx-2);
  font-size: 12px; font-weight: 600;
}
.seg button.on { background: var(--ac-soft); border-color: var(--ac-2); color: var(--tx); }

.office-create-dialog {
  width: min(540px, calc(100% - 32px));
  color: var(--tx);
}
.office-create-form { display: grid; gap: 14px; min-width: 0; }
.office-create-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.office-create-head h2 { margin: 0; font-size: 23px; line-height: 1.2; letter-spacing: -.02em; }
.office-create-head .icon-btn { color: var(--tx-2); }
.office-create-fields { display: grid; grid-template-columns: minmax(0, 1fr) 82px; gap: 10px; }
.office-create-fields input { width: 100%; min-width: 0; }
#officeIconInput { text-align: center; font-weight: 700; text-transform: uppercase; }
.office-theme-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.office-theme-field legend { margin-bottom: 7px; padding: 0; font-size: 14px; font-weight: 600; color: var(--tx-2); }
.theme-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.theme {
  position: relative;
  display: grid; min-width: 0; gap: 3px;
  padding: 4px; border-radius: 10px;
  background: var(--workspace-inset);
  border: 1px solid var(--line);
  cursor: pointer;
}
.theme input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme canvas { width: 100%; height: auto; display: block; border-radius: 6px; }
.theme span { padding: 2px 4px 3px; font-size: 13px; font-weight: 600; color: var(--tx-2); }
.theme small { padding: 0 4px 3px; font-size: 11px; color: var(--tx-2); }
.theme:has(input:checked) { border-color: var(--ac); background: var(--workspace-raised); }
.theme:has(input:checked) span { color: var(--tx); }
.theme:has(input:focus-visible) { outline: 2px solid var(--ac-2); outline-offset: 2px; }
.office-create-footer { display: flex; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--line); }
.office-create-footer .btn { height: 42px; border-radius: 10px; }
@media (max-width: 390px) {
  .theme-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .theme canvas { aspect-ratio: 2.2; object-fit: cover; }
}

.keys { margin: 0; display: grid; gap: 7px; }
.keys > div { display: flex; align-items: center; gap: 12px; }
.keys dt {
  flex: none; min-width: 76px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--wash);
  border: 1px solid var(--line);
  font-size: 10.5px; font-weight: 700;
  text-align: center; letter-spacing: .04em;
}
.keys dd { margin: 0; font-size: 12.5px; color: var(--tx-2); }

.toasts {
  position: fixed; left: 50%; bottom: 92px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 500; pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 999px;
  background: #171717;
  border: 1px solid #393939;
  color: #fff;
  font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-2);
  animation: toastIn .18s ease;
}
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .24s, transform .24s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 820px) {
  .app {
    --tools-top: 8px;
    --panel-inset: 8px;
    --panel-top: 56px;
    --dock-height: 62px;
    --corner-buttons: 32px;
    --hud-bottom: 8px;
    --minimap-width: clamp(120px, 22vw, 148px);
  }
  .workspace-tools-map { left: 8px; }
  .workspace-tools-team { right: 8px; }
  .net-status.ok { display: none; }
  .sidebar, .members, .chat { width: min(360px, calc(100% - 2 * var(--panel-inset))); }
  .app:is([data-panel="membersPanel"], [data-panel="chatView"], [data-panel="meetingChat"]) .workspace-tools-session {
    visibility: hidden;
  }
  .room-card { right: 8px; }
  .minimap { left: 8px; }
  .map-zoom { right: 8px; }
  .minimap { bottom: calc(var(--footer-height) + var(--hud-bottom)); }
  .call-bar { padding: 4px 6px; gap: 6px; }
  .ctrl { width: 37px; height: 38px; border-radius: 9px; }
  .bar-tile { max-width: 132px; }
  .bar-share { width: 68px; height: 38px; }
}
@media (max-width: 620px) {
  .device-dropdown { width: 18px; }
  .call-bar .bar-tile.own .dt-info, .call-bar .bar-tile.own .dt-icons { display: none; }
  .stage-count { display: none; }
  .stage-head { flex-wrap: wrap; }
  #meetingChat { top: calc(var(--panel-top) + 86px); }
  .meeting-leave span, #stageClose span { display: none; }
  .stage-body { grid-template-columns: minmax(0, 1fr); }
  .stage.has-share:not(.big) .stage-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(155px, 1.2fr) minmax(125px, 1fr);
  }
  .stage.has-share:not(.big) .meeting-people { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
  .meeting-share { grid-row: 1; }
}

#previewLevel { position: absolute; inset: auto 5px 5px; height: 3px; overflow: hidden; border-radius: 4px; }
#previewLevel span { display: block; height: 100%; background: #fff; transform: scaleX(0); transform-origin: left; }
.msg-text a { color: var(--ac-2); text-decoration: underline; }
.move-pad { display: none; }
@media (pointer: coarse) {
  #streamFullscreen .icon { opacity: 1; }
  .move-pad {
    position: absolute; left: 12px; z-index: 42;
    bottom: calc(var(--footer-height) + var(--hud-bottom) + 6px);
    display: grid; grid-template-columns: repeat(3, 40px); gap: 4px;
    touch-action: none;
  }
  .minimap { bottom: calc(var(--footer-height) + var(--hud-bottom) + 92px); }
  .move-pad button { height: 40px; border-radius: 10px; background: var(--workspace-surface); color: var(--tx); }
  .move-pad button:first-child { grid-column: 2; }
  .move-pad button:nth-child(2) { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: middle;
}
.icon-btn .icon, .ctrl .icon, .entry-device .icon { width: 18px; height: 18px; }
.card-ico .icon { width: 22px; height: 22px; color: var(--tx); }
.member-icons, .bar-tile .dt-icons { align-items: center; font-size: 14px; }
.presence-badge { display: inline-grid; place-items: center; width: 16px; height: 16px; }
.presence-badge.active::before { content: ""; width: 7px; height: 7px; background: var(--status-online); border-radius: 50%; }
.presence-badge.away { color: var(--tx-2); }

.profile-dialog { width: min(380px, calc(100% - 32px)); color: var(--tx); }
.office-search { width: min(440px, calc(100% - 32px)); }
.office-search input { width: 100%; }
.office-search .ch-list { max-height: min(390px, 48vh); overflow-y: auto; }
.office-search .ch-list > p { padding: 8px 4px; }
.profile-head, .profile-identity { display: flex; align-items: center; gap: 12px; }
.profile-head { justify-content: space-between; }
.profile-identity { overflow-wrap: anywhere; }
.profile-identity .me-avatar { width: 44px; height: 44px; }

.avatar-photo { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.dt-initials { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.profile-form { margin-top: 12px; }
.profile-form, .invite-content { display: grid; gap: 12px; }
.profile-form input[type="file"] { height: auto; min-height: 42px; padding: 8px; width: 100%; }
.profile-form input::file-selector-button {
  border: 0; border-radius: 7px; padding: 5px 9px; margin-inline-end: 7px;
  background: var(--ac-soft); color: var(--tx); font: inherit; cursor: pointer;
}
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; }
.profile-actions .btn-ghost { color: var(--tx-2); }

.dt-camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transform: scaleX(-1);
}
.bar-tile:disabled { cursor: default; }

.entry-layout .field input:focus {
  border-color: var(--ac-2);
  box-shadow: 0 0 0 2px var(--ac-soft);
}
#officeModal, #officeCreatedDialog { background: var(--workspace-surface); }
#officeModal .field input, #officeCreatedDialog .field input { background: var(--workspace-inset); }

#createdOfficeCode { font: 700 1.2rem ui-monospace, monospace; letter-spacing: .2em; }
#createdCodeStatus { color: var(--tx-2); }

.dropdown { min-width: 0; }
.dropdown-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--workspace-inset); color: var(--tx);
  font-size: 14px; text-align: left;
}
.dropdown-trigger > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-trigger[aria-expanded="true"] { border-color: var(--ac-2); }
.dropdown-trigger[aria-expanded="true"] .icon { transform: rotate(180deg); }
.dropdown-trigger:disabled { opacity: .55; cursor: default; }
.dropdown-options {
  position: fixed; inset: auto; margin: 0;
  display: grid; gap: 2px; max-height: 180px; overflow: auto;
  overscroll-behavior: contain; padding: 4px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--workspace-inset);
}
.dropdown-options:popover-open { box-shadow: var(--shadow-2); }
.dropdown-options button {
  min-width: 0; padding: 8px 10px; border-radius: 8px;
  text-align: left; overflow-wrap: anywhere; color: var(--tx-2);
}
.dropdown-options button:hover, .dropdown-options button[aria-selected="true"] {
  background: var(--workspace-raised); color: var(--tx);
}
.dropdown-options button:focus-visible { outline-offset: -2px; }

#characterTarget {
  position: absolute; padding: 0; border: 0; border-radius: 9px;
  background: transparent; cursor: pointer;
  transform: translate(-50%, -100%);
}
#characterTarget:focus-visible { outline: 2px solid #fff; box-shadow: 0 0 0 4px #333; }

.character-dialog { width: min(585px, calc(100% - 32px)); background: var(--workspace-surface); }
.character-dialog form { display: grid; gap: 14px; }
.character-layout { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 20px; align-items: start; min-width: 0; }
.character-preview {
  grid-area: 1 / 2;
  display: grid; justify-items: center; gap: 8px; padding: 7px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--workspace-inset);
}
.character-preview canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.character-tools, .character-choices, .character-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.character-tools { justify-content: center; }
.character-tools .btn, #profileCharacter { color: var(--tx-2); }
.character-tools .btn:hover, .character-tools .btn[aria-pressed="true"], #profileCharacter:hover { color: var(--tx); }
.character-tools .btn { padding: 6px 8px; font-size: 12px; }
.character-tools [aria-pressed="true"] { background: var(--ac-soft); }
.character-options { grid-area: 1 / 1; display: grid; gap: 12px; min-width: 0; }
.character-options fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.character-options legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.character-option {
  display: inline-grid; place-items: center; gap: 3px; min-height: 32px;
  padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--workspace-inset); color: var(--tx); font: inherit;
  font-size: 12px; cursor: pointer;
}
.character-option canvas { image-rendering: pixelated; }
.character-option:hover { background: var(--ac-soft); }
.character-option[aria-pressed="true"] {
  border-color: var(--ac-2); background: var(--ac-soft);
}
.character-swatches { margin-top: 6px; }
.character-swatches .character-option { min-width: 32px; padding: 4px; }
.character-swatch { display: block; width: 18px; height: 18px; border-radius: 4px; }
#characterError:empty { display: none; }
@media (max-width: 520px) {
  .character-layout { grid-template-columns: 1fr; gap: 12px; }
  .character-preview { grid-area: auto; grid-template-columns: 100px 1fr; align-items: center; }
  .character-options { grid-area: auto; gap: 9px; }
}

.seat-action {
  position: absolute; top: 0; left: 0; z-index: 1; padding: 5px 12px;
  min-height: 30px; border: 1px solid #b8b8b8; border-radius: 9px;
  background: #262626; color: #fff; font: 600 13px system-ui, sans-serif; cursor: pointer;
  transform: var(--seat-placement, none);
}
.seat-action[hidden] { display: none; }
.seat-action:hover { background: #444; }
@media (pointer: coarse) {
  .seat-action { inset: 76px 14px auto auto; min-width: 48px; min-height: 44px; transform: none; }
}

.lobby-office-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
}
.office-settings { width: min(460px, calc(100% - 24px)); }
.office-settings-cover {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--workspace-inset);
  color: var(--tx-2);
  font-size: .875rem;
}
.office-settings-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
#removeOfficeCover { justify-self: start; }
