/* Rico: GitHub "Files changed" look. Colours follow Primer's light and dark tokens. */
:root {
  color-scheme: light dark;
  --fg: #1f2328; --fg-muted: #59636e; --fg-subtle: #818b98;
  --bg: #ffffff; --bg-inset: #f6f8fa; --bg-hover: #eaeef2; --bg-header: #f6f8fa;
  --border: #d1d9e0; --border-muted: #d1d9e0b3;
  --accent: #0969da; --accent-subtle: #ddf4ff;
  --success: #1a7f37; --success-emph: #1f883d; --success-emph-hover: #1c8139;
  --danger: #d1242f; --attention: #9a6700; --attention-subtle: #fff8c5; --attention-border: #d4a72c66;
  --done: #8250df; --neutral-emph: #59636e; --sq: #d1d9e0;
  --btn-bg: #f6f8fa; --btn-hover: #eff2f5; --btn-border: #d1d9e0;
  --diff-add-bg: #dafbe1; --diff-add-num: #aceebb; --diff-del-bg: #ffebe9; --diff-del-num: #ffcecb;
  --diff-hunk-bg: #ddf4ff; --diff-hunk-num: #b6e3ff;
  --mark: rgba(255, 212, 0, .22); --sel: rgba(9, 105, 218, .28); --chg: #1a7f37; --ctx: #54aeff; --out: #d1d9e0;
  --shadow: 0 8px 24px rgba(140, 149, 159, .2); --toolbar-h: 49px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #f0f6fc; --fg-muted: #9198a1; --fg-subtle: #656c76;
    --bg: #0d1117; --bg-inset: #151b23; --bg-hover: #262c36; --bg-header: #010409;
    --border: #3d444d; --border-muted: #3d444db3;
    --accent: #4493f8; --accent-subtle: #388bfd1a;
    --success: #3fb950; --success-emph: #238636; --success-emph-hover: #2ea043;
    --danger: #f85149; --attention: #d29922; --attention-subtle: #bb800926; --attention-border: #bb800966;
    --done: #ab7df8; --neutral-emph: #9198a1; --sq: #3d444d;
    --btn-bg: #212830; --btn-hover: #262c36; --btn-border: #3d444d;
    --diff-add-bg: #2ea04326; --diff-add-num: #2ea04366; --diff-del-bg: #f851491a; --diff-del-num: #f8514966;
    --diff-hunk-bg: #388bfd1a; --diff-hunk-num: #388bfd66;
    --mark: rgba(210, 153, 34, .25); --sel: rgba(68, 147, 248, .35); --chg: #3fb950; --ctx: #388bfd; --out: #3d444d;
    --shadow: 0 8px 24px rgba(1, 4, 9, .85);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
    --fg: #f0f6fc; --fg-muted: #9198a1; --fg-subtle: #656c76;
    --bg: #0d1117; --bg-inset: #151b23; --bg-hover: #262c36; --bg-header: #010409;
    --border: #3d444d; --border-muted: #3d444db3;
    --accent: #4493f8; --accent-subtle: #388bfd1a;
    --success: #3fb950; --success-emph: #238636; --success-emph-hover: #2ea043;
    --danger: #f85149; --attention: #d29922; --attention-subtle: #bb800926; --attention-border: #bb800966;
    --done: #ab7df8; --neutral-emph: #9198a1; --sq: #3d444d;
    --btn-bg: #212830; --btn-hover: #262c36; --btn-border: #3d444d;
    --diff-add-bg: #2ea04326; --diff-add-num: #2ea04366; --diff-del-bg: #f851491a; --diff-del-num: #f8514966;
    --diff-hunk-bg: #388bfd1a; --diff-hunk-num: #388bfd66;
    --mark: rgba(210, 153, 34, .25); --sel: rgba(68, 147, 248, .35); --chg: #3fb950; --ctx: #388bfd; --out: #3d444d;
    --shadow: 0 8px 24px rgba(1, 4, 9, .85);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.container { max-width: 1760px; margin: 0 auto; padding: 0 24px; }
.empty { color: var(--fg-muted); }
.spacer { flex: 1; }
.octicon { vertical-align: text-bottom; fill: currentColor; }

/* buttons, inputs, labels */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 16px; font-size: 14px; font-weight: 500; line-height: 20px; white-space: nowrap; cursor: pointer; color: var(--fg); background: var(--btn-bg); border: 1px solid var(--btn-border); border-radius: 6px; }
.btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { color: #fff; background: var(--success-emph); border-color: rgba(31, 35, 40, .15); }
.btn-primary:hover:not(:disabled) { background: var(--success-emph-hover); }
.btn-icon { padding: 5px 8px; }
.btn-link, .linkish { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; cursor: pointer; text-decoration: none; }
.btn-link:hover, .linkish:hover { text-decoration: underline; }
input[type="text"], input[type="search"], textarea, select { width: 100%; padding: 5px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
input[type="text"]:focus, input[type="search"]:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; padding: 8px 12px; }
.Counter { display: inline-block; min-width: 20px; padding: 0 6px; font-size: 12px; font-weight: 500; line-height: 18px; text-align: center; background: #818b981f; border-radius: 2em; }
.btn-primary .Counter { background: rgba(255, 255, 255, .25); color: #fff; }
.Label { display: inline-block; padding: 0 7px; font-size: 12px; font-weight: 500; line-height: 18px; color: var(--fg-muted); border: 1px solid var(--border); border-radius: 2em; white-space: nowrap; }
.Label--attention { color: var(--attention); background: var(--attention-subtle); border-color: var(--attention-border); }

/* top bar */
.gh-nav { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--bg-header); border-bottom: 1px solid var(--border); }
.gh-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 600; font-size: 16px; text-decoration: none; white-space: nowrap; }
.gh-brand small { font-weight: 400; font-size: 12px; color: var(--fg-muted); }
.gh-brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; color: #fff; background: var(--accent); border-radius: 6px; }
#load { display: flex; gap: 8px; flex: 1; max-width: 640px; }
#status { font-size: 13px; color: var(--fg-muted); min-height: 1em; }
#status.err { color: var(--danger); }

/* pull request header */
#prhead { background: var(--bg); }
.gh-title { margin: 16px 0 8px; font-size: 32px; font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
.gh-num { color: var(--fg-muted); font-weight: 300; }
.gh-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--fg-muted); }
.gh-meta b, .gh-meta a { color: var(--fg); font-weight: 600; text-decoration: none; }
.State { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; font-size: 14px; font-weight: 500; line-height: 20px; color: #fff; border-radius: 2em; }
.State--open { background: var(--success-emph); } .State--merged { background: var(--done); } .State--closed { background: #cf222e; } .State--draft { background: #6e7781; }
.commit-ref { padding: 0 6px; font: 12px/20px var(--mono); color: var(--accent); background: var(--accent-subtle); border-radius: 6px; }
.tabnav { display: flex; margin-top: 16px; border-bottom: 1px solid var(--border); }
.tabnav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; color: var(--fg); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabnav a:hover { background: var(--bg-hover); border-radius: 6px 6px 0 0; }
.tabnav a[aria-current="page"] { font-weight: 600; border-bottom-color: #fd8c73; }
.tabnav .octicon { color: var(--fg-muted); }

/* sticky toolbar + review dialog */
.toolbar { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--border); }
.toolbar-in { display: flex; align-items: center; gap: 12px; min-height: var(--toolbar-h); padding: 8px 24px; }
#totals { font-size: 14px; color: var(--fg-muted); }
#totals b { color: var(--fg); }
.add { color: var(--success); } .del { color: var(--danger); }
.review-wrap { position: relative; }
.Popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; display: flex; flex-direction: column; width: min(480px, 92vw); max-height: calc(100vh - 90px); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.Popover[hidden] { display: none; }
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.pop-head .btn-link { font-size: 20px; line-height: 1; color: var(--fg-muted); }
.pop-body { padding: 12px 16px; overflow: auto; }
.pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
#result { font-size: 13px; } #result .err { color: var(--danger); }
.radios { margin: 12px 0; padding: 0; border: 0; }
.radios label { display: flex; gap: 8px; padding: 6px 0; cursor: pointer; }
.radios input { width: auto; margin-top: 4px; }
.radios small { display: block; color: var(--fg-muted); font-size: 12px; }
#pending summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }

/* layout: file tree + files */
.layout { display: flex; align-items: flex-start; gap: 16px; padding-top: 16px; }
#side { position: sticky; top: var(--toolbar-h); flex: 0 0 296px; max-height: calc(100vh - var(--toolbar-h)); overflow: auto; padding-bottom: 16px; }
.layout.tree-hidden #side { display: none; }
.tree-head { padding: 0 0 8px; }
#viewed-count { margin-top: 6px; font-size: 12px; color: var(--fg-muted); }
#files { font-size: 14px; }
.tree-dir { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px calc(8px + var(--depth, 0) * 16px); color: var(--fg-muted); cursor: pointer; border-radius: 6px; user-select: none; }
.tree-dir:hover { background: var(--bg-hover); }
.tree-dir .octicon.fold { color: var(--accent); }
.tree-file { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 8px 4px calc(8px + var(--depth, 0) * 16px); font-size: 14px; text-align: left; color: var(--fg); text-decoration: none; background: none; border: 0; border-radius: 6px; cursor: pointer; }
.tree-file:hover { background: var(--bg-hover); }
.tree-file[aria-current="true"] { background: var(--accent-subtle); }
.tree-file.dim { color: var(--fg-muted); }
.tree-file .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-file .st-added { color: var(--success); } .tree-file .st-modified { color: var(--attention); } .tree-file .st-removed { color: var(--danger); } .tree-file .st-renamed { color: var(--done); }
.tree-file .Counter { font-size: 11px; }
.tree-file .tick { color: var(--success); }
.tree-dir[hidden], .tree-file[hidden] { display: none; }
#main { position: relative; flex: 1; min-width: 0; padding-bottom: 120px; }
#legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 12px; color: var(--fg-muted); }
#legend .k { display: inline-block; width: 3px; height: 12px; margin-right: 6px; vertical-align: -2px; border-radius: 2px; }
.k.del { background: var(--danger); } .k.chg { background: var(--chg); } .k.ctx { background: var(--ctx); } .k.out { background: var(--out); }

/* file cards */
.file-card { margin: 0 0 16px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; scroll-margin-top: calc(var(--toolbar-h) + 52px); }
.file-header { position: sticky; top: var(--toolbar-h); z-index: 10; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 5px 10px 5px 6px; background: var(--bg-inset); border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0; font-size: 13px; }
.file-card.collapsed .file-header { border-bottom: 0; border-radius: 6px; }
.file-card.collapsed .file-body { display: none; }
.chev { display: inline-grid; place-items: center; width: 28px; height: 28px; color: var(--fg-muted); background: none; border: 0; border-radius: 6px; cursor: pointer; }
.chev:hover { background: var(--bg-hover); }
.file-card.collapsed .chev .octicon { transform: rotate(-90deg); }
.fname { flex: 1; min-width: 0; font: 12px/1.4 var(--mono); overflow-wrap: anywhere; }
.fname b { font-weight: 600; }
.copy { color: var(--fg-muted); }
.diffstat { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.sq { display: inline-block; width: 8px; height: 8px; margin-left: 1px; background: var(--sq); }
.sq.g { background: var(--success); } .sq.r { background: var(--danger); }
.viewed { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; user-select: none; }
.viewed input { width: auto; margin: 0; }
.seg { display: inline-flex; }
.seg button { padding: 3px 8px; font-size: 12px; cursor: pointer; background: var(--bg); border: 1px solid var(--border); }
.seg button:first-child { border-radius: 6px 0 0 6px; } .seg button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.seg button[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--accent); position: relative; z-index: 1; }
.file-body { display: flex; align-items: flex-start; gap: 28px; padding: 24px 24px 24px 32px; }
.file-body .load-more { margin: 8px auto; }
.rico-doc { position: relative; flex: 1 1 0; min-width: 0; max-width: 920px; font-size: 16px; }
.rico-margin { position: relative; flex: 0 0 300px; width: 300px; }
.file-card.src .file-body { display: none; }
.rico-src { display: none; }
.file-card.src .rico-src { display: block; }
.markdown-body { background: transparent; }
.markdown-body [data-l] { position: relative; }
/* change bars: drawn by layoutBars() in one gutter column at the document's left edge */
.rico-bars { position: absolute; inset: 0 auto 0 0; width: 0; pointer-events: none; }
.rico-bars i { position: absolute; left: -16px; width: 3px; border-radius: 2px; }
.rico-bars i.del { background: var(--danger); } .rico-bars i.chg { background: var(--chg); } .rico-bars i.ctx { background: var(--ctx); } .rico-bars i.out { background: var(--out); }
.markdown-body [data-l].chg { background: color-mix(in srgb, var(--chg) 9%, transparent); } /* like GitHub's rich diff */
.markdown-body [data-l].has-c { background: var(--mark); box-shadow: 0 0 0 3px var(--mark); border-radius: 2px; }
.markdown-body [data-l].has-t { background: color-mix(in srgb, var(--accent) 9%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 9%, transparent); border-radius: 2px; }
.markdown-body [data-l].hl { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
::highlight(rico-sel) { background-color: var(--sel); }
::highlight(rico-thread) { background-color: color-mix(in srgb, var(--attention) 22%, transparent); }
::highlight(rico-hl) { background-color: color-mix(in srgb, var(--accent) 38%, transparent); }

/* removed blocks, drawn from the old version like GitHub's rich diff */
/* The text keeps the column of the surrounding text; the red tint reaches 8px past it (negative margin + equal padding). */
.markdown-body .rm { --del: color-mix(in srgb, var(--danger) 18%, var(--bg)); margin: 8px -8px; padding: 4px 8px; background: var(--del); border-radius: 4px; }
.markdown-body .rm > :first-child { margin-top: 0; } .markdown-body .rm > :last-child { margin-bottom: 0; }
.markdown-body li.rm { margin: 2px 0 2px -8px; padding: 0 8px; }
.markdown-body tr.rm td, .markdown-body tr.rm th { background: color-mix(in srgb, var(--danger) 18%, var(--bg)); }
.markdown-body .rm [data-l]::before { display: none; }
.markdown-body [data-l].gone.has-t, .markdown-body [data-l].gone.has-c { box-shadow: 0 0 0 3px var(--mark); }

/* GitHub-flavoured markdown details */
.markdown-alert-title .octicon { margin-right: 8px; }
.markdown-body .anchor { cursor: pointer; }
.markdown-body details > summary { cursor: pointer; }

/* review threads (margin) in GitHub's comment style */
.thread { position: absolute; left: 0; right: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; transition: top .12s ease, box-shadow .12s, border-color .12s; }
.thread.pending { border-style: dashed; border-color: var(--attention-border); }
.thread.pending .msg:first-child .who { background: var(--attention-subtle); }
.thread.active, .thread:hover { border-color: var(--accent); box-shadow: var(--shadow); z-index: 5; }
.thread.outdated { opacity: .85; }
.thread .msg + .msg { border-top: 1px solid var(--border); }
.thread .who { display: flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 12px; color: var(--fg-muted); background: var(--bg-inset); border-radius: 6px 6px 0 0; flex-wrap: wrap; }
.thread .msg + .msg .who { border-radius: 0; }
.thread .who b { color: var(--fg); font-weight: 600; }
.thread .who a { color: inherit; text-decoration: none; } .thread .who a:hover { text-decoration: underline; }
.avatar { width: 20px; height: 20px; border-radius: 50%; flex: none; background: var(--bg-hover); }
.thread .av { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.thread .text { padding: 8px 12px; overflow-wrap: anywhere; }
.thread .text > :first-child { margin-top: 0; } .thread .text > :last-child { margin-bottom: 0; }
.thread .text p { margin: .3em 0; } .thread .text pre { padding: 6px; font-size: 12px; overflow: auto; background: var(--bg-inset); border-radius: 6px; }
.thread .badge { display: inline-block; padding: 0 7px; font-size: 12px; font-weight: 500; line-height: 18px; color: var(--fg-muted); border: 1px solid var(--border); border-radius: 2em; }
.thread.pending .badge { color: var(--attention); background: var(--attention-subtle); border-color: var(--attention-border); }
.thread .tacts { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); }
.thread .tacts button, .thread .reply button { padding: 2px 10px; font-size: 12px; }
.thread .reply { padding: 8px 12px 0; } .thread .reply textarea { margin-top: 0; }
.thread .reply .row { display: flex; gap: 6px; margin-top: 6px; }
.thread .err { color: var(--danger); font-size: 12px; }
.rico-margin .note { position: absolute; left: 0; right: 0; font-size: 12px; color: var(--fg-muted); }

/* composer (floats over the selection) */
/* the two icons that appear beside a selection, in the margin like Google Docs */
#selbar { position: absolute; z-index: 49; display: flex; gap: 2px; padding: 4px 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); }
#selbar[hidden] { display: none; }
#selbar button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--fg); background: none; border: 0; border-radius: 50%; cursor: pointer; }
#selbar button:hover, #selbar button:focus-visible { background: var(--bg-hover); color: var(--accent); outline: 0; }
#selbar svg { width: 22px; height: 22px; }
#composer { position: absolute; z-index: 50; width: min(440px, calc(100% - 24px)); padding: 12px; background: var(--bg); border: 1px solid var(--accent); border-radius: 6px; box-shadow: var(--shadow); }
#composer.pulse { animation: pulse .5s; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--sel); } }
#composer .row { display: flex; gap: 8px; margin-top: 8px; }
#composer blockquote, .card blockquote { margin: 0 0 6px; padding: 2px 8px; border-left: 3px solid var(--border); color: var(--fg-muted); font-size: 12px; max-height: 16em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
#composer .q-gap { margin: 2px 0; font-style: italic; text-align: center; color: var(--fg-muted); user-select: none; }
#c-range { margin-bottom: 6px; font-size: 12px; color: var(--fg-muted); }
#c-range.warn { color: var(--attention); }
.qrow { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12px; }
.qrow label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.qrow input { width: auto; margin: 0; }
.qrow #c-qnote { color: var(--fg-muted); }
#c-qtext { margin-bottom: 6px; font: 12px/1.4 var(--mono); }

/* pending-comment list in the review dialog */
.card { margin-bottom: 8px; padding: 8px 10px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.card .where { font-size: 12px; color: var(--fg-muted); overflow-wrap: anywhere; }
.card .where a { color: var(--accent); cursor: pointer; text-decoration: none; }
.card .note { font-size: 12px; color: var(--fg-muted); } .card .note.warn { color: var(--attention); }
.card .body { margin: 4px 0; white-space: pre-wrap; }
.card .acts { display: flex; gap: 6px; } .card .acts button { padding: 2px 8px; font-size: 12px; }
#list .card blockquote { max-height: 1.5em; white-space: nowrap; text-overflow: ellipsis; }
#list .card .note:not(.warn) { display: none; }

/* diagrams (D2, Mermaid) */
.markdown-body figure.dia { margin: 1em 0; }
.dia-out { padding: 8px; border: 1px solid var(--border); border-radius: 6px; text-align: center; cursor: pointer; }
.dia-out:hover { border-color: var(--accent); }
.dia-frame { display: block; width: 100%; border: 0; max-height: 380px; background: transparent; }
.markdown-body figure.dia.big .dia-frame { max-height: none; }
.dia-wait { color: var(--fg-muted); font-size: 13px; }
.dia-err { text-align: left; color: var(--danger); font-size: 13px; }
.dia-err ul { margin: 4px 0 0; padding-left: 18px; }
.dia-tools { display: flex; gap: 12px; align-items: flex-start; margin-top: 4px; font-size: 13px; }
.dia-src { font-size: 13px; } .dia-src summary { color: var(--fg-muted); cursor: pointer; }

/* source diff view */
.diff-table { width: 100%; border-collapse: collapse; table-layout: fixed; font: 12px/20px var(--mono); }
.diff-table td { padding: 0; vertical-align: top; }
.d-num { position: relative; padding: 0 10px !important; text-align: right; color: var(--fg-muted); user-select: none; cursor: pointer; }
.d-mark { width: 18px; padding: 0 0 0 4px !important; color: var(--fg-muted); user-select: none; }
.d-code { padding: 0 10px 0 0 !important; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-add .d-code, .d-add .d-mark { background: var(--diff-add-bg); } .d-add .d-num { background: var(--diff-add-num); color: var(--fg); }
.d-del .d-code, .d-del .d-mark { background: var(--diff-del-bg); } .d-del .d-num { background: var(--diff-del-num); color: var(--fg); }
.d-hunk td { padding: 2px 10px !important; color: var(--fg-muted); background: var(--diff-hunk-bg); }
.d-hunk .d-num { background: var(--diff-hunk-num); }
.d-sel .d-code, .d-sel .d-mark, .d-sel .d-num { box-shadow: inset 0 0 0 100px rgba(9, 105, 218, .12); }
.d-plus { position: absolute; left: -10px; top: 1px; display: none; width: 20px; height: 20px; padding: 0; color: #fff; background: var(--accent); border: 0; border-radius: 6px; cursor: pointer; line-height: 20px; text-align: center; font: 600 14px/20px var(--font); }
.diff-table tr:hover .d-plus { display: block; }
.thread-row > td { padding: 8px 16px 8px 144px !important; background: var(--bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-family: var(--font); }
.thread-row .thread { position: static; max-width: 760px; font-size: 14px; }
.src-empty { padding: 24px; text-align: center; color: var(--fg-muted); }

@media (max-width: 1150px) {
  .file-body { flex-direction: column; gap: 16px; }
  .rico-margin { flex: none; width: 100%; }
  .thread { position: static; margin-bottom: 8px; }
  .rico-margin .note { position: static; }
}
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  #side { position: static; flex: none; width: 100%; max-height: none; }
  .file-body { padding: 16px; }
}

/* who is signed in (hosted mode) */
#who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-muted); }
#who img { width: 24px; height: 24px; border-radius: 50%; }
#who .btn { padding: 2px 10px; font-size: 12px; }
#status a { color: inherit; font-weight: 600; text-decoration: underline; }

#theme { margin-left: auto; padding: 2px 10px; font-size: 12px; }
#who { margin-left: 0; }
#who .chip { padding: 1px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 2em; }
.intro a { color: var(--accent); }

/* actions on comments and threads */
.thread .who .macts { margin-left: auto; display: inline-flex; gap: 10px; opacity: 0; transition: opacity .1s; }
.thread .msg:hover .macts, .thread .msg:focus-within .macts { opacity: 1; }
.linkish { padding: 0; font: inherit; font-size: 12px; color: var(--accent); background: none; border: 0; cursor: pointer; }
.linkish:hover { text-decoration: underline; } .linkish.danger { color: var(--danger); }
.thread .edited { font-style: italic; }
.thread.local { opacity: .75; }
.thread .msg.failed { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.thread .msg.failed .row { display: flex; gap: 6px; padding: 0 12px 8px; }
.thread .msg > .err { padding: 0 12px 6px; }
.thread.outdated { opacity: .6; }
.thread.outdated .text blockquote { text-decoration: line-through; }
.thread.outdated:hover { opacity: 1; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 0 12px 8px; position: relative; }
.react { padding: 0 8px; font-size: 12px; line-height: 20px; color: var(--fg-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 2em; cursor: pointer; }
.react:hover:not(:disabled) { border-color: var(--accent); } .react:disabled { cursor: default; }
.react.mine { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
.react.add { opacity: 0; } .thread .msg:hover .react.add, .react.add:focus-visible { opacity: 1; }
.picker { position: absolute; left: 12px; bottom: 30px; z-index: 6; display: flex; gap: 2px; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.picker .react { border: 0; font-size: 15px; }
.thread.resolved .rmark { display: flex; align-items: center; gap: 4px; padding: 6px 12px; font-size: 12px; color: var(--fg-muted); overflow: hidden; white-space: nowrap; }
.thread.resolved .rmark .tick { color: var(--success, #1a7f37); font-weight: 700; } .thread.resolved .rmark .rtext { overflow: hidden; text-overflow: ellipsis; flex: 1; } 
.thread.resolved { border-color: var(--border); background: var(--bg-inset); }
#general { margin: 0 0 16px; padding: 8px 12px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 6px; }
#general h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--fg-muted); }
#general .thread { position: static; margin-bottom: 8px; max-width: 640px; }
#c-err { margin-top: 6px; font-size: 12px; color: var(--danger); }
#c-err:empty { display: none; }
.banner { margin: 0 0 12px; padding: 8px 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--attention-subtle); border: 1px solid var(--attention-border); border-radius: 6px; font-size: 13px; }
.banner[hidden] { display: none; }
#selbar button[hidden] { display: none; }
.Counter[hidden] { display: none; }

/* suggest an edit */
#c-suggest { margin-top: 6px; }
#c-suggest .sg-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; } #c-suggest .sg-label small { font-weight: 400; color: var(--fg-muted); }
#c-sugtext { font: 12px/1.5 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); }
.sugdiff, .sugg { margin-top: 6px; font: 12px/1.5 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.sugdiff:empty { display: none; }
.sugdiff > div, .sugg > div:not(.sugg-head) { display: flex; gap: 6px; padding: 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sg-add { background: var(--diff-add-bg); } .sg-del { background: var(--diff-del-bg); }
.sg-mark { flex: none; width: 1ch; color: var(--fg-muted); user-select: none; }
.sugg { margin: 6px 12px; } .thread .sugg code { padding: 0; background: none; font: inherit; }
.sugg-head { padding: 4px 8px; font: 600 12px var(--font); color: var(--fg-muted); background: var(--bg-inset); border-bottom: 1px solid var(--border); }
#selbar button:disabled { opacity: .35; cursor: not-allowed; } #selbar button:disabled:hover { background: none; color: var(--fg); }

.thread .msg { position: relative; }
.thread .err:empty { display: none; }
.picker { top: 30px; right: 8px; left: auto; bottom: auto; }
.reacts { padding-top: 0; }
.thread .who .macts .react.add { opacity: 1; padding: 0 6px; }

/* condensed threads: first and last message, the rest on hover (peek) or click (pin) */
.thread .more { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 12px; font-size: 12px; text-align: left; background: var(--bg-inset); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.thread .more .avatar, .thread .more .av { width: 16px; height: 16px; margin-right: -8px; border: 1px solid var(--bg); border-radius: 50%; font-size: 9px; }
.thread .more span:last-child { margin-left: 12px; }
.thread .mid { display: none; }
.thread.folded.peek .mid { display: block; }
.thread.folded.peek .more { display: none; }
.thread.clamped:not(.peek) .text { max-height: 9em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.thread .showmore { display: block; padding: 0 12px 6px; }
.thread.clamped.peek .showmore { display: none; }
.thread.peek { box-shadow: var(--shadow); z-index: 8; }
@media (prefers-reduced-motion: no-preference) { .thread .mid { animation: none; } }
.thread.opened .mid { display: block; } .thread.opened .more { display: none; }
.thread.opened.clamped .text { max-height: none; -webkit-mask-image: none; mask-image: none; } .thread.opened .showmore { display: none; }

/* comments column: ribbons, synced (sticky, non-linear) mode, overview ticks */
.file-body { position: relative; }
.rico-track { position: absolute; left: 0; right: 0; top: 0; }
.rico-ribbons { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 1; }
.rico-ribbons path { fill: none; stroke: color-mix(in srgb, var(--accent) 28%, transparent); stroke-width: 1.5; transition: stroke .1s; }
.rico-ribbons path.resolved { stroke-dasharray: 3 3; stroke: color-mix(in srgb, var(--fg-muted) 40%, transparent); }
.rico-ribbons path.on { stroke: var(--accent); stroke-width: 2.5; }
.file-body.sync .rico-margin { position: sticky; top: calc(var(--toolbar-h) + 8px); height: calc(100vh - var(--toolbar-h) - 24px); overflow: hidden; align-self: flex-start; }
.file-body.sync .rico-track { will-change: transform; }
.rico-margin .cnt { position: absolute; left: 50%; transform: translateX(-50%); z-index: 9; padding: 1px 10px; font-size: 11px; color: var(--accent); background: var(--bg); border: 1px solid var(--border); border-radius: 2em; box-shadow: var(--shadow); cursor: pointer; }
.rico-margin .cnt.up { top: 4px; } .rico-margin .cnt.down { bottom: 4px; } .rico-margin .cnt[hidden] { display: none; }
#ticks { position: fixed; right: 0; top: 0; width: 10px; height: 100vh; z-index: 30; pointer-events: none; }
#ticks .tick { position: absolute; right: 1px; width: 8px; height: 4px; padding: 0; background: var(--accent); border: 0; border-radius: 1px; opacity: .8; cursor: pointer; pointer-events: auto; }
#ticks .tick.pending { background: var(--attention); } #ticks .tick.resolved { background: var(--fg-muted); opacity: .4; } #ticks .tick.mine { width: 10px; right: 0; }
@media (max-width: 1150px) { .rico-ribbons, #ticks { display: none; } .rico-track { position: static; } }

.thread .who { position: relative; }
.thread .who .macts { position: absolute; right: 6px; top: 50%; margin-left: 0; transform: translateY(-50%); padding-left: 16px; background: linear-gradient(90deg, transparent, var(--bg-inset) 12px); }
.rico-margin .cnt { left: 0; right: 0; transform: none; border-radius: 0; border-left: 0; border-right: 0; text-align: center; box-shadow: none; background: color-mix(in srgb, var(--bg) 92%, var(--accent)); }
.rico-margin .cnt.up { top: 0; border-top: 0; } .rico-margin .cnt.down { bottom: 0; border-bottom: 0; }
