/* ============================================================================
   AI Shared Memory — inspection UI stylesheet
   Canonical spec: design.md (repository root). Tokens first; every component
   below references tokens only. No external fonts (the page must load on
   restricted networks), no build step, no framework.
   ============================================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;
  /* surfaces */
  --bg-canvas: #f7f7f8;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f2f2f3;
  --bg-active: #ebebed;
  /* text */
  --fg-primary: #18181b;
  --fg-secondary: #52525b;
  --fg-muted: #6e6e77;
  --fg-faint: #a1a1aa;
  --fg-on-accent: #ffffff;
  /* borders */
  --border-subtle: #ededef;
  --border-default: #e4e4e7;
  --border-strong: #d4d4d8;
  /* accent (interaction only) */
  --accent: #4f5bd5;
  --accent-hover: #4350c4;
  --accent-active: #3a46ad;
  --accent-subtle: #eef0fc;
  --accent-fg: #3d48b8;
  --focus-ring: rgba(79, 91, 213, 0.35);
  /* status */
  --success-fg: #15803d;
  --success-subtle: #ecfdf3;
  --success-on-subtle: #166534;
  --success-dot: #22c55e;
  --warning-fg: #b45309;
  --warning-subtle: #fffbeb;
  --warning-on-subtle: #92400e;
  --warning-dot: #f59e0b;
  --danger-fg: #b91c1c;
  --danger-subtle: #fef2f2;
  --danger-on-subtle: #991b1b;
  --danger-dot: #ef4444;
  --neutral-fg: #52525b;
  --neutral-subtle: #f4f4f5;
  --neutral-dot: #a1a1aa;
  /* shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --overlay: rgba(0, 0, 0, 0.4);
  /* radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 999px;
  /* type */
  --font-sans: "Inter", -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  /* spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  /* layout */
  --topbar-h: 48px;
  --sidebar-w: 240px;
  --content-max: 920px;
  --content-wide: 1200px;
  --page-pad: 32px;
  --spine-w: 200px;
  --filter-w: 180px;
  --cell-min-w: 180px; /* a table column that carries a title: it wraps there instead of growing (design.md §F.8) */
  /* controls */
  --control-h-sm: 28px;
  --control-h-md: 32px;
  --control-h-lg: 36px;
  /* motion */
  --dur-fast: 100ms;
  --dur-base: 150ms;
  --dur-slow: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  /* layers (design.md §G): the only z-index values outside a component's own stacking */
  --z-banner: 5;
  --z-topbar: 10;
  --z-skip: 20;
  --z-toast: 30;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-canvas: #131416;
    --bg-surface: #1a1b1e;
    --bg-elevated: #202126;
    --bg-subtle: #17181b;
    --bg-hover: #232428;
    --bg-active: #2a2b30;
    --fg-primary: #ededef;
    --fg-secondary: #a1a1aa;
    --fg-muted: #8d8d97;
    --fg-faint: #5c5c66;
    --fg-on-accent: #0f1020;
    --border-subtle: #232428;
    --border-default: #2a2b30;
    --border-strong: #3f3f46;
    --accent: #8b96f4;
    --accent-hover: #9aa3f6;
    --accent-active: #7b87ea;
    --accent-subtle: #232848;
    --accent-fg: #aab3f8;
    --focus-ring: rgba(139, 150, 244, 0.4);
    --success-fg: #4ade80;
    --success-subtle: #12271b;
    --success-on-subtle: #6ee7a0;
    --success-dot: #4ade80;
    --warning-fg: #fbbf24;
    --warning-subtle: #2a2210;
    --warning-on-subtle: #fcd34d;
    --warning-dot: #fbbf24;
    --danger-fg: #f87171;
    --danger-subtle: #2d1616;
    --danger-on-subtle: #fca5a5;
    --danger-dot: #f87171;
    --neutral-fg: #a1a1aa;
    --neutral-subtle: #26272b;
    --neutral-dot: #5c5c66;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
    --overlay: rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #131416;
  --bg-surface: #1a1b1e;
  --bg-elevated: #202126;
  --bg-subtle: #17181b;
  --bg-hover: #232428;
  --bg-active: #2a2b30;
  --fg-primary: #ededef;
  --fg-secondary: #a1a1aa;
  --fg-muted: #8d8d97;
  --fg-faint: #5c5c66;
  --fg-on-accent: #0f1020;
  --border-subtle: #232428;
  --border-default: #2a2b30;
  --border-strong: #3f3f46;
  --accent: #8b96f4;
  --accent-hover: #9aa3f6;
  --accent-active: #7b87ea;
  --accent-subtle: #232848;
  --accent-fg: #aab3f8;
  --focus-ring: rgba(139, 150, 244, 0.4);
  --success-fg: #4ade80;
  --success-subtle: #12271b;
  --success-on-subtle: #6ee7a0;
  --success-dot: #4ade80;
  --warning-fg: #fbbf24;
  --warning-subtle: #2a2210;
  --warning-on-subtle: #fcd34d;
  --warning-dot: #fbbf24;
  --danger-fg: #f87171;
  --danger-subtle: #2d1616;
  --danger-on-subtle: #fca5a5;
  --danger-dot: #f87171;
  --neutral-fg: #a1a1aa;
  --neutral-subtle: #26272b;
  --neutral-dot: #5c5c66;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --overlay: rgba(0, 0, 0, 0.6);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: var(--text-md); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 20px;
  color: var(--fg-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p, ul, ol, dl { margin: 0; }
h1 { font-size: var(--text-xl); line-height: 28px; font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 15px; line-height: 22px; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 15px; line-height: 22px; font-weight: 600; }
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
strong { font-weight: 600; }
::placeholder { color: var(--fg-muted); opacity: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: var(--space-2); z-index: var(--z-skip); padding: var(--space-1) var(--space-3); background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.skip:focus { left: var(--space-2); }

/* text utilities */
.eyebrow { font-size: var(--text-2xs); line-height: 14px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-muted); }
.muted { color: var(--fg-muted); }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.code { font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 14px; color: var(--fg-muted); }
.id { font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 14px; color: var(--fg-muted); background: none; border: 0; padding: 0; cursor: copy; border-radius: var(--radius-sm); transition: color var(--dur-fast) var(--ease); }
.id:hover { color: var(--accent-fg); }
.intro { font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); margin-bottom: var(--space-4); max-width: var(--content-max); }

