:root {
  /* shadcn/ui neutral palette (oklch) — aligned with JoyIndustrial-wiki */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted-c: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent-c: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive-c: oklch(0.577 0.245 27.325);
  --border-c: oklch(0.922 0 0);
  --input-c: oklch(0.922 0 0);
  --ring-c: oklch(0.708 0 0);
  --sidebar: oklch(0.985 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --radius-base: 0.625rem;

  /* Legacy aliases → remapped onto the neutral system so existing class rules
     keep working. accent* now means "neutral emphasis", not blue. */
  --bg: var(--background);
  --panel: var(--card);
  --ink: var(--foreground);
  --muted: var(--muted-foreground);
  --line: var(--border-c);
  --accent: var(--primary);
  --accent-strong: var(--foreground);
  --accent-soft: var(--secondary);
  --accent-border: var(--border-c);
  --accent-ring: oklch(0.708 0 0 / 25%);
  --surface-soft: var(--secondary);
  --table-head: var(--secondary);
  --user-bubble: var(--primary);
  --link: var(--foreground);
  --danger: var(--destructive-c);
  --shadow: 0 4px 12px oklch(0.145 0 0 / 8%);
  --shadow-soft: 0 1px 2px oklch(0.145 0 0 / 6%);
  --radius: var(--radius-base);
  --font: "Geist", "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  --display: "Geist", "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  max-width: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font);
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100%;
  min-height: 100vh;
  max-width: 100%;
  overflow: hidden;
}

.workspace {
  display: flex;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* Sidebar — fixed chrome: brand + new chat + scrollable history */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
  flex: 0 0 auto;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 2px;
  background: #fff;
  transform: rotate(45deg);
}
.brand h1 {
  font-size: 14px; margin: 0; font-weight: 650; letter-spacing: 0.02em;
}
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }

.btn-new {
  width: 100%;
  flex: 0 0 auto;
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: opacity .15s ease;
}
.btn-new:hover { opacity: 0.9; transform: none; }

.side-section-label {
  flex: 0 0 auto;
  margin: 28px 12px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.side-section-label + .session-list { margin-top: 0; }

.session-list {
  margin-top: 16px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-chip {
  margin-top: auto;
  flex: 0 0 auto;
  padding: 10px 12px 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-all;
}
.user-chip a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.session-item {
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
}
.session-item:hover { background: var(--surface-soft); }
.session-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}
.session-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.session-item-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
}
.session-item:hover .session-item-actions,
.session-item:focus-within .session-item-actions,
.session-item.active .session-item-actions {
  opacity: 1;
}
.session-item-rename,
.session-item-del {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
}
.session-item-rename:hover { background: var(--panel); color: var(--ink); }
.session-item-del:hover { background: #fef2f2; color: #dc2626; }
.session-item-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--accent-border, var(--ring-c));
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}
.session-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 20px 10px;
  text-align: center;
}

/* Main — scroll area + pinned composer */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* 行业大模型 / 深度研究 segmented control — centered at the top of the main pane.
   Hides on scroll-down, returns on scroll-up (see bindScrollHideChrome). */
.mode-switch-bar {
  position: relative;
  flex: 0 0 56px;
  height: 56px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 56px;
  background: var(--bg);
  z-index: 20;
  transition: transform .22s ease, margin-top .22s ease, opacity .18s ease;
}
.mode-switch-bar.is-hidden {
  transform: translateY(-100%);
  margin-top: -56px;
  opacity: 0;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .mode-switch-bar { transition: none; }
}
.mode-switch-bar .ir-icon-button {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}
.mode-home-link {
  position: absolute;
  left: 16px;
  top: 50%;
  display: none;
  min-height: 32px;
  align-items: center;
  padding: 0 12px;
  transform: translateY(-50%);
  border: 1px solid var(--border-c);
  border-radius: 6px;
  color: #506078;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.mode-home-link:hover { border-color: #cbd5df; background: #f8fafb; color: #243444; }
.mode-home-link:focus-visible { outline: 2px solid var(--ring-c); outline-offset: 2px; }
html.chat-detail .mode-home-link,
.ir-shellbar .mode-home-link { display: inline-flex; }
.ir-shellbar .mode-home-link { left: 56px; }
.mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  background: oklch(0.96 0 0);
  box-shadow: inset 0 0 0 1px oklch(0.92 0 0 / 70%);
}
.mode-switch-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 7px 20px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.mode-switch-item:hover {
  color: var(--ink);
}
.mode-switch-item.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px oklch(0.145 0 0 / 8%), 0 1px 3px oklch(0.145 0 0 / 6%);
}
.mode-switch-item:focus-visible {
  outline: 2px solid var(--ring-c);
  outline-offset: 2px;
}

