/* Agentic Memory 모니터 — "쓸수록 기억이 쌓인다"를 한 화면에.
   전체 화면 1920×1080, 4섹션을 열로 나란히 둔다. */

/* ── 상단 요약 ───────────────────────────────────────── */
.stats {
  display: flex;
  align-items: flex-end;
  gap: 3.5rem;
  padding: 1.3rem 2rem 1.2rem;
  background: linear-gradient(180deg, #101821 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.stat { display: flex; flex-direction: column; gap: 0.2rem; }
.stat--right { margin-left: auto; text-align: right; }
/* 보조 지표 — 주 지표와 같은 크기로 두면 시선을 나눠 먹는다. */
.stat--quiet .stat__num { font-size: 1.35rem; color: var(--ink-dim); font-weight: 500; }
.stat--quiet .stat__label { font-size: 0.78rem; color: var(--ink-faint); }
.stat__num {
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  transition: color 0.4s;
}
.stat__label { font-size: 0.85rem; color: var(--ink-dim); }
.stat--accent .stat__num { color: var(--accent); }
/* 새 기억이 생긴 순간 숫자가 한 번 번쩍인다 — 변화를 놓치지 않게 하는 유일한 애니메이션. */
.stat__num.is-bumped { animation: bump 0.7s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); color: var(--accent); }
  100% { transform: scale(1); }
}