/* ---------- 3. Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--space-4);
  height: var(--topbar-h); padding: 0 var(--space-6);
  background: var(--bg-surface); border-bottom: 1px solid var(--border-default);
}
.brand { display: flex; align-items: center; gap: var(--space-2); margin-right: auto; white-space: nowrap; min-width: 0; }
.brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.brand-name { font-size: var(--text-sm); font-weight: 600; letter-spacing: -0.005em; }
.brand-sub { font-size: var(--text-xs); color: var(--fg-muted); }
.connect { display: flex; align-items: center; gap: var(--space-2); }
.connect .input { width: min(360px, 44vw); }
.identity-handle { font-size: var(--text-xs); line-height: 16px; font-weight: 500; padding: var(--space-1) var(--space-2); border-radius: var(--radius-full); background: var(--accent-subtle); color: var(--accent-fg); }
.identity-name { font-size: var(--text-sm); color: var(--fg-secondary); }

/* ---------- 4. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h-md); padding: 0 var(--space-3);
  font-size: var(--text-sm); font-weight: 500; line-height: 1; white-space: nowrap;
  color: var(--fg-primary); background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.5; transform: none; }
.btn:disabled:hover { background: var(--bg-surface); border-color: var(--border-default); }
.btn-primary { color: var(--fg-on-accent); background: var(--accent); border-color: var(--accent); box-shadow: none; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); }
.btn-ghost { color: var(--fg-secondary); background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { color: var(--fg-primary); background: var(--bg-hover); border-color: transparent; }
.btn-danger { color: var(--danger-fg); }
.btn-danger:hover { background: var(--danger-subtle); border-color: var(--danger-fg); }
.btn-sm { height: var(--control-h-sm); padding: 0 var(--space-2); font-size: var(--text-xs); }
.btn[aria-pressed="true"] { background: var(--bg-active); border-color: var(--border-strong); box-shadow: none; } /* a toggle that is on (Table view) */

/* ---------- 5. Controls and forms ---------- */
.input, .select, .textarea {
  width: 100%; min-width: 0;
  height: var(--control-h-md); padding: 0 var(--space-3);
  font-size: var(--text-sm); line-height: 18px; color: var(--fg-primary);
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger-fg); }
.input:disabled, .select:disabled, .textarea:disabled { color: var(--fg-faint); background: var(--bg-subtle); }
.input-mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.textarea { height: auto; min-height: 96px; padding: var(--space-2) var(--space-3); line-height: 20px; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%2385858f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-2) center;
}
/* a list box (several choices): no chevron, rows instead of one line */
.select[multiple] { height: auto; padding: var(--space-1); background-image: none; }
.select[multiple] option { padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); white-space: normal; }
.select[multiple] option:checked { color: var(--accent-fg); background: var(--accent-subtle); } /* not the OS highlight */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field-label { font-size: var(--text-xs); line-height: 16px; font-weight: 500; color: var(--fg-secondary); }
.field-hint { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); }
.field-error { font-size: var(--text-xs); line-height: 16px; color: var(--danger-fg); }
.form { display: flex; flex-direction: column; gap: var(--space-4); max-width: var(--content-max); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--fg-secondary); cursor: pointer; min-height: var(--control-h-sm); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* ---------- 6. Shell and sidebar ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto;
  display: flex; flex-direction: column; gap: var(--space-6);
  padding: var(--space-5) var(--space-3);
  background: var(--bg-canvas); border-right: 1px solid var(--border-default);
}
.side-section { display: flex; flex-direction: column; gap: var(--space-2); }
.side-section > .eyebrow { padding: 0 var(--space-3); }
.project-list { display: flex; flex-direction: column; gap: 1px; }
.project-link {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--space-2); align-items: start;
  width: 100%; min-height: var(--control-h-lg); padding: var(--space-2) var(--space-3); text-align: left;
  color: var(--fg-primary); background: transparent; border: 0; border-radius: var(--radius-md);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.project-link:hover { background: var(--bg-hover); text-decoration: none; }
