/* ════════════════════════════════════════════════════════════════════
   DISPATCH · the customer SPA layout  ·  dispatch.css
   Loaded AFTER physea-tokens.css + physea-skin.css + physea-components.css.

   One job, kept small on purpose (Babel recompiles the JSX in-browser every
   load — website performance is a standing directive, so this stays lean):
   the app-shell / result-surface / list-detail LAYOUT from the two
   reference wireframes (app-page.html, app-secondary.html). Component
   ATOMS come from physea-components.css (.b, .empty, .skel, .field,
   .switch, .chip, .alert, .stat, .listrow); this file only positions them.
   Tokens (palette, radius ladder, type scale) come ONLY from the Library
   files, which are verbatim copies of PHYSEA/visual/design-system/ —
   tests/test_library_sync.py fails the suite if they ever diverge.
   All colors/rules/fonts reference tokens, so a palette edit re-skins Dispatch
   light AND dark for free.
   ════════════════════════════════════════════════════════════════════ */

:root {
  /* layout knobs (local, like the wireframes) */
  --dsp-sidebar-w: 15.5rem;
  --dsp-topbar-h: 3.8rem;
  --dsp-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; }        /* the app owns scrolling per-column */
#app { height: 100vh; }

/* ─────────────── APP SHELL (app-page.html) ─────────────── */
.dsp-app { display: grid; grid-template-columns: var(--dsp-sidebar-w) 1fr; height: 100vh; }

/* sidebar */
.dsp-side {
  background: color-mix(in srgb, var(--paper-2) 55%, var(--paper));
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; min-height: 0;
}
.dsp-side-brand { display: flex; align-items: center; gap: 10px; padding: 1.1rem 1.2rem 0.9rem; }
.dsp-side-brand .dsp-mark { width: 26px; height: 26px; flex: none; }
.dsp-side-brand .dsp-word { font-family: var(--font-head); font-weight: 700; font-size: 1.18rem; letter-spacing: -0.02em; }
.dsp-side-brand .dsp-word small { display: block; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); opacity: 0.7; font-weight: 400; margin-top: 1px; }
.dsp-side .sidebar-nav { max-width: none; padding: 0.4rem 0.6rem; flex: 1; }
.dsp-side .sidebar-nav button,
.dsp-side .sidebar-nav a {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  border: 0; background: transparent; padding: 9px 13px; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; transition: background 0.15s var(--dsp-ease), color 0.15s var(--dsp-ease);
}
.dsp-side .sidebar-nav button .si,
.dsp-side .sidebar-nav a .si { width: 17px; text-align: center; opacity: 0.85; }
.dsp-side .sidebar-nav button:hover,
.dsp-side .sidebar-nav a:hover { color: var(--ink); background: var(--rule-soft); }
.dsp-side .sidebar-nav button.on { color: var(--ink); background: var(--rule-soft); box-shadow: inset 2px 0 0 var(--primary); }
.dsp-side-foot { border-top: 1px solid var(--rule); padding: 0.8rem 0.9rem; }
.dsp-cockpit-link { display: block; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; color: var(--ink-2); text-decoration: none; padding: 4px 6px 8px; }
.dsp-cockpit-link:hover { color: var(--ink); }
.dsp-user { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); text-align: left; transition: background 0.15s; }
.dsp-user:hover { background: var(--rule-soft); }
.dsp-ava { width: 2rem; height: 2rem; border-radius: 50%; flex: none; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 0.8rem; color: var(--on-primary); background: radial-gradient(120% 160% at 30% 0%, var(--accent), var(--primary)); }
.dsp-user .who { font-size: 0.84rem; line-height: 1.2; min-width: 0; }
.dsp-user .who small { display: block; color: var(--ink-2); font-size: 0.72rem; }

/* main column */
.dsp-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dsp-top {
  height: var(--dsp-topbar-h); flex: none; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 1rem; padding: 0 clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(10px);
}
.dsp-top h1 { font-family: var(--font-head); font-weight: 700; font-size: 1.12rem; margin: 0; letter-spacing: -0.01em; }
.dsp-top .dsp-top-spacer { flex: 1; }
.dsp-content { flex: 1; overflow-y: auto; padding: clamp(1.4rem, 3.5vw, 2.75rem); width: 100%; }
/* narrow = readable column, but CENTERED and desktop-wide — never a left-pinned
   strip with a dead zone beside it (the "phone-sized on a desktop" bug) */
