:root {
  --accent: #111111;
  --accent-ink: #ffffff;
  --accent-soft: #eef0f3;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #6a717d;
  --line: #e3e6ea;
  --hover: #f1f3f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
:root.dark {
  --accent: #f2f2f2;
  --accent-ink: #111111;
  --accent-soft: #2a2d33;
  --bg: #121417;
  --panel: #1b1e22;
  --ink: #eceef1;
  --muted: #9aa1ac;
  --line: #2c3036;
  --hover: #24282d;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
[hidden] { display: none !important; }

.layout { display: flex; height: 100vh; gap: 0; }

/* Sidebar */
.sidebar {
  width: 260px; flex: none; margin: 10px; padding: 14px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 10px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); }
.brand-name { font-weight: 650; font-size: 14px; }
.brand-sub { color: var(--muted); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left;
  text-decoration: none; font-size: 13.5px;
}
.nav-item:hover { background: var(--hover); }
.ico { width: 16px; text-align: center; color: var(--muted); }
.history-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 6px; }
.history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.history-empty { color: var(--muted); text-align: center; font-size: 13px; padding: 14px 0; }
.history-item {
  padding: 7px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer;
  text-align: left; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item:hover { background: var(--hover); }
.history-item.active { background: var(--accent-soft); font-weight: 600; }
.sidebar-foot { margin-top: auto; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.menu-btn { display: none; position: absolute; top: 12px; left: 12px; z-index: 5; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 4px 10px; cursor: pointer; }

.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); font-weight: 600; letter-spacing: -.01em; margin: 0 0 18px; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px; max-width: 920px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12.5px; font-weight: 550;
  border: 1px solid var(--line); background: var(--panel); border-radius: 9px; cursor: pointer; box-shadow: var(--shadow);
}
.chip:hover { border-color: var(--muted); }
.chip.active { background: var(--accent-soft); border-color: var(--ink); }
.suggestions {
  width: min(720px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.suggestion { display: block; width: 100%; text-align: left; padding: 11px 14px; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; font-size: 13px; }
.suggestion:first-child { border-top: 0; }
.suggestion:hover { background: var(--hover); }
.human-pill {
  margin-top: 18px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--accent-soft); cursor: pointer; font-size: 12.5px; font-weight: 550;
}
.human-pill:hover { border-color: var(--muted); }

/* Thread */
.thread { flex: 1; overflow-y: auto; padding: 28px 24px 12px; }
.msg { max-width: 760px; margin: 0 auto 18px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); border-radius: 16px 16px 4px 16px; padding: 9px 14px; max-width: 80%; white-space: pre-wrap; }
.msg.bot { gap: 10px; }
.msg.bot .avatar { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.msg.bot .bubble { flex: 1; min-width: 0; }
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg.bot .msg-col { flex: 1; }
.msg.user .msg-col { align-items: flex-end; max-width: 80%; }
.msg.user .msg-col .bubble { max-width: 100%; }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg.bot:last-child .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-action { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.msg-action:hover { background: var(--hover); color: var(--ink); }
.msg-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.msg.user .bubble.editing { background: transparent; color: var(--ink); padding: 0; width: 100%; }
.msg.user .msg-col:has(.editing) { width: 100%; max-width: 100%; }
.edit-box { width: 100%; min-height: 72px; box-sizing: border-box; resize: vertical; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); font: inherit; }
.edit-box:focus { outline: none; border-color: var(--muted); }
.edit-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.edit-cancel, .edit-send { padding: 6px 14px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; }
.edit-cancel { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.edit-send { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.answer p { margin: 0 0 10px; }
.answer ul, .answer ol { margin: 0 0 10px; padding-left: 22px; }
.answer li { margin: 3px 0; }
.answer h3, .answer h4 { margin: 14px 0 6px; font-size: 15px; }
.answer code { background: var(--hover); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.table-wrap { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; }
.answer table { border-collapse: collapse; width: 100%; font-size: 13px; }
.answer th, .answer td { text-align: left; vertical-align: top; padding: 7px 10px; border-top: 1px solid var(--line); }
.answer thead th { border-top: 0; background: var(--hover); font-weight: 600; }
.answer sup { color: var(--muted); font-size: 10px; margin-left: 1px; }
.answer a { text-decoration: underline; }
.status { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dots::after { content: "..."; animation: dots 1.2s steps(4, end) infinite; display: inline-block; width: 14px; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 14px; } }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.source { font-size: 11.5px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--muted); background: var(--panel); }
.source b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.msg-error { color: #b42318; font-size: 13px; }

/* Composer */
.composer-wrap { padding: 0 24px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.promo {
  width: min(720px, 100%); display: flex; align-items: center; gap: 14px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.promo-icons img { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); }
.promo-text { flex: 1; min-width: 0; }
.promo-title { font-weight: 600; font-size: 13px; }
.promo-title span { color: var(--muted); font-weight: 600; }
.promo-sub { color: var(--muted); font-size: 12px; }
.promo-link { font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.composer {
  width: min(720px, 100%); display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--muted); }
.composer input { flex: 1; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; padding: 8px 0; }
.send {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 15px; flex: none;
}
.send:disabled { opacity: .35; cursor: default; }
.send.stop { font-size: 11px; }
.disclaimer { color: var(--muted); font-size: 11px; text-align: center; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-card { position: relative; width: min(400px, 92vw); background: var(--panel); border-radius: 14px; padding: 22px 24px; border: 1px solid var(--line); }
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-card p { margin: 0 0 14px; color: var(--muted); }
.modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.contact { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.contact-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.contact a { font-weight: 600; text-decoration: none; }

@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 10; top: 0; bottom: 0; left: -300px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .menu-btn { display: block; }
  .promo { display: none; }
  .hero h1 { margin-top: 30px; }
}
.source[href] { text-decoration: none; } .source[href]:hover { border-color: var(--muted); }
