/* Egen kod, idé från affectUI AI Answer (Pro), ingen kod tagen */
#c-b-ai-answer {
  --nai-ink: rgba(0,0,0,.88); --nai-text: rgba(0,0,0,.61);   --nai-line: rgba(0,0,0,.06); --nai-wash: rgba(0,0,0,.03); --nai-fill: rgba(0,0,0,.06);
  --nai-ember: #D9601C; --nai-ember-tint: rgba(217,96,28,.10); --nai-ok: #1E7A4C;
  --nai-shadow: 0 0 0 .5px rgba(0,0,0,.06), 0 1px 1px -1px rgba(0,0,0,.1), 0 1px 2px 0 rgba(0,0,0,.05);
  --nai-pop: 0 0 0 .5px rgba(0,0,0,.08), 0 12px 28px -10px rgba(0,0,0,.18), 0 1px 2px 0 rgba(0,0,0,.05);
  --nai-ease: cubic-bezier(.22,1,.36,1);
  width: 100%; max-width: 100%; contain: inline-size; font-family: var(--sans); font-size: 13px; line-height: 20px; color: var(--nai-ink);
  -webkit-font-smoothing: antialiased;
  --nai-card: #fff; --nai-strong: #000; --nai-solid: rgba(0,0,0,.88); --nai-on-solid: #fcfcfc; --nai-raised: #FBFAF8; --nai-rgb: 0,0,0;
  --nai-ember-ink: #B4501A; --nai-del: #A3402C; --nai-warn-ink: #7A4B05; --nai-toast: rgba(0,0,0,.86);
  --nai-te-bg: #F7E3D6; --nai-te-fg: #9A4310; --nai-tg-bg: #DDEDE4; --nai-tg-fg: #1E6A44; --nai-tn-bg: #ECEBE8; --nai-ty-bg: #F3E6C9; --nai-ty-fg: #7A5410;
}

#c-b-ai-answer *, #c-b-ai-answer *::before, #c-b-ai-answer *::after { box-sizing: border-box; }
:where(#c-b-ai-answer) button { margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#c-b-ai-answer button:focus-visible { outline: 2px solid rgba(217,96,28,.4); outline-offset: 1px; }
#c-b-ai-answer svg { display: block; flex: none; }
.nai-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.nai-card { position: relative; background: var(--nai-card); border-radius: 10px; box-shadow: var(--nai-shadow); padding: 16px 16px 0; }
.nai-q { margin: 0 0 12px; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--nai-strong); letter-spacing: -.005em; text-wrap: pretty; }