.dsp-content.narrow { max-width: 100rem; margin: 0 auto; }

/* engine chip */
.dsp-enginechip { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; padding: 4px 9px; border-radius: var(--radius-pill); border: 1px solid var(--rule); color: var(--ink-2); white-space: nowrap; }
.dsp-enginechip.up { color: var(--status-text, var(--status)); border-color: color-mix(in srgb, var(--status) 40%, transparent); }

/* ─────────────── HERO COMMAND (app-page.html .command) ─────────────── */
.dsp-command { margin-bottom: 2.25rem; }
.dsp-command .eyebrow { display: block; margin-bottom: 0.5rem; }
.dsp-command h2 { font-family: var(--font-head); font-size: clamp(2.5rem, 10.5vw, 4.5rem); font-weight: 400; letter-spacing: var(--head-tracking); margin: 0 0 0.5rem; line-height: var(--head-leading); }
.dsp-command p { max-width: 52ch; color: var(--ink-2); margin: 0 0 1.25rem; }
.dsp-cmdbox { display: flex; gap: 0.6rem; align-items: stretch; }
.dsp-cmdbox .inp { font-size: 1rem; padding: 0.85rem 1rem; }
.dsp-cmdbox .b { flex: none; }
.dsp-hints { display: flex; gap: 0.5rem; margin-top: 0.85rem; flex-wrap: wrap; }
.dsp-hints .chip { cursor: pointer; }
.dsp-hints .chip:hover { border-color: var(--rule-bold); color: var(--ink); }

/* ─────────────── RESULT SURFACE (app-page.html .route) ─────────────── */
.dsp-result { margin-top: 2rem; animation: dsp-fade 0.4s var(--dsp-ease); }
@keyframes dsp-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ─────────────── START demo + route tree (plan rev2 grammar: goal top, steps descend) ─────────────── */
.dsp-demo-grid { display: grid; grid-template-columns: 18rem 1fr; gap: 1.5rem; align-items: start; }
.dsp-demo-list { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.dsp-demo-stage { min-height: 20rem; }
.dsp-tree-goal { border: 1px solid var(--rule-bold); border-radius: var(--radius-lg); padding: 1rem 1.15rem; margin-bottom: 1rem; }
.dsp-tree-goal h3 { margin: 0.25rem 0 0; font-family: var(--font-ui); font-size: 1.02rem; font-weight: 600; }
.dsp-routetree.replaying .dsp-step { opacity: 0; animation: dsp-fade 0.5s var(--dsp-ease) forwards; }
@media (prefers-reduced-motion: reduce) { .dsp-routetree.replaying .dsp-step { opacity: 1 !important; animation: none !important; } }
@media (max-width: 900px) { .dsp-demo-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .dsp-result, .dsp-result * { animation: none !important; } }
.dsp-result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; padding-bottom: 0.85rem; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.dsp-result-head h2 { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.dsp-result-head .meta { font-family: var(--font-mono); font-size: 0.73rem; color: var(--ink-2); }
.dsp-ground-state { display: inline-flex; align-items: center; gap: 0.4rem; }
.dsp-ground-state .b--sm { padding: 0.15rem 0.55rem; font-size: 0.73rem; }
.dsp-answer { font-size: 1.02rem; line-height: 1.6; color: var(--ink); margin: 0 0 1.75rem; white-space: pre-wrap; }
.dsp-answer.headline-answer { font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; letter-spacing: -0.01em; line-height: 1.3; }

/* route as connected step cards */
.dsp-route { display: flex; flex-direction: column; }
.dsp-step { display: grid; grid-template-columns: 2.4rem 1fr; gap: 1rem; }
.dsp-rail { display: flex; flex-direction: column; align-items: center; }
.dsp-dot { width: 2.1rem; height: 2.1rem; border-radius: 50%; flex: none; display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.78rem; background: var(--paper); border: 1.5px solid var(--primary); color: var(--primary); }
.dsp-line { width: 2px; flex: 1; background: var(--rule); margin: 4px 0; min-height: 12px; }
.dsp-step:last-child .dsp-line { display: none; }
.dsp-card { background: color-mix(in srgb, var(--paper-2) 45%, var(--paper)); border: 1px solid var(--rule); border-radius: var(--radius-md); padding: 0.95rem 1.1rem; margin-bottom: 1rem; }
.dsp-card .rc-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dsp-card h3 { font-family: var(--font-ui); font-size: 0.98rem; font-weight: 600; margin: 0; }
.dsp-card .tool { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-2); background: var(--paper); border: 1px solid var(--rule); padding: 0.15rem 0.5rem; border-radius: var(--radius-xs); white-space: nowrap; }
.dsp-status { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.65rem; color: var(--ink-2); }
.dsp-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); }
.dsp-status.ready { color: var(--status-text, var(--status)); } .dsp-status.ready::before { background: var(--status); }
.dsp-status.wait { color: var(--accent-text, var(--accent)); } .dsp-status.wait::before { background: var(--accent); }
.dsp-status.recalc { color: var(--amber); } .dsp-status.recalc::before { background: var(--amber); } /* re-solve running — for the Recalculate control (brief item 72) */

