/* Yental AI · how the assistant looks (25 Nov 2026). One assistant on screen, chosen in Settings → General:
     body.ya-mode-chat   the chat bar at the bottom (opens into the chat)
     body.ya-mode-voice  the voice orb as before; the chat panel appears only when something has to be read or confirmed
   With either one the property / unit / asset pager sits at the top.
   Garnet tokens come from the dashboard's own #garnet-accent block. */
:root { --ya-shell:#F7F7F8; --ya-cell:#FFFFFF; --ya-line:#EBEBED; --ya-ink:#1D1D1F; --ya-sub:#6E6E73; --ya-chip:#F2F2F4;
    --ya-shadow:0 24px 60px -18px rgba(20,10,14,.30), 0 6px 18px -10px rgba(20,10,14,.20); }
html.dark { --ya-shell:#222225; --ya-cell:#151517; --ya-line:#2B2B2E; --ya-ink:#F5F5F7; --ya-sub:#9A9AA0; --ya-chip:#232326; --ya-shadow:0 26px 70px -16px rgba(0,0,0,.75); }

/* ── the container ── */
#ai-chat-window { position:fixed; left:50%; bottom:16px; transform:translateX(-50%); width:min(280px, calc(100vw - 32px)); z-index:40;
    font-family:'Plus Jakarta Sans',system-ui,sans-serif; color:var(--ya-ink); transition:width .55s cubic-bezier(.2,.9,.25,1); }
#ai-chat-window, #ai-chat-window * { box-sizing:border-box; letter-spacing:-.015em; -webkit-font-smoothing:antialiased; }
#ai-chat-window.ya-listening:not(.ai-open) { width:min(460px, calc(100vw - 32px)); }
#ai-chat-window.ai-open { width:min(620px, calc(100vw - 32px)); z-index:50; }
#ai-chat-window .ya-shell { border:1.5px solid transparent; border-radius:18px; padding:4px; display:flex; flex-direction:column;
    background:linear-gradient(var(--ya-shell),var(--ya-shell)) padding-box, var(--garnet-ring) border-box;
    box-shadow:0 0 0 1px rgba(158,18,54,.10), 0 0 22px -6px var(--garnet-glow), var(--ya-shadow); }
#ai-chat-window .ya-panel { display:grid; grid-template-rows:0fr; opacity:0; visibility:hidden; transition:grid-template-rows .55s cubic-bezier(.2,.9,.25,1), opacity .3s, visibility 0s .55s; }
#ai-chat-window.ai-open .ya-panel { grid-template-rows:1fr; opacity:1; visibility:visible; transition:grid-template-rows .55s cubic-bezier(.2,.9,.25,1), opacity .3s; }
#ai-chat-window .ya-panel > div { overflow:hidden; min-height:0; display:flex; flex-direction:column; }

/* ── top bar (itself a close area, except the name and the buttons) ── */
#ai-chat-window .ya-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:5px 4px 7px 8px; cursor:pointer; }
#ai-chat-window .ya-who { display:flex; align-items:center; gap:10px; cursor:default; }
#ai-chat-window .ya-who h3 { margin:0; font-size:13.5px; font-weight:800; letter-spacing:-.04em; color:var(--garnet-ink); }
#ai-chat-window .ya-matrix { display:grid; grid-template-columns:repeat(8,4px); grid-auto-rows:4px; gap:2px; }
#ai-chat-window .ya-matrix i { border-radius:1px; background:var(--garnet); opacity:.14; }
#ai-chat-window .ya-sq { width:30px; height:30px; flex:none; border:0; border-radius:9px; background:none; display:grid; place-items:center; color:var(--ya-sub); cursor:pointer; padding:0; }
#ai-chat-window .ya-sq:hover { background:var(--garnet-soft); color:var(--garnet); }
#ai-chat-window .ya-sq i { font-size:12px; }