.project-link.active { background: var(--accent-subtle); }
.project-link.active .name { color: var(--accent-fg); }
.project-link .name { font-size: var(--text-sm); line-height: 18px; font-weight: 500; grid-column: 1; overflow-wrap: anywhere; }
.project-link .ver { font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 18px; color: var(--fg-muted); grid-column: 2; }
.project-link .meta { grid-column: 1 / -1; font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-details summary {
  list-style: none; display: flex; align-items: center; gap: var(--space-2);
  min-height: var(--control-h-sm); padding: var(--space-1) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-xs); font-weight: 500; color: var(--fg-secondary); cursor: pointer;
}
.side-details summary::-webkit-details-marker { display: none; }
.side-details summary::before { content: "+"; content: "+" / ""; align-self: flex-start; font-weight: 500; color: var(--fg-muted); }
.side-details[open] summary::before { content: "−"; content: "−" / ""; } /* the marker is not part of the name */
.side-details summary:hover { background: var(--bg-hover); color: var(--fg-primary); }
.side-details .form { padding: var(--space-2) var(--space-3) 0; gap: var(--space-3); }
.hint { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); padding: 0 var(--space-3); }
/* account block (UI spec §9.3): identity, permissions and developer log disclosures, Disconnect */
.side-account { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.side-identity { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); padding: 0 var(--space-3); min-width: 0; }
.side-identity .identity-name { overflow-wrap: anywhere; }
.side-account > .btn-ghost { align-self: flex-start; margin-left: var(--space-1); }
.perm-list { list-style: none; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); padding: var(--space-2) var(--space-3); }
.perm-off { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); padding: var(--space-1) 0; }
.side-details .activity { padding-top: var(--space-2); }
.activity { list-style: none; padding: 0 var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); max-height: 220px; overflow: auto; font-size: var(--text-2xs); line-height: 14px; color: var(--fg-muted); }
.activity li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--space-2); }
.activity li span { font-family: var(--font-mono); overflow-wrap: anywhere; }
.activity li.err span { color: var(--danger-fg); }
.activity time { font-variant-numeric: tabular-nums; }

/* ---------- 7. Main column ---------- */
.main { padding: var(--space-6) var(--page-pad) var(--space-16); min-width: 0; background: var(--bg-surface); }

/* welcome */
.welcome { max-width: 560px; padding: var(--space-10) 0; display: flex; flex-direction: column; gap: var(--space-4); }
.welcome h1 { font-size: var(--text-2xl); line-height: 32px; letter-spacing: -0.02em; }
.lede { font-size: var(--text-md); line-height: 22px; color: var(--fg-secondary); }
.legend { display: flex; flex-direction: column; border: 1px solid var(--border-default); border-radius: var(--radius-lg); margin-top: var(--space-2); }
.legend-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); }
.legend-row:last-child { border-bottom: 0; }
.legend-row > .badge { justify-self: start; } /* a pill sized to its label, not stretched to the grid column */
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); }
.steps li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--space-2); }
.steps li::before { counter-increment: step; content: counter(step); font-size: var(--text-2xs); font-weight: 500; color: var(--fg-muted); border: 1px solid var(--border-default); border-radius: var(--radius-full); width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }

/* page head (UI spec §9.4): project name, description, "V4 · last change …", the + Contribute action */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); max-width: var(--content-wide); }
.page-head-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head-desc { font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); max-width: var(--content-max); overflow-wrap: anywhere; }
.page-head-meta { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); }
.page-head-meta .v { font-family: var(--font-mono); font-weight: 500; color: var(--fg-secondary); }
.page-head > .btn { flex: none; }
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--border-default); margin-bottom: var(--space-6); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] {
  flex: none; height: var(--control-h-lg); padding: 0 var(--space-1); margin-bottom: -1px;
  font-size: var(--text-sm); font-weight: 500; white-space: nowrap; color: var(--fg-secondary);
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tabs [role="tab"]:hover { color: var(--fg-primary); }
.tabs [role="tab"][aria-selected="true"] { color: var(--fg-primary); border-bottom-color: var(--accent); }
.tabs [role="tab"]:focus-visible { outline-offset: -2px; border-radius: var(--radius-sm); }
.view { max-width: var(--content-wide); }
/* a long unbroken string (an id, a URL, a title) wraps instead of widening the page (design.md §J); a table keeps its
   words and scrolls inside its .table-wrap instead */
.view, .dialog, .toast { overflow-wrap: anywhere; }
.view table { overflow-wrap: normal; }
.view-body { animation: fade var(--dur-base) var(--ease) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* view-level status under the navigation ("Review queue", "Viewing V2 of V4") — a sticky notice variant */
.banner {
  position: sticky; top: calc(var(--topbar-h) + var(--space-2)); z-index: var(--z-banner);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4);
  max-width: var(--content-max); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); margin-bottom: var(--space-6);
  font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary);
  background: var(--bg-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md);
}
.banner strong { color: var(--fg-primary); }

