/* Voice chat v2 layout aligned with Stitch screen */
body.chat-v2 {
  display: flex;
  min-height: 100vh;
}

body.chat-v2 .voice-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: #f2f4f7;
  border-right: 1px solid var(--color-border-secondary);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body.chat-v2 .voice-brand-sub {
  margin: 8px 0 0;
  color: var(--color-text-secondary);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

body.chat-v2 .voice-new-chat {
  width: 100%;
}

body.chat-v2 .voice-side-meta label {
  font-size: 12px;
}

body.chat-v2 .voice-side-meta .session-hint {
  display: block;
  margin-top: 8px;
  font-size: 12px;
}

body.chat-v2 .voice-session-picker {
  margin-top: 2px;
  font-size: 12px;
}

body.chat-v2 .voice-session-picker .session-picker-actions {
  margin-top: 6px;
}

body.chat-v2 .voice-history-hint {
  margin: 8px 0;
  font-size: 11px;
  color: var(--color-text-secondary);
  line-height: 1.45;
}

body.chat-v2 .voice-session-list {
  max-height: 200px;
}

body.chat-v2 .thread-dialog-divider {
  margin-left: 12px;
}

body.chat-v2 .voice-side-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.chat-v2 .voice-side-links a {
  text-decoration: none;
  color: var(--color-text-secondary);
  padding: 8px 10px;
  border-radius: 8px;
}

body.chat-v2 .voice-side-links a:hover {
  background: #e8ebf0;
}

body.chat-v2 .voice-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

body.chat-v2 .voice-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border-secondary);
  background: var(--color-bg-container);
  box-shadow: var(--shadow-header);
  gap: 12px;
}

body.chat-v2 .chat-v2-wrap {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 180px;
}

body.chat-v2 .thread {
  min-height: 220px;
  position: relative;
  padding-left: 28px;
}

body.chat-v2 .thread::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(180deg, rgba(22, 119, 255, 0.4), rgba(22, 119, 255, 0.1));
  border-radius: 2px;
}

body.chat-v2 .thread-empty {
  margin-left: 12px;
}

body.chat-v2 .bubble .who.assistant-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #d9e2ff;
  color: #0057c2;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body.chat-v2 .voice-dock {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--color-border-secondary);
  background: var(--color-bg-container);
  padding: 12px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.chat-v2 .tts-panel {
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 8px 12px;
  background: #f8fafc;
}

body.chat-v2 .tts-panel summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

body.chat-v2 .tts-panel-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--color-text-secondary);
}

body.chat-v2 .tts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

body.chat-v2 .tts-grid label {
  font-size: 12px;
  margin-bottom: 4px;
}

body.chat-v2 .v2-dialog-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

body.chat-v2 .v2-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text);
}

body.chat-v2 .v2-checkbox-label input {
  width: auto;
}

body.chat-v2 .v2-transcript-panel {
  border: 1px solid var(--color-border-secondary);
  border-radius: 10px;
  padding: 10px;
  background: var(--color-bg-elevated);
}

body.chat-v2 .v2-transcript-panel textarea {
  width: 100%;
  margin: 8px 0 10px;
  resize: vertical;
}

body.chat-v2 .v2-transcript-actions {
  display: flex;
  gap: 8px;
}

body.chat-v2 .v2-composer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f2f4f7;
  border: 1px solid var(--color-border-secondary);
  border-radius: 14px;
  padding: 10px 12px;
}

/* Анимация «волны» уровня сигнала вокруг микрофона */
body.chat-v2 .v2-mic-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

body.chat-v2 .mic-wave {
  display: block;
  width: 220px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(193, 198, 215, 0.7);
  box-shadow: 0 4px 10px rgba(25, 28, 30, 0.04);
}

body.chat-v2 .v2-composer-row:has(.agent-mic.recording) .mic-wave {
  border-color: rgba(255, 77, 79, 0.35);
  background: rgba(255, 255, 255, 0.92);
}

body.chat-v2 .v2-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 28px;
}

body.chat-v2 .v2-wave-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--color-primary);
  opacity: 0.38;
  height: 10px;
  transform-origin: bottom;
  animation: v2-wave-idle 1.25s ease-in-out infinite;
}

