/* Ansa dashboard — warm neutral canvas, single orange accent. */

:root {
  --accent:        #f0521f;
  --accent-soft:   #fdefe9;
  --accent-hover:  #d94515;

  --bg:            #ffffff;
  --bg-sunk:       #fbfaf9;
  --surface:       #ffffff;
  --border:        #ebe8e4;
  --border-strong: #ded9d3;

  --text:          #1b1a18;
  --text-soft:     #6b6862;
  --text-faint:    #98938b;

  --green:         #16a34a;
  --amber:         #d97706;
  --red:           #dc2626;

  --radius:   12px;
  --radius-sm: 8px;
  --rail:  392px;
  --side:  256px;

  --shadow: 0 1px 2px rgba(27, 26, 24, .04), 0 1px 3px rgba(27, 26, 24, .06);
}

* { box-sizing: border-box; }

/* The `hidden` attribute only gets `display: none` from the UA stylesheet, so
   any author rule that sets display (.picker is display:grid) silently beats
   it and the element stays on screen. Make hidden actually mean hidden. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Default size is a safety net: an icon that lands somewhere without an
   explicit rule stays 16px instead of expanding to fill its container. */
svg {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--rail);
  /* The page itself never scrolls; each panel scrolls on its own. That needs
     the height limit to reach the panels, and grid and flex children default
     to min-height: auto ("never shrink below my content"), which silently
     breaks the chain. So the row, and every container down to the
     transcript, is explicitly allowed to shrink. */
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* ── sidebar ─────────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 26px 16px 20px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.03em;
  padding: 0 12px 30px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-soft);
  font: 500 15px/1 Inter, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.nav-item:hover { background: var(--bg-sunk); color: var(--text); }

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.is-active::after {
  content: "";
  position: absolute;
  right: -16px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--accent);
}

.nav-icon { width: 21px; height: 21px; flex: none; }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  color: var(--text-soft);
  font-size: 14px;
}

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
}
.dot.is-live { background: var(--green); }
.dot.is-down { background: var(--red); }

/* ── main ────────────────────────────────────────────────────────── */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.view { display: none; flex-direction: column; min-height: 0; flex: 1; }
.view.is-active { display: flex; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 34px 22px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.sub { margin: 6px 0 0; color: var(--text-soft); font-size: 15px; }

.head-actions { display: flex; gap: 10px; flex: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1 Inter, sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--text-faint); background: var(--bg-sunk); }

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn .icon { width: 16px; height: 16px; }

.select select {
  appearance: none;
  padding: 10px 34px 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6862' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 12px center / 14px;
  font: 500 14px/1 Inter, sans-serif;
  color: var(--text);
  cursor: pointer;
}

/* ── thread ──────────────────────────────────────────────────────── */

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 34px 10px;
  scroll-behavior: smooth;
}

.empty {
  max-width: 520px;
  margin: 8vh auto 0;
  text-align: center;
  color: var(--text-soft);
}
.empty h3 { margin: 22px 0 8px; color: var(--text); font-size: 19px; font-weight: 600; }
.empty p { margin: 0; font-size: 15px; }

