:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f1d1a;
  --muted: #6f6a62;
  --line: #e6e1d8;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e5eee9;
  --user: #2f5d50;
  --user-ink: #ffffff;
  --warn: #9a5b13;
  --warn-soft: #fbf1e3;
  --error: #b3261e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412; --card: #1f1d1a; --ink: #ece8e1; --muted: #a39d93; --line: #34312c;
    --accent: #7fb3a2; --accent-ink: #10201b; --accent-soft: #23302b; --user: #2f5d50; --user-ink: #f2f7f4;
    --warn: #e0a55a; --warn-soft: #2e2618; --error: #f08b84;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tag {
  display: inline-block; font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; vertical-align: middle;
}
.avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: none; object-fit: cover;
  display: grid; place-items: center; font-size: 26px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
}
.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px 16px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 16px; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--error); font-size: 14px; min-height: 1.4em; margin: 8px 0 0; }
.notice {
  background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 12px;
  font-size: 13px; line-height: 1.55;
}

/* Intro page */
.intro { padding-block: 32px 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 14px; }
.who { display: flex; gap: 14px; align-items: center; }
.who h1 { margin: 0; font-size: 22px; line-height: 1.3; }
.who p { margin: 4px 0 0; }
.intro-text { white-space: pre-line; margin: 16px 0 0; }
.products { display: grid; gap: 10px; margin-top: 12px; }
.product {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.product.featured { border-color: var(--accent); }
.product b { font-size: 18px; }
.code-input {
  width: 100%; margin: 12px 0 12px; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); font-size: 20px; letter-spacing: 2px; text-align: center; text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.code-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
footer { padding: 20px 0 32px; text-align: center; }

/* Chat page */
.chat-page { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 2; background: var(--card); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.topbar .name { font-weight: 700; }
.credits { font-size: 13px; color: var(--muted); text-align: right; line-height: 1.35; }
.credits b { color: var(--ink); }
.thread { flex: 1; padding-block: 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 88%; }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--user); color: var(--user-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; }
.msg.assistant .bubble { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble { padding: 10px 14px; border-radius: var(--radius); overflow-wrap: anywhere; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 8px; padding-left: 1.3em; }
.bubble li { margin: 2px 0; }
sup.ref {
  font-size: 11px; line-height: 1; padding: 1px 4px; margin-left: 1px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.meta { font-size: 12px; color: var(--muted); margin: 4px 4px 0; }
.sources { margin-top: 6px; font-size: 13px; }
.sources summary { cursor: pointer; color: var(--muted); list-style: none; padding: 2px 4px; }
.sources summary::-webkit-details-marker { display: none; }
.source { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }
.source .title { font-weight: 600; }
.source blockquote { margin: 6px 0 0; padding-left: 10px; border-left: 3px solid var(--accent-soft); color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--accent); padding: 0; font-size: 13px; cursor: pointer; margin-top: 6px; }
.handoff { margin-top: 8px; }
.handoff.card {
  display: grid; gap: 8px; justify-items: start; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--accent); border-radius: 12px;
}
.handoff-title { font-weight: 600; }
.handoff-desc { font-size: 13px; color: var(--muted); line-height: 1.6; }
.topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.fill { margin-top: 8px; }
.composer .modes { flex-wrap: wrap; align-items: center; gap: 6px; padding-block: 8px 0; }
.mode {
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer;
}
.mode.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip {
  border: 1px solid var(--accent); background: var(--card); color: var(--accent); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; cursor: pointer;
}
.handoff a { display: inline-block; padding: 8px 14px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
.composer {
  position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.composer .wrap { display: flex; gap: 8px; align-items: flex-end; padding-block: 10px; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; max-height: 40vh; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; background: var(--bg); line-height: 1.5;
}
.composer textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.composer .btn { width: auto; padding: 10px 16px; }
.composer-hint { font-size: 12px; padding: 0 16px 8px; max-width: 640px; margin: 0 auto; }
.empty { text-align: center; padding: 24px 8px; }
.empty .avatar { margin: 0 auto 10px; }

/* Compliance: AI label bar, answer badge, consent checkbox, footer */
.aigc-bar {
  font-size: 12px; line-height: 1.4; text-align: center; padding: 4px 16px 6px;
  background: var(--accent-soft); color: var(--accent);
}
.ai-badge {
  display: inline-block; font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--muted); font-weight: 600; vertical-align: 1px;
}
.meta a { color: var(--muted); }
.agree { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.agree input { margin-top: 3px; flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.site-footer p { margin: 2px 0; line-height: 1.5; }
.site-footer a { color: var(--muted); }
.chat-page .site-footer { text-align: center; padding-block: 4px 12px; font-size: 12px; }

/* Legal and report pages */
.doc { padding-block: 24px 16px; }
.doc h1 { font-size: 22px; margin: 0 0 4px; }
.doc h2 { font-size: 17px; margin: 22px 0 6px; }
.doc p, .doc li { font-size: 15px; }
.doc ul, .doc ol { padding-left: 1.3em; }
.field { display: block; width: 100%; margin: 6px 0 12px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); }
textarea.field { min-height: 140px; resize: vertical; }