/* reusable badge + next-block (the account wall) */
.dsp-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.25rem 0 0; }

/* ── Execution Audit panel (always-on trust surface; light + dark via tokens) ── */
.dsp-audit { margin: 0 0 1.75rem; padding: 1rem 1.15rem; border: 1px solid var(--rule); border-left: 3px solid var(--status); border-radius: var(--radius-md); background: color-mix(in srgb, var(--status) 5%, var(--paper)); }
.dsp-audit-head { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.dsp-audit-title { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--status-text, var(--status)); font-weight: 600; }
.dsp-audit-sub { font-size: 0.82rem; color: var(--ink-2); }
.dsp-audit-grid { display: flex; align-items: center; gap: 0.75rem 1rem; flex-wrap: wrap; }
.dsp-audit-key { display: inline-flex; align-items: center; gap: 0.55em; font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink); background: var(--paper); border: 1px dashed color-mix(in srgb, var(--status) 55%, var(--rule)); border-radius: var(--radius-pill); padding: 0.34em 0.8em; cursor: pointer; max-width: 100%; transition: border-color 0.15s; }
.dsp-audit-key:hover { border-color: var(--status); }
.dsp-audit-key .k { color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.64rem; }
.dsp-audit-key .v { color: var(--status-text, var(--status)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.dsp-audit-key .c { color: var(--ink-2); font-size: 0.64rem; }
.dsp-audit-key.is-copied .c { color: var(--primary); }
.dsp-audit-stats { display: flex; gap: 0.4rem 0.9rem; flex-wrap: wrap; font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-2); }
.dsp-audit-stats .ok { color: var(--status-text, var(--status)); }
.dsp-audit-stats .warn { color: var(--accent-text, var(--accent)); }
.dsp-audit-stats .stop { color: var(--primary); }
.dsp-audit-toggle { display: inline-flex; align-items: center; margin-top: 0.85rem; padding: 0; border: 0; background: transparent; cursor: pointer; font-family: var(--font-mono); font-size: 0.74rem; color: var(--ink-2); }
.dsp-audit-toggle:hover { color: var(--ink); }
.dsp-audit-tree { list-style: none; margin: 0.7rem 0 0; padding: 0; counter-reset: audit; }
.dsp-audit-tree li { display: flex; align-items: baseline; gap: 0.7rem; padding: 0.4rem 0; border-top: 1px solid var(--rule-soft); }
.dsp-audit-tree li::before { counter-increment: audit; content: counter(audit); flex: none; font-family: var(--font-mono); font-size: 0.68rem; color: var(--status-text, var(--status)); min-width: 1.2em; }
.dsp-audit-leaf { flex: 1; font-size: 0.86rem; color: var(--ink); line-height: 1.45; }
.dsp-audit-pill { flex: none; font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--status-text, var(--status)); border: 1px solid color-mix(in srgb, var(--status) 40%, transparent); border-radius: var(--radius-pill); padding: 0.1em 0.55em; }
.dsp-audit-trace { margin: 0.85rem 0 0; font-size: 0.78rem; color: var(--ink-2); line-height: 1.5; }
.dsp-next { margin-top: 1.75rem; padding: 1.25rem 1.4rem; border-radius: var(--radius-lg); border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent); background: color-mix(in srgb, var(--primary) 7%, var(--paper)); }
.dsp-next h3 { font-family: var(--font-head); font-size: 1.05rem; font-weight: 700; margin: 0 0 0.75rem; }
.dsp-next-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ─────────────── LIBRARY CATALOG (grid of run-this-route cards) ─────────────── */
.dsp-cat-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.dsp-cat-bar .search-wrap { flex: 1; min-width: 12rem; max-width: 24rem; }
.dsp-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 0.9rem; }
.dsp-cat-card { text-align: left; border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.05rem 1.15rem; background: color-mix(in srgb, var(--paper-2) 40%, var(--paper)); cursor: pointer; transition: border-color 0.18s var(--dsp-ease), transform 0.12s var(--dsp-ease), box-shadow 0.18s var(--dsp-ease); display: flex; flex-direction: column; gap: 0.55rem; font-family: var(--font-ui); }
.dsp-cat-card:hover { border-color: var(--rule-bold); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.dsp-cat-card h3 { font-family: var(--font-ui); font-size: 0.96rem; font-weight: 600; margin: 0; color: var(--ink); line-height: 1.25; }
.dsp-cat-card .cc-sub { font-size: 0.82rem; color: var(--ink-2); line-height: 1.4; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dsp-cat-card .cc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.35rem; }
.dsp-cat-card .cc-run { font-family: var(--font-mono); font-size: 0.72rem; color: var(--primary); }

/* ─────────────── SAVED ROUTES (app-secondary.html list/detail) ─────────────── */
.dsp-workspace { display: grid; grid-template-columns: 20rem 1fr; flex: 1; min-height: 0; height: 100%; }
.dsp-listcol { border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.dsp-listhead { padding: 1rem 1.1rem 0.85rem; border-bottom: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; }
.dsp-listhead .label { font-family: var(--font-ui); font-size: 0.82rem; font-weight: 500; color: var(--ink-2); }
.dsp-listitems { overflow-y: auto; flex: 1; }
.dsp-listitem { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--rule-soft); background: transparent; padding: 0.9rem 1.1rem; cursor: pointer; transition: background 0.15s var(--dsp-ease); font-family: var(--font-ui); }
.dsp-listitem:hover { background: color-mix(in srgb, var(--paper-2) 55%, var(--paper)); }
.dsp-listitem.on { background: color-mix(in srgb, var(--primary) 10%, transparent); box-shadow: inset 3px 0 0 var(--primary); }
.dsp-listitem h3 { font-family: var(--font-ui); font-size: 0.92rem; font-weight: 600; margin: 0 0 0.2rem; color: var(--ink); }
.dsp-listitem .li-meta { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-2); }
.dsp-detailcol { overflow-y: auto; padding: clamp(1.5rem, 3.5vw, 2.5rem); }
.dsp-detailhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--rule); }
.dsp-detailhead h2 { font-family: var(--font-head); font-size: 1.55rem; font-weight: 700; margin: 0.4rem 0 0; letter-spacing: -0.02em; }
.dsp-detailhead .sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-2); margin-top: 0.4rem; }
.dsp-detailhead .label { font-family: var(--font-ui); font-size: 0.82rem; font-weight: 500; color: var(--ink-2); }
.dsp-metagrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.85rem; margin-bottom: 1.75rem; }
.dsp-metagrid .stat { padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--paper-2) 40%, var(--paper)); }
.dsp-metagrid .stat .s-num { font-size: 1.5rem; margin: 4px 0 0; }
.dsp-steplist { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.dsp-steplist li { display: grid; grid-template-columns: 1.8rem 1fr auto; gap: 0.85rem; align-items: center; padding: 0.7rem 0; border-bottom: 1px solid var(--rule-soft); }
.dsp-steplist li.on { background: color-mix(in srgb, var(--primary) 8%, transparent); box-shadow: inset 3px 0 0 var(--primary); }
.dsp-steplist .n { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.72rem; border: 1.5px solid var(--primary); color: var(--primary); border-radius: 50%; }
.dsp-section-sub { font-family: var(--font-ui); font-size: 0.82rem; font-weight: 500; font-style: italic; color: var(--ink-2); margin: 1.75rem 0 0.4rem; }

/* ─────────────── CONNECT PANEL (app-secondary.html .panel) ─────────────── */
.dsp-connectrow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--rule-soft); }
.dsp-connectrow:last-child { border-bottom: 0; }
.dsp-connectid { display: flex; align-items: center; gap: 0.75rem; }
.dsp-connecticon { width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--rule); display: grid; place-items: center; font-size: 0.95rem; flex: none; }
.dsp-connectid .name { font-family: var(--font-ui); font-weight: 600; font-size: 0.9rem; }
.dsp-connectid .st { font-family: var(--font-mono); font-size: 0.68rem; }
.dsp-connectid .st.ok { color: var(--status-text, var(--status)); } .dsp-connectid .st.off { color: var(--ink-2); }

