/* ============================================================
   structam.sh demo: configuration version control (js/demos/configs.js).
   The host page's Configs tab (web/src/pages/host/Configs.tsx, app.css
   "Configuration version control": .cfg-*) and the Config variants page
   (pages/ConfigVariants.tsx). Sizes are the product's px; every caption
   size of 13px or less is max(<px>, var(--sx-fmin, 0px)).
   Layout per tier: the tree beside the detail on wide apps (the product's
   .cfg-layout), stacked above it under 800px of app (the product stacks
   under 1100px of viewport). The page is a fixed viewport that configs.js
   scrolls with a transform.
   ============================================================ */

.cf-demo .app { --sx-h: 540px; }
.cf-demo .cf-viewport { height: 100%; overflow: hidden; }
.cf-demo .cf-page, .cf-demo .cf-vpage { will-change: transform; }
.cf-demo .cf-host-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: max(13px, var(--sx-fmin, 0px)); }

/* Head row: the summary, Export…, Baselines */
.cf-demo .cf-head { gap: 8px; }
.cf-demo .cf-summary { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--sx-ink-muted); font-size: max(13px, var(--sx-fmin, 0px)); }
.cf-demo .cf-at { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.cf-demo .cf-linklike { display: inline-flex; }

/* Tree | detail */
.cf-demo .cf-layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.cf-demo .cf-tree-col { position: relative; z-index: 1; min-width: 0; will-change: transform; }
.cf-demo .cf-detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Files panel (.cfg-files, .cfg-filters, .cfg-tree-tools, .cfg-tree) */
.cf-demo .cf-files { display: flex; flex-direction: column; overflow: hidden; }
.cf-demo .cf-filters { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 1px solid var(--sx-line); }
.cf-demo .cf-search { width: 100%; }
.cf-demo .cf-selects { gap: 8px; }
.cf-demo .cf-selects .sx-select { min-width: 0; flex: 1 1 140px; gap: 8px; }
.cf-demo .cf-selects .sx-select > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-demo .cf-tools { display: flex; align-items: center; gap: 12px; padding: 6px 12px; border-bottom: 1px solid var(--sx-line); }
.cf-demo .cf-check { display: inline-flex; align-items: center; gap: 8px; }
.cf-demo .cf-tree { padding: 4px 0; }
.cf-demo .cf-row {
  display: flex; align-items: center; gap: 4px;
  padding-left: calc(8px + var(--depth, 0) * 16px); padding-right: 8px;
}
.cf-demo .cf-row.is-file > .sx-check-box { margin-right: 2px; }
.cf-demo .cf-row.is-sel { background: var(--sx-surface-overlay); box-shadow: inset 3px 0 0 var(--sx-brand-text); }
.cf-demo .cf-btn {
  display: flex; flex: 1; align-items: center; gap: 6px; min-width: 0; min-height: 30px; padding: 0 4px;
  color: var(--sx-ink); font: 400 max(13px, var(--sx-fmin, 0px))/18px var(--sx-sans);
}
.cf-demo .cf-btn.is-hover { background: var(--sx-surface-overlay); border-radius: 4px; }
.cf-demo .is-dir .cf-btn { color: var(--sx-ink-muted); }
.cf-demo .cf-chev { display: inline-flex; transform: rotate(90deg); }
.cf-demo .cf-meta { display: inline-flex; flex: none; align-items: center; gap: 6px; margin-left: auto; }
.cf-demo .cf-foot { border-top: 1px solid var(--sx-line); }

/* Detail: file panel, version history, viewer */
.cf-demo .cf-file-head { align-items: center; }
.cf-demo .cf-title { gap: 8px; }
.cf-demo .cf-path { overflow-wrap: anywhere; }
.cf-demo .cf-aside { gap: 8px; }
.cf-demo .cf-kv { gap: 6px 12px; }
.cf-demo .cf-ph { padding: 14px 16px 12px; align-items: center; }
.cf-demo .cf-vt { font-size: max(13px, var(--sx-fmin, 0px)); }
.cf-demo .cf-vt .sx-td { padding-top: 7px; padding-bottom: 7px; }
.cf-demo .cf-vmarks { gap: 6px; }
.cf-demo .cf-obs-at { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-demo .cf-modes { justify-content: space-between; gap: 8px; }
.cf-demo .cf-seg { flex-wrap: wrap; }
.cf-demo .cf-seg > .cf-at { height: auto; padding: 0; }
.cf-demo .cf-seg .cf-at > span { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 6px; font: 500 max(13px, var(--sx-fmin, 0px))/20px var(--sx-sans); color: var(--sx-ink-subtle); white-space: nowrap; }
.cf-demo .cf-seg .cf-at > span.is-on { background: var(--sx-surface-overlay); color: var(--sx-ink); }
.cf-demo .cf-seg > span.is-disabled { opacity: .45; }
.cf-demo .cf-vbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cf-demo .cf-code {
  display: grid; grid-template-columns: auto minmax(0, 1fr); overflow: hidden;
  border: 1px solid var(--sx-line); border-radius: 8px; background: var(--sx-surface);
  font: 400 max(12px, var(--sx-fmin, 0px))/18px var(--sx-mono);
}
.cf-demo .cf-gutter, .cf-demo .cf-text { padding: 8px 12px; white-space: pre; }
.cf-demo .cf-gutter { border-right: 1px solid var(--sx-line); color: var(--sx-ink-subtle); text-align: right; }
.cf-demo .cf-text { overflow: hidden; }
/* Long diff lines wrap instead of ending in an ellipsis (the product scrolls them sideways): the
   redacted token must stay readable at every width. */
.cf-demo .app .sx-dl > span:last-child { white-space: pre-wrap; overflow-wrap: anywhere; text-overflow: clip; }
.cf-demo .cf-add { color: var(--sx-ok); }
.cf-demo .cf-del { color: var(--sx-crit); }
.cf-demo .cf-empty { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; font-size: max(13px, var(--sx-fmin, 0px)); }
.cf-demo .cf-empty-t { font-weight: 600; color: var(--sx-ink); }

/* The confirm dialog (ui.tsx ConfirmDialog, base.css .dialog) */
/* The dialog region is a child of the shell's grid: keep it out of the grid flow. */
.cf-demo .cf-overlay { display: contents; }
.cf-demo .cf-scrim { z-index: 30; }
.cf-demo .cf-dlg-wrap { position: absolute; inset: 0; z-index: 31; display: flex; align-items: center; justify-content: center; padding: 16px; }
.cf-demo .cf-dlg {
  display: flex; flex-direction: column; width: min(520px, 100%);
  background: var(--sx-surface-raised); border: 1px solid var(--sx-line); border-radius: 12px; box-shadow: var(--sx-shadow-md);
}
.cf-demo .cf-dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--sx-line); }
.cf-demo .cf-dlg-title { font: 600 18px/24px var(--sx-sans); color: var(--sx-ink); }
.cf-demo .cf-dlg-body { padding: 20px 24px; color: var(--sx-ink); font-size: 14px; line-height: 22px; }
.cf-demo .cf-dlg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--sx-line); }

