/* Trove graph UI: tokens, layout, shared controls. */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --text: #1b1f2a;
  --muted: #5b6375;
  --border: #d7dbe5;
  --accent: #3f5bd6;
  --accent-text: #ffffff;
  --accent-soft: #e3e8fb;
  --danger: #c2332f;
  --ok: #1f7a4d;
  --warn: #9a6200;
  --focus: #1a4fd1;
  --on-danger: #ffffff;
  --on-warn: #1b1f2a;
  --canvas-bg: #fbfcfe;
  --grid: #e6e9f1;
  --node-bg: #ffffff;
  --edge: #7b849a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .08);
  --radius: 10px;
  --radius-sm: 6px;
  --top-h: 52px;
  --left-w: 248px;
  --panel-w: 320px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme=dark] {
  --bg: #12151c;
  --surface: #1a1e28;
  --surface-2: #222736;
  --text: #e8ebf3;
  --muted: #a3acc0;
  --border: #2f3646;
  --accent: #8ea4ff;
  --accent-text: #0e1220;
  --accent-soft: #2a3354;
  --danger: #ff8a85;
  --ok: #6fd3a0;
  --warn: #f2c26b;
  --focus: #b7c6ff;
  --on-danger: #0e1220;
  --on-warn: #0e1220;
  --canvas-bg: #161a23;
  --grid: #222838;
  --node-bg: #1f2431;
  --edge: #8c96ab;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-text); text-decoration: none;
}
.skip-link:focus { top: 8px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Grid shell: toolbar over sidebar | stage | panel. */
.app {
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas:
    "top   top   top"
    "left  stage panel";
  height: 100vh;
  height: 100dvh;
}

/* Toolbar */
.toolbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .01em; }
.logo {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7d5bd6);
  box-shadow: inset 0 0 0 4px var(--surface);
}
.brand-name { white-space: nowrap; }

.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group.end { margin-left: auto; }

.search-wrap { flex: 1 1 220px; max-width: 420px; min-width: 120px; }
.search {
  width: 100%; height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.search::placeholder { color: var(--muted); }
.search:focus { background: var(--surface); border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 550;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); background: var(--accent); }
.btn-block { width: 100%; }
.icon-btn { width: 34px; padding: 0; font-size: 16px; }
.icon-btn[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); }

.presence {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px; height: 26px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12.5px; font-weight: 550;
  white-space: nowrap;
}
.presence::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
}

