    /* ─── Design tokens (from PaperKB — keep in sync) ───────────── */
    :root {
      --bg:           #ffffff;
      --bg-elevated:  #ffffff;
      --bg-subtle:    #f5f4f1;
      --bg-warm:      #efeee9;
      --fg:           #1a1a2e;
      --fg-muted:     #555770;
      --fg-faint:     #8e8fa3;
      --accent:       #1b2d4f;
      --accent-hover: #2d4a7a;
      --accent-soft:  #e4ecf5;
      --rule:         #ddd9d0;
      --rule-subtle:  #eae7e1;
      --danger:       #9b2226;
      --danger-soft:  #fce4e4;
      --success:      #2d6a4f;
      --success-soft: #d8f3dc;
      --radius:       6px;
      --radius-lg:    10px;
      --shadow-sm:    0 1px 2px rgba(27,45,79,.06);
      --shadow-md:    0 2px 8px rgba(27,45,79,.08), 0 1px 2px rgba(27,45,79,.04);
    }
    *, *::before, *::after { box-sizing: border-box; }
    html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
    body { font-family: 'Source Sans 3', sans-serif; margin: 0; background: var(--bg); color: var(--fg); font-size: 17px; line-height: 1.55; display: flex; flex-direction: column; height: 100vh; }
    a { color: var(--accent-hover); text-decoration: none; transition: color .15s; }
    a:hover { color: var(--accent); }
    .muted { color: var(--fg-muted); font-size: .9rem; }
    .badge { display: inline-block; padding: .15rem .5rem; border-radius: 3px; font-family: 'Source Code Pro', monospace; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--accent-hover); background: var(--accent-soft); line-height: 1.5; }
    .badge.gene      { background: #d1fae5; color: #065f46; }
    .badge.variant   { background: #fef9c3; color: #854d0e; }
    .badge.phenotype { background: #cffafe; color: #0e7490; }
    .badge.cohort    { background: #ede9fe; color: #4c1d95; }
    .badge.preprint  { background: #ffedd5; color: #7c2d12; }

    /* ─── TOP BAR (pixel-matched to PaperKB base.html) ─────────── */
    .topbar {
      display: flex; align-items: center;
      padding: .65rem clamp(1rem, 4vw, 2.5rem); gap: .75rem;
      background: var(--accent);
      flex-shrink: 0; position: sticky; top: 0; z-index: 100;
      min-height: 34px;
    }
    .topbar-brand { display: block; flex-shrink: 0; text-decoration: none; line-height: 0; transition: opacity 120ms ease; }
    .topbar-brand:hover { opacity: .8; }
    .topbar-crumb { display: flex; align-items: baseline; gap: .3rem; flex-shrink: 0; padding-left: .85rem; border-left: 1px solid rgba(255,255,255,.12); font-size: .95rem; font-weight: 500; }
    .topbar-crumb a { color: rgba(255,255,255,.6); text-decoration: none; transition: color 120ms ease; }
    .topbar-crumb a:hover { color: #fff; }
    .topbar-crumb a:last-child { color: rgba(255,255,255,.9); font-weight: 600; }
    .topbar-crumb a:last-child:hover { color: #fff; }
    .topbar-crumb-sep { color: rgba(255,255,255,.25); }
    .topbar-spacer { flex: 1; }

    .user-menu { position: relative; flex-shrink: 0; }
    .user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .4rem; height: 34px; padding: 0 .55rem 0 .3rem; border-radius: 20px; border: 1px solid rgba(255,255,255,.15); background: transparent; transition: background 120ms ease, border-color 120ms ease; user-select: none; }
    .user-menu summary::-webkit-details-marker { display: none; }
    .user-menu summary:hover, .user-menu[open] summary { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.24); }
    .user-avatar { width: 24px; height: 24px; border-radius: 50%; background: #c4956a; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: #fff; text-transform: uppercase; flex-shrink: 0; }
    .user-menu-label { font-size: .88rem; font-weight: 500; color: rgba(255,255,255,.8); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-caret { font-size: .55rem; color: rgba(255,255,255,.4); margin-left: .1rem; transition: transform .2s; }
    .user-menu[open] .user-caret { transform: rotate(180deg); }
    .user-dropdown { position: absolute; right: 0; top: calc(100% + 5px); background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 192px; z-index: 200; padding: .3rem 0; list-style: none; margin: 0; animation: ud-appear .13s ease-out; }
    @keyframes ud-appear { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
    .ud-name { padding: .55rem .85rem .38rem; font-size: .93rem; font-weight: 600; color: var(--fg); }
    .ud-sep { border: none; border-top: 1px solid var(--rule-subtle); margin: .28rem 0; }
    .user-dropdown a { display: block; padding: .36rem .85rem; font-size: .9rem; color: var(--fg); text-decoration: none; transition: background 120ms ease; }
    .user-dropdown a:hover { background: var(--bg-subtle); color: var(--accent); }
    .user-dropdown a.ud-danger { color: var(--danger); }
    .user-dropdown a.ud-danger:hover { background: var(--danger-soft); }
    .topbar-signin { font-size: .88rem; font-weight: 500; color: rgba(255,255,255,.72); text-decoration: none; height: 32px; display: inline-flex; align-items: center; padding: 0 .75rem; border-radius: 20px; border: 1px solid rgba(255,255,255,.18); transition: background 120ms ease, color 120ms ease; flex-shrink: 0; white-space: nowrap; }
    .topbar-signin:hover { background: rgba(255,255,255,.1); color: #fff; }
    .help-menu { position: relative; flex-shrink: 0; }
    .help-menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; padding: .25rem .6rem; color: rgba(255,255,255,.7); font-size: .85rem; font-weight: 500; flex-shrink: 0; transition: color 120ms ease; user-select: none; }
    .help-menu summary::-webkit-details-marker { display: none; }
    .help-menu summary:hover, .help-menu[open] summary { color: #fff; }
    .help-menu .help-caret { font-size: .55rem; color: rgba(255,255,255,.4); margin-left: .3rem; transition: transform .2s; }
    .help-menu[open] .help-caret { transform: rotate(180deg); }
    .help-dropdown { position: absolute; right: 0; top: calc(100% + 5px); background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 160px; z-index: 200; padding: .3rem 0; list-style: none; margin: 0; animation: ud-appear .13s ease-out; }
    .help-dropdown a { display: block; padding: .36rem .85rem; font-size: .9rem; color: var(--fg); text-decoration: none; transition: background 120ms ease; }
    .help-dropdown a:hover { background: var(--bg-subtle); color: var(--accent); }

    .subnav { background: var(--bg-subtle); border-bottom: 1px solid var(--rule); padding: 0 clamp(1rem, 4vw, 2.5rem); display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
    .subnav::-webkit-scrollbar { display: none; }
    .subnav a { display: inline-flex; align-items: center; padding: .6rem 1.1rem; font-size: .88rem; font-weight: 500; color: var(--fg-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color 120ms ease, border-color 120ms ease; }
    .subnav a:hover { color: var(--accent); }

    /* ── Back link with paper title ── */
    .nav-back-wrap {
      display: flex; align-items: center; gap: .35rem;
      min-width: 0; /* allow truncation */
    }
    .nav-back-wrap a { flex-shrink: 0; }
    .paper-subtitle {
      font-size: .93rem; font-weight: 400; color: var(--fg-muted);
      font-style: italic;
      max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      min-width: 0;
    }

    /* ── Subnav chat controls ── */
    .subnav-controls {
      margin-left: auto; display: flex; align-items: center;
      gap: .35rem; padding: .3rem 0;
    }
    .subnav-select {
      height: 28px; padding: 0 1.6rem 0 .55rem;
      font-size: .85rem; font-family: inherit; font-weight: 500;
      background: var(--bg-elevated) 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' stroke='%23555770' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right .45rem center;
      border: 1px solid var(--rule); border-radius: var(--radius);
      color: var(--fg); cursor: pointer; outline: none;
      -webkit-appearance: none; appearance: none;
      transition: border-color .15s, background .15s;
    }
    .subnav-select:hover { border-color: var(--accent); }
    .subnav-select:focus { border-color: var(--accent); background-color: var(--bg-elevated); }
    .subnav-btn {
      height: 28px; padding: 0 .65rem;
      font-size: .85rem; font-family: inherit; font-weight: 500;
      background: transparent; border: 1px solid var(--rule); border-radius: var(--radius);
      color: var(--fg-muted); cursor: pointer; white-space: nowrap; line-height: 1;
      transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
    }
    .subnav-btn:hover { background: var(--bg-subtle); color: var(--accent); border-color: var(--accent); }
    .subnav-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
    .subnav-btn.new-chat {
      background: var(--accent); color: #fff;
      border-color: var(--accent); font-weight: 600;
    }
    .subnav-btn.new-chat:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
    #model-select {
      font: inherit; font-size: .82rem; padding: .22rem .4rem;
      border: 1px solid var(--rule); border-radius: var(--radius);
      background: var(--bg-elevated); color: var(--fg-muted);
      cursor: pointer; max-width: 10rem;
    }
    #model-select:hover { border-color: var(--accent); color: var(--fg); }
    #filter-controls { display: none; align-items: center; }

    /* ── Messages scroll area ── */
    #messages {
      flex: 1; overflow-y: auto; padding: 1.5rem 1.5rem 1rem;
      display: flex; flex-direction: column; gap: 1rem;
    }
    #messages::-webkit-scrollbar { width: 6px; }
    #messages::-webkit-scrollbar-track { background: transparent; }
    #messages::-webkit-scrollbar-thumb { background: #c4d0dc; border-radius: 3px; }

    .msg-row { display: flex; flex-direction: column; max-width: 860px; width: 100%; animation: msgIn .18s ease; }
    .msg-row.user { align-self: flex-end; align-items: flex-end; }
    .msg-row.assistant { align-self: flex-start; max-width: min(1200px, 100%); }
    .msg-row.assistant .bubble { max-width: 860px; }
    .msg-row.error { align-self: flex-start; }

    @keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

    .role-label {
      font-size: .68rem; color: var(--fg-muted); margin-bottom: .3rem;
      padding: 0 .3rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    }

    /* ── Message bubbles ── */
    .bubble { padding: .8rem 1.1rem; border-radius: 2px; line-height: 1.65; font-size: .95rem; box-shadow: none; }
    .user      .bubble { background: #dbeafe; border: 1px solid #bcd4f8; border-bottom-right-radius: 4px; }
    .assistant .bubble { background: var(--bg-elevated); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
    .error     .bubble { background: var(--danger-soft); border: 1px solid #f0b4b4; color: var(--danger); font-size: .93rem; border-radius: 2px; }
    .info      .bubble { background: #fefce8; border: 1px solid #fde68a; color: #92400e; font-size: .9rem; border-radius: 2px; }
    .system    .bubble { background: var(--bg-subtle); border: 1px solid var(--rule); font-size: .93rem; border-radius: 2px; }

    /* markdown inside bubble */
    .bubble p { margin: 0 0 .6em; }
    .bubble p:last-child { margin-bottom: 0; }
    .bubble h1,.bubble h2,.bubble h3 { color: var(--accent); margin: .9em 0 .35em; }
    .bubble ul,.bubble ol { margin: .3em 0 .3em 1.2em; padding: 0; }
    .bubble li { margin-bottom: .2em; }
    .bubble pre {
      background: var(--bg-subtle); padding: .75rem 1rem; border-radius: 2px;
      white-space: pre-wrap; font-size: .82rem; line-height: 1.55;
      overflow-x: auto; margin: .5em 0; border: 1px solid var(--rule);
    }
    .bubble code { font-family: 'Source Code Pro', monospace; font-size: .85em; }
    .bubble p code { background: #e8f0fe; padding: 2px 6px; border-radius: 0; color: #1e40af; }
    .bubble blockquote { border-left: 3px solid #93c5fd; margin: .4em 0; padding: .25em .8rem; color: #475569; background: #f0f7ff; border-radius: 0 6px 6px 0; }
    .bubble a { color: var(--accent); }
    .bubble img { max-width: 100%; height: auto; border-radius: 2px; margin: .5em 0; }
    .bubble table { display: block; overflow-x: auto; max-width: 100%; border-collapse: collapse; font-size: .85rem; margin: .5em 0; box-shadow: none; border-radius: 0; }
    .bubble th { background: var(--bg-subtle); padding: .4rem .65rem; border-bottom: 1px solid var(--rule); text-align: left; font-weight: 600; }
    .bubble td { padding: .35rem .65rem; border-bottom: 1px solid var(--rule-subtle); }

    /* ── Tool call disclosure ── */
    details.tool-call {
      background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: 0;
      font-size: .85rem; max-width: 860px; width: 100%; align-self: flex-start;
      box-shadow: none; animation: msgIn .18s ease;
    }
    details.tool-call summary {
      padding: .55rem 1rem; cursor: pointer; user-select: none;
      color: var(--accent); font-weight: 600; list-style: none;
      display: flex; align-items: center; gap: .5rem;
      border-radius: 0; transition: background 120ms ease;
    }
    details.tool-call summary:hover { background: var(--bg-subtle); }
    details.tool-call summary::-webkit-details-marker { display: none; }
    details.tool-call summary::before { content: "▶"; font-size: .65rem; color: var(--fg-muted); transition: transform .15s; flex-shrink: 0; }
    details[open].tool-call summary::before { transform: rotate(90deg); }
    details[open].tool-call summary { border-radius: 0 10px 0 0; }
    details.tool-call .tool-body { padding: .8rem 1.1rem 1.1rem; border-top: 1px solid var(--bg); }

    /* RAG context card */
    details.tool-call.rag-context { border-color: #bfdbfe; background: #f8fbff; }
    details.tool-call.rag-context summary { color: var(--accent); }
    details.tool-call.rag-context summary:hover { background: #eff6ff; }

    /* ── Passage / fact tables inside tool results ── */
    .result-table { width: 100%; border-collapse: collapse; margin-top: .5rem; box-shadow: none; border-radius: 0; overflow: visible; }
    .result-table th { background: var(--bg-subtle); text-align: left; padding: .4rem .7rem; border-bottom: 1px solid var(--rule); font-size: .9rem; font-weight: 600; }
    .result-table td { padding: .35rem .7rem; border-bottom: 1px solid var(--rule-subtle); vertical-align: top; font-size: .93rem; }
    .result-table tr:hover td { background: var(--bg-subtle); }

    .badge.subject { background: #d1fae5; color: #065f46; }
    .badge.object  { background: #cffafe; color: #0e7490; }

    .score-track { height: 4px; width: 48px; background: #e2e8f0; border-radius: 2px; margin-top: 4px; }
    .score-fill  { height: 4px; background: var(--accent); border-radius: 2px; }

    h3.section-head { font-size: .9rem; color: var(--accent); margin: .9rem 0 .35rem; font-weight: 600; }
    h3.section-head:first-child { margin-top: 0; }

    /* ── Typing indicator ── */
    .typing-wrap { display: flex; align-items: center; gap: 5px; padding: .45rem 0 .25rem; }
    .typing-wrap .dot { width: 7px; height: 7px; background: var(--fg-faint); border-radius: 50%; animation: tdot 1.2s infinite; }
    .typing-wrap .dot:nth-child(2) { animation-delay: .2s; }
    .typing-wrap .dot:nth-child(3) { animation-delay: .4s; }
    @keyframes tdot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

    /* ── Debug panel ── */
    #debug-panel {
      border-top: 1px solid var(--rule); background: var(--bg-subtle);
      flex-shrink: 0; display: none; flex-direction: column; height: 220px;
    }
    .debug-panel-header {
      display: flex; justify-content: space-between; align-items: center;
      padding: .3rem .75rem; background: var(--accent); color: var(--fg-muted);
      font-size: .78rem; font-weight: 600; flex-shrink: 0;
    }
    .debug-panel-header button {
      font-size: .72rem; padding: .15rem .45rem; background: transparent;
      border: 1px solid var(--rule); border-radius: 0;
      cursor: pointer; color: var(--fg-muted); font-family: inherit;
    }
    .debug-panel-header button:hover { background: var(--bg-subtle); }
    #debug-entries { flex: 1; overflow-y: auto; padding: .4rem .6rem; }
    .debug-entry { margin-bottom: .35rem; }
    .debug-det { font-size: .78rem; }
    .debug-det > summary {
      cursor: pointer; padding: .2rem .4rem; border-radius: 0;
      list-style: none; display: flex; align-items: center; gap: .3rem; user-select: none;
    }
    .debug-det > summary::-webkit-details-marker { display: none; }
    .debug-det > summary::before { content: "▶"; font-size: .6rem; color: var(--fg-faint); display: inline-block; transition: transform .12s; }
    details[open].debug-det > summary::before { transform: rotate(90deg); }
    .debug-summary.req { background: #dbeafe; color: #1e3a8a; font-weight: 600; }
    .debug-summary.resp { background: #d1fae5; color: #065f46; margin-left: 1.2rem; }
    .debug-summary.resp-err { background: #fee2e2; color: #991b1b; margin-left: 1.2rem; }
    .debug-json {
      font-family: 'Source Code Pro', monospace; font-size: .72rem;
      background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: 0;
      padding: .4rem .5rem; margin: .2rem 0 .2rem 1.2rem;
      overflow-x: auto; white-space: pre-wrap; word-break: break-all;
      max-height: 300px; overflow-y: auto; line-height: 1.4;
    }

    /* ── Project picker ── */
    #project-picker {
      flex: 1; display: flex; flex-direction: column; align-items: center;
      justify-content: center; padding: 3rem 1.5rem; gap: 2rem;
    }
    #project-picker h2 { margin: 0; color: var(--accent); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
    #project-picker p { margin: 0; color: var(--fg-muted); font-size: .95rem; }
    .picker-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
      gap: 1rem; width: 100%; max-width: 800px;
    }
    .picker-card {
      background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: var(--radius-lg);
      padding: 1.35rem 1.5rem; cursor: pointer; text-decoration: none;
      color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s;
      display: flex; flex-direction: column; gap: .4rem; box-shadow: var(--shadow-sm);
    }
    .picker-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
    .picker-card .pc-name { font-weight: 600; color: var(--accent); font-size: .98rem; }
    .picker-card .pc-slug { font-size: .75rem; color: var(--fg-muted); font-family: 'Source Code Pro', monospace; }
    #picker-loading { color: var(--fg-muted); font-size: .9rem; }

    /* ── Input area ── */
    #input-area { border-top: 1px solid var(--rule); background: var(--bg-elevated); padding: .85rem 1.5rem 1rem; flex-shrink: 0; }
    #input-inner {
      display: flex; gap: 0; align-items: flex-end;
      background: var(--bg-subtle); border: 1.5px solid var(--rule); border-radius: var(--radius-lg);
      padding: .25rem .3rem .25rem .75rem;
      transition: border-color .15s, box-shadow .15s;
    }
    #input-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
    #input {
      flex: 1; padding: .35rem 0; font-size: .95rem;
      border: none; border-radius: 0; font-family: inherit;
      resize: none; min-height: 34px; max-height: 180px; line-height: 1.5;
      background: transparent; color: var(--fg); outline: none;
    }
    #input-status {
      font-size: .82rem; color: var(--fg-muted); white-space: nowrap;
      padding: 0 .5rem; align-self: center; flex-shrink: 0;
    }
    #send {
      padding: .4rem .9rem; font-size: .88rem;
      background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
      cursor: pointer; white-space: nowrap; font-family: inherit; font-weight: 500;
      transition: background 120ms ease; align-self: flex-end; margin-bottom: .1rem;
    }
    #send:hover { background: var(--accent-hover); }
    #send:disabled { opacity: .4; cursor: not-allowed; }
    #cancel {
      padding: .4rem .9rem; font-size: .88rem;
      background: var(--danger); color: #fff; border: none; border-radius: var(--radius);
      cursor: pointer; white-space: nowrap; font-family: inherit; font-weight: 500;
      transition: background 120ms ease; align-self: flex-end; margin-bottom: .1rem;
    }
    #cancel:hover { background: #7f1d1d; }

    /* ── Citation references inside assistant bubbles ── */
    .cite-ref {
      color: var(--accent); cursor: pointer; font-size: .72em; font-weight: 700;
      vertical-align: super; padding: 0 2px; text-decoration: none;
      background: #eff6ff; border-radius: 3px; border: 1px solid #bfdbfe;
      transition: background 120ms ease;
    }
    .cite-ref:hover { background: #dbeafe; }

    /* ── History sidebar ── */
    #history-sidebar {
      position: fixed; top: 52px; left: -320px; bottom: 0; width: 320px;
      background: var(--bg-elevated); border-right: 1px solid var(--rule);
      box-shadow: 4px 0 24px rgba(0,0,0,.1);
      z-index: 100; display: flex; flex-direction: column;
      transition: left .2s ease;
    }
    #history-sidebar.open { left: 0; }
    #history-backdrop {
      position: fixed; inset: 0; top: 52px; z-index: 99;
      background: rgba(0,0,0,.25); backdrop-filter: blur(1px);
      display: none;
    }
    #history-backdrop.open { display: block; }
    #history-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: .65rem 1rem; background: var(--bg-subtle); border-bottom: 1px solid var(--rule);
      flex-shrink: 0;
    }
    #history-close {
      background: none; border: none; font-size: 1.3rem; line-height: 1;
      cursor: pointer; color: var(--fg-muted); padding: 0 .2rem;
      border-radius: 0; transition: color .12s, background .12s;
    }
    #history-close:hover { color: var(--fg); background: var(--bg-subtle); }
    #history-list { overflow-y: auto; flex: 1; padding: .35rem; }
    .history-item {
      display: flex; align-items: flex-start; gap: .6rem;
      padding: .55rem .7rem; border-radius: 2px; cursor: pointer;
      transition: background 120ms ease; border: 1px solid transparent;
      position: relative;
    }
    .history-item:hover { background: var(--bg); border-color: var(--rule); }
    .history-item-body { flex: 1; min-width: 0; }
    .history-item-title { font-size: .88rem; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .history-item-project { font-size: .72rem; color: var(--fg-muted); margin-top: .12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .history-item-meta { font-size: .68rem; color: var(--fg-muted); margin-top: .08rem; }
    .history-item-delete {
      position: absolute; top: .4rem; right: .4rem;
      background: none; border: none; font-size: .72rem; color: var(--fg-muted);
      cursor: pointer; padding: .15rem .35rem; border-radius: 0;
      opacity: 0; transition: opacity .12s, color .12s, background .12s;
    }
    .history-item:hover .history-item-delete { opacity: 1; }
    .history-item-delete:hover { color: var(--danger); background: var(--danger-soft); }
    .history-empty { padding: 2rem 1rem; text-align: center; color: var(--fg-muted); font-size: .9rem; }
    .topbar-history-btn {
      background: none; border: 1px solid rgba(255,255,255,.18);
      color: rgba(255,255,255,.72); font-size: .85rem; font-weight: 500;
      height: 32px; padding: 0 .75rem; border-radius: 20px; cursor: pointer;
      font-family: inherit; transition: background .15s, color .15s, border-color .15s;
      display: none;
    }
    .topbar-history-btn:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.24); }

    /* ── Citation modal ── */
    #cite-modal {
      position: fixed; inset: 0; z-index: 1000;
      display: none; align-items: center; justify-content: center;
    }
    #cite-modal.open { display: flex; }
    #cite-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(2px); }
    #cite-modal-box {
      position: relative; z-index: 1; background: var(--bg-elevated); border-radius: var(--radius-lg);
      box-shadow: 0 12px 48px rgba(0,0,0,.2); width: min(560px, 92vw);
      max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
    }
    #cite-modal-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: .65rem 1.1rem; background: var(--bg-subtle); border-bottom: 1px solid var(--rule);
      flex-shrink: 0;
    }
    #cite-modal-header .modal-label { font-size: .88rem; font-weight: 700; color: var(--accent); }
    #cite-modal-close {
      background: none; border: none; font-size: 1.3rem; line-height: 1;
      cursor: pointer; color: var(--fg-muted); padding: 0 .2rem;
      border-radius: 0; transition: color .12s, background .12s;
    }
    #cite-modal-close:hover { color: var(--fg); background: var(--bg-subtle); }
    #cite-modal-content { overflow-y: auto; padding: 1rem 1.1rem; }
    .modal-entry { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--rule-subtle); }
    .modal-entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
    .modal-entry-num { font-size: .75rem; font-weight: 700; color: var(--accent); margin-bottom: .25rem; }
    .modal-entry-title { font-size: .95rem; font-weight: 600; color: var(--accent); line-height: 1.45; margin-bottom: .3rem; }
    .modal-entry-meta { font-size: .78rem; color: var(--fg-muted); margin-bottom: .5rem; }
    .modal-entry-section { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); margin-bottom: .25rem; }
    .modal-entry-text {
      font-size: .88rem; color: #475569; line-height: 1.65;
      background: #f8fbff; border-left: 3px solid #93c5fd;
      padding: .5rem .8rem; border-radius: 0 6px 6px 0;
      white-space: pre-wrap; max-height: 200px; overflow-y: auto; margin-bottom: .55rem;
    }
    .modal-entry-links { display: flex; gap: .75rem; }
    .modal-entry-links a { font-size: .85rem; color: var(--accent); text-decoration: none; }
    .modal-entry-links a:hover { text-decoration: underline; }

    /* ── References section at the bottom of assistant bubbles ── */
    .refs-section { margin-top: 1rem; padding-top: .7rem; border-top: 1px solid var(--rule); }
    .refs-section-heading {
      font-size: .68rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: .08em; color: var(--fg-faint); margin-bottom: .45rem;
    }
    .ref-item { display: flex; gap: .45rem; margin-bottom: .22rem; line-height: 1.5; font-size: .78rem; }
    .ref-item:last-child { margin-bottom: 0; }
    .ref-num { font-weight: 700; color: var(--accent); flex-shrink: 0; cursor: pointer; white-space: nowrap; }
    .ref-num:hover { text-decoration: underline; }
    .ref-text { color: var(--fg-muted); }

    /* ─── RESPONSIVE ──────────────────────────────────── */
    @media (max-width: 768px) {
      body { font-size: 16px; }
      .topbar { padding: .6rem .75rem; gap: .5rem; }
      .topbar-crumb { font-size: .9rem; padding-left: .6rem; }
      .topbar-crumb a { max-width: 7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
      .subnav { padding: 0 .75rem; }
      .subnav a { padding: .5rem .7rem; font-size: .85rem; }
      .subnav-controls { gap: .25rem; padding-left: .5rem; }
      #messages { padding: 1rem .75rem .75rem; }
      .msg-row, .msg-row.assistant .bubble { max-width: 100%; }
      #input-area { padding: .65rem .75rem .75rem; }
      .bubble { font-size: .93rem; padding: .65rem .85rem; }
      .bubble table { font-size: .82rem; }
      details.tool-call { font-size: .82rem; }
      .result-table th, .result-table td { padding: .3rem .5rem; }
      #cite-modal { width: calc(100vw - 1rem); right: .5rem; left: .5rem; max-height: 60vh; }
    }
    @media (max-width: 480px) {
      body { font-size: 15px; }
      .topbar-crumb { display: none; }
      .topbar-brand img, #brand-logo { height: 24px !important; }
      .subnav-select { max-width: 7rem; font-size: .82rem; }
      #messages { padding: .75rem .5rem .5rem; gap: .75rem; }
      #input-area { padding: .5rem .5rem .65rem; }
      .paper-subtitle { max-width: 120px; }
      .nav-back-wrap a { font-size: .88rem; }
      .picker-card { padding: .75rem; }
    }
