/* Chat: calm, readable, light and dark. No external fonts or libraries. */
:root {
  --bg: #faf9f6; --side: #f2f0ea; --card: #ffffff; --ink: #2b2a27; --ink-2: #4a4843; --muted: #7a766e;
  --line: #e5e2d9; --line-2: #eeebe4; --bubble: #efece4; --accent: #b4552d; --accent-ink: #fff;
  --accent-soft: #f6e7df; --ok: #2f7d4e; --warn: #9a6400; --warn-soft: #fbf1db; --bad: #a63a2b; --bad-soft: #fbe9e6;
  --link: #2f5f9e; --cell: #eef3fb; --cell-line: #d6e1f2; --cell-ink: #244f8c;
  --shadow: 0 1px 2px rgba(40, 35, 25, .05), 0 6px 24px rgba(40, 35, 25, .06);
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --side: #1f1e1d; --card: #30302e; --ink: #ecebe6; --ink-2: #cfcdc6; --muted: #9c988f;
    --line: #3d3c39; --line-2: #34332f; --bubble: #3a3936; --accent: #d9774e; --accent-ink: #1f1e1d;
    --accent-soft: #4a3329; --ok: #6cc08b; --warn: #e3b25c; --warn-soft: #43381f; --bad: #f08b7a; --bad-soft: #4a2c27;
    --link: #8ab4f0; --cell: #2d3644; --cell-line: #405069; --cell-ink: #a9c6f2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body.chat-page { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .88em; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
[hidden] { display: none !important; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------------- sidebar */
.sidebar { width: 272px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px 16px; }
.brand { color: var(--ink); font: 600 15px/1 var(--sans); display: inline-flex; align-items: center; gap: 9px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: inline-block; position: relative; }
.mark::after { content: ''; position: absolute; inset: 5px; border: 1.6px solid var(--accent-ink); border-radius: 50%; opacity: .9; }
.sidebar .sb-close { display: none; }
.new-task { margin: 6px 12px 10px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; color: var(--ink);
  font-weight: 550; background: var(--card); border: 1px solid var(--line); box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.new-task:hover { text-decoration: none; border-color: var(--muted); }
.new-task svg { color: var(--accent); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; min-height: 0; }
.conv-group { font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 14px 10px 4px; letter-spacing: .02em; }
.conv { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-size: 14px; }
.conv:hover { background: color-mix(in srgb, var(--line) 55%, transparent); text-decoration: none; }
.conv.on { background: var(--line); color: var(--ink); }
.conv .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.conv .dot.working { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.conv .dot.waiting { background: var(--warn); }
.conv .dot.failed { background: var(--bad); }
.conv .tag { font-size: 11px; color: var(--warn); font-weight: 600; flex: none; }
.conv-empty { color: var(--muted); font-size: 13px; padding: 10px; }
.sb-foot { border-top: 1px solid var(--line); padding: 10px 14px 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.sb-foot a { color: var(--muted); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }

/* ---------------- main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.public-banner { background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 600; text-align: center; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.public-banner.demo { background: var(--accent-soft); color: var(--accent); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; min-height: 52px; }
.topbar #sb-open { display: none; }
.conv-title { flex: 1; min-width: 0; margin: 0; font: 500 15px/1.3 var(--sans); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-link { font-size: 13px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); white-space: nowrap; }
.review-link:hover { text-decoration: none; background: var(--card); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: color-mix(in srgb, var(--line) 70%, transparent); color: var(--ink); }

.scroller { flex: 1; overflow-y: auto; min-height: 0; }
.thread { max-width: 760px; margin: 0 auto; padding: 8px 24px 28px; display: flex; flex-direction: column; gap: 18px; }

/* welcome */
.welcome { max-width: 760px; margin: 0 auto; padding: 14vh 24px 10px; text-align: center; }
.welcome h2 { font: 400 32px/1.25 var(--serif); margin: 0 0 8px; letter-spacing: -.01em; }
.welcome p { color: var(--muted); margin: 0 0 22px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggestion { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.suggestion:hover { border-color: var(--muted); color: var(--ink); }
.app.empty .scroller { display: flex; flex-direction: column; justify-content: flex-end; }
.app.empty .welcome { padding: 0 24px 6px; }
.app.empty .composer-wrap { margin-bottom: max(18vh, 24px); }
.app.empty .thread { display: none; }

/* ---------------- messages */
.msg-user { align-self: flex-end; max-width: min(85%, 620px); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.bubble { background: var(--bubble); border-radius: 18px; padding: 10px 16px; color: var(--ink); overflow-wrap: anywhere; }
.bubble p { margin: 0; } .bubble p + p { margin-top: 8px; }
.bubble.uploading { opacity: .75; }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; width: 160px; margin-top: 4px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 10px 6px 8px; font-size: 13px; max-width: 280px; }
.file .ic { width: 26px; height: 30px; border-radius: 5px; display: grid; place-items: center; font: 700 9px/1 var(--sans); color: #fff; flex: none; letter-spacing: .02em; }
.file .ic.xl { background: #2f7d4e; } .file .ic.doc { background: #3a68b0; } .file .ic.pdf { background: #b8432f; } .file .ic.img { background: #7b5ea7; }
.file .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .sz { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 0 0 2px; }

.msg-ai { display: flex; gap: 12px; align-items: flex-start; }
.msg-ai > .av { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); flex: none; margin-top: 2px; position: relative; }
.msg-ai > .av::after { content: ''; position: absolute; inset: 6.5px; border: 1.6px solid var(--accent-ink); border-radius: 50%; }
.msg-ai > .av.ghost { background: transparent; }
.msg-ai > .av.ghost::after { display: none; }
.msg-ai > .body { flex: 1; min-width: 0; }
.prose { font: 16.5px/1.65 var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.prose p { margin: 0 0 12px; } .prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 4px 0 12px; padding-left: 22px; } .prose li { margin: 3px 0; }
.prose h4 { font: 600 15px/1.4 var(--sans); margin: 16px 0 6px; }
.prose code { font-size: .8em; }
.tbl-wrap { overflow-x: auto; margin: 6px 0 12px; }
table.md, table.nums { border-collapse: collapse; font: 13.5px/1.4 var(--sans); width: 100%; }
table.md th, table.md td, table.nums th, table.nums td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; text-align: left; vertical-align: top; }
table.md th, table.nums th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.nums td.n, table.nums th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
table.nums td.mv-neg { color: var(--bad); } table.nums td.mv-pos { color: var(--ok); }

a.cell-link { display: inline; background: var(--cell); border: 1px solid var(--cell-line); color: var(--cell-ink); border-radius: 5px; padding: 0 5px;
  font: 500 .82em/1.5 var(--mono); white-space: nowrap; cursor: pointer; }
a.cell-link:hover { text-decoration: none; filter: brightness(.97); border-color: var(--cell-ink); }
.cells { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* route line */
.route { font-size: 14px; color: var(--ink-2); }
.route .lead { color: var(--muted); }
.route strong { color: var(--ink); font-weight: 600; }
.route .roles { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; color: var(--muted); font-size: 13px; }
.route .roles b { color: var(--ink-2); font-weight: 550; }
.route .why { color: var(--muted); font-size: 13px; margin-top: 3px; }
.linkbtn { border: 0; background: none; color: var(--link); cursor: pointer; padding: 0; font-size: 13px; }
.linkbtn:hover { text-decoration: underline; }
.route.superseded { opacity: .6; }
.route-edit { margin-top: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; font-size: 13.5px; }
.route-edit .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.route-edit .row > span:first-child { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
select, .field { font: inherit; font-size: 13.5px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

/* activity (collapsible status lines) */
details.activity { font-size: 13.5px; color: var(--muted); }
details.activity > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 6px; margin-left: -6px; border-radius: 8px; max-width: 100%; }
details.activity > summary::-webkit-details-marker { display: none; }
details.activity > summary:hover { background: color-mix(in srgb, var(--line) 50%, transparent); color: var(--ink-2); }
details.activity > summary .ttl { color: var(--ink-2); font-weight: 550; white-space: nowrap; }
details.activity > summary .cur { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.activity > summary .chev { transition: transform .15s; flex: none; }
details.activity[open] > summary .chev { transform: rotate(90deg); }
.steps { list-style: none; margin: 6px 0 2px 4px; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 5px; }
.steps li { display: flex; gap: 8px; align-items: baseline; color: var(--ink-2); line-height: 1.45; }
.steps li .i { flex: none; width: 14px; text-align: center; color: var(--muted); font-size: 12px; }
.steps li.ok .i { color: var(--ok); } .steps li.failed .i, .steps li.error .i { color: var(--bad); }
.steps li.flag { color: var(--warn); } .steps li.flag .i { color: var(--warn); }
.steps li.muted { color: var(--muted); }
.steps li .d { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.steps li .tx { min-width: 0; overflow-wrap: anywhere; }
.steps li .tx p { display: inline; margin: 0; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; display: inline-block; }
.check { color: var(--ok); flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }

/* question round */
.qcard { border: 1px solid var(--line); background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.qcard > header { padding: 14px 18px 8px; }
.qcard > header h3 { margin: 0 0 2px; font: 500 17px/1.35 var(--serif); }
.qcard > header p { margin: 0; color: var(--muted); font-size: 13px; }
.q { padding: 12px 18px 14px; border-top: 1px solid var(--line-2); }
.q .qt { font-weight: 550; color: var(--ink); display: flex; gap: 8px; }
.q .qt .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; flex: none; }
.q .meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 13px; color: var(--ink-2); margin: 6px 0 8px 20px; }
.q .meta dt { color: var(--muted); }
.q .meta dd { margin: 0; overflow-wrap: anywhere; }
.q textarea { width: calc(100% - 20px); margin-left: 20px; font: inherit; font-size: 14.5px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; resize: vertical; min-height: 40px; }
.q textarea:focus, .composer textarea:focus, select:focus, .field:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.q .qa { margin-left: 20px; margin-top: 6px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.badge { display: inline-block; font: 600 11px/1.6 var(--sans); padding: 0 7px; border-radius: 999px; background: var(--line-2); color: var(--muted); vertical-align: 1px; }
.badge.blocking { background: var(--bad-soft); color: var(--bad); }
.badge.def { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.qcard > footer { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line-2); background: color-mix(in srgb, var(--bg) 60%, var(--card)); flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 550; }
.btn.primary:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: default; }
.qdone .q { padding: 9px 18px; }
.qdone .ans { margin: 4px 0 0 20px; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }

/* answer */
.answer .why { margin-top: 12px; font-size: 13.5px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 12px; }
.answer .why p { margin: 0; }
.answer .why b { color: var(--ink-2); font-weight: 600; }
.answer h5 { font: 600 12px/1.3 var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }
.callout { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-top: 14px; }
.callout.flag { background: var(--warn-soft); color: var(--ink); }
.callout.flag b { color: var(--warn); }
.callout p { margin: 2px 0 0; }
.items { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; font-size: 14px; background: var(--card); }
.item .h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.item .h b { font-weight: 600; }
.item .amt { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
.item .dt { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.item .dt p { margin: 0 0 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.dcard { display: flex; gap: 11px; align-items: center; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 13px; color: var(--ink); min-width: 0; }
.dcard:hover { text-decoration: none; border-color: var(--muted); box-shadow: var(--shadow); }
.dcard .ic { width: 34px; height: 40px; border-radius: 6px; display: grid; place-items: center; font: 700 10px/1 var(--sans); color: #fff; flex: none; }
.dcard .ic.xl { background: #2f7d4e; } .dcard .ic.pdf { background: #b8432f; } .dcard .ic.doc { background: #3a68b0; } .dcard .ic.oth { background: #6d6a63; }
.dcard .l { min-width: 0; } .dcard .l b { display: block; font-weight: 600; font-size: 14px; }
.dcard .l span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dcard.off { opacity: .55; pointer-events: none; }
.answer .foot { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.answer .foot a.btn { font-size: 13.5px; padding: 6px 12px; color: var(--ink); }
.answer .foot a.btn:hover { text-decoration: none; }
.others { font-size: 13px; color: var(--muted); margin-top: 8px; }
.others a { margin-right: 10px; overflow-wrap: anywhere; }
details.others summary { cursor: pointer; width: max-content; }
details.others[open] summary { margin-bottom: 4px; }
.finalizing { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.answer.failed .prose { color: var(--bad); }

.note { font-size: 13.5px; border-radius: 10px; padding: 8px 12px; background: var(--line-2); color: var(--ink-2); }
.note p { margin: 0; }
.note.error { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--ink-2); }

/* ---------------- composer */
.composer-wrap { padding: 0 24px 14px; }
.composer { max-width: 760px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--muted) 60%, var(--line)); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; color: var(--ink); font: 15.5px/1.5 var(--sans); padding: 4px 2px; max-height: 40vh; min-height: 28px; }
.composer textarea::placeholder { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:not(:empty) { margin-bottom: 8px; }
.toolbar { display: flex; align-items: center; gap: 2px; margin-top: 2px; }
.toolbar .grow { flex: 1; }
.send { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.send:disabled { background: var(--line); color: var(--muted); cursor: default; }
.opts { position: relative; }
.popover { position: absolute; bottom: 42px; left: 0; width: 280px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; z-index: 5; display: grid; gap: 10px; }
.popover label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.popover input { font: inherit; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.popover p { margin: 0; }
.opt-badge { font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 9px; margin-left: 4px; }
.composer-hint { max-width: 760px; margin: 7px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); }
.drop { position: absolute; inset: 0; z-index: 15; background: color-mix(in srgb, var(--bg) 82%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop > div { border: 2px dashed var(--accent); color: var(--accent); border-radius: 18px; padding: 40px 56px; font: 500 18px/1.3 var(--serif); background: var(--card); }

/* ---------------- cell panel (shared with app.js) */
.cell-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--card); color: var(--ink); border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0, 0, 0, .12); padding: 14px 18px; overflow: auto; z-index: 30; font-size: 14px; }
.cell-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.cell-panel-head strong { font: 600 14px/1.4 var(--mono); overflow-wrap: anywhere; }
.cell-panel-head .icon-btn { font-size: 22px; }
.cell-panel .muted.small { color: var(--muted); }
.cell-panel .err { color: var(--bad); white-space: pre-wrap; font-size: 12.5px; }
.cell-facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13.5px; margin: 8px 0 14px; }
.cell-facts dt { color: var(--muted); } .cell-facts dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.grid-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.cellgrid { border-collapse: collapse; font: 12px/1.4 var(--sans); font-variant-numeric: tabular-nums; }
table.cellgrid th { background: var(--line-2); color: var(--muted); font-weight: 500; padding: 3px 7px; border: 1px solid var(--line); }
table.cellgrid td { border: 1px solid var(--line); padding: 3px 7px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
table.cellgrid td.f { color: var(--cell-ink); }
table.cellgrid td.num { text-align: right; }
table.cellgrid td.target { background: color-mix(in srgb, #f2c94c 35%, transparent); outline: 2px solid #d9a400; outline-offset: -2px; }

/* ---------------- narrow screens */
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 25; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); width: min(300px, 86vw); }
  .app.sb-open .sidebar { transform: none; }
  .sidebar .sb-close { display: inline-grid; }
  .topbar #sb-open { display: inline-grid; }
  .topbar { padding: 8px 10px; }
  .thread { padding: 4px 16px 24px; }
  .composer-wrap { padding: 0 10px 10px; }
  .welcome { padding: 6vh 18px 10px; }
  .welcome h2 { font-size: 26px; }
  .msg-ai { gap: 9px; }
  .msg-ai > .av { width: 20px; height: 20px; }
  .msg-ai > .av::after { inset: 5px; }
  .q textarea, .q .meta, .q .qa, .qdone .ans { margin-left: 0; width: 100%; }
  .q .meta { grid-template-columns: 1fr; }
  .q .meta dt { margin-top: 4px; }
  .prose { font-size: 16px; }
  .composer-hint { display: none; }
  .popover { width: min(280px, calc(100vw - 40px)); }
}
