/* Поле ввода: изображения, выбор модели, панель записи */
.popover { position: fixed; z-index: 25; width: min(360px, calc(100vw - 16px)); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 34px #0004; padding: 6px; animation: rise .16s ease-out; }
#attach-menu { width: 220px; }
.menu-item.btn { width: 100%; border: 0; background: none; padding: 10px 12px; border-radius: 10px; }
.menu-item.btn:hover { background: var(--hover); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

#attach-strip { display: flex; flex-shrink: 0; gap: 8px; overflow: auto hidden; padding: 4px 40px 4px 2px; }
.attach-thumb { position: relative; flex: none; width: 64px; height: 64px; animation: rise .2s ease-out; }
.attach-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.attach-remove.icon-button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); color: var(--bg); }
.attach-remove .icon { width: 13px; height: 13px; }
.message .markdown img { display: block; max-height: 260px; margin: 9px 0; }
/* Камера на весь экран */
#camera { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: #000; animation: camera-in .22s ease-out; }
#camera[open] { display: flex; flex-direction: column; }
@keyframes camera-in { from { opacity: 0; transform: scale(.96); } }
#camera-view { display: block; flex: 1; width: 100%; min-height: 0; object-fit: contain; }
.camera-actions { display: flex; align-items: center; justify-content: space-around; padding: 18px 0 max(24px, env(safe-area-inset-bottom)); }
.camera-actions .icon-button { width: 52px; height: 52px; color: #fff; background: #ffffff1f; border-radius: 50%; }
#camera-shot { width: 76px; height: 76px; border-radius: 50%; background: #fff; border: 4px solid #000; box-shadow: 0 0 0 4px #fff; transition: transform .12s; }
#camera-shot:active { transform: scale(.92); }

.place-icon.here, [data-place="here"] #gear-badge { color: #34a853; }
.place-icon.peer, [data-place="peer"] #gear-badge { color: var(--accent); }
.place-icon.cloud, [data-place="cloud"] #gear-badge { color: #d97757; }
.model-group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px 2px; }
.model-offline { padding: 2px 10px 6px; }
.model-row { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.model-row:hover { background: var(--hover); }
.model-row.active { background: #1e96eb1c; }
.model-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 7px 10px; text-align: left; }
.place-icon { display: inline-grid; place-content: center; flex: none; }
.model-pick .place-icon { width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, currentColor 14%, transparent); }
.model-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.model-text small { color: var(--muted); font-size: 12px; }
.model-choices { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 6px 10px; }
.model-choices .field-label { width: 100%; font-size: 12px; }
.chip.active { background: #1e96eb1c; color: var(--accent); }
.power-button { display: inline-grid; place-content: center; flex: none; width: 34px; height: 34px; margin-right: 4px; border-radius: 50%; border: 1px solid var(--line); background: none; color: var(--muted); }
.power-button.on { color: #fff; background: #34a853; border-color: #34a853; }
.power-button .icon { width: 17px; height: 17px; }
.power-button.working { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Запись голоса */
#composer.recording > #chat-input, #composer.recording > .composer-row, #composer.recording > #expand-button, #composer.recording > #attach-strip { display: none; }
#composer.recording { border-color: transparent; box-shadow: 0 0 0 1px #1e96eb66, 0 8px 34px #1e96eb2e; animation: glow 3s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 1px #a06bf077, 0 8px 40px #a06bf038; } }
#record-bar { display: flex; flex-direction: column; gap: 8px; padding: 4px 4px 2px; animation: rise .22s ease-out; }
#composer.expanded #record-bar { flex: 1; min-height: 0; }
.record-head { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
#record-title { flex: 1; }
#record-time { font-variant-numeric: tabular-nums; color: var(--text); font-size: 14px; }
#record-wave { display: block; width: 100%; height: 56px; color: var(--accent); }
#live-text { flex-shrink: 0; max-height: 28vh; overflow-y: auto; padding: 0 6px; min-height: 48px; font-size: 18px; line-height: 1.55; text-align: center; }
#composer.expanded #live-text { max-height: none; flex: 1; }
#live-hint { color: var(--muted); font-size: 15px; animation: pulse 1.8s infinite; }
#live-error { font-size: 13px; }
.live-word { display: inline-block; animation: word .38s cubic-bezier(.2, .7, .3, 1); transition: color .25s; }
.live-word.partial { color: var(--muted); }
@keyframes word { from { opacity: 0; transform: translateY(7px); filter: blur(4px); } }
.record-actions { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.record-button { display: inline-grid; place-content: center; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); transition: transform .12s; }
.record-button:active { transform: scale(.92); }
.record-button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.record-orb { position: relative; display: inline-grid; place-content: center; width: 58px; height: 58px; }
#record-halo { position: absolute; inset: 6px; border-radius: 50%; background: radial-gradient(circle, #1e96eb55, #a06bf033); transition: transform .08s linear; }
.record-core { position: relative; display: inline-grid; place-content: center; width: 42px; height: 42px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #1e96eb, #8f6bf0); }
#record-bar.processing .record-core { animation: pulse 1s infinite; }
.record-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }
#record-bar.processing .record-dot { background: var(--accent); }

/* Плашки состояния, базы, граф */
.status-line { display: flex; align-items: center; gap: 12px; margin: 4px 0 10px; }
.status-badge { display: grid; place-content: center; width: 38px; height: 38px; flex: none; border-radius: 50%; color: var(--muted); background: var(--hover); }
.status-line.ok .status-badge { color: #34a853; background: #34a85322; }
.status-line.warn .status-badge { color: var(--warn); background: #f6c45322; }
.status-line.busy .status-badge { color: var(--accent); background: #1e96eb22; }
.status-line.busy .icon { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }
.status-text { display: flex; flex-direction: column; min-width: 0; }
.status-text small { color: var(--muted); }
.status-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sync-state-body > progress, #speech-body > progress { display: block; height: 8px; border-radius: 6px; margin: 4px 0 8px; }
progress.flow { background: linear-gradient(90deg, var(--line) 25%, var(--accent) 50%, var(--line) 75%) 0 0 / 220% 100%; animation: flow 1.3s linear infinite; }
progress.flow::-webkit-progress-bar { background: transparent; }
@keyframes flow { from { background-position: 100% 0; } to { background-position: -120% 0; } }
.engine-switch.segmented button { display: inline-flex; align-items: center; gap: 5px; width: auto; padding: 0 9px; font-size: 12px; }

#view-files { position: relative; }
#graph-tools { position: absolute; right: 14px; bottom: 16px; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
#graph-zoom { font-size: 12px; min-width: 42px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-node .player { margin: 6px 0; padding: 4px 6px; cursor: default; }
.board-node .player-row > a { display: none; }
.board-node .player-words { max-height: 90px; touch-action: pan-y; }

@media (max-width: 760px) {
  .engine-switch.segmented button span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .live-word, .popover, #composer.recording, #record-bar { animation: none; } }
