/* ---------- Tokens ---------- */
:root {
  --sidebar: #f3f3f3;
  --main: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --hover: #ebebeb;
  --pressed: #e0e0e0;
  --border: #e3e3e3;
  --border-strong: #d1d1d1;
  --text: #1f1f1f;
  --text-2: #5c5c5c;
  --text-3: #8a8a8a;
  --brand: #0f6cbd;
  --brand-hover: #115ea3;
  --brand-soft: #e8f1fb;
  --user-bubble: #e9ebf8;
  --pill: #ffffff;
  --pill-on: #e2e2e2;
  --shield: #107c10;
  --danger: #c50f1f;
  --banner-bg: #fff4ce;
  --banner-text: #5c4400;
  --shadow: 0 2px 6px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.12);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --grid: #ececec; --baseline: #c8c8c8;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sidebar: #1c1c1c;
    --main: #242424;
    --surface: #2b2b2b;
    --surface-2: #303030;
    --hover: #333333;
    --pressed: #3b3b3b;
    --border: #383838;
    --border-strong: #474747;
    --text: #f0f0f0;
    --text-2: #bdbdbd;
    --text-3: #8c8c8c;
    --brand: #479ef5;
    --brand-hover: #62abf5;
    --brand-soft: #1d3147;
    --user-bubble: #34374a;
    --pill: #2e2e2e;
    --pill-on: #3a3a3a;
    --shield: #54b054;
    --danger: #f1707b;
    --banner-bg: #3f2e00;
    --banner-text: #ffe8a3;
    --shadow: 0 2px 6px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.45);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --grid: #363636; --baseline: #4a4a4a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sidebar: #1c1c1c;
  --main: #242424;
  --surface: #2b2b2b;
  --surface-2: #303030;
  --hover: #333333;
  --pressed: #3b3b3b;
  --border: #383838;
  --border-strong: #474747;
  --text: #f0f0f0;
  --text-2: #bdbdbd;
  --text-3: #8c8c8c;
  --brand: #479ef5;
  --brand-hover: #62abf5;
  --brand-soft: #1d3147;
  --user-bubble: #34374a;
  --pill: #2e2e2e;
  --pill-on: #3a3a3a;
  --shield: #54b054;
  --danger: #f1707b;
  --banner-bg: #3f2e00;
  --banner-text: #ffe8a3;
  --shadow: 0 2px 6px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.45);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --grid: #363636; --baseline: #4a4a4a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--main);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.training-banner {
  background: var(--banner-bg); color: var(--banner-text);
  font-size: 12.5px; font-weight: 600; text-align: center; padding: 5px 16px;
}
.training-banner:empty { display: none; }

