/* ==========================================================================
   👤 Avatars on every product (2026-11-30, migration 164) — avatars.js. Black outline + yellow edge = selected;
   struck = the Doctor's words, marked = yours. av-busy / av-spin / av-err are also used by doctorfeed.js.
   ========================================================================== */

.av-spin { display: inline-block; flex-shrink: 0; width: 16px; height: 16px; border-radius: 999px; border: 2px solid var(--surface-4); border-top-color: var(--ink); animation: av-spin .9s linear infinite; }
@keyframes av-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .av-spin { animation: none; } }
.av-busy, .av-err { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--ink-2); }
.av-err { color: var(--crit-ink); }

.av-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.av-code { font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.av-steps { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 12.5px; color: var(--ink-2); }
.av-steps li { display: inline-flex; align-items: center; gap: 6px; }
.av-steps b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: var(--surface-3); font-size: 11px; color: var(--ink); }

/* the cards */
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.av-card { display: flex; flex-direction: column; min-width: 0; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.av-card.is-on { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--act); }
.av-card-main { all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 6px; padding: 12px 12px 8px; cursor: pointer; min-width: 0; flex: 1; }
.av-card-main:hover { background: var(--surface-2); }
.av-card-main:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.av-card-t { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 14.5px; line-height: 1.4; unicode-bidi: plaintext; }
.av-desc { font-size: 13px; color: var(--ink-2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; unicode-bidi: plaintext; }
.av-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.av-meta .badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.av-card-act { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 12px; border-top: 1px solid var(--border); }
.av-card-act .btn-icon { margin-left: auto; }
.av-pick { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; }

/* the selected avatar: its research, the brief, its scripts */
.av-panel { margin-top: 14px; padding: 14px; border-radius: 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.av-panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.av-panel-t { display: flex; align-items: center; gap: 10px; min-width: 0; }
.av-panel-t > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 15px; unicode-bidi: plaintext; }
.av-panel-t .hint { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.av-research { padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.av-research summary { cursor: pointer; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.av-research-txt { margin: 10px 0 0; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 13px; line-height: 1.6; unicode-bidi: plaintext; }
.av-research-act { display: flex; justify-content: flex-end; margin-top: 8px; }

.av-brief { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.av-brief h4, .av-runs h4 { margin: 0; font-size: 15px; }
.av-fs { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.av-fs legend { padding: 0; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.av-remake input { font-size: 13px; }
.av-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.av-chip { position: relative; cursor: pointer; }
.av-chip input { position: absolute; opacity: 0; pointer-events: none; }
.av-chip span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.av-chip input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.av-chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.av-funnel { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 8px; }
.av-fun { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.av-fun:has(input:checked) { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--act); }
.av-fun input { margin-top: 3px; accent-color: var(--ink); flex-shrink: 0; }
.av-fun > span { display: flex; flex-direction: column; gap: 3px; font-size: 13px; min-width: 0; }
.av-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.av-row .field, .av-form .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.av-go { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.av-go .hint { flex: 1 1 240px; }
.av-brief-q { margin: 0; font-size: 13px; color: var(--ink-2); white-space: pre-line; unicode-bidi: plaintext; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.av-ad-link { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 12.5px; min-width: 0; }
.av-ad-link a { overflow-wrap: anywhere; color: var(--ink-2); }

/* a brief's run and its scripts, 3 hooks each */
.av-run { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); margin-top: 10px; min-width: 0; }
.av-run.is-failed { box-shadow: inset 4px 0 0 var(--act); }
.av-run-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.av-run-t { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.av-run-t .hint { overflow-wrap: anywhere; }
.av-scripts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 10px; }
.av-script { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); min-width: 0; }
.av-script-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.av-script-h > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.av-acts { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.av-del { color: var(--ink-2); }
.av-idea { margin: 0; font-size: 13px; color: var(--ink-2); white-space: pre-line; unicode-bidi: plaintext; }
.av-hooks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.av-hooks li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface); font-size: 13px; }
.av-hooks li b { font-size: 14.5px; line-height: 1.45; unicode-bidi: plaintext; }
.av-hook-n { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.av-body summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.av-body pre { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px; line-height: 1.6; unicode-bidi: plaintext; }
.av-body h5 { margin: 8px 0 4px; font-size: 12.5px; }
.av-hint { margin: 0; font-size: 12px; }
.av-review { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.av-review > .badge { align-self: flex-start; }
.av-rem { margin: 0; font-size: 13px; color: var(--ink-2); white-space: pre-line; unicode-bidi: plaintext; }
.av-learned { padding: 8px 10px; border-radius: 10px; background: var(--surface); font-size: 13px; }
.av-learned p { margin: 4px 0 0; white-space: pre-line; line-height: 1.55; unicode-bidi: plaintext; }

/* the windows */
.av-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.av-form .input { width: 100%; }
.av-wide { grid-column: 1 / -1; }
.av-files { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.av-files li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.av-file-n { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.av-res-who { margin: 0 0 10px; font-size: 14px; unicode-bidi: plaintext; }
.av-res-edit { width: 100%; min-height: 360px; font-size: 13px; line-height: 1.55; }
.av-spacer { flex: 1; }
.av-eform { display: flex; flex-direction: column; gap: 10px; }
.av-ehook { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.av-ehook legend { padding: 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.av-ehook-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.av-ebody { font-size: 14.5px; line-height: 1.7; }
.av-changes { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.av-changes h4 { margin: 0; font-size: 13.5px; }
.av-changes > .hint { margin: 0; }
.av-ch { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.av-ch-f { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.av-ch-b, .av-ch-a { font-size: 14px; line-height: 1.55; unicode-bidi: plaintext; overflow-wrap: anywhere; }
.av-ch-b { color: var(--ink-3); }
.av-ch-b del { color: var(--crit-ink); text-decoration-thickness: 2px; }
.av-ch-a ins { text-decoration: none; background: var(--act); color: var(--act-ink); border-radius: 4px; padding: 0 3px; }
.av-ch .input { font-size: 13px; }

@media (max-width: 720px) {
  .av-row, .av-form { grid-template-columns: 1fr; }
}
