/* ArchiFlow — разговор с помощницей голосом (voice-v13.js). Палитра — как skin-v13.css: тёмный фон, золото #B8A77E. */

/* ---------- кнопка-наушники в поле ввода (рядом с микрофоном диктовки) ---------- */
.inputbar .af-voice-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; margin: 0 -6px 4px -6px;
  border: 0; border-radius: 50%; background: transparent; color: var(--gold, #B8A77E);
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background .15s, transform .1s;
}
.inputbar .af-voice-btn[hidden] { display: none; }
.inputbar .af-voice-btn:hover { background: var(--gold-soft, rgba(184,167,126,.14)); }
.inputbar .af-voice-btn:active { transform: scale(.92); }
.inputbar .af-voice-btn:focus-visible { outline: 2px solid var(--gold-line, rgba(184,167,126,.55)); outline-offset: 2px; }
.inputbar .af-voice-btn svg { display: block; }
@media (hover: none) and (pointer: coarse) {
  .inputbar .af-voice-btn { width: 36px; height: 36px; margin-bottom: 1px; }
}

/* ---------- слой разговора ---------- */
html.afv-on, html.afv-on body { overflow: hidden; }
.afv {
  --lvl: 0;
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center;
  height: 100vh; height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 70% at 50% 38%, #2a2620 0%, #1f1e1d 46%, #19191b 100%);
  color: var(--text, #F2F0EC);
  font-family: "Helvetica Neue", Helvetica, Inter, Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  animation: afv-in .22s ease-out;
}
@keyframes afv-in { from { opacity: 0; } to { opacity: 1; } }
.afv-top { width: 100%; max-width: 560px; display: flex; justify-content: center; padding-top: 6px; }
.afv-title { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #9a978f); }
.afv-stage { flex: 1; width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; }
.afv-player { display: none; }

/* круг */
.afv-orb {
  position: relative; width: min(60vw, 248px); height: min(60vw, 248px); margin-bottom: 18px;
  padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.afv-orb:disabled { cursor: default; }
.afv-orb:focus-visible { outline: 2px solid var(--gold-line, rgba(184,167,126,.55)); outline-offset: 10px; }
.afv-halo {
  position: absolute; inset: -18%; border-radius: 50%;
  background: radial-gradient(circle, rgba(212,190,140,.34) 0%, rgba(184,167,126,.12) 42%, rgba(184,167,126,0) 70%);
  opacity: calc(.55 + var(--lvl) * .45);
  transform: scale(calc(.92 + var(--lvl) * .22));
  transition: transform .12s ease-out, opacity .2s;
  pointer-events: none;
}
.afv-core {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 34% 28%, #fbf2dc 0%, #e6d3a6 16%, #c7b384 38%, #9a8659 66%, #5f5233 100%);
  box-shadow: 0 18px 60px rgba(0,0,0,.45), 0 0 70px rgba(184,167,126,.28), inset -14px -20px 40px rgba(40,30,10,.38), inset 8px 10px 30px rgba(255,248,230,.25);
  transform: scale(calc(.94 + var(--lvl) * .12));
  transition: transform .09s ease-out, filter .3s;
  pointer-events: none;
}
.afv-core i {
  position: absolute; inset: -30%; opacity: 0;
  background: conic-gradient(from 0deg, rgba(255,250,235,0) 0deg, rgba(255,250,235,.55) 40deg, rgba(255,250,235,0) 110deg, rgba(255,250,235,0) 200deg, rgba(255,240,205,.35) 250deg, rgba(255,250,235,0) 320deg);
  mix-blend-mode: soft-light;
  transition: opacity .3s;
}
.afv-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(212,190,140,.55); opacity: 0; pointer-events: none;
}

/* слушаю: круг «дышит» и откликается на голос */
.afv[data-state="listening"] .afv-halo { animation: afv-breathe 2.6s ease-in-out infinite; }
@keyframes afv-breathe { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.25); } }

/* думаю: блик бежит по кругу */
.afv[data-state="thinking"] .afv-core { transform: scale(.9); }
.afv[data-state="thinking"] .afv-core i { opacity: 1; animation: afv-spin 1.4s linear infinite; }
.afv[data-state="thinking"] .afv-halo { opacity: .45; transform: scale(.95); animation: afv-breathe 1.2s ease-in-out infinite; }
@keyframes afv-spin { to { transform: rotate(360deg); } }