/* sub-navigation inside a section (Records / Evidence, Sharing / Members, Activity / Versions / Audit) */
.subnav-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-6); }
.subnav { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: none; display: inline-flex; align-items: center; height: var(--control-h-md); padding: 0 var(--space-3);
  font-size: var(--text-sm); font-weight: 500; white-space: nowrap; color: var(--fg-secondary);
  border-right: 1px solid var(--border-default);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.subnav a:last-child { border-right: 0; }
.subnav a:hover { color: var(--fg-primary); background: var(--bg-hover); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--accent-fg); background: var(--bg-active); }
.subnav a:focus-visible { outline-offset: -2px; }

/* filter bar (Knowledge › Records, Activity › Audit; design.md §F.30): compact labelled controls on one wrapping line; checkboxes and the
   More disclosure sit on the control line; an opened More takes a line of its own */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); margin-bottom: var(--space-2); }
.filter-bar > .field { flex: 0 1 var(--filter-w); }
.filter-bar > .filter-search { flex: 1 1 calc(2 * var(--filter-w)); }
.filter-bar > .check { min-height: var(--control-h-md); padding-right: var(--space-2); }
.filter-inline { display: flex; gap: var(--space-2); }
.filter-inline > .input { flex: 1 1 auto; }
.filter-inline > .btn { flex: none; }
.filter-more > summary { min-height: var(--control-h-md); }
.filter-more[open] { flex-basis: 100%; }
.filter-more .field { max-width: calc(2 * var(--filter-w)); }
.filter-note { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); margin-bottom: var(--space-6); }
.count-line { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); margin-bottom: var(--space-2); }

/* ---------- 8. Version spine and change rows ---------- */
.spine { position: sticky; top: calc(var(--topbar-h) + var(--space-6)); display: flex; flex-direction: column; gap: 0; }
.spine > .eyebrow { margin-bottom: var(--space-2); padding-left: var(--space-1); }
.rung {
  position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--space-2); align-items: center;
  padding: var(--space-1) var(--space-1); text-align: left; color: var(--fg-secondary);
  background: none; border: 0; border-radius: var(--radius-md);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.rung::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 1px; background: var(--border-default); }
.rung:first-of-type::before { top: 50%; }
.rung:last-of-type::before { bottom: 50%; }
.rung .dot { position: relative; z-index: 1; justify-self: center; width: 8px; height: 8px; border-radius: 50%; background: var(--bg-surface); border: 1.5px solid var(--fg-muted); }
.rung .v { font-family: var(--font-mono); font-size: var(--text-xs); line-height: 16px; font-weight: 500; }
.rung .k { display: block; font-size: var(--text-2xs); line-height: 14px; color: var(--fg-muted); }
.rung:hover { background: var(--bg-hover); color: var(--fg-primary); text-decoration: none; }
.rung:focus-visible { outline-offset: -2px; } /* inside the spine's scroll box, an outside outline would be clipped */
.rung.selected { color: var(--accent-fg); }
.rung.selected .dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-subtle); }
.rung.latest .k::after { content: "latest"; display: block; color: var(--accent-fg); }
.change { display: grid; grid-template-columns: minmax(56px, auto) minmax(0, 1fr); gap: var(--space-3); min-width: 0; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); line-height: 18px; overflow-wrap: anywhere; }
.change:last-child { border-bottom: 0; }
.change-v { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--fg-muted); padding-top: 1px; }
.change-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); min-width: 0; color: var(--fg-primary); overflow-wrap: anywhere; }
.change-text a { min-width: 0; overflow-wrap: anywhere; } /* a long unbroken token wraps instead of widening the page */
.change-how { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); margin-top: 2px; }

/* ---------- 8b. Overview (UI spec §10): attention list, summary line, record rows, recent changes ---------- */
.banner .v { font-family: var(--font-mono); font-size: var(--text-xs); }
.notice-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.attention { list-style: none; padding: 0; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.attention-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-height: var(--control-h-lg); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); line-height: 18px; }
.attention-row:last-child { border-bottom: 0; }
.attention-text { flex: 1 1 auto; min-width: 0; color: var(--fg-primary); }
.summary-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); max-width: var(--content-max); margin-bottom: var(--space-8); }
.summary-line p { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); font-size: var(--text-sm); line-height: 18px; font-variant-numeric: tabular-nums; }
.summary-line .sep { color: var(--fg-muted); }
/* record rows share three columns (status · type · text) across the list, so badges and tags line up */
.record-rows { list-style: none; padding: 0; display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); column-gap: var(--space-3); border-top: 1px solid var(--border-subtle); }
.record-rows > li { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; border-bottom: 1px solid var(--border-subtle); }
.record-row {
  display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: start;
  min-height: var(--control-h-lg); padding: var(--space-2); color: inherit; border-radius: var(--radius-md);
  transition: background-color var(--dur-fast) var(--ease);
}
.record-row:hover { background: var(--bg-hover); text-decoration: none; }
.record-row:focus-visible { outline-offset: -2px; }
.record-row-main { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.record-row-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-size: var(--text-md); line-height: 20px; color: var(--fg-primary); overflow-wrap: anywhere; }
.record-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); }
/* a record row with one action at its right (Review queue › Pending proposals): a fourth column, outside the row's link */
.record-rows-with-action { grid-template-columns: max-content max-content minmax(0, 1fr) max-content; }
.record-rows-with-action > li > .record-row { grid-column: 1 / 4; }
.record-row-action { grid-column: 4; align-self: center; margin-right: var(--space-2); }
.recent { list-style: none; padding: 0; }
.recent > li { padding: var(--space-1) 0; border-bottom: 1px solid var(--border-subtle); }
.recent > li:last-child { border-bottom: 0; }
.recent .change { padding: var(--space-1) 0; border-bottom: 0; }
.recent-actor { font-weight: 500; }
.recent-note { font-size: var(--text-xs); color: var(--fg-muted); }