@media (max-width: 520px) {
  .mode-switch-bar { padding-left: 104px; padding-right: 8px; justify-content: flex-end; }
  .mode-switch-item { min-width: 0; padding: 7px 12px; }
  .ir-shellbar.mode-switch-bar { padding-left: 144px; }
}

/* Right evidence / PDF panel — default wider (divider further left); drag to resize */
.evidence-panel {
  --evidence-width: min(58vw, 720px);
  display: none;
  flex-direction: column;
  position: relative;
  width: var(--evidence-width);
  min-width: 280px;
  max-width: min(78vw, 960px);
  flex: 0 0 auto;
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px oklch(0.145 0 0 / 5%);
}
.workspace.evidence-open .evidence-panel {
  display: flex;
}
.evidence-resizer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  margin-left: -3px;
  cursor: col-resize;
  z-index: 5;
  touch-action: none;
}
.evidence-resizer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 36px;
  border-radius: 999px;
  background: var(--ring-c);
  opacity: 0;
  transition: opacity .15s ease;
}
.evidence-resizer:hover::after,
.evidence-resizer:focus-visible::after,
body.evidence-resizing .evidence-resizer::after {
  opacity: 1;
}
body.evidence-resizing {
  cursor: col-resize;
  user-select: none;
}
body.evidence-resizing iframe {
  pointer-events: none;
}
.evidence-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border-c);
  background: var(--secondary);
}
.evidence-title-wrap {
  min-width: 0;
}
.evidence-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 4px;
}
.evidence-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-all;
}
.evidence-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.evidence-link {
  font-size: 12px;
  color: var(--accent-strong);
  text-decoration: none;
}
.evidence-link:hover { text-decoration: underline; }
.evidence-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.evidence-close:hover {
  color: var(--ink);
  background: var(--accent-soft);
}
.evidence-meta {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  min-height: 34px;
}
.evidence-search {
  display: none;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  align-items: center;
}
.evidence-panel.has-doc .evidence-search {
  display: flex;
}
.evidence-search-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface-soft);
  outline: none;
}
.evidence-search-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.evidence-search-btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.evidence-search-btn:hover {
  filter: brightness(0.96);
}
.evidence-hits {
  display: none;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow: auto;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.evidence-panel.has-doc .evidence-hits:not([hidden]) {
  display: flex;
}
.evidence-hits-status {
  font-size: 12px;
  color: var(--muted);
  padding: 2px 2px 4px;
}
.evidence-hit {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.evidence-hit:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.evidence-hit.active {
  border-color: #b7ccf5;
  box-shadow: 0 0 0 2px var(--accent-ring);
}
.evidence-hit-page {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent-strong);
}
.evidence-hit-snip {
  font-size: 12px;
  color: #5c6370;
  line-height: 1.4;
  word-break: break-word;
}
.evidence-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--surface-soft);
  display: none;
}
.evidence-panel.has-doc .evidence-frame { display: block; }
.evidence-panel.has-doc .evidence-empty { display: none; }
.evidence-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.chat-scroll {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 28px 24px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

.welcome {
  width: min(720px, 100%);
  text-align: center;
  padding: 0 12px 4px;
  background: none;
  border: none;
  box-shadow: none;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.welcome h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.35;
  color: var(--ink);
}
.suggests {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(720px, 100%);
  margin-top: 16px;
}
.suggest {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.suggest:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.suggest .tag {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 650;
  line-height: 1.3;
}
.suggest .q {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(420px, 70vw);
}

.thread {
  width: min(820px, 100%);
  display: none;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 12px;
}
.thread.visible { display: flex; }

.msg-user {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(560px, 85%);
  animation: rise .28s ease both;
}
.msg-actions {
  display: flex;
  gap: 12px;
  padding-right: 2px;
}
.msg-action {
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
  transition: color .15s ease;
}
.msg-action svg { flex: 0 0 auto; opacity: 0.85; }
.msg-action:hover:not(:disabled) {
  color: var(--foreground);
}
.msg-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.asst-card {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: min(720px, 100%);
  animation: rise .28s ease both;
}

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user {
  background: var(--user-bubble);
  color: var(--primary-foreground);
  border-radius: 12px 12px 4px 12px;
  box-shadow: none;
  max-width: 100%;
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}
.bubble.assistant,
.bubble.assistant.streaming-card {
  align-self: stretch;
  background: var(--card);
  border: 1px solid var(--border-c);
  box-shadow: var(--shadow-soft);
  border-radius: 12px;
  white-space: normal;
  max-width: 100%;
  padding: 18px 20px 14px;
}
.asst-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.asst-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--primary);
  color: var(--primary-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.asst-mark--safety,
.asst-mark--electrical,
.asst-mark--tools {
  background: var(--primary);
}
.asst-domain {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary-foreground);
  background: var(--secondary);
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.01em;
}
.asst-route {
  color: var(--muted-foreground);
  font-size: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border-c);
}
.bubble.assistant .md-body {
  font-size: 14.5px;
  line-height: 1.78;
  color: var(--foreground);
}
.bubble.assistant .md-body.streaming {
  white-space: pre-wrap;
}
.bubble.assistant .md-body p { margin: 0 0 0.8em; }
.bubble.assistant .md-body p:last-child { margin-bottom: 0; }
.bubble.assistant .md-body strong {
  font-weight: 700;
  color: var(--foreground);
}
.bubble.assistant .md-h {
  margin: 1.05em 0 0.45em;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.bubble.assistant .md-h:first-child { margin-top: 0; }
.bubble.assistant .md-body ul,
.bubble.assistant .md-body ol {
  margin: 0.2em 0 0.9em;
  padding-left: 1.25em;
}
.bubble.assistant .md-body li { margin: 0.3em 0; }
.bubble.assistant .md-body a {
  color: var(--link);
  text-decoration: none;
}
.bubble.assistant .md-body a:hover { text-decoration: underline; }
.bubble.assistant .md-body a.sku-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 6px;
  border-radius: 6px;
  background: #fff5e7;
  color: #b97800;
  border: 1px solid #ffe2a8;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}
.bubble.assistant .md-body a.sku-link:hover {
  background: #ffeacc;
  border-color: #f2c46d;
  text-decoration: none;
}
.bubble.assistant .md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 1px 5px;
  border-radius: 4px;
}
.bubble.assistant .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0 0.9em;
  font-size: 13px;
}
.bubble.assistant .md-table th,
.bubble.assistant .md-table td {
  border: 1px solid var(--line);
  border-left: none;
  border-right: none;
  padding: 8px 10px;
  text-align: left;
}
.bubble.assistant .md-table th {
  background: var(--table-head);
  font-weight: 600;
}
.metrics-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--border-c);
}
.metric-inline {
  font-size: 11.5px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.metric-inline + .metric-inline::before {
  content: "·";
  margin: 0 9px;
  color: var(--border-c);
}
.cite-links {
  margin-top: 0;
}
.cite-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.cite-action,
.cite-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  border: 1px solid var(--accent-border);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.cite-action .cite-chevron {
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
}
.cite-action:hover,
.cite-chip:hover {
  background: var(--secondary);
  border-color: var(--ring-c);
}
.cite-chip.muted {
  background: var(--secondary);
  color: var(--muted-foreground);
  border-color: var(--border-c);
  cursor: default;
}
.cite-chip.active {
  background: var(--secondary);
  border-color: var(--ring-c);
  color: var(--foreground);
  box-shadow: 0 0 0 2px var(--accent-ring);
}
.asst-card .trace-toggle,
.bubble.assistant .trace-toggle {
  align-self: flex-start;
  margin-top: 0;
  border: none;
  background: transparent;
  color: #a0a6af;
  border-radius: 0;
  padding: 0 2px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color .15s ease, text-decoration-color .15s ease;
}
.asst-card .trace-toggle:hover,
.bubble.assistant .trace-toggle:hover {
  background: transparent;
  color: #6b7280;
  text-decoration-color: #c5c9d0;
}
.bubble.assistant .cites {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
}
.trace-box {
  margin-top: 0;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: none;
  max-width: 100%;
  overflow: auto;
}
.trace-box.open { display: block; }
.typing {
  align-self: flex-start;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 4px;
  letter-spacing: 0.01em;
}

/* Composer — pinned to bottom during a thread; centered on the empty landing. */
.composer-wrap {
  flex: 0 0 auto;
  padding: 8px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, transparent, var(--bg) 28%);
}

