/* Dr.NUMPAI — 가상 AI 닥터 위젯 (CLAUDE.md §4.8)
   3분할 레이아웃을 가리지 않도록 우하단 플로팅. 팝아웃 창(chat.html)과 스타일을 공유한다. */

#npi-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--teal);
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
  display: grid; place-items: center; padding: 0;
  transition: transform var(--t), box-shadow var(--t);
}
#npi-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 24px rgba(0,0,0,.34); }
#npi-fab.open { transform: scale(.92); opacity: .82; }
#npi-fab .npi-ava { width: 46px; height: 46px; }
.npi-online {
  position: absolute; right: 2px; bottom: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #22c55e; border: 2px solid var(--surface);
}

.npi-ava {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--surface-3); border: 1px solid var(--line);
}
.npi-ava.big { width: 56px; height: 56px; }

#npi-panel {
  position: fixed; right: 20px; bottom: 84px; z-index: 91;
  width: 384px; height: min(560px, calc(100vh - 130px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: 0 16px 48px rgba(0,0,0,.34);
  overflow: hidden;
  animation: npi-rise .18s cubic-bezier(.2,1,.35,1);
}
@keyframes npi-rise { from { opacity: 0; transform: translateY(10px); } }

.npi-head {
  flex: none; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.npi-id { flex: 1; min-width: 0; }
.npi-id b { display: block; font-size: 12.5px; font-weight: 700; }
.npi-ctx {
  display: block; font-size: 10px; color: var(--teal); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.npi-icon {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  border-radius: var(--r-sm); color: var(--text-3);
  transition: background var(--t), color var(--t);
}
.npi-icon:hover { background: var(--surface-3); color: var(--accent-hi); }
.npi-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }

#npi-msgs {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 11px; display: flex; flex-direction: column; gap: 9px;
}
.npi-row { display: flex; align-items: flex-start; gap: 7px; }
.npi-row.user { justify-content: flex-end; }
.npi-bubble {
  max-width: 84%; padding: 7px 11px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
  overflow-wrap: anywhere;
}
.npi-bubble.user {
  background: var(--accent); color: #fff; border-color: var(--accent);
  border-radius: 12px; border-bottom-right-radius: 3px;
}
.npi-bubble.md h2, .npi-bubble.md h3, .npi-bubble.md h4 {
  font-size: 12px; font-weight: 700; color: var(--accent-hi); margin: 6px 0 3px;
}
.npi-bubble.md p { margin: 3px 0; }
.npi-bubble.md ul, .npi-bubble.md ol { margin: 3px 0; padding-left: 18px; }
.npi-bubble.md li { margin: 1px 0; }
.npi-bubble.md strong { font-weight: 600; }
.npi-bubble.md table { width: 100%; border-collapse: collapse; margin: 5px 0; font-size: 11px; }
.npi-bubble.md th, .npi-bubble.md td { border: 1px solid var(--line); padding: 3px 5px; }
.npi-bubble.md th { background: var(--surface-3); }
.npi-bubble.md p.alert { color: var(--danger); font-weight: 600; }

.npi-dots { display: inline-flex; gap: 3px; padding: 2px 0; }
.npi-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-3);
  animation: npi-bounce 1s infinite;
}
.npi-dots i:nth-child(2) { animation-delay: .15s; }
.npi-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes npi-bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

.npi-empty {
  margin: auto; text-align: center; color: var(--text-3); font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
}
.npi-samples { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.npi-sample {
  font-size: 10.5px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-2);
  background: var(--surface-2); transition: all var(--t);
}
.npi-sample:hover { border-color: var(--teal); color: var(--teal); }

.npi-note {
  flex: none; margin: 0 11px 6px; padding: 5px 8px;
  font-size: 10px; color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: var(--r-sm);
}

.npi-foot { flex: none; padding: 8px 10px 10px; border-top: 1px solid var(--line); }
.npi-attach {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 6px;
  font-size: 10.5px; color: var(--text-3); cursor: pointer; user-select: none;
}
.npi-attach input { accent-color: var(--teal); }
.npi-inrow { display: flex; gap: 6px; }
#npi-input {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--input-bg); color: var(--text);
}
#npi-input:focus { outline: none; border-color: var(--teal); }
#npi-send {
  flex: none; padding: 0 14px; font-size: 12px; font-weight: 700;
  border-radius: var(--r-md); background: var(--teal); color: #fff;
  transition: filter var(--t);
}
#npi-send:hover:not(:disabled) { filter: brightness(1.1); }
#npi-send:disabled, #npi-input:disabled { opacity: .5; cursor: not-allowed; }

/* 팝아웃 창 (chat.html) — 패널을 창 전체로. 창 크기에 따라 늘어난다. */
body.npi-popout {
  overflow: hidden;
  min-width: 320px;      /* 이보다 좁아지면 입력창·버튼이 뭉개진다 */
  min-height: 380px;
}
body.npi-popout #npi-panel {
  position: static; width: 100%; height: 100vh;
  border: none; border-radius: 0; box-shadow: none; animation: none;
}
/* 창이 좁아지면 글자·여백을 줄여 잘리지 않게 한다 */
@media (max-width: 380px) {
  body.npi-popout .npi-bubble { max-width: 92%; font-size: 12px; }
  body.npi-popout .npi-head { padding: 7px 8px; gap: 7px; }
  body.npi-popout .npi-foot { padding: 6px 8px 8px; }
  body.npi-popout #npi-msgs { padding: 9px 8px; }
  body.npi-popout #npi-send { padding: 0 10px; }
  body.npi-popout .npi-sample { font-size: 10px; padding: 3px 7px; }
}