.app { flex: 1; display: flex; min-height: 0; position: relative; }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 6px; color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[aria-pressed="true"] { background: var(--pill-on); color: var(--text); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 244px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  min-height: 0;
  transition: margin-left .2s ease, transform .2s ease;
}
.app.collapsed .sidebar { margin-left: -244px; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 8px 14px; }
.wordmark { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.sb-head-icons { display: flex; gap: 2px; }
.sb-head-icons .icon-btn { width: 28px; height: 28px; }

.seg {
  display: grid; grid-template-columns: 1fr 1fr;
  margin: 4px 6px 10px; padding: 3px;
  border-radius: 8px; background: var(--hover);
}
.seg button { padding: 5px 0; border-radius: 6px; font-size: 13px; color: var(--text-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.sb-nav { display: flex; flex-direction: column; padding: 0 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 6px 9px; border-radius: 6px;
  text-align: left; font-size: 13.5px;
}
.nav-item:hover { background: var(--hover); }
.nav-item svg { width: 17px; height: 17px; color: var(--text-2); }
.nav-item.new { font-weight: 600; background: var(--hover); margin-bottom: 2px; }
.nav-item.new:hover { background: var(--pressed); }
.plus-circle { width: 17px; height: 17px; border-radius: 50%; background: var(--text); display: grid; place-items: center; }
.plus-circle svg { width: 12px; height: 12px; color: var(--sidebar); stroke-width: 2.4; }

.search { padding: 2px 3px 6px; }
.search input {
  width: 100%; height: 30px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); outline: 0;
}
.search input:focus { border-color: var(--brand); }

.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 8px; }
.sb-heading { font-size: 12px; color: var(--text-3); padding: 16px 9px 6px; }
.agent-ic { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: #fff; }
.agent-ic svg { width: 12px !important; height: 12px !important; color: #fff !important; }
.agent-ic.g1 { background: linear-gradient(135deg, #2b88d8, #7b5cf0); }
.agent-ic.g2 { background: linear-gradient(135deg, #8a3ffc, #e3008c); }

.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-item { display: flex; align-items: center; border-radius: 6px; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--pressed); }
.chat-item .open {
  flex: 1; min-width: 0; text-align: left; padding: 6px 9px; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .del { width: 26px; height: 26px; margin-right: 3px; display: grid; place-items: center; border-radius: 5px; color: var(--text-2); opacity: 0; }
.chat-item .del svg { width: 15px; height: 15px; }
.chat-item:hover .del, .chat-item .del:focus-visible { opacity: 1; }
.chat-item .del:hover { background: var(--pressed); }
.empty-list { color: var(--text-3); font-size: 12.5px; padding: 2px 9px; margin: 0; }

.sb-foot { display: flex; align-items: center; gap: 4px; padding: 8px; border-top: 1px solid var(--border); }
.sb-foot .dd { flex: 1; min-width: 0; }
.profile-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px; border-radius: 6px; text-align: left; }
.profile-btn:hover { background: var(--hover); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: #8764b8; color: #fff; font-size: 11.5px; font-weight: 600;
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who-top { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.badge { font-size: 10px; padding: 0 4px; border-radius: 3px; background: var(--pressed); color: var(--text-2); font-weight: 600; }
.lic { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.scrim { display: none; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--main); }
.topbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 48px; }
.topbar .spacer { flex: 1; }
#openSidebar { display: none; }
.app.collapsed #openSidebar { display: grid; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px; border-radius: 8px;
  font-size: 13px; color: var(--text-2);
  border: 1px solid transparent;
}
.pill:hover { background: var(--hover); color: var(--text); }
.pill svg { width: 14px; height: 14px; }
.pill.toggle[aria-pressed="true"] { background: var(--pill-on); color: var(--text); }
.pill.toggle[aria-pressed="false"] { border-color: var(--border-strong); }
#modelBtn { border-color: var(--border-strong); border-radius: 999px; }

.shield { color: var(--shield) !important; }

/* Dropdown menus and popovers */
.dd { position: relative; }
.menu, .popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 220px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.menu.right, .popover.right { left: auto; right: 0; }
.dd.up .menu { top: auto; bottom: calc(100% + 6px); }
.menu button, .menu .mi {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 6px; text-align: left; font-size: 13.5px;
}
.menu button:hover { background: var(--hover); }
.menu button svg { width: 17px; height: 17px; color: var(--text-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu .menu-label { font-size: 12px; color: var(--text-3); padding: 6px 9px 2px; }
.menu .menu-head { padding: 8px 9px; font-size: 13px; }
.menu .menu-head small { display: block; color: var(--text-2); }
.model-menu { width: 270px; }
.model-menu button { align-items: flex-start; }
.model-menu .m-text { flex: 1; }
.model-menu .m-desc { display: block; font-size: 12px; color: var(--text-2); }
.model-menu .m-check { width: 17px; }
.model-menu .m-check svg { color: var(--brand); }
.popover { width: 280px; padding: 12px 14px; font-size: 13px; }
.popover strong { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.popover strong svg { color: var(--shield); width: 18px; height: 18px; }
.popover p { margin: 0; color: var(--text-2); }

/* ---------- Stage ---------- */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage.empty { justify-content: center; padding-bottom: 12vh; }
.stage.empty .thread, .stage.empty .disclaimer { display: none; }
.stage:not(.empty) .welcome, .stage:not(.empty) .starters { display: none; }

.welcome { text-align: center; padding: 0 16px 28px; }
.welcome h1 { font-size: 26px; font-weight: 500; margin: 0; letter-spacing: -.01em; }
.welcome-sub { color: var(--text-2); margin: 10px auto 0; max-width: 460px; }

.thread { flex: 1; overflow-y: auto; padding: 20px 16px 8px; }
.thread > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.temp-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-2); font-size: 12.5px; margin-bottom: 18px;
}
.temp-note svg { width: 16px; height: 16px; }

.msg { margin-bottom: 26px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  max-width: 80%; background: var(--user-bubble);
  padding: 9px 14px; border-radius: 18px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; max-width: 80%; }
.u-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .12s; }
.msg.user:hover .u-actions, .u-actions:focus-within { opacity: 1; }
.u-actions .icon-btn, .actions .icon-btn { width: 28px; height: 28px; }
.u-actions .icon-btn svg, .actions .icon-btn svg { width: 16px; height: 16px; }

.status { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; padding: 2px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #8a5cf6; animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; background: #3e7bff; }
.dots i:nth-child(3) { animation-delay: .3s; background: #e6559b; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

.thought { margin-bottom: 10px; font-size: 13px; color: var(--text-2); }
.thought summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; list-style: none; }
.thought summary::-webkit-details-marker { display: none; }
.thought summary svg { width: 14px; height: 14px; transition: transform .15s; }
.thought[open] summary svg { transform: rotate(180deg); }
.thought ol { margin: 8px 0 0; padding-left: 20px; border-left: 2px solid var(--border); }

.md { font-size: 14.5px; line-height: 1.62; overflow-wrap: anywhere; }
.md p { margin: 0 0 12px; }
.md h3, .md h4 { font-size: 15px; margin: 18px 0 6px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 0 0 12px; padding: 6px 12px; border-left: 3px solid var(--brand); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.md code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--hover); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 0 0 12px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 0 0 12px; font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md > :last-child { margin-bottom: 0; }
.cite {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 2px;
  font-size: 10.5px; font-weight: 600; line-height: 1; border-radius: 4px;
  background: var(--brand-soft); color: var(--brand); vertical-align: super;
}
.caret { display: inline-block; width: 8px; height: 15px; background: var(--brand); border-radius: 2px; vertical-align: -2px; animation: blink 1s steps(2) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* Action cards (email / meeting drafts) */
.card {
  margin-top: 14px; border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); }
.card-head svg { width: 17px; height: 17px; color: var(--brand); }
.card-fields { padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.card-fields div { display: flex; gap: 10px; padding: 2px 0; }
.card-fields span:first-child { width: 72px; flex-shrink: 0; color: var(--text-2); }
.card-body { padding: 12px 14px; }
.card-body .md { font-size: 14px; }
.card-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; }
.card-note { font-size: 12.5px; color: var(--text-2); flex: 1 1 100%; }
.card-note strong { color: var(--text); }
.card.sent .card-head svg { color: var(--shield); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 600; font-size: 13px;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--danger); }
.btn.subtle { border-color: transparent; background: none; }
.btn.subtle:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }

.mem-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
}
.mem-badge svg { width: 14px; height: 14px; }

.refs { margin-top: 12px; }
.refs-toggle { font-size: 12.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.refs-toggle:hover { color: var(--text); }
.refs-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.refs.open .refs-toggle svg { transform: rotate(180deg); }
.refs-list { display: none; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.refs.open .refs-list { display: flex; }
.ref, .file-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; max-width: 260px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 12.5px; background: var(--surface);
}
.ref:hover { background: var(--hover); }
.ref .n { font-weight: 600; color: var(--brand); }
.ref .t, .file-chip .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref svg, .file-chip svg { width: 16px; height: 16px; color: var(--text-2); }
.file-chip .x { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; margin-right: -4px; }
.file-chip .x:hover { background: var(--hover); }
.file-chip .x svg { width: 12px; height: 12px; }

.actions { display: flex; align-items: center; gap: 2px; margin-top: 10px; }
.actions .icon-btn[aria-pressed="true"] { color: var(--brand); background: none; }

.followups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.followup {
  padding: 6px 12px; border-radius: 999px; text-align: left;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px;
}
.followup:hover { background: var(--hover); }

/* ---------- Composer ---------- */
.composer-wrap { padding: 6px 16px 10px; }
.composer-inner { position: relative; max-width: 784px; margin: 0 auto; }
.composer {
  border: 1px solid var(--border-strong); border-radius: 28px;
  background: var(--surface); padding: 7px 8px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--text-3); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.c-row { display: flex; align-items: flex-end; gap: 4px; }
.c-row .icon-btn { width: 36px; height: 36px; border-radius: 50%; }
.c-row .icon-btn svg { width: 19px; height: 19px; }
.composer textarea {
  flex: 1; min-width: 0; display: block;
  border: 0; outline: 0; resize: none; background: none;
  font-size: 15px; line-height: 22px; padding: 7px 4px;
  max-height: 220px;
}
.composer textarea::placeholder { color: var(--text-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 6px; }
.chips:empty { display: none; }
.send {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--pill-on); color: var(--text);
}
.send svg { width: 18px; height: 18px; }
.send.ready { background: var(--text); color: var(--surface); }
.send.stop { background: var(--text); color: var(--surface); }

.edit-banner {
  display: flex; align-items: center; gap: 8px; margin: 0 12px 6px;
  font-size: 12.5px; color: var(--text-2);
}
.edit-banner svg { width: 14px; height: 14px; }
.edit-banner button { margin-left: auto; color: var(--brand); font-weight: 600; }

.plus-menu { top: auto; bottom: calc(100% + 6px); left: 4px; }
.picker {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 40;
  max-height: 300px; overflow-y: auto; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.picker-head { font-size: 12px; color: var(--text-3); padding: 6px 9px 4px; }
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 9px; border-radius: 6px; text-align: left; }
.picker-item[aria-selected="true"], .picker-item:hover { background: var(--hover); }
.picker-item svg { width: 18px; height: 18px; color: var(--text-2); }
.picker-item .p-name { font-size: 13.5px; }
.picker-item .p-meta { font-size: 12px; color: var(--text-2); }
.picker-empty { padding: 10px; color: var(--text-2); font-size: 13px; }

.starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.starter {
  height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); font-size: 13px; color: var(--text);
}
.starter:hover { background: var(--hover); }
.starter.more { border-color: transparent; width: 36px; padding: 0; display: grid; place-items: center; }
.starter.more svg { width: 18px; height: 18px; }

.disclaimer { text-align: center; color: var(--text-3); font-size: 11.5px; margin: 8px 0 0; }

/* ---------- Researcher / Analyst ---------- */
.chat-controls { display: flex; align-items: center; gap: 6px; }
.agent-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; padding: 0 4px; }
.nav-item.active { background: var(--pressed); font-weight: 600; }
/* Agent logos */
.agent-logo { display: inline-grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0; }
.agent-logo svg { width: 100%; height: 100%; }
.agent-logo.mini { width: 15px; height: 15px; }
.agent-logo.sm { width: 20px; height: 20px; }
.agent-logo-box {
  display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border);
}
.agent-logo-box .agent-logo { width: 24px; height: 24px; }
.agent-logo-box.sm { width: 32px; height: 32px; border-radius: 8px; }
.agent-logo-box.sm .agent-logo { width: 18px; height: 18px; }
.chat-item .open { display: flex; align-items: center; gap: 7px; }
.chat-item .open .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Agent start screens (Researcher, Analyst) */
body[data-agent]:not([data-agent=""]) .stage.empty { justify-content: flex-start; padding: 11vh 0 0; overflow-y: auto; }
body[data-agent]:not([data-agent=""]) .welcome { text-align: left; padding: 0 16px 26px; }
body[data-agent]:not([data-agent=""]) .composer-inner { max-width: 820px; }
body[data-agent]:not([data-agent=""]) .stage.empty .disclaimer { display: none; }
.agent-head { display: flex; align-items: flex-start; gap: 14px; max-width: 820px; margin: 0 auto; }
.agent-head h1 { font-size: 30px; font-weight: 500; margin: 0; line-height: 42px; letter-spacing: -.01em; }
.agent-by { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; margin-top: 2px; }
.agent-by svg { width: 15px; height: 15px; }

body[data-agent="researcher"] .composer { border-radius: 22px; padding: 12px 12px 8px 14px; }
body[data-agent="researcher"] .c-row { flex-wrap: wrap; align-items: center; }
body[data-agent="researcher"] .c-row textarea { order: -1; flex: 1 0 100%; padding: 2px 8px 10px; }
body[data-agent="researcher"] .c-row [data-toast="mic"] { margin-left: auto; }

.agent-body { max-width: 720px; margin: 36px auto 0; }
.stage:not(.empty) .agent-body { display: none; }
.agent-tabs { display: flex; gap: 6px; margin-bottom: 22px; }
.agent-tabs button { padding: 6px 13px; border-radius: 8px; font-size: 13.5px; background: var(--hover); color: var(--text); }
.agent-tabs button:hover { background: var(--pressed); }
.agent-tabs button[aria-selected="true"] { background: var(--text); color: var(--main); font-weight: 600; }
.agent-cards { display: grid; gap: 16px; }
.agent-cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.agent-cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.agent-card {
  display: flex; flex-direction: column; gap: 10px; min-height: 120px; padding: 16px 16px 14px;
  text-align: left; border: 1px solid var(--border-strong); border-radius: 18px; background: none;
}
.agent-card:hover { background: var(--hover); }
.ac-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.ac-icon { width: 17px; height: 17px; border-radius: 4px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.ac-icon svg { width: 12px; height: 12px; stroke-width: 2; }
.ac-text { font-size: 13.5px; font-weight: 600; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ac-text .ph { color: var(--text-3); }
.see-more { display: flex; align-items: center; gap: 4px; margin: 10px 4px 0 auto; font-size: 12.5px; color: var(--text-2); }
.see-more:hover { color: var(--text); }
.see-more svg { width: 14px; height: 14px; }
.agent-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 56px 16px 24px; color: var(--text-2); font-size: 13.5px; }
.agent-empty strong { color: var(--text-2); font-size: 15px; }
.agent-list { list-style: none; margin: 6px 0 0; padding: 0; }
.agent-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left; }
.agent-list button:hover { background: var(--hover); }
.agent-list .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-list small { color: var(--text-3); }
.agent-cards.three + .sample-link + .agent-list, .agent-cards.three + .sample-link + .agent-empty { margin-top: 26px; }
.sample-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 12.5px; color: var(--brand); }
.sample-link svg { width: 15px; height: 15px; }
.sample-link:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .agent-cards.two, .agent-cards.three { grid-template-columns: 1fr; }
  .agent-card { min-height: 0; }
  .agent-head h1 { font-size: 24px; }
  body[data-agent]:not([data-agent=""]) .stage.empty { padding-top: 5vh; }
}

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px;
  padding: 0 10px; border-radius: 999px; color: var(--text); font-size: 13.5px;
}
.chip-btn svg { width: 16px; height: 16px; }
.chip-btn:hover { background: var(--hover); }
#sourcesBtn { position: relative; }
#sourcesBtn.limited::after { content: ""; position: absolute; top: 4px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--series-2); }
.sources-menu { left: auto; right: 40px; width: 300px; }
.src-row { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.src-row:hover { background: var(--hover); }
.src-row > svg { width: 17px; height: 17px; color: var(--text-2); }
.src-text { flex: 1; }
.src-text small { display: block; font-size: 11.5px; color: var(--text-2); }

.progress { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 12px; font-size: 13px; }
.progress.live { padding: 12px 14px; }
.p-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.p-time { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.p-steps { list-style: none; margin: 0; padding: 0; }
.p-steps li { display: flex; align-items: center; gap: 10px; padding: 4px 0; color: var(--text-3); }
.p-steps li.active { color: var(--text); font-weight: 600; }
.p-steps li.done { color: var(--text-2); }
.p-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--text-3); flex-shrink: 0; }
.p-steps li.active .p-dot { border-color: var(--brand); background: var(--brand); animation: pulse 1s infinite alternate; }
.p-steps li.done .p-dot { border-color: var(--shield); background: var(--shield); }
@keyframes pulse { to { opacity: .4; } }
.p-sources { margin-top: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.progress.done { padding: 0; }
.progress.done > summary { display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer; list-style: none; color: var(--text-2); }
.progress.done > summary::-webkit-details-marker { display: none; }
.progress.done > summary svg { width: 16px; height: 16px; }
.progress.done > summary svg:first-child { color: var(--shield); }
.progress.done > summary svg:last-child { margin-left: auto; transition: transform .15s; }
.progress.done[open] > summary svg:last-child { transform: rotate(180deg); }
.progress.done .p-steps, .progress.done .code-block { margin: 0 14px 12px; }
.code-block { margin-top: 10px; }
.code-block summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; }
.code-block summary::-webkit-details-marker { display: none; }
.code-block summary svg { width: 16px; height: 16px; }
.code-block pre { margin: 8px 0 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }

.report { margin-top: 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); overflow: hidden; }
.report-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.report-head .agent-ic { width: 32px; height: 32px; border-radius: 8px; }
.report-head .agent-ic svg { width: 18px !important; height: 18px !important; }
.report-head small { display: block; color: var(--text-2); font-size: 12px; }
.report-body { padding: 4px 16px 14px; position: relative; }
.report-body.collapsed { max-height: 300px; overflow: hidden; }
.report-body.collapsed::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 70px; background: linear-gradient(transparent, var(--surface)); }
.report-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.report-foot .spacer { flex: 1; }

.chart { margin: 14px 0 0; padding: 14px 16px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.chart figcaption { margin-bottom: 8px; }
.chart figcaption small { display: block; color: var(--text-2); font-size: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); } .sw.s3 { background: var(--series-3); }
.sw.s4 { background: var(--series-4); } .sw.s5 { background: var(--series-5); }
.chart-plot { position: relative; }
.chart-plot svg { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--baseline); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cat { fill: var(--text-2); font-size: 12px; }
.chart .mark.s1 { fill: var(--series-1); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .line.s1 { stroke: var(--series-1); } .chart .dot.s1 { fill: var(--series-1); }
.chart .line.s2 { stroke: var(--series-2); } .chart .dot.s2 { fill: var(--series-2); }
.chart .line.s3 { stroke: var(--series-3); } .chart .dot.s3 { fill: var(--series-3); }
.chart .line.s4 { stroke: var(--series-4); } .chart .dot.s4 { fill: var(--series-4); }
.chart .line.s5 { stroke: var(--series-5); } .chart .dot.s5 { fill: var(--series-5); }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 140px;
  padding: 8px 10px; border-radius: 8px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.tip-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--text-2); }