/* The first screen of the demo: one thing to do, made obvious. */
.empty.is-gate .btn-lg { margin-top: 22px; }
.empty-note { margin-top: 10px !important; font-size: 13px; color: var(--text-faint, #98938b); }
.linkish {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--accent); font: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}

.btn-lg { padding: 12px 22px; font-size: 15px; }

.empty-mark {
  position: relative;
  width: 54px; height: 54px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
}
.empty-mark span { position: absolute; top: 12px; right: 13px; font-size: 11px; color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font: 500 13px/1 Inter, sans-serif;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.msg { margin-bottom: 26px; }

.msg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.avatar {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-soft);
}
.avatar svg { width: 19px; height: 19px; }

.avatar.is-bot { position: relative; color: var(--text); font-weight: 600; font-size: 16px; }
.avatar.is-bot::after {
  content: "+";
  position: absolute;
  top: 7px; right: 8px;
  font-size: 10px;
  color: var(--accent);
}

.who { font-size: 14px; font-weight: 600; }
.when { color: var(--text-faint); font-size: 14px; }
.when::before { content: "·"; margin: 0 7px; }

.msg.is-user .bubble {
  border-radius: var(--radius);
  background: var(--bg-sunk);
  padding: 18px 22px;
  font-size: 16px;
}

/* Header and text are two shaded boxes stacked into one card; spacing
   between them must be padding, since a margin shows the page through. */
.msg.is-user .msg-head { margin-bottom: 0; padding: 18px 22px 10px; background: var(--bg-sunk); border-radius: var(--radius) var(--radius) 0 0; }
.msg.is-user .bubble { border-radius: 0 0 var(--radius) var(--radius); padding-top: 0; }

.msg.is-bot .bubble { padding-left: 52px; }

.bubble p { margin: 0 0 14px; font-size: 16px; line-height: 1.62; }
.bubble p:last-child { margin-bottom: 0; }

.cite {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 3px 9px 3px 7px;
  border-left: 2px solid var(--border-strong);
  border-radius: 0 5px 5px 0;
  background: var(--bg-sunk);
  color: var(--text-soft);
  font-size: 12.5px;
  vertical-align: middle;
  cursor: pointer;
}
.cite:hover { color: var(--accent); border-left-color: var(--accent); }

.msg-tools { display: flex; gap: 6px; margin: 4px 0 18px 52px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-sunk); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.is-on { color: var(--accent); }

.ref-label {
  margin: 0 0 10px 52px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-left: 52px;
}

.ref-card {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s;
}
.ref-card:hover { border-color: var(--border-strong); }

.ref-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ref-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.ref-name svg { width: 15px; height: 15px; flex: none; color: var(--text-faint); }
.ref-score { flex: none; text-align: right; color: var(--accent); font-size: 14px; font-weight: 600; line-height: 1.25; }
.ref-score small { display: block; font-size: 11px; font-weight: 500; }
.ref-meta { margin-top: 5px; color: var(--text-faint); font-size: 12.5px; }

/* action cards inside the thread */

.action-card {
  margin: 0 0 14px 52px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.action-card.is-done { border-left-color: var(--green); }
.action-card.is-noresult { border-left-color: var(--border-strong); }
.action-card.is-bad { border-left-color: var(--red); }

.action-top { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.action-top svg { width: 16px; height: 16px; }
.action-args { margin-top: 6px; color: var(--text-soft); font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-word; }
.action-result { margin-top: 6px; color: var(--text-soft); font-size: 13px; }

.pill {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.pill.ok      { background: #e7f6ec; color: var(--green); }
.pill.bad     { background: #fdeaea; color: var(--red); }
.pill.wait    { background: #fdf3e3; color: var(--amber); }
.pill.neutral { background: var(--bg-sunk); color: var(--text-soft); }

/* typing indicator */

.typing { display: flex; gap: 5px; padding: 6px 0 0 52px; }
.typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-4px); }
}

/* ── composer ────────────────────────────────────────────────────── */

.composer {
  margin: 0 34px 26px;
  padding: 14px 16px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .12s;
}
.composer:focus-within { border-color: var(--text-faint); }

.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px/1.5 Inter, sans-serif;
  resize: none;
  outline: none;
}
.composer textarea::placeholder { color: var(--text-faint); }

.composer-foot { display: flex; align-items: center; margin-top: 8px; }

.attach {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  cursor: pointer;
}
.attach:hover { background: var(--bg-sunk); color: var(--text); }
.attach svg { width: 18px; height: 18px; }

.send {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { opacity: .45; cursor: not-allowed; }
.send svg { width: 19px; height: 19px; }

/* ── live inbox ──────────────────────────────────────────────────── */

.inbox {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  border-top: 1px solid var(--border);
}

.convo-list {
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-sunk);
}

.convo {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.convo:hover { background: var(--surface); border-color: var(--border); }
.convo.is-selected { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow); }
.convo.is-fresh { animation: fresh 2.4s ease-out; }

@keyframes fresh {
  0%   { background: var(--accent-soft); border-color: var(--accent); }
  100% { background: transparent; border-color: transparent; }
}

.convo-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.convo-time { color: var(--text-faint); font-size: 11.5px; }
.convo-title {
  margin-top: 6px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.convo-preview {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.convo-flags { display: flex; gap: 6px; margin-top: 8px; }

.convo-channel {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.convo-channel.widget { background: var(--accent-soft); color: var(--accent); }
.convo-channel.test   { background: var(--bg-sunk); color: var(--text-soft); border: 1px solid var(--border); }

.convo-flag { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.convo-flag.wait { background: #fdf3e3; color: var(--amber); }
.convo-flag.live { background: #e7f6ec; color: var(--green); }
.convo-flag.live::before, .live-dot::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: 1px;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

.convo-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 12px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}
.convo-empty strong { color: var(--text); font-size: 13.5px; }
.convo-empty .btn { align-self: flex-start; margin-top: 8px; }

.convo-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.convo-pane .thread { padding-top: 18px; }

.convo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 34px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.convo-head-title {
  min-width: 0;
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.live-dot { margin-left: auto; color: var(--green); font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.approval.in-thread { margin: 0 0 22px 52px; }

.watch-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 34px 26px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunk);
  font-size: 13.5px;
}
.watch-note div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.watch-note strong { color: var(--text); }
.watch-note span { color: var(--text-soft); }
.watch-note .btn { flex: none; }
.composer-hint { margin-left: 8px; color: var(--text-faint); font-size: 12px; }

/* ── generic page scroll ─────────────────────────────────────────── */

.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 34px 34px; }

.section-title {
  margin: 28px 0 14px;
  font-size: 15px;
  font-weight: 600;
}
.section-title.flush { margin-top: 0; }

.panel {
  padding: 22px 24px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.note { margin: 10px 0; color: var(--text-soft); font-size: 13.5px; }
.note code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg-sunk);
  font-size: 12.5px;
}

.code {
  margin: 12px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunk);
  font: 400 12.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* knowledge */

.dropzone {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 34px;
  margin-bottom: 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-sunk);
  color: var(--text-soft);
  font-size: 13.5px;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--text); font-size: 15px; }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.doc-card {
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.doc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.doc-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; min-width: 0; }
.doc-title svg { width: 17px; height: 17px; flex: none; color: var(--text-faint); }
.doc-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { margin-top: 8px; color: var(--text-faint); font-size: 13px; }
.doc-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.doc-error { margin-top: 8px; color: var(--red); font-size: 12.5px; }

.link-danger {
  border: 0;
  background: none;
  color: var(--text-faint);
  font: 500 13px/1 Inter, sans-serif;
  cursor: pointer;
  padding: 0;
}
.link-danger:hover { color: var(--red); }

/* permission segmented control */

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin-top: 14px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunk);
}

.mode {
  padding: 7px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font: 500 13px/1 Inter, sans-serif;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.mode:hover:not(.is-on) { color: var(--text); }

.mode.is-on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.mode[data-mode="off"].is-on  { color: var(--text-faint); }
.mode[data-mode="ask"].is-on  { color: var(--amber); }
.mode[data-mode="auto"].is-on { color: var(--green); }

.mode-hint { margin-top: 8px; color: var(--text-faint); font-size: 12px; }
.mode-hint em { font-style: normal; color: var(--accent); }

/* approvals */

.approval-list { display: flex; flex-direction: column; gap: 12px; }

.approval {
  padding: 18px 20px;
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  background: #fffdf8;
}
.approval-top { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.approval-top svg { width: 17px; height: 17px; flex: none; color: var(--amber); }
/* The human-readable line: what the approver is actually allowing. Reads as
   prose, not as data, because it is the thing being decided on. */
.approval-summary {
  margin: 10px 0 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--amber-soft, #f3d9a8);
  background: var(--bg-sunk);
  font-size: 14px;
  line-height: 1.5;
}

.approval-args {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunk);
  font: 400 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.approval-actions { display: flex; gap: 10px; }

.btn-danger { border-color: var(--border-strong); color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: #fdeaea; }

/* analytics */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat-label { color: var(--text-soft); font-size: 13px; }
.stat-value { margin-top: 6px; font-size: 27px; font-weight: 600; letter-spacing: -.02em; }
.stat-value small { font-size: 15px; font-weight: 500; color: var(--text-soft); }

.bars { display: flex; align-items: flex-end; gap: 8px; min-height: 168px; padding-top: 10px; }
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.bar {
  width: 100%;
  max-width: 44px;
  min-height: 3px;
  border-radius: 5px 5px 0 0;
  background: var(--accent);
  transition: height .25s;
}
.bar-value { color: var(--text-soft); font-size: 11px; font-weight: 600; }
.bar-label { color: var(--text-faint); font-size: 11px; white-space: nowrap; }

.rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { color: var(--text-soft); font-weight: 500; }

.meter {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-sunk);
  overflow: hidden;
}
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter i.green { background: var(--green); }
.meter i.red { background: var(--red); }

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  padding: 11px 16px;
  background: var(--bg-sunk);
  color: var(--text-soft);
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table code { font-size: 12px; color: var(--text-soft); word-break: break-word; }

/* ── sources rail ────────────────────────────────────────────────── */

.rail { display: flex; flex-direction: column; background: var(--bg); min-width: 0; min-height: 0; }

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30px 26px 0;
}
.rail-head h2 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }

.rail-label {
  margin: 22px 0 12px;
  padding: 0 26px;
  font-size: 14px;
  font-weight: 600;
}

.rail-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 26px 10px; }
.rail-empty { color: var(--text-faint); font-size: 14px; line-height: 1.55; }

.rail-group {
  margin: 4px 0 10px;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.source-card + .rail-group { margin-top: 22px; }

.source-card.is-lookup .source-name svg { color: var(--accent); }

.lookup-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  margin: 12px 0 0;
  font-size: 13px;
}
.lookup-facts dt { color: var(--text-faint); text-transform: capitalize; }
.lookup-facts dd { margin: 0; color: var(--text); word-break: break-word; }

.source-card {
  padding: 16px 18px 18px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.source-card.is-highlight { border-color: var(--accent); }

.source-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
/* The title column must be allowed to shrink, or a long title pushes the
   relevance score out of the card and the rail scrolls sideways. */
.source-top > div:first-child { min-width: 0; }
.source-name { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; min-width: 0; }
.source-name svg { width: 16px; height: 16px; flex: none; color: var(--text-faint); }
.source-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-meta { margin-top: 4px; color: var(--text-faint); font-size: 12.5px; }

.source-score { flex: none; text-align: right; color: var(--accent); font-size: 16px; font-weight: 600; line-height: 1.2; }
.source-score small { display: block; font-size: 11px; font-weight: 500; }

.grounded {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 13px 0 9px;
  color: var(--green);
  font-size: 13.5px;
  font-weight: 500;
}
.grounded svg { width: 16px; height: 16px; }

.source-snippet { margin: 0 0 14px; color: var(--text-soft); font-size: 13.5px; line-height: 1.55; }

.rail-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 26px 26px;
  padding: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1 Inter, sans-serif;
  cursor: pointer;
}
.rail-foot:hover { background: var(--bg-sunk); }
.rail-foot .icon { width: 15px; height: 15px; }

/* ── industry picker ─────────────────────────────────────────────── */

.picker {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(27, 26, 24, .42);
  backdrop-filter: blur(6px);
}

.picker-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 40px 40px 36px;
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .24);
}