/* Empty landing: greeting + input meet in the middle; seed chips hang under the box. */
.main.is-landing::after {
  content: "";
  flex: 1 1 0;
  min-height: 0;
}
.main.is-landing .chat-scroll,
.main.is-landing .ir-streamview {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 24px 24px 8px;
}
.main.is-landing .composer-wrap {
  flex: 0 1 auto;
  max-height: 58vh;
  overflow: auto;
  padding-top: 8px;
  padding-bottom: 28px;
  background: none;
}
.main.is-landing .composer {
  width: min(720px, 100%);
  border-radius: 28px;
  box-shadow: 0 8px 28px oklch(0.145 0 0 / 8%);
}
.main.is-landing .input-row textarea {
  min-height: 44px;
}
.main.is-landing .suggests { display: flex; }
.main.is-landing .ir-request-rail { display: none; }
.composer {
  width: min(820px, 100%);
  background: var(--card);
  border: 1px solid var(--border-c);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 12px 14px 10px;
}
.composer.dragging { border-color: var(--ring-c); box-shadow: 0 0 0 3px var(--accent-ring); }
.attachment-tray {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.attachment-tray.show { display: flex; }
.attachment-card {
  position: relative;
  flex: 0 0 min(220px, 70vw);
  min-width: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 30px 6px 7px;
  border: 1px solid var(--border-c);
  border-radius: 8px;
  background: var(--secondary);
}
.attachment-file-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--card);
  color: var(--secondary-foreground);
  font-size: 10px;
  font-weight: 700;
}
.attachment-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.attachment-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.attachment-info small { color: var(--muted-foreground); font-size: 11px; }
.attachment-remove {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.composer-tools { display: flex; align-items: center; gap: 7px; }
.attachment-hint { color: var(--muted-foreground); font-size: 12px; }
.message-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.message-attachment {
  padding: 6px 9px;
  border: 1px solid var(--border-c);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 12px;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.controls[hidden] { display: none !important; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-c);
  background: var(--secondary);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--secondary-foreground);
}
.pill select {
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  outline: none;
  cursor: pointer;
}

