/* ==========================================================================
   css/d2/ai.css -- owner D2-AI. Design 2 for the AI helper (DESIGN-2 7.6: the launcher and the chat sheet, the
   /pomocnik page) and the mascot pages (7.10: 404, error; 7.8 form cards: notice, launch list, first run, notify, push).
   Loaded only under the look row (body.rf): by the launcher partial on every page that carries it, and by those pages.
   Tokens are d2.css's (--d2-*); the only new shades are --ai-me (night bubble), --ai-field-edge and --ai-meter (contrast-checked,
   READY-D2-AI). No backdrop-filter, no blur.
   ========================================================================== */

/* night: the visitor's bubble is a lifted surface (the tray is nearly the page there) */
/* night: inputs get a visible edge (the tray ring alone is ~1.1:1 on the night surface) */
body.rf{--ai-me:var(--d2-tray);--ai-me-edge:none;--ai-field-edge:inset 0 0 0 1px #8F877E;--ai-meter:var(--d2-save-ink)}
@media (prefers-color-scheme: dark){body.rf:not(:where([data-theme="light"] *)){--ai-me:#2B1B22;--ai-me-edge:inset 0 0 0 1px rgba(255,255,255,.08);--ai-field-edge:inset 0 0 0 1px #7E6A73;--ai-meter:#4ADE80}}
body.rf:where([data-theme="dark"] *){--ai-me:#2B1B22;--ai-me-edge:inset 0 0 0 1px rgba(255,255,255,.08);--ai-field-edge:inset 0 0 0 1px #7E6A73;--ai-meter:#4ADE80}

/* ---- the launcher: the mascot's visnja disc, 56 px, above the tab bar on phones (d2.css moves it to 90 px) ---- */
body.rf .ai-launcher{right:16px}
@media (min-width:640px){body.rf .ai-launcher{right:24px;bottom:24px}}
body.rf .ai-launcher__btn{background:none;box-shadow:0 12px 28px -12px rgba(22,19,15,.55)}
body.rf .ai-launcher__btn:hover{background:none}
body.rf .ai-launcher__btn:focus-visible{outline:3px solid var(--d2-focus);outline-offset:2px}

/* ---- the sheet ---- */
body.rf .ai-chat__scrim{background:rgba(22,19,15,.48)}
body.rf .ai-chat__sheet{width:min(420px,calc(100vw - 48px));right:24px;bottom:24px;max-height:min(680px,calc(100vh - 48px));
  border:0;border-radius:var(--d2-r-ring);background:var(--d2-surface);box-shadow:var(--d2-edge),0 24px 48px -18px rgba(22,19,15,.45)}
@media (max-width:639px){
  body.rf .ai-chat__sheet{left:0;right:0;bottom:0;width:100%;max-height:86vh;max-height:86dvh;border-radius:var(--d2-r-ring) var(--d2-r-ring) 0 0}
  body.rf .ai-chat__sheet::before{content:"";align-self:center;flex:none;width:40px;height:5px;margin:8px 0 -4px;border-radius:999px;background:var(--d2-line)}
}
@media (prefers-reduced-motion:no-preference){
  body.rf .ai-chat.is-open .ai-chat__sheet{animation:ai-d2-up var(--d2-sheet) var(--d2-ease)}
}
@media (prefers-reduced-motion:reduce){body.rf .ai-chat.is-open .ai-chat__sheet{animation:ai-d2-fade var(--d2-fade) linear}}
@keyframes ai-d2-up{from{transform:translateY(40px)}to{transform:none}}
@keyframes ai-d2-fade{from{opacity:0}to{opacity:1}}

/* header: avatar | title over the counter | "Novi razgovor" | close */
body.rf .ai-chat__head{display:grid;grid-template-columns:auto 1fr auto auto;grid-template-areas:"av t new x" "av m new x";
  align-items:center;column-gap:8px;padding:10px 10px 10px 14px;border-bottom:1px solid var(--d2-line);background:var(--d2-surface)}
/* the night disc swaps in through <picture>; the picture adds no box of its own */
body.rf :is(.ai-launcher__btn,.ai-chat__head,.ai-chat__row)>picture{display:contents}
body.rf .ai-mascot--head{grid-area:av;width:38px;height:38px;display:inline-flex}
body.rf .ai-chat__title{grid-area:t;align-self:end;font-family:var(--sans);font-size:18px;font-weight:800;letter-spacing:-.02em;line-height:1.15;color:var(--d2-ink);white-space:nowrap}
body.rf .ai-chat__meter{grid-area:m;align-self:start;display:flex;align-items:center;gap:6px;margin:2px 0 0;font-size:12.5px;font-weight:700;color:var(--ai-meter);font-variant-numeric:tabular-nums}
body.rf .ai-chat__meter[hidden]{display:none}
body.rf .ai-chat__meter::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--d2-live);box-shadow:0 0 0 3px var(--d2-live-halo)}
body.rf .ai-chat__meter--plus::before{content:none}
body.rf .ai-chat__meter--out{color:var(--d2-muted)}
body.rf .ai-chat__meter--out::before{background:var(--d2-muted);box-shadow:none}
body.rf .ai-chat__plus{display:inline-flex;align-items:center;gap:5px;height:22px;padding:0 9px;border-radius:999px;background:var(--d2-dark);color:var(--d2-on-dark);font-size:12px;font-weight:800}
body.rf .ai-chat__plus::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--d2-cta)}
body.rf .ai-chat__head:not(:has(.ai-chat__meter:not([hidden]))) .ai-chat__title{grid-row:1 / span 2;align-self:center}
body.rf .ai-chat__new{grid-area:new;min-height:44px;padding:0 8px;border:0;border-radius:999px;background:none;color:var(--d2-accent);font:inherit;font-size:13.5px;font-weight:700;text-decoration:none;cursor:pointer}
body.rf .ai-chat__new:hover{background:var(--d2-tray);color:var(--d2-accent)}
body.rf .ai-chat__close{grid-area:x;margin:0;width:44px;height:44px;background:var(--d2-tray);color:var(--d2-ink)}
body.rf .ai-chat__close:hover{background:var(--d2-line);color:var(--d2-ink)}
body.rf :is(.ai-chat__new,.ai-chat__close,.ai-chat__example,.ai-chat__send--d2,.ai-chat__mic):focus-visible{outline:3px solid var(--d2-focus);outline-offset:2px}

