.voice-call-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  pointer-events: none;
}

.voice-call-modal.active {
  display: flex;
  overflow: visible;
}

/* Mobile: fixed at bottom, above composer */
@media (max-width: 67.4375rem) {
  .voice-call-modal {
    position: fixed;
    bottom: var(--footer-height);
    left: 0;
    right: 0;
    z-index: 9999;
    padding-inline: var(--inline-space);
    padding-block-end: 0;
    padding-bottom: calc(var(--block-space-half) + env(safe-area-inset-bottom, 0));
    pointer-events: none;
  }

  .voice-call-modal.active {
    display: flex;
    justify-content: center;
    pointer-events: auto;
    overflow: visible;
  }

  /* Ensure it stays at bottom on mobile */
  .voice-call-modal.active.ringing,
  .voice-call-modal.active.active-state {
    top: auto;
    left: 0;
    right: 0;
    bottom: var(--footer-height);
    transform: none;
  }

  /* Full width content on mobile - horizontal layout */
  .voice-call-modal.active .voice-call-content {
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    align-items: center;
    gap: calc(var(--inline-space) * 0.75); /* Slightly reduced gap */
    padding: calc(var(--block-space) * 0.625) var(--inline-space);
    text-align: left;
    flex-wrap: nowrap; /* Prevent wrapping to avoid overlaps */
    min-width: 0;
    overflow: visible; /* Allow dropdown to escape */
    box-sizing: border-box; /* Ensure padding is included in width */
    background: var(--color-bg); /* Solid background to prevent transparency */
    opacity: 1; /* Ensure full opacity */
  }

  /* Smaller avatar on mobile - horizontal */
  .voice-call-modal.active .voice-call-avatar {
    --avatar-size: 2.5rem;
    margin-block-end: 0;
    flex-shrink: 0;
    flex-basis: 2.5rem; /* Fixed width */
  }

  /* Override the size attribute on the image */
  .voice-call-modal.active .voice-call-avatar img {
    width: var(--avatar-size) !important;
    height: var(--avatar-size) !important;
    display: block;
    border-radius: 50%;
    object-fit: cover;
  }

  /* Info wrapper groups name and status */
  .voice-call-modal.active .voice-call-info {
    flex: 1 1 0%; /* Use percentage-based flex to allow proper shrinking */
    min-width: 0; /* Critical: Allow flex item to shrink below content size */
    max-width: 100%; /* Can take up to full width, but will shrink if needed */
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    justify-content: center;
    overflow: hidden; /* Prevent text overflow */
    position: relative;
    contain: layout style; /* Optimize rendering and prevent layout issues */
  }

  /* Truncate text if needed - ensure no overlaps */
  .voice-call-modal.active .voice-call-name,
  .voice-call-modal.active .voice-call-status,
  .voice-call-modal.active .voice-call-recording {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
    display: block;
    position: relative;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    isolation: isolate; /* Create new stacking context to prevent overlap */
  }

  /* Timer styling on mobile */
  .voice-call-modal.active .voice-call-timer {
    font-size: calc(var(--txt-small) * 0.9);
    line-height: 1.2;
    opacity: 0.7;
  }

  /* Name styling on mobile */
  .voice-call-modal.active .voice-call-name {
    font-size: var(--txt-medium);
    margin-block: 0;
    line-height: 1.2;
    font-weight: 600;
  }

  /* Status styling on mobile */
  .voice-call-modal.active .voice-call-status {
    font-size: var(--txt-small);
    margin-block: 0;
    line-height: 1.2;
    opacity: 0.8;
  }

  .voice-call-modal.active .voice-call-recording {
    justify-content: flex-start;
    margin-block: 0;
  }

  .voice-call-modal.active .voice-call-timer-row {
    justify-content: flex-start;
    align-self: flex-start;
    width: fit-content;
    margin-block: 0;
  }

  .voice-call-modal.active .voice-call-timer {
    width: auto;
  }

  /* Controls on the right - only visible when active (not ringing) */
  .voice-call-modal.active .voice-call-controls {
    margin-block-start: 0;
    flex-shrink: 0;
    flex-basis: content;
    gap: calc(var(--inline-space) * 0.5);
    display: flex;
    align-items: center;
    overflow: visible;
  }

  /* Smaller buttons on mobile */
  .voice-call-modal.active .voice-call-button {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    box-sizing: border-box;
    min-width: 2.5rem;
    max-width: 2.5rem;
  }

  .voice-call-modal.active .voice-call-button svg {
    width: 18px;
    height: 18px;
  }

  .voice-call-modal.active .voice-call-button--hangup {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    max-width: 2.5rem;
  }

  /* Actions (answer/decline) - shown when ringing */
  .voice-call-modal.active .voice-call-actions {
    margin-block-start: 0;
    flex-shrink: 0;
    flex-basis: content;
    gap: calc(var(--inline-space) * 0.5);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
  }

  /* Answer/Decline buttons on mobile - ensure proper spacing and no overflow */
  .voice-call-modal.active .voice-call-button--answer,
  .voice-call-modal.active .voice-call-button--decline {
    padding: calc(var(--inline-space) * 0.5) calc(var(--inline-space) * 0.75);
    white-space: nowrap;
    min-width: 3.5rem;
    width: auto;
    height: 2.5rem;
    flex-shrink: 0;
    text-align: center;
    box-sizing: border-box;
    font-size: var(--txt-small);
    line-height: 1;
  }
}

