:root{ --bg:#f8fafc; --fg:#0f172a; --muted:#64748b; --line:#e2e8f0; --bubble:#111827; --bubbleText:#fff; }
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{ margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif; color:var(--fg); background:linear-gradient(#f8fafc,#fff); }
header{ position:sticky; top:0; z-index:10; background:#fff; border-bottom:1px solid var(--line); padding:12px 16px; font-weight:700; }
main#chat{ height:45vh; overflow:auto; padding:12px 16px; display:block; }
.row{ display:flex; gap:8px; margin:8px 0; align-items:flex-start; }
.row.user{ justify-content:flex-end; }
.row.assistant{ justify-content:flex-start; }
.avatar{ width:28px; height:28px; border-radius:10px; display:flex; align-items:center; justify-content:center; background:#0f172a; color:#fff; font-size:14px; }
.bubble{ max-width:70%; border-radius:16px; padding:10px 12px; box-shadow:0 2px 6px rgba(0,0,0,.06); white-space:pre-wrap; }
.row.user .bubble{ background:var(--bubble); color:var(--bubbleText); }
.row.assistant .bubble{ background:#f1f5f9; color:#0f172a; }
.bubble .time{ margin-top:6px; font-size:10px; opacity:.6; }
.empty{ height:100%; display:flex; align-items:center; justify-content:center; text-align:center; color:var(--muted); }

/* 검색 영역 */
#search{ padding:16px; border-top:1px solid var(--line); }
#search h3{ margin:0 0 10px; }
.filters{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
.filters input, .filters select{ padding:8px 10px; border:1px solid var(--line); border-radius:10px; }
#result-table{ width:100%; border-collapse:collapse; margin-top:8px; }
#result-table th, #result-table td{ border:1px solid var(--line); padding:8px; font-size:14px; }
.pager{ display:flex; align-items:center; gap:10px; margin-top:8px; }

/* 모달 */
.modal{ position:fixed; inset:0; background:rgba(15,23,42,.3); display:none; align-items:center; justify-content:center; padding:16px; }
.modal:not([hidden]){ display:flex; }
.panel{ background:#fff; width:min(560px,95vw); border-radius:16px; padding:16px; box-shadow:0 10px 30px rgba(0,0,0,.15); }
.field{ display:flex; gap:8px; align-items:center; margin:8px 0; }
.field span{ width:120px; font-size:12px; color:var(--muted); }
.field input{ flex:1; padding:8px 10px; border:1px solid var(--line); border-radius:10px; }
.actions{ display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }
.actions button{ padding:8px 12px; border-radius:10px; border:1px solid var(--line); background:#0f172a; color:#fff; }

/* 하단 입력창 */
#composer{ position:sticky; bottom:0; background:#fff; border-top:1px solid var(--line); padding:12px 16px; display:flex; gap:8px; }
#composer select, #composer input{ padding:10px 12px; border:1px solid var(--line); border-radius:12px; }
#composer button{ padding:10px 14px; border-radius:12px; border:1px solid var(--line); background:#0f172a; color:#fff; }

#s-extra label.field{ display:inline-flex; align-items:center; gap:6px; margin:4px 8px 4px 0; }
#s-extra label.field>span{ min-width:5em; }

/* 자동완성 패널 */
.suggestions {
  position: fixed;              /* 화면 기준으로 고정 */
  left: 12px;
  right: 12px;
  bottom: 72px;                 /* 입력창(컴포저) 높이만큼 띄우기 */
  max-height: 40vh;             /* 높이 제한 */
  overflow: auto;               /* 많아지면 스크롤 */
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  z-index: 20;                  /* 입력창 위로, 모달(편집창)보다는 아래면 z-index 조정 */
}

.suggestions .title {
  position: sticky; top: 0;
  background: #f8fafc;
  font-size: 12px; color: #334155;
  padding: 8px 10px; border-bottom: 1px solid #e5e7eb;
}

.suggestions .item {
  padding: 10px 12px; cursor: pointer;
}

.suggestions .item:hover,
.suggestions .item.active {
  background: #f1f5f9;
}
