/* Graphersal Playground. Colours are tokens on :root; dark mode follows the system unless the
   user picks a theme (html[data-theme]). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e6e9ee;
  --border: #d9dde3;
  --border-strong: #c3c9d2;
  --text: #1c2330;
  --text-muted: #5d6676;
  --text-faint: #8a93a3;
  --accent: #2f6fde;
  --accent-hover: #2459b8;
  --accent-soft: #e4edfc;
  --accent-contrast: #ffffff;
  --danger: #c4372f;
  --danger-soft: #fbe9e7;
  --warn: #9a6200;
  --warn-soft: #fdf3dc;
  --ok: #23854f;
  --ok-soft: #e3f4ea;
  --code-bg: #fbfcfd;
  --selection: #cfdcf6;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .08);
  --syn-keyword: #8a3fbf;
  --syn-step: #1f5fc4;
  --syn-token: #b05a00;
  --syn-string: #1d7f4e;
  --syn-number: #b0336a;
  --syn-comment: #8a93a3;
  --syn-var: #1c2330;
  --graph-edge: #9aa3b2;
  --graph-text: #1c2330;
  --graph-text-outline: #ffffff;
  --graph-selected: #e0791f;
  --ai-accent: #7a4fd6; /* the AI Chat tabs */
  --ai-soft: #f1ebfd;
  /* The process memory bar's segments (components/memory-bar.js). */
  --mem-structure: #3b6fd4;
  --mem-properties: #2a9d8f;
  --mem-compressed: #8a5cc7;
  --mem-indexes: #c98a12;
  --mem-models: #c94f7c;
  --mem-live_graph: #5a8f3c;
  --mem-store: #b5651d;
  --mem-engine: #4f6d8a;
  --mem-other: #9aa3b2;
  --mem-shared: #6b7a90; /* a layer's shared base (outside the process bar's segments) */
  /* A layer's element origins (js/graph/origin-style.js; Okabe-Ito blue / reddish purple). */
  --origin-added: #0072b2;
  --origin-modified: #b5508a;
  --radius: 6px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 34px;
  --z-popover: 1000; /* every popup (menus) sits above panels, gutters and toolbars */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b;
    --surface: #181d25;
    --surface-2: #1f2530;
    --surface-3: #283040;
    --border: #2c3442;
    --border-strong: #3b4557;
    --text: #e3e7ee;
    --text-muted: #a2abbb;
    --text-faint: #6f7a8c;
    --accent: #6c9eff;
    --accent-hover: #8db4ff;
    --accent-soft: #1d2b46;
    --accent-contrast: #0b1220;
    --danger: #ff7b72;
    --danger-soft: #3a1d1d;
    --warn: #e3b341;
    --warn-soft: #362a10;
    --ok: #56d364;
    --ok-soft: #14301d;
    --code-bg: #141920;
    --selection: #2a3d63;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
    --syn-keyword: #d2a8ff;
    --syn-step: #79b8ff;
    --syn-token: #ffab70;
    --syn-string: #7ee2a8;
    --syn-number: #f9a8d4;
    --syn-comment: #6f7a8c;
    --syn-var: #e3e7ee;
    --graph-edge: #5d6879;
    --graph-text: #e3e7ee;
    --graph-text-outline: #181d25;
    --graph-selected: #ffab70;
    --ai-accent: #b69cff;
    --ai-soft: #2a2244;
    --mem-structure: #6c9eff;
    --mem-properties: #4fc1b3;
    --mem-compressed: #b69cff;
    --mem-indexes: #e3b341;
    --mem-models: #f08fb5;
    --mem-live_graph: #8bc66a;
    --mem-store: #e09552;
    --mem-engine: #8fb0cf;
    --mem-other: #5d6879;
    --mem-shared: #8d9bb0;
    --origin-added: #56b4e9;
    --origin-modified: #e69ac4;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11151b;
  --surface: #181d25;
  --surface-2: #1f2530;
  --surface-3: #283040;
  --border: #2c3442;
  --border-strong: #3b4557;
  --text: #e3e7ee;
  --text-muted: #a2abbb;
  --text-faint: #6f7a8c;
  --accent: #6c9eff;
  --accent-hover: #8db4ff;
  --accent-soft: #1d2b46;
  --accent-contrast: #0b1220;
  --danger: #ff7b72;
  --danger-soft: #3a1d1d;
  --warn: #e3b341;
  --warn-soft: #362a10;
  --ok: #56d364;
  --ok-soft: #14301d;
  --code-bg: #141920;
  --selection: #2a3d63;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
  --syn-keyword: #d2a8ff;
  --syn-step: #79b8ff;
  --syn-token: #ffab70;
  --syn-string: #7ee2a8;
  --syn-number: #f9a8d4;
  --syn-comment: #6f7a8c;
  --syn-var: #e3e7ee;
  --graph-edge: #5d6879;
  --graph-text: #e3e7ee;
  --graph-text-outline: #181d25;
  --graph-selected: #ffab70;
  --ai-accent: #b69cff;
  --ai-soft: #2a2244;
  --mem-structure: #6c9eff;
  --mem-properties: #4fc1b3;
  --mem-compressed: #b69cff;
  --mem-indexes: #e3b341;
  --mem-models: #f08fb5;
  --mem-live_graph: #8bc66a;
  --mem-store: #e09552;
  --mem-engine: #8fb0cf;
  --mem-other: #5d6879;
  --mem-shared: #8d9bb0;
  --origin-added: #56b4e9;
  --origin-modified: #e69ac4;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* An IDE, not a document: no pull-to-refresh, no rubber-band or swipe-back on the shell, and
     the shell itself never scrolls (panels scroll internally). */
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-ui);
}

#app { height: 100%; overflow: hidden; }

