:root {
  --ink: #0a0f1c;
  --panel: #121a2e;
  --hairline: #23304f;
  --text: #e6ebf7;
  --muted: #8896b8;
  --accent: #f2a65a;
  --live: #6fd1a6;
  --away: #e2b93b;
  --busy: #e2705f;
  --dnd: #d64545;
  --danger: #e2705f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
}

/* Navbar ------------------------------------------------------------------- */

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  gap: 16px;
}

.navbar__title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.navbar__btn {
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #182241;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease;
  white-space: nowrap;
}

.navbar__btn:hover:not(:disabled) { background: #1f2b52; }
.navbar__btn:disabled { opacity: 0.45; cursor: not-allowed; }
.navbar__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.navbar__btn--stop {
  background: var(--danger);
  border-color: var(--danger);
}

.navbar__btn--stop:hover:not(:disabled) {
  background: #f39081;
}

.navbar__controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.navbar__indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1s infinite;
}

.navbar__badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}

.navbar__badge[hidden] {
  display: none;
}

.navbar__stats {
  display: flex;
  gap: 24px;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.navbar__stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.navbar__stat-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.navbar__stat-value {
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  flex: 1;
  min-height: 0;
  padding: 16px;
  margin-left: 32px;
  transition: margin-left 0.3s ease;
}

.contacts-sidebar.expanded ~ .stage {
  margin-left: 240px;
}

/* Video ------------------------------------------------------------------- */

.videos {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.tiles {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 8px;
}

.tiles[data-count="0"] {
  display: grid;
  place-content: center;
}

.tiles[data-count="1"] {
  grid-template-columns: 1fr;
}

.tiles[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}

.tiles[data-count="3"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.tiles[data-count="3"] .tile:nth-child(3) {
  grid-column: 1 / -1;
}

.tiles[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.tile {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #060a13;
  border: 1px solid var(--hairline);
}

.tile--remote {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile--local {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 26%;
  min-width: 150px;
  aspect-ratio: 16 / 9;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  z-index: 10;
  transition: width 300ms ease, height 300ms ease, right 300ms ease, bottom 300ms ease;
}

/* For group calls (2+ remote peers = 3+ total people), make local video smaller */
.videos[data-call-type="group"] .tile--local {
  width: 18%;
  min-width: 120px;
  right: 12px;
  bottom: 12px;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tile--remote video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.tile--local video { transform: scaleX(-1); }

.tile__play-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: rgb(6 10 19 / 0.85);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  cursor: pointer;
}

.tile__play-prompt:hover {
  background: rgb(6 10 19 / 0.95);
}

.tile__label {
  position: absolute;
  left: 10px;
  bottom: 8px;
  margin: 0;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgb(6 10 19 / 0.7);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.tile__state-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--hairline);
  z-index: 20;
  color: var(--text);
}

.tile__state-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.tile__state-badge[data-state='connecting']::before {
  background: var(--accent);
  animation: pulse 1s infinite;
}

.tile__state-badge[data-state='connected']::before {
  background: var(--live);
}

.tile__state-badge[data-state='failed']::before {
  background: var(--danger);
}

.tile__state-badge[data-state='disconnected']::before {
  background: var(--muted);
}

.waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  padding: 24px;
}

.waiting__title { margin: 0; font-size: 20px; font-weight: 500; }
.waiting__hint { margin: 0; color: var(--muted); font-size: 14px; }

/* Panel ------------------------------------------------------------------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.panel__title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.join { display: flex; flex-direction: column; gap: 8px; }

.join__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #0d1424;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
}

.join__input:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.controls { display: flex; flex-direction: column; gap: 8px; }

.btn {
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #182241;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease;
}

.btn:hover:not(:disabled) { background: #1f2b52; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #21160a;
  font-weight: 500;
}

.btn--primary:hover:not(:disabled) { background: #f7b978; }

.btn--danger { color: var(--danger); }

/* File transfer ------------------------------------------------------------ */

.file-transfer {
  padding: 12px;
  background: #1a2844;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-transfer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.file-transfer__name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-transfer__cancel {
  padding: 4px 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: color 120ms ease;
}

.file-transfer__cancel:hover {
  color: var(--danger);
}

.file-transfer__bar-container {
  width: 100%;
  height: 8px;
  background: #0f1824;
  border-radius: 4px;
  overflow: hidden;
}

.file-transfer__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffc670);
  border-radius: 4px;
  width: 0%;
  transition: width 100ms ease;
}

.file-transfer__info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

/* Connection readout ------------------------------------------------------ */

.readout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.readout__title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.readout__grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.readout__grid dt { color: var(--muted); }
.readout__grid dd { margin: 0; text-align: right; color: var(--text); }

.readout__grid dd[data-value='connected'],
.readout__grid dd[data-value='complete'],
.readout__grid dd[data-value='stable'] { color: var(--live); }

.readout__grid dd[data-value='failed'],
.readout__grid dd[data-value='disconnected'] { color: var(--danger); }

.readout__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.roster {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.roster__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: #0d1424;
  border-radius: 4px;
  font-size: 12px;
  border-left: 3px solid var(--muted);
  transition: all 200ms ease;
  gap: 8px;
}

.roster__item--connecting {
  border-left-color: var(--accent);
  background: rgba(242, 166, 90, 0.08);
}

.roster__item--connected {
  border-left-color: var(--live);
  background: rgba(111, 209, 166, 0.08);
}

.roster__item--failed {
  border-left-color: var(--danger);
  background: rgba(226, 112, 95, 0.08);
}

.roster__item--disconnected {
  opacity: 0.6;
  background: #0a0f1c;
}

.roster__name {
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster__state {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.roster__stat {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.readout__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: #0d1424;
  border-radius: 4px;
  color: var(--text);
}

/* Chat -------------------------------------------------------------------- */

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.chat__title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 80px;
  padding: 8px 0;
}

.chat__message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
}

.chat__message--local {
  background: #1f2b52;
  margin-left: 12px;
  align-self: flex-end;
  max-width: 85%;
}

.chat__message--remote {
  background: #182241;
  margin-right: 12px;
  align-self: flex-start;
  max-width: 85%;
}

.chat__sender {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat__text {
  color: var(--text);
  word-wrap: break-word;
}

.chat__time {
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
}

.chat__input-group {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.chat__input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #0d1424;
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 14px;
}

.chat__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat__input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat__send-btn {
  padding: 8px 12px;
  font-size: 14px;
  min-width: 60px;
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .tile--remote { height: 100%; }
}

/* Modal ------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: 'Space Grotesk', system-ui, sans-serif;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(2px);
}

.modal__content {
  position: relative;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.8);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--hairline);
}

.modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.modal__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease;
}

.modal__close:hover { color: var(--text); }

.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal__footer {
  display: flex;
  gap: 10px;
  padding: 18px;
  border-top: 1px solid var(--hairline);
  justify-content: flex-end;
}

.modal__footer .btn { flex: 1; }

/* Settings ----------------------------------------------------------------- */

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-section__title {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.settings-select,
.settings-slider {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #0d1424;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.settings-select:focus-visible,
.settings-slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-slider {
  padding: 8px 12px;
  cursor: pointer;
  height: 36px;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: background 120ms ease;
}

.settings-slider::-webkit-slider-thumb:hover {
  background: #f7b978;
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: background 120ms ease;
}

.settings-slider::-moz-range-thumb:hover {
  background: #f7b978;
}

.settings-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
}

.settings-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Test Call ----------------------------------------------------------------- */

.test-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.test-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.test-section h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.test-video {
  width: 100%;
  height: 200px;
  background: #0d1424;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  object-fit: cover;
}

.test-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #0d1424;
  border: 1px solid var(--hairline);
  border-radius: 8px;
}

.test-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

.test-stat span:last-child {
  color: var(--live);
  font-weight: 500;
}

.test-section-hint {
  margin: 8px 0 0 0;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.test-info {
  padding: 12px;
  background: #0d1424;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.test-info p {
  margin: 0;
}

.test-info strong {
  color: var(--text);
}

.settings-slider::-webkit-slider-runnable-track {
  background: linear-gradient(to right,
    var(--accent) 0%,
    var(--accent) var(--value, 0%),
    #1f2b52 var(--value, 0%),
    #1f2b52 100%);
  height: 6px;
  border-radius: 3px;
  border: none;
}

.settings-slider::-moz-range-track {
  background: #1f2b52;
  height: 6px;
  border-radius: 3px;
  border: none;
}

.settings-slider::-moz-range-progress {
  background: var(--accent);
  height: 6px;
  border-radius: 3px;
}

.settings-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Contacts Modal ---------------------------------------------------------- */

.modal__content--large {
  max-width: 90vw;
  width: 1200px;
  max-height: 85vh;
}

.contacts-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  overflow: hidden;
  max-height: 624px;
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 8px;
}

.contacts-list__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.contacts-list__title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.contacts-list__items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-item {
  padding: 12px;
  background: #0d1424;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.contact-item:hover {
  background: #121f38;
  border-color: var(--accent);
}

.contact-item.active {
  background: #1a2a48;
  border-color: var(--accent);
}

.contact-item__name {
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px 0;
  font-size: 14px;
}

.contact-item__email {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: #0d1424;
  border: 1px solid var(--hairline);
  border-radius: 8px;
}

.contact-form__title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.contact-form__fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #060a13;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 120ms ease;
}

.form-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(242, 166, 90, 0.2);
}

.contact-form__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.btn--small {
  padding: 6px 12px;
  font-size: 12px;
}

.dm-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: #0d1424;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  min-height: 0;
}

