/* Models: openai/gpt-oss-20b (Hugging Face Router), sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 (local). Technologies: FastAPI, PostgreSQL/pgvector, Sentence Transformers, PyPDF, SQLAlchemy, Markdown, Bleach, HTML, CSS, JavaScript. */
:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  color: #172033;
  background: #f5f7ff;
  --ink: #172033;
  --muted: #52627e;
  --muted-strong: #3447a1;
  --green: #4255bb;
  --green-dark: #3447a1;
  --green-light: #ebefff;
  --line: #dce4f5;
  --line-strong: #cbd5eb;
  --surface: #fff;
  --surface-soft: #fafbff;
  --danger: #a52f2a;
  --shadow: 0 20px 50px #253f8912, inset 0 0 0 1px #4a5eff08;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f5f7ff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}

body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; }
body::before {
  background: radial-gradient(60vw 34vw at -10% -10%, rgba(74,94,255,.17), transparent 60%),
              radial-gradient(46vw 28vw at 110% 110%, rgba(56,189,248,.18), transparent 60%);
}
body::after {
  background-image: linear-gradient(rgba(74,94,255,.12) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(74,94,255,.12) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(40vw 34vw at 22% 42%, #000 20%, transparent 75%);
  mask-image: radial-gradient(40vw 34vw at 22% 42%, #000 20%, transparent 75%);
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, .drop-zone:focus-within {
  outline: 3px solid #4a5eff;
  outline-offset: 3px;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1520px, calc(100% - 64px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #16804d;
  box-shadow: 0 0 0 4px #16804d20;
}

.model-details {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 11px;
}

.model-chip {
  max-width: 100%;
  padding: 5px 8px;
  overflow-wrap: anywhere;
  border: 1px solid #d4def6;
  border-radius: 99px;
  background: #ebefff;
  color: #3447a1;
  line-height: 1.45;
}

.model-chip b { color: #273969; font-weight: 700; }

.hero { padding: 48px 2px 30px; }

.eyebrow, .section-index, .library-subheading, .page-footer {
  color: #526157;
  font: 12px var(--mono);
  letter-spacing: .07em;
}

.eyebrow { display: flex; align-items: center; gap: 12px; }
.eyebrow-line { width: 34px; height: 2px; background: #6f9b7d; }

.hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(38px, 4.2vw, 60px);
  line-height: 1.18;
  letter-spacing: -.045em;
  font-weight: 760;
}

.hero h1 span { color: var(--green); }
.hero > p { max-width: 760px; margin: 0; color: #435248; font-size: 17px; line-height: 1.7; }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  color: #34463a;
  font-size: 14px;
  font-weight: 600;
}

.meta-divider { color: #77867b; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.library-panel { padding: 24px 22px 20px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-heading h2 { margin: 5px 0 0; font-size: 24px; line-height: 1.3; letter-spacing: -.035em; }
.section-index { color: #526157; font-size: 12px; }

.count-pill {
  display: grid;
  min-width: 36px;
  height: 34px;
  padding: 0 9px;
  place-items: center;
  border-radius: 9px;
  background: #e4f1e8;
  color: #104c30;
  font: 700 14px var(--mono);
}

.panel-caption { margin: 8px 0 18px; color: #47564d; font-size: 14px; }

.drop-zone {
  display: flex;
  min-height: 156px;
  padding: 18px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #a9c0ae;
  border-radius: 13px;
  background: linear-gradient(135deg, #fbfdfb, #f1f7f3);
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background-color .18s ease;
}

.drop-zone:hover, .drop-zone.dragging { border-color: #286e45; background: #eaf4ed; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
  place-items: center;
  border: 1px solid #bed5c4;
  border-radius: 12px;
  background: #fff;
  color: #155a39;
  font-size: 25px;
}

.drop-title { color: #172a1e; font-size: 16px; font-weight: 700; }
.drop-subtitle { margin-top: 5px; color: #4c5e52; font-size: 14px; }

.notice { min-height: 24px; margin: 9px 0; color: #435248; font-size: 14px; }
.notice.error { color: var(--danger); font-weight: 600; }
.notice.success { color: #155a39; font-weight: 600; }

.library-subheading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0 9px;
  border-bottom: 1px solid var(--line);
  color: #405148;
  font-size: 12px;
  font-weight: 700;
}

.icon-button, .text-button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #344b3c;
  cursor: pointer;
}

.icon-button { font-size: 22px; line-height: 1; }
.icon-button:hover, .text-button:hover { border-color: #c6d8cb; background: #eff6f1; color: #104c30; }

.document-list { display: flex; flex-direction: column; gap: 5px; padding-top: 10px; }

.doc-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 9px 7px;
  border-radius: 10px;
}

.doc-row:hover { background: #f3f8f5; }

.file-badge {
  display: grid;
  width: 38px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #d7e6db;
  border-radius: 8px;
  background: #edf5ef;
  color: #185537;
  font: 700 11px var(--mono);
}

.doc-info { min-width: 0; flex: 1; }
.doc-name { display: block; overflow: hidden; color: #203429; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { margin-top: 3px; color: #4c5c51; font-size: 13px; }

.delete-doc {
  min-width: 40px;
  min-height: 40px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #59675d;
  cursor: pointer;
  font-size: 20px;
}

.delete-doc:hover { border-color: #e4c7c4; background: #fff4f2; color: var(--danger); }
.empty-state { padding: 18px 8px; color: #4c5c51; font-size: 14px; line-height: 1.65; }

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #4c5c51;
  font-size: 13px;
  line-height: 1.55;
}

.privacy-note span:first-child { color: #286e45; font-size: 18px; }

.chat-panel {
  display: flex;
  min-height: 700px;
  padding: 24px 26px 20px;
  flex-direction: column;
}

.chat-heading { margin-bottom: 18px; }
.text-button { font-size: 14px; font-weight: 600; }

.chat-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #dbe7de;
  border-radius: 12px;
  background: #f6faf7;
}

.assistant-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: #dcefe2;
  color: #125435;
  font-size: 19px;
  font-weight: 800;
}

.chat-intro strong { color: #1b3023; font-size: 15px; }
.chat-intro p { margin: 3px 0 0; color: #4a5a50; font-size: 14px; }

.chat-log {
  display: flex;
  min-height: 300px;
  max-height: 620px;
  padding: 20px 4px 16px;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  overscroll-behavior: contain;
}

.welcome-card {
  display: flex;
  min-height: 250px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #4b5a50;
  font-size: 15px;
  text-align: center;
}

.welcome-mark { color: #176b45; font-size: 32px; }
.welcome-card strong { color: #1c3023; font-size: 20px; }

.message { display: flex; max-width: min(88%, 900px); flex-direction: column; align-self: flex-start; gap: 6px; }
.message.user { align-items: flex-end; align-self: flex-end; }
.message-label { color: #526157; font: 12px var(--mono); }

.message-bubble {
  padding: 14px 16px;
  border: 1px solid #dce4de;
  border-radius: 4px 14px 14px 14px;
  background: #f7faf8;
  color: #24342a;
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.message.user .message-bubble {
  border-color: #b8d5c1;
  border-radius: 14px 4px 14px 14px;
  background: #e6f3e9;
  color: #183b26;
}

.message-bubble p { margin: 0 0 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble h1, .message-bubble h2, .message-bubble h3 { margin: 14px 0 8px; color: #1d3827; font-size: 20px; line-height: 1.4; }
.message-bubble ul, .message-bubble ol { margin: 8px 0; padding-left: 24px; }
.message-bubble li + li { margin-top: 5px; }
.message-bubble pre { overflow: auto; padding: 14px; border: 1px solid #dce4de; border-radius: 9px; background: #eef3ef; }
.message-bubble code { font-family: var(--mono); font-size: .9em; }
.message-bubble blockquote { margin: 8px 0; padding-left: 14px; border-left: 3px solid #4e8a61; color: #405248; }
.message-bubble table { width: 100%; border-collapse: collapse; }
.message-bubble th, .message-bubble td { padding: 8px; border: 1px solid var(--line-strong); text-align: left; }

.source-list { display: flex; flex-direction: column; gap: 8px; margin-top: 3px; }
.source-card { padding: 12px 14px; border: 1px solid #d6e2d9; border-radius: 10px; background: #fff; }
.source-title { display: flex; justify-content: space-between; gap: 12px; color: #294734; font-size: 14px; font-weight: 700; }
.source-page { color: #155b38; font: 13px var(--mono); white-space: nowrap; }
.source-excerpt { display: -webkit-box; margin-top: 6px; overflow: hidden; color: #435248; font-size: 14px; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }

.composer {
  padding: 12px 14px 10px;
  border: 1px solid #bdcfc2;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 5px 18px rgb(22 43 30 / 5%);
}

.composer:focus-within { border-color: #3c8054; box-shadow: 0 0 0 3px #176b4522; }
.composer textarea { display: block; width: 100%; min-height: 52px; max-height: 160px; resize: vertical; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.6; }
.composer textarea::placeholder { color: #647268; }

.composer-footer {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid #e1e8e3;
  color: #4d5c52;
  font-size: 13px;
}

.send-button {
  display: flex;
  min-width: 132px;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: #155d3b;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  transition: background-color .18s ease;
}

.send-button:hover { background: #0c482d; }
.send-button:disabled { opacity: .62; cursor: wait; }

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 0 3px;
  color: #59685e;
  font-size: 12px;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* HR 워크스페이스와 같은 라이트 팔레트: 문서, 채팅, 근거 카드. */
.status-dot { background: #4a5eff; box-shadow: 0 0 0 4px #4a5eff20; }
.eyebrow, .section-index, .library-subheading, .page-footer { color: #4255bb; }
.panel-caption, .doc-meta, .privacy-note, .chat-intro p,
.welcome-card, .message-label, .source-excerpt, .composer-footer, .page-footer { color: #52627e; }
.eyebrow-line { background: #4a5eff; }
.hero h1 span { color: #4255bb; }
.hero > p, .hero-meta { color: #455475; }
.meta-divider { color: #8d9ab6; }
.count-pill { background: #ebefff; color: #3447a1; }
.drop-zone { border-color: #aab9e7; background: linear-gradient(135deg, #fafbff, #eff2ff); }
.drop-zone:hover, .drop-zone.dragging { border-color: #4a5eff; background: #ebefff; }
.upload-icon { border-color: #d4def6; background: #fff; color: #4255bb; }
.drop-title, .chat-intro strong, .welcome-card strong, .doc-name { color: #172033; }
.drop-subtitle, .notice, .empty-state { color: #52627e; }
.notice.success, .privacy-note span:first-child { color: #3447a1; }
.library-subheading { color: #4255bb; }
.icon-button, .text-button { color: #3447a1; }
.icon-button:hover, .text-button:hover { border-color: #d4def6; background: #ebefff; color: #273969; }
.doc-row:hover { background: #f4f6ff; }
.file-badge { border-color: #d4def6; background: #ebefff; color: #3447a1; }
.delete-doc { color: #667691; }
.chat-intro { border-color: #dce4f5; background: #fafbff; }
.assistant-avatar { background: #ebefff; color: #4255bb; }
.welcome-mark { color: #4a5eff; }
.message-bubble { border-color: #dce4f5; background: #fafbff; color: #25324b; }
.message.user .message-bubble { border-color: #d4def6; background: #ebefff; color: #273969; }
.message-bubble h1, .message-bubble h2, .message-bubble h3 { color: #172033; }
.message-bubble pre { border-color: #dce4f5; background: #f0f3fd; }
.message-bubble blockquote { border-color: #4a5eff; color: #455475; }
.message-bubble th, .message-bubble td { border-color: #dce4f5; }
.message-bubble th { background: #ebefff; color: #273969; }
.source-card { border-color: #dce4f5; background: #fafbff; }
.source-title { color: #273969; }
.source-page { color: #4255bb; }
.composer { border-color: #cbd5eb; box-shadow: 0 5px 18px #253f8912; }
.composer:focus-within { border-color: #4a5eff; box-shadow: 0 0 0 3px #4a5eff22; }
.composer textarea::placeholder { color: #667691; }
.composer-footer { border-color: #e5eafb; }
.send-button { background: linear-gradient(90deg, #4a5eff, #188bbd); box-shadow: 0 10px 25px #4a5eff36; }
.send-button:hover { background: linear-gradient(90deg, #3447c8, #127da8); }

@media (max-width: 980px) {
  .page-shell { width: min(100% - 40px, 760px); padding-top: 20px; }
  .hero { padding: 36px 2px 24px; }
  .workspace-grid { grid-template-columns: 1fr; gap: 16px; }
  .chat-panel { min-height: 640px; padding: 22px; }
  .library-panel { order: 2; }
  .chat-panel { order: 1; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .page-shell { width: calc(100% - 28px); padding: 12px 0 18px; }
  .model-details { margin: 12px 0 18px; }
  .hero { padding: 32px 1px 20px; }
  .eyebrow { flex-wrap: wrap; gap: 8px; font-size: 12px; }
  .hero h1 { margin-top: 15px; font-size: clamp(34px, 9vw, 44px); }
  .hero > p { font-size: 16px; }
  .hero-meta { gap: 8px; margin-top: 16px; font-size: 13px; }
  .section-heading h2 { font-size: 22px; }
  .library-panel { padding: 20px 16px 17px; }
  .chat-panel { min-height: 620px; padding: 19px 15px 15px; }
  .chat-heading { align-items: flex-start; }
  .text-button { min-width: 44px; padding: 7px; font-size: 13px; }
  .chat-intro { padding: 12px; }
  .chat-intro p { font-size: 13px; }
  .chat-log { min-height: 260px; max-height: 55vh; padding: 16px 1px 12px; }
  .welcome-card { min-height: 220px; font-size: 14px; }
  .welcome-card strong { font-size: 18px; }
  .message { max-width: 96%; }
  .message-bubble { padding: 12px 13px; font-size: 16px; }
  .source-title { font-size: 13px; }
  .source-page { font-size: 12px; }
  .source-excerpt { font-size: 13px; }
  .composer { padding: 10px 11px 8px; }
  .composer-footer { align-items: flex-start; font-size: 12px; }
  .send-button { min-width: 112px; min-height: 46px; padding: 8px 10px; font-size: 14px; }
  .page-footer { flex-direction: column; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* HR 화면과 동일한 글자 크기 체계 (제목 32px, 카드 제목 15px, 답변 14px). */
.model-details, .model-chip { font-size: 11px; }
.eyebrow, .section-index, .library-subheading, .page-footer { font-size: 11px; }
.hero { padding: 30px 2px 25px; }
.hero h1 { margin: 12px 0 8px; font-size: 32px; }
.hero > p { font-size: 14px; }
.hero-meta { font-size: 12px; }
.section-heading h2 { font-size: 15px; }
.panel-caption, .drop-subtitle, .doc-meta, .privacy-note, .chat-intro p,
.composer-footer, .source-page { font-size: 12px; }
.drop-title, .doc-name, .notice, .empty-state, .chat-intro strong,
.welcome-card, .message-bubble, .send-button { font-size: 14px; }
.welcome-card strong { font-size: 16px; }
.message-label { font-size: 11px; }
.message-bubble h1 { font-size: 21px; }
.message-bubble h2 { font-size: 19px; }
.message-bubble h3 { font-size: 16px; }
.source-title, .source-excerpt, .text-button { font-size: 12px; }
.composer textarea { font-size: 16px; }
@media (max-width: 600px) {
  .hero { padding: 26px 1px 18px; }
  .hero h1 { font-size: 32px; }
}

/* 넓은 화면에서는 브라우저 높이에 맞추고, 긴 목록과 대화만 내부 스크롤. */
@media (min-width: 761px) and (min-height: 701px) {
  .page-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; padding: 16px 0 12px; }
  .hero { flex: 0 0 auto; padding: 0 2px 12px; }
  .hero-meta { margin-top: 10px; }
  .model-details { margin: 8px 0 12px; }
  .workspace-grid { flex: 1; min-height: 0; gap: 14px; }
  .library-panel { display: flex; min-height: 0; flex-direction: column; overflow: hidden; padding: 16px; }
  .panel-caption { margin: 6px 0 10px; }
  .drop-zone { min-height: 96px; flex-shrink: 0; }
  .notice { margin: 4px 0; }
  .library-subheading { padding: 5px 0; }
  .document-list { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
  .privacy-note { flex-shrink: 0; margin-top: 8px; padding-top: 8px; }
  .chat-panel { min-height: 0; padding: 16px; }
  .chat-heading { margin-bottom: 10px; }
  .chat-intro { padding: 10px 12px; }
  .chat-log { min-height: 0; max-height: none; padding: 8px 4px; }
  .welcome-card { min-height: 0; flex: 1; }
  .composer { flex-shrink: 0; }
  .page-footer { flex-shrink: 0; margin-top: 8px; }
}
@media (min-width: 761px) and (max-width: 980px) and (min-height: 701px) {
  .workspace-grid { grid-template-columns: minmax(230px, 32%) minmax(0, 1fr); }
  .library-panel, .chat-panel { order: 0; }
}

/* 세로 공간이 부족하거나 폭이 좁으면 페이지가 자연스럽게 스크롤됩니다. */
@media (max-width: 760px), (max-height: 700px) {
  .chat-panel { min-height: 0; }
  .chat-log { min-height: 220px; max-height: 55vh; max-height: 55dvh; }
}
@media (max-width: 760px) {
  .page-shell { width: calc(100% - 28px); }
  .workspace-grid { grid-template-columns: 1fr; }
  .library-panel { order: 2; }
  .chat-panel { order: 1; }
}
