/* ============================================================
   3열 · AI직원 대화창 + beat 카드

   Genffice 표준 4열(메뉴 | 목차 | 대화 | 미리보기)의 세 번째 열이다.
   genffice-docs 의 .chat 열과 같은 자리이고, 구성은 ksp-mock 3열 그대로다 —
   머리글 + 메시지 스트림 + **맨 아래 입력창**.

   AI직원은 따로 떠 있는 위젯이 아니라 이 열이다. 그래서 이 파일이
   대화창 크롬(컨텍스트 스트립 · 진행률 바 · 추천 칩 · composer)을 전부 갖는다.

   .composer / .cbox / .chint / .cchips 는 짧은 이름이므로 반드시
   `.stream` 아래로 스코프한다. beat 카드도 같은 이유로 .beats 스코프다.
   ksp-mock 설계문서 6.4 의 클래스 충돌 사고(.sp 가 슬라이드 푸터에 먹은 일)를
   반복하지 않기 위한 규칙이고, .verify/collide.js 가 이것을 지킨다.
   ============================================================ */

.stream {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--bg-panel);
  overflow: hidden;
}

.stream-head {
  flex: 0 0 auto;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-panel);
}
.stream-head .sh-t { display: flex; align-items: center; gap: 7px; }
.stream-head .sh-av {
  display: grid; place-items: center;
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: var(--r-6);
  background: linear-gradient(135deg, var(--accent), #3f8fd4);
  font-size: 12px;
}
.stream-head h2 {
  flex: 1; min-width: 0;
  font-size: var(--fs-13); font-weight: 650; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stream-head .live {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  padding: 2px 8px; border-radius: 20px;
  background: var(--warning-subtle); color: var(--warning);
  font-size: var(--fs-10); font-weight: 700;
}
.stream-head .live i { width: 5px; height: 5px; border-radius: 50%; background: var(--warning); animation: stpulse 1.1s infinite; }
.stream-head .sh-s { margin-top: 4px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.5; }

/* ------------------------------------------------------------
   컨텍스트 스트립 — "AI직원이 지금 무엇을 알고 있는지"를 보여준다.
   요구사항의 '어디까지 진행하고 있는지 알고 있어야 한다'를 눈에 보이게
   만든 자리다. 매 요청에 실려 가는 APP.context() 의 요약이다.
   ------------------------------------------------------------ */
.stream-ctx {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-1); background: var(--bg-sidebar);
}
.stream-ctx:empty { display: none; }
.stream-ctx .cx {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 20px;
  background: var(--bg-panel); border: 1px solid var(--border-1);
  font-size: var(--fs-10); font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.stream-ctx .cx b { font-weight: 700; color: var(--accent-text); }
.stream-ctx .cx.on { border-color: var(--accent-border); background: var(--accent-subtle); }

#stBody {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 14px 10px; background: var(--bg-app);
  display: flex; flex-direction: column; gap: 10px;
}

/* 시작 안내 — 아직 지시가 없을 때 */
.stream-empty {
  margin: auto; padding: 20px 8px; text-align: center;
}
.stream-empty .se-i {
  display: grid; place-items: center;
  width: 40px; height: 40px; margin: 0 auto 10px;
  border-radius: 50%; background: var(--accent-subtle); color: var(--accent);
}
.stream-empty .se-i svg { width: 19px; height: 19px; }
.stream-empty b { display: block; font-size: var(--fs-12); font-weight: 650; color: var(--text-2); }
.stream-empty span { display: block; margin-top: 5px; font-size: var(--fs-11); color: var(--text-3); line-height: 1.7; }

/* ------------------------------------------------------------
   작업 진행 — genffice-docs 의 .job-progress 자리.
   스트림과 입력창 사이에 끼고, 단계를 재생하는 동안에만 나타난다.
   ------------------------------------------------------------ */
.stream-foot {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-top: 1px solid var(--border-1); background: var(--bg-panel);
}
.stream-foot:empty { display: none; }
.job {
  border: 1px solid var(--accent-border); border-radius: var(--r-8);
  background: var(--accent-subtle); padding: 9px 11px;
}
.job-bar { height: 3px; border-radius: 999px; background: var(--accent-border); overflow: hidden; margin-bottom: 8px; }
.job-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.job-t { display: flex; align-items: baseline; gap: 7px; }
.job-t strong { font-size: var(--fs-11); font-weight: 700; color: var(--accent-text); }
.job-t span { flex: 1; min-width: 0; font-size: var(--fs-10); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-t .job-n { flex-shrink: 0; font-size: var(--fs-10); font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

@keyframes stpulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* ============================================================
   맨 아래 입력창 — ksp-mock 3열 composer 그대로.
   AI직원의 기능(컨텍스트 인식 · 대신 진행 · 지식 답변)이 여기에 있다.
   ============================================================ */

.stream .composer {
  flex: 0 0 auto;
  padding: 9px 12px 10px;
  border-top: 1px solid var(--border-1); background: var(--bg-panel);
}

/* 상황에 맞는 추천 질문 — 입력창 바로 위 */
.stream .cchips { display: flex; gap: 5px; margin-bottom: 7px; overflow-x: auto; }
.stream .cchips:empty { display: none; }
.stream .cchips .ch {
  flex-shrink: 0; padding: 4px 10px;
  border: 1px solid var(--border-2); border-radius: 999px;
  background: var(--bg-panel); color: var(--text-2);
  font: inherit; font-size: var(--fs-11); font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.stream .cchips .ch:hover { border-color: var(--accent-border); background: var(--accent-subtle); color: var(--accent-text); }

.stream .cbox {
  display: flex; gap: 7px; align-items: flex-end;
  padding: 6px 7px 6px 10px;
  border: 1px solid var(--border-2); border-radius: var(--r-10);
  background: var(--bg-panel); transition: border-color .14s, box-shadow .14s;
}
.stream .cbox:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.stream .cbox textarea {
  flex: 1; min-width: 0;
  min-height: 22px; max-height: 104px;
  border: 0; outline: none; resize: none; padding: 2px 0;
  background: transparent; color: var(--text-1);
  font: inherit; font-size: var(--fs-12); line-height: 1.6;
}
.stream .cbox .btn { flex-shrink: 0; }

.stream .chint {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-top: 6px; font-size: var(--fs-10); color: var(--text-3);
}
.stream .chint .kbd {
  padding: 1px 5px; border: 1px solid var(--border-2); border-radius: var(--r-4);
  background: var(--bg-subtle); font-size: 9.5px; font-weight: 600; color: var(--text-2);
}
.stream .chint .ctail {
  margin-left: auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stream .chint .ctail b { font-weight: 650; color: var(--accent-text); }

.stream .cdisc { margin-top: 6px; font-size: var(--fs-10); color: var(--text-3); text-align: center; line-height: 1.5; }

/* ============================================================
   beat 카드 — .beats 스코프 (대화와 작업 과정이 같은 카드를 쓴다)
   ============================================================ */

.beats .msg { display: flex; flex-direction: column; }
.beats .msg.user { align-items: flex-end; }
.beats .who {
  display: flex; align-items: center; gap: 5px; margin-bottom: 4px;
  font-size: var(--fs-10); font-weight: 600; color: var(--text-3);
}
.beats .who .wa {
  display: grid; place-items: center;
  width: 17px; height: 17px; border-radius: var(--r-4);
  background: var(--accent); color: #fff; font-size: 9px;
}
.beats .bubble {
  max-width: 94%; padding: 9px 12px;
  border: 1px solid var(--border-1); border-radius: var(--r-10);
  background: var(--bg-panel); color: var(--text-1);
  font-size: var(--fs-12); line-height: 1.7;
  border-bottom-left-radius: var(--r-4);
  word-break: break-word;
}
.beats .msg.user .bubble {
  background: var(--accent); border-color: transparent; color: #fff;
  border-bottom-left-radius: var(--r-10); border-bottom-right-radius: var(--r-4);
  white-space: pre-wrap;
}
.beats .bubble.warn { background: var(--warning-subtle); border-color: #f3ddb9; }
.beats .bubble b { font-weight: 700; color: var(--accent-text); }
.beats .bubble.warn b { color: var(--warning); }
.beats .msg.user .bubble b { color: #fff; }
.beats .bubble > *:first-child { margin-top: 0 }
.beats .bubble > *:last-child { margin-bottom: 0 }
.beats .bubble p { margin: 6px 0 }
.beats .bubble ul, .beats .bubble ol { margin: 6px 0; padding-left: 18px }
.beats .bubble li { margin: 2px 0 }
.beats .bubble h3, .beats .bubble h4 { font-size: var(--fs-12); font-weight: 700; margin: 10px 0 4px; color: var(--accent-text) }
.beats .bubble code { background: var(--bg-subtle); border-radius: 4px; padding: 1px 4px; font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace }
.beats .bubble table { border-collapse: collapse; width: 100%; font-size: var(--fs-11); margin: 6px 0 }
.beats .bubble th, .beats .bubble td { border: 1px solid var(--border-1); padding: 4px 7px; text-align: left; vertical-align: top; word-break: keep-all }
.beats .bubble thead th { background: var(--bg-subtle); font-weight: 700 }

.beats .typing { display: inline-flex; gap: 3px; align-items: center; padding: 4px 0; }
.beats .typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: agbnc 1.2s infinite; }
.beats .typing i:nth-child(2) { animation-delay: .16s }
.beats .typing i:nth-child(3) { animation-delay: .32s }
@keyframes agbnc { 0%, 60%, 100% { transform: translateY(0); opacity: .4 } 30% { transform: translateY(-4px); opacity: 1 } }

/* 작업 계획 */
.beats .plan { border: 1px solid var(--accent-border); border-radius: var(--r-10); background: var(--accent-subtle); padding: 10px 12px; }
.beats .plan .ph { font-size: var(--fs-11); font-weight: 700; color: var(--accent-text); margin-bottom: 3px; }
.beats .plan .pn { font-size: var(--fs-10); color: var(--text-2); margin-bottom: 7px; line-height: 1.55; }
.beats .plan ol { margin: 0; padding: 0; list-style: none; counter-reset: p; }
.beats .plan li {
  counter-increment: p; position: relative;
  padding: 3px 0 3px 21px; font-size: var(--fs-11); color: var(--text-1); line-height: 1.55;
}
.beats .plan li::before {
  content: counter(p); position: absolute; left: 0; top: 4px;
  display: grid; place-items: center; width: 14px; height: 14px;
  border-radius: var(--r-4); background: var(--bg-panel);
  border: 1px solid var(--accent-border); color: var(--accent-text);
  font-size: 8.5px; font-weight: 700;
}

/* 도구 사용 */
.beats .tool { border: 1px solid var(--border-1); border-radius: var(--r-8); background: var(--bg-panel); padding: 8px 10px; }
.beats .tool .th { display: flex; align-items: center; gap: 6px; font-size: var(--fs-10); font-weight: 700; color: var(--text-2); }
.beats .tool .tn { padding: 1px 6px; border-radius: var(--r-4); background: var(--bg-subtle); border: 1px solid var(--border-1); color: var(--accent-text); font-size: var(--fs-10); font-weight: 700; }
.beats .tool .td { font-size: var(--fs-10); color: var(--text-3); margin-top: 5px; line-height: 1.55; }
.beats .tool .tr { font-size: var(--fs-11); color: var(--text-1); margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-2); line-height: 1.6; }
.beats .tool .tr::before { content: "↳ "; color: var(--text-3); }
.beats .tool .tr b { font-weight: 700; color: var(--accent-text); }

/* 체크리스트 */
.beats .cl { border: 1px solid var(--border-1); border-left: 2px solid var(--accent); border-radius: 0 var(--r-8) var(--r-8) 0; background: var(--bg-panel); padding: 9px 11px; }
.beats .cl .clh { display: flex; align-items: baseline; gap: 7px; font-size: var(--fs-11); font-weight: 700; margin-bottom: 6px; }
.beats .cl .cn { margin-left: auto; font-size: var(--fs-10); font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.beats .cl ul { list-style: none; margin: 0; padding: 0; }
.beats .cl li { display: flex; gap: 6px; align-items: flex-start; padding: 2.5px 0; font-size: var(--fs-11); color: var(--text-3); line-height: 1.55; transition: color .2s; }
.beats .cl li .m { flex: 0 0 auto; width: 12px; text-align: center; font-size: var(--fs-10); line-height: 1.6; }
.beats .cl li.run { color: var(--text-1); font-weight: 600; }
.beats .cl li.run .m { color: var(--warning); }
.beats .cl li.done { color: var(--text-2); }
.beats .cl li.done .m { color: var(--success); }
.beats .cl li .lt { flex: 1; min-width: 0; }
.beats .cl li .ln { display: block; margin-top: 1px; font-size: var(--fs-10); font-weight: 400; color: var(--text-3); }

/* 결과 */
.beats .result { border: 1px solid #b8e3c6; border-radius: var(--r-10); background: var(--success-subtle); padding: 10px 12px; }
.beats .result .rh { display: flex; align-items: center; gap: 6px; font-size: var(--fs-11); font-weight: 700; color: var(--success); margin-bottom: 6px; }
.beats .result ul { list-style: none; margin: 0; padding: 0; }
.beats .result li { position: relative; padding: 3px 0 3px 13px; font-size: var(--fs-11); color: var(--text-1); line-height: 1.6; }
.beats .result li::before { content: "•"; position: absolute; left: 2px; color: var(--success); font-weight: 700; }
.beats .result li b { font-weight: 700; color: var(--success); }

/* 업무 이관 */
.beats .handoff { border: 1px dashed #c9bce8; border-radius: var(--r-8); background: #faf8ff; padding: 8px 11px; }
.beats .handoff .hh { font-size: var(--fs-10); font-weight: 700; color: #6d28d9; margin-bottom: 4px; }
.beats .handoff .hr { font-size: var(--fs-11); color: var(--text-1); line-height: 1.6; }
.beats .handoff .hr b { font-weight: 700; color: #5b21b6; }
.beats .handoff .hw { font-size: var(--fs-10); color: var(--text-3); margin-top: 3px; line-height: 1.55; }

/* 다음 행동 */
.beats .acts .at { font-size: var(--fs-11); color: var(--text-1); margin-bottom: 7px; line-height: 1.65; }
.beats .acts .ab { display: flex; flex-wrap: wrap; gap: 5px; }
.beats .acts .ab .btn { height: 26px; font-size: var(--fs-11); }

/* AI직원이 수행한 UI 액션 로그 */
.beats .did {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--r-8);
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  font-size: var(--fs-10); font-weight: 600; color: var(--accent-text);
}
.beats .did svg { width: 12px; height: 12px; flex-shrink: 0; }
