/* Presentation only. Voice state and busy attributes come from the existing
   renderer; delivery truth continues to live on the message receipt. */
body.chats-real-v1 .composer :is(button, textarea):focus-visible {
  outline: 2px solid #77ddd0;
  outline-offset: 3px;
}

body.chats-real-v1 .voice-draft-panel {
  min-width: 0;
  padding: 8px;
  border: 1px solid #475159;
  border-radius: 10px;
  background: #1a1d21;
  color: #d9e0e3;
  overflow-wrap: anywhere;
}

body.chats-real-v1 .voice-draft-panel > :is(span, small) {
  min-width: 0;
  max-width: 100%;
}

body.chats-real-v1 .voice-draft-panel :is(.voice-composer-status, small, [role="alert"]) {
  flex: 1 0 100%;
  line-height: 1.4;
}

body.chats-real-v1 .voice-draft-panel audio {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 100%;
  height: 44px;
}

body.chats-real-v1 .voice-draft-panel button {
  min-width: 44px;
  min-height: 44px;
  font: inherit;
  line-height: 1.3;
  white-space: normal;
}

/* Stop retains the recording as a draft. Cancel discards it. Distinguish
   these existing actions by weight, border and text as well as color. */
body.chats-real-v1 .voice-draft-panel [data-voice-stop] {
  background: #77ddd0;
  border-color: #77ddd0;
  color: #142725;
  font-weight: 700;
}

body.chats-real-v1 .voice-draft-panel [data-voice-cancel] {
  background: transparent;
  border-color: #68747d;
  color: #d9e0e3;
}

body.chats-real-v1 .voice-draft-panel[data-voice-state="recording"] {
  border-color: #dd9999;
}

body.chats-real-v1 .voice-draft-panel[data-voice-state="error"],
body.chats-real-v1 .voice-draft-panel [role="alert"] {
  color: #ffc1b9;
}

body.chats-real-v1 .voice-draft-panel[aria-busy="true"] {
  border-style: dashed;
}

body.chats-real-v1 .send-button:disabled {
  opacity: .55;
  cursor: default;
}

@media (max-width: 720px) {
  body.chats-real-v1 .composer,
  html[data-tarvi-media-product="on"] body.chats-real-v1.chats-real-active-inbox .composer {
    grid-template-columns: 44px 44px minmax(0, 1fr) 44px 44px !important;
    gap: 6px;
  }

  body.chats-real-v1 .composer > .composer-input-wrap,
  html[data-tarvi-media-product="on"] body.chats-real-v1 .composer > .composer-input-wrap {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  html[data-tarvi-media-product] body.chats-real-v1 .composer > [data-action="attach"] { grid-row: 2; grid-column: 1; }
  html[data-tarvi-media-product] body.chats-real-v1 .composer > .voice-record-button { grid-row: 2; grid-column: 2; }
  html[data-tarvi-media-product] body.chats-real-v1 .composer > .send-button { grid-row: 2; grid-column: 4; }
  body.chats-real-v1 .composer > #quietSendToggleWrap { grid-row: 2; grid-column: 5; }

  body.chats-real-v1 .composer-input-wrap textarea {
    font-size: 16px;
    max-height: min(120px, 25dvh);
    overflow-y: auto;
  }

  body.chats-real-v1 .voice-draft-panel:has([data-voice-stop]) > span {
    flex: 1 0 100%;
  }
}

/* Preserve V7's usable single row when a landscape IME leaves very little
   height. The draft scrolls internally; all external actions stay reachable. */
@media (max-width: 900px) and (max-height: 320px) {
  body.tarvi-pwa-keyboard.chats-real-v1 .composer {
    grid-template-columns: 44px 44px minmax(0, 1fr) 44px 44px !important;
  }
  html body.tarvi-pwa-keyboard.chats-real-v1 .composer > [data-action="attach"] { grid-row: 1; grid-column: 1; }
  html body.tarvi-pwa-keyboard.chats-real-v1 .composer > .voice-record-button { grid-row: 1; grid-column: 2; }
  html body.tarvi-pwa-keyboard.chats-real-v1 .composer > .composer-input-wrap { grid-row: 1; grid-column: 3; }
  html body.tarvi-pwa-keyboard.chats-real-v1 .composer > .send-button { grid-row: 1; grid-column: 4; }
  html body.tarvi-pwa-keyboard.chats-real-v1 .composer > #quietSendToggleWrap { grid-row: 1; grid-column: 5; }
  body.tarvi-pwa-keyboard.chats-real-v1 .composer-input-wrap {
    height: auto;
    max-height: calc(100dvh - 8px);
    overflow-y: auto;
  }
  body.tarvi-pwa-keyboard.chats-real-v1 .voice-draft-panel {
    padding: 0;
    margin-bottom: 0;
    border: 0;
    background: transparent;
    gap: 6px;
  }
  body.tarvi-pwa-keyboard.chats-real-v1 .voice-draft-panel:has([data-voice-stop]) > span {
    flex: 1 1 100px;
  }
}

/* SENT_VOICE_LAYOUT_START
   Native audio needs real inline space inside the shrink-to-content message.
   A wide player retains the browser controls; this does not implement seek. */
body.chats-real-v1 .message:has(.voice-message audio) {
  width: min(100%, 320px);
  max-width: min(100%, 320px);
}
body.chats-real-v1 .message:has(.voice-message audio) > .message-bubble {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}
body.chats-real-v1 .message .voice-message:has(audio) {
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}
body.chats-real-v1 .message .voice-message:has(audio) > span {
  flex: 1 0 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}
body.chats-real-v1 .message .voice-message audio {
  flex: 1 1 240px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 44px;
}
/* SENT_VOICE_LAYOUT_END */
