:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f1ece4;
  --ink: #23201c;
  --ink-2: #6b645b;
  --line: #e4ddd2;
  --accent: #b9532c;
  --accent-ink: #ffffff;
  --me: #fbe9df;
  --warn: #b3261e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161412;
    --surface: #211e1b;
    --surface-2: #2b2724;
    --ink: #eeeae4;
    --ink-2: #aaa197;
    --line: #3a3531;
    --accent: #e0805a;
    --accent-ink: #1b1714;
    --me: #3a2a22;
    --warn: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161412; --surface: #211e1b; --surface-2: #2b2724; --ink: #eeeae4; --ink-2: #aaa197;
  --line: #3a3531; --accent: #e0805a; --accent-ink: #1b1714; --me: #3a2a22; --warn: #ff8a80; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
.small { font-size: 13px; color: var(--ink-2); }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; margin: 6px 0;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }

/* 안내 페이지 (링크 오류·앱 안 브라우저·개인정보) */
.notice-page, .admin, .doc { max-width: 640px; margin: 0 auto; padding: 32px 16px 48px; }
.notice-page h1, .doc h1, .admin h1 { font-size: 22px; line-height: 1.4; }
.doc h2 { font-size: 17px; margin-top: 28px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); }
td.warn { color: var(--warn); font-weight: 700; }

/* 앱 */
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
.top {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.top h1 { font-size: 16px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .count { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.icon-btn {
  min-width: 40px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; padding: 0 10px;
}
.notice { margin: 0; padding: 8px 16px; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); }

.center { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; gap: 8px; }
.center h2 { font-size: 20px; margin: 0 0 4px; }
#gbtn { min-height: 48px; margin: 8px 0; }

.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: var(--radius); word-break: break-word; }
.msg.model { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: var(--me); white-space: pre-wrap; }
.msg.error { align-self: center; background: transparent; color: var(--warn); font-size: 14px; text-align: center; }
.msg .photo-tag { display: block; font-size: 12px; color: var(--ink-2); }
.msg img.thumb { display: block; max-width: 180px; max-height: 180px; border-radius: 8px; margin-bottom: 6px; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 0 0 8px; padding-left: 22px; }
.msg h3, .msg h4 { font-size: 16px; margin: 10px 0 6px; }
.msg code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.msg .table-wrap { margin: 6px 0 8px; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px;
  padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer;
}

.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.preview { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.row { display: flex; align-items: flex-end; gap: 8px; }
.row textarea {
  flex: 1; resize: none; max-height: 160px; min-height: 44px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: inherit; line-height: 1.45;
}
.row .send { margin: 0; min-width: 64px; }
.foot { text-align: center; padding: 4px 0 0; }
