/* App shell: gather-style left bar, floating right window, and the world between them. */

:root {
  --lb-open: 340px;
  --lb-rail: 62px;
}

body {
  --lb-w: 0px;
}

body.in-app .world {
  left: var(--lb-w);
  transition: left 0.25s var(--ease, ease);
}

body.in-app .hud-top {
  left: calc(var(--lb-w) + 12px);
}

body.in-app .dock {
  left: calc(var(--lb-w) + (100vw - var(--lb-w)) / 2);
}

body.in-app.side-open .dock {
  left: calc(var(--lb-w) + (100vw - var(--lb-w) - var(--side-w) - 14px) / 2);
}

body.in-app.side-open .zoom-ctl,
body.in-app.side-open .toasts {
  right: calc(var(--side-w) + 28px);
}

body.in-app.side-open .minimap {
  display: none;
}

/* The left bar holds the status and settings on desktop, so the dock keeps only call controls. */
@media (min-width: 761px) {
  body.in-app .dock-me,
  body.in-app .dock-me-sep {
    display: none;
  }
}

body.in-app .toasts {
  top: 64px;
}

/* Top right tools */

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-tools {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-sm);
}

.tool-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2, var(--muted));
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tool-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}

.tool-btn.active {
  background: var(--accent-soft, color-mix(in srgb, var(--accent) 18%, transparent));
  color: var(--accent-text, var(--accent));
}

.tool-btn[hidden] {
  display: none;
}

.tool-btn::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--tip-bg, rgba(14, 16, 28, 0.94));
  color: #fff;
  font: 500 12px/1.2 var(--font);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.12s, transform 0.12s;
}

.tool-btn:hover::after,
.tool-btn:focus-visible::after {
  opacity: 1;
  transform: none;
}

/* Left bar footer: who you are and your settings */

.lb-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

.lb-me {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 5px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.lb-me:hover {
  background: var(--panel-3);
}

.lb-me-pic {
  position: relative;
  flex: none;
  display: inline-flex;
}

.lb-me-pic::after {
  content: '';
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--dot, var(--good));
  box-shadow: 0 0 0 2.5px var(--panel);
}

.lb-me-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.lb-me-name,
.lb-me-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-me-name {
  font-size: 13.5px;
  font-weight: 600;
}

.lb-me-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.lb-me-status span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-me-caret {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
}

.lb-gear {
  flex: none;
}

.lb-rail-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.lb-rail-me .av-thumb {
  display: block;
}

.lb-chat .chat-tabs .seg-btn {
  min-width: 0;
  padding: 4px 6px;
  gap: 6px;
}

/* Left bar */

.leftbar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 28;
  display: flex;
}

.lb-rail,
.lb-panel {
  background: var(--panel);
  border-right: 1px solid var(--line-2);
}

.lb-rail {
  width: var(--lb-rail);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  overflow-y: auto;
}

.leftbar.collapsed .lb-rail {
  display: flex;
}

.leftbar.collapsed .lb-panel {
  display: none;
}

.lb-panel {
  width: var(--lb-open);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lb-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--line);
}

.lb-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.lb-space,
.lb-room {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-space {
  font-size: 14px;
  font-weight: 650;
}

.lb-room {
  font-size: 12px;
  color: var(--muted);
}

.lb-tabs {
  flex: none;
  display: flex;
  margin: 10px 12px 4px;
}

.lb-tabs .seg-btn {
  flex: 1;
  position: relative;
  justify-content: center;
}

.lb-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lb-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lb-pane[hidden] {
  display: none;
}

.lb-people {
  overflow-y: auto;
  padding-bottom: 12px;
}

.lb-people > .people-panel {
  flex: none;
}

.lb-chat > * {
  flex: 1;
  min-height: 0;
}

.lb-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.lb-tabs .lb-badge {
  margin-left: 4px;
}

.lb-badge[hidden] {
  display: none;
}

/* Conversations */

.lb-convos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 12px 4px;
}

.lb-section {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.lb-empty {
  margin: 2px 0 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.lb-convo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
}

.lb-convo.mine {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2));
  background: color-mix(in srgb, var(--accent) 9%, var(--panel-2));
}

.lb-convo.locked .lb-convo-icon {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
}

.lb-convo-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-convo-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 12.5px;
}

.lb-convo-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.lb-convo-meta b {
  font-size: 13px;
}

.lb-convo-meta small {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-convo-people {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lb-convo-person {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 30%;
}

.lb-convo-person:hover {
  box-shadow: 0 0 0 2px var(--accent);
}

.lb-convo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Rail */

.lb-rail-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.lb-rail-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}

.lb-rail-btn .lb-badge,
.lb-rail-count {
  position: absolute;
  right: -2px;
  bottom: -2px;
}

.lb-rail-count {
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--good);
  color: #0d1a12;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.lb-expand {
  margin-bottom: 6px;
}

.lb-rail-convos {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.lb-rail-convo {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 44px;
  padding: 4px 0;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}

.lb-rail-convo.mine {
  border-color: var(--accent);
}

.lb-rail-n,
.lb-lock {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.lb-rail-convo.locked .lb-lock {
  color: var(--warn);
}

/* Mobile: the left bar becomes a drawer over the world. */

.lb-scrim {
  position: fixed;
  inset: 0;
  z-index: 27;
  background: rgba(8, 10, 20, 0.45);
}

.lb-scrim[hidden] {
  display: none;
}

.leftbar.mobile.collapsed {
  display: none;
}

.leftbar.mobile .lb-panel {
  width: min(88vw, 340px);
  box-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.4));
}

/* Conversation chip in the top bar */

.convo-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 8px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.convo-chip[hidden] {
  display: none;
}

.convo-chip.locked {
  border-color: color-mix(in srgb, var(--warn) 60%, var(--line-2));
}

.convo-chip.locked .convo-text .fa-solid {
  color: var(--warn);
}

.convo-faces {
  display: inline-flex;
}

.convo-faces > * + * {
  margin-left: -6px;
}

.convo-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Floating right window (build, map maker) */

.sidebar {
  top: 68px;
  right: 14px;
  bottom: 88px;
  width: min(var(--side-w), calc(100vw - 28px));
  border: 1px solid var(--line-2);
  border-radius: 16px;
  overflow: hidden;
  transform: translateX(calc(100% + 28px));
}

.sidebar.open {
  transform: none;
}

@media (max-width: 760px) {
  .sidebar {
    top: 60px;
    right: 8px;
    left: 8px;
    bottom: 76px;
    width: auto;
  }

  body.in-app .hud-top {
    left: 12px;
  }

  .convo-text {
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Tile picking */

.pick-chip {
  position: fixed;
  bottom: 84px;
  left: calc(var(--lb-w) + (100vw - var(--lb-w)) / 2);
  transform: translateX(-50%);
  z-index: 26;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line-2));
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.pick-chip[hidden],
.pick-mark[hidden] {
  display: none;
}

.pick-chip .fa-solid {
  color: var(--accent);
}

.pick-mark {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 3px solid var(--good);
  border-radius: 8px;
  background: color-mix(in srgb, var(--good) 22%, transparent);
  pointer-events: none;
}

.pick-mark.bad {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 18%, transparent);
}