body.chat-v2 .v2-wave--left .v2-wave-bar:nth-child(1) {
  animation-delay: 0ms;
}
body.chat-v2 .v2-wave--left .v2-wave-bar:nth-child(2) {
  animation-delay: 120ms;
}
body.chat-v2 .v2-wave--left .v2-wave-bar:nth-child(3) {
  animation-delay: 240ms;
}
body.chat-v2 .v2-wave--left .v2-wave-bar:nth-child(4) {
  animation-delay: 360ms;
}
body.chat-v2 .v2-wave--left .v2-wave-bar:nth-child(5) {
  animation-delay: 480ms;
}

body.chat-v2 .v2-wave--right .v2-wave-bar:nth-child(1) {
  animation-delay: 80ms;
}
body.chat-v2 .v2-wave--right .v2-wave-bar:nth-child(2) {
  animation-delay: 200ms;
}
body.chat-v2 .v2-wave--right .v2-wave-bar:nth-child(3) {
  animation-delay: 320ms;
}
body.chat-v2 .v2-wave--right .v2-wave-bar:nth-child(4) {
  animation-delay: 440ms;
}
body.chat-v2 .v2-wave--right .v2-wave-bar:nth-child(5) {
  animation-delay: 560ms;
}

@keyframes v2-wave-idle {
  0%,
  100% {
    transform: scaleY(0.45);
    opacity: 0.28;
  }
  50% {
    transform: scaleY(1);
    opacity: 0.5;
  }
}

/* При записи — быстрее, ярче, цвет как у кнопки записи */
body.chat-v2 .v2-composer-row:has(.agent-mic.recording) .v2-wave-bar {
  background: #ff4d4f;
  opacity: 0.92;
  animation-name: v2-wave-record;
  animation-duration: 0.42s;
  animation-timing-function: ease-in-out;
}

@keyframes v2-wave-record {
  0%,
  100% {
    transform: scaleY(0.25);
    opacity: 0.55;
  }
  50% {
    transform: scaleY(1.55);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.chat-v2 .v2-wave-bar {
    animation: none;
    opacity: 0.4;
    transform: scaleY(0.65);
  }
  body.chat-v2 .v2-composer-row:has(.agent-mic.recording) .v2-wave-bar {
    animation: none;
    opacity: 0.85;
    transform: scaleY(1);
  }
}

body.chat-v2 .agent-mic {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #ff4d4f;
  color: #fff;
  font-size: 27px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(255, 77, 79, 0.28);
  transition: transform 0.15s ease;
}

body.chat-v2 .agent-mic.recording {
  animation: agent-mic-pulse-v2 1.2s ease-in-out infinite;
}

@keyframes agent-mic-pulse-v2 {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.22); }
  50% { box-shadow: 0 0 0 11px rgba(255, 77, 79, 0.12); }
}

body.chat-v2 .v2-composer-meta {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

body.chat-v2 .v2-mic-hint {
  font-size: 13px;
  color: var(--color-text-secondary);
}

body.chat-v2 .record-timer {
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--color-danger);
}

body.chat-v2 .v2-dock-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

body.chat-v2 .bubble .body {
  white-space: pre-wrap;
}

body.chat-v2 .thread .bubble.bubble-tl {
  position: relative;
  margin-bottom: 12px;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

body.chat-v2 .thread .bubble.bubble-tl .tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 10px;
  flex-shrink: 0;
  border: 2px solid #d9e2ff;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.08);
}

body.chat-v2 .thread .bubble.bubble-tl.user .tl-dot {
  border-color: rgba(22, 119, 255, 0.3);
  background: #1677ff;
}

body.chat-v2 .thread .bubble.bubble-tl .tl-card {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--color-border-secondary);
  border-radius: 12px;
  padding: 10px 14px;
}

body.chat-v2 .thread .bubble.bubble-tl.user .tl-card {
  background: #1677ff;
  border-color: #1677ff;
  color: #fff;
}

@media (max-width: 980px) {
  body.chat-v2 {
    display: block;
  }
  body.chat-v2 .voice-sidebar {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border-secondary);
  }
  body.chat-v2 .chat-v2-wrap {
    padding-bottom: 210px;
  }
  body.chat-v2 .v2-dock-actions {
    width: 100%;
    margin-left: 0;
  }
}
