/* Talk with Agent – BaseHeart administrators only. The portrait arrives only
   through the administrator-checked server route; the live face is drawn on
   the canvas above it. Self-themed: both palettes are scoped variables. */
#talkAgentNavBtn[hidden], #talkAgentPage[hidden] { display: none !important; }
.talk-agent-page {
  --talk-canvas: #0f1727; --talk-panel: #172337; --talk-ink: #f8fbff;
  --talk-muted: #acb9cd; --talk-stroke: rgba(187,207,235,.18);
  --talk-accent: #ff6c9e; --talk-blue: #85b9fb; --talk-amber: #e8c27c; --talk-green: #78c5a6;
  --talk-glow: rgba(133,185,251,.0);
  isolation: isolate; position: relative; z-index: 2; min-height: 100vh;
  color: var(--talk-ink); padding: 84px clamp(16px, 4.5vw, 66px) 70px; /* clears the floating top bar */
}
html[data-theme="light"] .talk-agent-page { --talk-canvas:#f5f8ff; --talk-panel:#eaf0fb; --talk-ink:#101f38; --talk-muted:#3e526d; --talk-stroke:rgba(56,85,118,.20); --talk-accent:#d82f70; --talk-blue:#2166af; --talk-amber:#8a5a00; --talk-green:#1f7a55; }
.talk-agent-page * { box-sizing: border-box; }
.talk-agent-wrap { margin: 0 auto; width: min(1216px, 100%); }
.talk-agent-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.talk-agent-kicker { margin: 0 0 9px; color: var(--talk-blue); font-size: 11px; font-weight: 700; line-height: 1.3; letter-spacing: .17em; text-transform: uppercase; }
.talk-agent-heading h1 { margin: 0; font-weight: 750; letter-spacing: -.05em; font-size: clamp(30px, 4vw, 50px); line-height: 1.07; }
.talk-agent-subtitle { color: var(--talk-muted); max-width: 60ch; margin: 11px 0 0; font-size: 14px; line-height: 1.6; }
.talk-agent-admin-chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border-radius: 999px; border: 1px solid var(--talk-stroke); color: var(--talk-muted); background: rgba(135,180,235,.07); font-size: 12px; white-space: nowrap; }
.talk-agent-layout { display: grid; grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.1fr); gap: clamp(14px, 2vw, 24px); align-items: stretch; }
.talk-agent-stage, .talk-agent-console { min-width: 0; border: 1px solid var(--talk-stroke); border-radius: 24px; overflow: hidden; background: var(--talk-canvas); box-shadow: 0 20px 54px rgba(0,0,0,.17); }
.talk-agent-stage { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.talk-agent-stage-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--talk-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 750; }
.talk-agent-statusbar { display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--talk-stroke); background: rgba(133,185,251,.06); color: var(--talk-ink); font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 650; }
.talk-agent-led { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--talk-green); box-shadow: 0 0 0 4px rgba(120,197,166,.14); }
.talk-agent-page[data-agent-state="listening"] .talk-agent-led { background: var(--talk-blue); box-shadow: 0 0 0 4px rgba(127,197,250,.18); animation: talk-agent-led 1.2s ease-in-out infinite; }
.talk-agent-page[data-agent-state="thinking"] .talk-agent-led { background: var(--talk-amber); box-shadow: 0 0 0 4px rgba(214,178,120,.18); animation: talk-agent-led .8s ease-in-out infinite; }
.talk-agent-page[data-agent-state="speaking"] .talk-agent-led { background: var(--talk-accent); box-shadow: 0 0 0 4px rgba(255,108,158,.18); }
@keyframes talk-agent-led { 50% { opacity: .35; } }
/* The stage: his face in a glowing ring that follows what he is doing. */
.talk-agent-portrait-wrap {
  position: relative; flex: 1; min-height: 300px; display: grid; place-items: center; align-content: center; gap: 14px; overflow: hidden; border-radius: 18px; padding: 22px 12px 18px;
  background: radial-gradient(ellipse at 50% 30%, #294e68 0%, #172d46 44%, #08111f 100%); border: 1px solid rgba(133,185,251,.12);
}
html[data-theme="light"] .talk-agent-portrait-wrap { background: radial-gradient(ellipse at 50% 30%, #dbe8fb 0%, #c3d5ef 48%, #a9bfdf 100%); }
.talk-agent-face-frame { position: relative; width: min(84%, 340px); aspect-ratio: 1; border-radius: 50%; }
.talk-agent-face-frame::before { content: ''; position: absolute; inset: -14px; border-radius: 50%; border: 1px solid rgba(133,185,251,.22); box-shadow: 0 0 0 0 var(--talk-glow); transition: box-shadow .5s, border-color .5s; }
.talk-agent-page[data-agent-state="listening"] .talk-agent-face-frame::before { --talk-glow: rgba(127,197,250,.28); border-color: rgba(127,197,250,.55); animation: talk-agent-ring 1.6s ease-in-out infinite; }
.talk-agent-page[data-agent-state="thinking"] .talk-agent-face-frame::before { border-color: rgba(232,194,124,.5); animation: talk-agent-ring 2.4s ease-in-out infinite; --talk-glow: rgba(232,194,124,.22); }
.talk-agent-page[data-agent-state="speaking"] .talk-agent-face-frame::before { border-color: rgba(255,108,158,.5); box-shadow: 0 0 0 8px rgba(255,108,158,.08), 0 0 44px rgba(255,108,158,.18); }
@keyframes talk-agent-ring { 0%, 100% { box-shadow: 0 0 0 0 var(--talk-glow); } 50% { box-shadow: 0 0 0 12px var(--talk-glow); } }
.talk-agent-portrait, .talk-agent-face { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid rgba(203,228,255,.35); box-shadow: 0 22px 60px rgba(0,0,0,.5); }
.talk-agent-portrait[hidden] { display: none; }
.talk-agent-face { opacity: 0; transition: opacity .35s ease; background: #0b1424; }
.talk-agent-has-face .talk-agent-face { opacity: 1; }
/* Sound bars while he speaks. */
.talk-agent-wave { display: flex; gap: 4px; align-items: center; height: 18px; opacity: 0; transition: opacity .25s; }
.talk-agent-wave i { width: 4px; height: 6px; border-radius: 3px; background: var(--talk-accent); }
.talk-agent-is-speaking .talk-agent-wave { opacity: 1; }
.talk-agent-is-speaking .talk-agent-wave i { animation: talk-agent-bar .9s ease-in-out infinite; }
.talk-agent-wave i:nth-child(2) { animation-delay: -.2s !important; } .talk-agent-wave i:nth-child(3) { animation-delay: -.45s !important; }
.talk-agent-wave i:nth-child(4) { animation-delay: -.1s !important; } .talk-agent-wave i:nth-child(5) { animation-delay: -.6s !important; }
@keyframes talk-agent-bar { 0%, 100% { height: 5px; } 50% { height: 18px; } }
.talk-agent-controls { display: flex; gap: 12px; justify-content: center; align-items: center; padding: 2px 0; }
.talk-agent-round { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--talk-stroke); background: var(--talk-panel); color: var(--talk-ink); cursor: pointer; transition: background .2s, border-color .2s, transform .15s; }
.talk-agent-round svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.talk-agent-round:hover:not(:disabled) { background: #294560; border-color: rgba(154,199,253,.5); }
html[data-theme="light"] .talk-agent-round:hover:not(:disabled) { background: #d9e5f7; }
.talk-agent-round:active:not(:disabled) { transform: scale(.96); }
.talk-agent-round#talkAgentVoiceButton:not(.is-on) .talk-agent-voice-waves { opacity: .2; }
.talk-agent-round:disabled { opacity: .36; cursor: not-allowed; }
.talk-agent-round-primary { width: 64px; height: 64px; background: var(--talk-accent); border-color: transparent; color: #15111e; box-shadow: 0 10px 28px rgba(255,108,158,.28); }
.talk-agent-round-primary svg { width: 26px; height: 26px; }
.talk-agent-round-primary:hover:not(:disabled) { background: #ff97bb; }
.talk-agent-round-primary { position: relative; }
.talk-agent-round-primary::after { content: ''; position: absolute; inset: -1px; border-radius: 50%; pointer-events: none; }
.talk-agent-round-primary.is-listening { background: var(--talk-blue); color: #08111f; }
.talk-agent-round-primary.is-listening::after { animation: talk-agent-pulse 1.3s ease-in-out infinite; }
@keyframes talk-agent-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(133,185,251,.45); } 50% { box-shadow: 0 0 0 12px rgba(133,185,251,0); } }
.talk-agent-notice { margin: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid rgba(232,194,124,.35); background: rgba(232,194,124,.1); color: var(--talk-amber); font-size: 12px; line-height: 1.5; text-align: center; }
.talk-agent-notice[hidden] { display: none; }
.talk-agent-console { display: flex; flex-direction: column; min-height: 580px; }
.talk-agent-console-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 22px 22px 16px; border-bottom: 1px solid var(--talk-stroke); }
.talk-agent-console-head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.talk-agent-console-head p { margin: 4px 0 0; font-size: 12px; color: var(--talk-muted); }
.talk-agent-small-button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--talk-stroke); background: transparent; color: var(--talk-muted); border-radius: 9px; padding: 8px 12px; font: inherit; font-size: 12px; cursor: pointer; }
.talk-agent-small-button:hover:not(:disabled) { background: rgba(143,187,240,.1); color: var(--talk-ink); }
.talk-agent-small-button:disabled { opacity: .4; cursor: default; }
.talk-agent-thread { flex: 1; min-height: 150px; max-height: 520px; overflow: auto; display: flex; flex-direction: column; gap: 16px; padding: 22px; overscroll-behavior: contain; }
.talk-agent-message { max-width: 86%; min-width: 0; align-self: flex-start; background: var(--talk-panel); border: 1px solid var(--talk-stroke); border-radius: 17px 17px 17px 4px; padding: 12px 15px; animation: talk-agent-in .25s ease-out; }
@keyframes talk-agent-in { from { opacity: 0; transform: translateY(6px); } }
.talk-agent-message strong { display: block; font-size: 11px; color: var(--talk-blue); margin-bottom: 6px; }
.talk-agent-message p { margin: 0; font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.talk-agent-message-user { align-self: flex-end; background: rgba(255,108,158,.13); border-color: rgba(255,108,158,.25); border-radius: 17px 17px 4px 17px; }
.talk-agent-message-user strong { color: #ff9dbd; }
html[data-theme="light"] .talk-agent-message-user { background: rgba(216,47,112,.09); }
html[data-theme="light"] .talk-agent-message-user strong { color: #ab235c; }
html[dir="rtl"] .talk-agent-message { border-radius: 17px 17px 4px 17px; }
html[dir="rtl"] .talk-agent-message-user { border-radius: 17px 17px 17px 4px; }
.talk-agent-ideas { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 20px 14px; }
.talk-agent-ideas button { border: 1px solid var(--talk-stroke); border-radius: 999px; background: rgba(133,185,251,.05); color: var(--talk-muted); font: inherit; font-size: 12px; padding: 8px 12px; cursor: pointer; }
.talk-agent-ideas button:hover { border-color: var(--talk-blue); color: var(--talk-ink); }
.talk-agent-compose { margin: 0 18px 18px; border: 1px solid var(--talk-stroke); border-radius: 15px; background: var(--talk-panel); padding: 10px; }
.talk-agent-compose:focus-within { border-color: var(--talk-blue); box-shadow: 0 0 0 3px rgba(133,185,251,.12); }
.talk-agent-compose textarea { width: 100%; min-height: 64px; padding: 6px; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--talk-ink); font: inherit; font-size: 14px; line-height: 1.55; }
.talk-agent-compose textarea::placeholder { color: var(--talk-muted); }
.talk-agent-compose-bottom { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.talk-agent-submit { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 10px 15px; background: var(--talk-accent); color: #1b1018; font: inherit; font-size: 12.5px; font-weight: 750; cursor: pointer; }
html[data-theme="light"] .talk-agent-round-primary, html[data-theme="light"] .talk-agent-submit { color: #fff; }
.talk-agent-submit:disabled { opacity: .4; cursor: not-allowed; }
.talk-agent-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 0; padding: 17px 0; border-top: 1px solid var(--talk-stroke); }
.talk-agent-small-button:focus-visible, .talk-agent-round:focus-visible, .talk-agent-submit:focus-visible, .talk-agent-ideas button:focus-visible, #talkAgentNavBtn:focus-visible, .talk-agent-compose textarea:focus-visible { outline: 3px solid var(--talk-blue); outline-offset: 2px; }
/* BaseHeart's page-wide button reset (styles.css: every button transparent, no
   border colour or shadow, white text on hover, a pink rail when pressed, all
   !important) must not reach these controls, or the microphone, Send and the
   conversation starters vanish. The id outranks it in every state. */
#talkAgentPage button { filter: none !important; }
#talkAgentPage .talk-agent-round { background: var(--talk-panel) !important; border-color: var(--talk-stroke) !important; color: var(--talk-ink) !important; box-shadow: none !important; }
#talkAgentPage .talk-agent-round:hover:not(:disabled) { background: #294560 !important; border-color: rgba(154,199,253,.5) !important; }
html[data-theme="light"] #talkAgentPage .talk-agent-round:hover:not(:disabled) { background: #d9e5f7 !important; }
#talkAgentPage .talk-agent-round-primary { background: var(--talk-accent) !important; border-color: transparent !important; color: #15111e !important; box-shadow: 0 10px 28px rgba(255,108,158,.28) !important; }
#talkAgentPage .talk-agent-round-primary:hover:not(:disabled) { background: #ff97bb !important; border-color: transparent !important; }
#talkAgentPage .talk-agent-round-primary.is-listening { background: var(--talk-blue) !important; color: #08111f !important; }
#talkAgentPage .talk-agent-small-button { background: transparent !important; border-color: var(--talk-stroke) !important; color: var(--talk-muted) !important; box-shadow: none !important; }
#talkAgentPage .talk-agent-small-button:hover:not(:disabled) { background: rgba(143,187,240,.1) !important; color: var(--talk-ink) !important; }
#talkAgentPage .talk-agent-ideas button { background: rgba(133,185,251,.05) !important; border-color: var(--talk-stroke) !important; color: var(--talk-muted) !important; box-shadow: none !important; }
#talkAgentPage .talk-agent-ideas button:hover { background: rgba(133,185,251,.1) !important; border-color: var(--talk-blue) !important; color: var(--talk-ink) !important; }
#talkAgentPage .talk-agent-submit { background: var(--talk-accent) !important; color: #1b1018 !important; box-shadow: none !important; }
#talkAgentPage .talk-agent-submit:hover:not(:disabled) { background: #ff97bb !important; }
html[data-theme="light"] #talkAgentPage .talk-agent-round-primary, html[data-theme="light"] #talkAgentPage .talk-agent-submit { color: #fff !important; }
html[data-theme="light"] #talkAgentPage .talk-agent-round-primary:hover:not(:disabled), html[data-theme="light"] #talkAgentPage .talk-agent-submit:hover:not(:disabled) { background: #b9245d !important; }
#talkAgentPage button:focus-visible { outline: 3px solid var(--talk-blue) !important; outline-offset: 2px !important; }
/* The message box shows focus on its frame (.talk-agent-compose:focus-within), not with the app's field rail. */
#talkAgentPage .talk-agent-compose textarea, #talkAgentPage .talk-agent-compose textarea:focus-visible { background: transparent !important; border-color: transparent !important; box-shadow: none !important; outline: 0 !important; }
@media (max-width: 980px) { .talk-agent-layout { grid-template-columns: 1fr; } .talk-agent-console { min-height: 480px; } }
@media (max-width: 620px) {
  .talk-agent-page { padding: 74px 13px 60px; }
  .talk-agent-heading { flex-direction: column; gap: 12px; }
  .talk-agent-admin-chip { align-self: flex-start; }
  .talk-agent-stage, .talk-agent-console { border-radius: 18px; }
  .talk-agent-portrait-wrap { min-height: 0; padding: 18px 10px 14px; }
  .talk-agent-face-frame { width: min(76vw, 300px); }
  .talk-agent-stage-top { flex-wrap: wrap; }
  .talk-agent-thread { padding: 16px; max-height: 420px; }
  .talk-agent-compose { margin: 0 12px 12px; }
  .talk-agent-ideas { padding: 0 12px 12px; }
}
@media (forced-colors: active) { #talkAgentPage .talk-agent-round, #talkAgentPage .talk-agent-submit, #talkAgentPage .talk-agent-ideas button { border: 1px solid ButtonText !important; } .talk-agent-round, .talk-agent-statusbar, .talk-agent-notice, .talk-agent-message { border: 1px solid CanvasText; } }
@media (prefers-reduced-motion: reduce) {
  .talk-agent-page *, .talk-agent-page *::before, .talk-agent-page *::after { animation: none !important; transition: none !important; }
}
