:root {
  --bg: #f5f3ee;
  --panel: #fffdf9;
  --side: #eeebe4;
  --line: #e9e4da;
  --line-strong: #d8d1c4;
  --text: #23211d;
  --muted: #6b665d;
  --faint: #857f74;
  --accent: #2f6f68;
  --accent-ink: #ffffff;
  --accent-soft: #e4efec;
  --amber: #a86a12;
  --amber-soft: #fbf0d9;
  --red: #b4443c;
  --red-soft: #f8e3e0;
  --violet: #6352c4;
  --violet-soft: #ece9fb;
  --green: #3f7d45;
  --seal: #b03a2e;
  --shadow: 0 1px 2px rgba(60, 48, 30, .05), 0 6px 20px -6px rgba(60, 48, 30, .10);
  --shadow-pop: 0 0 0 .5px rgba(0,0,0,.08), 0 2px 6px rgba(40, 30, 15, .06), 0 16px 48px -8px rgba(40, 30, 15, .22);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.36, .64, 1);
  --pdf-bg: #e4e0d8;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Charter, Georgia, "Songti SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19; --panel: #242320; --side: #201f1d; --line: #34322e; --line-strong: #45423c;
    --text: #ebe9e4; --muted: #a09a90; --faint: #8c867c; --accent: #72b8ad; --accent-ink: #10201e;
    --accent-soft: #23322f; --amber: #e0a94f; --amber-soft: #3a2f1c; --red: #e0827a; --red-soft: #3b2522;
    --violet: #a99cf0; --violet-soft: #2c2840; --green: #8cc492; --seal: #c8574a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --shadow-pop: 0 0 0 .5px rgba(255,255,255,.10), 0 2px 6px rgba(0,0,0,.3), 0 20px 56px -8px rgba(0,0,0,.6);
    --pdf-bg: #141312;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.6 var(--sans); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
textarea { max-height: 60vh; overflow-y: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
:is(button, a, summary, [tabindex]):focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.btn, .nav-item, .item, .jump, .tab, .scope, .sug, .seg button, .pal-item { transition: background-color .15s, border-color .15s, color .15s, box-shadow .2s var(--ease), transform .2s var(--ease); }
.brand, .list-head h2, .page-title, .research-title, .research-title-input, .md :is(h1, h2, h3, h4), .section h3, .element h3,
.modal h3, .notice h3, .empty b, .chat-empty, .reader-top .title { font-family: var(--serif); letter-spacing: 0; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: clamp(200px, 18vw, 248px) 1fr; height: 100vh; height: 100dvh; }
#side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#body { flex: 1; display: grid; grid-template-columns: clamp(280px, 32%, 420px) 1fr; min-height: 0; }
#body.single { grid-template-columns: 1fr; }
#body.single #list { display: none; }
#list { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
#detail { overflow-y: auto; min-height: 0; background: var(--panel); }

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: center; gap: 9px; padding: 18px 18px 12px; font-weight: 650; letter-spacing: .2px; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; }
.brand:hover { background: rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .brand:hover { background: rgba(255,255,255,.05); } }
.m-brand { display: none; }
.work-menu { position: fixed; z-index: 80; width: min(320px, calc(100vw - 16px)); max-height: min(60vh, 420px); overflow: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.work-head { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); padding: 4px 8px 2px; }
.work-item + .work-head { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.work-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.work-item.on { background: var(--accent-soft); }
.work-item:disabled { cursor: default; opacity: .7; }
.work-label { flex: none; font-size: 12px; font-weight: 600; color: var(--violet); }
.work-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mark { display: inline-block; width: 13px; height: 13px; vertical-align: -2px; flex: none; }
.mark .tomoe { transform-box: fill-box; transform-origin: center; }
.mark.on .tomoe { animation: spin 2.4s linear infinite; }
.brand-mark { width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 1px 2px rgba(60, 48, 30, .18); }
.pal-trigger { display: flex; align-items: center; gap: 8px; margin: 2px 12px 10px; width: calc(100% - 24px); border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 8px 6px 10px; color: var(--faint); cursor: pointer; text-align: left; font-size: 13px; }
.pal-trigger span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pal-trigger:hover { border-color: var(--line-strong); color: var(--muted); }
.nav { padding: 0 8px; overflow-y: auto; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 5px 10px; border-radius: 7px; cursor: pointer; color: var(--text); user-select: none; }
.nav-item:hover { background: rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .nav-item:hover { background: rgba(255,255,255,.05); } }
.nav-item.on { background: var(--panel); box-shadow: var(--shadow); font-weight: 560; }
.nav-item svg { color: var(--muted); flex: none; }
.nav-item .n { margin-left: auto; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.nav-item .n.hot { color: var(--amber); font-weight: 600; }
.nav-label { margin: 16px 10px 4px; font-size: 11.5px; color: var(--faint); letter-spacing: .5px; }
.tree-child { padding-left: 32px; font-size: 13.5px; }
.nav-edit, .nav-add { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 4px; border-radius: 5px; line-height: 18px; }
.nav-edit { visibility: hidden; margin-left: auto; }
.nav-item .n + .nav-edit { margin-left: 2px; }
.nav-item:hover .nav-edit, .nav-edit:focus-visible { visibility: visible; }
.nav-edit:hover, .nav-add:hover { color: var(--text); background: rgba(0,0,0,.06); }
.nav-label { display: flex; align-items: center; }
.nav-add { margin-left: auto; font-size: 15px; }
.nav-item.proposals { color: var(--violet); font-size: 12.5px; padding-left: 32px; }
.caret { width: 14px; display: inline-grid; place-items: center; color: var(--faint); transition: transform .15s; }
.caret.open { transform: rotate(90deg); }
.heat { margin: 8px 12px 0; }
.heat-grid { display: grid; grid-template-rows: repeat(7, 9px); grid-auto-flow: column; grid-auto-columns: 9px; gap: 2px; margin-bottom: 4px; }
.heat.wide .heat-grid { grid-template-rows: repeat(7, 11px); grid-auto-columns: 11px; gap: 3px; }
.heat-grid button { border: 0; padding: 0; border-radius: 2px; background: var(--line); cursor: pointer; }
.heat-grid button:hover, .heat-grid button.on { outline: 1.5px solid var(--text); outline-offset: 0; }
.act-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.act-row:hover { background: var(--bg); }
.act-row.static { cursor: default; }
.act-row time { color: var(--faint); font: 12px var(--mono); flex: none; }
.act-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.heat-grid .l1 { background: color-mix(in srgb, var(--accent) 30%, var(--side)); }
.heat-grid .l2 { background: color-mix(in srgb, var(--accent) 55%, var(--side)); }
.heat-grid .l3 { background: color-mix(in srgb, var(--accent) 80%, var(--side)); }
.heat-grid .l4 { background: var(--accent); }
.agent-status { margin: 8px; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; display: flex; gap: 8px; align-items: center; }
.agent-status:hover { background: rgba(0,0,0,.04); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--green); }
.dot.run { background: var(--violet); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- the one bar (⌘K) ---------- */
.pal-bg { position: fixed; inset: 0; z-index: 110; background: rgba(20, 18, 15, .32); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.pal { width: min(660px, 94vw); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.28); display: flex; flex-direction: column; max-height: 72vh; overflow: hidden; }
.pal-input { border: 0; outline: 0; resize: none; background: transparent; font-size: 16px; line-height: 24px; padding: 16px 18px 12px; min-height: 52px; max-height: min(30vh, 240px); border-bottom: 1px solid var(--line); }
.pal-files { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 18px 0; }
.thumb-pdf { display: grid; place-items: center; height: 100%; font-size: 11px; padding: 4px; text-align: center; color: var(--muted); word-break: break-all; }
.thumb-pdf b { color: var(--red); }
.pal-thought { display: flex; align-items: center; gap: 8px; padding: 9px 18px; border-bottom: 1px solid var(--line); }
.pal-thought span { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.pal-thought input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 13.5px; }
.pal-list { overflow-y: auto; padding: 6px; flex: 1; min-height: 0; }
.pal-group { font-size: 11.5px; color: var(--faint); padding: 8px 12px 3px; letter-spacing: .4px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px; cursor: pointer; min-width: 0; }
.pal-item.on { background: var(--accent-soft); }
.pal-icon { width: 18px; flex: none; text-align: center; color: var(--muted); }
.pal-item.on .pal-icon { color: var(--accent); }
.pal-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.short-name { display: inline-block; margin-right: 8px; padding: 0 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .9em; vertical-align: 1px; }
.pal-answer { align-items: flex-start; flex-wrap: wrap; }
.pal-answer .pal-label { white-space: normal; line-height: 1.65; flex-basis: calc(100% - 40px); }
.pal-answer .pal-hint { margin-left: 30px; }
.pal-hint { flex: none; max-width: 45%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; color: var(--faint); }
.pal-foot { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 18px; border-top: 1px solid var(--line); background: var(--bg); }
.drop-veil { position: fixed; inset: 0; z-index: 105; display: grid; place-items: center; background: color-mix(in srgb, var(--accent-soft) 70%, transparent); pointer-events: none; }
.drop-veil div { border: 2px dashed var(--accent); border-radius: 18px; padding: 40px 60px; color: var(--accent); font-size: 17px; font-weight: 600; background: var(--panel); }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; line-height: 18px; padding: 0; cursor: pointer; }
.hint { font-size: 12px; color: var(--faint); }
kbd { font: 11px var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); background: var(--panel); }