/* ─────────────── loading skeleton ─────────────── */
.dsp-skel-route { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }
.dsp-skel-row { display: grid; grid-template-columns: 2.1rem 1fr; gap: 1rem; align-items: start; }

/* ─────────────── theme toggle ───────────────
   Lives in the topbar (Topbar in dispatch.jsx, styled by .dsp-kbd): fixed
   bottom-right it sat under the App map toggle and could not be clicked. */
#dsp-theme { white-space: nowrap; }

/* ─────────────── power-user / per-company layer ─────────────── */
/* topbar: ⌘K button + workspace usage chip */
.dsp-kbd { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em; padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--paper); color: var(--ink-2); cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.dsp-kbd:hover { border-color: color-mix(in srgb, var(--primary) 45%, transparent); color: var(--primary); }
.dsp-usagechip { display: inline-flex; align-items: center; gap: 0; font-family: var(--font-mono); font-size: 10px; color: var(--ink-2); border: 1px solid var(--rule); border-radius: var(--radius-pill); overflow: hidden; white-space: nowrap; }
.dsp-usagechip .uc-tier { padding: 4px 9px; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); font-weight: 600; }
.dsp-usagechip .uc-sep { padding: 4px 9px; border-left: 1px solid var(--rule); }

/* result-surface keyed actions + trust panel */
.dsp-result-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1.1rem; }
.dsp-trust .dsp-trust-list { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.dsp-trust .dsp-trust-list li { font-size: 0.86rem; color: var(--ink-2); line-height: 1.45; margin: 0.2rem 0; }

/* library My / Company / Catalog segmented control */
/* wraps on purpose: five or six pills overflowed a 390px phone by 53px when this
   strip was a single non-wrapping row (Settings door, measured 2026-08-19). A
   second row keeps every tab reachable — a scroll strip would hide the last one. */
.dsp-segbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 1rem; }
.dsp-seg { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-ui); font-size: 0.82rem; font-weight: 500; color: var(--ink-2); border: 1px solid var(--rule); background: transparent; padding: 0.4rem 0.8rem; border-radius: var(--radius-pill); cursor: pointer; transition: all 0.15s var(--dsp-ease); }
.dsp-seg:hover { color: var(--ink); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.dsp-seg.on { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.dsp-seg .seg-n { font-family: var(--font-mono); font-size: 0.68rem; }

/* connect: MCP config card */
.dsp-connect-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 0.85rem; margin-bottom: 0.85rem; border-bottom: 1px solid var(--rule-soft); }
.dsp-connectid .st.on { color: var(--status-text, var(--status)); }
.dsp-mcp-snip { font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.5; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 0.85rem 1rem; margin: 0; overflow-x: auto; color: var(--ink); white-space: pre; }

/* ── AND-OR tree (REVISION 3: vertical AND, horizontal OR alternatives, tonic) ── */
.dsp-andorwrap { margin-top: 0.75rem; }
.dsp-crumbbar { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.9rem; padding: 0.5rem 0.75rem; background: var(--paper); border: 1px solid var(--rule-soft); border-radius: var(--radius-sm); }
.dsp-crumbbar .helper { color: var(--ink-2); font-size: 0.72rem; }
.dsp-andchain { display: flex; flex-direction: column; }
.dsp-andstep { display: grid; grid-template-columns: 2.4rem 1fr; gap: 1rem; cursor: pointer; }
.dsp-andstep:hover .dsp-andcard { border-color: var(--rule-bold); background: color-mix(in srgb, var(--paper-2) 55%, var(--paper)); }
.dsp-andstep.on .dsp-andcard { box-shadow: 0 0 0 2px var(--primary); }
.dsp-andrail { display: flex; flex-direction: column; align-items: center; }
.dsp-andcard { background: color-mix(in srgb, var(--paper-2) 40%, var(--paper)); border: 1px solid var(--rule); border-radius: var(--radius-md); padding: 0.85rem 1rem; margin-bottom: 1rem; transition: border-color 0.15s, background 0.15s; }
.dsp-orwrap { display: flex; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }
.dsp-oralt { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem 0.75rem; border: 1px solid var(--rule-soft); border-radius: var(--radius-sm); background: var(--paper); opacity: 0.85; cursor: pointer; }
.dsp-oralt:hover { opacity: 1; border-color: var(--rule-bold); }
.dsp-oralt.is-chosen { opacity: 1; border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--paper)); }
.dsp-oralt .score { font-family: var(--font-mono); font-size: 0.68rem; color: color-mix(in srgb, var(--ink-2) 60%, var(--ink)); }

