/* Voice Call V1 (P1-P3):
 * 1. Equal-height 3-button composer action cluster + dynamic Cat Paw / Send Arrow switching.
 * 2. Integrated lightweight composer function panel (up to 2 rows, warm paper & hand-drawn ink).
 * 3. Full-screen hand-drawn Call Screen matching call-screen-sketch.png.
 */

.composer.voice-composer .composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.composer.voice-composer .composer-tools > span {
  flex: 1 1 auto;
  min-width: 4px;
}

.composer.voice-composer .composer-tools > button,
.composer.voice-composer .composer-tools .icon,
.composer.voice-composer .composer-tools .sticker-toggle,
.composer.voice-composer .composer-tools .voice-mic,
.composer.voice-composer .composer-tools .send {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  display: grid;
  place-items: center;
  align-self: center;
  box-sizing: border-box;
  line-height: 1;
}

.composer.voice-composer .composer-tools .sticker-toggle svg,
.composer.voice-composer .composer-tools .voice-mic svg {
  width: 22px;
  height: 22px;
  display: block;
}

.composer.voice-composer .composer-tools .send svg {
  width: 22px;
  height: 22px;
  display: block;
}

.composer.voice-composer .composer-tools .send[data-mode="paw"][aria-expanded="true"] {
  background: color-mix(in srgb, var(--sage, #dfe8df) 82%, #bfd0c0);
  transform: scale(0.97);
}

/* Integrated lightweight function panel inside the composer */
.composer-more-panel {
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--rule, #cdc4b7);
  border-radius: 18px 16px 20px 15px;
  background: var(--paper, #fbf8f0);
  box-sizing: border-box;
  animation: composer-more-enter 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.composer-more-panel[hidden],
.composer.voice-mode .composer-more-panel {
  display: none !important;
}

@keyframes composer-more-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.composer-more-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(68px, auto);
  gap: 10px 12px;
  align-items: start;
  max-height: 164px;
  overflow: hidden;
}

.composer-more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 64px;
  padding: 6px 4px;
  border: 0;
  border-radius: 14px 12px 15px 13px;
  background: transparent;
  color: var(--ink, #393d42);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 110ms var(--ease-out, ease-out),
    background-color 140ms var(--ease-out, ease-out);
}

.composer-more-icon {
  width: 48px;
  height: 48px;
  border: 1px solid color-mix(in srgb, var(--rule, #cdc4b7) 85%, transparent);
  border-radius: 15px 13px 16px 14px;
  background: color-mix(in srgb, var(--paper, #fbf8f0) 76%, #ffffff);
  display: grid;
  place-items: center;
  color: var(--ink, #393d42);
  box-sizing: border-box;
}

.composer-more-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.composer-more-label {
  font-size: 12px;
  line-height: 1.25;
  color: var(--ink, #393d42);
  text-align: center;
  white-space: nowrap;
}

.composer-more-item:hover .composer-more-icon {
  background: color-mix(in srgb, var(--sage, #dfe8df) 45%, #ffffff);
}

.composer-more-item:active {
  transform: scale(0.96);
}

.composer-more-item:focus-visible {
  outline: 2px solid var(--ink, #655846);
  outline-offset: 2px;
}

/* Interrupted call message badge in chat flow */
.call-interrupted-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted, #747971);
  vertical-align: baseline;
  user-select: none;
}

/* Hidden continuation turn rows (grouped into the anchor Call Bubble) */
.message.call-turn-continuation,
.message.call-turn-continuation[hidden] {
  display: none !important;
}

/* Voice-capsule-style Call Bubble in the chat flow (user-initiated on right, assistant-initiated on left) */
.message.user.call-record-message > .message-text {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  max-width: 100%;
  width: fit-content;
  white-space: normal;
  justify-self: end;
}

.message.assistant.call-record-message > .message-text {
  padding: 0;
  background: transparent;
  white-space: normal;
}

.call-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  min-width: 0;
}

.message.user.call-record-message .call-bubble-wrap {
  align-items: flex-end;
}

.message.assistant.call-record-message .call-bubble-wrap {
  align-items: flex-start;
}

.call-bubble-row.voice-row {
  margin: 0;
  align-items: center;
  max-width: 100%;
}

.call-bubble-capsule.voice-capsule {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.56em;
  width: auto;
  min-width: 9.8em;
  max-width: 100%;
  height: clamp(36px, 2.875em, 56px);
  min-height: 36px;
  padding: 0 1.05em;
  border: 0;
  border-radius: 1.44em 1.31em 1.38em 1.19em;
  color: var(--ink, #393d42);
  font: inherit;
  font-size: clamp(13px, var(--chat-font, 16px), 22px);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
  transition:
    transform 120ms var(--ease-out, ease-out),
    background-color 140ms var(--ease-out, ease-out);
}

.message.user.call-record-message .call-bubble-capsule.voice-capsule {
  background: var(--blue, #e3e9ef);
}

.message.assistant.call-record-message .call-bubble-capsule.voice-capsule {
  background: var(--voice-paper, #e9eef0);
}

.call-bubble-capsule.voice-capsule:active {
  transform: scale(0.985);
}

.call-bubble-capsule.voice-capsule:focus-visible {
  outline: 2px solid var(--ink, #655846);
  outline-offset: 2px;
}

.call-bubble-icon {
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
  color: var(--ink, #393d42);
}

.call-bubble-icon svg {
  width: 1.18em;
  height: 1.18em;
  display: block;
}

.call-bubble-label {
  display: inline-flex;
  align-items: baseline;
  gap: 0.42em;
  font-size: 0.9em;
  line-height: 1.3;
  color: var(--ink, #393d42);
  white-space: nowrap;
}

.call-bubble-duration {
  font-variant-numeric: tabular-nums;
  font-size: 1em;
  color: var(--ink, #393d42);
}

/* Collapsible call transcript fold below the Call Bubble */
.call-transcript-fold.voice-transcript {
  margin: 6px 0 0;
  padding: 0.65em 0.9em;
  width: fit-content;
  min-width: min(12em, 100%);
  max-width: min(84vw, 380px);
  border-radius: 1.05em 0.95em 1.12em 0.9em;
  background: var(--voice-transcript-paper, #eef1f1);
  color: var(--ink, #393d42);
  font-size: var(--chat-font, 16px);
  line-height: 1.68;
  text-align: left;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.call-transcript-fold[hidden] {
  display: none !important;
}

.call-transcript-turn {
  margin: 0;
  font-size: 0.92em;
  line-height: 1.62;
  color: var(--ink, #393d42);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.call-transcript-speaker {
  font-weight: 600;
  color: var(--ink, #393d42);
}

.call-transcript-empty {
  margin: 0;
  font-size: 0.88em;
  color: var(--muted, #747971);
}

/* WeChat-style Floating Minimized Call Ball */
.yanlan-call-floating-ball {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1545;
  width: 68px;
  height: 68px;
  padding: 6px 4px;
  border: 1.4px solid var(--ink, #393d42);
  border-radius: 22px 20px 23px 19px;
  background: color-mix(in srgb, var(--sage, #dfe8df) 65%, var(--paper, #fbf8f0));
  color: var(--ink, #393d42);
  box-shadow: 0 4px 14px rgba(57, 61, 66, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
  transition: background-color 140ms ease, box-shadow 140ms ease;
}

.yanlan-call-floating-ball[hidden] {
  display: none !important;
}

.yanlan-call-floating-ball.dragging {
  box-shadow: 0 7px 20px rgba(57, 61, 66, 0.22);
}

.yanlan-call-floating-ball:focus-visible {
  outline: 2px solid var(--ink, #655846);
  outline-offset: 2px;
}

.call-ball-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--ink, #393d42);
}

.call-ball-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.call-ball-timer {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--ink, #393d42);
}

/* Full-screen Hand-Drawn Call Screen (matching call-screen-sketch.png) */
.yanlan-call-screen {
  position: fixed;
  inset: 0;
  z-index: 1550;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(32px, calc(env(safe-area-inset-bottom) + 18px))
    max(20px, env(safe-area-inset-left));
  background: var(--paper, #f7f4ec);
  color: var(--ink, #393d42);
  box-sizing: border-box;
  overflow: hidden;
  animation: call-screen-fade 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.yanlan-call-screen[hidden] {
  display: none !important;
}

@keyframes call-screen-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.call-screen-topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.call-back-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--rule, #cdc4b7) 75%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper, #fbf8f0) 85%, #ffffff);
  color: var(--ink, #393d42);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 110ms ease, background-color 140ms ease;
}

.call-back-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

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

.call-back-btn:focus-visible {
  outline: 2px solid var(--ink, #655846);
  outline-offset: 2px;
}

.call-screen-stage {
  flex: 1 1 auto;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 0;
}

/* Avatar pair & hand-drawn connecting line with center heart loop */
.call-avatars-row {
  width: 100%;
  max-width: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 8px;
  box-sizing: border-box;
}

.call-avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.call-avatar-circle {
  width: 68px;
  height: 68px;
  border-radius: 50% 48% 51% 49%;
  border: 1.4px solid var(--ink, #393d42);
  background: var(--sage, #dfe8df);
  color: var(--ink, #393d42);
  display: grid;
  place-items: center;
  font-size: 24px;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 1px 0 rgba(57, 61, 66, 0.06);
}

.call-avatar-circle.partner {
  background: var(--blue, #e3e9ef);
}

.call-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.call-avatar-name {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--muted, #747971);
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-heart-bridge {
  flex: 1 1 110px;
  min-width: 76px;
  max-width: 150px;
  height: 44px;
  margin: 0 -2px 18px;
  color: var(--ink, #393d42);
  overflow: visible;
}

/* Call duration mm:ss */
.call-timer {
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: 0.04em;
  color: var(--ink, #393d42);
  margin-top: 2px;
}

/* Real volume waveform */
.call-waveform-wrap {
  width: min(280px, 78vw);
  height: 64px;
  display: grid;
  place-items: center;
}

.call-waveform {
  width: 100%;
  height: 64px;
  display: block;
}

/* Status subtitle directly BELOW the waveform (Section 8.1) */
.call-status-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  text-align: center;
}

.call-status-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted, #747971);
  letter-spacing: 0.02em;
}

.call-sub-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted, #747971);
  opacity: 0.85;
  max-width: 280px;
}

.call-sub-hint:empty {
  display: none;
}

.call-manual-send-btn {
  min-height: 34px;
  padding: 4px 14px;
  border: 1px dashed var(--rule, #cdc4b7);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper, #fbf8f0) 90%, #ffffff);
  color: var(--ink, #393d42);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.call-manual-send-btn[hidden] {
  display: none !important;
}

/* Bottom centered hangup button */
.call-screen-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 8px;
}

.call-hangup-btn {
  width: 68px;
  height: 68px;
  min-width: 68px;
  min-height: 68px;
  padding: 0;
  border: 1.5px solid var(--danger, #9b6267);
  border-radius: 50% 48% 52% 49%;
  background: color-mix(in srgb, var(--danger, #9b6267) 14%, var(--paper, #fbf8f0));
  color: var(--danger, #9b6267);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
  transition:
    transform 120ms var(--ease-out, ease-out),
    background-color 140ms var(--ease-out, ease-out);
}

.call-hangup-btn svg {
  width: 30px;
  height: 30px;
  display: block;
}

.call-hangup-btn:hover {
  background: color-mix(in srgb, var(--danger, #9b6267) 22%, var(--paper, #fbf8f0));
}

.call-hangup-btn:active {
  transform: scale(0.94);
}

.call-hangup-btn:focus-visible {
  outline: 2px solid var(--danger, #9b6267);
  outline-offset: 3px;
}

@media (max-width: 380px) {
  .call-avatar-circle {
    width: 60px;
    height: 60px;
    font-size: 21px;
  }
  .call-heart-bridge {
    min-width: 64px;
  }
  .call-hangup-btn {
    width: 62px;
    height: 62px;
    min-width: 62px;
    min-height: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .composer-more-panel,
  .composer-more-item,
  .yanlan-call-screen,
  .call-back-btn,
  .call-hangup-btn {
    animation: none;
    transition: none;
  }
  .composer-more-item:active,
  .call-back-btn:active,
  .call-hangup-btn:active {
    transform: none;
  }
}

html[data-reduced="true"] .composer-more-panel,
html[data-reduced="true"] .composer-more-item,
html[data-reduced="true"] .yanlan-call-screen,
html[data-reduced="true"] .call-back-btn,
html[data-reduced="true"] .call-hangup-btn {
  animation: none;
  transition: none;
}