/* ---------- 8c. Contribute (UI spec §12): task cards, disclosures, Visibility, summary box, result ---------- */
.contribute-title { margin-bottom: var(--space-4); max-width: var(--content-max); overflow-wrap: anywhere; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); max-width: var(--content-max); margin-bottom: var(--space-6); }
.choice {
  display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); color: inherit;
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
a.choice:hover { background: var(--bg-hover); border-color: var(--border-strong); text-decoration: none; }
.choice[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.choice-desc { font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); }
.choice-note { margin-top: var(--space-1); font-size: var(--text-xs); line-height: 16px; font-weight: 500; color: var(--fg-muted); }
.choice-note-ok { color: var(--success-fg); }
.disclosure { max-width: var(--content-max); }
.disclosure > summary {
  list-style: none; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h-sm);
  font-size: var(--text-sm); font-weight: 500; color: var(--fg-secondary); cursor: pointer; border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "+"; content: "+" / ""; width: var(--space-3); color: var(--fg-muted); }
.disclosure[open] > summary::before { content: "−"; content: "−" / ""; }
.disclosure > summary:hover { color: var(--fg-primary); }
.disclosure-body { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-2); }
.other-types-list { list-style: none; padding: var(--space-2) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); line-height: 18px; }
.other-types-list span { color: var(--fg-muted); }
.crumb { margin-bottom: var(--space-3); font-size: var(--text-sm); line-height: 18px; }
.radio-group { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; margin: 0; padding: 0; border: 0; }
.radio-group > legend { padding: 0; margin-bottom: var(--space-1); }
.radio-hint { padding-left: var(--space-6); margin-bottom: var(--space-1); }
.check-disabled { color: var(--fg-faint); cursor: not-allowed; }
.audience-line { font-size: var(--text-sm); line-height: 18px; color: var(--fg-primary); overflow-wrap: anywhere; } /* read-only "Readable by" of an existing source */
.panel .notice { margin-bottom: 0; }
.form-errors:empty { display: none; }
.summary-box strong { display: block; margin-bottom: var(--space-1); }
.summary-lines { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.result-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.result-approval { display: inline-flex; align-items: center; gap: var(--space-2); } /* the separator wraps with its badge */
.result-facts { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); line-height: 18px; color: var(--fg-primary); }
.result-facts .mono { font-weight: 500; }
.result-note { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); overflow-wrap: anywhere; }

/* ---------- 8d. Members (UI spec §13.2): inline Edit panel, capability diff (the section action is in §9) ---------- */
/* inside a table cell: no trailing panel gap; on narrow screens it fits the visible part of the scrolling table */
.panel.member-edit { margin-bottom: 0; }
.diff { font-size: var(--text-sm); line-height: 18px; font-weight: 500; color: var(--fg-primary); overflow-wrap: anywhere; } /* "Adding: … · Removing: …" */
.table-note { margin-top: var(--space-2); font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); }

/* ---------- 8e. Record and source detail (design.md §F.31): head block, relation rows, two columns ---------- */
/* the head block: back link, title (source), chip line, then (record) the text, the approval sentence and the actions */
.detail-head { max-width: var(--content-max); margin-bottom: var(--space-8); }
.detail-title { margin-bottom: var(--space-2); overflow-wrap: anywhere; }
.detail-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.detail-line > .btn { margin-left: auto; }
.detail-meta { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); white-space: nowrap; }
.detail-sub { flex-basis: 100%; font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); overflow-wrap: anywhere; } /* a line of its own */
.detail-access { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-xs); line-height: 16px; color: var(--fg-secondary); }
.detail-content { margin-top: var(--space-3); font-size: var(--text-lg); line-height: 24px; color: var(--fg-primary); white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.section > .receipts { margin-top: 0; }
/* relation rows share five columns (label · type · lifecycle · text · Open) across the list, as record rows do */
.relation-rows { list-style: none; padding: 0; display: grid; grid-template-columns: max-content max-content max-content minmax(0, 1fr) max-content; column-gap: var(--space-3); }
.relation-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: baseline; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); line-height: 18px; }
.relation-row:last-child { border-bottom: 0; }
.relation-label { font-weight: 500; color: var(--fg-secondary); white-space: nowrap; }
.relation-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; color: var(--fg-primary); overflow-wrap: anywhere; }
.relation-text.muted { color: var(--fg-muted); }
.detail-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); max-width: var(--content-max); margin-bottom: var(--space-8); }
.detail-columns > .section { margin-bottom: 0; }