/* Källkort: en rad som scrollar i sidled */
.nai-sources { display: flex; gap: 6px; margin: 0 -16px; padding: 2px 16px 4px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.nai-sources::-webkit-scrollbar { display: none; }
.nai-src { flex: none; width: 152px; scroll-snap-align: start; display: grid; gap: 2px; padding: 8px 10px 9px; border-radius: 8px; box-shadow: inset 0 0 0 .5px rgba(var(--nai-rgb),.1); text-align: left; transition: background-color 160ms ease, box-shadow 160ms ease, opacity 300ms ease, transform 300ms var(--nai-ease); }
.nai-src:hover, .nai-src[data-hot] { background: var(--nai-wash); box-shadow: inset 0 0 0 .5px rgba(var(--nai-rgb),.16); }
.nai-src[data-hot] { box-shadow: inset 0 0 0 1px rgba(217,96,28,.45); background: rgba(217,96,28,.05); }
.nai-src[data-wait] { opacity: 0; transform: translateY(4px); }
.nai-src-kind { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--grey); }
.nai-src-kind svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nai-src-n { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--grey); }
.nai-src-title { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--nai-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Status: Skriver / Klart */
.nai-status { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; font-size: 12px; line-height: 16px; color: var(--grey); }
.nai-spark svg { width: 14px; height: 14px; fill: var(--nai-ember); }
.nai-card[data-state="writing"] .nai-status-text { background: linear-gradient(90deg, var(--grey) 0 35%, rgba(var(--nai-rgb),.85) 50%, var(--grey) 65% 100%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: nai-shine 1.6s linear infinite; }
@keyframes nai-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Svaret */
.nai-body { min-height: 20px; color: var(--nai-ink); text-wrap: pretty; }
.nai-body p { margin: 0 0 8px; }
.nai-body ul { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 6px; }
.nai-body li { position: relative; padding-left: 14px; }
.nai-body li::before { content: ""; position: absolute; left: 3px; top: 9px; width: 4px; height: 4px; border-radius: 50%; background: var(--grey); }
.nai-body b { font-weight: 600; color: var(--nai-strong); }
.nai-w[data-new] { animation: nai-in 360ms ease both; }
@keyframes nai-in { from { opacity: 0; filter: blur(2px); } }
.nai-cite { display: inline-flex; align-items: center; gap: 3px; height: 18px; margin: 0 1px; padding: 0 6px; border-radius: 5px; vertical-align: 1px; background: var(--nai-fill); font-size: 12px; line-height: 18px; font-weight: 500; color: var(--nai-text); white-space: nowrap; transition: background-color 140ms ease, color 140ms ease; }
.nai-cite:hover, .nai-cite[aria-expanded="true"] { background: var(--nai-ember-tint); color: var(--nai-ember-ink); }
.nai-cite-more { color: var(--grey); font-weight: 400; }
.nai-cite[hidden], .nai-w[hidden] { display: none; }

/* Förhandsvisning av källan */
.nai-pop { position: absolute; z-index: 5; width: min(260px, calc(100% - 24px)); display: grid; gap: 2px; padding: 10px 12px 11px; border-radius: 10px; background: var(--nai-card); box-shadow: var(--nai-pop); pointer-events: none; animation: nai-pop 200ms var(--nai-ease) both; }
.nai-pop[hidden] { display: none; }
@keyframes nai-pop { from { opacity: 0; transform: translateY(3px); } }
.nai-pop-kind { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--grey); }
.nai-pop-kind svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nai-pop-title { font-weight: 500; }
.nai-pop-text { font-size: 12px; line-height: 18px; color: var(--nai-text); }
.nai-pop-text mark { background: rgba(217,96,28,.14); color: inherit; border-radius: 3px; padding: 0 2px; }

/* Fot: Stoppa eller åtgärder */
.nai-foot { display: flex; align-items: center; min-height: 44px; margin: 8px -16px 0; padding: 8px 10px; border-top: .5px solid var(--nai-line); }
.nai-stop { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: 6px; box-shadow: var(--nai-shadow); font-weight: 500; }
.nai-stop:hover { background: var(--nai-wash); }
.nai-stop[hidden], .nai-actions[hidden] { display: none; }
.nai-stop-sq { width: 8px; height: 8px; border-radius: 2px; background: var(--nai-ink); }
.nai-actions { display: flex; align-items: center; gap: 2px; width: 100%; }
.nai-act { position: relative; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: rgba(var(--nai-rgb), 0.58); transition: background-color 160ms ease, color 160ms ease; }
.nai-act:hover { background: var(--nai-wash); color: var(--nai-ink); }
.nai-act svg { grid-area: 1/1; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: opacity 200ms ease, transform 300ms var(--nai-ease); }
.nai-act .nai-ok { opacity: 0; transform: scale(.6); color: var(--nai-ok); stroke-width: 1.6; }
.nai-act[data-done] svg:first-child { opacity: 0; transform: scale(.6); }
.nai-act[data-done] .nai-ok { opacity: 1; transform: none; }
.nai-act--down svg { transform: scaleY(-1); }
.nai-act[aria-pressed="true"] { background: var(--nai-fill); color: var(--nai-ink); }
.nai-act[aria-pressed="true"] svg { fill: currentColor; fill-opacity: .14; }
.nai-act[data-spin] svg { animation: nai-spin 640ms var(--nai-ease); }
@keyframes nai-spin { to { transform: rotate(360deg); } }
.nai-meta { margin-left: auto; padding-right: 4px; font-size: 12px; line-height: 16px; color: var(--grey); font-variant-numeric: tabular-nums; white-space: nowrap; }

.nai-why { margin: 0 -16px; padding: 4px 16px 12px; animation: nai-in 260ms ease both; }
.nai-why[hidden] { display: none; }
.nai-why-ask { display: block; margin-bottom: 8px; font-weight: 500; }
.nai-why-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nai-chip { height: 28px; padding: 0 10px; border-radius: 6px; box-shadow: inset 0 0 0 .5px rgba(var(--nai-rgb),.12); font-weight: 500; color: var(--nai-text); transition: background-color 140ms ease, color 140ms ease; }
.nai-chip:hover { background: var(--nai-wash); color: var(--nai-ink); }
.nai-chip[aria-pressed="true"] { background: var(--nai-fill); color: var(--nai-ink); }
.nai-why[data-sent] .nai-why-ask { color: var(--nai-ok); }

.nai-follow { margin: 6px 0 0; animation: nai-in 260ms ease both; }
.nai-follow[hidden] { display: none; }
.nai-follow-head { display: block; padding-bottom: 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--grey); }
.nai-follow-list { display: grid; }
.nai-fq { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 8px 8px; margin: 0 -8px; border-radius: 6px; box-shadow: inset 0 .5px 0 var(--nai-line); text-align: left; color: var(--nai-ink); transition: background-color 140ms ease, color 140ms ease; }
.nai-fq:hover { background: var(--nai-wash); box-shadow: none; }
.nai-fq:hover svg { transform: translateX(2px); opacity: .9; }
.nai-fq:active { transform: scale(.985); }
.nai-fq svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .5; transition: transform 180ms var(--nai-ease), opacity 160ms ease; }
.nai-fq { transition: background-color 140ms ease, transform 140ms var(--nai-ease); }
.nai-fq:disabled { opacity: .45; cursor: default; }