/* Connect: tool catalog table */
.dsp-cattable { border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; background: color-mix(in srgb, var(--paper-2) 35%, var(--paper)); }

/* ⌘K command palette */
.dsp-pal-scrim { position: fixed; inset: 0; z-index: 80; background: color-mix(in srgb, var(--ink) 30%, transparent); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 1rem 1rem; }
.dsp-pal { width: 100%; max-width: 34rem; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: 0 24px 60px -24px color-mix(in srgb, var(--ink) 55%, transparent); overflow: hidden; animation: dsp-pal-in 0.14s var(--dsp-ease) both; }
@keyframes dsp-pal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.dsp-pal-input { width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink); font-family: var(--font-ui); font-size: 1rem; padding: 1rem 1.1rem; outline: none; }
.dsp-pal-list { max-height: 22rem; overflow-y: auto; padding: 0.35rem; }
.dsp-pal-empty { padding: 1rem 1.1rem; color: var(--ink-2); font-size: 0.86rem; }
.dsp-pal-row { display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); font-family: var(--font-ui); font-size: 0.88rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); cursor: pointer; }
.dsp-pal-row.on { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.dsp-pal-row .pal-ic { width: 1.2rem; text-align: center; color: var(--primary); flex: none; }
.dsp-pal-row .pal-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsp-pal-row .pal-hint { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-2); flex: none; }

