/* SCKB web app. One section per screen, between the "--- <screen> ---" comments: a stream edits only its own. */

/* --- shell --- */
:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1c2330;
  --muted: #5b6573;
  --border: #d5dae1;
  --accent: #2b5cd9;
  --accent-fg: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --focus: #1a73e8;
  --nav-w: 14rem;
  --bar-h: 3.5rem;
  --radius: 0.5rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d;
    --surface: #1b212b;
    --fg: #e6e9ef;
    --muted: #9aa5b5;
    --border: #323b49;
    --accent: #7aa2ff;
    --accent-fg: #0d1320;
    --danger: #ff8a80;
    --danger-bg: #3a1e1c;
    --focus: #8ab4ff;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d;
  --surface: #1b212b;
  --fg: #e6e9ef;
  --muted: #9aa5b5;
  --border: #323b49;
  --accent: #7aa2ff;
  --accent-fg: #0d1320;
  --danger: #ff8a80;
  --danger-bg: #3a1e1c;
  --focus: #8ab4ff;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.5 var(--font);
}
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
[hidden] { display: none !important; }

/* buttons and fields: at least 44 px high, so a finger can hit them */
button, .button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; min-width: 2.75rem; padding: 0.5rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--fg);
}
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.icon-button { font-size: 1.25rem; padding: 0; }
input[type="text"], input[type="password"], input[type="search"] {
  width: 100%; min-height: 2.75rem; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
label { display: block; font-weight: 600; margin: 0 0 0.25rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; max-width: 60rem;
}
.card.narrow { max-width: 28rem; margin: 1rem auto; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }
.error {
  color: var(--danger); background: var(--danger-bg); border-radius: var(--radius);
  padding: 0.5rem 0.75rem; margin: 0;
}

/* wide screens: side navigation */
.shell {
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--bar-h) 1fr;
  grid-template-areas: "bar bar" "nav main";
}
.topbar {
  grid-area: bar; display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.2rem; color: var(--fg); text-decoration: none; }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.nav {
  grid-area: nav; display: flex; flex-direction: column; gap: 0.25rem;
  padding: 1rem 0.75rem; border-right: 1px solid var(--border); background: var(--surface);
  position: sticky; top: var(--bar-h); align-self: start; height: calc(100vh - var(--bar-h));
}
.nav a {
  display: flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 0.75rem;
  border-radius: var(--radius); color: var(--fg); text-decoration: none;
}
.nav a:hover { background: var(--bg); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.nav .short { display: none; }
main { grid-area: main; padding: 1.5rem; min-width: 0; }
.skip {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 20;
  background: var(--accent); color: var(--accent-fg); padding: 0.75rem 1rem; border-radius: var(--radius);
}
.skip:focus { top: 0.5rem; }

/* phones and narrow windows: the navigation moves to a bar at the bottom */
@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--bar-h) 1fr;
    grid-template-areas: "bar" "main";
    padding-bottom: calc(3.75rem + env(safe-area-inset-bottom));
  }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 10;
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 0 0 env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border);
  }
  .nav a { flex: 1 1 0; min-width: 0; justify-content: center; min-height: 3.5rem; padding: 0.25rem; font-size: 0.8rem; text-align: center; border-radius: 0; overflow: hidden; text-overflow: ellipsis; }
  .nav .full { display: none; }
  .nav .short { display: inline; }
  main { padding: 1rem; }
  .who { max-width: 7rem; }
}

/* the screens with no navigation: sign-in and its errors */
.bare { min-height: 100vh; min-height: 100dvh; padding: 1rem; display: flex; flex-direction: column; align-items: center; }
.bare-brand { font-weight: 700; font-size: 1.5rem; margin: 1.5rem 0 0.5rem; }
.bare main { width: 100%; padding: 0; display: block; }
.boot { padding: 2rem; }

/* --- login --- */
.host { font-family: var(--mono); font-size: 0.95rem; overflow-wrap: anywhere; }

/* --- oauth-error --- */

