/* 노을 — 모바일 우선, 해 질 녘 색 */
:root {
  --bg: #fff8f3;
  --surface: #ffffff;
  --text: #2b2320;
  --muted: #7a6a63;
  --line: #f0e0d6;
  --accent: #e0674a;
  --accent-2: #f2a65a;
  --accent-ink: #ffffff;
  --user-bubble: #fde7dc;
  --noeul-bubble: #ffffff;
  --warn-bg: #fff3cd;
  --warn-line: #e9c46a;
  --danger: #b3261e;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1715; --surface: #27201d; --text: #f3e9e3; --muted: #b5a49b; --line: #3a2f2a;
    --user-bubble: #4a2f25; --noeul-bubble: #2f2723; --warn-bg: #3b3220; --warn-line: #8a7234;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
header.top .brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; }
header.top nav { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; }
header.top nav a, header.top nav button.link { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.logo-dot { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(160deg, var(--accent-2), var(--accent)); display: inline-block; }
h1 { font-size: 1.6rem; line-height: 1.3; margin: 16px 0 8px; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }
p.lead { font-size: 1.05rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.btn { white-space: nowrap; display: inline-block; border: 0; border-radius: 999px; padding: 12px 20px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
form .field { margin: 12px 0; }
label { display: block; font-size: 0.9rem; margin-bottom: 4px; }
input[type=email], input[type=password], input[type=text], select, textarea {
  width: 100%; padding: 12px; font: inherit; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: 0.95rem; }
.check input { margin-top: 5px; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; }
.muted { color: var(--muted); font-size: 0.9rem; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px; padding: 12px; margin: 12px 0; font-size: 0.95rem; }
.draft-badge { display: inline-block; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 2px 8px; font-size: 0.85rem; font-weight: 600; }

/* 채팅 */
body.chat { display: flex; flex-direction: column; height: 100dvh; }
#messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; max-width: 720px; width: 100%; margin: 0 auto; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--user-bubble); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--noeul-bubble); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg .actions { display: flex; gap: 6px; margin-top: 6px; }
.msg .actions button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.msg .actions button.on { border-color: var(--accent); color: var(--accent); }
.msg.typing { color: var(--muted); }
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.composer form { display: flex; gap: 8px; max-width: 720px; margin: 0 auto; }
.composer .btn { flex-shrink: 0; }
.composer textarea { resize: none; min-height: 46px; max-height: 140px; }
.composer .row { display: flex; justify-content: space-between; align-items: center; max-width: 720px; margin: 0 auto 6px; gap: 8px; }
#crisis-banner { display: none; background: #fdecea; color: #5f1410; border-bottom: 1px solid #f5c2bd; padding: 12px 16px; font-size: 0.95rem; }
#crisis-banner.show { display: block; }
#crisis-banner a { color: #5f1410; font-weight: 700; }
#crisis-banner button { float: right; background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: #5f1410; }
#connect-panel { display: none; margin: 0 auto 8px; }
#status.status { padding-bottom: 0; }
#connect-panel.show { display: block; }

/* 기억 화면 */
.mem-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mem-item:last-child { border-bottom: 0; }
.mem-item .meta { color: var(--muted); font-size: 0.8rem; }
pre.note { white-space: pre-wrap; font-family: inherit; margin: 0; }

/* 관리자 */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.scroll-x { overflow-x: auto; }

footer.site { color: var(--muted); font-size: 0.85rem; padding: 24px 16px; text-align: center; }
footer.site a { color: var(--muted); }
