/* Attachment hub, recording dialog, and persisted room cards. */
.capability-menu, .capability-panel {
  color: var(--text-primary); background: var(--surface, #152235);
  border: 1px solid var(--border, #334155); border-radius: 16px;
  box-shadow: 0 16px 48px #0006; padding: 12px;
}
.capability-menu { position: fixed; z-index: 1100; width: 252px; max-width: calc(100% - 16px); max-height: calc(100dvh - 24px); overflow-y: auto; }
.capability-menu[hidden], .capability-error[hidden] { display: none; }
.capability-button {
  min-height: 44px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: inherit;
  font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.capability-button:hover { background: #ffffff0c; }
.capability-button:focus-visible { outline: 2px solid var(--accent, #55cce6); outline-offset: 2px; }
.capability-button:disabled { opacity: .55; cursor: wait; }
.capability-menu .capability-button { display: flex; align-items: center; gap: 12px; width: 100%; }
.capability-menu svg { width: 22px; height: 22px; flex-shrink: 0; }
.capability-menu hr { border: 0; border-top: 1px solid #ffffff20; margin: 8px 0; }
.capability-modal { position: fixed; inset: 0; z-index: 1200; background: #0009; display: grid; place-items: center; padding: 12px; }
.capability-panel { width: min(440px, 100%); max-height: calc(100dvh - 24px); overflow: auto; padding: 24px; }
.capability-panel h2 { margin: 0 0 16px; font-size: 2rem; }
.capability-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.capability-controls .capability-button, .capability-fields > .capability-button { border-color: #ffffff25; }
.capability-controls audio { width: 100%; min-width: 0; }
.capability-fields { display: flex; flex-direction: column; gap: 12px; }
.capability-fields label { display: grid; gap: 6px; }
.capability-fields input { width: 100%; min-width: 0; background: #081322; color: inherit; border: 1px solid #425369; border-radius: 8px; padding: 10px; font: inherit; }
.capability-error { color: #ffb4b4; font-size: 1.3rem; margin: 8px; overflow-wrap: anywhere; }
.thread__capability { display: grid; gap: 8px; width: min(300px, 100%); white-space: normal; overflow-wrap: anywhere; }
.thread__capability > strong { font-size: 1.5rem; }
.thread__capability .capability-button { border-color: #ffffff30; width: 100%; }
.thread__capability small { opacity: .8; }
.thread__media { display: block; width: 280px; max-width: 100%; min-width: 0; }
video.thread__media { max-height: 280px; border-radius: 8px; background: #000; }
@media (max-width: 600px) {
  .capability-menu { left: 8px !important; right: 8px; bottom: 8px !important; width: auto; max-width: none; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .capability-panel { padding: 16px; }
  .thread__media { width: 220px; }
}

/* Custom Sent Voice Message Player */
.voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 250px;
  max-width: 380px;
  padding: 4px 6px;
  box-sizing: border-box;
  color: #f8fafc;
  background: transparent;
  border: 0;
  border-radius: 0;
  margin: 2px 0 0;
}

.voice-player__audio {
  display: none;
}

/* Sender/Voice Identity Badge (Small Avatar / Mic marker) */
.voice-player__avatar-badge {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
}

.voice-player__avatar-badge .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: block;
}

.voice-player__avatar-badge .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.voice-player__mic-icon {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2dd4bf;
  color: #042127;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.voice-player__mic-icon .ui-icon {
  width: 10px;
  height: 10px;
}

/* Voice Player Control Button */
.voice-player__btn {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 50%;
  background: #2dd4bf;
  color: #042127;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, transform 0.12s ease;
}

.voice-player__btn:hover {
  background: #38efdb;
  transform: scale(1.05);
}

.voice-player__btn:focus-visible {
  outline: 2px solid #38efdb;
  outline-offset: 2px;
}

.voice-player__btn .ui-icon {
  width: 18px;
  height: 18px;
}

.voice-player__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Sent Voice Waveform Bars Container */
.voice-player__wave {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 24px;
  width: 100%;
  cursor: pointer;
  padding: 2px 0;
  box-sizing: border-box;
  overflow: hidden;
}

.voice-player__wave:focus-visible {
  outline: 2px solid #2dd4bf;
  outline-offset: 2px;
  border-radius: 4px;
}

.voice-player__bar {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  transition: background-color 0.12s ease;
  pointer-events: none;
}

.voice-player__bar.is-played {
  background: #2dd4bf;
}

.thread--own .voice-player__bar {
  background: rgba(255, 255, 255, 0.35);
}

.thread--own .voice-player__bar.is-played {
  background: #5eead4;
}

.voice-player__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.15rem;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.voice-player__time {
  font-weight: 600;
  color: #e2e8f0;
}

/* Ensure voice-player in thread bubble leaves room for menu button */
.thread__bubble:has(.voice-player) {
  padding-right: 28px;
}

/* Direct composer recording and voice preview bar */
/* Direct & Room composer recording and voice preview bar: compact right-aligned group */
.composer__voice-panel {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: auto;
  max-width: 100%;
  flex: 0 1 auto;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* Base button rules in composer recording panel */
.composer__voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.composer__voice-panel .composer__voice-btn {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

.composer__voice-btn:hover {
  transform: scale(1.05);
}

.composer__voice-btn:active {
  transform: scale(0.95);
}

.composer__voice-btn:focus-visible {
  outline: 2px solid var(--primary, #2dd4bf) !important;
  outline-offset: 2px;
}

/* Discard / Trash button - bare icon, no box, no background, 32px box, ~20-22px icon */
.composer__voice-btn--cancel,
.composer__voice-btn--delete {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--danger, #ef4444);
}

.composer__voice-btn--cancel svg,
.composer__voice-btn--delete svg,
.composer__voice-btn--cancel .ui-icon,
.composer__voice-btn--delete .ui-icon {
  width: 21px;
  height: 21px;
}

.composer__voice-btn--cancel:hover,
.composer__voice-btn--delete:hover {
  background: transparent !important;
  color: #dc2626;
}

/* Actions group: pause + send */
.composer__voice-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Pause button - bare icon-only, no box, no border, no background, 30-32px area, ~18px icon */
.composer__voice-btn--pause {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--text-secondary);
}

.composer__voice-btn--pause svg,
.composer__voice-btn--pause .ui-icon {
  width: 18px;
  height: 18px;
}

.composer__voice-btn--pause:hover {
  background: transparent !important;
  color: var(--text-primary);
}

.composer__voice-btn--pause.is-paused {
  background: transparent !important;
  color: var(--primary);
}

/* Send button - single solid filled circle, 40px, strictly no outer/inner rings, no wrapper styling, no glow */
.composer__voice-btn--send,
.direct-composer .composer__voice-btn--send,
.room-composer .composer__voice-btn--send {
  flex: 0 0 40px !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  background: var(--primary) !important;
  color: var(--primary-ink) !important;
  border: 0 !important;
  border-radius: 50% !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.composer__voice-btn--send svg,
.composer__voice-btn--send .ui-icon {
  width: 18px;
  height: 18px;
}

.composer__voice-btn--send:hover,
.direct-composer .composer__voice-btn--send:hover,
.room-composer .composer__voice-btn--send:hover {
  background: var(--primary-hover) !important;
  box-shadow: none !important;
  transform: scale(1.04);
}

.composer__voice-btn--send:active,
.direct-composer .composer__voice-btn--send:active,
.room-composer .composer__voice-btn--send:active {
  transform: scale(0.96);
}

.composer__voice-btn--send:focus-visible,
.direct-composer .composer__voice-btn--send:focus-visible,
.room-composer .composer__voice-btn--send:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Middle recording content: timer + compact waveform */
.composer__voice-middle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  min-width: 0;
  width: auto;
}

.composer__voice-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 15px;
  line-height: 1;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.composer__voice-dot {
  color: #ef4444;
  font-size: 8px;
  line-height: 1;
  animation: composerVoicePulse 1.2s ease-in-out infinite;
}

.composer__voice-dot.is-paused {
  animation: none;
  opacity: 0.45;
}

@keyframes composerVoicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.composer__voice-time {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* Compact voice waveform bars (~100-150px) */
.composer__voice-wave {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: 20px;
  width: clamp(100px, 10vw, 150px);
  flex: 0 1 150px;
  min-width: 70px;
  overflow: hidden;
}

.composer__voice-bar {
  flex: 1 1 auto;
  min-width: 2px;
  max-width: 3.5px;
  height: 3px;
  min-height: 3px;
  background: var(--text-muted);
  opacity: 0.65;
  border-radius: 2px;
  transition: height 0.07s ease;
}

@keyframes composerWavePulse {
  0%, 100% { height: 3px; opacity: 0.4; }
  50% { height: 16px; opacity: 0.85; }
}

/* Middle preview content */
.composer__voice-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.composer__preview-play {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary, #2dd4bf);
  color: var(--primary-ink, #042127);
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.composer__preview-play:hover {
  background: var(--primary-hover, #38efdb);
  transform: scale(1.05);
}

.composer__preview-play svg,
.composer__preview-play .ui-icon {
  width: 15px;
  height: 15px;
}

.composer__preview-track {
  flex: 1;
  min-width: 36px;
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.composer__preview-track:focus-visible {
  outline: 2px solid var(--primary, #2dd4bf);
  outline-offset: 2px;
}

.composer__preview-progress {
  height: 100%;
  background: var(--primary, #2dd4bf);
  border-radius: 3px;
  width: 0%;
  transition: width 0.08s linear;
}

.composer__preview-time {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 500;
  color: #cbd5e1;
  white-space: nowrap;
  flex-shrink: 0;
}

.composer__voice-audio {
  display: none;
}

/* Hide normal composer items when recording or previewing */
.direct-composer.is-recording > :not(.composer__voice-panel),
.direct-composer.is-previewing > :not(.composer__voice-panel),
.room-composer.is-recording > :not(.composer__voice-panel),
.room-composer.is-previewing > :not(.composer__voice-panel) {
  display: none !important;
}

/* Native composer bar transformation when recording / previewing */
.direct-composer.is-recording,
.direct-composer.is-previewing,
.room-composer.is-recording,
.room-composer.is-previewing {
  align-items: center;
  min-height: 40px !important;
  height: 40px !important;
  padding: 2px 6px !important;
  box-sizing: border-box !important;
  border-color: var(--surface-border);
  box-shadow: none !important;
}

/* Mobile & Touch Targets: preserve visible compact control sizes while keeping >= 44px hit targets via ::before */
@media (max-width: 768px), (pointer: coarse) {
  .composer__voice-panel {
    gap: 6px;
    padding: 0;
  }
  .voice-player__btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 400px) {
  .voice-player {
    min-width: 200px;
  }
  .composer__voice-wave {
    width: clamp(70px, 18vw, 110px);
    min-width: 70px;
    flex: 0 1 110px;
  }
  .composer__voice-middle {
    gap: 6px;
  }
  .composer__voice-panel {
    gap: 6px;
  }
}