.tip-row b { margin-left: auto; padding-left: 12px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 6px; font-size: 12.5px; }
.chart-table summary { cursor: pointer; color: var(--text-2); }
.chart-table .md { margin-top: 8px; font-size: 13px; }

/* ---------- Notebooks ---------- */
.workspace { flex: 1; min-height: 0; display: flex; position: relative; }
.workspace > .stage { flex: 1; min-width: 0; }
.nb-top.btn { height: 30px; padding: 0 12px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.sm svg { width: 14px; height: 14px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; border: 2px solid var(--surface); }
.field-error { color: var(--danger); font-size: 12.5px; margin: -8px 0 12px; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; margin-bottom: 14px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.pick-row:hover { background: var(--hover); }
.pick-row input { accent-color: var(--brand); }
.pick-row > svg { width: 17px; height: 17px; color: var(--text-2); }
.pick-row small { display: block; color: var(--text-2); font-size: 12px; }

.nb-panel {
  width: 330px; flex-shrink: 0; overflow-y: auto;
  border-left: 1px solid var(--border); background: var(--surface-2);
  padding: 16px 14px 20px;
}
.nbp-head { padding: 0 4px 12px; border-bottom: 1px solid var(--border); }
.nbp-title { display: flex; align-items: center; gap: 4px; }
.nbp-title h2 { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nbp-members { display: flex; align-items: center; margin-top: 10px; }
.nbp-members .avatar + .avatar { margin-left: -6px; }
.nbp-members .btn { margin-left: 8px; }
.nbp-section { padding: 14px 0 4px; border-bottom: 1px solid var(--border); }
.nbp-sec-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 8px; }
.nbp-sec-head small { color: var(--text-3); flex: 1; }
.nbp-list { list-style: none; margin: 0 0 8px; padding: 0; }
.nbp-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 6px; border-radius: 6px; text-align: left; font-size: 13px; }
.nbp-item:hover { background: var(--hover); }
.nbp-item > svg { width: 16px; height: 16px; color: var(--text-2); }
.nbp-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nbp-item small { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.nbp-item .spin { width: 14px; height: 14px; }
.nbp-empty { font-size: 12.5px; color: var(--text-2); margin: 0 4px 12px; }
.nbp-create { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 12px; }
.nbp-create-btn {
  display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; text-align: left;
}
.nbp-create-btn:hover { border-color: var(--border-strong); background: var(--hover); }
.nbp-create-btn svg { width: 18px; height: 18px; color: var(--brand); }
.nbp-foot { font-size: 11.5px; color: var(--text-3); margin: 14px 4px 0; }
.nb-suggest { margin-top: 0; }

/* Full-page views (Notebooks list, Library) */
.page-view { flex: 1; min-height: 0; overflow-y: auto; }
.page-inner { max-width: 980px; margin: 0 auto; padding: 56px 24px 40px; }
.page-inner.lib { max-width: 1030px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 40px; }
.page-head h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -.01em; }
.btn.outline { background: none; border-color: var(--border-strong); border-radius: 999px; font-weight: 500; height: 34px; padding: 0 14px; }
.btn.outline:hover { background: var(--hover); }
.btn.outline svg { width: 17px; height: 17px; }
.nb-onenote { height: 30px !important; border-radius: 8px !important; }
.page-h2 { font-size: 20px; font-weight: 600; margin: 0 0 18px; }
.page-h2-row { display: flex; align-items: center; gap: 6px; margin-top: 44px; }
.page-h2-row .page-h2 { margin: 0; white-space: nowrap; }
.page-h2-row .spacer { flex: 1; }
.page-h2-row + .nb-grid { margin-top: 18px; }
.page-search { height: 30px; width: 220px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); outline: 0; }
.page-search:focus { border-color: var(--brand); }
.page-empty-text { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; color: var(--text-2); }
.page-empty-text strong { color: var(--text); font-size: 13.5px; }