.transcript-timeline {
  row-gap: 0.75rem;
}

.transcript-timeline .message__avatar {
  box-shadow: none;
  background: transparent;
}

.transcript-loading {
  display: flex;
  justify-content: center;
  padding: 0.75rem 0;
}

.transcript-loading[hidden] {
  display: none;
}

.transcript-load-more-sentinel {
  height: 1px;
}

.transcript-audio-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.transcript-audio-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transcript-audio-section > .message__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.transcript-audio-section + .transcript-audio-section {
  margin-top: 1rem;
}

.transcript-audio-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  border-radius: 0.75rem;
}

.transcript-audio-item .message__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.transcript-audio-player {
  width: 100%;
}

.transcript-audio-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.summary-content {
  white-space: pre-line;
  line-height: 1.45;
  font-size: 1rem;
}

.summary-content.message__markdown {
  max-block-size: none;
  overflow: visible;
  padding: 0.75rem 1rem;
}

.summary-content h1 { font-size: 1.15em; }
.summary-content h2 { font-size: 1.05em; }
.summary-content h3 { font-size: 1em; }
.summary-content h4,
.summary-content h5,
.summary-content h6 { font-size: 0.95em; }

.summary-content code {
  background-color: var(--color-bg);
  border-radius: 0.25em;
  font-size: 0.9em;
  padding: 0.1em 0.35em;
}

.summary-content pre code {
  padding: 0;
}

.summary-content p {
  margin: 0.35rem 0;
}

.summary-content ul,
.summary-content ol {
  margin: 0.35rem 0 0.35rem 1.25rem;
}

/* Desktop: fixed positioning */
@media (min-width: 67.5rem) {
  /* Center the modal when ringing (before answer) */
  .voice-call-modal.active.ringing {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  /* Position in bottom-right corner when active (after answer) */
  .voice-call-modal.active.active-state {
    bottom: calc(var(--block-space) + 8rem); /* Account for composer height */
    right: var(--block-space);
    top: auto;
    left: auto;
    transform: none;
  }
}

.voice-call-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--block-space);
  padding: var(--block-space);
  text-align: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  max-width: 30ch;
  transition: all 0.3s ease;
  box-sizing: border-box;
  overflow: visible; /* Allow dropdown to escape */
}

