/* OLONE — голосовые сообщения (отдельно от .bubble-audio / музыки) */

.bubble-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(280px, 72vw);
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bubble-in, #f7f9fc) 88%, var(--text, #222) 4%);
  box-sizing: border-box;
}

.bubble.out .bubble-voice {
  background: color-mix(in srgb, var(--bubble-out, #caecd0) 90%, var(--text, #222) 3%);
}

.bubble-voice__play {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text, #222833) 12%, transparent);
  color: var(--text, #222833);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bubble-voice__play[aria-pressed="true"] {
  background: color-mix(in srgb, var(--text, #222833) 18%, transparent);
}

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

.bubble-voice__wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 28px;
  cursor: pointer;
  touch-action: none;
}

.bubble-voice__bar {
  flex: 1 1 0;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--muted, #6f7785) 55%, transparent);
  transform-origin: bottom;
  transition: background-color 120ms ease;
}

.bubble-voice__bar--played {
  background: color-mix(in srgb, var(--text, #222833) 72%, transparent);
}

.bubble-voice__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted, #6f7785);
  font-variant-numeric: tabular-nums;
}

.bubble-voice__speed {
  border: none;
  background: transparent;
  color: var(--muted, #6f7785);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
}

.bubble-voice__speed:hover {
  background: color-mix(in srgb, var(--text, #222) 8%, transparent);
}

.bubble-media-skeleton__tile--voice {
  width: min(280px, 100%);
  height: 52px;
  border-radius: 12px;
}

.composer-attach-tile--voice {
  background: color-mix(in srgb, var(--text, #222) 6%, var(--panel, #f4f7fb));
}

.composer-attach-tile--voice::after {
  content: "🎤";
  font-size: 22px;
}

.composer-attach-voice-label {
  font-size: 12px;
  color: var(--muted, #6f7785);
  text-align: center;
  padding: 0 4px;
  line-height: 1.25;
}

/* Запись — компактная панель как в Telegram */
.voice-record-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  pointer-events: none;
}

.voice-record-overlay.is-active {
  pointer-events: auto;
}

.voice-record-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12001;
  padding: 6px 10px max(8px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel, #1a1d24) 96%, #000 4%);
  border-top: 1px solid color-mix(in srgb, var(--border, #252830) 80%, transparent);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.22);
  transform: translateY(110%);
  transition: transform 180ms ease;
  pointer-events: auto;
  box-sizing: border-box;
}

.voice-record-overlay.is-active .voice-record-panel,
.voice-record-overlay.is-preview .voice-record-panel {
  transform: translateY(0);
}

.voice-record-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.voice-record-timer {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  color: var(--text, #e8eaed);
  flex-shrink: 0;
}

.voice-record-timer.is-limit {
  color: #e74c3c;
}

.voice-record-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  flex-shrink: 0;
  animation: voice-rec-pulse 1s ease infinite;
}

@keyframes voice-rec-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.voice-record-meter {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 22px;
  width: 56px;
  flex-shrink: 0;
}

.voice-record-meter-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 1px;
  background: color-mix(in srgb, #4caf50 65%, transparent);
  height: 20%;
  transition: height 80ms linear;
}

.voice-record-hint {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted, #9aa0a6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.voice-record-cancel,
.voice-record-stop {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.voice-record-cancel {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, #e74c3c 14%, transparent);
  color: #ffb4b4;
  font-size: 16px;
  line-height: 1;
}

.voice-record-stop {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  background: #4caf50;
  color: #fff;
}

.voice-record-stop.hidden {
  display: none;
}

.voice-preview-host {
  padding: 2px 0;
}

.voice-preview-host .bubble-voice {
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
}

.voice-preview-host .bubble-voice__play {
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.voice-preview-host .bubble-voice__wave {
  height: 22px;
}

.voice-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.voice-preview-actions.hidden,
.voice-preview-host.hidden {
  display: none;
}

.voice-preview-actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.voice-preview-delete {
  background: color-mix(in srgb, #e74c3c 20%, transparent);
  color: #ffb4b4;
}

.voice-preview-send {
  background: #4caf50;
  color: #fff;
}

/* Динамическая кнопка: микрофон ↔ отправить */
.send-fab {
  position: relative;
  overflow: hidden;
}

.send-fab__glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.62);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.send-fab__glyph svg {
  width: 16px;
  height: 16px;
}

.send-fab--mode-send .send-fab__glyph--send,
.send-fab--mode-mic .send-fab__glyph--mic,
.send-fab--mode-save .send-fab__glyph--save {
  opacity: 1;
  transform: scale(1);
}

.send-fab--mode-mic.is-recording {
  color: #e74c3c;
  background: color-mix(in srgb, #e74c3c 22%, var(--text, #222));
}

@media (max-width: 920px) {
  .bubble-voice {
    min-width: min(240px, 78vw);
  }

  .voice-record-hint {
    font-size: 11px;
  }

  .voice-record-meter {
    width: 44px;
  }
}

/* Light theme — voice bubbles in chat */
[data-theme="light"] .bubble-voice {
  background: color-mix(in srgb, #ffffff 94%, #f3f5f8);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .bubble.out .bubble-voice {
  background: color-mix(in srgb, #e2ebe5 88%, #ffffff);
}

[data-theme="light"] .bubble-voice__play {
  background: color-mix(in srgb, var(--accent, #5b8def) 14%, #ffffff);
  color: color-mix(in srgb, var(--accent, #5b8def) 78%, var(--text, #3a4554));
}

[data-theme="light"] .bubble-voice__play[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent, #5b8def) 22%, #ffffff);
}

[data-theme="light"] .bubble-voice__bar {
  background: color-mix(in srgb, var(--muted, #7b8494) 42%, transparent);
}

[data-theme="light"] .bubble-voice__bar--played {
  background: color-mix(in srgb, var(--accent, #5b8def) 52%, var(--muted, #7b8494));
}

[data-theme="light"] .bubble-voice__meta,
[data-theme="light"] .bubble-voice__speed {
  color: color-mix(in srgb, var(--muted, #7b8494) 88%, transparent);
}