.dm-thread__header {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
}

.dm-thread__messages {
  flex: 1;
  min-height: 200px;
}

/* Wider bubbles than the compact in-call sidebar chat: each message fills
   the row except for a fixed 64px gap, kept on the side facing the sender
   (left of a sent message, right of a received one) via align-self. */
.dm-thread__messages .chat__message {
  width: calc(100% - 64px);
  max-width: calc(100% - 64px);
}

.dm-thread__messages .chat__message--local {
  margin-left: 0;
  background: #3d5aa8;
}

.dm-thread__messages .chat__message--remote {
  margin-right: 0;
  background: #2a2438;
}

.captions-row {
  display: flex;
  justify-content: center;
  padding: 10px 16px 0;
}

.captions-row[hidden] {
  display: none;
}

.captions-overlay {
  max-width: min(80%, 800px);
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(10, 15, 28, 0.8);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
}

.captions-overlay__line {
  margin: 2px 0;
}

.captions-overlay__line--interim {
  color: var(--muted);
  font-style: italic;
}

.conversation-item__preview {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Scrollbar styling */
.contacts-list::-webkit-scrollbar {
  width: 6px;
}

.contacts-list::-webkit-scrollbar-track {
  background: transparent;
}

.contacts-list::-webkit-scrollbar-thumb {
  background: var(--hairline);
  border-radius: 3px;
}

.contacts-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

@media (max-width: 1024px) {
  .contacts-layout {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Contacts Sidebar */
.contacts-sidebar {
  position: fixed;
  left: 0;
  top: 60px;
  height: calc(100vh - 60px);
  width: 32px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--hairline);
  z-index: 100;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.contacts-sidebar.expanded {
  width: 240px;
}

.sidebar__toggle {
  width: 32px;
  height: 32px;
  margin-top: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.sidebar__toggle:hover {
  background: var(--hairline);
}

.sidebar__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  opacity: 0;
  width: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
  padding: 0;
}

.contacts-sidebar.expanded .sidebar__content {
  opacity: 1;
  width: 208px;
  padding: 12px;
}

.sidebar__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
  padding: 0;
}

/* Make Groups title more prominent */
.sidebar__content > div:first-child .sidebar__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px 0;
}

.sidebar__contacts-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar__contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-height: 32px;
}