.picker-mark {
  position: relative;
  width: 54px; height: 54px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 21px;
  font-weight: 600;
}
.picker-mark span { position: absolute; top: 12px; right: 13px; font-size: 11px; color: var(--accent); }

.picker-card h1 { margin: 0 0 10px; font-size: 27px; font-weight: 600; letter-spacing: -.02em; }
.picker-card > p {
  max-width: 460px;
  margin: 0 auto 28px;
  color: var(--text-soft);
  font-size: 15px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.picker-option {
  padding: 22px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, transform .12s, background .12s;
}
.picker-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}
.picker-option .po-icon { font-size: 26px; line-height: 1; }
.picker-option .po-name { margin-top: 12px; font-size: 16px; font-weight: 600; color: var(--text); }
.picker-option .po-tag { margin-top: 5px; color: var(--text-soft); font-size: 13px; line-height: 1.5; }

/* current industry in the sidebar */

.industry {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunk);
}
.industry-row { display: flex; align-items: center; gap: 9px; }
.industry-icon { font-size: 17px; }
.industry-name { font-size: 14px; font-weight: 600; }
.industry-actions { display: flex; gap: 6px; margin-top: 10px; }

.mini {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  font: 500 12px/1 Inter, sans-serif;
  cursor: pointer;
}
.mini:hover { border-color: var(--accent); color: var(--accent); }