/* ---------- 8f. Access › Sharing (design.md §I.6): request scope lines, the Approve / Deny panels under a request ---------- */
.scope { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); overflow-wrap: anywhere; }
.card > .scope, .card > .scope + .card-body { margin-top: var(--space-1); }
.card > .card-head + .scope { margin-top: 0; }
.panel.request-panel { margin: var(--space-2) 0 0; }
.section > .panel:last-child { margin-bottom: 0; } /* the section's own margin spaces what follows */

/* ---------- 8g. Review queue (design.md §I.7): under each decision's record row, its Details and the review form ---------- */
.review-list > li.review-item { row-gap: var(--space-2); padding: var(--space-3) 0; }
.review-item > :not(.record-row) { grid-column: 1 / -1; margin: 0 var(--space-2); }
.review-item .notice { margin-bottom: 0; } /* the item's row gap spaces it */
.review-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); }
.review-form > .field { flex: 0 1 var(--filter-w); }
.review-form > .review-note { flex: 1 1 calc(2 * var(--filter-w)); }

/* ---------- 8h. Activity feed (design.md §F.32): one row per commit, newest first; columns line up across rows ---------- */
.activity-feed { list-style: none; padding: 0; display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); column-gap: var(--space-3); max-width: var(--content-max); }
.activity-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: baseline; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); line-height: 18px; }
.activity-row:last-child { border-bottom: 0; }
.activity-v { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--fg-muted); }
.activity-at { font-size: var(--text-xs); color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.activity-main { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; color: var(--fg-primary); }
.activity-actor { font-weight: 500; }
.activity-quote { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden; overflow-wrap: anywhere; color: var(--fg-secondary); }
.activity-records { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); overflow-wrap: anywhere; }
.activity-more { font-size: var(--text-xs); color: var(--fg-muted); }
.activity-redacted .activity-main { color: var(--fg-muted); }

/* ---------- 8i. Activity › Versions (design.md §I.8): the spine beside the selected version's panel ---------- */
.versions-layout { display: grid; grid-template-columns: var(--spine-w) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.versions-layout > .spine { max-height: calc(100vh - var(--topbar-h) - 2 * var(--space-6)); overflow-y: auto; } /* scrolls on its own */
.versions-panel { min-width: 0; }
.versions-head { max-width: var(--content-max); margin-bottom: var(--space-6); }
.versions-head .v { font-family: var(--font-mono); }
.versions-latest { font-weight: 400; color: var(--fg-muted); }
.versions-commit { margin-top: var(--space-1); font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); overflow-wrap: anywhere; }
.versions-commit.redacted { color: var(--fg-muted); }
.versions-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); max-width: var(--content-max); margin-bottom: var(--space-6); }

/* ---------- 9. Sections and cards ---------- */
.section { margin-bottom: var(--space-8); max-width: var(--content-max); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-3); }
.section-head .count { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.section-head .what { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); }
/* at the right of a section head: a "more" link (View all, Browse versions) or one action button (Add member) */
.section-head .section-more { margin-left: auto; font-size: var(--text-xs); line-height: 16px; }
.section-head > .btn { margin-left: auto; align-self: center; }
.cards { display: flex; flex-direction: column; gap: var(--space-2); }
.card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4); }
/* a record or request that no longer holds (design.md §F.6, ADR-0005 #2): opaque and receded — the subtle surface and
   outline, its text one tier down (primary → secondary); badges keep their tone. No opacity: every text on it is a
   token pair that `pnpm ui:contrast` checks. */