/* the thread */
body.rf .ai-chat__body{padding:18px 16px;gap:12px;background:var(--d2-bg)}
body.rf .ai-chat__row{gap:8px;align-items:flex-end}
body.rf .ai-mascot--avatar{width:24px;height:24px;margin-bottom:2px}
body.rf .ai-chat__bubble{max-width:86%;padding:11px 14px;border-radius:var(--d2-r-field);font-size:15px;line-height:1.45;font-weight:500}
body.rf .ai-chat__bubble--bot{border:0;background:var(--d2-surface);color:var(--d2-ink);box-shadow:inset 0 0 0 1px var(--d2-line);border-bottom-left-radius:6px}
body.rf .ai-chat__bubble--me{background:var(--ai-me);color:var(--d2-ink);box-shadow:var(--ai-me-edge);border-bottom-right-radius:6px}
body.rf .ai-chat__bubble.fine{font-size:14.5px;color:var(--d2-ink-2)}
body.rf .ai-chat__row--bot:has(.ai-fact) .ai-chat__bubble{max-width:calc(100% - 32px);flex:1}

/* suggestion chips: the d2 chip (36 px pill, 44 px tap), wrapping, never a sideways scroll */
body.rf .ai-chat__examples{display:flex;flex-wrap:wrap;gap:8px;padding-left:32px}
body.rf .ai-chat__examples--follow{margin-top:8px}
body.rf .ai-chat__example{display:inline-flex;align-items:center;width:auto;min-height:44px;padding:0 16px;border:0;border-radius:999px;background:var(--d2-surface);
  color:var(--d2-ink);font-size:14px;font-weight:600;text-align:left;box-shadow:inset 0 0 0 1px var(--d2-line),0 1px 0 var(--d2-line)}
body.rf .ai-chat__example:hover{color:var(--d2-ink);box-shadow:inset 0 0 0 1px var(--d2-muted)}

/* typing: the thinking pose + three dots */
body.rf .ai-chat__wait{display:flex;align-items:center;gap:8px;color:var(--d2-muted)}
body.rf .ai-chat__row:has(.ai-chat__wait) .ai-mascot--avatar{width:28px;height:28px}
body.rf .ai-chat__dots i{width:6px;height:6px;background:var(--d2-accent)}
@media (prefers-reduced-motion:reduce){body.rf .ai-chat__dots i{animation:none}}