/* Smaller size when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-content {
    max-width: 20ch;
    padding: calc(var(--block-space) * 0.75);
    gap: calc(var(--block-space) * 0.75);
  }
}

.voice-call-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0; /* Allow flex item to shrink */
  overflow: hidden; /* Prevent content overflow */
  width: 100%; /* Take full width of container */
}

.voice-call-avatar {
  --avatar-size: 12ch;
  margin-block-end: calc(var(--block-space) / 2);
  transition: all 0.3s ease;
}

.voice-call-avatar img {
  width: var(--avatar-size);
  height: var(--avatar-size);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Smaller avatar when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-avatar {
    --avatar-size: 8ch;
    margin-block-end: calc(var(--block-space) / 3);
  }
}

.voice-call-name {
  font-size: var(--txt-large);
  font-weight: 600;
  margin-block-end: calc(var(--block-space) / 2);
  transition: all 0.3s ease;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Smaller name when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-name {
    font-size: var(--txt-medium);
    margin-block-end: calc(var(--block-space) / 3);
  }
}

.voice-call-status {
  font-size: var(--txt-medium);
  color: var(--color-text-secondary);
  margin-block-end: 0.25rem;
  transition: all 0.3s ease;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-call-timer-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  width: fit-content;
  align-self: center;
  margin-block-end: var(--block-space);
}

.voice-call-timer-row .voice-call-recording {
  width: auto;
  min-height: 0;
}

.voice-call-timer-row .voice-call-timer {
  width: auto;
  max-width: none;
  display: inline-block;
}

.voice-call-recording {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0;
  color: var(--color-negative);
  margin-block-end: 0.2rem;
  width: 100%;
  min-height: 0.6rem;
  cursor: pointer;
}

.voice-call-recording__dot {
  display: block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--color-border-darker);
  box-shadow: none;
  flex: 0 0 auto;
}

.voice-call-recording.is-recording .voice-call-recording__dot {
  background: var(--color-negative);
  border-color: rgba(220, 38, 38, 0.85);
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.65), 0 0 8px rgba(220, 38, 38, 0.55);
  animation: voice-call-recording-pulse 1.2s infinite ease-in-out;
}

.voice-call-timer {
  font-size: var(--txt-small);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
  line-height: 1;
}

/* Smaller status when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-status {
    font-size: var(--txt-small);
    margin-block-end: 0.125rem;
  }

  .voice-call-modal.active.active-state .voice-call-recording {
    margin-block-end: 0.2rem;
  }

  .voice-call-modal.active.active-state .voice-call-timer {
    font-size: calc(var(--txt-small) * 0.9);
    margin-block-end: calc(var(--block-space) * 0.5);
  }

  .voice-call-modal.active.active-state .voice-call-timer-row {
    margin-block-end: calc(var(--block-space) * 0.5);
  }
}

@keyframes voice-call-recording-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7), 0 0 8px rgba(220, 38, 38, 0.6);
    opacity: 1;
  }
  70% {
    box-shadow: 0 0 0 0.6rem rgba(220, 38, 38, 0), 0 0 12px rgba(220, 38, 38, 0);
    opacity: 0.65;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0), 0 0 8px rgba(220, 38, 38, 0);
    opacity: 1;
  }
}

.voice-call-controls {
  display: flex;
  gap: var(--inline-space);
  align-items: center;
  margin-block-start: var(--block-space);
  transition: all 0.3s ease;
  overflow: visible;
}

/* Smaller controls when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-controls {
    margin-block-start: calc(var(--block-space) * 0.5);
    gap: calc(var(--inline-space) * 0.75);
  }
}

.voice-call-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4ch;
  height: 4ch;
  border-radius: 50%;
  border: none;
  background: var(--color-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Smaller buttons when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-button {
    width: 3.5ch;
    height: 3.5ch;
  }

  .voice-call-modal.active.active-state .voice-call-button svg {
    width: 20px;
    height: 20px;
  }
}

.voice-call-button:hover {
  background: var(--color-border-darker);
}

.voice-call-button--mute {
  background: var(--color-border);
}

.voice-call-button--mute.muted {
  background: var(--color-negative);
  color: white;
}

.voice-call-button--mute.muted .mic-icon {
  opacity: 0.5;
}

.voice-call-button--mute.muted .mute-indicator {
  display: block !important;
}

.voice-call-button--hangup {
  background: #dc2626;
  color: white;
  width: 5ch;
  height: 5ch;
  box-sizing: border-box;
  flex-shrink: 0; /* Prevent button from shrinking */
}

