/* Dictation (js/dictation.js): mic button inside free-text answer boxes. */
.dict { position: relative; display: block; }
.dict > textarea.dict__field { padding-right: 52px; }
.dict.is-rec > textarea.dict__field, .dict.is-err > textarea.dict__field { padding-bottom: 38px; }
.dict:has(> .dict__field[readonly]) .dict__btn,
.dict:has(> .dict__field[disabled]) .dict__btn,
.dict:has(> .dict__field[readonly]) .dict__live { display: none; }

.dict__btn {
  position: absolute; right: 4px; bottom: 4px; z-index: 1;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: var(--text-muted);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.dict__btn::before {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  background: var(--bg-sunken, var(--bg)); border: 1px solid var(--border);
  transition: background-color .15s, border-color .15s;
}
.dict__btn svg { position: relative; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dict__btn:hover { color: var(--accent); }
.dict__btn:hover::before { border-color: var(--accent); }
.dict__btn:focus-visible { outline: none; }
.dict__btn:focus-visible::before { box-shadow: 0 0 0 3px var(--focus, var(--accent-soft)); border-color: var(--accent); }

.dict__dot { position: absolute; inset: 6px; border-radius: 50%; pointer-events: none; opacity: 0; }
.dict.is-rec .dict__btn { color: #fff; }
.dict.is-rec .dict__btn::before { background: var(--bad); border-color: var(--bad); }
.dict.is-rec .dict__dot { opacity: 1; animation: dict-pulse 1.4s ease-out infinite; }
@keyframes dict-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); }
  100% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--bad) 0%, transparent); }
}

.dict__live {
  position: absolute; left: 10px; right: 54px; bottom: 10px; z-index: 1;
  display: flex; gap: 6px; justify-content: flex-start; pointer-events: none;
  font-size: 0.82rem; line-height: 1.35; min-width: 0;
}
.dict__interim, .dict__msg {
  min-width: 0; max-width: 100%; padding: 3px 8px; border-radius: var(--radius-sm, 6px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
}
.dict__interim { color: var(--text-faint); font-style: italic; }
.dict__msg { color: var(--text-muted); font-weight: 600; }
.dict.is-err .dict__msg { color: var(--bad); background: var(--bad-soft, var(--bg-elev)); }
.dict__interim:empty, .dict__msg:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .dict.is-rec .dict__dot { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 35%, transparent); }
}
@media (max-width: 760px) {
  .dict__live { font-size: 0.8rem; }
  .dict__interim, .dict__msg { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .dict__interim:empty, .dict__msg:empty { display: none; }
}
