/* Task 123: chat-style voice/text composer. Theme-aware via the site's
   custom properties so a theme change applies automatically.
   Task 124: tuned to the v12 teal tokens (card shadow, focus ring). */

:root {
  --ink: #102A33;
  --muted: #56707A;
  --line: #E2EAEE;
  --bg: #F3F8FA;
  --card: #FFFFFF;
  --accent: #0F766E;
  --accent-ink: #115E59;
  --accent-soft: #E6FAF6;
  --accent-bright: #14B8A6;
  --blue: #0369A1;
  --blue-soft: #E8F4FD;
  --sky: #38BDF8;
  --sky-pale: #7DD3FC;
  --teal-glow: #5EEAD4;
}

.composer {
  margin: 12px 0;
}

.composer [hidden] {
  display: none !important;
}

/* --- thread: chat bubbles above the pill --- */

.composer-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.composer-thread:empty {
  display: none;
}

.composer-bubble {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: break-word;
  hyphens: manual;
}

.composer-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.composer-bubble-status {
  align-self: flex-start;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 4px;
}

.composer-audio-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.composer-audio-pill audio {
  display: none;
}

.composer-audio-meta {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.composer-play {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
}

.composer-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.composer-step.is-active {
  color: var(--ink);
}

.composer-step.is-done {
  color: var(--muted);
}

.composer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
}

.composer-step.is-done .composer-dot {
  background: var(--accent);
}

.composer-step.is-active .composer-dot {
  background: var(--accent);
  animation: composer-pulse 1s ease-in-out infinite;
}

@keyframes composer-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.composer-result {
  margin: 0 0 8px;
}

.composer-cta {
  display: inline-block;
  padding: 10px 18px;
  min-height: 44px;
  line-height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.composer-retry-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-retry {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

/* --- the pill bar --- */

.composer-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 6px;
}

.composer-pill:focus-within {
  border-color: var(--accent);
}

.composer-attach {
  position: relative;
  flex: none;
}

.composer-plus,
.composer-mic,
.composer-send,
.composer-cancel {
  flex: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-plus {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.composer-mic {
  background: var(--accent-soft);
  color: var(--accent);
}

.composer-send {
  background: var(--accent);
  color: #fff;
}

.composer-cancel {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.composer-plus:disabled,
.composer-mic:disabled,
.composer-send:disabled,
.composer-cancel:disabled {
  opacity: 0.45;
  cursor: default;
}

.composer-plus:focus-visible,
.composer-mic:focus-visible,
.composer-send:focus-visible,
.composer-cancel:focus-visible,
.composer-retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fallback row (no JS): the upload choice stays visible and usable. */
.composer-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* With JS the menu becomes a dropdown above the + button. */
.composer.is-js .composer-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-card);
  z-index: 30;
}

.composer-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}

.composer.is-js .composer-menu-item:hover {
  background: var(--accent-soft);
}

.composer-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.composer-text {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  padding: 10px 6px;
  resize: none;
  max-height: 120px;
}

.composer-text:focus {
  outline: none;
}

.composer-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 44px;
  min-width: 0;
  padding: 0 6px;
}

.composer-bar {
  flex: 1;
  min-width: 2px;
  height: 20%;
  border-radius: 2px;
  background: var(--accent);
}

.composer-level {
  display: block;
  height: 8px;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
}

.composer-timer {
  flex: none;
  margin: 0;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.composer-nojs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-nojs-send {
  min-height: 44px;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.composer-hint {
  margin: 8px 4px 0;
  font-size: 14px;
  color: var(--muted);
  hyphens: manual;
}

@media (prefers-reduced-motion: reduce) {
  .composer-step.is-active .composer-dot {
    animation: none;
    opacity: 1;
  }

  .composer-bar {
    transition: none;
  }
}

/* Task 131: spoken-language chip inside the pill. Small enough to share
   the bar with + / mic on a 320px phone; the menu scrolls. */

.composer-lang {
  position: relative;
  flex: none;
  min-width: 0;
}

.composer-lang-chip {
  display: inline-flex;
  align-items: center;
  max-width: 96px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.composer-lang-chip [data-composer-lang-label] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-lang-chip:focus-visible,
.composer-lang-menu [role="option"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.composer-lang-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 160px;
  max-width: 72vw;
  max-height: 240px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-card);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.composer-lang-menu [role="option"] {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.composer-lang-menu [role="option"][aria-selected="true"] {
  background: var(--accent-soft);
  font-weight: 600;
}

/* Task 131: "needs you" question inside the status bubble. */

.composer-heard-label {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.composer-quote {
  margin: 4px 0 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg);
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  overflow-wrap: break-word;
}

.composer-lang-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.composer-lang-pick {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

.composer-lang-pick:disabled {
  opacity: 0.45;
  cursor: default;
}

.composer-lang-pick:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