/* Smaller hangup button when active (in corner) - desktop only */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-button--hangup {
    width: 4ch;
    height: 4ch;
  }
}

.voice-call-button--hangup:hover {
  background: #b91c1c;
}

.voice-call-actions {
  display: flex;
  gap: var(--inline-space);
  margin-block-start: var(--block-space);
}

.voice-call-button--answer {
  background: #22c55e;
  color: white;
  padding: var(--inline-space) calc(var(--inline-space) * 2);
  border-radius: var(--border-radius);
  width: auto;
  height: auto;
}

.voice-call-button--answer:hover {
  background: #16a34a;
}

.voice-call-button--decline {
  background: #dc2626;
  color: white;
  padding: var(--inline-space) calc(var(--inline-space) * 2);
  border-radius: var(--border-radius);
  width: auto;
  height: auto;
}

.voice-call-button--decline:hover {
  background: #b91c1c;
}

/* Mic Group - groups mute button and switcher together */
.voice-call-mic-group {
  display: flex;
  align-items: center;
  position: relative;
  gap: 0.25rem;
}

/* Keep mute button circular in mic group */
.voice-call-mic-group .voice-call-button--mute {
  border-radius: 50%;
}

/* Mic Switcher Button - small pill next to mute */
.voice-call-button--mic-switcher {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-border);
  opacity: 0.8;
}

.voice-call-button--mic-switcher:hover {
  background: var(--color-border-darker);
  opacity: 1;
}

.voice-call-button--mic-switcher svg {
  width: 10px;
  height: 10px;
}

/* Mic Dropdown - fixed positioning to escape all containers */
.voice-call-mic-dropdown {
  position: fixed;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  min-width: 220px;
  max-width: 280px;
  z-index: 10002;
}

.voice-call-mic-dropdown-header {
  padding: 0.625rem 0.875rem;
  font-size: var(--txt-small);
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.voice-call-mic-dropdown-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.voice-call-mic-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: var(--txt-small);
  color: var(--color-text);
  transition: background 0.15s ease;
}

.voice-call-mic-option:hover {
  background: var(--color-bg-secondary);
}

.voice-call-mic-option--selected {
  background: var(--color-bg-secondary);
}.voice-call-mic-option--empty {
  color: var(--color-text-secondary);
  cursor: default;
  font-style: italic;
}

.voice-call-mic-option--empty:hover {
  background: transparent;
}

.voice-call-mic-option-check {
  flex-shrink: 0;
  width: 16px;
  color: var(--color-positive, #22c55e);
}

.voice-call-mic-option-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile adjustments for mic group */
@media (max-width: 67.4375rem) {
  .voice-call-modal.active .voice-call-button--mic-switcher {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
  }

  .voice-call-button--mic-switcher svg {
    width: 8px;
    height: 8px;
  }

  .voice-call-mic-dropdown {
    min-width: 200px;
    max-width: calc(100vw - 32px);
  }
}

/* Desktop active state adjustments */
@media (min-width: 67.5rem) {
  .voice-call-modal.active.active-state .voice-call-button--mic-switcher {
    width: 1.25rem;
    height: 1.25rem;
  }  .voice-call-modal.active.active-state .voice-call-button--mic-switcher svg {
    width: 8px;
    height: 8px;
  }
}