/* Group items in the Groups section */
#sidebarGroupsList .sidebar__contact-item {
  padding: 8px 10px;
  min-height: 32px;
  background: linear-gradient(135deg, #1f2b52 0%, #182241 100%);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  margin-bottom: 4px;
  font-weight: 500;
}

#sidebarGroupsList .sidebar__contact-item:hover {
  background: linear-gradient(135deg, #2a3a62 0%, #1f3051 100%);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(242, 166, 90, 0.2);
}

#sidebarGroupsList .sidebar__contact-item.online {
  border-color: var(--live);
  box-shadow: 0 0 8px rgba(111, 209, 166, 0.3);
}

#sidebarGroupsList .sidebar__contact-name {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

.sidebar__contact-item:hover {
  background: var(--bg-focus);
}

.sidebar__status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.sidebar__contact-item.online .sidebar__status-dot {
  background: #51cf66;
  box-shadow: 0 0 4px rgba(81, 207, 102, 0.6);
}

.sidebar__contact-item.status-away .sidebar__status-dot {
  background: var(--away);
  box-shadow: 0 0 4px rgba(226, 185, 59, 0.6);
}

.sidebar__contact-item.status-busy .sidebar__status-dot {
  background: var(--busy);
  box-shadow: 0 0 4px rgba(226, 112, 95, 0.6);
}