/* ── 4섹션 열 ────────────────────────────────────────── */
.sections {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  flex: 1;
  min-height: 0;
}
.section {
  background: var(--bg);
  padding: 1rem 1.25rem 1.2rem;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.section__head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  position: sticky;
  top: -1.1rem;
  background: var(--bg);
  padding: 0.2rem 0 0.5rem;
  margin: -0.2rem 0 0;
  z-index: 2;
}
.section__name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.section__ko { font-size: 0.8rem; color: var(--ink-faint); }
.section__count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-dim);
}
/* 섹션 색 — Working Memory의 출처 색과 겹치지 않는 별도 축이다(다른 것을 뜻하므로). */
.section--profile   .section__name { color: #7FC7F0; }
.section--behavior  .section__name { color: #8FD9B6; }
.section--event     .section__name { color: #E8C07A; }
.section--knowledge .section__name { color: #C3A6F0; }
.section--profile   .topic__name { color: #7FC7F0; }
.section--behavior  .topic__name { color: #8FD9B6; }
.section--event     .topic__name { color: #E8C07A; }
.section--knowledge .topic__name { color: #C3A6F0; }

.topic { display: flex; flex-direction: column; gap: 0.55rem; }
/* 카드 자체는 폭이 넓어지면 여러 장이 나란히 놓이게 한다(짧은 사실이 대부분이다). */
.topic__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0.8rem;
}
.topic__name {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  opacity: 0.85;
}

.fact {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.6rem 0.85rem 0.5rem;
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--ink);
}
.fact__meta {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.28rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--ink-faint);
  opacity: 0.75;
}

/* 신규 기억 — 이 데모의 핵심 연출. 생긴 직후 강조하고 시간이 지나면 가라앉는다. */
.fact.is-new {
  border-color: var(--accent);
  background: rgba(79, 195, 217, 0.09);
  animation: arrive 0.65s ease;
}
.fact.is-new::before {
  content: "NEW";
  position: absolute;
  top: -0.55rem;
  right: 0.7rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  background: var(--accent);
  color: #06222A;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-weight: 700;
}
.fact.is-updated {
  border-color: var(--chunk);
  background: rgba(224, 179, 87, 0.08);
}
.fact.is-updated::before {
  content: "변경";
  position: absolute;
  top: -0.55rem;
  right: 0.7rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  background: var(--chunk);
  color: #2A2214;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-weight: 700;
}
.fact__was {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--line);
  font-size: 0.82rem;
  color: var(--ink-faint);
  text-decoration: line-through;
}

/* 대체된 사실 — 죽은 믿음. DB라면 그대로 남을 옛 값이 여기서는 취소선으로 죽는다. */
.fact.is-superseded {
  opacity: 0.5;
  border-style: dashed;
  border-color: var(--line);
  background: transparent;
  text-decoration: line-through;
  text-decoration-color: var(--ink-faint);
}
.fact.is-superseded .fact__meta { text-decoration: none; }
.fact__tag-dead {
  text-decoration: none;
  color: var(--danger, #E8736B);
  font-weight: 700;
  letter-spacing: 0.04em;
}
@keyframes arrive {
  0% { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fact.is-new { animation: none; }
  .stat__num.is-bumped { animation: none; }
}

/* 빈 분류 — 존재는 드러내되 시선을 끌지 않는다. */
.section--quiet { opacity: 0.55; }
.section--quiet .section__head { flex-wrap: wrap; }
.section__empty {
  color: var(--ink-faint);
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-line;
  padding: 1.1rem 0;
  border-top: 1px dashed var(--line-soft);
}

/* ── 최근 변화 스트립 ────────────────────────────────── */
.changes {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 0.85rem 2rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-height: 3.4rem;
}
.changes__title {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  flex: none;
}
.changes__list {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
.changes__none { color: var(--ink-faint); font-size: 0.85rem; }
.change {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  white-space: nowrap;
  flex: none;
}
.change--added { border-color: rgba(79, 195, 217, 0.45); }
.change--updated { border-color: rgba(224, 179, 87, 0.45); }
.change__kind {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
}
.change--added .change__kind { color: var(--accent); }
.change--updated .change__kind { color: var(--chunk); }
.change__text { color: var(--ink-dim); }

.empty--full {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  border: none;
  font-size: 1rem;
  line-height: 1.9;
}

@media (max-width: 1100px) {
  .sections { grid-template-columns: repeat(2, 1fr); }
  .stats { flex-wrap: wrap; gap: 1.5rem 2.5rem; }
}


/* ── 기억 성장 추이 ──────────────────────────────────────
   "쓸수록 쌓인다"를 숫자가 아니라 형태로 보여준다. 데이터는 각 fact의 firstSeen에서
   유도하므로 새로고침해도 그대로 복원된다(별도 히스토리를 들고 있지 않는다). */
.stat--chart { min-width: 13rem; }
.growth {
  height: 2.6rem;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-bottom: 0.35rem;
}
.growth i {
  flex: 1;
  background: var(--accent);
  opacity: 0.45;
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
}
.growth i:last-child { opacity: 1; }
.growth--empty {
  align-items: center;
  color: var(--ink-faint);
  font-size: 0.78rem;
  font-family: var(--mono);
}


/* ── 아직 비어 있는 분류 ─────────────────────────────────
   4분류 모델이 있다는 건 보이되, 빈 열이 화면 절반을 먹지 않게 한 줄로 접는다. */
.pending {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.6rem 2rem;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
}
.pending__label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.pending__chip {
  font-size: 0.8rem;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}
.pending__chip b { color: var(--ink-dim); font-weight: 600; }

/* 마지막 막대에 값 — hover title은 전시에서 보이지 않는다. */
.growth { position: relative; padding-right: 2.2rem; }
/* 값은 그래프 바깥 오른쪽에 — 막대 안에 넣으면 폭이 좁아 잘린다(실측). */
.growth::after {
  content: attr(data-total);
  position: absolute;
  right: 0;
  bottom: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}


/* ── 기반층: 대화 원문 ───────────────────────────────────
   4기둥(정제된 사실) 아래에 놓아 "원문이 쌓이고 → 사실로 정제된다"를 위치로 보인다.
   기둥보다 한 단 낮은 밝기를 써서 주인공이 사실이라는 게 유지되게 한다. */
.raw {
  margin: 0 1.5rem 0.8rem;
  padding: 0.7rem 1.1rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.raw__head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.raw__arrow { color: var(--chunk); font-size: 0.9rem; }
.raw__title { font-weight: 600; color: var(--chunk); }
.raw__note { font-size: 0.8rem; color: var(--ink-faint); }
.raw__meta { margin-left: auto; font-size: 0.8rem; color: var(--ink-dim); }

.raw__list { display: flex; flex-direction: column; gap: 0.1rem; }
.rawline {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.14rem 0.35rem;
  border-radius: 3px;
  font-size: 0.88rem;
  line-height: 1.4;
}
.rawline__who {
  flex: none;
  width: 4.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.rawline__who--user { color: var(--accent); }
.rawline__text {
  flex: 1;
  min-width: 0;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rawline__at { flex: none; font-size: 0.72rem; color: var(--ink-faint); }
/* 신규 강조는 사실 쪽과 같은 색·같은 근거(기준선 이후 저장)를 쓴다. */
.rawline--new { background: #17281E; }
.rawline--new .rawline__text { color: var(--ink); }

.raw__more {
  align-self: flex-start;
  margin-top: 0.35rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.2rem 0.7rem;
  cursor: pointer;
}
.raw__more:hover { color: var(--ink); border-color: var(--ink-faint); }