/* Multi-select domain picker (native <details> dropdown) */
.pill-multi {
  position: relative;
  cursor: pointer;
  padding: 0;
}
.pill-multi > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.pill-multi > summary::-webkit-details-marker { display: none; }
.pill-multi .domain-summary {
  font-weight: 600;
  color: var(--foreground);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-multi .pill-caret {
  font-size: 10px;
  color: var(--muted-foreground);
  transition: transform .15s ease;
}
.pill-multi[open] .pill-caret { transform: rotate(180deg); }
.domain-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border-c);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.main.is-landing .domain-menu {
  bottom: auto;
  top: calc(100% + 6px);
}
.domain-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--foreground);
  cursor: pointer;
}
.domain-opt:hover { background: var(--secondary); }
.domain-opt input { accent-color: var(--primary); cursor: pointer; }
.domain-all {
  border-bottom: 1px solid var(--border-c);
  border-radius: 6px 6px 0 0;
  margin-bottom: 2px;
  font-weight: 600;
}
.domain-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); }
.chip-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink);
}
.chip-btn.on {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
  font-weight: 600;
}

.input-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.attach-btn {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: calc(6px + 1.45em);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.attach-btn svg {
  display: block;
}
.attach-btn:hover {
  background: var(--secondary);
  color: var(--ink);
}
.input-row textarea {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  resize: none;
  outline: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  min-height: 56px;
  max-height: 160px;
  padding: 6px 4px;
  color: var(--ink);
  background: transparent;
}
.input-row textarea::placeholder { color: var(--muted-foreground); }

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.icon-btn, .send-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.send-btn {
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 8px;
  padding: 8px 18px;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: none;
}
.send-btn:hover:not(:disabled) {
  background: var(--foreground);
}
.send-btn:disabled { opacity: .45; cursor: not-allowed; }
.preview {
  display: none;
  margin: 6px 0;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.preview.show { display: flex; }
.preview img {
  width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
}
.preview button {
  border: none; background: none; color: var(--danger); cursor: pointer; font-size: 12px;
}

@media (max-width: 1100px) {
  .evidence-panel {
    --evidence-width: min(52vw, 560px);
  }
}
body.public-demo #btnNew,
body.public-demo .user-chip,
body.public-demo .controls,
body.public-demo #bidPkg,
body.public-demo #requiredInput,
body.public-demo #categoryInput,
body.public-demo #btnAttach,
body.public-demo .attachment-hint,
body.public-demo .web-toggle,
body.public-demo .session-item-actions {
  display: none !important;
}

.contact-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}
.contact-dialog[hidden] { display: none; }
.contact-panel[hidden] { display: none; }
.contact-notice {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 90;
  margin: 0;
  transform: translate(-50%, -50%);
  padding: 18px 22px;
  border: 1px solid var(--border-c);
  border-radius: var(--radius-base);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 15px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}
.contact-notice.is-visible { opacity: 1; }
.contact-notice[hidden] { display: none; }
.contact-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0.145 0 0 / 40%);
  backdrop-filter: blur(3px);
}
.contact-window {
  position: relative;
  width: min(450px, 100%);
  overflow: hidden;
  border: 1px solid #dde5ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 64px oklch(0.145 0 0 / 22%);
}
.contact-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid #e7edf0;
}
.contact-window-header h2 {
  margin: 0;
  color: #17212f;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0;
}
.contact-close {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 5px;
  color: #7b8794;
  background: transparent;
  font: inherit;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.contact-close:hover { background: #f2f5f6; color: #344252; }
.contact-close:focus-visible { outline: 2px solid #4f8c69; outline-offset: 2px; }
.contact-window-body {
  display: grid;
  justify-items: center;
  padding: 28px 36px 32px;
  text-align: center;
}
.contact-window-body h3 {
  margin: 0;
  color: #243444;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.4;
}
.contact-window-lead {
  max-width: 305px;
  margin: 10px 0 22px;
  color: #6d7988;
  font-size: 14px;
  line-height: 1.75;
}
.contact-qr-frame {
  display: grid;
  width: 218px;
  height: 218px;
  padding: 11px;
  place-items: center;
  border: 1px solid #d8e8df;
  border-radius: 6px;
  background: #f5fbf7;
}
.contact-qr {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
.contact-scan-note {
  margin: 16px 0 0;
  color: #4f8c69;
  font-size: 13px;
}
.contact-panel h2 { margin: 0; font-size: 18px; }
.contact-lead, .contact-error { margin: 0; color: var(--muted); font-size: 13px; }
.contact-error { color: var(--danger); }
.contact-panel label { display: grid; gap: 6px; font-size: 13px; }
.contact-panel input,
.contact-panel textarea {
  width: 100%;
  border: 1px solid var(--border-c);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: var(--background);
}
.contact-actions { display: flex; justify-content: flex-end; gap: 8px; }
.contact-cancel {
  border: 1px solid var(--border-c);
  background: transparent;
  border-radius: 8px;
  padding: 8px 12px;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  body.public-demo .app { grid-template-columns: 220px minmax(0, 1fr); }
  .sidebar { display: none; }
  body.public-demo .sidebar { display: flex; }
  .workspace.evidence-open .main { display: none; }
  .evidence-panel {
    --evidence-width: 100%;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .evidence-resizer { display: none; }
}