.sidebar__contact-item.status-dnd .sidebar__status-dot {
  background: var(--dnd);
  box-shadow: 0 0 4px rgba(214, 69, 69, 0.6);
}

/* Larger, more visible status dot for groups with active meetings */
#sidebarGroupsList .sidebar__status-dot {
  width: 12px;
  height: 12px;
  animation: pulse 2s infinite;
}

#sidebarGroupsList .sidebar__status-dot[style*="background: var(--live)"] {
  background: var(--live) !important;
  box-shadow: 0 0 8px rgba(111, 209, 166, 0.8);
}

.sidebar__contact-name {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar__contact-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.sidebar__contact-item:hover .sidebar__contact-remove {
  opacity: 1;
}

.sidebar__contact-remove:hover {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.15);
}

.sidebar__contacts-list::-webkit-scrollbar {
  width: 4px;
}

.sidebar__contacts-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar__contacts-list::-webkit-scrollbar-thumb {
  background: var(--hairline);
  border-radius: 2px;
}

.sidebar__contacts-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Sidebar Chat */
.sidebar__chat {
  border-top: 1px solid var(--hairline);
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 8px;
}

.sidebar__chat-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  padding: 0;
}

.sidebar__chat-messages {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
}

.sidebar__chat-messages::-webkit-scrollbar {
  width: 3px;
}

.sidebar__chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar__chat-messages::-webkit-scrollbar-thumb {
  background: var(--hairline);
  border-radius: 2px;
}

.sidebar__chat-input-group {
  display: flex;
  gap: 4px;
}

.sidebar__chat-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
}

.sidebar__chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar__chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sidebar__chat-send-btn {
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.context-menu[hidden] {
  display: none;
}

.context-menu__item {
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.context-menu__item:hover:not(:disabled) {
  background: var(--bg-focus);
}

.context-menu__item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Meeting Invite Toast Stack */
.invite-stack {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  pointer-events: none;
}

.invite-toast {
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
  border: 2px solid #6ab7ff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(74, 144, 226, 0.4), 0 0 20px rgba(74, 144, 226, 0.2);
  pointer-events: auto;
  animation: slideInRight 0.3s ease, pulse 2s ease-in-out infinite;
  color: white;
}

.invite-toast--info {
  background: rgba(30, 30, 40, 0.95);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideInRight 0.3s ease;
}

.invite-toast__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-toast__header {
  font-size: 13px;
  font-weight: 600;
  color: white;
}

.invite-toast__group {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'JetBrains Mono', monospace;
}

.invite-toast__actions {
  display: flex;
  gap: 6px;
}

.invite-btn-join,
.invite-btn-dismiss {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  font-weight: 500;
}

.invite-btn-join {
  background: white;
  border-color: white;
  color: #4a90e2;
  font-weight: 600;
}

.invite-btn-join:hover {
  background: rgba(255, 255, 255, 0.9);
}

.invite-btn-dismiss:hover {
  background: rgba(255, 255, 255, 0.3);
}

.invite-btn-join:hover {
  background: #f7b978;
}

.invite-btn-dismiss:hover {
  background: #1f2b52;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Group Form Styling */
.group-form__members {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.group-form__member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #0d1424;
  border-radius: 6px;
  font-size: 12px;
}

.group-form__member-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}

.group-form__counter {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  padding: 6px 8px;
  background: #0d1424;
  border-radius: 4px;
}

/* Right panel toggle */
.panel {
  position: relative;
  transition: width 300ms ease;
}

.panel {
  position: relative;
  transition: width 300ms ease;
  overflow: visible;
}

.panel__toggle {
  /* Positioned relative to .stage (not .panel) so it stays put and
     clickable even while the panel is translated off-screen when
     collapsed. */
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 100;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.panel__toggle:hover {
  background: var(--hairline);
}

.panel__content {
  display: flex;
  flex-direction: column;
  padding-top: 44px;
  transition: opacity 300ms ease;
}

/* Collapsed state */
.panel.collapsed {
  transform: translateX(100%);
}

.panel.collapsed .panel__content {
  opacity: 0;
  pointer-events: none;
  display: none;
}
