/* aiclient — Claude-inspired warm minimal theme */
:root {
  --bg: #faf9f5;
  --bg-sidebar: #f0eee6;
  --surface: #ffffff;
  --surface-2: #f5f4ee;
  --border: #e3e0d3;
  --border-strong: #cfccbe;
  --ink: #29261b;
  --ink-secondary: #56523f;
  --muted: #83806e;
  --fg: var(--ink); /* alias — prefer --ink */
  --accent: #d97757;
  --accent-hover: #c05f3c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(217, 119, 87, 0.1);
  --user-bubble: #f0eee6;
  --code-bg: #23211d;
  --code-ink: #e8e6dd;
  --danger: #b3382c;
  --ok: #3d7a48;
  --shadow: 0 4px 24px rgba(41, 38, 27, 0.08);
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --control-h: 32px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", Georgia, "Times New Roman", "Songti SC", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #262624;
  --bg-sidebar: #1f1e1c;
  --surface: #30302e;
  --surface-2: #343431;
  --border: #3d3d39;
  --border-strong: #52524c;
  --ink: #f0eee6;
  --ink-secondary: #c9c6ba;
  --muted: #918e82;
  --user-bubble: #393937;
  --code-bg: #1b1a18;
  --code-ink: #e8e6dd;
  --danger: #e0685a;
  --ok: #7fbb8a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
::selection { background: rgba(217, 119, 87, 0.25); }

.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-h); height: var(--control-h); border-radius: var(--radius-sm); color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.svg-sm, .icon-btn.sm { width: 26px; height: 26px; border-radius: var(--radius-xs); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted);
  padding: 4px 8px; border-radius: var(--radius-sm);
}
.mini-btn:hover { background: var(--surface-2); color: var(--ink); }
.mini-btn.on { color: var(--accent); background: var(--accent-soft); }
.mini-btn svg { width: 14px; height: 14px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100%; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.main.is-home { background: var(--bg); }
.topbar-home { opacity: 0.85; }
.topbar .title-muted { color: var(--muted); font-weight: 500; font-size: 14px; }
.home-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px 48px; min-height: 0; overflow-y: auto;
}
.home-greeting { text-align: center; margin-bottom: 28px; max-width: 560px; }
.home-greeting .star { width: 40px; height: 40px; margin-bottom: 14px; color: var(--accent); }
.home-hello {
  font-family: var(--font-serif); font-weight: 400; font-size: clamp(28px, 4vw, 40px);
  margin: 0 0 10px; color: var(--ink); letter-spacing: -0.02em; line-height: 1.2;
}
.home-sub { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.home-tip { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 32px)); z-index: 2; }
.home-ideas { width: min(720px, 100%); margin-top: 22px; }
.home-ideas-label {
  font-size: 12px; color: var(--muted); margin-bottom: 10px; letter-spacing: 0.02em;
}
.home-ideas-list { display: flex; flex-wrap: wrap; gap: 8px; }
.home-idea {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-secondary); font-size: 13.5px; text-align: left;
}
.home-idea:hover { border-color: rgba(217, 119, 87, 0.4); color: var(--accent); background: var(--accent-soft); }
.composer-wrap.hero {
  width: min(720px, 100%); padding: 0; flex: none;
}
.composer.composer-hero {
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(41, 38, 27, 0.04), 0 8px 28px rgba(41, 38, 27, 0.06);
  padding-top: 4px;
}
.composer.composer-hero > textarea {
  min-height: 72px; font-size: 15.5px; padding: 14px 16px 8px;
}
[data-theme="dark"] .composer.composer-hero {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 10px 32px rgba(0, 0, 0, 0.25);
}