/* ── messages (the existing message markup, restyled) ── */
#ai-chat-window #ai-chat-history { flex:none; height:min(400px, calc(100dvh - 300px)); min-height:140px; overflow-y:auto; background:var(--ya-cell); border-radius:13px; padding:16px; margin-bottom:4px; scrollbar-width:thin; scrollbar-color:var(--garnet) transparent; }
#ai-chat-window #ai-chat-history::-webkit-scrollbar { display:block; width:4px; }
#ai-chat-window #ai-chat-history::-webkit-scrollbar-thumb { background:var(--garnet); border-radius:4px; }
#ai-chat-window #ai-chat-history > .flex.justify-end > div { background:var(--garnet-soft) !important; color:var(--garnet-ink) !important; border:0 !important; box-shadow:none !important; border-radius:10px 10px 4px 10px !important; font-size:13px; font-weight:600; line-height:1.5; max-width:80%; padding:9px 13px; }
#ai-chat-window #ai-chat-history > .flex.justify-start > .rounded-tl-sm:not([role="alertdialog"]) { background:transparent !important; border:0 !important; box-shadow:none !important; padding:2px 0 !important; max-width:94% !important; font-size:13.5px; font-weight:600; line-height:1.65; color:var(--ya-ink) !important; }
#ai-chat-window #ai-chat-history .ai-md { font-size:13.5px; font-weight:600; }
#ai-chat-window #ai-chat-history .ai-md strong { font-weight:800; }
#ai-chat-window #ai-chat-history > .aai-confirm-card, #ai-chat-window #ai-chat-history > .flex > .aai-confirm-card { flex:none; }

/* before the first message: a small window with the greeting; it grows with the first message */
#ai-chat-window #ai-chat-history { transition:height .55s cubic-bezier(.2,.9,.25,1); }
#ai-chat-window.ai-open.ya-fresh { width:min(460px, calc(100vw - 32px)); }
body #ai-chat-window.ai-open.ya-fresh #ai-chat-history { height:60px; min-height:0; }

/* ── quick questions ── (the plan / credits line is not shown here: it lives in Settings → Usage & Plan Limits) */
#ai-chat-window #ai-quick-actions { display:flex; flex-wrap:nowrap; gap:6px; overflow-x:auto; padding:2px 4px 6px; border:0; background:transparent; scrollbar-width:none; }
#ai-chat-window #ai-quick-actions:empty { display:none; }
#ai-chat-window #ai-quick-actions button { white-space:nowrap; flex:1 0 auto; text-align:center; font-size:11px !important; font-weight:700 !important; color:var(--ya-sub) !important; background:var(--ya-cell) !important; border:0; border-radius:999px; padding:6px 12px; cursor:pointer; }
#ai-chat-window #ai-quick-actions button:hover { color:var(--garnet-ink) !important; box-shadow:inset 0 0 0 1px var(--garnet); }
#ai-chat-window #ai-usage-line { display:none; }

/* ── the bar ── */
#ai-chat-window .ya-bar { display:flex; gap:4px; align-items:stretch; }
#ai-chat-window .ya-field, #ai-chat-window .ya-listen { flex:1; min-width:0; display:flex; align-items:center; gap:2px; background:var(--ya-cell); border-radius:13px; height:46px; margin:0; }
#ai-chat-window .ya-field { padding:0 4px 0 14px; }
#ai-chat-window .ya-field:focus-within { box-shadow:inset 0 0 0 1.5px var(--garnet); }
#ai-chat-window #ai-chat-input { flex:1; min-width:0; width:100%; height:46px; background:none; border:0; outline:0 !important; box-shadow:none !important; font-family:inherit; font-size:13px; font-weight:600; color:var(--ya-ink); padding:0; }
#ai-chat-window #ai-chat-input::placeholder { color:var(--ya-sub); font-weight:600; }
#ai-chat-window .ya-field .ya-sq:focus-visible, #ai-chat-window .ya-sq:focus-visible, #ai-chat-window #ai-send-btn:focus-visible { outline:2px solid var(--garnet); outline-offset:1px; }
#ai-chat-window #ai-send-btn { width:46px; flex:none; border:0; border-radius:13px; display:grid; place-items:center; cursor:pointer; color:#fff; background:var(--garnet-btn); box-shadow:0 8px 18px -10px rgba(138,18,56,.65), inset 0 1px 0 rgba(255,255,255,.22); }
#ai-chat-window #ai-send-btn:hover { background:var(--garnet-btn-h); }

