:root {
  color-scheme: light;
  --investigations-rail-width: 42px;
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1c2330; --muted: #667085; --line: #e1e5ec;
  --accent: #2459d6; --red: #c8342b; --amber: #b7791f; --green: #1f8a4c; --gray: #6b7280; --blue: #2459d6;
  --red-bg: #fdecea; --amber-bg: #fdf3dc; --green-bg: #e6f5ec; --gray-bg: #eceef2; --blue-bg: #e7eefc;
  --assertion-color: #7948a6;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #12151b; --panel: #1b2029; --ink: #e6e9ef; --muted: #9aa3b2; --line: #2b3240;
  --accent: #7aa2ff; --red: #ff7b72; --amber: #e3b341; --green: #56d364; --gray: #9aa3b2; --blue: #7aa2ff;
  --red-bg: #3a1c1c; --amber-bg: #3a2f14; --green-bg: #15301f; --gray-bg: #262c38; --blue-bg: #1c2740;
  --assertion-color: #c69aff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.mobile-only, .mobile-nav, .mobile-menu, .record-label { display: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:where(input:not([type=checkbox], [type=radio], [type=hidden]), textarea) {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
}
.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; padding: 16px 20px 0; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; padding-bottom: 8px; }
#theme-toggle { flex: none; white-space: nowrap; }
#theme-toggle[aria-pressed=true] { background: var(--blue-bg); color: var(--accent); border-color: var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { flex: none; border-radius: 8px; }
h1 { font-size: 18px; margin: 0; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.count { background: var(--gray-bg); color: var(--muted); border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
main { padding: 16px 20px 80px; max-width: 1400px; margin: 0 auto; }
.warn { background: var(--amber-bg); color: var(--amber); padding: 8px 20px; font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 220px; max-width: 360px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 4px 10px; cursor: pointer; font-size: 12px; color: var(--muted); }
.chip.on, .chip[aria-pressed=true] { background: var(--blue-bg); color: var(--accent); border-color: var(--accent); }

main:has(.issues-layout) { max-width: none; padding: 0; }
.issues-layout { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; }
.issues-board { container-type: inline-size; min-width: 0; width: 100%; max-width: 1400px; margin-inline: auto; padding: 16px 20px 80px; }
.issues-board .toolbar input[type=search] { min-width: 0; }
.issue-filter-options { display: flex; flex-wrap: wrap; gap: 8px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; align-items: start; }
@container (width < 996px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (width < 492px) { .board { grid-template-columns: 1fr; } }
.col { background: color-mix(in srgb, var(--panel) 60%, var(--bg)); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 80px; }
.col h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; display: flex; justify-content: space-between; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--gray); border-radius: 6px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card.s-active, .card.s-retriggered { border-left-color: var(--red); }
.card.s-recovering, .card.s-watching, .card.s-snoozed, .card.s-acknowledged { border-left-color: var(--amber); }
.card.s-recovered { border-left-color: var(--green); }
.card.s-closed, .card.s-accepted { border-left-color: var(--gray); opacity: .85; }
.card .t { font-weight: 600; margin-bottom: 3px; overflow-wrap: anywhere; }
.card .k { font: 11px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.card .m { color: var(--muted); font-size: 12px; margin-top: 5px; }
.card .sum { font-size: 12.5px; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 600; margin-right: 4px; background: var(--gray-bg); color: var(--gray); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.scan-status { display: inline-flex; align-items: center; gap: 5px; border-radius: 4px; padding: 2px 7px; background: var(--blue-bg); color: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; }
.scan-status[hidden] { display: none; }
.scan-status::before { content: ''; width: 8px; height: 8px; flex: 0 0 8px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) {
  .scan-status::before { animation: scan-spin .9s linear infinite; }
  @keyframes scan-spin { to { transform: rotate(360deg); } }
}
.empty { color: var(--muted); font-size: 12px; padding: 6px 2px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.18); overflow-y: auto; padding: 18px 20px 40px; z-index: 20; }
.drawer h2 { font-size: 16px; margin: 0 0 4px; overflow-wrap: anywhere; }
.drawer h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.drawer .close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.mono { font: 12px var(--mono); overflow-wrap: anywhere; color: var(--muted); }
.drawer ul { margin: 0; padding-left: 18px; }
.drawer li { margin-bottom: 4px; overflow-wrap: anywhere; }
.issue-drawer { width: min(620px, 100vw); padding: 22px clamp(16px, 4vw, 26px) 40px; }
.issue-detail { display: grid; gap: 14px; overflow-wrap: anywhere; }
.issue-detail-header { display: grid; gap: 8px; padding-right: 24px; }
.issue-detail-header h2 { margin: 0; font-size: clamp(20px, 4vw, 25px); line-height: 1.25; letter-spacing: -.015em; }
.issue-detail-badges, .issue-detail-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.issue-detail-badges .badge { margin: 0; }
.issue-detail-section, .issue-detail > .inv-section, .issue-detail > .adhoc-backlinks:not(:empty) { padding: 13px 15px; border: 1px solid var(--line); border-radius: 8px; margin: 0; }
.issue-detail > .adhoc-backlinks:empty { display: none; }
.issue-detail h3 { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 700; }
.issue-detail-section:has(.issue-detail-meta) { background: var(--bg); }
.issue-summary { margin: 0 0 10px; font-size: 15px; line-height: 1.55; }
.issue-detail-meta { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.issue-detail-toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.issue-detail-toolbar select { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); }
.issue-detail .actions .btn { font-size: 12px; }
.issue-more-actions summary { width: fit-content; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }
.issue-more-actions p { margin-bottom: 0; }
.issue-more-actions .issue-decision-note { margin-top: 9px; }
.issue-decision-note { display: grid; gap: 4px; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.issue-decision-note textarea { font-size: 13px; color: var(--ink); }
.issue-detail h4 { margin: 9px 0 2px; color: var(--ink); font-size: 13px; }
.issue-detail h4 + p { margin: 0; }
.tl { border-left: 2px solid var(--line); margin-left: 4px; padding-left: 12px; }
.tl .ev { margin-bottom: 10px; }
.tl .ev .ts { font-size: 11px; color: var(--muted); }
.tl .ev .tx { overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
textarea { width: 100%; min-height: 60px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }
.bulkbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }
.bulkbar select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.bulkbar .btn[disabled] { opacity: .45; cursor: not-allowed; }
td.sel, th.sel { width: 28px; }
.actionbox { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 4px; }
.actionbox details { margin: 8px 0; }
.actionbox pre { max-height: 320px; overflow: auto; }
.note.warnnote { background: var(--red-bg); }
table.kv th { text-align: left; white-space: nowrap; padding-right: 12px; vertical-align: top; font-weight: 600; }
.note { background: var(--blue-bg); border-radius: 6px; padding: 8px 10px; margin: 8px 0; overflow-wrap: anywhere; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: color-mix(in srgb, var(--panel) 70%, var(--bg)); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--blue-bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.key { font: 12px var(--mono); overflow-wrap: anywhere; max-width: 420px; }
.tblwrap { overflow-x: auto; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.ask-view { max-width: 850px; margin: 0 auto 32px; }
.ask-header, .ask-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ask-header { justify-content: space-between; margin-bottom: 14px; }
.ask-header :is(h1, h2) { margin: 0; font-size: 22px; }
main:has(> .ask-workspace) { padding-bottom: 24px; }
.ask-workspace { display: flex; flex-direction: column; max-width: 1200px; margin-inline: auto;
  height: max(490px, calc(100dvh - var(--issues-header-height, 100px) - 42px)); }
.ask-layout { display: grid; grid-template-columns: minmax(200px, 268px) minmax(0, 1fr);
  flex: 1; min-height: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.ask-sidebar { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0;
  padding: 12px; background: color-mix(in srgb, var(--panel) 45%, var(--bg)); border-inline-end: 1px solid var(--line); }
.ask-sidebar > .btn { align-self: stretch; }
.ask-sidebar > p { margin: 4px 2px; }
.ask-thread-list { display: flex; flex-direction: column; gap: 3px; overflow: auto; scrollbar-gutter: stable; padding: 2px; }
.ask-thread { display: grid; align-content: center; gap: 2px; flex: none; min-height: 42px; min-width: 0;
  text-align: start; padding: 7px 9px; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; }
.ask-thread:hover { background: var(--panel); border-color: var(--line); }
.ask-thread[aria-current=true] { background: var(--blue-bg); color: var(--accent); font-weight: 600; }
.ask-thread-name, .ask-thread-detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-thread-detail { color: var(--muted); font-size: 11px; font-weight: 500; }
.ask-history-toggle { display: none; }
.ask-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ask-chat-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--line); }
.ask-chat-header .ask-thread-title { flex: 1 1 240px; min-width: 0; margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.ask-chat-header .ask-case-link { max-width: min(100%, 340px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ask-case-label { overflow-wrap: anywhere; }
.ask-transcript { flex: 1; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 14px 18px; }
.ask-empty { margin: min(9dvh, 72px) auto 0; text-align: center; color: var(--muted); font-size: 17px; }
.ask-messages { display: grid; gap: 16px; max-width: 780px; margin-inline: auto; }
.ask-messages[hidden], .ask-composer[hidden] { display: none; }
.ask-turn { min-width: 0; overflow-wrap: anywhere; padding: 4px 0; }
.ask-turn > h3 { font-size: 12px; margin: 0 0 6px; color: var(--muted); }
.ask-turn .md > :first-child { margin-top: 0; }
.ask-turn .md > :last-child { margin-bottom: 0; }
.ask-user { justify-self: end; max-width: 90%; background: var(--blue-bg); border-radius: 9px; padding: 9px 12px; }
.ask-question-text { white-space: pre-wrap; }
.ask-composer { padding: 10px 18px; border-top: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.ask-composer textarea { display: block; width: 100%; resize: vertical; min-height: 60px; max-height: 24dvh;
  margin-bottom: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.ask-status, .ask-turn-status { margin: 0; color: var(--muted); }
.ask-error, .ask-turn-status { margin-top: 6px; }
.ask-error { margin-bottom: 6px; }
.ask-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.panel h2 { margin: 0 0 10px; font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.bar { height: 10px; border-radius: 3px; background: var(--amber); min-width: 2px; }
.barwrap { background: var(--gray-bg); border-radius: 3px; width: 160px; }

.linkbtn { font-size: 12px; color: var(--accent, #7aa2ff); text-decoration: underline; cursor: pointer; }
.modal .box header .btn { margin-left: 4px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden], .drawer[hidden], .warn[hidden] { display: none; }
.modal .box { background: var(--panel); border-radius: 10px; max-width: 980px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; }
.modal .box header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal .box pre { margin: 0; padding: 14px 16px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 var(--mono); }

.nowrap { white-space: nowrap; }

.card[draggable=true] { cursor: grab; }
.card.dragging { opacity: .45; }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.col.drop { border-color: var(--accent); background: var(--blue-bg); }
.col { transition: background .1s, border-color .1s; }
.dlg { padding: 14px 16px 16px; }
.dlg p { margin: 0 0 10px; }
select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }

/* auth */
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.loginbox { max-width: 340px; padding: 22px; gap: 10px; display: flex; flex-direction: column; }
.loginbox input, .dlg input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg, transparent); color: inherit; }
.err { color: var(--red); min-height: 1em; font-size: 13px; }
.modal[hidden], .tab[hidden], .btn[hidden] { display: none; }
#login { z-index: 40; background: rgba(0,0,0,.7); }

.docs { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 800px) { .docs { grid-template-columns: 1fr; } }
.doclist { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 12px; max-height: 78vh; overflow-y: auto; }
.doclist h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
.doc-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.doc-item:hover { background: var(--blue-bg); }
.doc-item.on { background: var(--blue-bg); outline: 1px solid var(--accent); }
.doc-item .dn { font: 12px var(--mono); overflow-wrap: anywhere; }
.doc-item .dm { color: var(--muted); font-size: 11px; margin-left: auto; }
.docview { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.dochead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.docbody { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 var(--mono); max-height: 74vh; overflow-y: auto; }
.docedit { min-height: 60vh; font: 12px/1.5 var(--mono); }

.seg { display: inline-flex; gap: 4px; }
.md-wrap { font: 14px/1.6 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; white-space: normal; max-height: 74vh; overflow-y: auto; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .4em; line-height: 1.25; }
.md h1 { font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.md h2 { font-size: 17px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.md h3 { font-size: 15px; } .md h4 { font-size: 14px; color: var(--muted); }
.md > :first-child { margin-top: 0; }
.md p { margin: .5em 0; } .md ul, .md ol { margin: .4em 0; padding-left: 22px; } .md li { margin: .15em 0; }
.md a { color: var(--accent); }
.md code { font: 12px var(--mono); background: var(--gray-bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.md pre.mdcode { background: var(--gray-bg); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: .6em 0; }
.md pre.mdcode code { background: none; padding: 0; overflow-wrap: normal; }
.md blockquote { margin: .6em 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md .mdtbl { overflow-x: auto; margin: .6em 0; }
.md table { border-collapse: collapse; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--gray-bg); }

.usage-view { max-width: 1120px; margin: 0 auto; }
.usage-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 20px; }
.usage-filters label { display: grid; gap: 4px; font-size: .9em; }
.usage-filters input, .usage-filters select { min-height: 34px; padding: 4px 8px; }
.usage-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 12px; }
.usage-card { display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.usage-card strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.usage-breakdown { margin-top: 24px; }
.usage-scroll { overflow-x: auto; }
.usage-table { border-collapse: collapse; text-align: left; width: 100%; }
.usage-table th, .usage-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.usage-table td:last-child, .usage-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.usage-breakdown > .btn { margin-top: 8px; }
.proposal-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.migration-definition { width: 100%; min-height: 22rem; tab-size: 2; }
.migration-review pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.improvement-changes { width: 100%; min-height: 16rem; }
.improvement-review pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.record-open { display: block; border: 0; background: none; padding: 0; text-align: start; cursor: pointer; }
.record-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.record-table td { overflow-wrap: anywhere; }

/* Keep editable controls above Safari's focus-zoom threshold, including
   module-specific forms. Double taps stay taps, while pinch zoom still works. */
@media (max-width: 960px), (any-pointer: coarse) {
  html, body, body * { touch-action: manipulation; }
  :is(input, select, textarea, [contenteditable]:not([contenteditable="false"])) { font-size: max(16px, 1em) !important; }
}

@media (max-width: 960px) {
  :root {
    --page-gutter: 14px;
    --page-left: max(var(--page-gutter), env(safe-area-inset-left));
    --page-right: max(var(--page-gutter), env(safe-area-inset-right));
    --nav-height: calc(61px + env(safe-area-inset-bottom));
  }
  .mobile-only { display: revert; }
  .desktop-only, .desktop-title { display: none; }
  .top {
    align-items: center; min-height: 56px;
    padding: calc(8px + env(safe-area-inset-top)) var(--page-right) 8px var(--page-left);
  }
  .top .brand { flex: 1; }
  .header-actions { padding-bottom: 0; }
  .brand, .brand > div { min-width: 0; }
  .brand-icon { width: 34px; height: 34px; }
  .brand h1 { line-height: 1.2; }
  .brand .sub { font-size: 11px; overflow-wrap: anywhere; }
  main, .issues-board { padding: 14px var(--page-right) calc(var(--nav-height) + 18px) var(--page-left); }
  main:focus { outline: none; }
  .warn { padding-inline: var(--page-left) var(--page-right); }
  .mobile-nav:not([hidden]) {
    display: flex; gap: 6px; position: fixed; z-index: 10; inset: auto 0 0;
    min-height: var(--nav-height); background: var(--panel); border-top: 1px solid var(--line);
    padding: 7px var(--page-right) calc(7px + env(safe-area-inset-bottom)) var(--page-left);
  }
  .mobile-nav button {
    flex: 1; min-width: 0; min-height: 44px; border: 0; border-radius: 9px;
    background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
  }
  .mobile-nav button.active { background: var(--blue-bg); color: var(--accent); }
  .mobile-menu[open] {
    display: block; position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 560px);
    max-width: none; max-height: min(82dvh, 100%); overflow-y: auto; overscroll-behavior: contain;
    border: 1px solid var(--line); border-radius: 18px 18px 0 0; background: var(--panel); color: var(--ink);
    padding: 12px var(--page-right) max(14px, env(safe-area-inset-bottom)) var(--page-left);
  }
  .mobile-menu::backdrop { background: rgb(0 0 0 / .55); }
  .mobile-menu-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .mobile-menu-heading h2 { margin: 0; font-size: 18px; }
  .mobile-menu .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .mobile-menu .tab {
    display: flex; justify-content: space-between; align-items: center; gap: 4px; min-height: 48px;
    padding: 8px; border: 1px solid var(--line); border-radius: 8px; text-align: start; color: var(--ink);
  }
  .mobile-menu .tab[hidden] { display: none; }
  .mobile-menu .tab.active { border-color: var(--accent); background: var(--blue-bg); color: var(--accent); }
  .mobile-menu .count { margin: 0; white-space: nowrap; }
  .mobile-menu .who { flex-wrap: wrap; margin-top: 12px; padding: 12px 0 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

  .issues-layout { display: block; }
  .issue-categories {
    position: sticky; top: var(--issues-header-height, 56px); z-index: 4; display: flex;
    justify-content: center; gap: 3px; padding: 5px var(--page-right) 5px var(--page-left);
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .issue-categories button {
    flex: 1 1 auto; min-height: 48px; border: 0; border-radius: 7px; padding: 3px 1px;
    background: transparent; color: var(--muted); font-size: clamp(10px, 3vw, 14px);
    font-weight: 600; cursor: pointer;
  }
  .issue-categories .count { display: table; margin: 2px auto 0; padding: 0 6px; }
  .issue-categories button[aria-selected=true] { background: var(--blue-bg); color: var(--accent); }
  .issue-categories button[aria-selected=true] .count { color: inherit; background: var(--panel); }
  .issues-layout[data-category=investigations] .issues-board { display: none; }
  .issues-layout .board { display: block; }
  .issues-layout .col { display: none; }
  .issues-layout[data-category=attention] [data-col=attention],
  .issues-layout[data-category=watching] [data-col=watching],
  .issues-layout[data-category=recovered] [data-col=recovered],
  .issues-layout[data-category=closed] [data-col=closed] { display: block; }
  .issues-layout .col { padding: 0; border: 0; background: none; }
  .col h2 { padding-inline: 2px; }
  .col h2 > span:last-child { display: none; }
  .card { padding: 11px 12px; }
  .card .t { font-size: 15px; }
  .card .sum { font-size: 14px; overflow-wrap: anywhere; }
  .issue-filter-options:not(.expanded) { display: none; }
  .issue-filter-options { flex-basis: 100%; }
  .toolbar input[type=search] { flex-basis: 160px; max-width: none; min-width: 0; }

  :is(.btn, .chip, select, input:not([type=checkbox], [type=radio], [type=hidden])) { min-height: 44px; max-width: 100%; }
  .chip { padding-inline: 12px; }
  .seg { flex-wrap: wrap; }
  .bulkbar { top: var(--issues-header-height, 56px); z-index: 4; }
  .panel { padding: 12px; }
  .ask-view, .usage-view, .docs, .drawer { overflow-wrap: anywhere; }
  .ask-workspace { height: max(410px, calc(100dvh - var(--issues-header-height, 56px) - var(--nav-height) - 27px)); }
  main:has(> .ask-workspace) { padding-bottom: calc(var(--nav-height) + 13px); }
  .ask-workspace:not(.ask-embedded) .ask-header h1, .usage-view > h2 { display: none; }
  .usage-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 8px; }
  .usage-filters label { min-width: 0; }
  .usage-filters :is(input, select) { width: 100%; min-width: 0; }
  .usage-filters input[type=datetime-local] { appearance: none; background: var(--panel); }
  .proposal-filters select { min-width: 0; flex: 1 1 200px; }
  .usage-scroll, .tblwrap, .mdtbl { max-width: 100%; }
  .md-wrap pre { max-width: 100%; }

  .docs { grid-template-columns: minmax(0, 1fr); }
  .docs.doc-selected .doclist, .docs:not(.doc-selected) .doc-detail { display: none; }
  .doclist, .docbody { max-height: none; overflow: visible; }
  .doc-item { min-height: 46px; padding-block: 9px; }
  .dochead .actions { margin: 0; }
  .doc-back { margin-bottom: 10px; }

  body:has(.drawer:not([hidden]), .modal:not([hidden]), .mobile-menu[open], .inv-full, dialog[open]) { overflow: hidden; }
  .drawer {
    width: 100%; border: 0; padding: max(12px, env(safe-area-inset-top)) var(--page-right)
      max(24px, env(safe-area-inset-bottom)) var(--page-left); overscroll-behavior: contain;
  }
  .drawer .close {
    position: sticky; display: block; top: 0; margin: 0 0 6px auto; z-index: 1;
    width: 44px; height: 44px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  }
  .issue-detail-header { padding-right: 0; }
  .issue-detail-toolbar select { min-width: 0; }
  .issue-detail-section, .issue-detail > .inv-section, .issue-detail > .adhoc-backlinks:not(:empty) { padding: 12px; }
  .issue-more-actions summary { min-height: 44px; align-content: center; }
  table.kv th { white-space: normal; }
  .modal {
    padding: max(10px, env(safe-area-inset-top)) var(--page-right) max(10px, env(safe-area-inset-bottom)) var(--page-left);
  }
  .modal .box { max-height: 100%; overflow: auto; overscroll-behavior: contain; }
  .modal .box header { flex-wrap: wrap; gap: 6px; }
  .dlg input, .loginbox input { width: 100%; min-width: 0; }
}

@media (max-width: 700px) {
  .ask-header { margin-bottom: 8px; }
  .ask-header h2 { font-size: 17px; }
  .ask-history-toggle { display: inline-block; }
  .ask-layout { display: flex; flex-direction: column; }
  .ask-chat { flex: 1; }
  .ask-sidebar { display: none; }
  .ask-history-open .ask-sidebar { display: flex; flex: 1; border-inline-end: 0; }
  .ask-history-open .ask-chat { display: none; }
  .ask-chat-header, .ask-composer, .ask-transcript { padding-inline: 11px; }
  .ask-chat-header .ask-thread-title { flex-basis: 100%; }
  .record-table, .record-table :is(thead, tbody) { display: block; background: none; border: 0; }
  .record-table .record-head, .record-table:has(thead .sel) thead th:not(.sel) {
    position: absolute; width: 1px; height: 1px; padding: 0; border: 0; clip-path: inset(50%); overflow: hidden;
  }
  .record-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
  .record-table tbody tr {
    margin-bottom: 9px; padding: 11px; background: var(--panel); border: 1px solid var(--line);
    border-radius: 9px; overflow-wrap: anywhere;
  }
  .record-table :is(th, td) { display: block; text-align: start; width: auto; padding: 0; border: 0; white-space: normal; }
  .usage-table.record-table :is(th, td):last-child { text-align: start; }
  .record-table thead .sel { grid-column: 1 / -1; background: none; }
  .record-table .record-wide { grid-column: 1 / -1; }
  .record-table .record-title { color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 650; }
  .record-label { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
  .record-table .sel label { display: flex; align-items: center; gap: 7px; min-height: 44px; cursor: pointer; }
  .record-table tbody .sel { grid-column: 1 / -1; }
  .record-table tbody .sel input { inline-size: 22px; block-size: 22px; }
  .record-table .record-open { min-height: 36px; }
  .record-table .actions { margin: 0; }
  .record-table .barwrap { width: min(160px, 100%); }
  .account-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); }
  .account-form input { min-width: 0; padding: 7px 9px; }
  .runs-chart { overflow-x: auto; }
  .runs-chart svg { display: block; min-width: 510px; }
}