/* Inner scroll containers keep their scrolling to themselves instead of chaining it to the page. */
* { overscroll-behavior: contain; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

code, pre, kbd, .mono { font-family: var(--font-mono); font-size: 12.5px; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ boot screen */

.boot {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.boot-logo {
  width: 48px;
  height: 48px;
  background: url(../assets/favicon.svg) center / contain no-repeat;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

/* ------------------------------------------------------------------ buttons, inputs */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { height: 24px; padding: 0 8px; font-size: 12px; }
.run-btn { gap: 4px; }
.run-btn svg { width: 12px; height: 12px; flex: none; }
.stop-btn { gap: 4px; }
.loops-line { font-size: 11px; }
.stop-btn svg { width: 12px; height: 12px; flex: none; }
.stop-btn:not(:disabled) { color: var(--danger); border-color: var(--danger); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

select, input[type="number"], input[type="text"] {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
input[type="number"] { width: 80px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
/* The dev server badge in the top bar (graphersal --server): DEV mode, unstable. */
.dev-badge { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
/* The MCP badge (graphersal --server --mcp): an AI agent may work on the same graph. */
.mcp-badge { font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; cursor: pointer; border: none; font-family: inherit; }
/* MCP usage: 150px wider than a plain dialog, so its tables fit without a horizontal scroll. */
dialog.mcp-stats-dialog { width: min(830px, calc(100% - 32px)); }
@media (min-width: 862px) { dialog.mcp-stats-dialog .dialog-body { overflow-x: hidden; } }
/* The Runs badge (graphersal --server --admin-runs) and its run administration dialog. */
.admin-runs-badge { font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; cursor: pointer; border: none; font-family: inherit; }
dialog.admin-runs-dialog { width: min(900px, calc(100% - 32px)); }
.admin-runs-token { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.admin-runs-text code { white-space: pre-wrap; word-break: break-word; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.brand::before {
  content: "";
  width: 22px;
  height: 22px;
  background: url(../assets/favicon.svg) center / contain no-repeat;
}
.brand small { color: var(--text-muted); font-weight: 500; }
.topbar .version-label {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* A path keeps its file or directory name: two grid columns, the directory part (may shrink to
   nothing, shortened from the LEFT: direction: rtl puts the ellipsis there, <bdi> keeps the
   path's own order) and the name (never shrinks below itself, so the header cannot squeeze it
   away; no overflow on the grid, or its minimum size would drop to 0). */
.topbar .graph-name {
  display: inline-grid;
  grid-template-columns: minmax(0, max-content) max-content;
  max-width: 260px;
  white-space: nowrap;
  font-weight: 600;
}
.topbar .graph-name-dir {
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
}
.topbar .graph-name-base {
  grid-column: 2;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* dropdown menus (details/summary based) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.menu-list.left { left: 0; right: auto; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .code { font-family: var(--font-mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }

/* The Store menu (dev server on a Store directory) and its dialog. */
.btn.danger { color: var(--danger); border-color: var(--danger); font-weight: 600; }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
.menu-title.store-title { display: flex; align-items: center; gap: 6px; }
.store-refresh { flex: none; font-size: 15px; text-transform: none; }
.store-refresh.busy { animation: store-spin 0.8s linear infinite; }
@keyframes store-spin { to { transform: rotate(360deg); } }
/* A running store action (runStoreTask): its button bold in the accent colour with an inline
   spinner and the elapsed time; it stays fully visible although it is disabled meanwhile. The
   Store button in the top bar shows it too (`store-busy`). */
.store-spinner {
  display: inline-block; flex: none; width: 0.9em; height: 0.9em; margin-right: 6px; vertical-align: -0.12em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: store-spin 0.8s linear infinite;
}
.store-running, .store-running:disabled, .menu-item.store-running:disabled {
  opacity: 1; color: var(--accent); font-weight: 700; border-color: var(--accent); cursor: progress;
}
.menu-item.store-running { background: var(--accent-soft); }
.store-elapsed { font-variant-numeric: tabular-nums; font-weight: 600; }
.btn.store-busy { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.btn.store-busy > span { font-variant-numeric: tabular-nums; }
.menu-item.store-verify-result { padding-top: 0; }
@media (prefers-reduced-motion: reduce) { .store-spinner { animation-duration: 2.4s; } }
.menu-item.store-block { cursor: default; display: block; line-height: 1.5; }
.menu-item.store-viewing { background: var(--accent-soft); }
.menu-item.store-viewing .btn { margin-top: 4px; }
.menu-item.store-row { cursor: default; display: block; }
.store-row-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.store-row-head small { color: var(--text-muted); }
.store-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.store-explain { padding: 0 8px 4px; color: var(--text-muted); font-size: 11.5px; line-height: 1.4; }
.menu-item .store-explain { padding: 2px 0 0; }
.store-view-banner .btn, .change-burst-banner .btn { margin-left: 8px; }
.store-dialog p { margin: 0 0 10px; font-size: 13px; line-height: 1.5; }
.store-choice { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 12.5px; }
.store-choice .btn { flex: none; min-width: 190px; justify-content: center; }
.store-check { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; font-size: 13px; cursor: pointer; }
.store-dialog-buttons { display: flex; gap: 8px; margin-top: 16px; }
.store-warn { color: var(--danger); font-weight: 600; }
.store-code { margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); white-space: pre-wrap; word-break: break-all; }
.store-error { display: block; height: auto; margin-top: 12px; padding: 6px 10px; white-space: pre-wrap; }
/* The store dialog: a column whose body scrolls in both directions (the changes table is wide:
   its cells never wrap or cut, the wrapper scrolls); wide for "Show changes", full screen on
   request. */
.store-dialog[open] { display: flex; flex-direction: column; }
.store-dialog .dialog-body { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; }
.store-dialog.wide { width: min(1100px, calc(100% - 32px)); }
.store-dialog.full { width: calc(100vw - 16px); height: calc(100vh - 16px); max-width: none; max-height: none; margin: 8px; }
.store-changes-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 6px; }
.store-dialog:not(.full) .store-changes-wrap { max-height: 60vh; }
.store-changes { width: auto; min-width: 100%; font-size: 12px; }
table.data-table.store-changes th, table.data-table.store-changes td { vertical-align: top; white-space: nowrap; max-width: none; overflow: visible; text-overflow: clip; }
.store-pager { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12.5px; }
.store-page { color: var(--text-muted); }
.store-volatile { color: var(--warn, var(--danger)); font-weight: 600; }
.menu-item.store-active-db { background: var(--accent-soft); }
.store-more { color: var(--accent); }
/* The history calendar (store-calendar.js): marks and snapshots per local day. Two badges per
   day (M: --warn, S: --accent), each deeper with its count (buckets 1-4); the cell background
   follows the total. The selected day's list sits beside the calendar (below it when narrow). */
.store-calendar { width: min(1100px, calc(100% - 32px)); }
.store-calendar[open] { height: min(760px, calc(100vh - 48px)); }
.cal-filter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; font-size: 12.5px; }
.cal-kind { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 16px; align-items: start; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-month { margin: 6px 0; font-size: 12.5px; }
.cal-grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.cal-grid th { padding: 2px 0; color: var(--text-faint); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.cal-grid td { padding: 0; }
.cal-day {
  display: flex; flex-direction: column; align-items: stretch; justify-content: space-between;
  width: 100%; height: 64px; padding: 4px 5px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.cal-day:hover { border-color: var(--border-strong); }
.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-day.out { opacity: .45; }
.cal-day.today .cal-num { color: var(--accent); font-weight: 700; text-decoration: underline; }
.cal-day.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-day.t1 { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.cal-day.t2 { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.cal-day.t3 { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.cal-day.t4 { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.cal-num { font-size: 12px; }
.cal-badges { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.cal-badge {
  display: inline-block; min-width: 18px; padding: 0 4px; border-radius: 8px;
  font-size: 10.5px; font-weight: 700; line-height: 15px; text-align: center; font-variant-numeric: tabular-nums;
}
.cal-badge.m1 { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--text); }
.cal-badge.m2 { background: color-mix(in srgb, var(--warn) 40%, var(--surface)); color: var(--text); }
.cal-badge.m3 { background: color-mix(in srgb, var(--warn) 70%, var(--surface)); color: var(--text); }
.cal-badge.m4 { background: var(--warn); color: var(--surface); }
.cal-badge.s1 { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--text); }
.cal-badge.s2 { background: color-mix(in srgb, var(--accent) 40%, var(--surface)); color: var(--text); }
.cal-badge.s3 { background: color-mix(in srgb, var(--accent) 70%, var(--surface)); color: var(--accent-contrast); }
.cal-badge.s4 { background: var(--accent); color: var(--accent-contrast); }
.cal-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
.cal-day-panel { min-width: 0; max-height: calc(min(760px, 100vh - 48px) - 150px); overflow: auto; padding-left: 12px; border-left: 1px solid var(--border); }
.cal-day-panel h3 { margin: 0 0 6px; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); }
.cal-day-panel .menu-title { padding: 8px 0 2px; }
.cal-row { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.cal-time { font-family: var(--font-mono); color: var(--text-muted); }
@media (max-width: 760px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-day { height: 48px; padding: 2px 3px; }
  .cal-day-panel { max-height: none; padding-left: 0; border-left: 0; border-top: 1px solid var(--border); padding-top: 8px; }
}
@media (max-width: 560px) {
  .store-choice { flex-direction: column; align-items: stretch; }
  .store-choice .btn { min-width: 0; }
}
.menu-title { padding: 4px 8px; color: var(--text-faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------------------------ start page */

.start {
  height: 100%;
  overflow: auto;
}
.start-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}
.start h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.01em; }
.start .lead { margin: 0 0 24px; max-width: 720px; color: var(--text-muted); font-size: 16px; }
/* The privacy promise of the WebAssembly playground: meant to be seen at first glance. */
.start .privacy {
  margin: 0 0 28px; max-width: 860px; padding: 16px 20px;
  border: 2px solid var(--ok); border-radius: var(--radius); background: var(--ok-soft);
}
.start .privacy h2 {
  margin: 0 0 8px; font-size: 20px; font-weight: 700; color: var(--ok);
  text-transform: none; letter-spacing: 0;
}
.start .privacy p { margin: 6px 0 0; font-size: 15px; line-height: 1.5; color: var(--text); }
.start h2 { margin: 32px 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.card:hover:not(.disabled) { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.card.disabled { cursor: not-allowed; opacity: .65; }
.card.dragover { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.card h3 { margin: 0; font-size: 16px; }
.card p { margin: 0; color: var(--text-muted); font-size: 13px; }
.card .card-foot { margin-top: auto; display: flex; gap: 6px; align-items: center; }
.card-icon { font-size: 22px; line-height: 1; }

.start .error-box { margin-top: 16px; }
.links { display: flex; flex-wrap: wrap; gap: 18px; }
.links .disabled { color: var(--text-faint); }
.start-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.note {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}
.note h4 { margin: 0 0 4px; font-size: 13.5px; }
.note p { margin: 0; color: var(--text-muted); }

/* ------------------------------------------------------------------ workspace layout */

.workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.ws-main {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 6px;
}
.ws-main.vertical { flex-direction: column; }
.ws-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.ws-main:not(.vertical) > .ws-col.only { flex: 1; }
.ws-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
}

/* UI profiles (js/ui-profiles.js): the tab row of a profile with several tabs, its module tabs
   (components/profile-tab.js) and the card of api.card (components/profile-card.js). */
.profile-nav {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  flex: none;
}
.profile-nav-tab {
  padding: 7px 12px 6px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-size: 13.5px;
}
.profile-nav-tab:hover { color: var(--text); }
.profile-nav-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.profile-tab {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
}
.profile-tab-error {
  max-width: 720px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--surface);
}
.profile-tab-error-head { margin: 0 0 6px; font-weight: 600; color: var(--danger); }
.profile-tab-error-msg { margin: 0 0 6px; white-space: pre-wrap; }
/* The profile's top-bar module (components/profile-header.js): it may shrink (min-width: 0), so
   the bar never overflows; the module hides parts of its own under its media queries
   (`hide-narrow` works inside it as everywhere in the top bar). */
.profile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}
.profile-header > * { min-width: 0; max-width: 100%; }
.profile-header-error {
  padding: 2px 8px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  color: var(--danger);
  font-size: 12px;
  white-space: nowrap;
  cursor: help;
}
.profile-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  margin: 0 0 8px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.profile-card.compact { padding: 7px 12px; }
.profile-card.openable { cursor: pointer; }
.profile-card.openable:hover { border-color: var(--border-strong); }
.profile-card.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.profile-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.profile-card-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; min-width: 0; color: var(--text); }
.profile-card.compact .profile-card-title { font-size: 13.5px; }
.profile-card-title.from-label { color: var(--text-muted); font-weight: 500; }
.profile-card-open {
  all: unset;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.profile-card-open:hover { color: var(--accent); }
.profile-card-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.profile-card-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.profile-card-badge {
  font-size: 11.5px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg);
  white-space: nowrap;
}
.profile-card-badge.tone-accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.profile-card-badge.tone-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.profile-card-badge.tone-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.profile-card-badge.tone-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.profile-card-subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.profile-card-excerpt {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-card-body { margin-top: 6px; min-width: 0; }
.profile-card-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 8px 0 0; }
.profile-card-fields dt { color: var(--text-muted); }
.profile-card-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.profile-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
/* The demo profile's Hello tab (js/profiles/demo/hello.js): a list of compact cards and the
   opened card beside it; one column when narrow. */
.demo-cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: start; max-width: 960px; }
.demo-cards-list, .demo-cards-open { min-width: 0; }
@media (max-width: 720px) { .demo-cards { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) {
  .profile-card-fields { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .profile-card-fields dd { margin-bottom: 4px; }
}
/* The graph view of a profile tab (components/profile-graph.js, `api.graph`): a toolbar, the
   drawing (the Graph panel's renderers) with the selected element's card beside it, a legend
   strip under it; the card goes under the drawing when narrow. */
.profile-graph { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.profile-graph-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.profile-graph-toolbar select { height: 24px; font-size: 12px; }
.profile-graph-counts { font-size: 12px; white-space: nowrap; }
.profile-graph-body { display: flex; gap: 10px; align-items: stretch; min-width: 0; }
.profile-graph-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.profile-graph-stage .cy-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.profile-graph-side { flex: 0 0 min(340px, 40%); min-width: 0; overflow: auto; }
.profile-graph-side-head { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.profile-graph-error {
  padding: 8px 12px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  background: var(--danger-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.profile-graph-note { margin: 0; font-size: 12px; }
.profile-graph-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-muted); }
.profile-graph-legend li { display: inline-flex; align-items: center; gap: 5px; }
.profile-graph-legend li.extra { font-style: italic; }
.profile-graph-swatch { flex: none; }
@media (max-width: 720px) {
  .profile-graph-body { flex-direction: column; }
  .profile-graph-side { flex: none; }
}
.boot.profile-error p { max-width: 640px; text-align: left; }

.gutter {
  flex: none;
  background: transparent;
  position: relative;
}
.gutter::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: var(--border);
  transition: background .1s;
}
.gutter:hover::after, .gutter:active::after { background: var(--accent); }
.gutter.gutter-horizontal { cursor: col-resize; }
.gutter.gutter-horizontal::after { top: 30%; bottom: 30%; left: 2px; right: 2px; }
.gutter.gutter-vertical { cursor: row-resize; }
.gutter.gutter-vertical::after { left: 30%; right: 30%; top: 2px; bottom: 2px; }

/* ------------------------------------------------------------------ panels */

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  container-type: inline-size; /* the header hides secondary items when the panel is narrow */
  min-height: var(--header-h);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.panel-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--header-h);
  padding: 0 4px 0 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  user-select: none;
}
.panel.collapsed .panel-header { border-bottom: 0; }
.panel-title.toggles { cursor: pointer; user-select: none; }
.panel-title {
  flex: 0 1 auto;
  min-width: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  white-space: nowrap;
}
.panel-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: auto;
}
.panel.collapsed .panel-body { display: none; }
/* Panel content fills the body exactly; inner parts scroll on their own. */
.fill { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.panel-actions { flex: none; display: flex; align-items: center; gap: 2px; margin-left: auto; }
.panel-actions .result-meta { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-wrap: nowrap; }
/* A narrow panel drops secondary header items instead of pushing its buttons out of view. */
@container (max-width: 520px) { .panel-header .secondary { display: none; } }
@container (max-width: 380px) { .panel-header .tabs .tab { padding: 0 6px; } }
/* A narrow panel (a phone): the header may grow to a second row, so no control is cut off. */
@container (max-width: 520px) {
  .panel-header { height: auto; flex-wrap: wrap; row-gap: 2px; padding: 3px 4px; }
  .panel-actions { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; row-gap: 2px; }
}
.panel-toolbar {
  flex: none;
  display: flex;
  flex-wrap: nowrap; /* Fit/Export never wrap: the controls scroll instead */
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.toolbar-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  white-space: nowrap;
}
.toolbar-main label { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.toolbar-end { flex: none; display: flex; align-items: center; gap: 6px; }
.info-tip { color: var(--text-faint); cursor: help; font-size: 14px; line-height: 1; padding: 0 2px; }
.info-tip:hover, .info-tip:focus-visible { color: var(--accent); outline: none; }
/* The Graph panel's toolbar (js/graph/toolbar.js): the panel measures the row and moves items into
   the Display menu, so it never scrolls or wraps; the gap is TOOLBAR_GAP. */
.graph-toolbar { overflow: hidden; min-height: 37px; } /* the same height with or without the Layout select */
.graph-toolbar .toolbar-main { gap: 6px; overflow: hidden; }
.tb-item { display: inline-flex; flex: none; }
/* The Layout select sizes to the chosen layout where the browser can, else it is capped. */
.graph-toolbar select { field-sizing: content; max-width: 13em; }
/* The Filter slot: a split button, "⚲ Filter · 2" opens the drawer, the switch on its right. */
.split-btn { display: inline-flex; flex: none; }
.split-btn .split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn .split-toggle { border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 6px; }
.split-btn .split-main.active { background: var(--accent-soft); color: var(--accent); }
.filter-badge { color: var(--accent); font-weight: 600; }
.split-btn.off .filter-badge, .split-btn.off .split-main { color: var(--text-faint); }
.switch-track { position: relative; display: inline-block; width: 22px; height: 12px; border-radius: 6px; background: var(--accent); }
.switch-knob { position: absolute; top: 2px; left: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); transition: left .12s; }
.split-btn.off .switch-track { background: var(--border); }
.split-btn.off .switch-knob { left: 2px; }
/* Display menu parts (also usable by other menus). */
.menu-row { padding: 4px 8px; }
.menu-note { padding: 0 8px 4px; color: var(--text-faint); font-size: 12px; line-height: 1.4; }
.menu-item.menu-indent { padding-left: 28px; }
.menu-item.menu-field { justify-content: space-between; cursor: default; }
.menu-item:disabled { opacity: .5; cursor: not-allowed; }
.menu-item:disabled:hover { background: none; }
.menu-help { margin: 0; padding: 2px 8px 6px 26px; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
.menu-help li + li { margin-top: 3px; }
.menu-list.popover {
  position: fixed;
  right: auto;
  z-index: var(--z-popover);
  max-width: calc(100vw - 16px);
}
.tabs { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 2px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; }
.tab {
  height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-3); color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 600; }

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.placeholder code { color: var(--text); }

/* ------------------------------------------------------------------ editor */

/* Query tabs: a strip above the editor. */
.qtabs {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 30px;
  padding: 3px 4px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.qtab-list { flex: 0 1 auto; min-width: 0; display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; scrollbar-width: thin; }
.qtab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 200px;
  height: 26px;
  padding: 0 4px 0 10px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.qtab:hover { background: var(--surface-3); color: var(--text); }
.qtab.active { background: var(--code-bg); border-color: var(--border); color: var(--text); font-weight: 600; margin-bottom: -1px; height: 27px; }
.qtab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.qtab-name { overflow: hidden; text-overflow: ellipsis; }
.qtab-input { width: 130px; height: 20px; padding: 0 4px; font: inherit; font-weight: 400; }
.qtab-stale { color: var(--warn); font-size: 10px; line-height: 1; }
.qtab .running-dot { flex: none; }
.qtab-close {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  visibility: hidden;
}
.qtab:hover .qtab-close, .qtab.active .qtab-close { visibility: visible; }
.qtab-close:hover { background: var(--surface-3); color: var(--text); }
.qtab-add { flex: none; font-size: 16px; }
.qtab.ai { color: var(--ai-accent); }
.qtab.ai.active { border-top: 2px solid var(--ai-accent); color: var(--text); }
.qtab-ai-mark { color: var(--ai-accent); font-size: 11px; line-height: 1; }

/* AI Chat tab (js/components/ai-chat.js) */
.ai-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--code-bg); }
.ai-chat-head {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 10px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted);
}
.ai-chat-badge { color: var(--ai-accent); font-weight: 600; }
.ai-chat-model { color: var(--text); }
.ai-chat-notice.remote { color: var(--warn); }
.ai-chat-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
/* Blocks inside the transcript (code blocks and tables that scroll sideways, tool results with a
   max-height) hand a vertical gesture on to the transcript once they cannot scroll further; the
   global `contain` would swallow it there. The transcript itself keeps `contain`. */
.ai-chat-list * { overscroll-behavior: auto; }
.ai-chat-empty, .ai-chat-off { font-size: 13px; line-height: 1.5; }
.ai-chat-off pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); padding: 6px 8px; border-radius: var(--radius); }
.chat-msg { max-width: 100%; min-width: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-msg.user {
  align-self: flex-end; max-width: 85%; white-space: pre-wrap; padding: 6px 10px;
  background: var(--ai-soft); border: 1px solid var(--ai-accent); border-radius: 10px 10px 2px 10px; color: var(--text);
}
.chat-msg.assistant { align-self: stretch; }
.chat-turn { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chat-steps { border: 1px dashed var(--border); border-radius: var(--radius); background: transparent; min-width: 0; }
.chat-steps.open { border-style: solid; background: var(--surface); }
.chat-steps-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; padding: 3px 8px;
  background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.chat-steps-toggle:hover { color: var(--text); }
.chat-steps-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chat-steps-chevron { flex: none; display: inline-block; transition: transform 0.12s; }
.chat-steps.open .chat-steps-chevron { transform: rotate(90deg); }
.chat-steps-toggle .running-dot { flex: none; }
.chat-steps-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-error .chat-steps-summary, .turn-stopped .chat-steps-summary, .turn-interrupted .chat-steps-summary { color: var(--warn); }
.chat-steps-body { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chat-msg.assistant.interim { color: var(--text-muted); font-size: 12.5px; }
.chat-answer { font-size: 13.5px; }
.chat-tool { border: 1px solid var(--border); border-left: 3px solid var(--ai-accent); border-radius: var(--radius); background: var(--surface); font-size: 12px; min-width: 0; }
.chat-tool.failed { border-left-color: var(--danger); }
.chat-tool > summary { cursor: pointer; padding: 4px 8px; display: flex; gap: 8px; align-items: baseline; min-width: 0; list-style: revert; }
.chat-tool > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chat-tool-name { font-weight: 600; flex: none; }
.chat-tool-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tool-summary.ok { color: var(--ok); }
.chat-tool-summary.err { color: var(--danger); }
.chat-tool-body { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chat-tool-body pre { margin: 0; padding: 6px 8px; background: var(--surface-2); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto; }
.chat-tool-actions { display: flex; gap: 6px; }
.chat-error { border: 1px solid var(--danger); background: var(--danger-soft); border-radius: var(--radius); padding: 6px 10px; font-size: 12.5px; }
.chat-error-message { color: var(--danger); font-weight: 600; overflow-wrap: anywhere; }
.chat-error-help { white-space: pre-wrap; color: var(--text); margin-top: 2px; overflow-wrap: anywhere; }
.chat-notice { font-size: 12px; color: var(--text-muted); font-style: italic; }
.chat-timing { font-size: 11px; color: var(--text-muted); margin: -2px 0 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chat-thinking { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ai-chat-input { flex: none; display: flex; gap: 6px; padding: 6px 8px 2px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-chat-input textarea { flex: 1; min-width: 0; resize: vertical; min-height: 38px; max-height: 40vh; font: inherit; font-size: 13px; padding: 6px 8px; }
.ai-chat-buttons { flex: none; display: flex; flex-direction: column; gap: 4px; }
.ai-chat-hint { flex: none; padding: 0 10px 4px; font-size: 11px; background: var(--surface); }

/* Markdown of an assistant answer (js/components/markdown-view.js) */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote { margin: 0 0 8px; }
.md ul, .md ol { padding-left: 22px; }
.md .md-h { margin: 10px 0 6px; font-size: 14px; }
.md h1.md-h { font-size: 16px; }
.md h2.md-h { font-size: 15px; }
.md blockquote { padding-left: 10px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.md a { color: var(--accent); }
.md .md-inline-code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 0 3px; border-radius: 3px; }
.md-code, .md-table { position: relative; margin: 0 0 8px; min-width: 0; }
.md-code pre { margin: 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; font-size: 12px; }
.md-code.query pre { border-left: 3px solid var(--ai-accent); }
.md-tools { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; align-items: center; opacity: 0; transition: opacity .1s; z-index: 1; }
.md-code:hover .md-tools, .md-code:focus-within .md-tools, .md-table:hover .md-tools, .md-table:focus-within .md-tools { opacity: 1; }
.md-lang { font-size: 10.5px; color: var(--text-faint); margin-right: 2px; }
.md-btn { padding: 1px 8px; }
.md-table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.md-table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.md-table table { border-collapse: collapse; font-size: 12.5px; }
.md-table th, .md-table td { padding: 4px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-2); font-weight: 600; }
.md-table tr:last-child td { border-bottom: 0; }
.menu-item .history-tab { margin-left: auto; flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }

.editor-host { height: 100%; }
.editor-host .cm-editor { height: 100%; background: var(--code-bg); color: var(--syn-var); }
.editor-host .cm-scroller { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.55; }
.editor-host .cm-editor.cm-focused { outline: none; }
/* A GQL tab: the error span the engine reported, and the Parameters field under the editor. */
.editor-host .cm-gql-error { text-decoration: wavy underline var(--danger); text-underline-offset: 3px; background: var(--danger-soft); }
.gql-params {
  flex: 0 1 auto;
  max-height: 45%; /* the editor keeps the larger part of a short panel */
  overflow: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 8px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
}
.gql-params-label { padding-top: 4px; color: var(--text-muted); font-weight: 600; }
.gql-params-input {
  width: 100%;
  min-height: 2.4em;
  max-height: 9em;
  resize: vertical;
  box-sizing: border-box;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--text);
  font-size: 12.5px;
}
.gql-params-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.gql-params-input.invalid { border-color: var(--danger); }
.gql-params-note { grid-column: 2 / 4; color: var(--text-muted); overflow-wrap: anywhere; }
.gql-params-note:empty { display: none; }
.gql-params-note.error { color: var(--danger); }
@container (max-width: 520px) {
  .gql-params { padding: 4px 8px; gap: 4px 6px; }
  .lang-switch .seg-btn { padding: 0 6px; }
  .gql-params .hide-narrow { display: none; }
}
.qtab-lang {
  flex: none;
  padding: 0 3px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 12px;
  letter-spacing: .03em;
}
/* The status bar stays ONE line at any width: the hints shrink (and then hide) first, the run
   status truncates with an ellipsis, the cursor position turns compact in a narrow panel (the
   .panel is the size container). */
.editor-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 24px;
  padding: 0 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}
.editor-status > * { min-width: 0; }
.editor-status .spacer { flex: 1 1 0; }
.editor-status .status-run { flex: 0 1 auto; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.editor-status .status-run .running-dot { flex: none; }
.editor-status .status-text, .editor-status .status-hints { overflow: hidden; text-overflow: ellipsis; }
.editor-status .status-hints { flex: 0 1000 auto; }
.editor-status .status-cursor { flex: none; }
.editor-status .cursor-short { display: none; }
@container (max-width: 640px) { .editor-status .status-hints { display: none; } }
@container (max-width: 520px) {
  .editor-status .cursor-long { display: none; }
  .editor-status .cursor-short { display: inline; }
}
.running-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse .8s ease-in-out infinite;
}

/* CodeMirror tooltips follow the app tokens (the editor theme sets structure only). They are
   fixed-position children of the body (or of the modal dialog of their editor, see
   js/editor/tooltips.js), above panels, gutters and menus. */
.cm-tooltip { z-index: calc(var(--z-popover) + 10) !important; }
.cm-tooltip { border: 1px solid var(--border) !important; border-radius: var(--radius); background: var(--surface) !important; color: var(--text); box-shadow: var(--shadow); }
.cm-tooltip-autocomplete ul li[aria-selected] { background: var(--accent) !important; color: var(--accent-contrast) !important; }
.cm-tooltip-autocomplete ul li[aria-selected] .cm-completionDetail { color: inherit; opacity: .85; }
.cm-completionDetail { color: var(--text-faint); font-style: normal !important; margin-left: 8px; }
.cm-completionInfo { max-width: 420px; padding: 8px 10px !important; }
.completion-doc h5 { margin: 0 0 4px; font: 600 12.5px var(--font-mono); }
.completion-doc .aliases { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.completion-doc .sigs { margin: 0 0 6px; padding: 0; list-style: none; font: 12px var(--font-mono); color: var(--text-muted); }
.completion-doc p { margin: 0 0 6px; font-size: 12.5px; white-space: pre-wrap; }
.completion-doc pre.example { margin: 0 0 6px; padding: 4px 6px; font: 12px var(--font-mono); white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border-radius: 4px; }
.completion-doc .cat { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.cm-completionIcon-method::after, .cm-completionIcon-function::after { content: "ƒ"; }

/* ------------------------------------------------------------------ results */

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.notice {
  flex: none;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
}
.notice.info { background: var(--accent-soft); color: var(--accent); }

.data-table-wrap { overflow: auto; height: 100%; }
table.data-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 12.5px;
}
.data-table th, .data-table td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
}
.data-table td.num { text-align: right; font-family: var(--font-mono); }
.data-table td.rownum { color: var(--text-faint); text-align: right; width: 1%; font-family: var(--font-mono); }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .cell-null { color: var(--text-faint); font-style: italic; }
.data-table .cell-json { font-family: var(--font-mono); color: var(--text-muted); }
.data-table .cell-vector summary { cursor: pointer; font-family: var(--font-mono); }
.data-table .cell-vector .mono { color: var(--text-muted); white-space: normal; }
.data-table .cell-str { color: var(--syn-string); }
/* Collapsed long values (components/value-text.js): the inspector and the result table. */
.inspector .value-text, .value-text.collapsible .value-body { white-space: pre-wrap; }
.value-tools { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; vertical-align: middle; white-space: nowrap; }
.value-toggle {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.4;
  padding: 0 5px;
  cursor: pointer;
}
.value-toggle:hover { background: var(--surface-3); }
.value-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.value-tools .icon-btn.value-copy { width: 20px; height: 20px; }
.value-tools .icon-btn.value-copy svg { width: 13px; height: 13px; }
.data-table .value-text.collapsible:not(.expanded) { display: inline-flex; align-items: baseline; max-width: 400px; }
.data-table .value-text.collapsible:not(.expanded) .value-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.data-table .value-text.collapsible.expanded { display: block; white-space: pre-wrap; word-break: break-word; min-width: 260px; }
.data-table .cell-bool { color: var(--syn-keyword); font-family: var(--font-mono); }

pre.code-view {
  margin: 0;
  padding: 10px 12px;
  min-height: 100%;
  background: var(--code-bg);
  color: var(--text);
  white-space: pre;
  tab-size: 2;
}
pre.code-view.wrap { white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------------------ statistics tab (Profile panel) */

.stats-view { flex: 1; min-height: 0; display: flex; flex-direction: column; font-size: 12.5px; }
.stats-title { font-weight: 600; }
.stats-body { flex: 1; overflow: auto; padding: 8px 10px 10px; min-height: 0; }
.stats-section h4 { margin: 10px 0 4px; font-size: 12.5px; }
.stats-section h4 .muted { font-weight: 400; }
.stats-section p { margin: 4px 0; }
.stats-tables { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.stats-tables .data-table { min-width: 0; }
.stats-section .data-table { min-width: 0; width: auto; }
.stats-section .data-table th { position: static; }
.stats-pair { display: inline-block; margin-right: 14px; white-space: nowrap; }

/* ------------------------------------------------------------------ error view */

.error-view {
  margin: 10px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-soft);
  overflow: hidden;
}
.error-view .error-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  color: var(--danger);
  font-weight: 600;
}
.error-view .error-head .msg { font-family: var(--font-mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.error-view .error-body { padding: 0 12px 12px; color: var(--text); }
.error-view .help {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface);
  white-space: pre-wrap;
  font-size: 13px;
}
.error-view .help-title { margin: 0 0 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.error-view .error-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 12px; }
.error-view .diagnostic { margin: 8px 0 0; }
.error-view .diagnostic summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }

/* ------------------------------------------------------------------ graph view */

.graph-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
/* The tier switch (Auto / Detailed / Fast): one bordered group of toggle buttons. */
.segmented { display: inline-flex; flex: none; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg-btn {
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn:first-child { border-left: 0; }
.seg-btn:hover:not(:disabled) { background: var(--surface-2); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg-btn:disabled { opacity: .5; cursor: not-allowed; }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tier-note { background: var(--surface-2); color: var(--text-muted); }
/* The drawing never scrolls and never makes the panel scroll: the renderers round their canvases to
   whole pixels (a 758.5 px host gets a 759 px canvas), and that half pixel reaching the panel body
   (overflow: auto) made classic scrollbars (Windows) appear and vanish in a loop while a notice
   took a fractional height (js/graph/resize-guard.js). */
.cy-host { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.cy-canvas { position: absolute; inset: 0; overflow: hidden; }
.graph-legend {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 60%;
  pointer-events: none;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  font-size: 11.5px;
}
.legend-swatch { width: 9px; height: 9px; border-radius: 50%; }
/* A layer's origins (js/graph/origin-style.js): a ring like the drawing's outline. */
.legend-ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--graph-edge); box-sizing: border-box; }
.legend-ring.origin-added { border-color: var(--origin-added); border-style: solid; }
.legend-ring.origin-modified { border-color: var(--origin-modified); border-style: dashed; }
.legend-ring.origin-base { border-color: transparent; background: var(--graph-edge); }
.inspector {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 3;
  width: min(300px, calc(100% - 16px));
  max-height: calc(100% - 16px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12.5px;
}
.inspector-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.inspector dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; padding: 8px 10px; }
.inspector dt { color: var(--text-muted); }
.inspector dd { margin: 0; font-family: var(--font-mono); word-break: break-word; }
.inspector-note { padding: 0 10px 8px; }
.graph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  text-align: center;
}

/* ------------------------------------------------------------------ schema / mermaid */

.mermaid-view {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.mermaid-view.dragging { cursor: grabbing; }
.pz-stage { position: absolute; left: 0; top: 0; will-change: transform; }
.pz-stage svg { display: block; }

/* Schema editor: a wrapping toolbar, the review, and one scroll area (the only place that
   scrolls sideways on a narrow screen). */
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.schema-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.schema-bar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.schema-bar-group label { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); }
.schema-bar-group.flow { margin-left: auto; }
.schema-review { flex: none; max-height: 45%; overflow: auto; font-size: 12.5px; }
.schema-review:empty { display: none; }
.schema-block, .schema-error, .schema-note, .schema-hint { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.schema-error { background: var(--danger-soft); color: var(--danger); }
.schema-error pre { margin: 4px 0 0; font: 12px/1.4 var(--font-mono); white-space: pre-wrap; word-break: break-word; }
.schema-note { color: var(--text-muted); }
.schema-hint { background: var(--warn-soft); color: var(--text); border-radius: var(--radius); margin: 6px 0 0; border: 0; }
.schema-hint .btn { margin-left: 6px; }
.schema-block-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.schema-list { margin: 4px 0 0; padding: 0; list-style: none; }
.schema-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0; }
.schema-list .kind { color: var(--text-muted); }
.schema-list code, .schema-chip { font: 11.5px var(--font-mono); }
.link-btn {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 100%;
  padding: 1px 4px; border: 0; border-radius: 4px; background: transparent; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
.link-btn:hover { background: var(--surface-3); }
.link-btn:focus-visible, .cell-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.schema-scroll { flex: 1; min-height: 0; overflow: auto; }
.schema-doc { padding: 6px 10px 16px; width: fit-content; min-width: 100%; }
.schema-section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 6px; }
.schema-section-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.schema-section-head form, .schema-table .add-row form { display: inline-flex; gap: 4px; align-items: center; }
.schema-empty { margin: 0 0 8px; font-size: 12.5px; }
.schema-settings { margin: 2px 0 4px; font-size: 12.5px; }
.schema-settings summary { cursor: pointer; color: var(--text-muted); padding: 2px 0; }
.schema-settings textarea { display: block; width: min(560px, 100%); margin-top: 4px; }
.schema-label { margin: 0 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.schema-label-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 6px; background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; font-size: 12.5px; }
.schema-label-head label { display: inline-flex; align-items: center; gap: 4px; }
.schema-label-head .label-name { font-weight: 700; width: 16ch; }
.schema-connections { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 5px 8px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.schema-connection { display: inline-flex; align-items: center; gap: 3px; }
.schema-label-body { padding: 0 0 2px; }
table.schema-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.schema-table th, .schema-table td { padding: 2px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.schema-table th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; background: var(--surface); }
.schema-table td.check { text-align: center; width: 1%; }
.schema-table td.actions, .schema-table th.actions { width: 1%; text-align: right; }
.schema-table td.constraints { white-space: normal; min-width: 120px; width: 100%; }
.schema-table td.constraints .schema-chip { padding: 0 5px; border-radius: 4px; background: var(--surface-3); color: var(--text); }
.schema-table tr.open > td { background: var(--accent-soft); }
.schema-table tr.prop-row.open { cursor: pointer; }
.schema-table .details-close { display: flex; justify-content: flex-end; padding: 4px 8px 0; }
.icon-btn.danger-hover:hover { color: var(--danger); }
.icon-btn svg { display: block; }
.schema-table .nested-row > td, .schema-table .details-row > td { padding: 2px 0 6px 18px; border-bottom: 1px solid var(--border); }
.schema-table .nested-row > td > .schema-table { border-left: 2px solid var(--border-strong); }
.schema-table .nested-toggle { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }
.schema-table .add-row td { border-bottom: 0; padding-top: 4px; }
.cell-input[type="text"] { border-color: transparent; background: transparent; width: 14ch; }
.cell-input[type="text"]:hover, .cell-input[type="text"]:focus { border-color: var(--border-strong); background: var(--surface); }
.cell-input.name { font-family: var(--font-mono); }
.schema-details { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 6px 8px; background: var(--surface-2); border-radius: var(--radius); white-space: normal; }
.schema-details fieldset { flex: 1 1 240px; display: grid; grid-template-columns: auto 1fr; align-content: start; gap: 4px 8px; align-items: center; margin: 0; padding: 4px 8px 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.schema-details legend { padding: 0 4px; color: var(--text-muted); font-size: 11.5px; font-weight: 600; }
.schema-details label { display: contents; }
.schema-details label > span { color: var(--text-muted); font-size: 12px; }
.schema-details label.check { display: flex; gap: 4px; align-items: center; grid-column: 1 / -1; }
.schema-details input[type="text"], .schema-details input[type="number"], .schema-details select, .schema-details textarea { width: 100%; min-width: 0; }
.schema-details .hint { grid-column: 1 / -1; margin: 0; color: var(--text-faint); font-size: 11.5px; }
textarea.code-input, .schema-details textarea {
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--text);
  font: 12.5px/1.45 var(--font-mono);
  resize: vertical;
}
.schema-details textarea { font-family: var(--font-ui); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input.invalid, textarea.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger); }
.field-error { padding: 4px 10px; color: var(--danger); background: var(--danger-soft); font-size: 12px; }
.schema-json { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.schema-json textarea { flex: 1; min-height: 0; width: 100%; border: 0; border-radius: 0; resize: none; padding: 10px 12px; white-space: pre; overflow: auto; }
.schema-json textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ------------------------------------------------------------------ profile */

.profile-table td.step { font-family: var(--font-mono); }
.profile-table td.step .indent { display: inline-block; }
.profile-table td.step .twisty { display: inline-block; width: 14px; color: var(--text-faint); cursor: pointer; }
.pct-cell { min-width: 120px; }
.pct-bar { position: relative; height: 14px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.pct-bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); opacity: .75; }
.pct-bar > em { position: relative; padding-left: 4px; font-style: normal; font-size: 11px; font-family: var(--font-mono); line-height: 14px; color: var(--text); }
.rules { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 12.5px; }
.profile-run {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.profile-run.stale { opacity: .8; }
.profile-script { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.profile-table tr.failed td { background: var(--danger-soft); }
.profile-table tr.failed-path td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.step-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 10px; font-size: 12.5px; }
.step-path code { padding: 1px 5px; border-radius: 4px; background: var(--surface); color: var(--text-muted); }
.step-path code.last { color: var(--danger); font-weight: 600; }
.step-path .sep { color: var(--text-faint); }
/* Query toolbar toggles (Profile / Memory) */
.toggle { display: inline-flex; align-items: center; gap: 3px; padding: 0 4px; font-size: 12px; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.toggle.off { opacity: .55; }
.profile-totals { display: flex; flex-wrap: wrap; gap: 14px; padding: 6px 10px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; }
.profile-totals b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }

/* ------------------------------------------------------------------ dialogs */

dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 15, 25, .45); }
.dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-body { padding: 14px 16px 18px; overflow: auto; }
/* Inside a dialog, scrolling chains outwards (a table that only scrolls sideways, a textarea or
   list at its end, a dialog body that does not overflow) up to the dialog itself, which keeps the
   global `contain` so nothing reaches the shell. */
dialog * { overscroll-behavior: auto; }
.dialog-body h3 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.dialog-body h3:first-child { margin-top: 0; }
.shortcuts { width: 100%; border-collapse: collapse; font-size: 13px; }
.shortcuts td { padding: 5px 4px; border-bottom: 1px solid var(--border); }
.shortcuts td:first-child { width: 45%; }
.form-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; font-size: 13px; }
.form-grid .hint { grid-column: 2; margin-top: -6px; color: var(--text-faint); font-size: 12px; }

/* ------------------------------------------------------------------ saved queries */

.saved-query-dialog { width: min(820px, calc(100% - 32px)); }
.saved-query-dialog .form-grid input[type="text"] { width: 100%; min-width: 0; }
.saved-query-dialog .form-grid textarea { width: 100%; min-width: 0; }
.saved-query-dialog .sq-span { grid-column: 2; margin-top: -6px; }
.saved-query-dialog .sq-language { justify-self: start; }
.sq-note { margin: 6px 0; font-size: 12px; }
.sq-preview { margin: 8px 0; padding: 6px 8px; border-radius: 6px; font-size: 13px; background: var(--warn-soft); color: var(--warn); }
.sq-description { margin: 0 0 10px; font-size: 13px; }
.sq-param { margin-bottom: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.sq-param.invalid { border-color: var(--danger); }
.sq-param-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.sq-param-row:last-of-type { margin-bottom: 0; }
.sq-param-name { width: 14ch; font-family: var(--font-mono); }
.sq-default { width: 22ch; }
.sq-small { width: 11ch; }
.sq-grow { flex: 1 1 200px; }
.sq-schema { width: 100%; margin-top: 4px; }
.sq-signature { padding: 2px 6px; color: var(--text-muted); font-size: 12.5px; }
.sq-editor { height: 200px; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.sq-editor.invalid { border-color: var(--danger); }
.sq-editor .cm-editor { height: 100%; }
.sq-buttons { display: flex; gap: 8px; margin-top: 16px; }
.sq-required { margin-left: 2px; color: var(--danger); }
.sq-error { color: var(--danger) !important; }
.sq-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

/* ------------------------------------------------------------------ the catalog managers */

.catalog-dialog { width: min(760px, calc(100% - 32px)); }
.catalog-dialog.wide { width: min(1100px, calc(100% - 32px)); }
.catalog-dialog .form-grid input[type="text"] { width: 100%; min-width: 0; }
.catalog-dialog .sq-span { grid-column: 2; margin-top: -6px; }
.catalog-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.catalog-row .sq-desc { flex: 1 1 160px; min-width: 0; }
.catalog-table-wrap { overflow-x: auto; }
table.data-table.catalog-table td, table.data-table.catalog-table th { white-space: nowrap; max-width: none; }
.catalog-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.cc-sub { font-size: 12px; }
/* The rules table never scrolls sideways: long names and paths wrap, details sit under them. */
table.data-table.catalog-table.cc-rules { min-width: 0; }
table.data-table.catalog-table.cc-rules td { white-space: normal; vertical-align: top; }
table.data-table.catalog-table.cc-rules .cc-rule { overflow-wrap: anywhere; min-width: 16ch; }
table.data-table.catalog-table.cc-rules td.num { white-space: nowrap; }
table.data-table.catalog-table.cc-rules td:has(> .catalog-actions) { width: 1%; }
.cc-rules .catalog-actions { justify-content: flex-end; flex-wrap: nowrap; }
.cc-rules .cc-check { width: 1%; padding-right: 0; }
.cc-rules th { position: static; }
.cc-group td { background: var(--surface-2, transparent); border-top: 1px solid var(--border); }
.cc-group-toggle { all: unset; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline; }
.cc-group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-group-by { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
@media (max-width: 1060px) {
  .cc-rules .cc-mid-hide { display: none; }
}
@media (max-width: 860px) {
  .cc-rules .cc-narrow-hide { display: none; }
  .cc-rules .cc-rule { min-width: 12ch; }
  .cc-rules .catalog-actions { flex-wrap: wrap; }
}
/* The System journal panel (js/components/journal.js): a scrolling table, messages wrap. */
.jl-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 6px 0 10px; font-size: 13px; }
.jl-filters input[type="text"] { width: 22ch; }
.catalog-dialog .jl-table { font-size: 13px; }
.catalog-table-wrap:has(> .jl-table) { max-height: 60vh; overflow-y: auto; }
table.data-table.catalog-table.jl-table td:nth-child(5) { white-space: normal; min-width: 30ch; }
.jl-fields { word-break: break-word; white-space: pre-wrap; }
.jl-time { font-variant-numeric: tabular-nums; }
table.data-table.catalog-table { width: 100%; }
table.data-table.catalog-table td .cc-reason { font-size: 12px; white-space: normal; min-width: 28ch; }
.cc-estimate { margin: 10px 0; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cc-estimate-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
table.cc-estimate-table tr.cc-best td { background: var(--ok-soft); }
.cc-tag { display: inline-block; padding: 0 5px; border-radius: 8px; font-size: 11px; background: var(--accent-soft); color: var(--accent); }
.cc-bar { display: inline-block; vertical-align: middle; width: 70px; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.cc-bar-fill { display: block; height: 100%; background: var(--ok); }

/* ------------------------------------------------------------------ toasts */

.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  max-width: 380px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.error { border-color: var(--danger); }
.toast.warn { border-color: var(--warn); }
.toast.success { border-color: var(--ok); }
.toast-action { margin-left: 8px; }

/* Journal notifications (components/journal-toasts.js): top right, below the top bar; never
   blocking: the stack itself lets clicks through, only the toasts take them. */
.journal-toasts {
  position: fixed; top: 54px; right: 14px; z-index: 110;
  display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}
.jt {
  position: relative; pointer-events: auto;
  border: 1px solid var(--border); border-left: 4px solid var(--text-faint); border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-size: 13px;
  animation: jt-in .18s ease-out;
}
.jt-error { border-left-color: var(--danger); background: var(--danger-soft); }
.jt-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.jt-notice { border-left-color: var(--accent); background: var(--accent-soft); }
.jt-info { border-left-color: var(--text-faint); }
.jt-debug { border-left-color: var(--border); }
.jt-body {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px 30px 8px 10px;
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.jt-body:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.jt-head { display: flex; align-items: baseline; gap: 6px; font-size: 11px; color: var(--text-muted); }
.jt-level { font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.jt-error .jt-level { color: var(--danger); }
.jt-warn .jt-level { color: var(--warn); }
.jt-notice .jt-level { color: var(--accent); }
.jt-kind { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jt-count { margin-left: auto; padding: 0 6px; border-radius: 8px; background: var(--surface-3); color: var(--text); }
.jt-message { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.jt-more .jt-body { color: var(--text-muted); }
/* The close cross shows on hover and keyboard focus; always on devices without hover. */
.jt-close {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 4px; background: transparent; color: var(--text-muted);
  font-size: 16px; line-height: 1; cursor: pointer; opacity: 0;
}
.jt:hover .jt-close, .jt:focus-within .jt-close { opacity: 1; }
.jt-close:hover { background: var(--surface-3); color: var(--text); }
.jt-close:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: 0; }
@media (hover: none) { .jt-close { opacity: 1; } }
@keyframes jt-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .jt { animation: none; } }
/* The System journal panel's row a notification opened. */
table.data-table.jl-table tr.jl-highlight td { background: var(--selection); }

/* ------------------------------------------------------------------ narrow screens */

@media (max-width: 760px) {
  .topbar .hide-narrow { display: none; }
  .start-inner { padding-top: 24px; }
  .start h1 { font-size: 24px; }
}

/* Graph panel view selector (GR4): the neighbourhood form, the inspector's action, a result row's action. */
.nb-form input[type="text"] { width: 10em; }
.inspector-actions { padding: 0 10px 8px; font-size: 12.5px; }
.data-table .row-action {
  margin-left: 4px;
  padding: 0 3px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
}
.data-table .row-action:hover, .data-table .row-action:focus-visible { color: var(--text); border-color: var(--text-muted); }

/* ------------------------------------------------------------------ the property editor */

.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; color: var(--text-muted); }
.inspector-edit { display: inline-flex; }
.element-editor { width: min(860px, calc(100% - 32px)); }
.element-editor[open] { display: flex; flex-direction: column; }
.element-editor .dialog-body { flex: 1 1 auto; min-height: 0; }
.ee-ident { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; margin: 0 0 6px; font-size: 13px; }
.ee-ident .mono { word-break: break-word; }
.ee-ident-note { font-size: 12px; }
.ee-note { margin: 4px 0; font-size: 12px; }
/* The property grid: one row per property, the columns name | type | value | actions shared by
   every row through subgrid; what does not fit a line (multi-line text, JSON, children) goes
   below, spanning name..value. */
.ee-grid {
  display: grid;
  grid-template-columns: minmax(120px, 28%) auto minmax(0, 1fr) auto;
  column-gap: 8px;
  margin: 6px 0;
}
.ee-empty { grid-column: 1 / -1; padding: 4px 0; }
.ee-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: 4px;
  align-items: center;
  position: relative;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.ee-row::before { content: ""; position: absolute; left: -9px; top: 5px; bottom: 5px; width: 3px; border-radius: 2px; background: transparent; }
.ee-row.changed::before { background: var(--accent); }
.ee-row.invalid::before { background: var(--danger); }
.ee-row.removed > :not(.ve-actions) { opacity: .6; }
.ee-row.removed .ee-key { text-decoration: line-through; }
.ee-add-row { border-bottom: 0; padding-top: 8px; }
.ee-name { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 4px; min-width: 0; }
.ee-key, .ee-new-key { flex: 1 1 auto; width: 100%; min-width: 0; }
.ee-row > .ve-in-row { display: contents; }
.ee-row > .ve-type, .ee-row > .ve > .ve-type { grid-column: 2; grid-row: 1; }
.ee-row > .ve-value, .ee-row > .ve > .ve-value { grid-column: 3; grid-row: 1; }
.ee-row > .ve-actions, .ee-row > .ve > .ve-actions { grid-column: 4; grid-row: 1; }
.ee-row > .ve > .ve-below { grid-column: 1 / 4; }
.ee-row > .ve > .ve-under-value { grid-column: 3 / 4; margin-top: 0; }
.ee-removed-note { grid-column: 2 / 4; grid-row: 1; font-size: 12px; }
.ee-under { grid-column: 2 / 4; margin-top: 0; }
.ee-hint { font-size: 12px; }
.ee-declared { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; font-size: 12.5px; }
.ee-json { align-self: center; }
.ee-raw textarea, .ve-raw textarea { width: 100%; min-width: 0; resize: vertical; font-size: 12.5px; }
.ee-status { align-self: center; font-size: 12px; }
/* One value: type | value | actions on a line, the rest below (a nested value's own small grid). */
.ve { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 6px; align-items: center; }
.ve-type { grid-column: 1; grid-row: 1; min-width: 0; }
.ve-value { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.ve-actions { grid-column: 3; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.ve-below { grid-column: 1 / -1; }
.ve-under-value { grid-column: 2 / 3; }
.ve-input { flex: 1 1 auto; width: 100%; min-width: 0; }
.ve-input.invalid { box-shadow: 0 0 0 1px var(--danger); }
textarea.ve-text { min-height: 4.5em; resize: vertical; font-family: var(--font-mono); font-size: 12.5px; }
.ve-bool, .ve-toggle, .ve-note { font-size: 12.5px; }
.ve-bool { display: inline-flex; align-items: center; gap: 4px; }
input.ve-null { color: var(--text-muted); }
.ve-toggle { text-decoration: none; font-family: var(--font-mono); }
.ve-small { width: 24px; height: 24px; font-size: 12px; flex: none; }
.ve-error { margin-top: 3px; color: var(--danger); font-size: 12px; }
.ve-raw-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; }
.ve-children { margin: 0 0 2px 10px; padding-left: 8px; border-left: 2px solid var(--border); }
.ve-child { display: flex; align-items: flex-start; gap: 6px; margin: 4px 0; }
.ve-child > .ve { flex: 1 1 auto; }
.ve-child > .ve-key { width: 14ch; flex: none; align-self: center; }
.ve-add { margin-top: 2px; }
/* A narrow dialog: a property takes two lines, name + actions above, type + value below. */
@media (max-width: 560px) {
  .ee-grid { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ee-name { grid-column: 1 / 3; }
  .ee-row > .ve-actions, .ee-row > .ve > .ve-actions { grid-column: 3; grid-row: 1; }
  .ee-row > .ve-type, .ee-row > .ve > .ve-type { grid-column: 1; grid-row: 2; }
  .ee-row > .ve-value, .ee-row > .ve > .ve-value { grid-column: 2 / 4; grid-row: 2; }
  .ee-removed-note { grid-column: 1 / 3; grid-row: 2; }
  .ee-row > .ve > .ve-below, .ee-row > .ve > .ve-under-value, .ee-under { grid-column: 1 / -1; }
  .ve-child > .ve-key { width: 10ch; }
}

/* ------------------------------------------------------------------ the Graph panel's edit mode */

.cy-host .graph-empty { pointer-events: none; }
.cy-canvas:focus { outline: none; }
.cy-canvas.graph-editing:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cy-canvas.graph-editing { cursor: crosshair; }
.graph-band { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; overflow: visible; }
.graph-band line { stroke: var(--graph-selected); stroke-width: 2; stroke-dasharray: 6 4; }
.graph-edit-note { position: absolute; left: 8px; bottom: 8px; z-index: 3; max-width: calc(100% - 16px); margin: 0; }
.edit-toggle.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.edit-hint { background: var(--accent-soft); }
.icon-btn.danger:not(:disabled) { color: var(--danger); }
.inspector-confirm { margin: 8px 10px 0; padding: 8px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--danger-soft); }
.inspector-confirm > div { margin-top: 4px; }
.inspector-confirm-buttons { display: flex; gap: 6px; }
.ee-new { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 6px; }
.ee-new-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ee-new-field input[list] { width: 22ch; }
.ee-label-note { font-size: 12px; }

/* Share as link (components/share-dialog.js) */
.share-dialog p { margin: 0 0 10px; }
.share-dialog .share-note { padding: 8px 10px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.share-dialog .share-error { display: block; height: auto; padding: 6px 10px; white-space: normal; }
.share-dialog .share-url { width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: 11.5px; resize: vertical; word-break: break-all; }
.share-dialog .share-run { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
/* The top bar's Share button: its own colour, so it is found (sharing links spreads the project). */
.btn.share-btn { gap: 5px; background: var(--ok); border-color: var(--ok); color: var(--ok-soft); font-weight: 600; }
.btn.share-btn:hover:not(:disabled) { background: var(--ok); filter: brightness(1.1); }
.btn.share-btn svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

/* The Examples panel (components/examples-panel.js): an overlay drawer below the Examples button,
   over the editor and results (it never moves the layout); full width on narrow screens. */
.examples-panel {
  position: fixed;
  z-index: var(--z-popover);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow), 0 12px 32px rgba(20, 30, 50, .14);
  animation: ex-slide-in .14s ease-out;
}
@keyframes ex-slide-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .examples-panel { animation: none; } }
@media (max-width: 639.98px) { .examples-panel { border-radius: 0; border-left: 0; border-right: 0; } }
.ex-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border); }
.ex-search {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.ex-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.ex-count { flex: none; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ex-close { flex: none; width: 26px; height: 26px; border: 0; border-radius: 5px; background: none; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer; }
.ex-close:hover { background: var(--surface-2); color: var(--text); }
.ex-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 10px; }
.ex-empty { padding: 14px 8px; font-size: 13px; }
.ex-group + .ex-group { margin-top: 6px; }
/* Group and subgroup headers are bars on a grey background in the text colour, so they stand out
   from the plain example rows they collapse. */
.ex-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 2px 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.ex-toggle.sub { width: calc(100% - 12px); margin-left: 12px; background: var(--surface-2); text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; }
.ex-toggle:hover:not(:disabled) { background: var(--border-strong); color: var(--text); }
.ex-toggle:disabled { cursor: default; }
.ex-toggle:disabled .ex-caret { visibility: hidden; }
.ex-caret { visibility: hidden; }
.ex-caret { flex: none; width: 12px; font-size: 11px; }
.ex-group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-n { flex: none; margin-left: auto; font-weight: 400; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ex-sub .ex-item { padding-left: 32px; }
.ex-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 5px 8px 5px 22px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.ex-item:hover { background: var(--surface-2); }
.ex-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ex-item.last { border-left-color: var(--accent); background: var(--accent-soft); }
.ex-item.ex-action { color: var(--text-muted); font-style: italic; }
.ex-title { min-width: 0; }
.ex-last { margin-left: 6px; padding: 0 5px; border-radius: 3px; background: var(--accent); color: var(--accent-contrast); font-size: 10.5px; font-style: normal; vertical-align: 1px; white-space: nowrap; }
.ex-snippet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 11.5px; }
.examples-panel mark { padding: 0 1px; border-radius: 2px; background: var(--warn-soft); color: var(--warn); font-weight: 700; }

/* The Graph panel's filter popover (components/graph-filter.js): an overlay anchored under the
   toolbar's Filter button, at the LEFT edge of the panel (its top and max-height are set by the
   panel from the measured toolbar), so it opens next to the button also when the panel is
   maximized and never moves the layout. The inspector sits at the right (`.inspector`, at most
   300 px + 8 px margin): the popover narrows from 340 px down to 280 px to leave room for it, and
   only a panel narrower than about 600 px lets the popover (the open dialog) cover the
   inspector until it is closed. Its height follows the content up to the space below the toolbar. */
.filter-drawer {
  position: absolute;
  left: 8px;
  top: 34px;
  max-height: calc(100% - 42px);
  z-index: 5; /* above the drawing, the legend and the inspector */
  display: flex;
  flex-direction: column;
  width: min(calc(100% - 16px), max(280px, min(340px, calc(100% - 324px))));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow), 0 8px 24px rgba(20, 30, 50, .14);
  font-size: 12.5px;
  animation: fd-drop-in .12s ease-out;
}
@keyframes fd-drop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .filter-drawer { animation: none; } }
.fd-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.fd-title { font-weight: 600; }
.fd-switch { display: inline-flex; align-items: center; gap: 5px; }
.fd-switch.off .switch-track { background: var(--border); }
.fd-switch.off .switch-knob { left: 2px; }
.fd-mode { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
/* The vertex label's colour (graph-filter.js): a fixed 10 px square column between the checkbox
   and the name, so the names line up; decorative (aria-hidden). Filled = shown, a ring of the
   same colour = hidden, a dashed neutral outline = no colour yet (never drawn in this page). */
.fd-swatch {
  flex: none;
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--sw, var(--border));
  background: var(--sw, transparent);
}
.fd-swatch.hollow { background: transparent; opacity: .75; }
.fd-swatch.unassigned { border: 1px dashed var(--text-muted); background: transparent; }
.fd-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 8px; }
.fd-loading, .fd-empty { padding: 6px 10px; }
.fd-side { padding: 4px 0; }
.fd-side + .fd-side { border-top: 1px solid var(--border); }
.fd-side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 10px; }
.fd-side-title { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.fd-all { font-size: 11.5px; }
.fd-label { padding: 1px 10px 3px; }
.fd-label-line { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.fd-label.off .fd-label-name { color: var(--text-faint); }
.fd-label-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-count { font-variant-numeric: tabular-nums; }
.fd-cond { margin: 3px 0 0 22px; }
.fd-cond-line { display: flex; align-items: center; gap: 4px; }
.fd-cond input, .fd-cond select {
  height: 24px; min-width: 0; padding: 0 5px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 12px;
}
.fd-key { width: 82px; flex: none; }
.fd-op { flex: none; max-width: 96px; }
.fd-value { flex: 1; width: 60px; }
.fd-value.half { width: 40px; }
.fd-cond.has-problem input, .fd-cond.has-problem select { border-color: var(--danger); }
.fd-remove { flex: none; width: 22px; height: 22px; border: 0; border-radius: 4px; background: none; color: var(--text-muted); cursor: pointer; }
.fd-remove:hover { background: var(--surface-2); color: var(--danger); }
.fd-type { margin-top: 1px; font-size: 11px; }
.fd-problem { margin-top: 2px; color: var(--danger); font-size: 11.5px; line-height: 1.35; overflow-wrap: anywhere; }
.fd-add { margin: 3px 0 0 22px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }
.fd-add:hover { text-decoration: underline; }
.fd-isolated { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.fd-foot { flex: none; padding: 6px 10px; border-top: 1px solid var(--border); }
.filtered-strip a { font-weight: 600; }
.fd-partial { margin: 0 10px 4px; border: 0; border-radius: 5px; font-size: 11.5px; line-height: 1.4; }

/* The Optimize panel (js/components/optimize.js). */
.optimize-dialog .dialog-head { gap: 12px; flex-wrap: wrap; }
.op-tabs { display: inline-flex; gap: 2px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.op-tabs button { border: 0; background: transparent; color: var(--text-muted); padding: 4px 10px; border-radius: 4px; cursor: pointer; font: inherit; }
.op-tabs button.active { background: var(--accent-soft); color: var(--accent); }
.op-tabs.small { margin: 8px 0; }
.op-tabs.small button { padding: 3px 8px; font-size: 12px; }
.op-bar { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.op-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.op-note { display: flex; align-items: center; gap: 12px; margin: 8px 0; padding: 8px 12px; font-size: 13px; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 8px; }
.op-note .btn { flex: none; }
.op-rec { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.op-rec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.op-rec-line { margin-top: 4px; font-size: 13px; }
.op-groups { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0; font-size: 13px; }
.op-selection { position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 4px 0; }
.op-rec-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.op-command { font-size: 12px; background: var(--accent-soft); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.op-effect { font-size: 13px; font-weight: 600; }
.op-effect.good { color: var(--ok); }
.op-effect.cost { color: var(--warn); }
/* The impact badge: what a recommendation is worth (high stands out, low recedes). */
.op-impact.high { background: var(--accent-soft); color: var(--accent); }
.op-impact.low { opacity: 0.7; }
.op-effect .muted { font-weight: 400; }
.op-table .op-row { cursor: pointer; }
.op-table .op-row.selected td { background: var(--accent-soft); }
.optimize-dialog.catalog-dialog.wide { width: min(1400px, calc(100% - 32px)); }
.op-table { table-layout: fixed; width: 100%; }
.op-table .op-col-channel { width: 100px; }
.op-table .op-col-n { width: 76px; }
.op-table .op-col-t { width: 88px; }
.op-table .op-col-spark { width: 140px; }
.op-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-full { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; padding: 6px 8px; margin-bottom: 6px; background: var(--accent-soft); border-radius: 4px; }
.op-sort { cursor: pointer; user-select: none; }
.op-sort.active { color: var(--accent); }
.op-sort.active.desc::after { content: ' ▾'; }
.op-sort.active.asc::after { content: ' ▴'; }
.op-spark { display: block; }
.op-spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.op-chart { width: 100%; height: 160px; display: block; }
.op-bars rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 0.5; }
.op-bars rect.failed { fill: var(--danger-soft); stroke: var(--danger); }
.op-line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.op-line.mean { stroke: var(--ok); }
.op-line.max { stroke: var(--warn); stroke-dasharray: 4 3; }
.op-legend { display: flex; gap: 14px; font-size: 12px; flex-wrap: wrap; margin-top: 4px; }
.op-legend .sw { display: inline-block; width: 12px; height: 8px; margin-right: 4px; vertical-align: middle; }
.op-legend .sw.bars { background: var(--accent-soft); border: 1px solid var(--accent); }
.op-legend .sw.failed { background: var(--danger-soft); border: 1px solid var(--danger); }
.op-legend .sw.mean { border-top: 2px solid var(--ok); height: 0; }
.op-legend .sw.max { border-top: 2px dashed var(--warn); height: 0; }
.op-totals { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.op-total { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; min-width: 120px; font-size: 13px; }
/* The Scheduled jobs manager (js/components/catalog.js JobsManager): one full-width block per
   job that grows downwards (head with the actions, description, what it does, facts), never
   sideways: long names, texts and paths wrap. */
.cj-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); font-size: 13px; }
.cj-job { display: flex; flex-direction: column; gap: 3px; padding: 8px 2px; border-bottom: 1px solid var(--border); min-width: 0; }
.cj-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.cj-running { display: inline-flex; align-items: center; gap: 4px; }
.cj-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.cj-head .catalog-actions { justify-content: flex-end; margin-left: auto; }
.cj-text { overflow-wrap: anywhere; min-width: 0; }
.cj-label { color: var(--text-muted); font-size: 12px; }
.cj-label::after { content: ":"; }
.cj-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 18px; overflow-wrap: anywhere; min-width: 0; }
.cj-facts .num { font-family: var(--font-mono); }
.cj-facts .field-error { padding: 1px 6px; border-radius: var(--radius); }
.cj-on { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.cj-schedule { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.op-applied { background: var(--ok-soft); }
.op-dismissed { margin-top: 10px; }
.op-dismissed summary { cursor: pointer; color: var(--text-muted); }

/* The process memory bar (components/memory-bar.js): Statistics tab and Optimize -> Memory. */
.mem-bar { margin: 6px 0 10px; max-width: 720px; min-width: 0; }
.mem-bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.mem-bar-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.mem-bar-pct.mem-normal { color: var(--ok); }
.mem-bar-pct.mem-amber { color: var(--warn); }
.mem-bar-pct.mem-red { color: var(--danger); }
.mem-bar-track { display: flex; height: 12px; margin: 4px 0; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.mem-bar-seg { display: block; height: 100%; flex: none; }
.mem-bar-seg + .mem-bar-seg { box-shadow: inset 1px 0 0 var(--surface); }
.mem-bar-legend { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.mem-bar-legend li { white-space: nowrap; }
.mem-bar-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.mem-bar-note { margin: 2px 0; font-size: 12px; }
.profile-peak.mem-amber b { color: var(--warn); }
.profile-peak.mem-red b { color: var(--danger); }

/* The shared base of a layer beside the process memory bar (components/memory-bar.js): striped,
   so it does not read as one of the bar's segments. */
.mem-bar-shared { display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; font-size: 12.5px; }
.mem-bar-shared-track { flex: 1; height: 8px; border: 1px dashed var(--border); border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.mem-bar-shared-fill, .mem-bar-swatch.shared { background: repeating-linear-gradient(135deg, var(--mem-shared) 0 3px, transparent 3px 6px); }
.mem-bar-shared-fill { display: block; height: 100%; }

/* Layered graphs: the top-bar badge (components/layer-diff.js) and the Layer changes dialog. */
.layer-badge { cursor: pointer; border: 1px solid var(--origin-added); color: var(--text); background: var(--surface); font: inherit; font-size: 12px; }
.layer-badge:hover { background: var(--surface-2); }
.layer-counts { font-variant-numeric: tabular-nums; }
.layer-count.added { color: var(--origin-added); }
.layer-count.modified { color: var(--origin-modified); }
.layer-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.layer-filters { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 6px 0 10px; }
.layer-filters label { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; }
.layer-filters input[type="text"] { min-width: 0; width: 180px; }
.layer-group h3 { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 14px; }
.layer-mark { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--graph-edge); box-sizing: border-box; }
.layer-mark.added { border-color: var(--origin-added); }
.layer-mark.modified { border-color: var(--origin-modified); border-style: dashed; }
.layer-mark.removed { border-color: var(--danger); background: linear-gradient(135deg, transparent 40%, var(--danger) 40% 60%, transparent 60%); }
.layer-entries { list-style: none; margin: 0; padding: 0; }
.layer-entry { padding: 4px 6px; border-bottom: 1px solid var(--border); min-width: 0; }
.layer-entry-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.layer-entry-head button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.layer-entry-head button.link:hover { text-decoration: underline; }
.layer-props { display: grid; grid-template-columns: minmax(80px, max-content) 1fr; gap: 1px 10px; margin: 3px 0 0; font-size: 12.5px; }
.layer-props dt { color: var(--text-muted); font-family: var(--font-mono); overflow-wrap: anywhere; }
.layer-props dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.layer-props .was { color: var(--text-muted); text-decoration: line-through; }
.layer-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }

/* Server mode (js/server-mode.js): the database badge in the top bar links home (`/api/info` `home`). */
.db-badge a { color: inherit; text-decoration: none; }
.db-badge a:hover { text-decoration: underline; }
