<!--
  EidEvidenceCard — 이드 채팅 deep(검색) 답변의 근거 카드 (ds-eid-ask-absorb P1).

  ReactResult.sources = {id, doc_id, title, score} (citation 번호 n 없음 — /ask 의 Citation 과
  다름) → 순서 기반 번호([1],[2]...). 1단계 카드 = 제목·출처·점수 (스니펫은 react_loop
  _result_payload items_src 에 없음 — 2단계 후보). 접이식 <details> 로 채팅 흐름 보존.
  디자인 토큰만 (CLAUDE.md lint:tokens).
-->
<script lang="ts">
  type EidSource = { id?: number; doc_id?: number; title?: string; score?: number };
  let { sources, partial = false }: { sources: EidSource[]; partial?: boolean } = $props();
</script>

{#if sources.length}
  <details class="mt-2 rounded-lg border border-default bg-surface text-xs max-w-[85%] sm:max-w-[75%]">
    <summary class="cursor-pointer px-3 py-2 text-dim hover:text-text select-none font-semibold">
      근거 {sources.length}개{partial ? ' · 부분 답변 (확정 근거 부족)' : ''}
    </summary>
    <ul class="px-3 pb-2.5 flex flex-col gap-1.5">
      {#each sources as src, i (src.id ?? i)}
        <li class="flex items-start gap-2">
          <span class="text-accent font-bold shrink-0">[{i + 1}]</span>
          <span class="flex-1 min-w-0 text-text break-words">{src.title || `문서 ${src.doc_id ?? '?'}`}</span>
          {#if typeof src.score === 'number'}
            <span class="text-faint shrink-0 tabular-nums">{src.score.toFixed(2)}</span>
          {/if}
        </li>
      {/each}
    </ul>
  </details>
{/if}
