:root {
  --ink: #17201d;
  --muted: #6c756f;
  --line: #dfe3de;
  --paper: #f7f6f1;
  --surface: #fffef9;
  --green: #164b3b;
  --green-2: #246c55;
  --lime: #c8f36b;
  --sand: #e9e5d9;
  --danger: #a23a2a;
  --shadow: 0 18px 60px rgba(25, 39, 33, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { overflow: hidden; }
.app-shell { height: 100dvh; overflow: hidden; }
.workspace, .sidebar, .evidence-panel { max-height: 100dvh; }
.conversation { min-height: 0; }
.topbar, .composer-wrap { flex-shrink: 0; }
.contract-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 30px; border-bottom: 1px solid var(--line); }
.contract-toolbar label { font-size: 11px; white-space: nowrap; color: var(--muted); }
.contract-toolbar select { min-width: 0; flex: 1; width: 120px; padding: 8px; border: 1px solid var(--line); background: white; font-size: 12px; }
.contract-toolbar button { white-space: nowrap; border: 1px solid var(--green); background: transparent; padding: 8px 10px; color: var(--green); cursor: pointer; font-size: 11px; }
.contract-toolbar button:hover { background: #edf4ef; }
.contract-toolbar button:disabled, .primary-button:disabled { opacity: .5; cursor: wait; }
#open-summary { display: none; }
.demo-notice { padding: 8px 30px; background: #f1f4ea; color: #657552; font-size: 10px; }
#storage-label { display: inline-block; margin-left: 8px; }
#review-dialog { width: min(780px, calc(100vw - 24px)); max-height: 90dvh; overflow-y: auto; }
.review-item { padding: 14px 0; border-top: 1px solid var(--line); }
.review-item summary { cursor: pointer; font-size: 14px; }
.review-item summary small { float: right; color: var(--green); font-size: 11px; }
.review-item p { font-size: 12px; line-height: 1.75; white-space: pre-line; color: #49554e; }
.review-item button { border: 0; background: #e6efdf; color: var(--green); padding: 8px 12px; cursor: pointer; font-size: 12px; }
.review-locator { font-size: 10px; color: var(--muted); }
.document-item.selected { background: #284a3d; border-left: 2px solid var(--lime); }
button.document-item { width: 100%; border: 0; text-align: left; background: transparent; cursor: pointer; }
button.document-item.selected { background: #284a3d; }
.document-item > span:last-child { min-width: 0; }
@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr); }
  #open-summary { display: block; }
  .evidence-panel.mobile-evidence { display: block; position: fixed; z-index: 4; inset: 90px 12px 12px; min-height: 0; border: 1px solid var(--line); box-shadow: var(--shadow); }
}
@media (max-width: 740px) {
  .contract-toolbar { padding: 10px 14px; gap: 5px; }
  .contract-toolbar label { display: none; }
  .demo-notice { padding: 6px 14px; font-size: 9px; }
  .top-actions { gap: 0; }
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  letter-spacing: -.015em;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(480px, 1fr) 360px;
  min-height: 100vh;
  background: var(--surface);
}
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 26px 18px 18px;
  background: #132e26;
  color: #f7fbf7;
  min-height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; padding: 0 8px 28px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #769488; color: var(--lime); font: 600 19px Georgia, serif; }
.brand strong, .brand small, .identity strong, .identity small { display: block; }
.brand strong { font: 600 19px Georgia, "Times New Roman", serif; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: #9eb3aa; font-size: 10px; text-transform: uppercase; letter-spacing: .11em; }
.nav { display: grid; gap: 4px; }
.nav-item { width: 100%; border: 0; background: transparent; color: #b9c9c2; padding: 11px 12px; text-align: left; border-radius: 8px; cursor: pointer; font-size: 13px; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-icon { display: inline-block; width: 25px; color: var(--lime); font-size: 18px; vertical-align: -1px; }
.library { min-height: 0; flex: 1; margin-top: 30px; overflow: auto; }
.section-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 10px; color: #879f95; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.count-pill { border: 1px solid #3f5a50; border-radius: 99px; min-width: 24px; padding: 2px 6px; text-align: center; }
.document-list { display: grid; gap: 4px; }
.document-item { display: grid; grid-template-columns: 31px 1fr; gap: 8px; padding: 9px 10px; border-radius: 7px; color: #d6e0dc; }
.document-item:hover { background: rgba(255,255,255,.055); }
.doc-icon { display: grid; place-items: center; width: 28px; height: 32px; border: 1px solid #5f786e; color: var(--lime); font: 600 9px/1 monospace; }
.document-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.document-item small { color: #82988f; font-size: 10px; }
.security-card { display: flex; gap: 10px; margin: 18px 0 14px; padding: 12px; border: 1px solid #345348; background: #193c31; }
.security-icon { color: var(--lime); }
.security-card strong { font-size: 11px; }
.security-card p { margin: 3px 0 0; color: #9cb3aa; font-size: 10px; line-height: 1.45; }
.identity { display: grid; grid-template-columns: 34px 1fr 8px; align-items: center; gap: 9px; padding: 12px 7px 2px; border-top: 1px solid #345047; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--sand); color: var(--green); font-size: 12px; font-weight: 800; }
.identity strong { font-size: 11px; }
.identity small { margin-top: 2px; color: #88a198; font: 9px monospace; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(200,243,107,.12); }

.workspace { display: flex; min-width: 0; min-height: 100vh; flex-direction: column; background: var(--surface); }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 91px; padding: 20px 32px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 6px; color: var(--green-2); font: 700 9px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .17em; }
.topbar h1 { margin: 0; font: 500 24px Georgia, "Noto Serif KR", serif; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.role-control { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.role-control span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.role-control select { border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; font-weight: 700; }
.provider-badge { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 5px; background: #edf4ef; color: var(--green); font: 700 9px monospace; letter-spacing: .08em; }
.provider-badge i { width: 6px; height: 6px; border-radius: 50%; background: #39a673; }

.conversation { flex: 1; overflow-y: auto; padding: 34px 7vw 24px; }
.welcome { max-width: 670px; margin: 6vh auto 0; text-align: center; }
.welcome-symbol { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 25px; border: 1px solid var(--green); color: var(--green); font: 28px Georgia, serif; transform: rotate(45deg); }
.welcome-symbol::first-line { transform: rotate(-45deg); }
.welcome h2 { margin: 0; font: 500 45px/1.12 Georgia, "Noto Serif KR", serif; letter-spacing: -.045em; }
.welcome-copy { max-width: 460px; margin: 17px auto 28px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); text-align: left; }
.suggestions button { position: relative; min-height: 118px; padding: 20px 17px; border: 0; border-right: 1px solid var(--line); background: #fff; cursor: pointer; transition: background .18s, transform .18s; }
.suggestions button:last-child { border-right: 0; }
.suggestions button:hover { background: #f1f5ef; transform: translateY(-2px); }
.suggestions span { display: block; color: var(--green-2); font: 700 9px monospace; }
.suggestions strong { display: block; margin-top: 22px; font: 600 14px Georgia, "Noto Serif KR", serif; }
.suggestions small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.message { max-width: 760px; margin: 0 auto 27px; }
.message-user { display: flex; justify-content: flex-end; }
.message-user .bubble { max-width: 75%; padding: 13px 17px; border-radius: 15px 15px 3px 15px; background: var(--green); color: white; font-size: 13px; line-height: 1.6; }
.message-user .bubble small { display: block; margin-bottom: 4px; color: #c8dfd6; font-size: 9px; }
.message-answer { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.ai-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--green); color: var(--green); font: 16px Georgia, serif; }
.answer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.answer-head strong { font: 600 12px Georgia, serif; }
.answer-head small { color: var(--muted); font: 9px monospace; }
.answer-body { color: #2d3532; font-size: 13px; line-height: 1.9; }
.answer-body p { margin: 0 0 8px; }
.answer-body .citation { display: inline-grid; place-items: center; min-width: 25px; height: 18px; padding: 0 5px; border: 0; border-radius: 3px; background: #dff0e6; color: var(--green); font: 700 9px monospace; cursor: pointer; }
.answer-actions { display: flex; gap: 6px; margin-top: 12px; }
.answer-actions button { border: 1px solid var(--line); background: #fff; width: 28px; height: 26px; border-radius: 5px; color: var(--muted); cursor: pointer; }
.thinking { animation: pulse 1.2s ease-in-out infinite; color: var(--muted); font-size: 12px; }
@keyframes pulse { 50% { opacity: .45; } }

.composer-wrap { padding: 10px 7vw 18px; background: var(--surface); }
.composer { max-width: 760px; margin: auto; padding: 13px 14px 9px; border: 1px solid #aeb9b3; background: #fff; box-shadow: 0 10px 35px rgba(24,48,40,.08); }
.composer:focus-within { border-color: var(--green-2); box-shadow: 0 12px 38px rgba(24,75,59,.12); }
.composer textarea { display: block; resize: none; width: 100%; max-height: 130px; border: 0; outline: 0; color: var(--ink); font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: #9ba39e; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; }
.scope { display: flex; gap: 6px; color: var(--muted); font-size: 9px; }
.scope span:first-child { color: var(--green); font-size: 13px; }
#send-button { display: grid; place-items: center; width: 31px; height: 31px; border: 0; border-radius: 50%; background: var(--green); color: var(--lime); cursor: pointer; font-size: 17px; }
#send-button:disabled { background: #9aa7a1; cursor: wait; }
.disclaimer { margin: 8px auto 0; color: #9aa19d; font-size: 8px; text-align: center; letter-spacing: .02em; }

.evidence-panel { padding: 27px 22px; border-left: 1px solid var(--line); background: #f2f0e8; min-height: 100vh; overflow-y: auto; }
.evidence-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 21px; border-bottom: 1px solid #d5d2c8; }
.evidence-header h2 { margin: 0; font: 500 18px Georgia, "Noto Serif KR", serif; }
.source-count { padding: 5px 7px; border: 1px solid #c8c7be; color: var(--muted); font: 700 8px monospace; }
.contract-overview { padding: 15px 0 4px; }
.overview-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.overview-title strong { overflow: hidden; font: 600 13px Georgia, "Noto Serif KR", serif; text-overflow: ellipsis; white-space: nowrap; }
.overview-title span { flex: none; color: var(--muted); font: 8px monospace; }
.overview-items { display: grid; gap: 5px; }
.overview-item { display: grid; grid-template-columns: 103px 1fr; gap: 8px; width: 100%; padding: 8px 9px; border: 1px solid #d7d5cb; background: rgba(255,255,255,.58); text-align: left; cursor: pointer; }
.overview-item:hover { border-color: var(--green-2); background: #fffef9; }
.overview-item > span { color: var(--ink); font-size: 9px; font-weight: 700; }
.overview-item i { display: inline-block; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: var(--green-2); }
.overview-item small { display: -webkit-box; overflow: hidden; color: #657069; font-size: 9px; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.overview-item.missing { opacity: .58; }
.overview-item.missing i { background: #9ba19d; }
.overview-review { width: 100%; margin-top: 8px; padding: 8px; border: 1px solid var(--green); background: transparent; color: var(--green); font-size: 9px; cursor: pointer; }
.overview-loading, .overview-error, .overview-empty { padding: 18px 10px; color: var(--muted); font-size: 10px; text-align: center; }
.overview-empty strong, .overview-empty span { display: block; }
.overview-empty span { margin-top: 4px; }
.overview-error { color: var(--danger); }
.evidence-divider { display: flex; align-items: center; gap: 8px; margin: 11px 0 5px; color: var(--muted); font: 700 8px monospace; text-transform: uppercase; letter-spacing: .08em; }
.evidence-divider::after { content: ""; flex: 1; height: 1px; background: #d5d2c8; }
.evidence-empty { margin-top: 7vh; text-align: center; color: var(--muted); }
.radar { position: relative; width: 52px; height: 52px; margin: 0 auto 17px; border: 1px solid #9fafaa; border-radius: 50%; }
.radar::before, .radar::after { content: ""; position: absolute; background: #b9c4bf; }
.radar::before { left: 25px; top: 5px; width: 1px; height: 40px; }
.radar::after { left: 5px; top: 25px; width: 40px; height: 1px; }
.radar span { position: absolute; width: 6px; height: 6px; left: 31px; top: 15px; border-radius: 50%; background: var(--green-2); }
.evidence-empty strong { color: var(--ink); font: 500 14px Georgia, serif; }
.evidence-empty p { max-width: 220px; margin: 7px auto; font-size: 10px; line-height: 1.55; }
.hidden { display: none !important; }
.evidence-close { display: none; }
.mobile-evidence .evidence-close { display: block; border: 0; cursor: pointer; background: transparent; }
.trace { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin: 16px 0; }
.trace-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
.trace-item { padding: 10px; border: 1px solid #d6d4ca; background: rgba(255,255,255,.5); }
.trace-item strong { display: block; font: 600 15px Georgia, serif; }
.trace-item span { color: var(--muted); font: 8px monospace; text-transform: uppercase; letter-spacing: .06em; }
.sources { display: grid; gap: 9px; }
.source-card { padding: 14px; border: 1px solid #d1cec3; background: #fffef9; cursor: pointer; transition: border-color .16s, transform .16s; }
.source-card:hover, .source-card.active { border-color: var(--green-2); transform: translateX(-2px); }
.source-top { display: flex; align-items: center; justify-content: space-between; }
.source-label { color: var(--green); font: 800 9px monospace; }
.source-score { color: var(--muted); font: 8px monospace; }
.source-card h3 { margin: 9px 0 4px; font: 600 13px Georgia, "Noto Serif KR", serif; }
.source-path { overflow: hidden; color: var(--green-2); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.source-excerpt { display: -webkit-box; overflow: hidden; margin: 11px 0 0; color: #606963; font-size: 10px; line-height: 1.65; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.source-card.active .source-excerpt { display: block; }
.source-meta { margin-top: 10px; color: #8c938e; font: 8px monospace; }

dialog { width: min(520px, calc(100vw - 30px)); padding: 0; border: 0; background: transparent; }
dialog::backdrop { background: rgba(9, 24, 19, .62); backdrop-filter: blur(4px); }
.dialog-card { position: relative; padding: 30px; background: var(--surface); box-shadow: var(--shadow); }
.dialog-card h2 { margin: 0; font: 500 30px Georgia, "Noto Serif KR", serif; }
.dialog-close { position: absolute; right: 16px; top: 13px; border: 0; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; }
.dialog-copy { color: var(--muted); font-size: 11px; line-height: 1.55; }
.file-drop { display: grid; place-items: center; min-height: 145px; margin: 20px 0; border: 1px dashed #9aa9a2; background: #f4f5ef; cursor: pointer; }
.file-drop input { display: none; }
.upload-symbol { color: var(--green); font-size: 27px; }
.file-drop strong { margin: 7px 0 4px; font-size: 12px; }
.file-drop small { color: var(--muted); font-size: 9px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; }
.form-grid input, .form-grid select { width: 100%; padding: 10px; border: 1px solid var(--line); background: #fff; outline: 0; font-size: 11px; }
.primary-button { width: 100%; margin-top: 17px; padding: 12px; border: 0; background: var(--green); color: white; cursor: pointer; font-size: 11px; font-weight: 700; }
.upload-status { min-height: 16px; margin-top: 9px; color: var(--green-2); font-size: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; transform: translateY(80px); padding: 11px 15px; border-radius: 5px; background: var(--ink); color: white; opacity: 0; font-size: 11px; transition: .25s; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 210px 1fr; }
  .evidence-panel { display: none; }
}
@media (max-width: 740px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 16px 18px; }
  .topbar h1 { font-size: 19px; }
  .role-control span, .provider-badge { display: none; }
  .conversation { padding: 24px 18px; }
  .welcome { margin-top: 3vh; }
  .welcome h2 { font-size: 35px; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestions button { min-height: 86px; border-right: 0; border-bottom: 1px solid var(--line); }
  .suggestions button:last-child { border-bottom: 0; }
  .suggestions strong { margin-top: 12px; }
  .composer-wrap { padding: 8px 18px 14px; }
}