@media (pointer: coarse) { .nai-act { width: 36px; height: 36px; } .nai-chip { height: 34px; } }
@media (prefers-reduced-motion: reduce) {
  #c-b-ai-answer *, #c-b-ai-answer *::before, #c-b-ai-answer *::after { animation: none !important; transition: none !important; }
  .nai-card[data-state="writing"] .nai-status-text { color: var(--grey); background: none; }
}

/* Mörkt läge, samma konvention som affectUI: data-theme="dark" eller .dark på en förälder */
:where(.dark, [data-theme="dark"]) #c-b-ai-answer {
  --nai-ink: rgba(255,255,255,.9); --nai-text: rgba(255,255,255,.64);   --nai-line: rgba(255,255,255,.08); --nai-wash: rgba(255,255,255,.04); --nai-fill: rgba(255,255,255,.08);
  --nai-card: #1C1B1A; --nai-strong: #fff; --nai-solid: rgba(255,255,255,.9); --nai-on-solid: #161615; --nai-raised: #232220; --nai-rgb: 255,255,255;
  --nai-ember-ink: #F08A4B; --nai-del: #FF8A73; --nai-warn-ink: #F0B232; --nai-ok: #3EC27A; --nai-toast: #2C2B29; --nai-wait: #F0B232;
  --nai-te-bg: rgba(217,96,28,.2); --nai-te-fg: #F5A06C; --nai-tg-bg: rgba(62,194,122,.15); --nai-tg-fg: #6FD49C; --nai-tn-bg: rgba(255,255,255,.1); --nai-ty-bg: rgba(240,178,50,.15); --nai-ty-fg: #F0B232;
  --nai-shadow: 0 0 0 .5px rgba(255,255,255,.1), 0 1px 2px rgba(0,0,0,.4);
  --nai-pop: 0 0 0 .5px rgba(255,255,255,.12), 0 12px 28px -10px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.4);
}
