:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --accent: #0071e3;
  --accent-ink: #ffffff;
  --success: #248a3d;
  --danger: #b42318;
  --radius: 18px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-soft: #2c2c2e;
  --ink: #f5f5f7;
  --muted: #a1a1a6;
  --line: #38383a;
  --accent: #2997ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.shell {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}
.rail, .chat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rail { padding: 28px; }
.brand-name { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: 0; }
.brand-sub { margin: 6px 0 28px; color: var(--muted); }
.rail-section { margin-top: 28px; }
.rail-section h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.products, .prompts { display: grid; gap: 10px; }
.product, .prompts button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--ink);
  text-align: left;
  padding: 13px 14px;
}
.product span { display: block; font-weight: 650; }
.product small { display: block; margin-top: 3px; color: var(--muted); }
.product:hover, .prompts button:hover { border-color: var(--accent); }
.notice { margin: 28px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.chat { display: flex; flex-direction: column; min-height: 680px; overflow: hidden; }
.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.chat-head h1 { margin: 0; font-size: 24px; letter-spacing: 0; }
.chat-head p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.head-actions button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 13px;
}
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.message { max-width: 78%; padding: 13px 15px; border-radius: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.message.assistant { align-self: flex-start; background: var(--surface-soft); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.message.error { border-color: var(--danger); color: var(--danger); }
.citations { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.citations span { border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; color: var(--muted); font-size: 12px; }
.copy-button { margin-top: 10px; border: 0; background: transparent; color: var(--accent); padding: 0; font-size: 13px; }
.setup { margin: 0 24px 16px; border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface-soft); }
.setup p { margin: 0 0 10px; line-height: 1.6; }
.setup a { color: var(--accent); font-weight: 650; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 16px 24px 24px; border-top: 1px solid var(--line); }
.composer textarea {
  resize: vertical;
  min-height: 48px;
  max-height: 140px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface-soft);
  color: var(--ink);
}
.composer button {
  align-self: end;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 20px;
  font-weight: 650;
}
.composer button:disabled { opacity: .55; cursor: not-allowed; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; width: calc(100% - 20px); margin: 10px auto; }
  .rail { padding: 20px; }
  .chat { min-height: 620px; }
  .message { max-width: 92%; }
  .chat-head { align-items: flex-start; flex-direction: column; }
  .head-actions { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
