:root {
  --ink: #28302d;
  --muted: #737b76;
  --line: #e4e8e3;
  --paper: #ffffff;
  --canvas: #f7f8f6;
  --mint: #e3f0e9;
  --green: #287b62;
  --green-dark: #1d5e4b;
  --orange: #d88447;
  --shadow: 0 16px 45px rgba(38, 54, 46, 0.08);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.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; }

.site-header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 72px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--green); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 8px 0; font-size: 13px; }
.text-button:hover { color: var(--green-dark); }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 50px 0 80px; }
.welcome-band { display: flex; justify-content: space-between; gap: 24px; align-items: end; padding: 0 4px 34px; }
.eyebrow { margin: 0 0 12px; color: var(--orange); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(32px, 5vw, 54px); line-height: 1.1; letter-spacing: 0; font-weight: 800; }
.welcome-copy { max-width: 620px; margin-bottom: 0; color: var(--muted); line-height: 1.75; }
.welcome-meta { display: flex; flex-direction: column; align-items: end; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.welcome-meta span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--orange); }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; align-items: start; }
.chat-panel, .side-note, .admin-panel { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.chat-panel { min-height: 580px; padding: clamp(22px, 4vw, 42px); }
.messages { min-height: 310px; }
.message { max-width: 820px; padding: 18px 20px; margin-bottom: 16px; line-height: 1.75; }
.assistant-message { border-left: 3px solid var(--green); background: #fbfcfb; }
.user-message { margin-left: auto; border-right: 3px solid var(--orange); background: #fffaf5; }
.message-label { margin-bottom: 8px; color: var(--green-dark); font-size: 12px; font-weight: 800; }
.message p:last-child { margin-bottom: 0; }
.message strong { color: var(--green-dark); font-weight: 800; }
.message a { color: var(--green-dark); text-decoration: underline; }
.message-meta { margin-top: 14px; color: var(--muted); font-size: 11px; }
.message-sources { display: grid; gap: 5px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.message-sources a { overflow-wrap: anywhere; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.quick-actions a, .quick-actions button { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 11px; border: 1px solid #cfe0d8; border-radius: 7px; color: var(--green-dark); background: #f5faf7; text-decoration: none; font-size: 12px; }
.quick-actions a:hover, .quick-actions button:hover { background: var(--mint); }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 16px; }
.suggestions button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #fff; font-size: 12px; }
.suggestions button:hover { border-color: #bdd5c9; color: var(--green-dark); background: #f7fbf8; }
.ask-form { padding-top: 15px; border-top: 1px solid var(--line); }
.ask-form textarea, .admin-form input, .admin-form textarea, .admin-form select, .admin-login-row input { width: 100%; border: 1px solid #d8ded9; border-radius: 7px; color: var(--ink); background: #fff; outline: none; }
.ask-form textarea { resize: vertical; min-height: 92px; padding: 14px; line-height: 1.6; }
.ask-form textarea:focus, .admin-form input:focus, .admin-form textarea:focus, .admin-form select:focus, .admin-login-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(40, 123, 98, .1); }
.ask-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 10px; }
.ask-actions span, .privacy-note, .field-help { color: var(--muted); font-size: 11px; line-height: 1.6; }
.primary-button, .secondary-button { min-height: 40px; padding: 9px 16px; border-radius: 7px; font-weight: 800; }
.primary-button { border: 1px solid var(--green); color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.secondary-button { border: 1px solid #c9d9d0; color: var(--green-dark); background: #f6faf7; }
.privacy-note { margin: 14px 0 0; }

.side-note { padding: 24px 22px; }
.side-note-block + .side-note-block { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.note-number { color: var(--orange); font-size: 11px; font-weight: 800; }
.side-note h2 { margin: 9px 0 7px; font-size: 16px; }
.side-note p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

.admin-panel { margin-top: 22px; padding: clamp(22px, 4vw, 36px); }
.admin-heading, .admin-login-row, .list-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-heading { margin-bottom: 22px; }
.admin-heading h2 { margin-bottom: 0; font-size: 24px; }
.admin-login-row { justify-content: flex-start; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.admin-login-row label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.admin-login-row input { width: min(300px, 100%); padding: 10px 12px; }
.admin-message { min-height: 20px; margin: 12px 0 0; color: var(--green-dark); font-size: 12px; }
.admin-test-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 18px; }
.admin-test-row label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.admin-test-row input { width: min(240px, 100%); padding: 10px 12px; border: 1px solid #d8ded9; border-radius: 7px; }
.admin-grid { display: grid; grid-template-columns: minmax(260px, .85fr) minmax(0, 1.15fr); gap: 28px; margin-top: 18px; }
.admin-form { padding-right: 28px; border-right: 1px solid var(--line); }
.admin-form h3, .document-list-wrap h3 { margin-bottom: 18px; font-size: 16px; }
.admin-form label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.admin-form input, .admin-form textarea, .admin-form select { margin-top: 6px; padding: 10px 12px; }
.admin-form textarea { resize: vertical; line-height: 1.6; }
.admin-form .primary-button { width: 100%; margin-top: 5px; }
.document-list { display: grid; gap: 9px; }
.document-item { display: flex; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 7px; background: #fcfdfc; }
.document-item strong, .document-item small { display: block; }
.document-item strong { margin-bottom: 4px; font-size: 13px; }
.document-item small { color: var(--muted); font-size: 11px; }
.document-delete { align-self: start; border: 0; color: #b55c52; background: transparent; font-size: 11px; }
.empty-state { color: var(--muted); font-size: 12px; }

@media (max-width: 800px) {
  .page-shell { width: min(100% - 28px, 680px); padding-top: 32px; }
  .welcome-band { display: block; padding-bottom: 24px; }
  .welcome-meta { flex-direction: row; align-items: start; margin-top: 16px; }
  .chat-layout, .admin-grid { grid-template-columns: 1fr; }
  .side-note { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  .side-note-block + .side-note-block { margin-top: 0; padding-top: 0; padding-left: 18px; border-top: 0; border-left: 1px solid var(--line); }
  .admin-form { padding-right: 0; padding-bottom: 22px; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-login-row { align-items: stretch; flex-direction: column; }
  .admin-login-row input { width: 100%; }
  .admin-test-row { align-items: stretch; flex-direction: column; }
  .admin-test-row input { width: 100%; }
}

@media (max-width: 480px) {
  .site-header { height: 64px; padding: 0 18px; }
  .page-shell { width: calc(100% - 20px); }
  .chat-panel { padding: 20px 16px; }
  h1 { font-size: 34px; }
  .welcome-meta { display: grid; gap: 5px; }
  .side-note { display: block; }
  .side-note-block + .side-note-block { margin-top: 22px; padding-top: 22px; padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .ask-actions { align-items: stretch; flex-direction: column; }
  .ask-actions .primary-button { width: 100%; }
}