/* ---------- sidebar (layout: brand + icons, pill CTA; keep original palette) ---------- */
.sidebar {
  width: 280px; flex: none; background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: margin-left 0.2s ease;
}
.sidebar.closed { margin-left: -280px; }
.sidebar-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 12px 6px 16px;
}
.sidebar-head-actions {
  display: flex; align-items: center; gap: 2px; flex: none; margin-left: auto;
}
.sidebar-head-actions .icon-btn {
  color: var(--muted);
  width: 34px; height: 34px; border-radius: 10px;
}
.sidebar-head-actions .icon-btn:hover {
  color: var(--ink); background: rgba(41, 38, 27, 0.05);
}
.sidebar-head-actions .icon-btn.on {
  color: var(--accent); background: var(--accent-soft);
}
[data-theme="dark"] .sidebar-head-actions .icon-btn:hover {
  background: rgba(240, 238, 230, 0.06);
}
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
  font-family: var(--font-sans); font-size: 20px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1; color: var(--accent);
}
.brand-btn {
  background: transparent; border: 0; padding: 0; cursor: pointer; text-align: left;
}
.brand-btn:hover { opacity: 0.88; }
.brand .logo { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.sidebar-nav-pills {
  display: flex; gap: 6px; padding: 4px 12px 8px;
}
.nav-pill {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; border-radius: 999px; border: 1px solid transparent;
  font-size: 13px; font-weight: 550; color: var(--muted); background: transparent;
}
.nav-pill:hover { color: var(--ink); background: rgba(41, 38, 27, 0.04); }
.nav-pill.on {
  color: var(--ink); background: var(--surface);
  border-color: var(--border); box-shadow: 0 1px 2px rgba(41, 38, 27, 0.04);
}
[data-theme="dark"] .nav-pill:hover { background: rgba(240, 238, 230, 0.06); }
.new-chat-btn {
  margin: 2px 12px 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13.5px; font-weight: 600;
}
.new-chat-btn:hover { background: var(--accent-soft); border-color: rgba(217, 119, 87, 0.35); color: var(--accent); }
.sidebar-menu {
  padding: 0 8px 6px; display: flex; flex-direction: column; gap: 1px;
}
.sidebar-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: var(--radius);
  font-size: 13.5px; color: var(--ink-secondary); text-align: left;
}
.sidebar-menu-item:hover { background: rgba(41, 38, 27, 0.04); color: var(--ink); }
.sidebar-menu-item.on { background: var(--accent-soft); color: var(--accent); }
.sidebar-menu-item .menu-meta {
  margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted);
}
[data-theme="dark"] .sidebar-menu-item:hover { background: rgba(240, 238, 230, 0.06); }
.sidebar-submenu {
  padding: 0 0 4px 8px; display: flex; flex-direction: column; gap: 1px;
}
.conv-item.muted { color: var(--muted); gap: 8px; }
.recents-head { text-transform: none; letter-spacing: 0.04em; padding-top: 6px; }
.filter-chip.sm { height: 22px; padding: 0 8px; font-size: 11px; }
.search-box { margin: 0 12px 8px; position: relative; }
.search-box input {
  width: 100%; height: 36px; padding: 0 32px 0 34px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); outline: none; font-size: 13px;
}
.search-box input:focus { border-color: var(--border-strong); }
.search-box > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.search-clear:hover { color: var(--ink); background: rgba(41, 38, 27, 0.05); }
.sidebar-filters {
  padding: 0 12px 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.sidebar-filters .hint { font-size: 11px; color: var(--muted); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); background: transparent;
}
.filter-chip:hover { color: var(--ink); background: var(--surface); }
.filter-chip.on {
  color: var(--accent); border-color: rgba(217, 119, 87, 0.35);
  background: var(--accent-soft);
}
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 16px; min-height: 0; }
.conv-load-more {
  display: block; width: 100%; margin: 8px 0 4px; padding: 8px 10px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
}
.conv-load-more:hover { border-color: var(--accent); color: var(--accent); }
.conv-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 10px 8px 4px;
  display: flex; align-items: center; gap: 6px;
}
.conv-section .grow { flex: 1; }
.conv-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px 10px; border-radius: var(--radius); text-align: left; color: var(--ink-secondary);
  font-size: 13.5px;
}
.conv-item-main {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 0; flex: 1;
}
.share-badge {
  display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border-radius: 999px;
  padding: 0 6px; line-height: 16px; vertical-align: middle;
}
.radio-line {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-secondary); cursor: pointer;
}
.search-notice-banner.warn {
  border-color: rgba(217, 119, 87, 0.4);
}
.conv-item-title {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.conv-item-snippet {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.conv-empty { padding: 16px; color: var(--muted); font-size: 13px; }
.conv-item.muted { color: var(--muted); }
.conv-item span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-item:hover { background: rgba(41, 38, 27, 0.05); }
[data-theme="dark"] .conv-item:hover { background: rgba(240, 238, 230, 0.06); }
.conv-item.active { background: rgba(41, 38, 27, 0.08); color: var(--ink); font-weight: 500; }
[data-theme="dark"] .conv-item.active { background: rgba(240, 238, 230, 0.1); }
.conv-item .del {
  opacity: 0; width: 22px; height: 22px; border-radius: var(--radius-xs);
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none;
}
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { color: var(--danger); background: rgba(179, 56, 44, 0.1); }
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
  flex: none;
  background: var(--bg-sidebar);
  position: relative;
  z-index: 2;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 8px 8px 8px 10px;
  border-radius: var(--radius-md);
  background: transparent;
}
.user-chip:hover { background: rgba(41, 38, 27, 0.04); }
[data-theme="dark"] .user-chip:hover { background: rgba(240, 238, 230, 0.06); }
.avatar {
  width: var(--control-h); height: var(--control-h); border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none;
  text-transform: uppercase;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who i { display: block; font-style: normal; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 52px; }
.topbar .title {
  font-size: 14px; color: var(--ink-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.topbar .title-left { text-align: left; font-weight: 600; color: var(--ink); }
.topbar .title-edit {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px; margin: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; font-size: 14px; font-weight: 600; color: var(--ink);
  outline: none;
}
.topbar .title-edit:hover { background: rgba(41, 38, 27, 0.04); }
.topbar .title-edit:focus { border-color: var(--border); background: var(--surface); }
[data-theme="dark"] .topbar .title-edit:hover { background: rgba(240, 238, 230, 0.06); }
.topbar .spacer { width: 32px; }
.ui-tip-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 16px 8px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--accent-soft); font-size: 12.5px; color: var(--ink-secondary);
}
.ui-tip-banner span { flex: 1; min-width: 180px; line-height: 1.45; }

/* ---------- thread ---------- */
.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread-inner { max-width: 760px; margin: 0 auto; padding: 8px 20px 40px; }
.greeting { text-align: center; margin-top: min(16vh, 120px); padding: 0 12px; }
.greeting .star { width: 48px; height: 48px; margin-bottom: 10px; }
.greeting-brand {
  font-family: var(--font-sans); font-weight: 700; font-size: 36px; margin: 0 0 6px;
  letter-spacing: -0.03em; color: var(--accent);
}
.greeting-hello { font-family: var(--font-serif); font-weight: 400; font-size: 22px; margin: 0 0 8px; color: var(--ink); }
.greeting-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.greeting-prompts {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 420px; margin: 0 auto;
}
.greeting-chip {
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--ink-secondary);
}
.greeting-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.jump-bottom {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  z-index: 5; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink-secondary);
}
.jump-bottom:hover { color: var(--accent); border-color: var(--accent); }
.thread { position: relative; }

