/* The chat page shares type, layout and the near-black accent (hover,
   active, primary buttons) with the HTML reports (STYLE in src/render.ts). */
:root {
  color-scheme: light;
  --ink: #1c1c1c; --paper: #fdfdfc; --line: #d9d9d4; --accent: #2a2a2a; --accent-soft: #ecece8;
  --muted: #6b6b6b; --green: #1f8a3c; --amber: #b07d2b; --red: #b03a2e;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; color: var(--ink); background: var(--paper); line-height: 1.45; display: flex; flex-direction: column; }
a { color: var(--accent); }
code { font-family: "DejaVu Sans Mono", Consolas, monospace; font-size: 0.86em; background: #f1f1ec; padding: 0 0.2em; }
[hidden] { display: none !important; }
button { font: inherit; font-size: 0.84rem; padding: 0.3rem 0.75rem; cursor: pointer; border-radius: 3px; border: 1px solid #c9c9c2; background: #f1f1ec; color: var(--ink); }
button:hover { background: #e6e6df; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #000000; }
.dot { display: inline-block; flex: none; box-sizing: border-box; width: 8px; height: 8px; min-width: 8px; aspect-ratio: 1; border-radius: 50%; background: var(--green); margin-right: 0.3rem; vertical-align: middle; }
.dot.idle { background: #b9b9b2; }
.dot.busy { background: var(--amber); animation: pulse 1.2s infinite; }
.dot.bad { background: var(--red); }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.35; } 100% { opacity: 1; } }
.hint { margin: 0.2rem 0 0; }
.hint.error { color: var(--red); }

/* Shell: rail | chat | report panel */
.shell { --rail-w: 16rem; flex: 1; display: grid; grid-template-columns: var(--rail-w) minmax(24rem, 1fr) minmax(0, 1.15fr); min-height: 0; height: 100vh; }
.shell.no-report { grid-template-columns: var(--rail-w) minmax(24rem, 1fr) 0; }
.shell.no-report .report { display: none; }
/* Handle at the right edge: brings a hidden PDF panel back. */
.panel-handle { position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 20; display: flex; align-items: center; justify-content: center; width: 2rem; height: 3rem; padding: 0; border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; background: #fff; color: var(--ink); cursor: pointer; box-shadow: -2px 2px 8px rgba(0,0,0,0.08); }
.panel-handle:hover { background: var(--accent-soft); }
.panel-handle[hidden] { display: none; }
.panel-handle svg { width: 1.15rem; height: 1.15rem; }

/* Rail */
/* The rail's right edge: drag to make it wider or narrower. */
.shell { position: relative; }
.rail-resize { position: absolute; left: var(--rail-w); top: 0; bottom: 0; width: 7px; margin-left: -4px; cursor: col-resize; z-index: 5; }
.rail-resize:hover, .rail-resize.on { background: rgba(0, 0, 0, 0.08); }
.rail { border-right: 1px solid var(--line); background: #f6f6f2; padding: 1rem 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; overflow: auto; }
.rail .brand { font-weight: 600; margin-bottom: 0.8rem; display: flex; align-items: center; gap: 0.45rem; }
.rail .brand .mark { display: inline-flex; align-items: center; width: 1.5rem; height: 1.5rem; flex: none; }
.rail .brand .mark svg { width: 100%; height: 100%; display: block; }
.rail .brand .mark-glyph { color: var(--ink); }
.rail .brand a.mark { border-radius: 3px; }
.rail .brand a.mark:hover { background: #fff; }
.rail .brand .mark[hidden] { display: none; }
.rail .brand button { font: inherit; font-weight: 600; background: transparent; border: 0; padding: 0.1rem 0.2rem; color: var(--ink); cursor: pointer; border-radius: 3px; }
.rail .brand button:hover { background: #fff; }
.stage { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.4rem; border-radius: 4px; color: #333333; border: 1px solid transparent; cursor: pointer; list-style: none; }
.stage::-webkit-details-marker { display: none; }
.rail details.block { margin-top: 0.35rem; }
.rail details.block > summary::before { display: none; }
.rail details.block > summary .name { display: block; text-transform: uppercase; letter-spacing: 0.03em; font-size: 0.74rem; font-weight: 600; line-height: 1.25; }
.rail .block-body { padding: 0.1rem 0 0.2rem 0.4rem; }
.rail .block-body details.sub { margin-top: 0.15rem; margin-left: 1.2rem; }
.stage svg.ico { width: 1.75rem; height: 1.75rem; flex: none; color: #8a8a8a; }
.stage:hover { background: #fff; }
/* The opened block is the selected one; nothing is selected until a click. */
.rail details.block[open] > summary { background: #fff; border-color: var(--accent); }
.rail details.block[open] > summary svg.ico { color: var(--accent); }
.stage.skipped { color: #8a8a8a; }
.stage small { display: block; font-size: 0.72rem; color: var(--muted); }
.rail details { margin-top: 0.5rem; font-size: 0.8rem; }
.rail details summary { cursor: pointer; color: #333333; font-weight: 600; padding: 0.25rem 0.2rem; list-style: none; display: flex; align-items: center; gap: 0.35rem; }
.rail details summary::-webkit-details-marker { display: none; }
.rail details summary::before { content: ""; width: 0; height: 0; border-left: 5px solid #6b6b6b; border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; }
.rail details[open] > summary::before { transform: rotate(90deg); }
.rail details summary .cnt { margin-left: auto; color: var(--muted); font-weight: 400; }
.rail-list a.item { display: block; padding: 0.2rem 0.3rem 0.2rem 0.9rem; color: var(--accent); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 3px; cursor: pointer; }
.rail-list a.item:hover { background: #fff; }
.rail-list a.item.past { white-space: normal; line-height: 1.25; padding-top: 0.3rem; padding-bottom: 0.3rem; }
.rail-list a.item.past span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-list a.item.past small { display: block; color: var(--muted); font-size: 0.7rem; }
.rail-list a.item.past.current { background: #fff; border-left: 2px solid var(--accent); cursor: default; }
.rail-list a.item.past { position: relative; padding-right: 0.4rem; }
/* A conversation's own files (report, PRISMA diagram) and its trash, at the right. */
.rail-list a.item.past .acts { position: absolute; right: 0.2rem; top: 0.25rem; display: none; gap: 0.05rem; padding-left: 0.3rem; background: #fff; box-shadow: -0.6rem 0 0.5rem #fff; }
.rail-list a.item.past:hover .acts { display: flex; }
.rail-list a.item.past .rep { padding: 0.1rem; border: 0; background: transparent; color: var(--muted); display: inline-flex; border-radius: 4px; cursor: pointer; }
.rail-list a.item.past .rep svg { width: 0.95rem; height: 0.95rem; }
.rail-list a.item.past .rep.new { opacity: 0.55; }
.rail-list a.item.past .rep.stale { position: relative; }
.rail-list a.item.past .rep.stale::after { content: ""; position: absolute; right: 0; top: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--amber); }
.rail-list a.item.past .rep:hover { color: var(--ink); background: #f1f1ec; opacity: 1; }
.rail-list a.item.past .trash { padding: 0.1rem; border: 0; background: transparent; color: var(--muted); display: inline-flex; border-radius: 4px; }
.rail-list a.item.past .trash svg { width: 0.95rem; height: 0.95rem; }
.rail-list a.item.past:hover .trash { display: inline-flex; }
.rail-list a.item.past .trash:hover { color: var(--red); background: #f1f1ec; }
.rail-list details.other { margin: 0.2rem 0 0 0.4rem; font-size: 0.78rem; }
.rail-list details.other summary { font-weight: 400; color: var(--muted); }
.rail-list .sub { padding: 0.35rem 0.3rem 0.1rem 0.9rem; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.rail-list .hist-more { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0.3rem 0.3rem 0.3rem 0.9rem; font-size: 0.76rem; color: var(--muted); cursor: pointer; border-radius: 3px; }
.rail-list .hist-more:hover { color: var(--ink); background: #ecece6; }
.rail-note { font-size: 0.72rem; color: var(--muted); padding: 0.15rem 0.3rem 0 0.9rem; }
.rail .spacer { flex: 1; }
/* Status line and icons stay at the bottom of the rail however long its lists get (bottom -1rem = the rail's padding: flush with its edge). */
.rail .railfoot { position: sticky; bottom: -1rem; z-index: 4; margin: 0 -0.9rem -1rem; padding: 0.7rem 0.9rem 1rem; background: #f6f6f2; border-top: 1px solid var(--line); }
.rail .status { font-size: 0.76rem; color: #3d3d3d; }
.rail .links { display: flex; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.rail .rail-icon { padding: 0.3rem; border: 1px solid transparent; background: transparent; color: #3d3d3d; display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 6px; font-size: 0.84rem; }
.rail .rail-icon svg { width: 1.15rem; height: 1.15rem; flex: none; }
.rail .rail-icon:hover { background: #fff; border-color: var(--line); }
.rail .rail-icon.ext { text-decoration: none; }
.rail .rail-icon.ext:first-of-type { margin-left: auto; }
.rail .rail-icon.ext svg { width: 1.05rem; height: 1.05rem; }
/* "+ New ..." reads like the rows below it: same indent, same weight, the plus where the triangle sits. */
.rail .rail-icon.new { align-self: stretch; justify-content: flex-start; color: #333333; font-weight: 600; margin: 0.15rem 0 0 1.2rem; padding: 0.25rem 0.2rem; gap: 0.3rem; font-size: 0.8rem; border-radius: 4px; }
.rail .rail-icon.new svg { width: 0.8rem; height: 0.8rem; color: #6b6b6b; }
.rail .rail-icon.new:hover { background: #fff; border-color: transparent; }
.rail .status .down { color: var(--red); }
/* Help answers: a thin accent bar, small label in the note. */
.msg.assistant.help { border-left: 3px solid var(--accent); padding-left: 0.7rem; }
/* Start screen: the question in the serif pi.dev uses for its tagline
   (Plantin where installed, Georgia elsewhere), two tiles with the verbs. */
.hero { width: 100%; max-width: 44rem; margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 2.2rem; padding: 2rem 0 3rem; }
.hero h1 { font-family: "Plantin MT Pro", "Plantin MT Std", Plantin, Georgia, "Times New Roman", serif; font-style: italic; font-weight: 400; font-size: 1.75rem; color: var(--ink); margin: 0; text-align: center; letter-spacing: 0.005em; line-height: 1.35; display: flex; flex-direction: column; gap: 0.1em; }
.hero h1 span { white-space: nowrap; }
.hero .hero-mark { margin-bottom: -0.9rem; color: var(--ink); }
.hero .hero-mark svg { width: 2.6rem; height: 2.6rem; display: block; }
/* Build-up: lines one to three slide in one after another; the fourth is
   typed in two colour groups (sage, then rosé) and settles to ink. Played
   once per browser session; reduced-motion users see the settled state. */
.hero.animate h1 span.fly { opacity: 0; transform: translateY(0.4em); animation: hero-up 0.7s ease forwards; }
@keyframes hero-up { to { opacity: 1; transform: none; } }
.hero h1 span.typed { min-height: 1.35em; }
.hero h1 span.typed i { font-style: inherit; transition: color 1.4s ease; }
.hero h1 span.typed i.g1 { color: #5f9c8a; }
.hero.settled h1 span.typed i { color: var(--ink); }
.hero h1 span.typed.caret::after { content: "|"; color: var(--muted); animation: hero-blink 1s steps(1) infinite; }
@keyframes hero-blink { 50% { opacity: 0; } }
.hero.animate .tiles { opacity: 0; transition: opacity 0.9s ease; }
.hero.animate .tiles.in, .hero.settled .tiles { opacity: 1; }
@media (max-width: 60rem) { .hero h1 { font-size: 1.35rem; } }
.hero .tiles { display: flex; gap: 2.5rem; flex-wrap: wrap; justify-content: center; }
.hero .tile { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 1.1rem 1.6rem; cursor: pointer; color: #333333; font: inherit; }
.hero .tile svg { width: 3.4rem; height: 3.4rem; color: #6b6b6b; }
.hero .tile { max-width: 17rem; }
.hero .tile span { font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.hero .tile:hover, .hero .tile:focus-visible { background: #fff; border-color: var(--line); outline: none; }
.hero .tile:hover svg { color: var(--accent); }
.hero .tile:disabled { opacity: 0.45; cursor: default; }
.hero .tile:disabled:hover { background: transparent; border-color: transparent; }
/* Start of the page (index.html): the invisible start-screen copy keeps
   only its pi mark visible; it starts to pulse after 0.4 s, from full
   strength, so a fast load shows the still mark only. */
.hero.boot h1, .hero.boot .tiles { visibility: hidden; }
.hero.boot .hero-mark { animation: boot-pulse 1.4s ease-in-out 0.4s infinite; }
@keyframes boot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .hero.boot .hero-mark { animation: none; } }
.hero .tile:disabled:hover svg { color: #6b6b6b; }
/* Info popover in the rail: where the data goes, the sources. */
.rail .links { position: relative; }
.rail .info-pop { position: fixed; left: 0.9rem; bottom: 3.6rem; width: 22rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.85rem; font-size: 0.76rem; color: #3d3d3d; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); line-height: 1.4; z-index: 5; }
.rail .info-pop[hidden] { display: none; }
.rail .info-pop b { color: var(--ink); }
.rail .info-pop p { margin: 0 0 0.5rem; }
.rail .info-pop p:last-child { margin: 0; }
.rail .info-pop .cite { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.rail .info-pop .cite .ref { display: block; margin: 0.3rem 0; padding: 0.35rem 0.5rem; background: #f6f6f3; border-radius: 4px; color: var(--ink); user-select: all; }
.rail .info-pop .cite .ibtn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0.1rem 0.55rem; font: inherit; font-size: 0.74rem; cursor: pointer; }

/* Chat column: a centred, narrow conversation */
.chat { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.thread { flex: 1; overflow: auto; padding: 1.6rem 1.4rem 0.5rem; display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }
.msg { width: 100%; max-width: 44rem; font-size: 0.95rem; }
.msg.assistant { padding: 0 0.2rem; }
.msg p { margin: 0 0 0.4rem; white-space: pre-wrap; }
.msg p:last-child { margin-bottom: 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: 80%; background: #eef0ee; border-radius: 14px 14px 4px 14px; padding: 0.6rem 0.95rem; white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.chips button { font-size: 0.84rem; padding: 0.3rem 0.8rem; border-radius: 999px; background: #fff; border-color: #d0d0ca; color: var(--accent); }
.chips button:hover { background: var(--accent-soft); }
.chips button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips button.toggle.on { background: var(--accent-soft); border-color: var(--accent); }
.chips button.toggle.on::before { content: "\2713 "; }
.msg.spent .chips button, .msg.spent .blocks input { opacity: 0.45; pointer-events: none; }
.blocks { margin: 0.5rem 0 0.2rem; display: flex; flex-direction: column; gap: 0.3rem; }
.blocks input { font: inherit; font-size: 0.88rem; padding: 0.3rem 0.5rem; border: 1px solid #c9c9c2; border-radius: 3px; width: 100%; background: #fff; }
.blocks .brow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.blocks .term { display: inline-flex; align-items: center; border: 1px solid #c9c9c2; border-radius: 999px; background: #fff; padding: 0 0.1rem 0 0.6rem; }
.blocks .term:focus-within { border-color: var(--ink); }
/* Synonyms of one block are linked by a small "≈" between their boxes. */
.blocks .term { position: relative; }
.blocks .term + .term { margin-left: 0.85rem; }
.blocks .term + .term::before { content: "\2248"; position: absolute; left: -0.95rem; width: 0.9rem; text-align: center; color: var(--muted); font-size: 0.8rem; pointer-events: none; }
.blocks .term input { width: auto; border: 0; padding: 0.25rem 0; background: transparent; outline: none; font-size: 0.88rem; }
.blocks button.ed { border: 0; background: transparent; color: var(--muted); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.95rem; line-height: 1; cursor: pointer; }
.blocks button.ed:hover { color: var(--ink); background: var(--accent-soft); }
.blocks button.ed.rm { margin-left: auto; }
.blocks button.ed.rm svg { width: 0.95rem; height: 0.95rem; vertical-align: -2px; }
.blocks .addblock { align-self: flex-start; font-size: 0.82rem; margin-top: 0.2rem; }
.msg.spent .blocks button.ed { display: none; }
.blocks .and { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-left: 0.2rem; }
.pending { color: var(--muted); display: flex; align-items: center; padding: 0.4rem 0.8rem; }
/* Vertical tick lists (journals, authors, topics, papers) */
.list { margin: 0.55rem 0 0.1rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.list summary { cursor: pointer; padding: 0.4rem 0.8rem; font-size: 0.84rem; color: var(--accent); list-style: none; display: flex; align-items: center; gap: 0.4rem; }
.list summary::-webkit-details-marker { display: none; }
.list summary::before { content: ""; width: 0; height: 0; border-left: 5px solid var(--accent); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; }
.list[open] summary::before { transform: rotate(90deg); }
.list .items { max-height: 18rem; overflow: auto; padding: 0.2rem 0.5rem 0.4rem; border-top: 1px solid var(--line); }
.list label { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.22rem 0.3rem; font-size: 0.88rem; border-radius: 4px; cursor: pointer; }
.list label:hover { background: var(--accent-soft); }
.list label input { margin-top: 0.3rem; flex: none; }
.msg.spent .list label { pointer-events: none; opacity: 0.55; }
.pending .dot { margin-right: 0.4rem; }

/* Working bubble: the job's progress lines */
/* Closed: one line, the dot and the current progress line. Open: the dark log. */
.working { width: 100%; max-width: 44rem; border-radius: 8px; }
.working summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem; color: var(--muted); padding: 0.4rem 0.8rem; min-height: 1.6rem; }
.working summary::-webkit-details-marker { display: none; }
.working summary .wstatus { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.working summary .dot { margin-right: 0; }
.working summary button { margin-left: auto; flex: none; font: inherit; font-size: 0.8rem; line-height: 1.3; padding: 0.05rem 0.5rem; background: none; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; }
.working pre { display: none; }
.working[open] { background: #1f2326; color: #d7dbd2; }
.working[open] summary { color: #fff; }
.working[open] summary button { color: #fff; border-color: #555; }
.working[open] pre { display: block; font-family: "DejaVu Sans Mono", Consolas, monospace; font-size: 0.76rem; }
.working pre { margin: 0; padding: 0 0.8rem 0.6rem; white-space: pre-wrap; max-height: 11rem; overflow: auto; line-height: 1.4; }
.working .ok { color: #8fd19e; }
.working .warn { color: #e6c07b; }
.working .bad { color: #f0917f; }
.working .dim { color: #8a8f88; }

/* Answer bubble (the paper chat) */
.answer .prose sup a { color: var(--accent); text-decoration: none; font-weight: 600; }
.answer .prose ul { margin: 0.2rem 0 0.4rem; padding-left: 1.3rem; }
.answer .prose li { margin: 0.1rem 0; }
.answer .prose p.h { font-weight: 600; margin: 0.6rem 0 0.2rem; }
.answer .cites { font-size: 0.82rem; color: #3d3d3d; margin: 0.5rem 0 0; padding-left: 0; list-style: none; }
.answer .cites li { margin: 0.15rem 0; }
.answer .cites .n { font-weight: 600; color: var(--accent); }
.answer .trail { font-size: 0.78rem; color: var(--muted); margin: 0.5rem 0 0; border-top: 1px solid var(--line); padding-top: 0.4rem; }
.answer.ungrounded .prose { color: var(--muted); }
.answer .uncited { display: inline-block; margin-bottom: 0.25rem; font-size: 0.72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 0.5rem; }

/* File and folder cards */
.filecard { display: inline-flex; align-items: center; gap: 0.7rem; margin: 0.2rem 0; padding: 0.5rem 0.6rem 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; max-width: 100%; }
.filecard .ico { flex: none; width: 1.9rem; height: 1.9rem; color: var(--accent); }
.filecard .txt { min-width: 0; line-height: 1.25; }
.filecard .txt a, .filecard .txt .name { font-weight: 600; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); cursor: pointer; }
.filecard .txt .name.plain { color: var(--ink); cursor: default; }
.filecard .txt small { color: var(--muted); font-size: 0.76rem; }
.filecard .folder { flex: none; border: 1px solid transparent; background: transparent; padding: 0.25rem; border-radius: 6px; color: #3d3d3d; display: inline-flex; }
.filecard .folder:hover { background: #f1f1ec; border-color: var(--line); }
.filecard .folder svg { width: 1.25rem; height: 1.25rem; }

/* Composer */
.composer-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0.6rem 1.4rem 1rem; background: linear-gradient(to bottom, rgba(253,253,252,0), var(--paper) 40%); }
.composer { display: flex; gap: 0.5rem; width: 100%; max-width: 44rem; padding: 0.45rem 0.45rem 0.45rem 1rem; border: 1px solid #c9c9c2; border-radius: 14px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.composer input { flex: 1; font: inherit; font-size: 0.95rem; padding: 0.45rem 0.2rem; border: 0; outline: none; background: transparent; min-width: 0; }
.composer input:disabled { color: var(--muted); }
.composer button { border-radius: 10px; }
/* The "+" menu of the request box: options before the search, pills
   under the box for what is set (opens upward at the bottom of the page,
   downward in the entry layout). */
.composer .plusanchor { position: relative; display: inline-flex; }
.composer .plusanchor[hidden], .composer .plusbtn[hidden] { display: none; }
.composer .plusbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; padding: 0; background: #fff; color: var(--muted); border: 1px solid transparent; }
.composer .plusbtn svg { width: 1.25rem; height: 1.25rem; }
.composer .plusbtn:hover, .composer .plusbtn[aria-expanded="true"] { color: var(--ink); background: var(--accent-soft); }
.plusbtn .badge { position: absolute; top: 0.1rem; right: 0.1rem; min-width: 1rem; height: 1rem; border-radius: 999px; background: #2a2a2a; color: #fff; font-size: 0.62rem; line-height: 1rem; text-align: center; padding: 0 0.2rem; }
.plusbtn .badge:empty { display: none; }
.plusmenu { position: absolute; right: 0; bottom: calc(100% + 0.5rem); z-index: 30; width: 30rem; max-width: calc(100vw - 2rem); max-height: min(70vh, 34rem); overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,0.14); padding: 0.35rem; text-align: left; }
.plusmenu[hidden] { display: none; }
.composer { position: relative; }
.mention { position: absolute; left: 0.6rem; bottom: calc(100% + 0.4rem); z-index: 31; width: 26rem; max-width: calc(100% - 1.2rem); max-height: 18rem; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,0.14); padding: 0.3rem; text-align: left; }
.mention[hidden] { display: none; }
.chat.entry .mention { bottom: auto; top: calc(100% + 0.4rem); }
.mention .mrow { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.3rem 0.5rem; border-radius: 6px; cursor: pointer; font-size: 0.86rem; }
.mention .mrow.on, .mention .mrow:hover { background: var(--accent-soft); }
.mention .mname { flex-shrink: 0; white-space: nowrap; }
.mention small { color: var(--muted); margin-left: auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention .wait { font-size: 0.82rem; color: var(--muted); display: flex; gap: 0.4rem; align-items: center; padding: 0.3rem 0.5rem; }
.chat.entry .plusmenu { bottom: auto; top: calc(100% + 0.5rem); max-height: min(44vh, 34rem); }
.plusmenu input { flex: none; }
.plusmenu button { border-radius: 6px; }
.plusmenu .row { display: flex; align-items: center; gap: 0.65rem; padding: 0.4rem 0.55rem; border-radius: 8px; min-height: 2.35rem; }
.plusmenu .row:hover { background: #f7f7f3; }
.plusmenu .row .ico { width: 1.15rem; height: 1.15rem; color: #444; flex: none; }
.plusmenu .row .name { flex: 1; font-size: 0.9rem; }
.plusmenu .row .val { font-size: 0.8rem; color: var(--muted); max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plusmenu .row.off { opacity: 0.45; }
.plusmenu .row.off:hover { background: transparent; }
.plusmenu .soon { font-size: 0.7rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem; color: var(--muted); }
.plusmenu .sep { height: 1px; background: var(--line); margin: 0.3rem 0.4rem; }
.plusmenu .row.click { cursor: pointer; }
.plusmenu .switch { display: inline-block; width: 2.1rem; height: 1.2rem; border-radius: 999px; background: #d6d6d0; border: 0; position: relative; padding: 0; flex: none; }
.plusmenu .switch::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 0.9rem; height: 0.9rem; border-radius: 50%; background: #fff; transition: left 0.15s; }
.plusmenu .switch[data-toggle] { cursor: pointer; }
.plusmenu .switch.on { background: #2a2a2a; }
.plusmenu .switch.on::after { left: 1.05rem; }
.plusmenu .seg { display: inline-flex; border: 1px solid #d6d6d0; border-radius: 8px; overflow: hidden; }
.plusmenu .seg button { border: 0; border-radius: 0; background: #fff; padding: 0.2rem 0.5rem; font-size: 0.78rem; color: #444; }
.plusmenu .seg button + button { border-left: 1px solid #d6d6d0; }
.plusmenu .seg button.on { background: #2a2a2a; color: #fff; }
.plusmenu .stepper { display: inline-flex; align-items: center; border: 1px solid #d6d6d0; border-radius: 8px; overflow: hidden; }
.plusmenu .stepper button { border: 0; border-radius: 0; background: #fff; width: 1.6rem; height: 1.6rem; padding: 0; color: #444; }
.plusmenu .stepper input { width: 3.2rem; border: 0; padding: 0.2rem; text-align: center; font: inherit; font-size: 0.82rem; outline: none; }
.plusmenu .more { border: 0; background: transparent; color: var(--muted); font-size: 1rem; padding: 0 0.3rem; }
.plusmenu .sub { padding: 0.2rem 0.55rem 0.55rem 2.35rem; }
.plusmenu .sub .wait { font-size: 0.82rem; color: var(--muted); display: flex; gap: 0.4rem; align-items: center; padding: 0.2rem 0; }
.plusmenu .sub label { display: flex; align-items: baseline; gap: 0.45rem; font-size: 0.84rem; padding: 0.18rem 0; cursor: pointer; }
.plusmenu .sub label span { min-width: 0; }
.plusmenu .sub label .au { flex-shrink: 0; white-space: nowrap; }
.plusmenu .sub label small { color: var(--muted); margin-left: auto; white-space: nowrap; padding-left: 0.5rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.plusmenu .sub .lookup { width: 100%; font: inherit; font-size: 0.82rem; padding: 0.3rem 0.5rem; border: 1px solid #d6d6d0; border-radius: 6px; margin: 0.15rem 0 0.35rem; }
.plusmenu .sub .scope { margin-top: 0.4rem; }
.plusmenu .sub.syn { padding-left: 0.9rem; }
/* The paper chat's menu: one radio per source kind, folder tree and paper
   list scroll inside the menu, report kinds under their switch. */
.plusmenu .radio { width: 0.95rem; height: 0.95rem; border-radius: 50%; border: 1.5px solid #9a9a94; flex: none; position: relative; }
.plusmenu .radio.on { border-color: #2a2a2a; }
.plusmenu .radio.on::after { content: ""; position: absolute; inset: 0.15rem; border-radius: 50%; background: #2a2a2a; }
.plusmenu .kcheck { width: 0.85rem; height: 0.85rem; border-radius: 3px; border: 1.5px solid #9a9a94; flex: none; background: #fff; }
.plusmenu .kcheck.on { border-color: #2a2a2a; background: #2a2a2a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.2 5 8.5l4.4-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; }
.plusmenu .sub.tree, .plusmenu #chat-papers { max-height: 14rem; overflow: auto; }
.plusmenu #chat-papers label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plusmenu .sub.tree label input:disabled + span { color: var(--muted); }
/* Report kinds: two small groups (Summarize, Synthesize) of radio rows. */
.plusmenu .sub.kinds { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.plusmenu .kgroup { flex: 1 1 11rem; }
.plusmenu .khead { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 0.15rem 0 0.25rem; }
.plusmenu .krow { display: flex; align-items: center; gap: 0.5rem; font-size: 0.84rem; padding: 0.25rem 0.3rem; border-radius: 6px; cursor: pointer; }
.plusmenu .krow:hover { background: #f7f7f3; }
.plusmenu .sub.syn .blocks { margin-top: 0.1rem; }
.plusmenu .sub.syn .term { padding-left: 0.45rem; }
.plusmenu .sub.syn .term input { font-size: 0.82rem; }
.plusmenu .sub.syn .brow { gap: 0.25rem; }
.plusmenu .regen { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.45rem; border: 1px solid #d6d6d0; background: #fff; color: #333; font-size: 0.8rem; padding: 0.2rem 0.55rem; border-radius: 8px; }
.plusmenu .regen svg { width: 0.9rem; height: 0.9rem; }
.plusmenu .regen:hover { background: var(--accent-soft); }
.pills { display: flex; flex-wrap: wrap; gap: 0.35rem; width: 100%; max-width: 44rem; margin-top: 0.45rem; padding: 0 0.3rem; }
.pills[hidden] { display: none; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; border: 1px solid #d6d6d0; border-radius: 999px; background: #fff; padding: 0.12rem 0.3rem 0.12rem 0.6rem; font-size: 0.78rem; color: #333; cursor: pointer; max-width: 100%; }
.pill .ico { width: 0.9rem; height: 0.9rem; flex: none; }
.pill .x { border: 0; background: transparent; color: var(--muted); padding: 0 0.25rem; font-size: 0.9rem; line-height: 1; }
.pill .x:hover { color: var(--ink); }
.pill.fixed { padding-right: 0.6rem; }
/* The synonym drop-down under the request box. */
.drop { width: 100%; max-width: 44rem; margin-top: 0.5rem; padding: 0.75rem 1rem; border: 1px solid #c9c9c2; border-radius: 14px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.06); max-height: 55vh; overflow: auto; }
.drop[hidden] { display: none; }
.drop .msg { margin: 0; text-align: left; }
.drop .msg > p:first-child { font-size: 0.86rem; color: #3d3d3d; margin-top: 0; }
/* Entry layout (class set by app.js): a conversation that holds only its
   first question shows that question, in the start screen's serif, and the
   input box together in the middle of the column; the note under the
   request question is dropped because the input types the examples. */
.chat.entry .thread { flex: 0 1 auto; margin-top: auto; overflow: visible; padding-bottom: 0; }
.chat.entry .thread .msg { text-align: center; }
.chat.entry .thread .msg > p:first-child { font-family: "Plantin MT Pro", "Plantin MT Std", Plantin, Georgia, "Times New Roman", serif; font-style: italic; font-size: 1.45rem; line-height: 1.35; color: var(--ink); margin-bottom: 0.5rem; }
.chat.entry .thread .chips { justify-content: center; }
.chat.entry .composer-wrap { margin-bottom: auto; padding-top: 0.5rem; background: none; }

/* Report panel */
.report { display: flex; flex-direction: column; min-height: 0; background: #fff; }
.report .head { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.82rem; color: #3d3d3d; }
.report .head b { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.report .head .ticked { margin-left: auto; color: var(--accent); white-space: nowrap; }
.report .head button.icon { padding: 0.25rem; border-color: transparent; background: transparent; color: #3d3d3d; display: inline-flex; border-radius: 6px; }
.report .head button.icon svg { width: 1.15rem; height: 1.15rem; }
.report .head button.icon:hover { background: #f1f1ec; border-color: var(--line); }
.report iframe { flex: 1; border: 0; width: 100%; }
.report .empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.9rem; text-align: center; padding: 2rem; }
/* A flow diagram is small: its window fits it instead of the page. */
.report.popup.compact { inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(54rem, calc(100vw - 2rem)); height: min(44rem, calc(100vh - 2rem)); }
.report.popup { position: fixed; inset: 2.2rem 3rem; z-index: 30; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); overflow: hidden; display: flex !important; }
.backdrop { position: fixed; inset: 0; background: rgba(20, 24, 28, 0.45); z-index: 20; }
.toast { position: fixed; bottom: 5.2rem; left: 50%; transform: translateX(-50%); background: #1f2326; color: #fff; font-size: 0.82rem; padding: 0.45rem 0.9rem; border-radius: 8px; z-index: 40; max-width: 40rem; }

/* Settings dialog */
dialog { border: 1px solid var(--line); border-radius: 6px; padding: 1.2rem 1.4rem; width: min(42rem, 92vw); font-size: 0.9rem; color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 28, 0.35); }
dialog h3 { margin: 0 0 0.4rem; font-size: 1rem; }
dialog h4 { margin: 1rem 0 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: #333333; }
dialog label { display: block; margin: 0.5rem 0 0.15rem; font-size: 0.82rem; color: #2c2c2c; }
dialog input, dialog select { width: 100%; font: inherit; font-size: 0.88rem; padding: 0.35rem 0.5rem; border: 1px solid #c9c9c2; border-radius: 3px; background: #fff; margin-top: 0.15rem; }
dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.8rem; }
dialog table.keys { border-collapse: collapse; margin-top: 0.6rem; font-size: 0.8rem; width: 100%; }
dialog table.keys td { border-top: 1px solid var(--line); padding: 0.25rem 0.4rem; vertical-align: top; }
dialog .progress { background: #1f2326; color: #d7dbd2; font-family: "DejaVu Sans Mono", Consolas, monospace; font-size: 0.76rem; padding: 0.5rem 0.7rem; max-height: 9rem; overflow: auto; white-space: pre-wrap; margin: 0.8rem 0 0; border-radius: 4px; }
dialog .progress:empty { display: none; }
dialog .progress .ok { color: #8fd19e; }
dialog .progress .warn { color: #e6c07b; }
dialog .progress .bad { color: #f0917f; }
dialog .progress .dim { color: #8a8f88; }
dialog .row { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

@media (max-width: 70rem) {
  .shell, .shell.no-report { grid-template-columns: 11rem 1fr 0; }
  .shell:not(.no-report) .report { position: fixed; inset: 2.2rem 1rem; z-index: 30; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
}

/* Narrow screens (phones, small tablets): one column. The rail becomes a
   drawer from the left, closed at start, opened by the menu button
   (#btn-rail) and closed by the backdrop or by choosing an entry in it. */
.rail-toggle, .rail-backdrop { display: none; }
@media (max-width: 48rem) {
  .shell, .shell.no-report { grid-template-columns: minmax(0, 1fr) 0; height: 100dvh; }
  .rail-resize { display: none; }
  .rail { position: fixed; top: 0; bottom: 0; left: 0; width: min(18rem, 85vw); z-index: 40; transform: translateX(-100%); transition: transform 0.2s ease; visibility: hidden; }
  .shell.rail-open .rail { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); }
  .shell.rail-open .rail-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.3); }
  .rail-toggle { display: inline-flex; align-items: center; justify-content: center; position: fixed; top: 0.6rem; left: 0.6rem; z-index: 20; width: 2.4rem; height: 2.4rem; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, 0.92); color: var(--ink); cursor: pointer; }
  .rail-toggle svg { width: 1.3rem; height: 1.3rem; }
  .chat { border-right: 0; }
  .thread { padding: 3.4rem 0.9rem 0.5rem; }
  .composer-wrap { padding: 0.5rem 0.7rem 0.8rem; }
  .shell:not(.no-report) .report { inset: 0; border: 0; border-radius: 0; z-index: 45; }
}

/* Result cards of a search run (app.js resultsHtml): header with counters,
   filter funnel and sort; the searched blocks; the filter panel; the
   cards; the action bar (download, add-on, reports from the list). */
.msg.results { width: 100%; max-width: 46rem; }
.results .rhead { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.results .rcount { font-weight: 600; font-size: 0.92rem; }
.results .rcount .rsub { font-weight: 400; }
.results .rcount .rsub a { color: inherit; }
.results .rmeta { color: var(--muted); font-size: 0.78rem; display: inline-flex; align-items: center; gap: 0.4rem; }
.results .spacer { flex: 1; }
.results .ibtn { display: inline-flex; align-items: center; gap: 0.35rem; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0.28rem 0.6rem; font: inherit; font-size: 0.8rem; cursor: pointer; color: var(--ink); }
.results .ibtn svg { width: 1rem; height: 1rem; }
/* Buttons that run the search again: the "+" menu's icon with a small arrow. */
.rerun { position: relative; display: inline-flex; margin-right: 0.3rem; }
.rerun .mini { position: absolute; right: -0.3rem; bottom: -0.3rem; width: 0.7rem; height: 0.7rem; display: inline-flex; background: #fff; border-radius: 50%; }
.results .ibtn .rerun .mini svg { width: 0.7rem; height: 0.7rem; }
.results .rtools .tsep { width: 1px; align-self: stretch; background: var(--line); margin: 0.15rem 0.2rem; }
dialog.modal h3.wtitle { display: flex; align-items: center; gap: 0.45rem; }
dialog.modal h3.wtitle svg { width: 1.15rem; height: 1.15rem; }
dialog.modal .regen { display: inline-flex; align-items: center; gap: 0.35rem; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0.25rem 0.6rem; font: inherit; font-size: 0.8rem; cursor: pointer; margin-top: 0.4rem; }
dialog.modal .regen svg { width: 0.9rem; height: 0.9rem; }
dialog.modal .regen:disabled { opacity: 0.5; cursor: default; }
.results .rtools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin: 0.15rem 0 0.6rem; }
.results .sortwrap { position: relative; }
.results .sortmenu { position: absolute; left: 0; top: calc(100% + 0.25rem); z-index: 5; display: flex; flex-direction: column; min-width: 9rem; padding: 0.25rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,0.1); }
.results .sortmenu button { text-align: left; border: 0; background: none; font: inherit; font-size: 0.8rem; padding: 0.35rem 0.6rem; border-radius: 6px; cursor: pointer; color: var(--ink); }
.results .sortmenu button:hover { background: var(--accent-soft); }
.results .sortmenu button.on { font-weight: 600; }
.results .ibtn.on { background: var(--accent-soft); border-color: #bdbdb6; }
.results .ibtn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.results .ibtn[disabled], .results .chip[disabled] { opacity: 0.45; cursor: default; }
/* Filters: a two-column table, label left, choices right. */
.results .rfilters { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 0.7rem; font-size: 0.85rem; }
.results .rfilters[hidden] { display: none; }
.results .rfilters th { text-align: left; font-weight: 600; white-space: nowrap; vertical-align: top; padding: 0.55rem 1rem 0.4rem; width: 1%; }
.results .rfilters td { padding: 0.35rem 1rem 0.35rem 0; }
.results .rfilters tr + tr th, .results .rfilters tr + tr td { border-top: 1px solid var(--line); }
.results .rfilters td.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.results .rfilters input[type=text] { font: inherit; padding: 0.25rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; width: 100%; max-width: 22rem; box-sizing: border-box; }
.results .rfilters .foot td { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.results .rfilters .chip small { color: var(--muted); margin-left: 0.15rem; }
.results .rfilters .chip.on small { color: inherit; opacity: 0.75; }
.results .rfilters td.pickcell { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.results .rfilters .picklist { flex-basis: 100%; margin-top: 0.2rem; }
.results .rfilters .picklist input[type=text] { margin-bottom: 0.3rem; }
.results .rfilters .picks { max-height: 14rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0.2rem 0; }
.results .rfilters .picks label { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.6rem; cursor: pointer; }
.results .rfilters .picks label:hover { background: var(--accent-soft); }
.results .rfilters .picks label input { margin: 0; flex: none; }
.results .rfilters .picks label span { flex: 1; min-width: 0; }
.results .rfilters .picks label small { color: var(--muted); }
.results .rfilters .picks .none { padding: 0.2rem 0.6rem; color: var(--muted); }
.results .chips { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 0; }
.results .chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.12rem 0.6rem; font: inherit; font-size: 0.76rem; cursor: pointer; color: var(--ink); }
.results .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.results .rlist { display: flex; flex-direction: column; gap: 0.5rem; }
.results .rempty { color: var(--muted); font-size: 0.85rem; padding: 1rem; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.results .pcard { display: grid; grid-template-columns: 1.4rem minmax(0, 1fr) auto; gap: 0.15rem 0.7rem; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 0.65rem 0.9rem 0.55rem 0.7rem; }
.results .pcard:hover { border-color: #bdbdb6; }
.results .pcard.isdropped { background: #fafaf7; color: #555; }
.results .pcard input { margin: 0.25rem 0 0; width: 1rem; height: 1rem; accent-color: var(--accent); }
.results .pcard .notick { display: inline-block; width: 1rem; height: 1rem; }
.results .pcard .t { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.results .pcard .t a { color: inherit; text-decoration: none; }
.results .pcard .t a:hover { text-decoration: underline; }
.results .pcard .a { color: #333; font-size: 0.81rem; }
.results .pcard .a button.au { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; border-radius: 0; }
.results .pcard .a button.au:hover { text-decoration: underline; text-decoration-color: #9a9a94; text-underline-offset: 2px; }
.results .pcard .a button.au.more { color: var(--muted); }
#plus-menu .au { cursor: pointer; }
#plus-menu .au:hover { text-decoration: underline; text-decoration-color: #9a9a94; text-underline-offset: 2px; }
.results .pcard .v { color: var(--muted); font-size: 0.77rem; }
.results .pcard .v b { color: #333; font-weight: 500; }
.results .pcard .flags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.2rem; }
.results .pcard .flag { font-size: 0.7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 0.45rem; }
.results .pcard .flag.snow { display: inline-flex; align-items: center; gap: 0.15rem; }
.results .pcard .flag.snow svg { width: 0.75rem; height: 0.75rem; }
.results .pcard .body, .results .pcard .flags { min-width: 0; }
.results .pcard .flag.dropped { display: inline-block; vertical-align: top; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .pcard .right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.results .pcard .cites b { color: #333; font-weight: 600; }
.results .badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 0.08rem 0.55rem; font-size: 0.71rem; font-weight: 600; }
.results .badge.free { background: #e8f3ec; color: #2f7d4f; }
.results .badge.abstract_only { background: #fbf3df; color: #9a6f00; }
.results .badge.restricted { background: #f8e7e4; color: #9b2d20; }
.results .badge.unknown { background: #eee; color: #666; }
.results .pcard .links { grid-column: 2 / 4; display: flex; gap: 0.9rem; font-size: 0.75rem; margin-top: 0.25rem; flex-wrap: wrap; align-items: center; }
.results .pcard .links a { color: #444; text-decoration: none; border-bottom: 1px dotted #aaa; display: inline-flex; align-items: center; gap: 0.25rem; }
.results .pcard .links a svg { width: 0.9rem; height: 0.9rem; }
.results .pcard .links .src { color: var(--muted); margin-left: auto; }
.results .pcard .abs { grid-column: 2 / 4; font-size: 0.78rem; color: #444; margin-top: 0.15rem; }
.results .pcard .abs summary { cursor: pointer; color: var(--muted); font-size: 0.73rem; }
.results .ractions { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); padding: 0.6rem 0 0.3rem; margin-top: 0.5rem; display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.results .ractions .sep { width: 1px; height: 1.4rem; background: var(--line); margin: 0 0.3rem; }
.results .ractions .lbl { font-size: 0.75rem; color: var(--muted); }

/* Results view (stage 1 after a search): the list is the page, the input box is away. */
.chat.resultsview .composer-wrap, .chat.startscreen .composer-wrap, .chat.booting .composer-wrap { display: none; }
.chat.resultsview .thread { padding-bottom: 1.2rem; }
/* The window over the list (download, contact email, keyword blocks). */
dialog.modal { width: min(32rem, 92vw); padding: 1.1rem 1.3rem 1rem; }
dialog.modal p { margin: 0 0 0.5rem; }
dialog.modal .hint { color: var(--muted); font-size: 0.8rem; }
dialog.modal label.check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; margin-top: 0.5rem; }
dialog.modal label.check input { width: auto; margin: 0; }
dialog.modal textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 0.9rem; padding: 0.45rem 0.6rem; border: 1px solid #c9c9c2; border-radius: 6px; resize: vertical; }
dialog.modal .modal-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
dialog.modal .modal-actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
dialog.modal .working { margin: 0.4rem 0; }
dialog.modal .folderline { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; font-size: 0.85rem; }
dialog.modal .folderline svg { width: 1.2rem; height: 1.2rem; color: #3d3d3d; }
dialog.modal .chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.12rem 0.6rem; font: inherit; font-size: 0.76rem; cursor: pointer; color: var(--ink); }

/* PDF library as folders (the user's own structure) */
.rail-list details.lfolder { margin: 0.05rem 0; }
.rail-list details.lfolder > summary { display: flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.3rem 0.18rem 0.4rem; cursor: pointer; border-radius: 3px; list-style: none; font-size: 0.8rem; color: var(--ink); }
.rail-list details.lfolder > summary::-webkit-details-marker { display: none; }
.rail-list details.lfolder > summary:hover { background: #fff; }
.rail-list details.lfolder > summary svg { width: 0.95rem; height: 0.95rem; flex: none; color: var(--muted); }
.rail-list details.lfolder > summary .lname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-list details.lfolder > summary .cnt { color: var(--muted); font-size: 0.72rem; }
.rail-list details.lfolder > summary .reveal { border: 0; background: transparent; padding: 0.05rem; color: var(--muted); display: none; border-radius: 4px; cursor: pointer; }
.rail-list details.lfolder > summary:hover .reveal { display: inline-flex; }
.rail-list details.lfolder details.lfolder, .rail-list details.lfolder > a.item { margin-left: 0.7rem; }
#rail-library > .rail-icon.new { margin: 0.2rem 0 0; }
/* Source ticks in the library: small quiet boxes; a ticked name is bold. */
.rail-list input.tick { appearance: none; -webkit-appearance: none; width: 0.72rem; height: 0.72rem; margin: 0; border: 1px solid #bdbdb6; border-radius: 3px; background: #fff; flex: none; cursor: pointer; }
.rail-list input.tick:checked { background: #2a2a2a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.2 5 8.5l4.4-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; border-color: #2a2a2a; }
.rail-list input.tick:disabled { cursor: default; }
/* The box's click area is larger than the box (no layout change); the
   hand shows only over the box and the title. */
.rail-list .tickhit { display: inline-flex; align-items: center; padding: 0.3rem; margin: -0.3rem; cursor: pointer; vertical-align: middle; }
.rail-list .tickhit:has(input:disabled) { cursor: default; }
.rail-list a.item.paper, .rail-list details.lfolder > summary { cursor: default; }
.rail-list a.item.paper > span, .rail-list details.lfolder > summary .lname, .rail-list details.lfolder > summary > svg { cursor: pointer; }
.rail-list input.tick:disabled:checked { background-color: #9a9a94; border-color: #9a9a94; }
.rail-list input.tick:hover:not(:disabled) { border-color: #6b6b66; }
.rail-list details.lfolder > summary { font-weight: 400; }
.rail-list details.lfolder > summary:has(> .tickhit > input.tick:checked:not(:disabled)) .lname { font-weight: 600; }
.rail-list a.item.paper:has(> .tickhit > input.tick:checked:not(:disabled)) > span { font-weight: 600; }
/* A PDF the library already held, after an upload: its row lights up. */
@keyframes rowflash { 0%, 40% { background: #e8e3cf; } 100% { background: transparent; } }
.rail-list a.item.paper.flash { animation: rowflash 3s ease-out; }
/* Background indexing: one quiet line with a thin bar under "Library". */
.rail .indexing { display: flex; align-items: center; gap: 0.4rem; padding: 0 0.3rem 0.25rem 1.1rem; font-size: 0.72rem; color: var(--muted); }
.rail .indexing[hidden] { display: none; }
.rail .indexing b { flex: 1; height: 3px; background: #deded7; border-radius: 2px; overflow: hidden; }
.rail .indexing i { display: block; height: 100%; width: 0; background: #8a8a84; transition: width .3s; }
/* The choice window (sources, indexing). */
dialog.modal .askrows { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.5rem 0 0.9rem; }
dialog.modal .askrow { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; justify-content: flex-start; text-align: left; }
dialog.modal .askrow input { flex: none; width: auto; margin: 0; }
dialog.modal .askrow span { flex: none; }
dialog.modal .askrow small { color: var(--muted); font-size: 0.78rem; }

/* PDF folders in Settings */
#settings .folders { display: flex; flex-direction: column; gap: 0.2rem; margin: 0.3rem 0; }
#settings .folders .folder { display: flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; }
#settings .folders .folder span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#settings .folders .folder .ibtn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0.1rem 0.35rem; cursor: pointer; display: inline-flex; align-items: center; }
#settings .folders .folder .ibtn svg { width: 0.9rem; height: 0.9rem; }
#settings .folder-add input { flex: 1; min-width: 10rem; }

/* Download window: the target folder */
dialog.modal .dlfolder { display: flex; align-items: center; gap: 0.45rem; margin: 0.6rem 0 0.2rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 0.88rem; }
dialog.modal .dlfolder svg { width: 1.1rem; height: 1.1rem; flex: none; color: #3d3d3d; }
dialog.modal .dlfolder .path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
dialog.modal .dlfolder input { flex: 1; min-width: 0; font: inherit; border: 0; outline: none; }

/* Drag and drop: the whole page takes PDFs */
/* The overlay takes the drop itself, also over the PDF viewer on the right
   (an iframe would otherwise open the dropped file). */
#dropzone { position: fixed; inset: 0; z-index: 1000; background: rgba(250, 250, 248, 0.86); display: flex; align-items: center; justify-content: center; }
#dropzone .dz { pointer-events: none; }
#dropzone[hidden] { display: none; }
#dropzone .dz { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; padding: 2.2rem 3rem; border: 2px dashed #9a9a92; border-radius: 16px; background: #fff; color: var(--ink); font-size: 1.05rem; }
#dropzone .dz svg { width: 3rem; height: 3rem; color: #6b6b6b; }

/* Library papers: the row continues the paper's last chat; "+" on hover starts a new one. */
.rail-list a.item.paper { position: relative; display: flex; align-items: center; gap: 0.35rem; }
.rail-list a.item.paper > span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-list a.item.paper .newchat { display: none; flex: none; margin-left: auto; border: 0; background: transparent; color: var(--muted); padding: 0 0.3rem; border-radius: 4px; cursor: pointer; font: inherit; font-size: 0.95rem; line-height: 1.2; }
.rail-list a.item.paper:hover .newchat { display: inline-flex; }
.rail-list a.item.paper .newchat:hover { color: var(--ink); background: #f1f1ec; }

/* Citation marks: the paper's letter plus the passage number (A1, B2);
   a chat on one PDF shows numbers only. */
.answer .prose a.cite { display: inline-block; font-size: 0.68rem; line-height: 1; font-weight: 600; vertical-align: super; margin: 0 0.06rem; padding: 0.12rem 0.24rem; border-radius: 3px; background: var(--accent-soft); color: var(--ink); text-decoration: none; letter-spacing: 0.01em; cursor: pointer; }
.answer .prose a.cite:hover { background: var(--accent); color: #fff; }
.citecard { position: fixed; z-index: 60; width: min(23rem, calc(100vw - 16px)); background: #fff; border: 1px solid #cfcfc8; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 0.65rem 0.85rem; font-size: 0.82rem; color: var(--ink); }
.citecard .hd { display: flex; align-items: center; gap: 0.45rem; font-weight: 600; }
.citecard .ttl { margin: 0.2rem 0 0.4rem; color: #333; }
.citecard q { display: block; color: #333; font-style: italic; border-left: 2px solid var(--line); padding-left: 0.55rem; margin: 0.3rem 0 0.5rem; }
.citecard .lk { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.citecard .lk a { color: var(--ink); }
.citecard .badge, .report .tabs .badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.15rem; height: 1.15rem; padding: 0 0.2rem; border-radius: 3px; background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700; flex: none; }

/* Tabs in the panel: the cited papers of a chat, then its reports. */
/* Layout switch of a paper report, under the panel head (fixed in place). */
.report .layoutbar { display: flex; align-items: center; justify-content: flex-end; gap: 0.15rem; padding: 0.2rem 0.9rem; border-bottom: 1px solid var(--line); background: #fbfbf8; }
.report .layoutbar[hidden] { display: none; }
.report .layoutbar .lbl { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: #8a8a8a; margin-right: 0.35rem; }
.report .layoutbar button { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.6rem; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #8a8a8a; }
.report .layoutbar button svg { width: 1.15rem; height: 1.15rem; }
.report .layoutbar button:hover { background: #f1f1ec; color: var(--ink); }
.report .layoutbar button.on { border-color: var(--accent); color: var(--ink); background: #fff; }
.report .head .tabs { flex: 1; min-width: 0; display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: thin; }
.report .head .tabs[hidden] { display: none; }
.report .tabs .tab { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid transparent; border-radius: 6px; padding: 0.22rem 0.55rem; color: #444; cursor: pointer; white-space: nowrap; max-width: 14rem; flex: none; }
.report .tabs .tab .t { overflow: hidden; text-overflow: ellipsis; }
.report .tabs .tab:hover { background: #f4f4f0; }
.report .tabs .tab.on { background: #f1f1ec; border-color: var(--line); color: var(--ink); font-weight: 600; }
.report .tabs .tab .badge { background: #9a9a94; }
.report .tabs .tab.on .badge { background: var(--accent); }
.report .tabs .tab svg { width: 0.95rem; height: 0.95rem; flex: none; }
.report .tabs .tab .x { border: 0; background: transparent; padding: 0 0.15rem; color: var(--muted); font-size: 0.95rem; line-height: 1; }
.report .tabs .tab .x:hover { color: var(--ink); background: transparent; }

/* Sources changed after answers: a thin line in the thread. */
.msg.divider { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.78rem; margin: 0.8rem 0; }
.msg.divider::before, .msg.divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* The paper chat's report buttons, right of the source pill. */
.pills .rbtns { margin-left: auto; display: inline-flex; gap: 0.4rem; }
.pills .rbtn { display: inline-flex; align-items: stretch; border: 1px solid #c9c9c2; border-radius: 6px; background: #fff; overflow: hidden; }
.pills .rbtn button { border: 0; border-radius: 0; background: transparent; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.55rem; font-size: 0.78rem; }
.pills .rbtn button:hover:not(:disabled) { background: #f1f1ec; }
.pills .rbtn button svg { width: 0.95rem; height: 0.95rem; flex: none; }
.pills .rbtn .again { border-left: 1px solid #d9d9d4; padding: 0.18rem 0.4rem; color: var(--muted); }
.pills .rbtn .again.stale { color: var(--ink); }
.pills .rbtn .again.stale svg { stroke-width: 2.4; }
.pills .rbtn.busy button.main { color: var(--muted); }
/* Report state: dashed = none yet; written = dark border + dot (green up to date, amber newer questions missing). */
.pills .rbtn.none { border-style: dashed; background: transparent; }
.pills .rbtn.done { border-color: var(--accent); }
.pills .rbtn.done .again { border-left-color: var(--accent); }
.rdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.rdot.ok { background: var(--green); }
.rdot.old { background: var(--amber); }

/* The library of the rail is where the paper chat's sources are chosen:
   a tick for the whole library on its row, a find box over the tree. */
.rail #rail-library.flash > summary { animation: rowflash 2s ease-out; }
.rail .lib-find { display: block; width: calc(100% - 0.6rem); margin: 0.45rem 0.3rem 0.35rem; padding: 0.22rem 0.5rem; font: inherit; font-size: 0.78rem; border: 1px solid #d6d6d0; border-radius: 6px; background: #fff; color: var(--ink); }
.rail .lib-find:focus { outline: none; border-color: #9a9a94; }
.rail-list .lib-hidden { display: none !important; }
.rail-list a.item.paper .newchat.info svg { width: 0.85rem; height: 0.85rem; }
.rail-list a.item.paper .newchat.info { align-items: center; }

/* Paper info window */
dialog.paperinfo { width: min(40rem, 94vw); }
dialog.paperinfo h3 { margin: 0 0 0.7rem; font-size: 1.02rem; line-height: 1.3; }
dialog.paperinfo .wait { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); }
.infotable { border-collapse: collapse; width: 100%; font-size: 0.84rem; }
.infotable th { text-align: left; vertical-align: top; font-weight: 600; color: #3d3d3d; padding: 0.28rem 0.9rem 0.28rem 0; white-space: nowrap; width: 1%; }
.infotable td { padding: 0.28rem 0; vertical-align: top; overflow-wrap: anywhere; }
.infotable .muted { color: var(--muted); }
.infotable .path { font-size: 0.78rem; color: #3d3d3d; }
.infotable button.icon { border: 0; background: transparent; padding: 0.05rem; vertical-align: middle; display: inline-flex; color: var(--muted); }
.infotable button.icon svg { width: 0.95rem; height: 0.95rem; }
.cbars { display: inline-flex; align-items: flex-end; gap: 0.2rem; height: 2.1rem; margin-left: 0.9rem; vertical-align: middle; }
.cbar { display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 1.15rem; }
.cbar i { display: block; width: 0.7rem; min-height: 2px; background: #9a9a94; border-radius: 2px 2px 0 0; }
.cbar small { font-size: 0.6rem; color: var(--muted); line-height: 1.1; }
dialog.paperinfo details.abstract { margin-top: 0.7rem; font-size: 0.84rem; }
dialog.paperinfo details.abstract summary { cursor: pointer; font-weight: 600; }
dialog.paperinfo details.abstract p { margin: 0.4rem 0 0; line-height: 1.5; }
.rail-list a.item.paper .newchat.info + .newchat { margin-left: 0; }
.rail #rail-library > summary .tickhit { display: inline-flex; align-items: center; padding: 0.3rem; margin: -0.3rem 0 -0.3rem -0.3rem; cursor: pointer; }
.pills .rbtn.on { background: var(--accent); border-color: var(--accent); }
.pills .rbtn.on button { color: #fff; }
.pills .rbtn.on button:hover:not(:disabled) { background: #000; }
.pills .rbtn.on .again { border-left-color: #555; }

/* Settings: one row per model role, compact key-value rows below. */
#settings { width: min(40rem, 92vw); }
#settings h4 { margin: 1.1rem 0 0.4rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
#settings h4:first-of-type { border-top: none; padding-top: 0; }
#settings .mrow { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.6rem; align-items: start; padding: 0.35rem 0; }
#settings .mname { font-weight: 600; font-size: 0.86rem; padding-top: 0.45rem; display: flex; align-items: baseline; gap: 0.1rem; flex-wrap: wrap; }
#settings .mname small { font-weight: 400; color: var(--muted); }
#settings .mname .dot { margin-right: 0.4rem; position: relative; top: -1px; }
#settings .mbody { display: grid; grid-template-columns: 1fr; gap: 0.35rem; align-items: center; }
#settings .mfields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
#settings .mfields[hidden], #settings .mfixed[hidden] { display: none; }
#settings .mfields input { margin: 0; }
#settings .mfixed { padding: 0.4rem 0; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#settings .mfixed small { color: var(--muted); }
#settings label.think { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.8rem; color: var(--muted); }
#settings label.think select { width: auto; margin: 0; padding: 0.2rem 0.4rem; font-size: 0.8rem; }
#settings .mbody > .mini { justify-self: start; }
#settings .mbody > .mini[hidden] { display: none; }
#settings button.mini { font: inherit; font-size: 0.8rem; padding: 0.3rem 0.7rem; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; white-space: nowrap; }
#settings button.mini:disabled { opacity: 0.5; cursor: default; }
#settings .warnline { color: var(--red); font-size: 0.8rem; margin: 0.3rem 0 0; }
#settings details.adv { margin-top: 0.4rem; font-size: 0.82rem; }
#settings details.adv summary { cursor: pointer; color: var(--muted); }
#settings .kv { display: grid; grid-template-columns: 9.5rem 1fr auto; gap: 0.6rem; align-items: center; padding: 0.25rem 0; font-size: 0.86rem; }
#settings .kv > span:first-child { font-weight: 600; }
#settings .kv input { margin: 0; grid-column: 2 / 4; }
#settings .kv.store .folders, #settings .kv > .keys { grid-column: 2 / 4; }
#settings .kv > b { font-weight: 400; }
#settings .kv > .btns { display: flex; gap: 0.4rem; }
#settings .keys { display: flex; flex-wrap: wrap; gap: 0.4rem; }
#settings .key { border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.78rem; color: var(--muted); }
#settings .key.on { color: var(--ink); border-color: #9a9a94; }
#settings .kv.lib, #settings .kv.store { align-items: start; }
#settings .kv.lib > span:first-child, #settings .kv.store > span:first-child { padding-top: 0.15rem; }
#settings .kv.lib > div { grid-column: 2 / 4; min-width: 0; }
#settings .kv.lib .folders { margin-top: 0; }
#settings button.key { font: inherit; font-size: 0.78rem; background: #fff; cursor: pointer; }
#settings button.key:hover { border-color: #9a9a94; color: var(--ink); }
#settings button.key.editing { border-color: var(--ink); color: var(--ink); }
#settings .kv.keyedit[hidden] { display: none; }
#settings .keyget { font-size: 0.8rem; white-space: nowrap; align-self: center; margin-left: 0.3rem; }
#settings .keyget[hidden] { display: none; }
#settings .kv.keyedit > span:first-child { font-weight: 400; color: var(--muted); }
#settings .keyrow { grid-column: 2 / 4; display: flex; gap: 0.4rem; align-items: center; }
#settings .keyrow input { flex: 1; min-width: 0; }
#settings .keyrow [hidden] { display: none; }
#settings .count { display: flex; align-items: center; gap: 0.5rem; }
#settings .count .ibtn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0.1rem 0.35rem; cursor: pointer; display: inline-flex; align-items: center; }
#settings .count .ibtn svg { width: 0.9rem; height: 0.9rem; }
#settings .folder-add { display: flex; gap: 0.5rem; align-items: center; margin: 0.35rem 0 0.2rem; }
#settings .folder-add [hidden] { display: none; }
@media (max-width: 34rem) {
	#settings .mrow, #settings .kv { grid-template-columns: 1fr; }
	#settings .mfields { grid-template-columns: 1fr; }
}
#settings .pick { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
#settings .pick select, #settings .pick input { margin: 0; }
#settings .pick [hidden], #settings #set-browser-model[hidden] { display: none; }
#settings .pick .other { display: flex; gap: 0.3rem; }
#settings .pick .other input { flex: 1; min-width: 0; }
#settings .pick .back { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 3px; padding: 0 0.55rem; cursor: pointer; font-size: 0.9rem; }
#settings #set-browser-model { margin: 0; }

/* The stage name above a stage's start question. */
.stagehead { display: flex; align-items: center; justify-content: center; gap: 0.45rem; margin: 0 auto 0.9rem; color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.stagehead svg { width: 1.15rem; height: 1.15rem; flex: none; }

/* Browser demo: the install window. */
dialog.modal table.installrows { border-collapse: collapse; width: 100%; margin: 0.4rem 0 0.2rem; font-size: 0.9rem; }
dialog.modal table.installrows th { text-align: left; font-weight: 600; padding: 0.45rem 0.6rem 0.45rem 0; white-space: nowrap; }
dialog.modal table.installrows td { padding: 0.45rem 0.3rem; border-top: 1px solid var(--line); }
dialog.modal table.installrows tr:first-child td, dialog.modal table.installrows tr:first-child th { border-top: 0; }
dialog.modal table.installrows code { background: #f1f1ec; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.86rem; white-space: nowrap; }
dialog.modal table.installrows a { display: block; font-size: 0.78rem; margin-top: 0.25rem; white-space: nowrap; }
#installbox .modal-actions a { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.8rem; color: var(--ink); text-decoration: none; font-size: 0.88rem; }
#installbox .modal-actions a:hover { background: var(--accent-soft); }
/* Browser demo: the recorded questions under the paper chat's box. */
.demo-asks { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; max-width: 44rem; margin-top: 0.5rem; }
.demo-asks .chip { text-align: left; }
/* Browser demo: the paper chat's box takes no typed questions. */
.composer.demo-locked { background: #f1f1ec; border-color: var(--line); box-shadow: none; }
.composer.demo-locked input { background: transparent; cursor: pointer; }
.composer.demo-locked input::placeholder { color: #6b6b66; }
.dot.off { background: transparent; border: 1px solid #b9b9b3; }
.demo-asks .demolink { border: 0; background: none; padding: 0.2rem 0.1rem; font: inherit; font-size: 0.9rem; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.demo-asks .demolink:hover { text-decoration-thickness: 2px; }
.info-pop .demo-install-row { display: block; margin-top: 0.45rem; }

/* Notepad (static/notes.js): one note per library paper, in the chat
   column's place; the PDF stays in the panel. Chat | Notes switches. */
.rail-list a.item.paper .newchat.note svg { width: 0.85rem; height: 0.85rem; }
.rail-list a.item.paper .newchat.note { align-items: center; }
.rail-list a.item.paper .newchat.note + .newchat { margin-left: 0; }
.shell.notes-open > .chat { display: none; }
.notes { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); background: var(--paper); }
.viewbar { display: flex; align-items: center; gap: 0.7rem; min-width: 0; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); background: var(--paper); }
.viewbar .viewlabel { cursor: pointer; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; font-weight: 500; color: #3d3d3d; }
.viewbar .viewlabel:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.viewtabs { display: inline-flex; flex: none; border: 1px solid #c9c9c2; border-radius: 7px; overflow: hidden; }
.viewtabs button { border: 0; border-radius: 0; background: #fff; padding: 0.18rem 0.75rem; font-size: 0.8rem; color: var(--muted); }
.viewtabs button + button { border-left: 1px solid #c9c9c2; }
.viewtabs button.on { background: var(--accent); color: #fff; cursor: default; }
.viewtabs button:not(.on):hover { background: #f1f1ec; color: var(--ink); }
.notes-state { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #b9b9b2; }
.notes-state.saved { background: var(--green); }
.notes-state.dirty { background: var(--amber); }
.notes-state.error { background: var(--red); }
.notes-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.35rem 1.1rem; border-bottom: 1px solid var(--line); background: #fbfbf9; }
.notes-tools, .notes-bg { display: flex; align-items: center; gap: 0.1rem; flex-wrap: wrap; }
.notes-bar button, .notes-bg button { display: inline-flex; align-items: center; justify-content: center; min-width: 1.75rem; height: 1.85rem; padding: 0 0.3rem; border: 0; border-radius: 5px; background: transparent; color: #3d3d3d; font-size: 0.82rem; }
.notes-bg button:hover, .notes-bar button:hover { background: #ecece6; color: var(--ink); }
.notes-bg button.on, .notes-bar button.on { background: #e2e2dc; color: var(--ink); }
.notes-bg button svg, .notes-bar button svg { width: 1.05rem; height: 1.05rem; }
.notes-bar .mono { font-family: "DejaVu Sans Mono", Consolas, monospace; font-size: 0.76rem; }
.notes-bar .sep { width: 1px; height: 1.2rem; margin: 0 0.3rem; background: #d6d6d0; }
.notes-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 1.2rem 1.2rem 3rem; }
.notepaper { --line-h: 1.75rem; max-width: 46rem; min-height: 100%; margin: 0 auto; padding: 1.2rem 1.6rem 4rem; background-color: #fff; border: 1px solid #e4e4de; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); font-size: 0.97rem; line-height: var(--line-h); color: var(--ink); outline: none; overflow-wrap: anywhere; }
/* Lined: one rule per text line; grid: 5 mm squares like squared paper. */
.notepaper[data-bg="lined"] { background-image: linear-gradient(to bottom, transparent calc(var(--line-h) - 1px), #d9e3ec calc(var(--line-h) - 1px)); background-size: 100% var(--line-h); background-position: 0 1.2rem; }
.notepaper[data-bg="grid"] { background-image: linear-gradient(to bottom, #e3e8ee 1px, transparent 1px), linear-gradient(to right, #e3e8ee 1px, transparent 1px); background-size: 0.875rem 0.875rem; background-position: -1px 1.2rem; }
.notepaper > :first-child { margin-top: 0; }
.notepaper p, .notepaper ul, .notepaper ol, .notepaper blockquote, .notepaper table, .notepaper figure { margin: 0 0 var(--line-h); }
.notepaper h1, .notepaper h2, .notepaper h3 { margin: 0 0 calc(var(--line-h) / 2); line-height: var(--line-h); }
.notepaper h1 { font-size: 1.45rem; }
.notepaper h2 { font-size: 1.2rem; }
.notepaper h3 { font-size: 1.02rem; }
.notepaper ul, .notepaper ol { padding-left: 1.5rem; }
.notepaper blockquote { padding: 0 0 0 0.9rem; border-left: 3px solid #c9c9c2; color: #3d3d3d; }
.notepaper a { color: var(--ink); text-decoration: underline; text-decoration-color: #9a9a94; text-underline-offset: 2px; cursor: pointer; }
.notepaper hr { border: 0; border-top: 1px solid #c9c9c2; margin: 0 0 var(--line-h); }
.notepaper table { border-collapse: collapse; background: #fff; }
.notepaper th, .notepaper td { border: 1px solid #c9c9c2; padding: 0.1rem 0.5rem; min-width: 4rem; vertical-align: top; text-align: left; }
.notepaper th { background: #f4f4f0; font-weight: 600; }
.notepaper figure { display: table; max-width: 100%; padding: 0.4rem; background: #fff; border: 1px solid #e4e4de; border-radius: 4px; cursor: default; }
.notepaper figure img { display: block; max-width: 100%; height: auto; }
.notepaper figcaption { padding-top: 0.25rem; font-size: 0.78rem; line-height: 1.3; color: #3d3d3d; font-style: italic; }
.notepaper figcaption:empty { display: none; }
.notepaper figure.sel, .notepaper table.sel { outline: 2px solid #4a7fc1; outline-offset: 2px; }
@media (max-width: 48rem) {
  .notes { border-right: 0; }
  .notes .notes-rail { position: static; flex: none; }
  .notes-scroll { padding: 0.6rem 0.4rem 2rem; }
  .notepaper { padding: 0.9rem 1rem 3rem; }
}
/* Toolbar labels: the heading buttons show their own weight and size,
   italic is a slanted serif letter; pressed buttons follow the caret. */
.notes-bar .tp { font-family: Georgia, "Times New Roman", serif; font-size: 0.98rem; }
.notes-bar .th1, .notes-bar .th2, .notes-bar .th3 { font-weight: 700; letter-spacing: -0.01em; }
.notes-bar .th1 { font-size: 0.86rem; }
.notes-bar .th2 { font-size: 0.76rem; }
.notes-bar .th3 { font-size: 0.66rem; }
.notes-bar .tb { font-weight: 800; font-size: 0.95rem; }
.notes-bar .ti { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 1.02rem; }
.notes-bar button.on { background: #dcdcd5; color: var(--ink); box-shadow: inset 0 0 0 1px #c4c4bc; }
.notes-bar button.armed { background: #f6e3e0; color: var(--red); box-shadow: inset 0 0 0 1px #e2b5ae; }
.notes-bar button:disabled { opacity: 0.35; background: transparent; }
.notes-tabletools { flex-basis: 100%; display: flex; align-items: center; gap: 0.1rem; padding-top: 0.25rem; border-top: 1px dashed #e0e0da; }
.viewtabs button { display: inline-flex; align-items: center; justify-content: center; padding: 0.2rem 0.6rem; }
.viewtabs button svg { width: 1.05rem; height: 1.05rem; }
.rail-list a.item.paper .newchat.note.noted svg { width: 0.95rem; height: 0.95rem; }
.notepaper p[data-indent="1"] { padding-left: 2rem; }
.notepaper p[data-indent="2"] { padding-left: 4rem; }
.notepaper p[data-indent="3"] { padding-left: 6rem; }
.notepaper li > ul, .notepaper li > ol { margin: 0; }
.notepaper ul ul { list-style-type: circle; }
.notepaper ul ul ul { list-style-type: square; }
.notepaper ol ol { list-style-type: lower-alpha; }
.notepaper ol ol ol { list-style-type: lower-roman; }
.notes-tabletools button:disabled { opacity: 0.3; }
/* The notepad's head lines up with the panel's head: same padding,
   buttons no taller than the panel's icon buttons. */
.viewbar .notes-bg button, .viewbar button.icon { height: 1.65rem; min-width: 1.65rem; padding: 0 0.2rem; }
.viewbar .notes-bg button svg, .viewbar button.icon svg { width: 1.1rem; height: 1.1rem; }
.viewbar button.icon { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 5px; background: transparent; color: #3d3d3d; }
.viewbar button.icon:hover { background: #ecece6; color: var(--ink); }
.viewtabs button { height: 1.55rem; }
.notes-export { position: relative; display: inline-flex; }
.exportmenu { position: absolute; top: calc(100% + 0.35rem); right: 0; z-index: 30; display: flex; flex-direction: column; min-width: 11rem; padding: 0.3rem; background: #fff; border: 1px solid #cfcfc8; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.exportmenu button { border: 0; background: transparent; text-align: left; padding: 0.38rem 0.6rem; border-radius: 5px; font-size: 0.84rem; }
.exportmenu button:hover { background: #f1f1ec; }
.report .head { min-height: 2.85rem; }
.viewbar { height: 2.85rem; flex: none; }
.notes-bar { padding: 0.3rem 0.7rem; }
.notes-bar button { min-width: 1.6rem; padding: 0 0.2rem; }
.notes-bar .sep { margin: 0 0.15rem; }
/* The notepad's toolbar row lines up with the PDF viewer's bar
   (pdfview.html .bar, 2.35rem); the table row adds below it. The head
   never wraps: the paper title gives way. */
.notes-bar { min-height: 2.35rem; padding: 0 0.7rem; align-content: center; }
.notes-bar button { height: 1.7rem; }
.notes-tabletools { padding: 0.2rem 0; }
.viewbar .notes-bg { flex-wrap: nowrap; flex: none; }
.viewbar .viewtabs, .viewbar .notes-export, .viewbar .notes-state { flex: none; }
/* A narrow column: the tools scroll sideways instead of a second line. */
.notes-tools { flex: 1 1 100%; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.notes-tools::-webkit-scrollbar { display: none; }
.notes-tools button, .notes-tools .sep { flex: none; }
/* AI corrector: a small button beside the selected text, then a window
   with the changes (removed struck through, added green). */
.notes-ai { position: fixed; z-index: 40; display: inline-flex; gap: 1px; padding: 2px; border: 1px solid #c9c9c2; border-radius: 9px; background: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14); }
.notes-ai button { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--ink); }
.notes-ai button:hover { background: #f1f1ec; }
.notes-ai svg { width: 1.15rem; height: 1.15rem; }
.proofstate { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0 0.2rem; font-size: 0.92rem; }
.proofnote { margin: 0.5rem 0 0; font-size: 0.84rem; }
dialog.notes-proof { width: min(40rem, 94vw); }
.proofdiff { max-height: 55vh; overflow: auto; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap; }
.proofdiff del { color: var(--red); background: #f8e6e3; text-decoration: line-through; }
.proofdiff ins { color: var(--green); background: #e3f3e6; text-decoration: none; font-weight: 600; }
.notes-ai.demo button { color: #b4b4ae; }
.notes-ai.demo button:hover { background: transparent; color: #8a8a84; }