/* the answer: sentence, credit, product rows, report */
body.rf .ai-chat__answer{gap:6px}
body.rf .ai-chat__answer .ai-app-text p,body.rf .ai-chat__answer .ai-app-text{margin:0}
body.rf .ai-credit{margin:0;font-size:12.5px;color:var(--d2-muted)}
body.rf .ai-chat__bubble .ai-facts{margin-top:6px;font-size:inherit}
body.rf .ai-facts__cap{margin:0;font-size:12.5px;font-weight:600;color:var(--d2-muted)}

/* one product row (the chat and the page share it): picture | name, shop · date, the 30-day note, proof | price */
body.rf .ai-fact--d2{display:grid;grid-template-columns:auto 1fr auto;align-items:start;column-gap:10px;min-height:72px;padding:10px 0 0;border-top:1px solid var(--d2-line)}
body.rf .ai-fact--d2:first-of-type{border-top:0}
body.rf .ai-fact--d2 .d2-pv{margin-top:2px}
body.rf .ai-fact__main{display:grid;gap:2px;min-width:0}
body.rf .ai-fact--d2 .ai-fact__name{display:inline-flex;align-items:center;justify-self:start;min-height:44px;margin:-10px 0 -4px;font-size:14.5px;font-weight:700;line-height:1.3;color:var(--d2-ink);text-decoration:none}
body.rf .ai-fact--d2 .ai-fact__name:hover{color:var(--d2-accent);text-decoration:underline}
body.rf .ai-fact--d2 .ai-fact__meta{margin:0;font-size:12.5px;font-weight:500;line-height:1.35;color:var(--d2-muted)}
body.rf .ai-fact__low30{margin:2px 0 0;font-size:13.5px;font-weight:600;line-height:1.35;color:var(--d2-low30)}
body.rf .ai-fact--d2 .d2-proof{margin:-4px 0 0}
body.rf .ai-fact--d2 .ai-fact__price{padding-top:3px;font-size:17px;color:var(--d2-ink)}

body.rf .ai-chat__report-toggle{min-height:44px;font-size:13px;color:var(--d2-muted)}
body.rf .ai-chat__report-reasons .btn,body.rf .ai-report__f .d2-btn{min-height:44px;padding:0 14px;font-size:13.5px}