/* говорю: круг пульсирует, от него расходятся кольца */
.afv[data-state="speaking"] .afv-core { animation: afv-talk .46s ease-in-out infinite alternate; }
.afv[data-state="speaking"] .afv-halo { opacity: .95; animation: afv-talk-halo .46s ease-in-out infinite alternate; }
.afv[data-state="speaking"] .afv-ring.r1 { animation: afv-wave 1.8s ease-out infinite; }
.afv[data-state="speaking"] .afv-ring.r2 { animation: afv-wave 1.8s ease-out .9s infinite; }
@keyframes afv-talk { from { transform: scale(.95); } to { transform: scale(1.03); } }
@keyframes afv-talk-halo { from { transform: scale(.96); } to { transform: scale(1.12); } }
@keyframes afv-wave { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.55); opacity: 0; } }

/* пауза / ошибка: круг гаснет */
.afv[data-state="paused"] .afv-core { filter: saturate(.35) brightness(.62); transform: scale(.9); }
.afv[data-state="paused"] .afv-halo { opacity: .18; }

.afv-status { min-height: 26px; font-size: 19px; font-weight: 500; text-align: center; color: var(--text, #F2F0EC); max-width: 92%; }
.afv[data-state="paused"] .afv-status { font-size: 16px; color: #e8d9b6; }
.afv-hint { min-height: 18px; font-size: 13.5px; color: var(--muted, #9a978f); text-align: center; }

.afv-lines { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; -webkit-user-select: text; user-select: text; }
.afv-line {
  margin: 0; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.45;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; white-space: pre-line;
}
.afv-line b { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 2px; color: var(--muted, #9a978f); }
.afv-you { align-self: flex-end; max-width: 88%; background: #2a2a2d; border: 1px solid var(--line, #3a3a3e); color: var(--text, #F2F0EC); }
.afv-ai { align-self: flex-start; max-width: 100%; background: rgba(184,167,126,.08); border: 1px solid rgba(184,167,126,.22); color: #efe6d2; }
.afv-ai b { color: var(--gold, #B8A77E); }

.afv-bottom { width: 100%; max-width: 560px; display: flex; justify-content: center; padding-top: 10px; }
.afv-end {
  display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 26px;
  border-radius: 25px; border: 1px solid var(--line2, #46464b); background: #2a2a2d; color: var(--text, #F2F0EC);
  font: inherit; font-size: 15px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: border-color .15s, background .15s;
}
.afv-end:hover { border-color: var(--conf, #E07A55); }
.afv-end:active { background: #323236; }
.afv-end:focus-visible { outline: 2px solid var(--gold-line, rgba(184,167,126,.55)); outline-offset: 3px; }
.afv-end svg { color: var(--conf, #E07A55); }

@media (max-height: 560px) {
  .afv-orb { width: min(40vh, 200px); height: min(40vh, 200px); margin-bottom: 6px; }
  .afv-line { -webkit-line-clamp: 2; }
}
@media (prefers-reduced-motion: reduce) {
  .afv, .afv * { animation: none !important; transition: none !important; }
  .afv[data-state="thinking"] .afv-core i { opacity: .6; }
}

/* ---------- «Площадка» → Голос ElevenLabs ---------- */
.afplat > .afvoice-set { border-top: 1px solid var(--line, #3a3a3e); padding-top: 12px; margin-top: 2px; }
.afvoice-set h4 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.afvoice-state { font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--line2, #46464b); color: var(--muted, #9a978f); }
.afvoice-state.on { color: var(--gold, #B8A77E); border-color: var(--gold-line, rgba(184,167,126,.55)); background: var(--gold-soft, rgba(184,167,126,.14)); }
.afvoice-key, .afvoice-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.afvoice-key label, .afvoice-row label { flex: 1 1 240px; min-width: 0; }
.afvoice-key .afplat-mini, .afvoice-row .afplat-mini { height: 36px; }
.afvoice-btns { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.accbox .afvoice-set select { width: 100%; min-width: 0; }
.afvoice-model { max-width: 100%; }
.afvoice-play { display: inline-flex; align-items: center; gap: 6px; }
.afvoice-play svg { color: var(--gold, #B8A77E); }
.afvoice-play.busy { opacity: .6; }
.afvoice-help { line-height: 1.45; }