.msg { margin: 22px 0; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user-wrap {
  width: min(85%, 560px); margin-left: auto;
  display: flex; flex-direction: column; align-items: flex-end;
}
.msg-user .bubble {
  background: var(--user-bubble); border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 10px 16px; white-space: pre-wrap; word-break: break-word; align-self: stretch;
}
.msg-edit-box {
  width: 100%; min-height: 80px; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px; background: var(--surface); outline: none; resize: vertical;
}
.msg-edit-box:focus { border-color: var(--accent); }
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; width: 100%; }
.msg-user .imgs, .gen-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; justify-content: flex-end; }
.msg-user .imgs img, .gen-imgs img { max-width: 180px; max-height: 180px; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; }
.gen-imgs { justify-content: flex-start; }
.gen-imgs img { max-width: 320px; max-height: 320px; }

.msg-assistant { position: relative; }
.msg-assistant .prose { word-break: break-word; }
.branch-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 2px;
}
.branch-nav-label {
  font-size: 11px;
  color: var(--muted);
  min-width: 2.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.msg-tools-row { display: flex; gap: 6px; margin-top: 6px; opacity: 0; transition: opacity 0.15s; flex-wrap: wrap; }
.msg-assistant:hover .msg-tools-row, .msg-user:hover .msg-tools-row,
.msg-assistant:focus-within .msg-tools-row, .msg-user:focus-within .msg-tools-row { opacity: 1; }
@media (hover: none) {
  .msg-tools-row { opacity: 0.9; }
}
.model-tag { font-size: 11px; color: var(--muted); padding: 4px 4px; }

/* prose (markdown) */
.prose p { margin: 0.7em 0; }
.prose h1, .prose h2, .prose h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.3; margin: 1.2em 0 0.5em; }
.prose h1 { font-size: 1.5em; } .prose h2 { font-size: 1.3em; } .prose h3 { font-size: 1.12em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0.6em 0; }
.prose li { margin: 0.25em 0; }
.prose blockquote { border-left: 3px solid var(--border-strong); margin: 0.8em 0; padding: 2px 0 2px 14px; color: var(--ink-secondary); }
.prose table { border-collapse: collapse; margin: 0.8em 0; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 12px; }
.prose th { background: var(--surface-2); }
.prose code { font-family: var(--font-mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.prose img { max-width: 100%; border-radius: 10px; }

.codeblock { margin: 0.9em 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); padding: 5px 12px; font-size: 12px; color: var(--muted);
  font-family: var(--font-mono);
}
.codeblock-head button { color: var(--muted); font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.codeblock-head button:hover { color: var(--ink); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; background: var(--code-bg); color: var(--code-ink); font-size: 13px; line-height: 1.55; }
.codeblock pre code { background: none; border: none; padding: 0; font-size: inherit; }
.tok-kw { color: #d3869b; } .tok-str { color: #b8bb70; } .tok-com { color: #8b8578; font-style: italic; }
.tok-num { color: #d8a657; } .tok-fn { color: #7daea3; }

/* reasoning + tool cards */
.fold {
  margin: 10px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  font-size: 13px; overflow: hidden;
}
.fold-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; color: var(--ink-secondary); text-align: left; }
.fold-head svg { width: 14px; height: 14px; flex: none; transition: transform 0.15s; }
.fold-head.open svg.chev { transform: rotate(90deg); }
.fold-body { padding: 4px 14px 12px; color: var(--ink-secondary); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto; }
/* Reasoning traces can be long — don't clip mid-thought behind a short scroll box. */
.fold-body.reasoning { max-height: min(70vh, 1200px); overflow-y: auto; }
.fold-body[hidden] { display: none !important; }
.fold-meta { font-size: 11px; color: var(--muted); margin-left: 8px; }
.fold-body.reasoning .prose-reasoning {
  font-size: 13px; color: var(--ink-secondary); line-height: 1.55;
}
.fold-body.reasoning .prose-reasoning p { margin: 0.45em 0; }
.fold-body.reasoning .prose-reasoning p:first-child { margin-top: 0; }
.fold-body.reasoning .prose-reasoning p:last-child { margin-bottom: 0; }
.fold-body.reasoning .prose-reasoning h1,
.fold-body.reasoning .prose-reasoning h2,
.fold-body.reasoning .prose-reasoning h3 { font-size: 1.05em; margin: 0.8em 0 0.35em; }
.fold-body pre { background: var(--code-bg); color: var(--code-ink); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12px; }
.answer-sources { margin-top: 8px; }
.sources-toggle {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 4px 10px 4px 6px;
  font-size: 12.5px; color: var(--ink-secondary, var(--ink));
  cursor: pointer; font-family: inherit;
}
.sources-toggle:hover { border-color: var(--accent); color: var(--ink); }
.sources-toggle .chev {
  width: 14px; height: 14px; flex: none;
  transition: transform 0.15s ease; color: var(--muted);
}
.sources-toggle.open .chev { transform: rotate(90deg); }
.sources-preview {
  font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; max-width: 220px;
}
.sources-body { margin-top: 8px; }
.answer-sources-count {
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 0 6px; line-height: 18px;
}
.source-empty {
  font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface);
}
.source-favicon {
  width: 16px; height: 16px; border-radius: 3px; flex: none;
  background: var(--surface-2);
}
.source-card.flash, .kb-card.flash { outline: 2px solid var(--accent); background: var(--accent-soft); }
.search-notice-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 16px 0; padding: 8px 12px;
  font-size: 12.5px; color: var(--ink-secondary);
  background: var(--accent-soft); border: 1px solid rgba(217, 119, 87, 0.35);
  border-radius: var(--radius);
}
.search-notice-banner > span { flex: 1; min-width: 0; }
.search-hint-banner {
  font-size: 12.5px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-secondary);
}
.search-hint-banner.warn {
  border-color: rgba(217, 119, 87, 0.4); background: var(--accent-soft);
}
.search-probe-row {
  display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap;
}
.search-probe-row input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); outline: none;
}
.search-probe-row input:focus { border-color: var(--accent); }
.search-probe-result {
  margin-top: 8px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); font-size: 12.5px; background: var(--surface);
}
.search-probe-result.ok { border-color: rgba(61, 122, 72, 0.45); }
.search-probe-result.err { border-color: rgba(179, 56, 44, 0.4); }
.search-probe-samples { margin: 6px 0 0; padding-left: 18px; }
.search-probe-samples a { color: var(--accent); text-decoration: none; }
.search-probe-samples a:hover { text-decoration: underline; }
.tool-status { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tool-status.ok { background: var(--ok); } .tool-status.err { background: var(--danger); } .tool-status.run { background: var(--accent); animation: pulse 1s infinite; }
.tool-group-names {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 42vw;
}
.tool-group-list { display: flex; flex-direction: column; gap: 4px; }
.tool-card-compact .fold {
  background: var(--surface); border-style: dashed;
}
.tool-card-compact .fold-head { padding: 6px 10px; font-size: 12.5px; }
.tool-card-compact .fold-body { max-height: 220px; }
@keyframes pulse { 50% { opacity: 0.3; } }

.cursor-blink { display: inline-block; width: 7px; height: 15px; background: var(--accent); border-radius: 2px; animation: pulse 1s infinite; vertical-align: text-bottom; margin-left: 2px; }
.err-banner { background: rgba(179, 56, 44, 0.08); border: 1px solid rgba(179, 56, 44, 0.3); color: var(--danger); border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 13.5px; }

/* ---------- composer ---------- */
.composer-wrap { padding: 0 20px calc(14px + env(safe-area-inset-bottom)); }
.composer {
  max-width: 760px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow);
  padding: 12px 12px 10px;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer > textarea {
  width: 100%; border: none; outline: none; resize: none; background: transparent;
  max-height: 220px; min-height: 28px; padding: 4px 6px 10px; line-height: 1.55; font-size: 15px;
}
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 0;
  padding-top: 2px;
}
.composer-tools, .composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.composer-tools { flex: 1; }
.composer-menu-wrap { position: relative; flex: none; }
.composer-plus {
  width: var(--control-h); height: var(--control-h); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-secondary); border: 1px solid var(--border); background: transparent;
}
.composer-plus:hover, .composer-plus.on { background: var(--surface-2); color: var(--ink); }
.composer-plus:disabled { opacity: 0.4; }
.composer-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: var(--control-h); padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; color: var(--ink-secondary);
  border: 1px solid transparent; background: transparent; flex: none;
}
.composer-chip:hover { background: var(--surface-2); color: var(--ink); }
.composer-status-dots {
  font-size: 11.5px; color: var(--muted); padding: 0 4px; white-space: nowrap;
}
.composer-toggle-group {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
}
.composer-more-menu { min-width: 200px; }
.composer-chip.on {
  border-color: rgba(217, 119, 87, 0.35);
  color: var(--accent);
  background: var(--accent-soft);
}
.composer-chip-label { line-height: 1; }
@media (max-width: 560px) {
  .composer-chip-label { display: none; }
  .composer-chip { padding: 0 8px; }
}
.composer-model-label {
  font-size: 12.5px; color: var(--muted); padding: 0 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px;
}
.composer-plus-menu { min-width: 200px; }
.send-btn {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.35; cursor: default; }
.send-btn svg { width: 17px; height: 17px; }
.send-btn.stop { background: var(--ink); border-radius: 10px; }
.attach-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 4px 10px; }
.attach-chip { position: relative; }
.attach-chip img { width: 56px; height: 56px; object-fit: cover; border-radius: 9px; border: 1px solid var(--border); }
.attach-chip button {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.file-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 4px 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 5px 8px 5px 10px; border-radius: 8px; background: var(--surface-2); color: var(--ink-secondary);
}
.file-chip button { color: var(--muted); font-size: 14px; line-height: 1; padding: 0 2px; }
.mode-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 10px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--muted); margin-right: 4px;
}
.mode-pill.on { border-color: var(--accent); color: var(--accent); background: rgba(217, 119, 87, 0.08); }
.mode-pill svg { width: 14px; height: 14px; }
.composer-hint { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.recording-dot { width: 9px; height: 9px; background: var(--danger); border-radius: 50%; animation: pulse 1s infinite; }
.json-schema-input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  padding: 8px 10px; margin-bottom: 8px; font-size: 12.5px; resize: vertical; outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.json-schema-input:focus { border-color: var(--accent); }

/* model picker */
.model-picker { position: relative; min-width: 0; }
.model-picker-btn {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted);
  padding: 5px 8px; border-radius: 8px; max-width: min(220px, 36vw); height: 32px;
}
.model-picker-btn:hover { background: var(--surface-2); color: var(--ink); }
.model-picker-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 240px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; z-index: 30;
}
.menu.up { bottom: auto; top: calc(100% + 6px); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .sub { display: block; font-size: 11px; color: var(--muted); }
.menu-item .check { margin-left: auto; color: var(--accent); }
.menu-sep { border-top: 1px solid var(--border); margin: 5px 0; }
.menu-label { font-size: 11px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- auth ---------- */
.auth-page { height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 20px; padding: 20px; }
.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-family: var(--font-sans); font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1; color: var(--accent);
}
.auth-brand-logo { width: 56px; height: 56px; display: block; }
.auth-brand-inline {
  flex-direction: row; justify-content: center; gap: 10px;
  font-size: 18px; margin-bottom: 12px;
}
.auth-brand-inline .auth-brand-logo { width: 34px; height: 34px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.auth-card h1 { font-family: var(--font-serif); font-weight: 500; font-size: 26px; margin: 0 0 4px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-secondary); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.btn:hover { border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger-fill {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger-fill:hover { filter: brightness(0.95); }
.btn.wide { width: 100%; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Centered app dialogs (replace native alert/confirm/prompt) */
.dialog-overlay { z-index: 80; }
.app-dialog {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-dialog h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}
.app-dialog-msg {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-secondary, var(--ink));
  white-space: pre-wrap;
  word-break: break-word;
}
.app-dialog-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
.app-dialog-input:focus { border-color: var(--accent); }
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.auth-err { color: var(--danger); font-size: 13px; margin: 8px 0 0; text-align: center; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.auth-switch button { color: var(--accent); font-weight: 600; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------- modal / settings ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30, 27, 20, 0.4); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 860px; max-height: 88vh; display: flex; overflow: hidden;
}
.modal-nav { width: 190px; flex: none; background: var(--bg-sidebar); border-right: 1px solid var(--border); padding: 16px 10px; }
.modal-nav h2 { font-family: var(--font-serif); font-size: 17px; font-weight: 500; margin: 0 0 12px 10px; }
.modal-nav-group { margin-bottom: 10px; }
.modal-nav-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px 4px;
}
.modal-nav button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px;
  color: var(--ink-secondary); text-align: left; white-space: nowrap;
}
.modal-nav button.active { background: rgba(41, 38, 27, 0.08); color: var(--ink); font-weight: 600; }
[data-theme="dark"] .modal-nav button.active { background: rgba(240, 238, 230, 0.1); }
.modal-nav button svg { width: 15px; height: 15px; flex: none; }
.modal-nav button .nav-label { white-space: nowrap; }
.modal-body { flex: 1; overflow-y: auto; padding: 22px 26px; min-width: 0; }
.modal-body h3 { margin: 0 0 4px; font-size: 17px; }
.modal-body .desc { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.card { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head .grow { flex: 1; min-width: 0; }
.card-head b { font-size: 14px; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-section-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.tool-switch-row { margin-top: 8px; }
.tool-switch-row:first-of-type { margin-top: 0; }
.tool-code { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.tool-defaults {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2, rgba(0,0,0,0.02));
  padding: 0 12px 8px;
}
.tool-defaults > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  font-size: 13.5px;
  font-weight: 600;
  user-select: none;
}
.tool-defaults > summary::-webkit-details-marker { display: none; }
.tool-defaults > summary::before {
  content: '';
  width: 0; height: 0;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
}
.tool-defaults[open] > summary::before { transform: rotate(90deg); }
.tool-defaults .pill { margin-left: auto; font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Toggle track only — never put caption text inside .switch (fixed 36px width). */
.switch { position: relative; display: inline-block; width: 36px; height: 21px; flex: none; vertical-align: middle; }
.switch input { display: none; }
.switch i {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: 0.15s; cursor: pointer;
}
.switch i::after { content: ""; position: absolute; width: 17px; height: 17px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: 0.15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 17px; }
/* Toggle + caption side by side */
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  min-width: 0;
}
.switch-row > span,
.switch-row .switch-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
  min-width: 0;
}
.field > .switch-row { margin-top: 2px; margin-bottom: 10px; }
.field > .switch-row .switch-label { font-weight: 500; color: var(--ink); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.err { color: var(--danger); border-color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
table.users { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.users th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.users td { padding: 8px; border-bottom: 1px solid var(--border); }

/* ---------- voice overlay ---------- */
.voice-overlay {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 30px;
}
.voice-orb {
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e89b7f, var(--accent));
  box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.3); cursor: pointer; border: none;
  transition: transform 0.2s;
}
.voice-orb:hover { transform: scale(1.04); }
.voice-orb.listening { animation: orb 1.6s infinite; }
.voice-orb.speaking { animation: orb 0.9s infinite; }
.voice-orb.busy { opacity: 0.75; animation: spin-pulse 1.4s infinite; }
@keyframes orb {
  0% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.35); }
  70% { box-shadow: 0 0 0 34px rgba(217, 119, 87, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0); }
}
@keyframes spin-pulse { 50% { transform: scale(0.95); } }
.voice-state { font-family: var(--font-serif); font-size: 21px; }
.voice-caption { max-width: 560px; text-align: center; color: var(--ink-secondary); font-size: 15px; min-height: 48px; overflow-y: auto; max-height: 30vh; }
.voice-close { position: absolute; top: 18px; right: 18px; }

/* image lightbox */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(20, 18, 14, 0.85); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
.conv-list, .modal-body, .sidebar {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border); }

@media (max-width: 720px) {
  .sidebar {
    position: fixed; z-index: 40; height: 100%; width: min(288px, 88vw);
    box-shadow: var(--shadow);
  }
  .sidebar.closed { margin-left: calc(-1 * min(288px, 88vw)); }
  .composer-wrap { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .composer-status-dots { display: none; }
  .greeting-brand { font-size: 30px; }
  .greeting-hello { font-size: 18px; }
  .home-stage { justify-content: flex-start; padding-top: 12vh; }
  .home-hello { font-size: 28px; }
  .home-ideas-list { flex-direction: column; }
  .home-idea { width: 100%; }
  .artifact-panel, .artifact-panel.is-canvas {
    position: fixed; inset: 0; z-index: 45; width: 100% !important; max-width: none;
  }
  .wb-toolbar { gap: 4px; }
  .wb-toolbar .wb-hint { display: none; }
  .overlay { padding: 10px; align-items: stretch; }
  .modal {
    flex-direction: column;
    max-height: none;
    height: 100%;
    max-width: none;
    border-radius: 12px;
  }
  .modal-nav {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .modal-nav h2 { display: none; }
  /* Chip-style horizontal tabs — must not inherit width:100% / shrink */
  .modal-nav button,
  .modal .modal-nav > button {
    width: max-content !important;
    max-width: none !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    writing-mode: horizontal-tb;
    padding: 8px 12px;
    font-size: 13px;
  }
  .modal-nav button .nav-label {
    display: inline;
    white-space: nowrap !important;
    writing-mode: horizontal-tb;
  }
  .modal-body { padding: 16px 16px 24px; }
  .modal-close { top: 10px; right: 10px; z-index: 2; }
  .row2 { grid-template-columns: 1fr; }
}

/* --- enhancements --- */
.stream-plain { white-space: pre-wrap; font-family: var(--font-mono); font-size: 0.92em; background: transparent; border: 0; padding: 0; margin: 0; }
.context-banner {
  font-size: 12px; color: var(--muted); padding: 8px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0 12px;
  background: var(--surface);
}
.tool-confirm-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.artifact-panel { width: min(440px, 42vw); border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; }
.artifact-panel.is-canvas { width: min(520px, 48vw); }
.canvas-preview { overflow: auto; background: var(--bg); }
/* Offscreen host for PNG export — fixed width so the image looks like a clean card. */
.canvas-capture-host {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 800px;
  background: var(--bg);
  color: var(--ink);
  overflow: visible;
  pointer-events: none;
  z-index: -1;
}
.canvas-capture-host .cv-root {
  padding: 28px 32px 36px;
}
.canvas-inline {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px; margin: 10px 0; background: var(--surface);
}
.canvas-payload { display: none !important; }
.canvas-inline-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.canvas-inline-head b { font-size: 14px; }
.canvas-inline-badge {
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 1px 7px;
}
.canvas-inline-detail { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.canvas-inline-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cv-root { padding: 16px 18px 28px; color: var(--ink); }
.cv-head h2 {
  margin: 0 0 6px; font-size: 20px; font-weight: 550;
  font-family: var(--font-serif, Georgia, serif);
}
.cv-head p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.cv-source { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.cv-blocks { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.cv-block-title { font-size: 12.5px; font-weight: 650; margin-bottom: 8px; color: var(--ink-secondary, var(--ink)); }
.cv-unit { font-weight: 500; color: var(--muted); margin-left: 4px; }
.cv-text { margin: 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.cv-callout {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px; background: var(--surface);
}
.cv-callout b { display: block; margin-bottom: 4px; font-size: 12.5px; }
.cv-callout.tone-info { border-color: rgba(59, 130, 246, 0.35); background: rgba(59, 130, 246, 0.06); }
.cv-callout.tone-good { border-color: rgba(61, 122, 72, 0.4); background: rgba(61, 122, 72, 0.08); }
.cv-callout.tone-warn { border-color: rgba(217, 119, 87, 0.4); background: var(--accent-soft); }
.cv-callout.tone-bad { border-color: rgba(179, 56, 44, 0.4); background: rgba(179, 56, 44, 0.06); }
.cv-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.cv-stat {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface);
}
.cv-stat i { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.cv-stat b { display: block; font-size: 18px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.cv-stat span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.cv-stat.tone-good b { color: #3d7a48; }
.cv-stat.tone-bad b { color: #b3382c; }
.cv-stat.tone-warn b { color: var(--accent); }
.cv-kv { margin: 0; }
.cv-kv-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cv-kv-row dt { color: var(--muted); margin: 0; }
.cv-kv-row dd { margin: 0; }
.cv-list { margin: 0; padding-left: 18px; font-size: 13.5px; }
.cv-list li { margin: 4px 0; }
.cv-table-wrap { overflow: auto; }
.cv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cv-table th, .cv-table td {
  border-bottom: 1px solid var(--border); padding: 7px 8px; text-align: left;
  vertical-align: top;
}
.cv-table th { color: var(--muted); font-weight: 650; font-size: 11.5px; }
.cv-bars { display: flex; flex-direction: column; gap: 8px; }
.cv-bar-row { display: grid; grid-template-columns: 72px 1fr 56px; gap: 8px; align-items: center; font-size: 12px; }
.cv-bar-label { color: var(--ink-secondary, var(--ink)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-bar-track { height: 8px; background: var(--surface-2, var(--surface)); border-radius: 999px; overflow: hidden; }
.cv-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; min-width: 2px; }
.cv-bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.cv-err { color: var(--danger, #b3382c); }
.cv-err .sub { color: var(--muted); }
.artifact-head {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.artifact-head-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-width: 0;
}
.artifact-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
}
.artifact-close {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); background: var(--surface);
}
.artifact-close:hover { border-color: var(--accent); color: var(--accent); }
.artifact-head-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.artifact-body { margin: 0; padding: 12px; overflow: auto; flex: 1; font-size: 12.5px; white-space: pre-wrap; }
.artifact-edit { border: 0; outline: none; resize: none; background: var(--bg); color: var(--ink); font-family: var(--font-mono); width: 100%; }
.artifact-select {
  font-size: 12px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); max-width: 140px; height: 28px;
}
.artifact-preview { flex: 1; width: 100%; border: 0; background: var(--surface); }
.app:has(.artifact-panel) { display: flex; }
@media (max-width: 900px) {
  .artifact-panel { position: fixed; inset: 0; z-index: 60; width: 100%; }
}
.gen-img-wrap { display: inline-flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.gen-ref-btn { margin-top: 2px; }
.share-page { min-height: 100vh; background: var(--bg); color: var(--ink); }
.share-head { display: flex; gap: 14px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.share-brand {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--accent); text-decoration: none;
}
.share-brand .logo { width: 28px; height: 28px; display: block; }
.share-brand:hover { opacity: 0.88; }
.share-head h1 { margin: 0; font-size: 18px; font-family: var(--font-serif); font-weight: 500; }
.share-thread { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.share-thread .msg { margin-bottom: 18px; }
.share-thread .msg-img { max-width: 100%; border-radius: var(--radius-md); margin: 8px 0; }
.source-cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.source-card {
  display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px; text-decoration: none;
  color: var(--ink); background: var(--surface); max-width: 280px; min-width: 0;
}
.source-card:hover { border-color: var(--accent); }
.source-card .source-body b {
  display: block; max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-card { cursor: default; }
.kb-card.flash { outline: 2px solid var(--accent); background: var(--accent-soft); }
.cite-ref {
  display: inline; border: none; background: rgba(217, 119, 87, 0.15);
  color: var(--accent); border-radius: 4px; padding: 0 4px;
  font-size: 0.85em; cursor: pointer; font-family: inherit;
}
.cite-ref:hover { background: rgba(217, 119, 87, 0.28); }
.canvas-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.canvas-body.split { flex-direction: row; }
.canvas-body.split .artifact-edit { flex: 1; min-width: 0; border-right: 1px solid var(--border); }
.canvas-body.split .artifact-preview { flex: 1; min-width: 0; }
.canvas-preview-clickable {
  position: relative;
  cursor: pointer;
}
.canvas-preview-clickable:hover .cv-src-chip { opacity: 1; transform: translateY(0); }
.cv-src-chip {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 650;
  font-family: var(--font-mono, ui-monospace, monospace);
  padding: 4px 9px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.cv-src-chip:hover { border-color: var(--accent); color: var(--accent); opacity: 1; }
.canvas-edit-mode { gap: 0; }
.cv-edit-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
.cv-edit-toolbar span {
  font-size: 11.5px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.canvas-preview-live {
  flex: 0 0 auto;
  max-height: 42%;
  min-height: 120px;
  border-bottom: 1px solid var(--border);
  overflow: auto;
}
.canvas-source-edit {
  flex: 1;
  min-height: 0;
  border-top: 0;
  font-size: 12px;
  line-height: 1.45;
}
.source-n { font-size: 11px; color: var(--accent); font-weight: 700; }
.source-body { display: flex; flex-direction: column; min-width: 0; }
.source-body b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-body i { font-size: 11px; color: var(--muted); font-style: normal; }
.proj-section { border-bottom: 1px solid var(--border); padding: 0 8px 6px; margin-bottom: 4px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form-actions.start { justify-content: flex-start; }
.lab-inline-form { display: flex; gap: 8px; align-items: center; }
.lab-inline-form input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); outline: none; }
.lab-inline-form input:focus { border-color: var(--accent); }
.skill-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.skill-row b { display: block; font-size: 13.5px; }
.skill-row i { display: block; font-size: 12px; color: var(--muted); font-style: normal; }
.settings-save-bar {
  position: sticky; bottom: 0; background: var(--bg);
  padding: 12px 0 2px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border); margin-top: 12px;
}

/* Diff viewer — warm palette */
.diff-view { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 10px 0; background: var(--surface); }
.diff-head { font-size: 12px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); }
.diff-body { margin: 0; padding: 0; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.45; overflow: auto; max-height: 420px; }
.diff-line { padding: 0 10px; white-space: pre; }
.diff-add { background: rgba(61, 122, 72, 0.12); color: var(--ok); }
.diff-del { background: rgba(179, 56, 44, 0.1); color: var(--danger); }
.diff-hunk { background: rgba(217, 119, 87, 0.1); color: var(--accent); }
.diff-meta { color: var(--muted); }

/* KaTeX */
.prose .katex-display { margin: 12px 0; overflow-x: auto; }
.prose .math-fallback { color: var(--muted); }

/* Mermaid */
.mermaid-block {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; margin: 12px 0; background: var(--surface);
}
.mermaid-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.mermaid-source { display: none !important; height: 0 !important; overflow: hidden !important; margin: 0 !important; padding: 0 !important; border: 0 !important; }
.mermaid-mount { padding: 12px; overflow: auto; background: var(--surface); }
.mermaid-mount svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.mermaid-loading, .mermaid-err { font-size: 13px; color: var(--muted); padding: 8px; }
.mermaid-err { color: var(--danger); white-space: pre-wrap; }
.mermaid-fallback { font-size: 12px; background: var(--bg); padding: 8px; overflow: auto; max-height: 200px; border-top: 1px solid var(--border); }
.mermaid-artifact { padding: 16px; overflow: auto; background: var(--surface); flex: 1; }
.mermaid-artifact svg { max-width: 100%; height: auto; }

/* Modal single-panel variant */
.modal.compact { max-width: 560px; display: block; position: relative; }
.modal.compact .modal-body { padding: 22px 26px 26px; }

/* —— Sidebar whiteboard (大画布) —— */
.board-section { border-top: 1px solid var(--border); } /* legacy */
.wb-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.wb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
.wb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.wb-hint { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.wb-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}
.wb-viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--border) 70%, transparent) 1px, transparent 0) 0 0 / 24px 24px;
}
.wb-viewport.panning, .wb-viewport:active { cursor: grabbing; }
.wb-world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.wb-grid { position: absolute; inset: -4000px; pointer-events: none; }
.wb-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  overflow: hidden;
  user-select: none;
}
.wb-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), 0 8px 24px rgba(0,0,0,0.08);
}
.wb-node-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  flex: none;
}
.wb-node-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  cursor: default;
}
.wb-text-display {
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--ink);
  min-height: 100%;
}
.wb-edit {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  background: transparent;
  color: var(--ink);
  outline: none;
}
.wb-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--muted) 55%, transparent) 50%);
  border-radius: 2px;
}
.wb-note { background: #fff8c5; border-color: #ebd67a; }
.wb-note .wb-node-chrome { border-color: rgba(0,0,0,0.06); color: #6b5b1e; }
.wb-note-blue { background: #dcecff; border-color: #a8c8f0; }
.wb-note-blue .wb-node-chrome { color: #274b7a; }
.wb-note-green { background: #ddf5e4; border-color: #9fd0ae; }
.wb-note-green .wb-node-chrome { color: #2a5c3a; }
.wb-note-pink { background: #ffe0ec; border-color: #efb0c6; }
.wb-note-pink .wb-node-chrome { color: #7a3350; }
.wb-note-purple { background: #ebe4ff; border-color: #c4b4f0; }
.wb-note-purple .wb-node-chrome { color: #4a3a7a; }
.wb-note-yellow { background: #fff8c5; border-color: #ebd67a; }
html[data-theme='dark'] .wb-note,
html[data-theme='dark'] .wb-note-yellow { background: #4a4020; border-color: #8a7540; color: #f7efc8; }
html[data-theme='dark'] .wb-note-blue { background: #243950; border-color: #4a6f9a; color: #e8f0fa; }
html[data-theme='dark'] .wb-note-green { background: #243e30; border-color: #4a7a58; color: #e4f5ea; }
html[data-theme='dark'] .wb-note-pink { background: #4a2836; border-color: #8a5068; color: #fce8f0; }
html[data-theme='dark'] .wb-note-purple { background: #352850; border-color: #6850a0; color: #eee6ff; }
html[data-theme='dark'] .wb-note .wb-node-chrome,
html[data-theme='dark'] .wb-note-yellow .wb-node-chrome,
html[data-theme='dark'] .wb-note-blue .wb-node-chrome,
html[data-theme='dark'] .wb-note-green .wb-node-chrome,
html[data-theme='dark'] .wb-note-pink .wb-node-chrome,
html[data-theme='dark'] .wb-note-purple .wb-node-chrome { color: inherit; opacity: 0.85; border-color: rgba(255,255,255,0.12); }
.wb-color-dots { display: flex; gap: 4px; }
.wb-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  padding: 0;
  cursor: pointer;
}
.wb-dot.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.wb-dot-yellow { background: #f5e06a; }
.wb-dot-blue { background: #6aa8f0; }
.wb-dot-green { background: #6bc48a; }
.wb-dot-pink { background: #f08ab0; }
.wb-dot-purple { background: #a08ae0; }
.wb-text { background: var(--surface); }
.wb-chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.wb-chat-msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wb-chat-empty { font-size: 12.5px; color: var(--muted); padding: 8px; }
.wb-chat-bubble {
  max-width: 92%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.wb-chat-bubble.user {
  align-self: flex-end;
  background: var(--accent-soft, #f3e6dc);
  color: var(--ink);
}
.wb-chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
}
.wb-chat-input {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  flex: none;
}
.wb-chat-input input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.wb-prose {
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
  word-break: break-word;
}
.wb-image {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #111;
}
.wb-image img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  display: block;
  background: #0d0d0d;
  pointer-events: none;
}
.wb-image-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--bg);
}
.wb-image-caption {
  flex: none;
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-node.wb-image { padding: 0; }
.wb-node.wb-image .wb-node-body { overflow: hidden; }