/* ── dictation: your words while you speak, a frequency bar while you are quiet ── */
#ai-chat-window .ya-listen { display:none; padding:0 4px; box-shadow:inset 0 0 0 1.5px var(--garnet); }
#ai-chat-window.ya-listening .ya-field { display:none; }
#ai-chat-window.ya-listening .ya-listen { display:flex; }
#ai-chat-window .ya-stage { flex:1; min-width:0; height:46px; position:relative; }
#ai-chat-window .ya-wave { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; gap:2.5px; transition:opacity .18s; }
#ai-chat-window .ya-wave i { width:2.5px; height:3px; border-radius:3px; background:var(--garnet); transition:height .09s linear; }
#ai-chat-window .ya-said { position:absolute; inset:0; display:flex; align-items:center; justify-content:flex-end; overflow:hidden; white-space:nowrap; font-size:13px; font-weight:600; opacity:0; transition:opacity .18s; -webkit-mask-image:linear-gradient(90deg,transparent,#000 28px); mask-image:linear-gradient(90deg,transparent,#000 28px); }
#ai-chat-window .ya-said span { margin-right:auto; flex:none; padding-left:6px; }
#ai-chat-window .ya-listen.ya-talking .ya-wave { opacity:0; }
#ai-chat-window .ya-listen.ya-talking .ya-said { opacity:1; }
#ai-chat-window .ya-listen .ya-ok { color:var(--garnet); background:var(--garnet-soft); }

/* ── focus: while the chat is open, or the orb is in a conversation, everything behind is blurred except the main rail ── */
#ya-veil { position:fixed; inset:0; z-index:49; background:rgba(245,245,247,.42); -webkit-backdrop-filter:blur(14px) saturate(.9); backdrop-filter:blur(14px) saturate(.9); opacity:0; visibility:hidden; transition:opacity .4s ease, visibility 0s .4s; }
html.dark #ya-veil { background:rgba(6,6,8,.55); }
body.ya-open #ya-veil, body.ya-voice-busy #ya-veil { opacity:1; visibility:visible; transition:opacity .4s ease; }
body.ya-open #left-sidebar, body.ya-voice-busy #left-sidebar { position:relative; z-index:51 !important; }
body.ya-voice-busy #voice-orb-wrap { z-index:50 !important; }

/* ── the two modes ── */
body.ya-mode-chat #voice-orb-wrap { display:none !important; }
body.ya-mode-voice #ai-chat-window:not(.ai-open) { visibility:hidden; pointer-events:none; }
body.ya-mode-voice #ai-chat-window.ai-open { bottom:108px; }
body.ya-mode-voice #ai-chat-window.ai-open #ai-chat-history { height:min(360px, calc(100dvh - 400px)); }

/* ── property / unit / asset pager and position counter: always at the top ── */
@media (min-width:769px) {
    body #ysk .dock { bottom:auto !important; top:var(--ya-pager-top, 19vh) !important; }
    body #nav-counter { bottom:auto !important; top:calc(var(--ya-pager-top, 19vh) + 52px) !important; }
}

/* ── Settings → General → Yental AI assistant ── */
.ya-grp { border:1px solid rgba(128,128,128,.22); border-radius:14px; padding:14px 14px 2px; margin-bottom:12px; }
.ya-grp.on { border-color:var(--garnet); box-shadow:inset 0 0 0 1px var(--garnet-halo); }
.ya-grp-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.ya-grp-head .set-label { font-size:13.5px; }
.ya-grp.off .ya-grp-body { opacity:.45; }
.ya-grp .conn-switch[aria-checked="true"] .conn-switch-track { background:var(--garnet-btn) !important; }

/* ── phones: no resting bar over the bottom navigation; the chat opens above it from the AI button ── */
@media (max-width:768px) {
    #ya-veil { z-index:49; }
    body.ya-mode-chat #ai-chat-window:not(.ai-open) { visibility:hidden; pointer-events:none; }
    #ai-chat-window.ai-open, body.ya-mode-voice #ai-chat-window.ai-open { left:.5rem; right:.5rem; width:auto; transform:none; bottom:5.25rem; }
    #ai-chat-window #ai-chat-history { height:min(50dvh, 360px); }
    body #ai-chat-window.ai-open.ya-fresh { width:auto; }
    body #ai-chat-window.ai-open.ya-fresh #ai-chat-history { height:auto; }
    #ai-chat-window #ai-chat-input { font-size:16px; }
}
@media (prefers-reduced-motion:reduce) { #ai-chat-window, #ai-chat-window *, #ya-veil { transition:none !important; animation:none !important; } }