.nb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.nb-card { position: relative; min-height: 176px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); }
.nb-card:hover { background: var(--hover); }
.nb-card-open { display: flex; flex-direction: column; gap: 6px; width: 100%; height: 100%; padding: 18px; text-align: left; }
.nb-card-open strong { font-size: 15px; margin-top: auto; }
.nb-card-open small { color: var(--text-2); }
.nb-card-icon .agent-logo { width: 30px; height: 30px; }
.nb-card-members { display: flex; margin-top: 4px; }
.nb-card-members .avatar + .avatar { margin-left: -6px; }
.nb-card > .icon-btn { position: absolute; top: 10px; right: 10px; opacity: 0; }
.nb-card:hover > .icon-btn, .nb-card > .icon-btn:focus-visible { opacity: 1; }
.nb-create { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border-style: dashed; background: var(--surface-2); font-size: 14px; }
.plus-ring { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--text-2); display: grid; place-items: center; }
.plus-ring svg { width: 14px; height: 14px; }
.nb-suggestions { display: flex; }
.nb-suggest-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--border-strong); border-radius: 14px; text-align: left; max-width: 520px; width: 100%; }
.nb-suggest-card:hover { background: var(--hover); }
.nb-suggest-card > span:nth-child(2) { flex: 1; }
.nb-suggest-card small { display: block; color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.nb-suggest-add { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--brand); font-weight: 600; }
.nb-suggest-add svg { width: 15px; height: 15px; }