.card.superseded, .card.rejected, .card.revoked { background: var(--bg-subtle); border-color: var(--border-subtle); color: var(--fg-secondary); }
.card.superseded .card-body, .card.rejected .card-body, .card.revoked .card-body { color: var(--fg-secondary); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.card-head strong { font-size: var(--text-sm); line-height: 18px; }
.card-meta { margin-left: auto; font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); white-space: nowrap; }
.card-body { font-size: var(--text-md); line-height: 22px; color: var(--fg-primary); white-space: pre-wrap; overflow-wrap: anywhere; }
.card-approval { margin-top: var(--space-2); font-size: var(--text-xs); line-height: 16px; color: var(--success-fg); }
.card-approval.pending { color: var(--warning-fg); }
.card-approval.rejected { color: var(--danger-fg); }
.receipts { list-style: none; padding: 0; margin-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.receipt { display: flex; flex-direction: column; gap: 2px; padding: var(--space-1) var(--space-3); border-left: 2px solid var(--border-strong); background: var(--bg-subtle); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: var(--text-xs); line-height: 16px; }
.receipt-src { color: var(--fg-secondary); font-weight: 500; }
.receipt-quote { color: var(--fg-muted); }
.relations { margin-top: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-1); }
.rel { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-2xs); line-height: 14px; padding: var(--space-1) var(--space-2); border: 1px solid var(--border-default); border-radius: var(--radius-sm); color: var(--fg-secondary); background: var(--bg-surface); }
.rel b { font-weight: 500; color: var(--fg-primary); }
.card-summary { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-3); margin-top: var(--space-2); font-size: var(--text-xs); line-height: 16px; color: var(--fg-secondary); }
.card-foot { margin-top: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 14px; color: var(--fg-muted); }
.card-actions { margin-top: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- 10. Badges and tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); line-height: 16px; font-weight: 500; padding: 2px var(--space-2); border-radius: var(--radius-full); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none; background: currentColor; }
.badge-success { background: var(--success-subtle); color: var(--success-on-subtle); }
.badge-success::before { background: var(--success-dot); }
.badge-warning { background: var(--warning-subtle); color: var(--warning-on-subtle); }
.badge-warning::before { background: var(--warning-dot); }
.badge-danger { background: var(--danger-subtle); color: var(--danger-on-subtle); }
.badge-danger::before { background: var(--danger-dot); }
.badge-neutral { background: var(--neutral-subtle); color: var(--neutral-fg); }
.badge-neutral::before { background: var(--neutral-dot); }
.tag { display: inline-block; font-size: var(--text-xs); line-height: 16px; font-weight: 500; padding: 2px 6px; border-radius: var(--radius-sm); background: var(--neutral-subtle); color: var(--fg-secondary); white-space: nowrap; }
.tag-on { background: var(--success-subtle); color: var(--success-on-subtle); }
.tags { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }

/* ---------- 11. Tables ---------- */
.table-wrap { position: relative; overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); } /* relative: an .sr-only header stays inside the scroll box */
table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); line-height: 18px; }
th { padding: var(--space-2) var(--space-4); text-align: left; font-size: var(--text-2xs); line-height: 14px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-muted); background: var(--bg-subtle); border-bottom: 1px solid var(--border-default); white-space: nowrap; }
td { padding: 10px var(--space-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-subtle); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-hover); }
td.mono { white-space: nowrap; }
/* a cell that carries a title (a source, a member; always a <strong>) wraps a long unbroken one instead of growing */
.view td:has(> strong, > a > strong) { min-width: var(--cell-min-w); overflow-wrap: anywhere; }
tbody tr.row-detail > td, tbody tr.row-detail:hover > td { background: var(--bg-subtle); }
tbody tr.row-detail > td > .notice { margin-bottom: 0; } /* a result left under a member's row (.row-note) */
td strong { font-weight: 500; }
.cell-sub { font-size: var(--text-xs); line-height: 16px; color: var(--fg-muted); margin-top: 2px; }
.kv { display: flex; flex-wrap: wrap; gap: var(--space-1); max-width: 520px; }
.kv-item { font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 14px; padding: 2px 6px; border-radius: var(--radius-sm); background: var(--neutral-subtle); color: var(--fg-secondary); white-space: nowrap; }
.kv-item b { font-weight: 500; color: var(--fg-muted); }
/* a table's footer (design.md §F.8): its caption and one action on a wrapping line */
.table-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-2); }
.table-foot > .table-note { margin-top: 0; }
/* expandable table row (design.md §F.33): a ghost Details button opens the row's tr.row-detail under it; it keeps the
   row's height close to a text row's, and reads as pressed while open */
tbody .row-expand { margin: calc(-1 * var(--space-1)) 0; }
.row-expand[aria-expanded="true"] { color: var(--fg-primary); background: var(--bg-active); }
/* Activity › Audit (design.md §F.33): a non-ok event's status edge, as wide as the .toast-error stripe — danger when
   denied, warning for any other outcome; an inset shadow, so no column moves */
tbody tr.audit-flag > td:first-child { box-shadow: inset 3px 0 0 var(--warning-fg); }
tbody tr.audit-flag-danger > td:first-child { box-shadow: inset 3px 0 0 var(--danger-fg); }