/* --- overview --- */
:root {
  --warn: #8a5a00;
  --ok: #1e7a3a;
  --p0: #2b5cd9;
  --p1: #b45f06;
  --p2: #7b3fa0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --warn: #f0b34a; --ok: #6cc788; --p0: #7aa2ff; --p1: #f0a35a; --p2: #c79bea; }
}
:root[data-theme="dark"] { --warn: #f0b34a; --ok: #6cc788; --p0: #7aa2ff; --p1: #f0a35a; --p2: #c79bea; }

.small { font-size: 0.875rem; }
.dim { opacity: 0.55; }
select, input[type="date"] {
  min-height: 2.75rem; padding: 0.5rem 0.75rem; max-width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.notice { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--surface); padding: 0.5rem 0.75rem; margin: 0 0 1rem; }
.notice p { margin: 0 0 0.5rem; }
.notice.bad { border-left-color: var(--danger); }
.notice.busy { border-left-color: var(--warn); }
.badge { display: inline-block; margin-left: 0.5rem; padding: 0 0.5rem; border-radius: 1rem; background: var(--accent); color: var(--accent-fg); font-size: 0.8rem; font-weight: 600; }
.chips { list-style: none; margin: 0.5rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.chip { padding: 0.125rem 0.625rem; border: 1px solid var(--border); border-radius: 1rem; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.empty { text-align: center; padding: 2rem 1rem; }
.empty-title { font-size: 1.2rem; font-weight: 600; margin: 0 0 0.25rem; }

.stat-grid { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-height: 7.5rem; }
.stat p { margin: 0; }
.stat-title { color: var(--muted); }
.stat-value { font-size: 2.125rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat.bad .stat-value { color: var(--danger); }
.stat.busy .stat-value { color: var(--warn); }
.stat-detail { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.stat-link { display: inline-flex; align-items: center; min-height: 2.75rem; }
.kv { margin: 0; }
.kv-row { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: 0.25rem 1.5rem; padding: 0.375rem 0; border-top: 1px solid var(--border); }
.kv-row:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv-row { grid-template-columns: 1fr; } }

/* --- search --- */
.se-form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 52rem; }
.se-form input[type="search"] { width: 100%; min-height: 2.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 1.1rem; }
.se-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.se-k { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.se-k label { margin: 0; font-weight: 400; }
.filters { max-width: 52rem; margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.filters summary { display: flex; align-items: center; min-height: 2.75rem; padding: 0 1rem; cursor: pointer; font-weight: 600; }
.filters-body { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.cond { position: relative; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding-right: 3.25rem; }
.cond input[type="text"], .cond input[type="date"] { flex: 1 1 10rem; width: auto; min-width: 0; }
.cond select { flex: 0 1 12rem; }
.field-error { flex-basis: 100%; margin: 0; color: var(--danger); font-size: 0.875rem; }
.remove { position: absolute; right: 0; top: 0; font-size: 1.4rem; line-height: 1; }
.group { position: relative; margin: 0; padding: 0.75rem 3.5rem 0.75rem 0.75rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.group.or { border-left-color: var(--p1); }
.group.not { border-left-color: var(--danger); }
.group legend { font-weight: 600; padding: 0 0.375rem; }
.group > .remove { top: 0.375rem; right: 0.375rem; }
.add-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.results { max-width: 52rem; }
.hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.hit { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.hit:hover { border-color: var(--accent); }
.hit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.hit-title { font-size: 1.1rem; margin: 0; }
.hit-title a { color: var(--fg); text-decoration: none; }
.hit-title a:hover { text-decoration: underline; }
.hit-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.hit-score { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.hit-path { margin: 0.25rem 0; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.hit-desc { margin: 0.375rem 0 0.75rem; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.scorebar { display: flex; gap: 1px; height: 0.375rem; border-radius: 0.25rem; overflow: hidden; background: var(--border); }
.seg { display: block; min-width: 0; }
.seg.p0, .dot.p0 { background: var(--p0); }
.seg.p1, .dot.p1 { background: var(--p1); }
.seg.p2, .dot.p2 { background: var(--p2); }
.legend { list-style: none; margin: 0.375rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.375rem; }

/* --- page --- */
.page { max-width: 70rem; }
.page-bar { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.page-header h1 { margin-bottom: 0.25rem; overflow-wrap: anywhere; }
.page-desc { margin: 0.5rem 0; color: var(--muted); }
.stable { margin: 0.5rem 0; overflow-wrap: anywhere; }
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; margin-top: 1rem; }
@media (min-width: 1100px) { .page-grid { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; } }
.toggle-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.toggle { border: 0; border-radius: 0; background: var(--surface); }
.toggle + .toggle { border-left: 1px solid var(--border); }
.toggle.on { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.markdown { line-height: 1.65; overflow-wrap: anywhere; max-width: 46rem; }
.markdown h1, .markdown h2, .markdown h3 { margin: 1.5rem 0 0.5rem; }
.markdown pre, .plain { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; overflow-x: auto; }
.markdown code { font-family: var(--mono); font-size: 0.9em; background: var(--surface); padding: 0.05rem 0.3rem; border-radius: 0.25rem; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { margin: 1rem 0; padding: 0 1rem; border-left: 4px solid var(--border); color: var(--muted); }
.markdown table { border-collapse: collapse; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 0.375rem 0.625rem; }
.markdown img { max-width: 100%; height: auto; }
a.wiki { text-decoration-style: solid; }
.wiki-broken { color: var(--danger); text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.pickers { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: end; margin-bottom: 1rem; }
.pick label { margin: 0; font-size: 0.875rem; }
.pick select { min-width: 5rem; }
.pickers .toggle-group { margin-bottom: 0; }
.diff-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.diff { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 0.85rem; }
table.diff.side { min-width: 40rem; table-layout: fixed; }
table.diff td { padding: 0 0.5rem; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
table.diff td.num { width: 3rem; text-align: right; color: var(--muted); user-select: none; }
table.diff td.sign { width: 1.25rem; text-align: center; color: var(--muted); }
table.diff tr.hunk td { background: var(--bg); color: var(--muted); padding: 0.25rem 0.75rem; }
table.diff tr.add, table.diff tr.change td:nth-child(n+3) { background: color-mix(in srgb, #2e9e4f 20%, var(--surface)); }
table.diff tr.del { background: color-mix(in srgb, #d6453d 20%, var(--surface)); }
table.diff.side tr.change td:nth-child(-n+2) { background: color-mix(in srgb, #d6453d 20%, var(--surface)); }
table.diff.side tr.change td.none { background: var(--surface); }
.side-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.side-block h2 { margin-top: 0; font-size: 1.1rem; }
.side-block h3 { font-size: 0.95rem; color: var(--muted); margin: 1rem 0 0.25rem; }
.versions, .links { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.version { width: 100%; justify-content: flex-start; align-items: flex-start; gap: 0.75rem; text-align: left; border-color: transparent; background: none; }
.version.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.vnum { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--border); font-weight: 600; font-size: 0.85rem; }
.version.on .vnum { background: var(--accent); color: var(--accent-fg); }
.vbody { display: flex; flex-direction: column; min-width: 0; }
.vmsg { font-weight: 600; overflow-wrap: anywhere; }
.vmeta, .vstats, .context, .since { color: var(--muted); font-size: 0.8rem; }
.vstats .plus { color: var(--ok); }
.vstats .minus { color: var(--danger); }
.tag { margin-left: 0.5rem; font-size: 0.75rem; font-weight: 400; color: var(--muted); border: 1px solid var(--border); border-radius: 1rem; padding: 0 0.4rem; }
.asof { margin-top: 1rem; }
.asof .row { margin-top: 0; }
.link { padding: 0.375rem 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.link a { display: inline-flex; align-items: center; min-height: 2.75rem; overflow-wrap: anywhere; }
.context { overflow-wrap: anywhere; }

/* --- graph --- */
/* shared by graph, health and connect: the heading row with the live badge */
.graph-head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.graph-head h1 { margin: 0; }
.grow { flex: 1 1 auto; }
.mono { font-family: var(--mono); font-size: 0.95rem; overflow-wrap: anywhere; }
.live-badge { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2rem; padding: 0.15rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; background: var(--surface); }
.live-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); }
.live-badge[data-state="live"] .live-dot { background: var(--ok); }
.live-badge[data-state="connecting"] .live-dot, .live-badge[data-state="waiting"] .live-dot { background: var(--warn); }
.live-badge[data-state="denied"] .live-dot { background: var(--danger); }
.box { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0.75rem 0; background: var(--surface); }
.box p { margin: 0.4rem 0; }
.box.warn { border-color: var(--warn); }
.box.done { border-color: var(--ok); }
.ok { color: var(--ok); }
.bad-text, .help.bad { color: var(--danger); }
.warn { color: var(--fg); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
button.linklike { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0.25rem 0.1rem; min-height: 2.75rem; justify-content: flex-start; text-align: left; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; font-weight: 400; margin: 0; }
.check input { width: 1.4rem; height: 1.4rem; }
select, textarea { width: 100%; min-height: 2.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
textarea { resize: vertical; }
.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; margin-right: 0.4rem; background: var(--muted); flex: none; }
.swatch[data-color="0"] { background: var(--graph-c0); } .swatch[data-color="1"] { background: var(--graph-c1); }
.swatch[data-color="2"] { background: var(--graph-c2); } .swatch[data-color="3"] { background: var(--graph-c3); }
.swatch[data-color="4"] { background: var(--graph-c4); } .swatch[data-color="5"] { background: var(--graph-c5); }
.swatch[data-color="6"] { background: var(--graph-c6); } .swatch[data-color="7"] { background: var(--graph-c7); }
:root {
  --ok: #1b7a3a; --warn: #a15c00;
  --graph-c0: #0072b2; --graph-c1: #d55e00; --graph-c2: #009e73; --graph-c3: #cc79a7;
  --graph-c4: #e69f00; --graph-c5: #56b4e9; --graph-c6: #8c6d00; --graph-c7: #8a94a3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ok: #6fd48f; --warn: #f0b24a;
    --graph-c0: #56b4e9; --graph-c1: #e69f00; --graph-c2: #2fc79a; --graph-c3: #e58bbd;
    --graph-c4: #f0e442; --graph-c5: #4c8fe8; --graph-c6: #f0743a; --graph-c7: #9aa5b5;
  }
}
:root[data-theme="dark"] {
  --ok: #6fd48f; --warn: #f0b24a;
  --graph-c0: #56b4e9; --graph-c1: #e69f00; --graph-c2: #2fc79a; --graph-c3: #e58bbd;
  --graph-c4: #f0e442; --graph-c5: #4c8fe8; --graph-c6: #f0743a; --graph-c7: #9aa5b5;
}

.graph-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-bottom: 0.75rem; }
.graph-field { min-width: 11rem; }
.graph-field.grow { min-width: 12rem; }
.graph-count { color: var(--muted); align-self: center; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.seg button:last-child { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.graph-body { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1rem; align-items: start; }
.graph-stage { position: relative; height: clamp(22rem, calc(100dvh - 17rem), 60rem); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.graph-stage.is-list { height: auto; max-height: calc(100dvh - 17rem); min-height: 12rem; overflow: auto; }
.graph-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.graph-canvas:active { cursor: grabbing; }
.graph-note { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem; text-align: center; pointer-events: none; }
.graph-note button { pointer-events: auto; }
.graph-zoom { position: absolute; right: 0.5rem; bottom: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.graph-zoom button { background: var(--surface); font-size: 1.25rem; }
.graph-legend { position: absolute; left: 0.5rem; top: 0.5rem; max-width: 16rem; max-height: calc(100% - 4rem); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.25rem 0.5rem; z-index: 2; }
.graph-legend summary { min-height: 2.75rem; display: flex; align-items: center; cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.legend-row { display: flex; width: 100%; justify-content: flex-start; gap: 0.25rem; border: 0; background: none; padding: 0.25rem; text-align: left; }
.legend-row.off { opacity: 0.5; text-decoration: line-through; }
.legend-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.graph-chip { position: absolute; left: 0.5rem; right: 4.5rem; bottom: 0.5rem; display: none; align-items: center; gap: 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.25rem 0.5rem; }
.chip-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.graph-time { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.75rem; }
.graph-time label { margin: 0; }
.graph-time input[type="range"] { flex: 1 1 10rem; min-height: 2.75rem; accent-color: var(--accent); }
.graph-time-label { min-width: 9rem; font-variant-numeric: tabular-nums; }
.graph-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: calc(100dvh - 12rem); overflow: auto; }
.graph-panel h2 { margin-top: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.75rem; margin: 0.75rem 0; font-size: 0.95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.neighbors { list-style: none; margin: 0; padding: 0; }
.neighbors li { display: flex; flex-direction: column; border-bottom: 1px solid var(--border); padding: 0.25rem 0; }
.neighbors .tag, .neighbors .context { font-size: 0.85rem; color: var(--muted); }
.graph-table { width: 100%; border-collapse: collapse; }
.graph-table th, .graph-table td { text-align: left; padding: 0.25rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.graph-table td a { display: inline-block; padding: 0.6rem 0; }
.graph-table td.num, .graph-table th:nth-last-child(-n+2) { white-space: nowrap; }
.graph-table tr[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); }
@media (max-width: 900px) {
  .graph-body { grid-template-columns: minmax(0, 1fr); }
  .graph-panel { max-height: none; }
}
@media (max-width: 600px) {
  .graph-stage { height: clamp(18rem, calc(100dvh - 22rem), 40rem); }
  .graph-chip { display: flex; }
  .graph-legend { max-width: 12rem; }
}
@media (prefers-reduced-motion: reduce) {
  .graph-canvas { cursor: default; }
}

/* --- write --- */
.write-screen { max-width: 48rem; }
.steps { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.steps li { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.steps li.current { color: var(--fg); font-weight: 600; }
.step-no { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--border); font-size: 0.85rem; }
.steps li.current .step-no { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.field { margin: 0 0 1rem; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.help { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0; }
.counter { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 600; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.body-edit { font-family: var(--mono); font-size: 0.95rem; min-height: 16rem; }
.suggestions, .stable-list, .warnings, .findings { list-style: none; margin: 0.5rem 0; padding: 0; }
.suggestions li, .stable-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem; margin-bottom: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.write-footer { position: sticky; bottom: 0; background: var(--bg); padding: 0.5rem 0; border-top: 1px solid var(--border); margin-top: 1rem; align-items: center; }
.locked { border: 1px dashed var(--border); border-radius: var(--radius); padding: 0.5rem 1rem; margin: 0.75rem 0; background: color-mix(in srgb, var(--muted) 10%, transparent); }
.locked h2 { margin-top: 0.25rem; font-size: 1rem; }
.hunks { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; font-family: var(--mono); font-size: 0.88rem; background: var(--surface); }
.hunk-head { padding: 0.15rem 0.6rem; color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.hunk-line { display: grid; grid-template-columns: 3rem 3rem 1.5rem 1fr; white-space: pre-wrap; overflow-wrap: anywhere; }
.hunk-no { color: var(--muted); text-align: right; padding-right: 0.4rem; user-select: none; }
.hunk-sign { text-align: center; font-weight: 700; }
.hunk-line.add { background: color-mix(in srgb, var(--ok) 20%, transparent); }
.hunk-line.del { background: color-mix(in srgb, var(--danger) 20%, transparent); }

/* --- health --- */
.health-screen { max-width: 56rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.tile { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tile-label { color: var(--muted); font-size: 0.9rem; }
.tile-n { font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile.bad .tile-n { color: var(--danger); }
.tile.warn .tile-n { color: var(--warn); }
.queue-line { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-variant-numeric: tabular-nums; }
.finding { padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--surface); }
.finding.error { border-left-color: var(--danger); }
.finding.warning { border-left-color: var(--warn); }
.finding p { margin: 0.25rem 0 0; overflow-wrap: anywhere; }
.finding a { margin-left: 0.5rem; }

/* --- connect --- */
.connect-screen { max-width: 52rem; }
.connect-block { margin: 1.25rem 0; }
.copy-block { display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; }
.code { width: 100%; margin: 0; padding: 0.75rem 1rem; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-family: var(--mono); font-size: 0.9rem; white-space: pre; }
.steps-list { padding-left: 1.4rem; }
.steps-list li { margin: 0.3rem 0; }

/* --- write (phones) --- */
@media (max-width: 760px) {
  .write-footer { bottom: calc(3.75rem + env(safe-area-inset-bottom)); }
}

/* --- graph (mouse) --- */
@media (pointer: fine) {
  .legend-row { min-height: 2rem; padding: 0.1rem 0.25rem; }
  .graph-legend summary { min-height: 2rem; }
}

/* --- graph (phones: the toolbar takes two rows, so the picture starts high on the screen) --- */
@media (max-width: 600px) {
  .graph-toolbar { gap: 0.5rem; }
  .graph-toolbar .graph-field { flex: 1 1 8rem; min-width: 0; }
  .graph-toolbar .graph-field label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .graph-toolbar .graph-field.grow { flex-basis: 100%; }
  .graph-head { margin-bottom: 0.25rem; }
  .graph-head h1 { font-size: 1.25rem; }
  .graph-stage { height: clamp(18rem, calc(100dvh - 21rem), 40rem); }
}