/* signed out / not paid inside the thread: a plain sentence and the d2 primary pill, not a notice box */
body.rf .ai-chat__prompt{display:grid;gap:10px;padding:0;border:0;background:none;color:var(--d2-ink)}
body.rf .ai-chat__prompt .notice__text{margin:0;font-size:15px}
body.rf .ai-chat__prompt .btn{justify-self:start;min-height:48px;padding:0 22px;border:0;border-radius:999px;background:var(--d2-cta);color:#fff;font-size:14.5px;font-weight:800;box-shadow:none}

/* the AI Act notice: muted, readable */
body.rf .ai-chat__notice{padding:8px 18px;border-top:1px solid var(--d2-line);background:var(--d2-surface);color:var(--d2-muted);font-size:12.5px;line-height:1.4}
body.rf .ai-chat__notice-more{display:inline-flex;align-items:center;justify-content:center;min-height:44px;min-width:44px;color:var(--d2-ink-2);font-weight:700}

/* the input: the search tray (6 px ring r26 around a white field r20) with the round visnja send */
body.rf .ai-chat__form{gap:6px;align-items:flex-end;margin:0 12px 12px;padding:6px;border:0;border-radius:var(--d2-r-tray);background:var(--d2-tray);box-shadow:var(--d2-edge)}
body.rf .ai-chat__sheet>.ai-chat__form{margin-top:10px}
body.rf .ai-chat__input{min-height:52px;padding:14px 16px;border:0;border-radius:var(--d2-r-field);background:var(--d2-surface);color:var(--d2-ink);font-size:16px;line-height:1.5;box-shadow:var(--ai-field-edge)}
body.rf .ai-chat__input::placeholder{color:var(--d2-muted)}
body.rf .ai-chat__input:focus-visible{outline:3px solid var(--d2-focus);outline-offset:2px}
body.rf .ai-chat__mic{width:44px;height:44px;margin-bottom:4px;border:0;background:var(--d2-surface);color:var(--d2-ink);box-shadow:inset 0 0 0 1px var(--d2-line)}
body.rf .ai-chat__send--d2{display:grid;place-items:center;flex:none;width:44px;height:44px;margin:0 4px 4px 0;padding:0;border:0;border-radius:50%;background:var(--d2-cta);color:#fff;cursor:pointer}
body.rf .ai-chat__send--d2:disabled{opacity:.4;cursor:default}
body.rf .ai-chat__send--d2 .icon{width:20px;height:20px}


/* ==== the /pomocnik page ================================================= */
body.rf .ai-page{display:grid;gap:16px;max-width:720px;margin:0 auto;padding:12px 0 32px}
body.rf .ai-page__head{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:6px 14px;margin-bottom:6px}
body.rf .ai-page__head .ai-page__lead{grid-column:1 / -1}
body.rf .ai-page__head .ai-pose img{width:72px;height:72px}
body.rf .ai-page__lead{margin:10px 0 0;font-size:15px;line-height:1.5;font-weight:500;color:var(--d2-ink-2)}
body.rf .ai-pose{display:block;flex:none}
body.rf .ai-pose img{display:block}
body.rf .ai-card{display:grid;gap:14px;padding:20px;border-radius:var(--d2-r-card);background:var(--d2-surface);box-shadow:var(--d2-shadow),var(--d2-edge)}
body.rf .ai-card--center{justify-items:center;text-align:center;padding:28px 20px}
body.rf .ai-card__say{margin:0;max-width:40ch;font-size:17px;font-weight:700;line-height:1.35;color:var(--d2-ink)}
body.rf .ai-meter--pill{justify-self:start;display:inline-flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0;padding:8px 14px;border-radius:999px;
  background:var(--d2-save-bg);color:var(--d2-save-ink);font-size:13.5px;font-weight:700;line-height:1.3}
body.rf .ai-ask{display:grid;gap:8px}
body.rf .ai-ask__label{font-size:14.5px;font-weight:700;color:var(--d2-ink)}
body.rf .ai-ask__tray{display:flex;align-items:flex-end;gap:6px;padding:6px;border-radius:var(--d2-r-tray);background:var(--d2-tray)}
body.rf .ai-ask__field{flex:1;min-width:0;min-height:104px;padding:14px 16px;border:0;border-radius:var(--d2-r-field);background:var(--d2-surface);color:var(--d2-ink);
  font:inherit;font-size:16px;line-height:1.5;resize:vertical;box-shadow:var(--ai-field-edge)}
body.rf .ai-ask__field::placeholder{color:var(--d2-muted)}
body.rf .ai-ask__field:focus-visible,body.rf .ai-ask__send:focus-visible{outline:3px solid var(--d2-focus);outline-offset:2px}
body.rf .ai-ask__send{display:grid;place-items:center;flex:none;width:48px;height:48px;margin:0 4px 4px 0;border:0;border-radius:50%;background:var(--d2-cta);color:#fff;cursor:pointer}
body.rf .ai-notice{margin:0;font-size:12.5px;line-height:1.45;color:var(--d2-muted)}
body.rf .ai-msg{display:flex;align-items:flex-end;gap:10px}
body.rf .ai-msg .ai-pose img{width:40px;height:40px}
body.rf .ai-msg__bubble{flex:0 1 auto;max-width:calc(100% - 50px);margin:0;padding:14px 16px;border-radius:var(--d2-r-field);border-bottom-left-radius:6px;background:var(--d2-surface);
  color:var(--d2-ink);font-size:15px;line-height:1.5;box-shadow:inset 0 0 0 1px var(--d2-line)}
body.rf div.ai-msg__bubble{flex:1;display:grid;gap:8px}
body.rf .ai-msg__bubble p{margin:0}
body.rf .ai-msg--me{justify-content:flex-end}
body.rf .ai-msg--me .ai-msg__bubble{background:var(--ai-me);box-shadow:var(--ai-me-edge);border-bottom-left-radius:var(--d2-r-field);border-bottom-right-radius:6px}
body.rf .ai-facts__t{margin:6px 0 0;font-size:12.5px;font-weight:600;color:var(--d2-muted)}
body.rf .ai-facts--d2{margin:0;padding:0;list-style:none}
body.rf .ai-report summary{display:inline-flex;align-items:center;min-height:44px;font-size:13px;color:var(--d2-muted);cursor:pointer}
body.rf .ai-report__f{display:flex;flex-wrap:wrap;gap:8px}


/* ==== 404 / error: mascot, headline, one sentence, the action ============ */
body.rf .ai-lost{display:grid;justify-items:center;gap:14px;padding-top:18px;padding-bottom:8px;text-align:center}
body.rf .ai-lost .ai-pose img{width:132px;height:132px}
body.rf .ai-lost .d2-h1{max-width:16ch}
body.rf .ai-lost__p{margin:0;max-width:42ch;font-size:15px;line-height:1.5;color:var(--d2-ink-2)}
body.rf .ai-lost .d2-tray{width:100%;max-width:560px;margin-top:6px;text-align:left}
body.rf .ai-lost .d2-chips{justify-content:center}
body.rf .ai-lost--error{padding:32px 0 16px}
body.rf .ai-lost__more{margin-top:var(--d2-gap)}
body.rf .ai-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin:22px 0 0}


/* ==== form pages (notice, launch list, first run, notify, push): form cards on white r22, 52 px inputs r16 in trays ==== */
body.rf.d2-form .page-title,body.rf.d2-form .acct-narrow h1{font-family:var(--sans);font-size:34px;font-weight:800;line-height:1.05;letter-spacing:-.035em;color:var(--d2-ink)}
body.rf.d2-form main h2{font-family:var(--sans);font-size:21px;font-weight:800;line-height:1.15;letter-spacing:-.025em;color:var(--d2-ink)}
body.rf.d2-form .lead{font-size:15px;line-height:1.5;color:var(--d2-ink-2)}
body.rf.d2-form .panel{border:0;border-radius:var(--d2-r-card);background:var(--d2-surface);box-shadow:var(--d2-shadow),var(--d2-edge)}
body.rf.d2-form .panel--pad{padding:20px}
body.rf.d2-form .field__label{font-size:14.5px;font-weight:700;color:var(--d2-ink)}
body.rf.d2-form .field__control{min-height:64px;padding:12px 16px;border:6px solid var(--d2-tray);border-radius:22px;background:var(--d2-surface);background-clip:padding-box;color:var(--d2-ink);font-size:16px;box-shadow:var(--ai-field-edge)}
body.rf.d2-form textarea.field__control{min-height:140px}
body.rf.d2-form select.field__control{padding-right:40px}
body.rf.d2-form .field__control:focus-visible{outline:3px solid var(--d2-focus);outline-offset:2px;border-color:var(--d2-tray)}
body.rf.d2-form .check{display:flex;align-items:center;gap:12px;min-height:44px}
body.rf.d2-form .check input{width:22px;height:22px;accent-color:var(--d2-cta)}
body.rf.d2-form fieldset{margin:0;padding:0;border:0}
body.rf.d2-form legend{font-size:13.5px;font-weight:700;color:var(--d2-ink-2)}
body.rf.d2-form .fine{font-size:12.5px;color:var(--d2-muted)}
body.rf.d2-form .btn{min-height:48px;padding:0 22px;border-radius:999px;font-size:14.5px;font-weight:800}
body.rf.d2-form .btn--sm{min-height:44px;padding:0 18px;font-size:13.5px}
body.rf.d2-form .btn--primary{border:0;background:var(--d2-cta);color:#fff}
body.rf.d2-form .btn--secondary{border:0;background:var(--d2-surface);color:var(--d2-ink);box-shadow:inset 0 0 0 1px var(--d2-line),0 1px 0 var(--d2-line)}
body.rf.d2-form .btn--ghost{min-height:44px;border:0;background:none;color:var(--d2-accent)}
body.rf.d2-form .notice{border:0;border-radius:var(--d2-r-card);background:var(--d2-surface);box-shadow:var(--d2-shadow),var(--d2-edge)}
body.rf.d2-form .notice--success{background:var(--d2-save-bg);color:var(--d2-save-ink);box-shadow:none}
body.rf.d2-form .notice--success :is(.notice__title,.notice__text){color:var(--d2-save-ink)}
body.rf.d2-form .ai-pose--top{width:fit-content;margin:18px 0 4px}
body.rf.d2-form .acct-narrow>section{margin-top:var(--d2-gap)}
body.rf.d2-form .acct-narrow>section>h2{margin:0 0 4px}
body.rf.d2-form .ai-pose--top img{width:120px;height:120px}
body.rf.d2-form [data-notice]{display:grid;gap:4px}
body.rf.d2-form [data-notice] p{margin:0}
body.rf.d2-form [data-unread][data-notice]{box-shadow:inset 4px 0 0 var(--d2-cta),var(--d2-shadow),var(--d2-edge)}