/* ---------- 12. Panels, notices, states ---------- */
.panel { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-5); margin-bottom: var(--space-6); max-width: var(--content-max); display: flex; flex-direction: column; gap: var(--space-4); }
.panel-head { display: flex; flex-direction: column; gap: var(--space-1); }
.panel-desc { font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); }
.panel .cards { gap: var(--space-2); }
.panel .table-wrap { margin: 0; }
/* a table's name inside a section (Access › Sources you share: Your sources, Shares) */
.subhead { margin: var(--space-6) 0 var(--space-2); font-size: var(--text-sm); line-height: 18px; font-weight: 600; color: var(--fg-primary); }
.section-head + .subhead { margin-top: 0; }
.notice { display: block; max-width: var(--content-max); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-6); font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); background: var(--bg-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.notice strong { color: var(--fg-primary); }
.notice-warning { background: var(--warning-subtle); border-color: var(--warning-subtle); color: var(--warning-on-subtle); }
.notice-warning strong { color: var(--warning-on-subtle); }
.notice-danger { background: var(--danger-subtle); border-color: var(--danger-subtle); color: var(--danger-on-subtle); }
.notice-danger strong { color: var(--danger-on-subtle); }
.notice-success { background: var(--success-subtle); border-color: var(--success-subtle); color: var(--success-on-subtle); }
.notice-success strong { color: var(--success-on-subtle); }
.empty { font-size: var(--text-sm); line-height: 18px; color: var(--fg-muted); padding: var(--space-2) 0; }
.loading { font-size: var(--text-sm); line-height: 18px; color: var(--fg-muted); padding: var(--space-2) 0; }
.stack-gap { margin-top: var(--space-4); }

/* ---------- 13. Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%); z-index: var(--z-toast);
  max-width: min(90vw, 560px); padding: 10px var(--space-4);
  font-size: var(--text-sm); line-height: 18px; color: var(--fg-primary);
  background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  animation: fade var(--dur-base) var(--ease) both;
}
.toast-error { color: var(--danger-fg); border-left: 3px solid var(--danger-fg); }

/* ---------- 13b. Confirmation dialog (design.md §F.16) ---------- */
.dialog {
  width: 100%; max-width: min(480px, calc(100vw - 2 * var(--space-4))); padding: var(--space-6);
  color: var(--fg-primary); background: var(--bg-elevated);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.dialog::backdrop { background: var(--overlay); }
.dialog-title { overflow-wrap: anywhere; }
.dialog-body { margin-top: var(--space-2); font-size: var(--text-sm); line-height: 18px; color: var(--fg-secondary); overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6); }

/* ---------- 14. Responsive ---------- */
@media (max-width: 900px) {
  :root { --page-pad: 16px; }
  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
  .brand-sub, .side-identity .identity-name { display: none; }
  .connect .input { width: min(320px, 50vw); }
  .shell { grid-template-columns: 1fr; min-height: 0; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border-default); padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .side-section > .eyebrow, .hint { padding: 0; }
  #new-project, .hint { display: none; }
  /* account block: one compact row under the project switcher; an opened disclosure takes its own line */
  .side-account { margin-top: 0; padding-top: var(--space-2); flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
  .side-identity { padding: 0; }
  .side-account > .side-details summary { padding: var(--space-1) var(--space-2); }
  .side-account > .side-details[open] { flex-basis: 100%; }
  .side-account > .btn-ghost { margin-left: auto; }
  .project-list { flex-direction: row; overflow-x: auto; gap: var(--space-2); padding-bottom: var(--space-1); scrollbar-width: none; }
  .project-list::-webkit-scrollbar { display: none; }
  .project-link { flex: 0 0 auto; min-width: 200px; max-width: 260px; border: 1px solid var(--border-default); background: var(--bg-surface); }
  .project-link .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .project-link:focus-visible { outline-offset: -2px; } /* inside the row's scroll box, an outside outline would be clipped */
  .main { padding-top: var(--space-4); padding-bottom: var(--space-12); }
  .welcome { padding: var(--space-6) 0; }
  .tabs { gap: var(--space-4); margin-bottom: var(--space-4); -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .versions-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .versions-layout > .spine { max-height: none; }
  .spine { position: static; flex-direction: row; overflow-x: auto; gap: var(--space-1); padding-bottom: var(--space-1); }
  .spine > .eyebrow { display: none; }
  .rung::before { display: none; }
  .rung { flex: none; grid-template-columns: auto auto; padding: var(--space-1) var(--space-2); }
  .legend-row { grid-template-columns: 1fr; gap: var(--space-1); }
  .panel.member-edit { position: sticky; left: var(--space-4); max-width: calc(100vw - 2 * var(--page-pad) - 2 * var(--space-4) - 2px); }
  .detail-columns { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-8); }
  /* touch: every button, disclosure and option row is at least --control-h-md tall (design.md §J) */
  .btn-sm { height: var(--control-h-md); }
  .side-details summary, .disclosure > summary, .check { min-height: var(--control-h-md); }
}
@media (max-width: 480px) {
  .topbar { height: auto; flex-wrap: wrap; padding: var(--space-2) var(--space-4); }
  .brand { width: 100%; }
  .connect { width: 100%; }
  .connect .input { width: auto; flex: 1; }
  .page-head { flex-wrap: wrap; }
  .banner { position: static; }
  .filter-bar > .field { flex-basis: 100%; }
  .filter-more .field { max-width: none; }
  .record-rows, .record-rows > li { display: block; }
  .record-row { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
  .record-row-main { flex-basis: 100%; }
  .record-row-action { margin: 0 var(--space-2) var(--space-2); }
  .record-rows > li.review-item { display: flex; flex-direction: column; gap: var(--space-2); }
  .review-form { flex-direction: column; align-items: stretch; }
  .review-form > .field { flex: none; }
  .form-actions .btn { width: 100%; }
  .choices { grid-template-columns: 1fr; }
  .card-meta { margin-left: 0; width: 100%; }
  .detail-meta, .detail-line > .btn { margin-left: 0; }
  .relation-rows { display: block; }
  .relation-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); }
  .relation-text { flex-basis: 100%; }
  .activity-feed { display: block; }
  .activity-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); }
  .activity-main { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