/* ---------- buttons & chips ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 8px; padding: 5px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 560; box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 2px rgba(0,0,0,.12); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(0,0,0,.05); color: var(--text); }
.btn.sm { padding: 2px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.big { padding: 9px 16px; border-radius: 10px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 999px; background: var(--side); color: var(--muted); white-space: nowrap; }
.chip.topic { background: var(--accent-soft); color: var(--accent); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.violet { background: var(--violet-soft); color: var(--violet); }
.chip.green { color: var(--green); }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; opacity: .6; }
.chip button:hover { opacity: 1; }
.cite { font: 600 11px var(--mono); color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 5px; cursor: pointer; border: 0; vertical-align: 1px; }
.cite:hover { filter: brightness(.95); }
.spin { width: 11px; height: 11px; border: 1.6px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- list ---------- */
.list-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 14px 18px 10px; display: flex; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 16px; font-weight: 650; white-space: nowrap; }
.list-head .sub { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.list-head .keys { margin-left: auto; }
.item { padding: 13px 18px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.item:hover { background: rgba(0,0,0,.025); }
.item.on { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent); }
.item-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); margin-bottom: 3px; }
.item-meta .src { color: var(--muted); }
.item-meta time { margin-left: auto; }
.item-title { font-weight: 560; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-paper { font: 13.5px/1.45 var(--serif); color: var(--text); margin-top: 4px; display: flex; gap: 6px; }
.item-paper::before { content: "↳"; color: var(--faint); font-family: var(--sans); }
.item-paper.no-arrow::before { content: none; }
.item-tldr { font-size: 13px; color: var(--muted); margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-thought { font-size: 12.5px; color: var(--muted); margin-top: 5px; border-left: 2px solid var(--amber); padding-left: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.item-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.item-actions { position: absolute; right: 12px; top: 10px; display: none; gap: 4px; background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 3px; }
.item:hover .item-actions { display: flex; }
.empty { padding: 48px 28px; color: var(--muted); text-align: center; line-height: 1.8; }
.empty b { color: var(--text); display: block; font-size: 15px; margin-bottom: 4px; }
.group-label { padding: 12px 18px 4px; font-size: 12px; color: var(--faint); }

/* ---------- detail ---------- */
.detail { max-width: 780px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 64px; }
.src-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.src-bar .grow { flex: 1; }
.raw { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--bg); color: var(--muted); font-size: 13px; white-space: pre-wrap; word-break: break-all; max-height: 140px; overflow: auto; }
.cap-title { font-size: 17px; font-weight: 620; margin: 10px 0 0; }
.thoughts { margin: 14px 0 0; }
.thought { border-left: 3px solid var(--amber); background: var(--amber-soft); color: var(--text); padding: 7px 12px; border-radius: 0 8px 8px 0; margin-bottom: 6px; font-size: 13.5px; }
.thought small { color: var(--muted); margin-left: 6px; }
.add-line { display: flex; gap: 8px; margin-top: 6px; }
.add-line input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; background: var(--panel); outline: none; }
.add-line input:focus { border-color: var(--accent); }
.block { margin-top: 22px; }
.block-title { font-size: 12px; color: var(--faint); letter-spacing: .4px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.block-title .line { flex: 1; height: 1px; background: var(--line); }
.notice { border-radius: var(--radius); padding: 14px 16px; background: var(--amber-soft); margin-top: 18px; }
.notice.info { background: var(--bg); }
.notice h3 { margin: 0 0 8px; font-size: 14.5px; }
.cand { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid rgba(0,0,0,.06); }
.cand:first-of-type { border-top: 0; }
.cand-body { flex: 1; min-width: 0; }
.cand-title { font: 14.5px/1.4 var(--serif); }
.cand-meta { font-size: 12px; color: var(--muted); }

/* paper card */
.paper { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); background: var(--panel); }
.paper-title { font: 600 20px/1.35 var(--serif); margin: 0; letter-spacing: -.1px; }
.paper-meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.topics-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; position: relative; }
.tldr { font-size: 15.5px; line-height: 1.6; margin: 16px 0 4px; font-weight: 520; }
.kv { display: grid; grid-template-columns: 52px 1fr; gap: 6px 12px; margin-top: 12px; }
.kv dt { color: var(--faint); font-size: 12.5px; padding-top: 1px; }
.kv dd { margin: 0; }
.results { margin: 6px 0 0; padding-left: 18px; }
.results li { margin: 3px 0; }
.res-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.res-row b { color: var(--text); font-weight: 560; }
.relevance { margin-top: 14px; background: var(--accent-soft); border-radius: 9px; padding: 10px 13px; font-size: 13.5px; }
.relevance b { color: var(--accent); }
.takes { margin-top: 12px; font-size: 13px; color: var(--muted); }
.take { margin: 4px 0; }
.abstract { color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.card-wait { margin-top: 14px; padding: 12px 14px; border-radius: 9px; background: var(--bg); color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.paper-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

/* figures carousel */
.figs { position: relative; margin: 14px 0 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.figs-track { display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; }
.figs-track::-webkit-scrollbar { display: none; }
.fig { flex: 0 0 100%; scroll-snap-align: start; margin: 0; display: flex; flex-direction: column; }
.fig-img { border: 0; padding: 12px 12px 6px; background: #fff; cursor: zoom-in; display: flex; align-items: center; justify-content: center; height: 340px; }
.fig-img img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.fig figcaption { padding: 8px 14px 4px; font-size: 12.5px; color: #4a463f; background: var(--panel); border-top: 1px solid var(--line); line-height: 1.5; min-height: 52px; }
@media (prefers-color-scheme: dark) { .fig figcaption { color: var(--muted); } }
.fig figcaption b { color: var(--text); font-weight: 600; }
.figs-nav { position: absolute; top: 158px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(255,255,255,.92); color: #333; font-size: 20px; line-height: 26px; cursor: pointer; box-shadow: var(--shadow); padding: 0; }
.figs-nav:hover { background: #fff; }
.figs-nav:disabled { opacity: .3; cursor: default; }
.figs-nav.prev { left: 8px; }
.figs-nav.next { right: 8px; }
.figs-foot { display: flex; align-items: center; gap: 8px; padding: 2px 14px 8px; font-size: 12px; color: var(--faint); background: var(--panel); }
.figs-foot .grow { flex: 1; }
.panel .fig-img { height: 220px; }
.panel .figs-nav { top: 98px; }
.lightbox { display: flex; flex-direction: column; gap: 10px; }
.lb-head { display: flex; align-items: center; gap: 8px; }
.lb-head .grow { flex: 1; }
.lb-stage { position: relative; background: #fff; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; padding: 14px 44px; min-height: 240px; }
.lb-stage img { max-width: 100%; max-height: 62vh; object-fit: contain; }
.lb-stage .figs-nav { top: calc(50% - 15px); }
.lb-note { margin: 0; font-weight: 600; }
.lb-caption { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* jumps from a title card into the paper */
.jumps { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 7px; }
.jumps.full { margin-top: 12px; row-gap: 6px; }
.jumps-label { font-size: 11.5px; color: var(--faint); margin: 0 1px 0 4px; }
.jumps-label:first-child { margin-left: 0; }
.jump { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 0 8px; line-height: 21px; font-size: 12px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.jump small { color: var(--faint); font-size: 11px; }
.jump:hover { border-color: var(--accent); color: var(--accent); }
.jump.go { border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 560; }
.jump.run { border-color: transparent; background: var(--violet-soft); color: var(--violet); }
.jump .spin { width: 9px; height: 9px; }
.rtoc { position: sticky; top: -16px; z-index: 2; display: flex; gap: 5px; flex-wrap: wrap; padding: 8px 0; margin: -8px 0 6px; background: var(--panel); border-bottom: 1px solid var(--line); }
.toc { border: 1px solid var(--line-strong); border-radius: 8px; padding: 3px 8px; background: var(--panel); font-size: 12.5px; max-width: 260px; color: var(--muted); }

/* topic picker */
.picker { position: absolute; top: 28px; left: 0; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; width: 260px; max-height: 340px; overflow: auto; }
.picker label { display: flex; gap: 8px; align-items: center; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.picker label:hover { background: var(--bg); }
.picker .child { padding-left: 24px; }
.picker .foot { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; font-size: 12px; color: var(--muted); }

/* runs */
details.runs { margin-top: 22px; }
details.runs summary { cursor: pointer; color: var(--muted); font-size: 12.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.runs summary::-webkit-details-marker { display: none; }
.run { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.run-head { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }
.run-head .grow { flex: 1; }
.run pre { white-space: pre-wrap; font: 12px/1.5 var(--mono); color: var(--muted); background: var(--bg); padding: 8px; border-radius: 6px; margin: 8px 0 0; max-height: 200px; overflow: auto; }
.tools { margin-top: 6px; font: 12px/1.6 var(--mono); color: var(--faint); }
.tools div { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* markdown */
.md p { margin: .45em 0; }
.md ul, .md ol { margin: .4em 0; padding-left: 1.3em; }
.md li { margin: .2em 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 14.5px; margin: .9em 0 .3em; }
.md code { font: 12.5px var(--mono); background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md-table { border-collapse: collapse; margin: .5em 0; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 4px 10px; text-align: left; }
.md-table th { background: var(--bg); font-weight: 600; }
.md blockquote { margin: .5em 0; padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--muted); }

/* related work comparison table */
.cmp-wrap { overflow-x: auto; }
.cmp { border-collapse: collapse; font-size: 13px; width: 100%; }
.cmp th, .cmp td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.cmp th { background: var(--bg); font-weight: 560; white-space: nowrap; }
.cmp tr.ours td { background: var(--bg); font-weight: 560; }

/* ---------- reader ---------- */
#reader { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); }
#reader[hidden] { display: none; }
.peek { position: fixed; top: 64px; right: 24px; z-index: 80; width: min(560px, calc(100vw - 32px)); height: min(78vh, 820px); min-width: 320px; min-height: 240px;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 10px 40px rgba(30, 25, 15, .25);
  resize: both; overflow: hidden; padding-bottom: 12px; }
.peek-top { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); cursor: move; user-select: none; touch-action: none; }
.peek-top b { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.peek-q { padding: 4px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-pdf { flex: 1; min-height: 0; overflow: auto; background: var(--pdf-bg); padding: 12px; }
.peek-box { position: absolute; left: 0; top: 0; }
.peek > .pdf-missing { flex: 1; display: grid; }
.peek > .pdf-loading { flex: 1; padding-top: 0; }
.peek-top .grow { flex: 1; }
.reader-top { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.reader-brand { display: grid; place-items: center; width: 28px; height: 28px; flex: none; margin-left: -6px; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.reader-brand:hover { background: rgba(0,0,0,.05); }
@media (prefers-color-scheme: dark) { .reader-brand:hover { background: rgba(255,255,255,.06); } }
.reader-brand .brand-mark { width: 22px; height: 22px; }
.reader-top .title { font: 600 15px var(--serif); flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reader-body { display: grid; grid-template-columns: minmax(0, 1fr) var(--dock-w, min(460px, 45vw)); min-height: 0; }
.reader-body.wide { grid-template-columns: minmax(0, 1fr) var(--dock-w, min(640px, 60vw)); }
.pdf-missing { display: grid; place-items: center; color: var(--muted); }
.panel { position: relative; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 560; }
.tab .n { font-size: 11px; color: var(--faint); margin-left: 3px; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 18px 28px; min-height: 0; }
.panel-body.chatwrap { padding: 0; display: flex; flex-direction: column; }
.panel .paper { border: 0; box-shadow: none; padding: 0; margin: 0; }
.section h3 { font-size: 14.5px; margin: 18px 0 4px; display: flex; gap: 8px; align-items: baseline; }
.section:first-child h3, .rtoc + .section h3 { margin-top: 0; }
.section .cites { margin-top: 4px; display: flex; gap: 5px; flex-wrap: wrap; }
/* report sections and the sentences they were read from share a color */
.rc0 { --rc: #2f6f68; } .rc1 { --rc: #3d6fb6; } .rc2 { --rc: #8a5cc2; } .rc3 { --rc: #c07a12; } .rc4 { --rc: #b4443c; } .rc5 { --rc: #4f8a3a; }
.section h3 { border-left: 3px solid var(--rc, transparent); padding-left: 7px; }
.rtoc .jump[class*="rc"] { box-shadow: inset 0 -2px 0 var(--rc); }
.rpoint { border-left: 2px solid transparent; padding: 2px 0 6px 8px; margin-left: -10px; border-radius: 2px; }
.rpoint:hover { border-left-color: var(--rc); background: color-mix(in srgb, var(--rc) 6%, transparent); }
.textLayer mark.rp-hl { background: color-mix(in srgb, var(--rc) 10%, transparent); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--rc) 75%, transparent); cursor: pointer; }
.textLayer mark.rp-hl:hover, .textLayer mark.rp-hl.on { background: color-mix(in srgb, var(--rc) 28%, transparent); }

/* ---------- PDF viewer (PDF.js canvas + text layer) ---------- */
.pdfv { overflow: auto; background: var(--pdf-bg); padding: 14px 18px 40px; min-height: 0; }
.pdf-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.10), 0 2px 12px rgba(40, 30, 15, .14); }
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pdf-loading { color: var(--muted); display: flex; gap: 8px; align-items: center; justify-content: center; padding-top: 30vh; font-size: 13px; }
.textLayer { position: absolute; inset: 0; overflow: clip; text-align: initial; line-height: 1; opacity: 1; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(47, 111, 104, .32); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
.textLayer mark { color: transparent; padding: 0; border-radius: 2px; }
.textLayer mark.anchor-hl { background: rgba(240, 180, 40, .38); cursor: pointer; }
.textLayer mark.anchor-hl:hover { background: rgba(240, 160, 20, .55); }
.textLayer mark.flash-hl { background: rgba(47, 111, 104, .35); animation: flashhl 2.6s ease-out forwards; }
@keyframes flashhl { 0%, 55% { background: rgba(47, 111, 104, .45); } 100% { background: transparent; } }
.anchor-bubble { position: absolute; right: 6px; z-index: 3; transform: translateY(-4px); border: 0; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; line-height: 18px; background: var(--amber); color: #fff; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.anchor-bubble:hover { filter: brightness(1.08); }

/* ---------- pinned discussions ---------- */
mark.anchor-mark { background: var(--amber-soft); color: inherit; border-bottom: 1.5px solid var(--amber); cursor: pointer; padding: 0 1px; border-radius: 2px; }
mark.anchor-mark:hover { background: color-mix(in srgb, var(--amber) 22%, transparent); }
.anchor-count { border: 0; background: var(--amber); color: #fff; border-radius: 999px; font-size: 10.5px; line-height: 15px; padding: 0 6px; margin-left: 3px; cursor: pointer; vertical-align: 2px; font-family: var(--sans); font-weight: 600; }
.anchor-count:hover { filter: brightness(1.08); }
#selpop { position: fixed; z-index: 120; width: min(300px, calc(100vw - 16px)); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 6px 24px rgba(30, 25, 15, .18); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
#selpop[hidden] { display: none; }
.selpop-quote { font: 13px/1.5 var(--serif); color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#selpop input { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; outline: none; background: var(--panel); font-size: 13px; }
#selpop input:focus { border-color: var(--accent); }
.selpop-acts { display: flex; flex-wrap: wrap; gap: 6px; }
#selpop:has(.selpop-ans) { width: min(420px, calc(100vw - 16px)); }
.selpop-ans { max-height: 45vh; overflow: auto; font-size: 13px; line-height: 1.6; border-top: 1px solid var(--line); padding-top: 8px; }
::highlight(selpop) { background: rgba(255, 200, 60, .45); }
.anchor-head { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.anchor-head .grow { flex: 1; }
.anchor-quote { margin: 0; padding: 10px 16px; border-left: 3px solid var(--amber); background: var(--amber-soft); font: 13.5px/1.6 var(--serif); max-height: 140px; overflow: auto; flex: none; }
.anchor-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.anchor-chat > .chat { flex: 1; height: auto; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.chat-head .grow { flex: 1; }
.scope-papers { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.find-ask { font-size: 14.5px; margin: 2px 0 6px; white-space: pre-wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.msg.user { align-self: flex-end; max-width: 85%; background: var(--accent-soft); padding: 8px 12px; border-radius: 12px 12px 3px 12px; white-space: pre-wrap; }
.msg.bot { max-width: 100%; }
.msg.bot .md { font-size: 14px; }
.msg-foot { display: flex; gap: 6px; align-items: center; margin-top: 4px; color: var(--faint); font-size: 12px; }
.typing { color: var(--muted); font-size: 12.5px; display: flex; gap: 7px; align-items: center; }
.chat-input { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; align-items: flex-end; background: var(--panel); }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 11px; outline: none; max-height: min(40vh, 320px); min-height: 38px; background: var(--panel); line-height: 20px; }
.chat-input textarea:focus { border-color: var(--accent); }
.chat-input { flex-wrap: wrap; }
.chat-imgs { flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
.chat-attach { cursor: pointer; }
.chat-model { appearance: none; -webkit-appearance: none; border: 0; border-radius: 8px; height: 38px; max-width: 150px; field-sizing: content; padding: 0 22px 0 10px;
  font-size: 12.5px; color: var(--muted); cursor: pointer; text-overflow: ellipsis; outline: none;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center; }
.chat-model:hover, .chat-model:focus-visible { background-color: rgba(0,0,0,.05); color: var(--text); }
@media (prefers-color-scheme: dark) { .chat-model:hover, .chat-model:focus-visible { background-color: rgba(255,255,255,.06); } .chat-model option { background: var(--panel); } }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; max-width: 420px; }
.chat-empty .sugs { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.sug { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 12px; cursor: pointer; text-align: left; color: var(--text); font-size: 13px; }
.sug:hover { border-color: var(--accent); }
.scope-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.scope { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.scope.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.new-thread { padding: 10px 18px 8px; border-bottom: 1px solid var(--line); }
.detail.thread { max-width: none; padding: 0; height: 100%; display: flex; flex-direction: column; }
.detail.thread > .btn { align-self: flex-start; margin: 8px 12px 0; }
.detail.thread .chatbox { flex: 1; min-height: 0; }
.page { max-width: 860px; margin: 0 auto; width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.page.pad { padding: 22px clamp(16px, 3vw, 32px); height: auto; }
.page-title { font-size: 18px; font-weight: 650; margin: 0 0 4px; }

/* discussion tree */
.tree-bar { padding: 8px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.tree-title { display: flex; align-items: center; gap: 8px; }
.tree-title .grow { flex: 1; }
.tree-mark { position: absolute; top: 0; height: 22px; width: 8px; margin-left: -13px; border-left: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }

/* ---------- research ---------- */
.seg { display: inline-flex; background: var(--side); border-radius: 9px; padding: 2px; gap: 2px; }
.list-head + .seg { margin: 10px 18px 2px; }
.list-head + .seg { max-width: calc(100% - 36px); overflow-x: auto; scrollbar-width: none; }
.seg button { flex: none; white-space: nowrap; border: 0; background: none; padding: 4px clamp(9px, 1vw, 14px); border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 560; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.sm button { padding: 2px clamp(7px, .8vw, 10px); font-size: 12.5px; }
.chip.green-solid { background: var(--accent); color: var(--accent-ink); }
.research-new { margin: 10px 18px 6px; }
.research-new input { padding: 7px 11px; }
.research-title { font-size: 21px; font-weight: 680; line-height: 1.35; margin: 14px 0 0; letter-spacing: -.1px; }
.research-summary { font-size: 15px; color: var(--muted); margin-top: 6px; }
.elements { margin-top: 18px; display: grid; gap: 10px; }
.element { border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px 14px; background: var(--panel); }
.element h3 { color: var(--accent); font-size: 13px; letter-spacing: .3px; margin: 0 0 4px; }
.element.blank { border-style: dashed; background: var(--bg); cursor: pointer; }
.element.blank:hover { border-color: var(--accent); }
.element.blank h3 { color: var(--muted); }
.establish { margin-top: 14px; display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; }
.establish.done { background: var(--bg); }
.plan-progress { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.plan-progress .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.plan-progress .bar span { display: block; height: 100%; background: var(--accent); }
.tasks { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 8px; }
.task { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task.late { border-color: var(--red); }
.task.late .task-due { color: var(--red); }
.task-body { flex: 1; min-width: 0; }
.task-title { width: 100%; border: none; background: none; padding: 0; font-size: 14px; }
.task-due { border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; font-size: 12px; background: var(--panel); color: var(--muted); }
.task-acts { display: flex; gap: 2px; visibility: hidden; }
.task:hover .task-acts, .fig-grid .exp-card:hover .task-acts { visibility: visible; }
.task-acts .x { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 3px; }
.task-acts .x:disabled { opacity: .3; cursor: default; }
.task-diff { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.task-diff .struck { text-decoration: line-through; color: var(--muted); }
.models { display: flex; flex-direction: column; gap: 10px; }
.model-label { font-size: 13px; margin-bottom: 4px; }
.model-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.model-picks select { max-width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; background: var(--panel); }
.ol-diff { max-height: 420px; overflow: auto; font-size: 12px; margin: 8px 0; padding: 8px 0; background: var(--bg); border-radius: 8px; }
.ol-diff > div { padding: 0 10px; white-space: pre-wrap; }
.ol-diff .add { background: rgba(46, 160, 67, .18); }
.ol-diff .del { background: rgba(248, 81, 73, .18); }
.ol-diff .hunk { color: var(--muted); }
.research-split { display: grid; grid-template-columns: minmax(0, 1fr) var(--dock-w, clamp(320px, 38%, 480px)); height: 100%; }
.research-split.off { grid-template-columns: minmax(0, 1fr); }
.research-main { overflow-y: auto; min-height: 0; }
.research-main .detail { max-width: 1080px; }
.research-dock { position: relative; min-height: 0; border-left: 1px solid var(--line); background: var(--panel); }
.dock-grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; touch-action: none; }
.dock-grip:hover, .dock-grip:focus-visible, .dock-grip.on { background: var(--accent); opacity: .35; outline: 0; }
.rtabs { flex-wrap: wrap; }
.rtabs .grow { flex: 1; }
.rtabs .tab, .rtabs > .btn { flex: none; white-space: nowrap; }
.rtabs > .btn { align-self: center; }
.proposal { margin-top: 16px; border: 1.5px solid var(--violet); border-radius: 12px; padding: 12px 16px 14px; background: var(--violet-soft); }
.proposal-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.pr-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(0,0,0,.06); }
.pr-label { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.proposal-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pr-row.off .pr-new { opacity: .45; }
.pr-label input { margin: 0 2px 0 0; vertical-align: -2px; }
.diff { white-space: pre-wrap; font-size: 13.5px; line-height: 1.7; }
.diff ins { text-decoration: none; background: rgba(80, 170, 90, .28); border-radius: 3px; }
.diff del { color: var(--red); background: var(--red-soft); border-radius: 3px; }
.role-select { flex: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; font-size: 12px; background: var(--panel); color: var(--muted); }
.find-why { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-top: 18px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13px; }
.find-why .btn { margin-left: auto; }
.cmap.compare tbody th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
.cmap.compare thead th { white-space: normal; min-width: 200px; font-size: 13.5px; color: var(--text); }
.cmap.compare .results { margin: 0; padding-left: 16px; }
.research-form { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.research-form input, .research-form textarea { border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 11px; background: var(--panel); outline: none; resize: vertical; line-height: 1.55; }
.research-form input:focus, .research-form textarea:focus { border-color: var(--accent); }
.research-form label { font-size: 13px; font-weight: 600; margin-top: 8px; }
.research-title-input { font-size: 18px; font-weight: 650; }
.source { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.source:hover { background: var(--bg); }
.source.missing { cursor: default; opacity: .55; }
.source-kind { flex: none; font-size: 11.5px; color: var(--faint); width: 92px; }
.source-label { flex: 1; min-width: 0; font-size: 13.5px; }
.source-label.serif, .serif { font-family: var(--serif); }
.source time { font-size: 12px; color: var(--faint); flex: none; }
.source .x { border: 0; background: none; color: var(--faint); cursor: pointer; visibility: hidden; padding: 0 2px; }
.source:hover .x { visibility: visible; }
.research-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; }
.research-chip { background: var(--violet-soft); color: var(--violet); }
.research-chip:hover { text-decoration: none; filter: brightness(.97); }
.thought { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.thought-acts { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.thought .btn.sm.ghost { padding: 0 6px; font-size: 12px; }
.msg-wrap.user { align-self: flex-end; max-width: 85%; display: flex; flex-direction: column; align-items: flex-end; }
.msg-wrap.user .msg.user { max-width: 100%; }
.msg-foot.right { justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.msg-wrap:hover .msg-foot.right, .msg-foot.right:has(.research-chip) { opacity: 1; }
.flash { animation: flash 2.4s ease-out; border-radius: 10px; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--amber); background-color: var(--amber-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }
.picker-filter { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; margin: 4px 0 8px; outline: none; background: var(--panel); }
.pick-list { max-height: 280px; overflow: auto; }
.pick { display: flex; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.pick:hover { background: var(--bg); }
.pick-title { flex: 1; min-width: 0; }
.research-create { display: flex; flex-direction: column; gap: 8px; }
.research-create input, .research-create textarea { border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 11px; outline: none; background: var(--panel); resize: vertical; }
.research-create input:focus, .research-create textarea:focus { border-color: var(--accent); }

/* ---------- research tabs: code, experiments, writing ---------- */
.rtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-top: 16px; }
.rtabs .tab { padding: 8px 14px; }
.tab-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.repo-add { margin-top: 14px; }
.repo-add select, .repo-map select, .exp-form select { border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; background: var(--panel); }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.repo { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 10px; }
.repo-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.repo-map { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.repo-map select { max-width: 360px; }
.add-line select { border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; background: var(--panel); max-width: 220px; }
.diagram { margin: 14px 0 0; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.diagram img { display: block; width: 100%; height: auto; background: #fff; border-radius: 6px; }
.diagram figcaption { font-size: 13px; margin-top: 8px; color: var(--muted); }
.diagram figcaption b { color: var(--text); }
.diagram-bar { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.table-wrap { overflow-x: auto; }
.cmap { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmap th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.cmap td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cmap pre { white-space: pre-wrap; font: 12px/1.5 var(--mono); background: var(--bg); padding: 8px; border-radius: 6px; margin: 6px 0 0; }
.exp-add { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.exp-add textarea, .exp-form input, .exp-form textarea, .writing-form textarea { border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 11px; background: var(--panel); outline: none; resize: vertical; font: inherit; line-height: 1.55; }
.exp-add textarea:focus, .exp-form input:focus, .exp-form textarea:focus, .writing-form textarea:focus { border-color: var(--accent); }
.writing-form textarea { width: 100%; font: 13.5px/1.6 var(--mono); }
.exp-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; background: var(--panel); }
.exp-card.abandoned { opacity: .7; border-style: dashed; }
.exp-form { display: flex; flex-direction: column; gap: 8px; }
.exp-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.exp-row { display: grid; grid-template-columns: 40px 1fr; gap: 8px; font-size: 13.5px; margin: 3px 0; }
.exp-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; margin: 8px 0; }
.exp-chart { position: relative; height: 240px; }
.fig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; margin-top: 8px; }
.fig-grid .exp-card { margin-bottom: 0; }
.fig-section { margin-top: 14px; }
.fig-section-title { font-weight: 600; font-size: 13.5px; color: var(--muted); }
.fig-caption { font-size: 12.5px; line-height: 1.5; margin: 6px 0; }
.design ol { margin: 0; padding-left: 18px; }
.cmap.paper tr.ours td { background: var(--accent-soft); }
.exp-card pre { white-space: pre-wrap; font: 12px/1.5 var(--mono); background: var(--bg); padding: 8px; border-radius: 6px; max-height: 220px; overflow: auto; }
.exp-acts { display: flex; gap: 4px; margin-top: 6px; }

/* ---------- start a research ---------- */
.modal.wide { width: min(860px, 94vw); }
.composer { display: flex; flex-direction: column; gap: 10px; }
.composer h3 { margin-bottom: 0; }
.cmp-title { border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 11px; font-size: 15px; font-weight: 600; outline: none; background: var(--panel); }
.cmp-title:focus { border-color: var(--accent); }
.cmp-box { border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; background: var(--panel); }
.cmp-box:focus-within { border-color: var(--accent); }
.cmp-box.drop { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.cmp-text { width: 100%; border: 0; outline: 0; resize: vertical; background: transparent; line-height: 1.6; min-height: 150px; max-height: 50vh; }
#cmp-files { display: flex; gap: 6px; flex-wrap: wrap; }
#cmp-files:not(:empty) { margin-top: 8px; }
.cmp-section { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cmp-section > .hint:first-child { width: 84px; flex: none; }
.cmp-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; align-items: center; }
.cmp-section select { border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; background: var(--panel); }
.cmp-picker { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.cmp-acts { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.role-toggle { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 6px; font-size: 11px; padding: 0 5px; cursor: pointer; margin-left: 2px; }
.select-bar { position: sticky; top: 52px; z-index: 3; display: flex; gap: 8px; align-items: center; padding: 8px 18px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.item.picked { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.item.picked .item-title::before { content: "✓ "; color: var(--accent); }

/* ---------- lines that open a discussion ---------- */
.thought-open { cursor: pointer; }
.thought-open:hover { text-decoration: underline; text-decoration-color: var(--amber); }
.paper-chip { background: var(--side); color: var(--text); }
.paper-chip:hover { text-decoration: none; filter: brightness(.97); }

/* ---------- toast & modal ---------- */
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; background: #2a2825; color: #f3f1ec; padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; z-index: 100; pointer-events: none; font-size: 13.5px; }
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast.error { background: var(--red); color: #fff; }
#toast button { border: 0; background: none; color: #9fd8cf; cursor: pointer; font-weight: 600; padding: 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 18, 15, .35); backdrop-filter: blur(3px); z-index: 90; display: grid; place-items: center; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px 24px; width: min(620px, 92vw); box-shadow: var(--shadow); max-height: 86vh; overflow: auto; }
.modal h3 { margin: 0 0 8px; }
.modal pre { background: var(--bg); padding: 10px 12px; border-radius: 8px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; }
.modal ol { padding-left: 20px; }
.modal li { margin: 8px 0; }

/* ---------- journal typography: small spaced labels, a masthead rule on the paper card, a pull-quote TL;DR ---------- */
.nav-label, .block-title, .pal-group, .group-label, .kv dt, .jumps-label, .source-kind { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.paper:not(.panel .paper) { border-top: 3px solid var(--text); border-radius: 3px 3px 14px 14px; }
.paper-title { font-size: 22px; line-height: 1.3; }
.tldr { font: 600 16.5px/1.65 var(--serif); border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; }
.md h2 { padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.elements { counter-reset: el; }
.elements > .element:nth-child(-n+3) h3::before { counter-increment: el; content: counter(el, upper-roman); display: inline-block; min-width: 1.6em; color: var(--faint); }
.element h3 { font-size: 15px; }
.list-head { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }

/* ---------- platform polish: spring-in overlays, press feedback, focus halos, balanced headings ---------- */
.list-head, .rtoc { backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); }
.rtoc { background: color-mix(in srgb, var(--panel) 85%, transparent); }
:is(.btn, .jump, .scope, .sug, .seg button, .nav-item, .chip button, .figs-nav, .cite):not(:disabled):active { transform: scale(.97); }
.btn.primary:not(:disabled):active { filter: brightness(.94); }
:is(input:not([type=checkbox], [type=radio], [type=range]), textarea, select):not(.pal-input, .pal-thought input, .cmp-text, .task-title, .chat-model):focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.cmp-box:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input, textarea, select { transition: border-color .15s, box-shadow .2s var(--ease); }
.pal, .modal, .work-menu, .picker, #selpop, .peek, .item-actions { box-shadow: var(--shadow-pop); }
.pal, .work-menu, #selpop { border-color: transparent; }
.modal-bg, .pal-bg { background: rgba(20, 18, 15, .28); backdrop-filter: saturate(140%) blur(6px); -webkit-backdrop-filter: saturate(140%) blur(6px); animation: fade-in .2s var(--ease); }
.pal, .modal { animation: pop-in .32s var(--spring); }
.work-menu, .picker, #selpop:not([hidden]) { animation: pop-in .22s var(--ease); transform-origin: top left; }
.drop-veil { animation: fade-in .15s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(4px); } }
.leaving { pointer-events: none; }
.modal-bg.leaving, .pal-bg.leaving { animation: fade-out .16s var(--ease) forwards; }
.modal-bg.leaving .modal, .pal-bg.leaving .pal, .work-menu.leaving { animation: pop-out .16s var(--ease) forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-out { to { opacity: 0; transform: scale(.97); } }
/* one selection mark per segmented control / tab bar; main.js sets --mark-x/y/w/h (the chosen button's box) and data-mark */
.seg, .tabs, .rtabs { position: relative; }
.seg > button, .tabs > .tab, .rtabs > .tab { position: relative; z-index: 1; }
.seg[data-mark]::before, .tabs[data-mark]::after, .rtabs[data-mark]::after { content: ""; position: absolute; left: 0; top: 0; width: var(--mark-w); transform: translate(var(--mark-x), var(--mark-y)); transition: transform .34s var(--ease), width .34s var(--ease); }
.seg[data-mark]::before { height: var(--mark-h); border-radius: 7px; background: var(--panel); box-shadow: 0 0 0 .5px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.10); }
.seg[data-mark] button.on { background: transparent; box-shadow: none; }
.tabs[data-mark]::after, .rtabs[data-mark]::after { top: calc(var(--mark-h) - 2px); height: 2px; border-radius: 2px; background: var(--accent); z-index: 2; }
.chat-head { flex-wrap: wrap; row-gap: 4px; }
.branch-switch { white-space: nowrap; }
.add-line :is(input, select) { min-width: 0; }
/* Retina: structural dividers become true hairlines (one device pixel), a shade darker so they read the same */
@media (min-resolution: 2dppx) {
  :root { --line: #dcd5c8; }
  #side, #list, .list-head, .item, .reader-top, .panel, .tabs, .rtabs, .chat-head, .chat-input, .pal-input, .pal-thought, .pal-foot, .rtoc,
  .anchor-head, .peek-top, .peek-q, .research-dock, .scope-papers, .tree-bar, .new-thread, .select-bar, .md h2, .fig figcaption,
  .work-item + .work-head, .picker .foot, .selpop-ans, .cmap td, .cmap th { border-width: .5px; }
  .block-title .line { height: .5px; }
}
@media (min-resolution: 2dppx) and (prefers-color-scheme: dark) { :root { --line: #403d38; } }
/* system "Increase Contrast": secondary text moves toward primary, dividers toward the strong line */
@media (prefers-contrast: more) {
  :root { --muted: #4f4b44; --faint: #6b665d; --line: var(--line-strong); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --muted: #c9c4bb; --faint: #a09a90; }
}
/* toggle buttons show their state as pressed (tinted), so solid fill stays reserved for the one main action */
.btn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 560; }
.src-bar .btn.primary { padding: 2px 11px; font-size: 12.5px; border-radius: 7px; margin-left: auto; }
/* recently deleted */
.trash-list { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.trash-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.trash-row + .trash-row { border-top: 1px solid var(--line); }
.trash-main { flex: 1; min-width: 0; }
.trash-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* destructive actions read as destructive (red), everywhere */
.danger, .btn.ghost.danger { color: var(--red); }
.btn.ghost.danger:hover { background: var(--red-soft); color: var(--red); }
#toast .toast-x { color: inherit; opacity: .75; font-size: 16px; line-height: 1; font-weight: 400; }
#toast .toast-x:hover { opacity: 1; }
/* touch: controls get a finger-sized hit area (HIG: 44pt; 40px keeps dense lists usable) */
@media (pointer: coarse) {
  .btn, .tab, .seg button, .nav-item, .pal-item, .scope, .sug, .work-item { min-height: 40px; }
  .btn.sm, .jump, .nav-edit, .caret, .task-acts .x, .source .x { min-height: 32px; min-width: 32px; justify-content: center; }
  .btn { justify-content: center; }
}
.tabs[data-mark] .tab.on, .rtabs[data-mark] .tab.on { border-bottom-color: transparent; }
/* layout fixes for narrow panes: full-width segmented filter, heatmap keeps the latest weeks, docked chat stacks below */
.list-head + .seg { display: flex; width: calc(100% - 36px); }
.list-head + .seg button { flex: 1 0 auto; padding-inline: 6px; }
.heat { overflow: hidden; padding: 2px; margin-inline: 10px; }
.heat-grid { justify-content: end; }
.short-name { white-space: nowrap; flex: none; align-self: flex-start; }
#detail, .chat { container-type: inline-size; }
@container (max-width: 760px) {
  .research-split { display: block; height: auto; }
  .research-dock { height: 75dvh; border-left: 0; border-top: 1px solid var(--line); }
  .dock-grip { display: none; }
}
@container (max-width: 440px) {
  .chat-input textarea { order: -1; flex-basis: 100%; }
  .chat-imgs { order: -2; }
  .chat-input .chat-model { margin-right: auto; }
}
#toast { border-radius: 999px; padding: 9px 18px; background: rgba(42, 40, 37, .86); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: var(--shadow-pop); transition: opacity .25s var(--ease), transform .4s var(--spring); }
:is(.paper-title, .research-title, .page-title, .cap-title, .modal h3, .empty b, .item-title) { text-wrap: balance; }
:is(.md p, .tldr, .item-tldr, .abstract, .research-summary) { text-wrap: pretty; }
#list, #detail, .pal-list, .msgs, .panel-body, .research-main, .pdfv, .work-menu, .picker, .modal { overscroll-behavior: contain; }
@media (prefers-reduced-motion: reduce) {
  .pal, .modal, .modal-bg, .pal-bg, .work-menu, .picker, #selpop, .drop-veil, .leaving, .leaving .modal, .leaving .pal { animation: none; }
  .seg::before, .tabs::after, .rtabs::after { transition: none; }
  :is(.btn, .jump, .scope, .sug, .seg button, .nav-item, .chip button, .figs-nav, .cite):active { transform: none; }
  #toast { transition: opacity .2s; }
}

#mnav, .mpal { display: none; }
@media (max-width: 1200px) { .list-head .keys { display: none; } }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #side { display: none; }
  #mnav { display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px 0; background: var(--bg); scrollbar-width: none; }
  .m-brand { display: grid; place-items: center; width: 36px; flex: none; border: 0; background: none; padding: 0 2px; cursor: pointer; }
  .m-brand .brand-mark { width: 22px; height: 22px; }
  #mnav .nav-item { flex: none; padding: 5px 10px; }
  #mnav .nav-item svg { display: none; }
  #mnav .nav-item .n { margin-left: 4px; }
  .pal-trigger.mpal { display: flex; margin: 6px 12px 8px; }
  .pal-bg { padding-top: 4vh; }
  #body { grid-template-columns: 1fr; }
  #detail { display: none; }
  #body.show-detail #list { display: none; }
  #body.show-detail #detail { display: block; }
  .wide-only { display: none; }
  .reader-body, .reader-body.wide { grid-template-columns: 1fr; }
  .pdfv, .pdf-missing { display: none; }
  #detail > .btn:first-child { position: sticky; top: 0; z-index: 4; width: 100%; border-radius: 0; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
  .detail { padding: 14px 14px 48px; }
  .page.pad { padding: 16px 14px; }
  .paper { padding: 16px; border-radius: 12px; }
  .modal { padding: 18px 16px; width: calc(100vw - 16px); max-height: 92dvh; }
  .reader-top { gap: 6px; padding: 8px 10px; }
  .reader-top .toc, .reader-top > .btn:last-child { display: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; padding: 8px 10px; }
  .pr-row { grid-template-columns: 84px 1fr; }
  .research-split { display: block; height: auto; }
  .research-dock { height: 75dvh; border-left: 0; border-top: 1px solid var(--line); }
  .dock-grip { display: none; }
}
@media (min-width: 1680px) {
  .detail { max-width: 880px; }
  .page { max-width: 960px; }
}
/* touch screens have no hover: show the hover-only controls, and keep iOS from zooming into inputs */
@media (hover: none) {
  .nav-edit, .task-acts, .source .x { visibility: visible; }
  .msg-foot.right, .up-msg .fork-here { opacity: 1; }
  .pal-trigger kbd { display: none; }
}
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px !important; }
}