.lib-bar { display: flex; align-items: center; gap: 6px; margin: -16px 0 24px; }
.lib-bar .spacer { flex: 1; }
.lib-tabs { display: flex; align-items: center; gap: 4px; }
.lib-tab { height: 34px; padding: 0 12px; border-radius: 8px; font-size: 14px; }
.lib-tab:hover { background: var(--hover); }
.lib-tab.icon { width: 34px; padding: 0; display: grid; place-items: center; }
.lib-tab svg { width: 18px; height: 18px; }
.lib-tab[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--text); background: var(--surface); font-weight: 600; }
.lib-divider { width: 1px; height: 28px; background: var(--border-strong); margin: 0 6px; }
.view-toggle { display: flex; padding: 2px; border-radius: 8px; background: var(--hover); }
.view-toggle button { width: 32px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.view-toggle button svg { width: 17px; height: 17px; }
.view-toggle button[aria-pressed="true"] { background: var(--pressed); color: var(--text); }
.lib-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 110px 16px 40px; color: var(--text-2); }
.lib-empty > svg { width: 44px; height: 44px; color: var(--text); margin-bottom: 8px; stroke-width: 1.3; }
.lib-empty strong { color: var(--text); font-size: 20px; font-weight: 600; }
.lib-empty span { font-size: 15px; margin-bottom: 14px; }
.btn.pill-white { background: var(--text); color: var(--main); border-color: var(--text); border-radius: 999px; font-weight: 500; }
.btn.pill-white:hover { opacity: .9; background: var(--text); }
.lib-items.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.lib-items.list { display: flex; flex-direction: column; gap: 2px; }
.lib-item { display: flex; flex-direction: column; gap: 10px; text-align: left; border-radius: 14px; padding: 8px; }
.lib-item:hover { background: var(--hover); }
.lib-items.list .lib-item { flex-direction: row; align-items: center; gap: 14px; padding: 6px 8px; border-radius: 8px; }
.lib-thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.lib-thumb svg { width: 100%; height: 100%; display: block; }
.lib-thumb.page svg, .lib-thumb.file svg { width: 40px; height: 40px; }
.lib-items.list .lib-thumb { width: 56px; flex-shrink: 0; }
.lib-items.list .lib-thumb.page svg, .lib-items.list .lib-thumb.file svg { width: 22px; height: 22px; }
.lib-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-text strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-text small { color: var(--text-2); font-size: 12px; }
.img-view { border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; max-height: 60vh; margin: 0 auto 12px; }
.img-view svg { width: 100%; height: 100%; display: block; }
.menu .m-check { width: 17px; display: inline-grid; }
.menu .m-check svg { color: var(--brand); }
@media (max-width: 640px) {
  .page-inner { padding: 28px 16px; }
  .page-head h1 { font-size: 26px; }
  .page-search { width: 0; flex: 1 1 90px; min-width: 70px; }
  .lib-bar { flex-wrap: wrap; }
}