/* ─────────────── responsive ─────────────── */
@media (max-width: 900px) {
  /* header band = its content height, main column takes the rest —
     without the explicit rows the 1fr default stretched the header to ~235px */
  /* minmax(0,1fr): one wide child (a long chip, the hero input) must squeeze,
     not push the whole shell past the viewport edge */
  .dsp-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .dsp-cmdbox .inp { min-width: 0; }
  .dsp-side { position: static; height: auto; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--rule); }
  /* the nav row is the scroller (not the whole sidebar), so the account button
     stays on screen; the right-edge fade says "more doors this way" */
  .dsp-side .sidebar-nav {
    flex-direction: row; align-items: center; gap: 2px; overflow-x: auto; padding: 0.35rem 0.4rem;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
  }
  /* icon-over-label, compact: six doors + Connect fit far more of a 390px row */
  .dsp-side .sidebar-nav button,
  .dsp-side .sidebar-nav a { flex-direction: column; gap: 3px; width: auto; font-size: 10.5px; padding: 6px 7px; white-space: nowrap; }
  .dsp-side .sidebar-nav button .si,
  .dsp-side .sidebar-nav a .si { width: auto; }
  /* .dsp-side-brand small alone lost to the higher-specificity display:block base rule */
  .dsp-side-brand .dsp-word small { display: none; }
  .dsp-side-brand { padding: 0.5rem 0.4rem 0.5rem 0.8rem; flex: none; }
  /* the foot shrinks to the avatar — sign-in must stay reachable on mobile */
  .dsp-side-foot { border-top: 0; padding: 0 0.5rem 0 0; flex: none; display: flex; align-items: center; }
  .dsp-side-foot::before { content: '›'; color: var(--ink-2); padding-right: 4px; }
  .dsp-side-foot .dsp-appmap { display: none; }   /* the map keeps its own fixed toggle */
  .dsp-side-foot .dsp-account { padding: 4px; }
  .dsp-side-foot .dsp-account .who { display: none; }
  .dsp-cockpit-link { display: none; }
  .dsp-palchip { display: none; }                 /* no keyboard = no shortcut chip */
  .dsp-workspace { grid-template-columns: 1fr; }
  .dsp-listcol { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 38vh; }
  .dsp-metagrid { grid-template-columns: 1fr; }
  .dsp-usagechip .uc-tier { display: none; }
}
@media (max-width: 480px) {
  /* reclaim the brand width for the doors: mark only */
  .dsp-side-brand .dsp-word { display: none; }
}