/* Sidebar */
.sidebar {
  grid-area: left;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.tabs {
  display: flex; gap: 4px;
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 8px 6px 10px;
  border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--muted);
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.sidebar-body { flex: 1; overflow: auto; padding: 14px; }

/* Stage */
.stage {
  grid-area: stage;
  position: relative;
  min-width: 0; min-height: 0;
  overflow: hidden;
  background-color: var(--canvas-bg);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
}
.stage:focus { outline: none; }
.canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Canvas: nodes, edges, zoom controls, cap banner */
.canvas.panning { cursor: grabbing; }
.canvas:not(.panning) { cursor: grab; }
.arrow path { fill: var(--edge); }
.edge-line { fill: none; stroke: var(--edge); stroke-width: 1.6; }
.edge-label {
  font-size: 11px; fill: var(--muted);
  paint-order: stroke; stroke: var(--canvas-bg); stroke-width: 4px; stroke-linejoin: round;
}
.node { cursor: pointer; outline: none; }
.node-box {
  fill: var(--node-bg); stroke: var(--border); stroke-width: 1;
}
.node:hover .node-box { stroke: var(--accent); }
.node.selected .node-box { stroke: var(--accent); stroke-width: 2; }
.node:focus-visible .node-box { stroke: var(--focus); stroke-width: 3; }
.node-bar { fill: var(--accent); }
.node.kind-question .node-bar, .node.kind-limit .node-bar { fill: var(--warn); }
.node.kind-value .node-bar, .node.kind-item .node-bar { fill: var(--ok); }
.node.kind-note .node-bar { fill: var(--edge); }
.node-title { font-size: 13px; font-weight: 600; fill: var(--text); }
.node-kind { font-size: 11px; fill: var(--muted); text-transform: lowercase; }
.node-lock { font-size: 11px; }
.zoom-controls {
  position: absolute; right: 14px; top: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.cap-banner {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px;
  background: var(--warn); color: var(--on-warn); font-size: 12px; font-weight: 550;
  box-shadow: var(--shadow);
}
.cap-banner[hidden] { display: none; }
.cap-banner { white-space: nowrap; }

/* Filters sidebar: full-width selects; labels wrap instead of truncating. */
.filter-form { display: grid; gap: 10px; margin-bottom: 12px; }
.filter-field { display: grid; gap: 4px; min-width: 0; }
.filter-field label, .filter-check { font-size: 12px; font-weight: 550; color: var(--muted); overflow-wrap: anywhere; }
.filter-select { width: 100%; min-width: 0; box-sizing: border-box; min-height: 36px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 8px; }
.filter-check { display: flex; align-items: center; gap: 6px; }

.minimap {
  position: absolute; right: 14px; bottom: 14px;
  width: 180px; height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: .92;
}

.empty {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
  pointer-events: none;
}
.empty-title { margin: 0 0 4px; font-size: 18px; font-weight: 650; }
.empty-text { margin: 0; color: var(--muted); }

.hints {
  position: absolute; left: 14px; bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 6px;
  color: var(--muted); font-size: 12px;
  pointer-events: none;
}
.hints span {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Node panel */
.panel {
  grid-area: panel;
  min-height: 0; overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.node-panel { padding: 16px; min-height: 100%; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--surface-2); }
.np-empty { padding: 24px 8px; text-align: center; color: var(--muted); }
.np-empty-title { margin: 0 0 6px; font-weight: 600; color: var(--text); }
.np-empty-text { margin: 0; font-size: 13px; }
.np-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.np-kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.np-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.np-status-verified, .np-status-confirmed { color: var(--ok); }
.np-status-disputed, .np-status-contradicted { color: var(--warn); }
.np-lock { color: var(--warn); }
.np-deleted { color: var(--danger); }
.np-meta {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 14px;
  font-size: 13px;
}
.np-meta dt { color: var(--muted); }
.np-meta dd { margin: 0; overflow-wrap: anywhere; }
.np-reason {
  margin: 0 0 12px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); font-size: 13px;
}
.np-form { display: grid; gap: 12px; }
.np-field { display: grid; gap: 4px; }
.np-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.np-input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.np-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.np-input:disabled { background: var(--surface-2); color: var(--muted); }
.np-textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.np-hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); }
.np-error { margin: 0; min-height: 0; font-size: 13px; color: var(--danger); }
.np-error:empty { display: none; }
.np-actions, .np-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.np-actions[hidden] { display: none; }
.np-bar { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.np-id { margin: 12px 0 0; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: no-preference) {
  .np-input { transition: border-color .15s ease, box-shadow .15s ease; }
}

/* Live region, toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow);
  z-index: 60;
}

/* Join dialog */
.join {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(10, 12, 18, .45);
  backdrop-filter: blur(2px);
}
.join-card {
  width: min(380px, 100%);
  padding: 24px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.join-title { margin: 0 0 4px; font-size: 20px; }
.join-text { margin: 0 0 16px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 550; }
.field input {
  height: 38px; padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.field input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.join-error { min-height: 1.4em; margin: 10px 0 0; color: var(--danger); font-size: 13px; }

/* Connectors and relation chooser (22-connect.js) */
.handle {
  fill: var(--surface); stroke: var(--accent); stroke-width: 2;
  cursor: crosshair; opacity: 0; transition: opacity .15s ease;
}
.node:hover .handle, .node.selected .handle, .node:focus-visible .handle, .handle:hover { opacity: 1; }
.node.connect-target .node-box { stroke: var(--ok); stroke-width: 3; }
.connect-line { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.connect-backdrop {
  position: fixed; inset: 0; z-index: 75;
  display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 18, .45);
}
.connect-dialog {
  width: min(360px, 100%); padding: 20px;
  border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.connect-title { margin: 0 0 12px; font-size: 17px; }
.connect-kinds { display: grid; gap: 6px; margin: 0 0 16px; padding: 0; border: 0; }
.connect-kinds legend { margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.connect-kind {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.connect-kind:hover { background: var(--surface-2); }
.connect-kind:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
.connect-kind input { accent-color: var(--accent); }
.connect-actions { display: flex; justify-content: flex-end; gap: 8px; }
.connect-backdrop .btn:focus-visible,
.connect-kind input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  body { transition: background-color .2s ease, color .2s ease; }
}



@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Type picker dialog (23-typepicker.js) */
.tp-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(10, 14, 24, .42);
  backdrop-filter: blur(2px);
}
.tp-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.tp-heading { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
.tp-types {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
  border: 0; margin: 0 0 14px; padding: 0;
}
.tp-types legend, .tp-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.tp-type {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; user-select: none;
}
.tp-type:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tp-type:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tp-field { display: flex; flex-direction: column; margin-bottom: 12px; }
.tp-field input, .tp-field select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
}
.tp-field input:focus-visible, .tp-field select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tp-error { min-height: 1.2em; margin: 0 0 8px; color: var(--danger); font-size: 13px; }
.tp-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Evidence list (32-evidence.js) */
.ev-heading { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.ev-empty { margin: 8px 0; color: var(--muted); font-size: 13px; }
.ev-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ev-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ev-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.ev-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.ev-table tr:last-child td { border-bottom: 0; }
.ev-row.ev-deleted td { color: var(--muted); opacity: .7; text-decoration: line-through; }
.ev-row.ev-deleted .ev-badge, .ev-row.ev-deleted .ev-btn { text-decoration: none; }
.ev-tier { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 12px; white-space: nowrap; }
.ev-badge { color: var(--danger); font-size: 12px; font-weight: 600; }
.ev-note, .ev-ref { max-width: 26ch; }
.ev-value { max-width: 16ch; }
.ev-actions { white-space: nowrap; }
.ev-btn { padding: 3px 8px; font-size: 12px; margin-right: 4px; }
.ev-editing td { background: var(--surface-2); }
.ev-edit-title { margin: 0 0 6px; font-weight: 600; font-size: 13px; }
.ev-add { margin: 14px 0 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ev-add .attrs-legend, .ev-edit-form .attrs-legend { padding: 0 4px; font-weight: 600; }
.ev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.ev-field { min-width: 0; }
.ev-error { min-height: 1.2em; margin: 6px 0 0; color: var(--danger); font-size: 13px; }
.ev-add-form .btn, .ev-edit-form .btn { margin-top: 8px; }
.ev-table-box { margin-bottom: 8px; }
.ev-table-box:empty { display: none; }
.ev-table .btn:focus-visible, .ev-add .btn:focus-visible, .ev-add .np-input:focus-visible, .ev-edit-form .np-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .ev-table * { transition: none !important; } }

/* Confirm / dispute panel (33-vote.js) */
.vote-heading { margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.vote-summary { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.vote-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.vote-btn { min-width: 96px; }
.vote-btn[aria-pressed=true].vote-confirm { background: var(--accent-soft); border-color: var(--accent); }
.vote-btn[aria-pressed=true].vote-dispute { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.vote-form { margin-top: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.vote-reason-label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.vote-reason { width: 100%; box-sizing: border-box; padding: 6px 8px; font: inherit; font-size: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.vote-reason[aria-invalid=true] { border-color: var(--danger); }
.vote-count { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; text-align: right; }
.vote-actions { display: flex; gap: 8px; margin-top: 8px; }
.vote-error { min-height: 1.2em; margin: 6px 0 0; color: var(--danger); font-size: 13px; }
.vote-lock, .vote-empty, .vote-none { margin: 8px 0; color: var(--muted); font-size: 13px; }
.vote-list { list-style: none; margin: 10px 0 0; padding: 0; }
.vote-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.vote-row:last-child { border-bottom: 0; }
.vote-who { font-weight: 600; overflow-wrap: anywhere; }
.vote-badge { padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--text); }
.vote-badge.vote-dispute { background: var(--danger); color: var(--on-danger); }
.vote-why { flex-basis: 100%; color: var(--muted); overflow-wrap: anywhere; }
.vote-form .vote-reason:focus-visible, .vote-buttons .btn:focus-visible, .vote-actions .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .vote-btn { transition: none !important; } }

/* Comment threads (34-comments.js) */
.cm-heading { margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.cm-empty, .cm-none { margin: 8px 0; color: var(--muted); font-size: 13px; }
.cm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cm-item { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.cm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cm-author { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.cm-body { margin: 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-delete { padding: 2px 8px; font-size: 12px; }
.cm-form { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.cm-label { font-size: 13px; font-weight: 600; }
.cm-input { width: 100%; box-sizing: border-box; min-height: 64px; padding: 6px 8px; font: inherit; font-size: 13px; resize: vertical; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.cm-input[aria-invalid=true] { border-color: var(--danger); }
.cm-count { align-self: flex-end; color: var(--muted); font-size: 12px; }
.cm-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 13px; }
.cm-lock { margin: 0; color: var(--muted); font-size: 13px; }
.cm-form .btn { align-self: flex-start; }
.cm-form .cm-input:focus-visible, .cm-form .btn:focus-visible, .cm-delete:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Revision history (35-history.js) */
.hist-heading { margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.hist-empty, .hist-hint, .hist-legend { margin: 8px 0; color: var(--muted); font-size: 13px; }
.hist-error { margin: 8px 0; color: var(--danger); font-size: 13px; }
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hist-item { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.hist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hist-author { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.hist-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hist-summary { margin: 4px 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.hist-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.hist-pick input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
.hist-pick input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hist-diff { margin-top: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--accent-soft); }
.hist-label { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.hist-text { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.hist-add { background: transparent; color: var(--ok); text-decoration: underline; text-decoration-thickness: 2px; }
.hist-del { background: transparent; color: var(--danger); text-decoration: line-through; }
.hist-legend { margin: 6px 0 0; font-size: 12px; }

/* Conflict dialog (36-conflict.js) */
.cf-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(10, 14, 24, .48);
}
.cf-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--danger);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.cf-title { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.cf-body { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.cf-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cf-value { min-width: 0; }
.cf-label { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cf-text {
  margin: 0; padding: 8px 10px; max-height: 180px; overflow: auto;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cf-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.cf-btn {
  font: inherit; font-size: 13px; padding: 7px 14px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.cf-btn.cf-keep { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.cf-btn:hover { filter: brightness(.97); }
.cf-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 560px) { .cf-compare { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .cf-btn { transition: none !important; } }