.industry ~ .status { margin-top: 10px; }

.doc-card.is-builtin { background: var(--bg-sunk); }

/* ── toast ───────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.toast.is-error { background: var(--red); }

/* ── responsive ──────────────────────────────────────────────────── */

@media (max-width: 1240px) {
  .app { grid-template-columns: var(--side) minmax(0, 1fr); }
  .rail { display: none; }
}

@media (max-width: 860px) {
  /* Fixed-height panels suit a desktop, but on a phone the stacked headers
     leave the chat a sliver of the screen. Here the page scrolls normally. */
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .main { overflow: visible; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .brand { padding: 0 10px 0 0; font-size: 22px; }
  .nav { flex-direction: row; }
  .nav-item span:not(.nav-badge) { display: none; }
  .nav-item.is-active::after { display: none; }
  .status { margin: 0 0 0 auto; }
  .status span:not(.dot) { display: none; }
  .page-head { flex-direction: column; padding: 20px 18px 16px; }
  .thread, .scroll { padding-left: 18px; padding-right: 18px; }
  .composer { margin: 0 18px 18px; }
  .msg.is-bot .bubble, .msg-tools, .ref-label, .ref-grid, .action-card, .typing { margin-left: 0; padding-left: 0; }
  .two-col { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .convo-list { max-height: 200px; border-right: 0; border-bottom: 1px solid var(--border); }
  .convo-head { padding: 12px 18px; }
  .approval.in-thread { margin-left: 0; }
  .watch-note { margin: 0 18px 18px; flex-direction: column; align-items: stretch; }
  .composer-hint { display: none; }
}
