/* Phase Chat shell — matches Concordia window / HUD chrome */

.chat-cluster { gap: 6px; }

#btn-bubbles.bubbles-off {
  opacity: 0.55;
  text-decoration: line-through;
}

#win-chat {
  display: flex;
  flex-direction: column;
}
#win-chat.hidden { display: none; }

.chat-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line, #3a4654);
  background: #12161c;
  flex-shrink: 0;
}
.chat-tab {
  flex: 1;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted, #8b97a5);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.chat-tab:hover { color: var(--ink, #e8eef4); }
.chat-tab.active {
  color: var(--cyan, #3ec6d8);
  border-bottom-color: var(--cyan, #3ec6d8);
}

#win-chat .chat-body {
  padding: 8px 10px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-log {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.chat-empty { margin: 8px 0; }
.chat-line { word-break: break-word; }
.chat-from {
  color: var(--gold, #c4a35a);
  font-weight: 600;
}
.chat-text { color: var(--ink, #e8eef4); }

.chat-compose {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line, #3a4654);
  background: #12161c;
  flex-shrink: 0;
  position: relative;
}
#chat-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line, #3a4654);
  background: var(--panel-2, #1a2028);
  color: var(--ink, #e8eef4);
  font: inherit;
  font-size: 14px;
  border-radius: 2px;
}
#chat-input:focus {
  outline: 1px solid var(--cyan, #3ec6d8);
  outline-offset: 0;
}
#chat-send {
  flex-shrink: 0;
}

.chat-speech-bubble {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  max-width: min(220px, 50vw);
  padding: 6px 10px;
  background: rgba(18, 22, 28, 0.92);
  border: 1px solid #3a4654;
  border-radius: 10px;
  color: var(--ink, #e8eef4);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: rgba(18, 22, 28, 0.92);
  border-right: 1px solid #3a4654;
  border-bottom: 1px solid #3a4654;
  transform: translateX(-50%) rotate(45deg);
}
.chat-speech-bubble.hidden { display: none; }

#chat-hud-fallback {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40;
  display: flex;
  gap: 6px;
}

/* Mobile chat vs flickable HUD drawer (deck-drawer).
   Keep the window clear of the bottom tray; do not raise z above the handle. */
:root {
  --chat-deck-clear: calc(var(--deck-handle-h, 28px) + env(safe-area-inset-bottom, 0px) + 10px);
  --chat-deck-clear-expanded: calc(108px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 720px) {
  /* Full-screen sheet on narrow (html.popup-sheet owns the real layout in admin.css).
     Keep these as fallback if sheet class not yet applied. */
  #win-chat {
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    max-height: none !important;
    min-height: 0;
    border-radius: 0;
  }

  /* Bubbles above joystick (z=4), still under drawer chrome (z=12) */
  .chat-speech-bubble {
    z-index: 5;
    max-width: min(200px, 46vw);
  }
}

/* AIs tab — watcher lines + listen-only compose */
.chat-line-ai .chat-from-ai {
  color: #6a7a8c;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.chat-line-ai .chat-text {
  color: #b7c2ce;
}
.chat-compose.chat-listen-only {
  opacity: 0.72;
}
.chat-compose.chat-listen-only #chat-input:disabled {
  cursor: default;
  color: var(--muted, #8b97a5);
  background: #141920;
}
.chat-compose.chat-listen-only #chat-send:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}


/* Online roster tab */
.online-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.online-toolbar.hidden { display: none; }
#online-search {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line, #3a4654);
  border-radius: 6px;
  background: #0c0e11;
  color: var(--ink, #e8eef4);
  font: inherit;
  font-size: 12px;
}
.online-summary {
  font-size: 11px;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.online-group-title {
  margin-top: 8px;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan, #3ec6d8);
}
.online-row {
  font-size: 13px;
  line-height: 1.35;
  padding: 2px 0;
}
.online-name { color: var(--ink, #e8eef4); font-weight: 600; }
.online-handle { font-size: 12px; }
.online-where { font-size: 12px; }
.online-ai .online-name { color: var(--gold, #c4a35a); }
.online-ai-link {
  margin-left: 6px;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--cyan, #3ec6d8);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.online-more { font-size: 12px; margin: 2px 0 0; }

/* Four tabs: slightly tighter */
#win-chat .chat-tab {
  padding: 8px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
}


#chat-emoji-btn {
  flex-shrink: 0;
  min-width: 36px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 16px;
  line-height: 1;
}
.chat-compose.chat-listen-only #chat-emoji-btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.chat-emoji-popup {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 6px);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  width: min(176px, calc(100% - 16px));
  background: #12161c;
  border: 1px solid var(--line, #3a4654);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.chat-emoji-popup.hidden { display: none; }
.chat-emoji-pick {
  appearance: none;
  border: 0;
  background: transparent;
  min-width: 36px;
  min-height: 36px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}
.chat-emoji-pick:hover,
.chat-emoji-pick:focus {
  background: rgba(62, 198, 216, 0.15);
  outline: none;
}

@media (max-width: 720px) {
  .chat-emoji-popup {
    width: min(168px, calc(100% - 16px));
    left: 8px;
    right: auto;
  }
  #chat-emoji-btn {
    min-width: 34px;
    padding-left: 6px;
    padding-right: 6px;
  }
}


/* Party voice HUD stub (Phase A — no WebRTC media) */
.party-voice-strip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
}
.party-voice-strip.hidden { display: none; }
.party-act {
  font-size: 11px;
  letter-spacing: 0.04em;
  padding-left: 8px;
  padding-right: 8px;
}
#btn-party-mic.muted {
  opacity: 0.65;
}
#btn-party[aria-pressed="true"] {
  color: var(--cyan, #3ec6d8);
}

.online-join-sounds {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  font-size: 11px;
  color: var(--dim, #9a958c);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.online-join-sounds input {
  margin: 0;
  accent-color: #6bcf7f;
}


/* Moderation affordances on Online roster — mod1 */
.online-mod-acts {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.online-mod-btn {
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(232, 136, 136, 0.45);
  background: rgba(80, 24, 24, 0.45);
  color: #f0c0c0;
  cursor: pointer;
}
.online-mod-btn:hover,
.online-mod-btn:focus-visible {
  border-color: rgba(232, 136, 136, 0.8);
  background: rgba(120, 32, 32, 0.55);
  color: #fff;
}

/* Living AI Stage C — AI Broadcast board */
.bc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.bc-toolbar-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.bc-refresh {
  min-width: 32px;
  padding: 4px 8px;
}
.bc-exchange {
  border: 1px solid var(--line, #3a4654);
  background: #151a21;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
}
.bc-ex-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.bc-event {
  color: var(--cyan, #3ec6d8);
  font-size: 12px;
  line-height: 1.35;
}
.bc-meta {
  font-size: 11px;
}
.bc-turn {
  position: relative;
  padding-right: 4px;
}
.bc-speaker {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.bc-speaker:hover {
  color: var(--cyan, #3ec6d8);
  text-decoration: underline;
}
.bc-turn-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.bc-act {
  border: 1px solid var(--line, #3a4654);
  background: #1a2028;
  color: var(--muted, #8b97a5);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  cursor: pointer;
}
.bc-act:hover {
  color: var(--ink, #e8eef4);
  border-color: var(--cyan, #3ec6d8);
}
.bc-local-band {
  margin: 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.bc-label { font-size: 11px; }
.bc-muted-bar { margin-top: 8px; font-size: 12px; }

.chat-broadcast-write {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line, #3a4654);
  background: #12161c;
  flex-shrink: 0;
}
.chat-broadcast-write.hidden { display: none; }
.bc-write-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--cyan, #3ec6d8);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#bc-write-subject,
#bc-write-body {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line, #3a4654);
  background: var(--panel-2, #1a2028);
  color: var(--ink, #e8eef4);
  font: inherit;
  font-size: 13px;
  border-radius: 2px;
  padding: 6px 8px;
}
#bc-write-body { resize: vertical; min-height: 64px; }
.bc-write-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bc-write-hint { font-size: 11px; }
.chat-compose.hidden { display: none; }

/* Living AI Stage D — accountable room link on Broadcast */
.bc-room-strip {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.4;
}
.bc-room-link {
  color: #3ec6d8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bc-room-link:hover,
.bc-room-link:focus-visible {
  color: #7fe0ec;
}


/* Party text tab — visible only while in party */
#chat-tab-party.hidden,
.chat-tab.hidden { display: none !important; }


/* Party unread + voice honesty · partyux1 */
#btn-chat {
  position: relative;
}
#btn-chat .chat-unread-badge,
.chat-tab .chat-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 4px;
  border-radius: 999px;
  background: #c45a5a;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
#btn-chat .chat-unread-badge[hidden],
.chat-tab .chat-unread-badge[hidden] {
  display: none !important;
}
#btn-chat.has-party-unread {
  box-shadow: 0 0 0 1px rgba(196, 90, 90, 0.55);
}
.chat-tab.has-party-unread {
  color: var(--cyan, #3ec6d8);
}
.party-voice-soon {
  font-size: 10px;
  letter-spacing: 0.03em;
  padding: 0 6px;
  color: var(--dim, #9a958c);
  white-space: nowrap;
  user-select: none;
}
.party-voice-soon.hidden { display: none !important; }
#btn-party-mic.hidden { display: none !important; }


/* —— voicespaces1 Room Spaces shell (provider-agnostic) —— */
/* voicespaces1 flex shell */
#win-chat {
  width: 380px;
  height: 440px;
  display: flex;
  flex-direction: column;
}
#win-chat .win-body.chat-body,
#win-chat .chat-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#win-chat .chat-log {
  flex: 1 1 auto;
  min-height: 0;
}
.chat-room-space {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(22, 28, 36, 0.96), rgba(16, 20, 26, 0.92));
}
.chat-room-space[hidden] { display: none !important; }
.crs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.crs-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.crs-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #9a958c);
  font-weight: 700;
}
.crs-provider {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(62, 198, 216, 0.35);
  color: var(--cyan, #3ec6d8);
  background: rgba(62, 198, 216, 0.08);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.crs-provider[data-provider="livekit"] {
  border-color: rgba(232, 197, 106, 0.45);
  color: var(--gold, #e8c56a);
  background: rgba(232, 197, 106, 0.08);
}
.crs-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}
.crs-btn {
  font-size: 11px !important;
  padding: 5px 9px !important;
  min-height: 0;
  line-height: 1.2;
}
.crs-btn.primary {
  border-color: rgba(62, 198, 216, 0.55) !important;
  color: #c8f4fa !important;
}
.crs-btn.live {
  border-color: rgba(100, 200, 140, 0.55) !important;
  color: #c8f0d0 !important;
}
.crs-btn.danger {
  border-color: rgba(232, 136, 136, 0.45) !important;
  color: #f0c0c0 !important;
}
.crs-section { margin-top: 6px; }
.crs-section-label {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted, #9a958c);
  margin-bottom: 6px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.crs-speaker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 6px;
}
.crs-speaker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 4px 2px;
  border-radius: 8px;
}
.crs-speaker.self {
  background: rgba(196, 163, 90, 0.08);
}
.crs-speaker.speaking .crs-av {
  box-shadow: 0 0 0 2px rgba(62, 198, 216, 0.65), 0 0 12px rgba(62, 198, 216, 0.3);
}
.crs-speaker.empty { opacity: 0.4; }
.crs-av {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #24303a;
  color: var(--cyan, #3ec6d8);
  font-size: 10px;
  font-weight: 700;
  overflow: hidden;
  position: relative;
}
.crs-av-lg {
  width: 44px;
  height: 44px;
  font-size: 13px;
}
.crs-av.has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.crs-av.empty-slot {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: transparent;
  color: var(--muted, #9a958c);
  font-weight: 500;
}
.crs-eq {
  position: absolute;
  right: -1px;
  bottom: -1px;
  background: rgba(14, 17, 22, 0.9);
  border-radius: 4px;
  padding: 2px 3px;
  color: var(--cyan, #3ec6d8);
  height: 11px;
}
.crs-mic-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  line-height: 1;
  filter: grayscale(0.4);
  opacity: 0.85;
}
.crs-mic-badge.on {
  filter: none;
  opacity: 1;
}
.crs-speaker-name {
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: var(--ink, #e8eef4);
}
.crs-listener-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 72px;
  overflow: auto;
}
.crs-listener {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-width: 120px;
}
.crs-listener.self {
  border-color: rgba(196, 163, 90, 0.35);
}
.crs-listener-name {
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crs-listeners-empty {
  font-size: 11px;
  padding: 2px 0;
}
.chat-room-space.crs-idle .crs-body {
  opacity: 0.92;
}