/* Notebook outputs */
.audio-player { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.ap-play { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--surface); flex-shrink: 0; }
.ap-play svg { width: 22px; height: 22px; }
.ap-main { flex: 1; min-width: 0; }
.ap-title small { display: block; color: var(--text-2); font-size: 12px; }
.ap-bar { height: 6px; border-radius: 3px; background: var(--pressed); margin: 10px 0 8px; overflow: hidden; }
.ap-bar span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 3px; transition: width .3s; }
.ap-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.transcript { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.tr-line { margin: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.tr-line:hover { background: var(--hover); }
.tr-line strong { color: var(--text); }
.tr-line.h1 strong { color: var(--series-2); }
.tr-line.h0 strong { color: var(--series-1); }
.tr-line.on { background: var(--brand-soft); color: var(--text); }
.hint { color: var(--text-2); font-size: 12.5px; }

.mm-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface-2); }
.mindmap { display: block; }
.mm-link { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.mm-node { cursor: pointer; outline: none; }
.mm-node rect { fill: var(--surface); stroke: var(--border-strong); }
.mm-node text { fill: var(--text); font-size: 12.5px; }
.mm-node.d0 rect { fill: var(--brand); stroke: var(--brand); }
.mm-node.d0 text { fill: #fff; font-weight: 600; }
.mm-node.d1 rect { fill: var(--brand-soft); stroke: var(--brand); }
.mm-node.d1 text { font-weight: 600; }
.mm-node:hover rect, .mm-node:focus rect { stroke: var(--text); stroke-width: 1.5; }
.mm-toggle { fill: var(--surface); stroke: var(--border-strong); }
.mm-toggle-t { fill: var(--text-2) !important; font-size: 11px !important; font-weight: 600; }

.doc-view { max-width: 680px; }
.infographic { max-width: 560px; margin: 0 auto; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.ig-head { padding: 26px 26px 22px; color: #fff; background: linear-gradient(135deg, #0f6cbd, #8a3ffc 60%, #e3558f); }
.ig-head small { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; opacity: .85; }
.ig-head h2 { margin: 6px 0 4px; font-size: 24px; line-height: 1.2; }
.ig-head p { margin: 0; opacity: .9; }
.ig-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 18px; }
.ig-stat { padding: 12px; border-radius: 12px; background: var(--surface-2); border-top: 4px solid var(--series-1); }
.ig-stat.s2 { border-top-color: var(--series-2); }
.ig-stat.s3 { border-top-color: var(--series-3); }
.ig-stat strong { display: block; font-size: 20px; }
.ig-stat span { font-size: 12px; color: var(--text-2); }
.ig-steps { padding: 0 18px 12px; }
.ig-steps h3 { font-size: 15px; margin: 4px 0 10px; }
.ig-step { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ig-step b { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; flex-shrink: 0; }
.ig-foot { padding: 10px 18px 14px; font-size: 11.5px; color: var(--text-3); }

@media (max-width: 1100px) {
  .nb-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); }
}
@media (max-width: 640px) {
  .nb-panel { width: 100%; }
  .nb-top.btn { display: none; }
  .ig-stats { grid-template-columns: 1fr; }
}

/* ---------- Powered by ---------- */
.powered {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 2px 16px 10px; font-size: 11.5px; color: var(--text-3);
}
.powered img { height: 17px; width: auto; display: block; }
.powered .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .powered .logo-light { display: none; }
  :root:not([data-theme="light"]) .powered .logo-dark { display: block; }
}
:root[data-theme="dark"] .powered .logo-light { display: none; }
:root[data-theme="dark"] .powered .logo-dark { display: block; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--main);
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  max-width: calc(100% - 32px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dialogs ---------- */
.dialog {
  border: 0; border-radius: 12px; padding: 0;
  width: calc(100% - 32px); max-width: 520px; max-height: calc(100% - 48px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.dialog:not([open]) { display: none; }
.dialog.wide { max-width: 880px; height: min(680px, calc(100% - 48px)); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.dlg-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.dlg-body { padding: 8px 22px 16px; overflow-y: auto; flex: 1; min-height: 0; }
.dlg-body p { color: var(--text-2); margin: 0 0 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label, .field .lbl { font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--text-2); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field select, .field textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); outline: 0;
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; font-size: 13.5px; cursor: pointer; }
.radio input { margin-top: 3px; accent-color: var(--brand); }
.radio small { display: block; color: var(--text-2); }

/* Settings layout */
.settings { display: flex; gap: 20px; min-height: 100%; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; width: 170px; flex-shrink: 0; }
.settings-nav button { text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; white-space: nowrap; }
.settings-nav button:hover { background: var(--hover); }
.settings-nav button[aria-selected="true"] { background: var(--pressed); font-weight: 600; }
.settings-pane { flex: 1; min-width: 0; }
.settings-pane h3 { margin: 0 0 4px; font-size: 15px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row p { margin: 2px 0 0; font-size: 12.5px; }
.switch { position: relative; width: 40px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; border: 1px solid var(--text-2); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); transition: transform .15s; }
.switch input:checked + span { background: var(--brand); border-color: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.mem-list { list-style: none; margin: 8px 0 0; padding: 0; }
.mem-list li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.mem-list li span { flex: 1; }
.mem-list li small { display: block; color: var(--text-3); font-size: 11.5px; }
.mem-empty { color: var(--text-2); font-size: 13px; padding: 10px 0; }

/* Prompt Lab */
.lab-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.lab-tabs button { padding: 8px 12px; font-size: 13.5px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lab-tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-color: var(--brand); }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cat-chip { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12.5px; }
.cat-chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.lab-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.lab-card:hover { border-color: var(--border-strong); }
.lab-card .lc-cat { font-size: 11.5px; color: var(--text-3); }
.lab-card .lc-title { font-weight: 600; }
.lab-card .lc-text { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lab-card .lc-actions { display: flex; gap: 4px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.lab-card .lc-actions .btn { height: 28px; padding: 0 10px; font-size: 12.5px; }
.lab-empty { color: var(--text-2); text-align: center; padding: 40px 20px; }
.sched-list { list-style: none; margin: 0; padding: 0; }
.sched-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sched-list li div { flex: 1; min-width: 0; }
.sched-list li small { display: block; color: var(--text-2); }

/* Prompt Coach */
.coach-checks { list-style: none; margin: 0 0 14px; padding: 0; }
.coach-checks li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.coach-checks li svg { width: 18px; height: 18px; margin-top: 1px; }
.coach-checks li.ok svg { color: var(--shield); }
.coach-checks li.miss svg { color: var(--text-3); }
.coach-checks small { display: block; color: var(--text-2); }
.coach-score { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.coach-score strong { color: var(--text); font-size: 15px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 30; transform: translateX(-100%); box-shadow: var(--shadow); }
  .app.open .sidebar { transform: none; }
  .app.collapsed .sidebar { margin-left: 0; }
  .app.open .scrim { display: block; position: absolute; inset: 0; z-index: 25; background: rgba(0,0,0,.35); }
  #openSidebar { display: grid; }
  .settings { flex-direction: column; }
  .settings-nav { flex-direction: row; width: auto; overflow-x: auto; }
}
@media (max-width: 640px) {
  .topbar { padding: 6px 8px; gap: 2px; }
  .welcome h1 { font-size: 21px; }
  .msg.user .bubble { max-width: 90%; }
  .composer-wrap { padding: 6px 10px 10px; }
  .u-actions { opacity: 1; }
  .row2 { grid-template-columns: 1fr; }
  .dlg-body, .dlg-head, .dlg-foot { padding-left: 16px; padding-right: 16px; }
}