/* Config variants (.cfg-search, .cfg-variant-*, .cfg-share) */
.cf-demo .cf-search-row { display: flex; gap: 8px; }
.cf-demo .cf-input { flex: 1; width: auto; }
.cf-demo .cf-code-i { font: 400 max(12px, var(--sx-fmin, 0px))/16px var(--sx-mono); color: var(--sx-ink-muted); }
.cf-demo .cf-vsum { margin: 0; padding: 0 16px 12px; color: var(--sx-ink-muted); font-size: 14px; }
.cf-demo .cf-var-t { font-size: max(13px, var(--sx-fmin, 0px)); }
.cf-demo .cf-vname {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 4px;
  border: 1px solid var(--sx-line-strong); border-radius: 4px; font-weight: 500;
}
.cf-demo .cf-share { display: inline-block; width: 72px; height: 6px; overflow: hidden; border-radius: 999px; background: var(--sx-surface-overlay); vertical-align: middle; }
.cf-demo .cf-share > span { display: block; height: 100%; background: var(--sx-ink-subtle); }
.cf-demo .cf-hosts { gap: 6px; align-items: center; }

/* Narrow app: tree above the detail; the version table and variant rows become phone cards. */
@container sxapp (max-width: 799px) {
  .cf-demo .app { --sx-h: 540px; }
  .cf-demo .cf-layout { grid-template-columns: minmax(0, 1fr); }
  .cf-demo .cf-file-head { flex-direction: column; align-items: flex-start; }
  .cf-demo .cf-aside { flex-wrap: wrap; }
  .cf-demo .cf-kv { grid-template-columns: 120px minmax(0, 1fr) !important; }
  /* Version history: Version, Change, Observed (the pick box, size and event link drop out). */
  .cf-demo .cf-vt { --sx-cols: minmax(0, 1.1fr) minmax(0, .9fr) minmax(0, 1.4fr) !important; }
  .cf-demo .cf-vt .sx-tr > :is(:nth-child(1), :nth-child(5), :nth-child(6)) { display: none; }
  .cf-demo .cf-vt .sx-tr > :nth-child(2) { padding-left: 16px; }
  /* Variants: Variant, Hosts, Share on one line; the host names and the diff button below them. */
  .cf-demo .cf-var-t { --sx-cols: 84px 64px minmax(0, 1fr) !important; }
  .cf-demo .cf-var-t .sx-thead > :nth-child(n + 4) { display: none; }
  .cf-demo .cf-var-t .sx-td.cf-hosts-td, .cf-demo .cf-var-t .sx-td.cf-diffa { grid-column: 1 / -1; padding-top: 0; padding-left: 16px; text-align: left; }
  .cf-demo .cf-var-t .sx-td.cf-diffa:empty { display: none; }
  .cf-demo .cf-search-row { flex-wrap: wrap; }
  .cf-demo .cf-input { width: 100%; flex-basis: 100%; }
}
@container sxapp (max-width: 559px) {
  /* The sidebar gives way to the small-screen header here in every demo (css/kit.css, T5). */
  .cf-demo .cf-selects { flex-wrap: wrap; }
  .cf-demo .cf-selects .sx-select { flex: 1 1 100%; }
  .cf-demo .cf-tools { flex-wrap: wrap; gap: 4px 12px; }
  .cf-demo .cf-tools > * { white-space: nowrap; }
  .cf-demo .cf-tools .sx-grow { display: none; }
  .cf-demo .cf-vt { --sx-cols: minmax(0, 1fr) max-content !important; }
  .cf-demo .cf-vt .sx-tr > :nth-child(4) { display: none; }
  /* The diff wraps on phones (the product scrolls it sideways), in 11px so long lines take fewer rows. */
  .cf-demo .app .sx-diff-t { font-size: max(11px, var(--sx-fmin, 0px)); line-height: 16px; }
  .cf-demo .app .sx-dl > .sx-ln { min-width: 22px; padding: 0 3px; }
  .cf-demo .app .sx-dl > .sx-mk { padding: 0 2px; }
  .cf-demo .cf-viewer.is-pad { padding: 12px 10px 14px; }
  .cf-demo .cf-page .sx-h1 { font-size: 22px; line-height: 28px; white-space: normal; overflow-wrap: anywhere; }
  .cf-demo .sx-panel.is-pad { padding: 12px 14px 16px; }
  .cf-demo .cf-dlg-head, .cf-demo .cf-dlg-body, .cf-demo .cf-dlg-foot { padding-left: 16px; padding-right: 16px; }
  .cf-demo .cf-kv { grid-template-columns: minmax(0, 1fr) !important; gap: 0 12px; }
  .cf-demo .cf-kv .sx-kv-k { margin-top: 6px; font-size: max(12px, var(--sx-fmin, 0px)); }
  .cf-demo .cf-vmarks { flex-wrap: wrap; }
}