/* ── Arche finish additions (loops / usage / config card) ─────────────── */
.dsp-cfgcard { padding: 1.1rem 1.25rem; margin-top: 1.25rem; }
.dsp-cfgcard .chip { cursor: pointer; }
.dsp-metagrid .stat .helper { margin-top: 0.3rem; font-size: 0.72rem; }
/* solved vs executed — two visually distinct treatments, never conflated */
.dsp-outcome { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.08em;
  padding: 0.22rem 0.6rem; border-radius: 999px; border: 1.5px solid; white-space: nowrap; }
.dsp-outcome.is-solved { color: var(--ink-2); border-color: var(--ink-2); border-style: dashed; background: transparent; }
.dsp-outcome.is-exec { color: var(--status, #1c7c54); border-color: var(--status, #1c7c54); border-style: solid;
  background: color-mix(in srgb, var(--status, #1c7c54) 10%, transparent); }

/* FlowTrace run diagram — the SVG inherits page tokens (day/night follows) */
.dsp-flow { margin: 0.9rem 0 0.4rem; padding: 0.75rem 0.9rem; border: 1px solid var(--rule); border-radius: 10px; background: color-mix(in srgb, var(--paper-2) 40%, var(--paper)); overflow-x: auto; }
.dsp-flow svg { display: block; max-width: 100%; height: auto; }

/* trust strip on Start — the panel's trust/pricing blockers answered in one glance */
.dsp-trust-strip { display: grid; gap: 0.5rem; margin-top: 1rem; font-size: 0.85rem; color: var(--ink-2); }
.dsp-trust-strip strong { color: var(--ink); font-weight: 600; }
@media (min-width: 60rem) { .dsp-trust-strip { grid-template-columns: 1fr 1fr 1fr; gap: 1rem; } }

/* blocked step on the replay trace — honest red, never hidden */
.dsp-status.stop { color: var(--primary); } .dsp-status.stop::before { background: var(--primary); }

/* try-it-on-my-case block under the Start demo */
.dsp-trycase { margin-top: 2.25rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.dsp-trycase h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.dsp-trycase-row { display: flex; gap: 0.6rem; margin-top: 0.85rem; }
.dsp-trycase-input { flex: 1; min-width: 0; padding: 0.6rem 0.8rem; font: inherit; font-size: 0.9rem;
  color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.dsp-trycase-input:focus { outline: none; border-color: var(--accent); }
.dsp-workspace-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 420px);
  gap: 24px;
  align-items: end;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}
.dsp-workspace-head h2 { margin: 6px 0 0; }
.dsp-workspace-pick { display: flex; gap: 8px; }
.dsp-workspace-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 16px; margin-top: 16px; }
.dsp-action-grid { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.dsp-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.dsp-action:hover { background: var(--paper-2); }
.dsp-action span { color: var(--ink-2); font-size: .76rem; }
.dsp-action:disabled { opacity: .55; cursor: wait; }
.dsp-workspace-links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dsp-workspace-flow { list-style: none; margin: 0; padding: 0; }
.dsp-workspace-flow li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.dsp-workspace-flow .n { color: var(--primary); font-family: var(--font-mono); font-size: .72rem; }
.dsp-workspace-result { margin-top: 16px; }
.dsp-ready { min-height: 120px; }
/* idle Ready card: one-click example asks (top ready-made routes) */
.dsp-ready-asks { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin-top: 0.75rem; }
.dsp-ready-asks .b { white-space: normal; max-width: 100%; }
.dsp-key-fallback { margin-top: 8px; color: var(--ink-2); font-size: .78rem; }
.dsp-key-fallback summary { cursor: pointer; margin-bottom: 8px; }
.dsp-key-fallback .b { margin-top: 8px; }
@media (max-width: 840px) {
  .dsp-workspace-head, .dsp-workspace-grid { grid-template-columns: 1fr; }
}

/* ── Workspace map canvas (layout only; every colour is a Library token) ── */
.dsp-map { margin-bottom: 16px; }
.dsp-map-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dsp-map-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dsp-map-canvas { overflow: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); margin-top: 10px; max-height: 460px; }
.dsp-map-svg { display: block; touch-action: none; user-select: none; }
.dsp-map-edge { stroke: var(--rule); stroke-width: 1.5; }
.dsp-map-edge.is-causal { stroke: var(--primary); stroke-width: 2; }
.dsp-map-edge.is-associative { stroke: var(--ink-2); stroke-dasharray: 4 4; }
.dsp-map-node { cursor: grab; }
.dsp-map-node:active { cursor: grabbing; }
.dsp-map-node rect { fill: var(--paper-2); stroke: var(--rule); stroke-width: 1; }
.dsp-map-node.is-algorithm rect { fill: var(--paper); stroke: var(--primary); }
.dsp-map-node.is-run rect { stroke-dasharray: 3 3; }
.dsp-map-node.on rect { stroke: var(--primary); stroke-width: 2.5; }
.dsp-map-node text { fill: var(--ink); font-size: .76rem; pointer-events: none; }
.dsp-map-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ════════ transplant additions (two-planes build) ════════ */

/* sell-plane gate — the key IS the front door */
.dsp-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--paper); }
.dsp-gate-card { width: 100%; max-width: 26rem; display: flex; flex-direction: column; gap: 0.9rem; text-align: center; align-items: center; }
.dsp-gate-title { font-family: var(--font-head); font-size: 1.35rem; color: var(--ink); margin: 0; }
.dsp-gate-sub { color: var(--ink-2); margin: 0; font-size: 0.95rem; line-height: 1.5; }
.dsp-gate-form { display: flex; gap: 0.5rem; width: 100%; }
.dsp-gate-form .inp { flex: 1; }
.dsp-gate-err { color: var(--err, var(--primary)); font-size: 0.9rem; margin: 0; } /* error text rides --err, not accent */
.dsp-gate-foot { font-size: 0.85rem; color: var(--ink-2); margin: 0; }
.dsp-gate-foot a { color: var(--primary); }

/* ?embed=1 — chrome stripped, content edge to edge */
.dsp-app--embed { display: block; }
.dsp-app--embed .dsp-main { margin: 0; }

/* Ask door craft panel (Advanced) */
.dsp-craft { border: 1px solid var(--rule); border-radius: var(--radius-md, 0.6rem); padding: 0.9rem 1rem; margin-top: 0.75rem; background: var(--paper-2); }
.dsp-craft-note { font-size: 0.9rem; color: var(--ink-2); margin: 0; }
.dsp-craft-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.35rem 0; }
.dsp-craft-row > .lbl { font-size: 0.85rem; color: var(--ink-2); min-width: 5.5rem; text-align: left; }
.dsp-craft-row input[type='range'] { flex: 1; max-width: 14rem; accent-color: var(--primary); }
.dsp-craft-subs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

/* four-field algorithm cards (title + Use it for / How to use it / Needs) */
.cc-fields { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.35rem; text-align: left; }
.cc-field { margin: 0; font-size: 0.83rem; color: var(--ink-2); line-height: 1.45; }
.cc-field .cc-k { color: var(--ink); font-weight: 600; }
