/* ============================================================================
   Synapse · app.css
   Full layout + component styling. Apple language. Consumes tokens.css (§4).
   No inline hex — every color is a token. One soft shadow (drawer + card hover).
   No gradients. Generous whitespace. Active press = scale(.96) (from tokens reset).
   Structure mirrors CONTRACT §7 (layout) and §5/§3 (class names the JS emits).
   ============================================================================ */

/* ============================================================================
   0 · App shell — full-viewport, no page scroll; stage owns the scrolling regions
   ============================================================================ */
html, body {
  height: 100%;
}
body {
  overflow: hidden;                 /* the graph + panels manage their own scroll */
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;                   /* honor mobile browser chrome */
}

/* ============================================================================
   1 · Header — header.top
   56px · parchment · hairline bottom · backdrop blur · brand / search / actions
   ============================================================================ */
header.top {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: var(--s-md);
  padding: 0 var(--s-lg);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--hairline);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge);
  position: relative;
  z-index: 40;
}

/* --- Accessibility utility ----------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Brand (left) -------------------------------------------------------- */
.top-brand {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  flex: 0 0 auto;
  min-width: 0;
}
.top .brand-logo {
  height: 22px;
  width: auto;                         /* the fabius pixel wordmark — natural aspect, not a 34² square */
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;          /* keep the pixel edges crisp at any scale */
  /* Sign of life: the wordmark breathes a soft glow. GLOW only, NO scale beat. */
  animation: brand-breathe var(--breath-dur) var(--pulse-ease) infinite;
}
@keyframes brand-breathe {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50%      { filter: drop-shadow(0 0 6px var(--brand-glow)); }
}
.brand-divider {
  width: 1px;
  height: 18px;
  background: var(--chip);
  margin: 0 var(--s-xxs);
  flex: 0 0 auto;
}
.top .brand-company {
  color: var(--ink-48);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Read-state chip base — app.js adds .brand-state + .brand-demo (public read-only
   demo) or .brand-state + .brand-offline (couldn't reach the org). */
.brand-state {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  margin-left: var(--s-xxs);
  padding: 2px var(--s-xs);
  border-radius: var(--r-pill);
  font-size: var(--fs-fine);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
/* Demo · read-only — a calm lit pill with an inline "Add token" affordance. */
.brand-demo {
  color: var(--ink-80);
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--hairline));
  background: var(--canvas);
  box-shadow: var(--glow-soft);
}
.brand-demo-add {
  padding: 0;
  font-size: var(--fs-fine);
  font-weight: var(--w-semibold);
  color: var(--blue);
  border-radius: var(--r-pill);
}
.brand-demo-add:hover { text-decoration: underline; }

/* Offline/demo-data indicator (app.js adds it to .top-brand when Store.offline). */
.brand-offline {
  margin-left: var(--s-xxs);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-fine);
  font-weight: 600;
  white-space: nowrap;
  color: var(--t-agent);
  background: color-mix(in srgb, var(--t-agent) 12%, var(--canvas));
}

/* --- Search (center, pill) ---------------------------------------------- */
.top-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}
/* One premium icon system (js/icons.js → window.FabIcon). Apple/Figma line style:
   inherits currentColor, round joins, crisp stroke at any size. Size via width/height. */
.fab-icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-search .search-glyph {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink-48);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.top-search .search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--ink-48);
  background: var(--parchment);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xs);
  padding: 1px 6px;
  pointer-events: none;
}
.top-search input,
.top input[type="search"],
.top input.search-input {
  width: 100%;
  height: 40px;
  padding: 12px 20px 12px 38px;     /* leading search glyph at 14px */
  border-radius: var(--r-pill);
  border: 1px solid rgba(0, 0, 0, .08);
  background: var(--canvas);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.search-input::placeholder {
  color: var(--ink-48);
}
.search-input:focus {
  outline: none;
  border-color: var(--blue-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-focus) 16%, transparent);
}

/* --- Sidebar search (mirrors the header field) --------------------------- */
.side-search .search-field {
  position: relative;
}
.side-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-48);
  pointer-events: none;
}
.side-search .search-input,
.side-search input[type="search"] {
  width: 100%;
  height: 38px;
  padding: 8px 12px 8px 34px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  color: var(--ink);
}
.side-search .search-input:focus {
  outline: none;
  border-color: var(--blue-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-focus) 16%, transparent);
}

/* Inline glyphs that live outside a fixed-size swatch need explicit bounds
   (svgGlyph() ships viewBox only, leaving size to CSS). */
.search-icon,
.locate-icon { width: 16px; height: 16px; }
.mini-tile-icon { width: 18px; height: 18px; }

/* --- Actions (right) ----------------------------------------------------- */
.top-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s-xs);
}
.legend-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xxs);
  min-width: 40px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: var(--glass-border);
  background: var(--glass-bg-soft);
  -webkit-backdrop-filter: var(--glass-blur-soft);
  backdrop-filter: var(--glass-blur-soft);
  color: var(--ink-80);
  font-size: var(--fs-caption);
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-caption);
  transition: background .16s ease, border-color .16s ease;
}
.legend-toggle:hover {
  background: var(--parchment);
  border-color: var(--chip);
}
.legend-toggle .legend-glyph {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.legend-toggle .legend-label {
  white-space: nowrap;
}

/* ============================================================================
   2 · Stage — main.stage = flex row, fills height below header
   ============================================================================ */
main.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  min-height: 0;                    /* allow children to scroll */
  position: relative;
}

/* ============================================================================
   3 · Sidebar — aside.sidebar
   280px · canvas · right hairline · scroll · padding s-lg
   ============================================================================ */
aside.sidebar {
  flex: 0 0 280px;
  width: 280px;
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-lg);
  -webkit-overflow-scrolling: touch;
  z-index: 30;
}

/* --- Section blocks ------------------------------------------------------ */
.side-section {
  margin-bottom: var(--s-xl);
}
.side-section:last-child {
  margin-bottom: 0;
}
/* --- Filter rows --------------------------------------------------------- */
.filter-row {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  min-height: 40px;
  transition: background .14s ease, opacity .14s ease;
  user-select: none;
}
.filter-row:hover {
  background: var(--parchment);
}
.filter-row .filter-swatch {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--swatch, var(--chip));   /* per-type colour JS sets inline (--swatch); --chip fallback */
  display: grid;
  place-items: center;
}
/* the type glyph sits white on the coloured chip — a mini of the graph node tile */
.filter-row .filter-swatch .filter-icon {
  width: 12px;
  height: 12px;
  color: #fff;
  stroke: #fff;
  stroke-width: 2;
}
.filter-row .filter-swatch.round {
  border-radius: var(--r-pill);
}
.filter-row .filter-label {
  flex: 1 1 auto;
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  color: var(--ink-80);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-row .filter-count {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--pearl);
  border: 1px solid var(--divider);
  color: var(--ink-48);
  font-size: var(--fs-fine);
  font-weight: var(--w-semibold);
  text-align: center;
  letter-spacing: 0;
}
/* "off" state — dimmed; the label reads as struck/retired */
.filter-row[data-on="false"],
.filter-row.is-off {
  opacity: .42;
}
.filter-row[data-on="false"] .filter-label,
.filter-row.is-off .filter-label {
  text-decoration: line-through;
  text-decoration-color: var(--chip);
}
.filter-row[data-on="false"]:hover,
.filter-row.is-off:hover {
  opacity: .7;
}

/* --- Mini-card (selected entity preview) --------------------------------- */
.mini-card {
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  padding: var(--s-md);
  box-shadow: var(--shadow-sm);   /* resting card → base elevation */
  transition: box-shadow .2s ease, border-color .2s ease,
              transform .2s var(--ease-out);
}
@media (hover: hover) {
  .mini-card:hover {
    box-shadow: var(--shadow-md);   /* card hover → mid elevation */
    border-color: var(--divider);
    transform: translateY(-2px) scale(1.01);
  }
}
.mini-card .mini-head {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-bottom: var(--s-sm);
}
.mini-card .mini-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--parchment);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mini-card .mini-avatar { border-radius: var(--r-pill); }
.mini-card .mini-name {
  font-family: var(--font-display);
  font-weight: var(--w-semibold);
  font-size: var(--fs-body);
  letter-spacing: -0.3px;
  color: var(--ink);
  line-height: 1.2;
}
.mini-card .mini-summary {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--ink-80);
  margin: var(--s-xs) 0 var(--s-sm);
}
/* --- Chips --------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xxs);
  height: 26px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--pearl);
  border: 1px solid var(--divider);
  color: var(--ink-80);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease;
}
button.chip,
a.chip,
.chip[role="button"] {
  cursor: pointer;
}
button.chip:hover,
a.chip:hover,
.chip[role="button"]:hover {
  background: var(--parchment);
  border-color: var(--chip);
}
.chip:active,
.chip[role="button"]:active {
  transform: scale(.96);
}
/* a chip can carry a leading type dot tinted by --t-* (JS sets inline) */
.chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: currentColor;
  opacity: .85;
}

/* ============================================================================
   4 · Graph — div.graph
   flex:1 · relative · parchment canvas
   ============================================================================ */
div.graph {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  background: var(--parchment);
  overflow: hidden;
}
.graph canvas {
  display: block;
}


/* Focused / local-graph controls, top-right of the graph (v3 · CONTRACT-v3 §5) */
.graph .graph-controls {
  position: absolute;
  top: var(--s-md);
  right: var(--s-md);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 5px;
  border-radius: var(--r-pill);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow: var(--glass-edge), var(--shadow-lg);   /* lit edge + top elevation */
}
.graph .graph-focus-toggle {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-80);
  font-family: var(--font-text);
  font-size: var(--fs-caption);
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-caption);
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.graph .graph-focus-toggle:hover {
  background: var(--parchment);
}
.graph .graph-focus-toggle:active {
  transform: scale(.96);
}
.graph .graph-focus-toggle[aria-pressed="true"] {
  background: var(--blue);
  color: var(--canvas);
}
.graph .graph-focus-toggle:focus-visible {
  outline: 2px solid var(--blue-focus);
  outline-offset: 2px;
}
.graph .graph-depth {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.graph .graph-depth-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-48);
  font-family: var(--font-text);
  font-size: var(--fs-caption);
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-caption);
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.graph .graph-depth-btn:hover:not(:disabled) {
  background: var(--parchment);
  color: var(--ink-80);
}
.graph .graph-depth-btn:active:not(:disabled) {
  transform: scale(.96);
}
.graph .graph-depth-btn[aria-pressed="true"] {
  background: var(--parchment);
  color: var(--blue);
}
.graph .graph-depth-btn:disabled {
  opacity: .4;
  cursor: default;
}
.graph .graph-depth-btn:focus-visible {
  outline: 2px solid var(--blue-focus);
  outline-offset: 2px;
}

/* ============================================================================
   5 · Profile drawer — aside.profile
   420px · canvas · left hairline · soft shadow · over graph · slide from right
   GSAP also drives x/opacity; CSS provides the resting closed/open geometry.
   ============================================================================ */
aside.profile {
  flex: 0 0 auto;
  width: 420px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-left: var(--glass-border);
  box-shadow: var(--glass-edge), var(--shadow-lg);   /* lit edge + drawer elevation */
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  will-change: transform;
}
aside.profile[data-open="false"] {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
aside.profile[data-open="true"] {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* --- Drawer scroll body -------------------------------------------------- */
.profile-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Close affordance ---------------------------------------------------- */
.profile .profile-close {
  position: absolute;
  top: var(--s-sm);
  right: var(--s-sm);
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--parchment);
  color: var(--ink-80);
  z-index: 2;
  transition: background .14s ease;
}
.profile .profile-close:hover {
  background: var(--chip);
}
.profile .profile-close svg {
  width: 16px;
  height: 16px;
}

/* --- Header block -------------------------------------------------------- */
.profile-header {
  padding: var(--s-xl) var(--s-lg) var(--s-lg);
  border-bottom: 1px solid var(--divider);
}
.profile-header .ph-top {
  display: flex;
  align-items: center;
  gap: var(--s-md);
  margin-bottom: var(--s-md);
}
.profile-header .avatar {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: var(--r-pill);
  object-fit: cover;
  background: var(--parchment);
  border: 1px solid var(--divider);
}
/* agent header tile: emoji on its agent color (JS sets background inline).
   ::before carries the liquid-glass sheen so the inline background shorthand
   (set by profile.js) can't wipe it; mirrors the canvas glass node tile. */
.profile-header .agent-tile {
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  width: 64px;
  height: 64px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  color: var(--canvas);
  background: var(--t-agent);
  box-shadow: var(--glass-edge);
}
.profile-header .agent-tile::before,
.profile-header .glyph-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image:
    radial-gradient(130% 90% at 50% -15%, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 48%, rgba(0, 0, 0, .15));
}
/* entity header glyph tile for dept/team/project/etc (JS tints via --tint) */
.profile-header .glyph-tile {
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  width: 64px;
  height: 64px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--canvas);
  background: var(--ink);
  box-shadow: var(--glass-edge);
}
.profile-header .glyph-tile svg {
  position: relative;   /* above the ::before sheen */
  z-index: 1;
  width: 30px;
  height: 30px;
}
.profile-header .ph-name {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: var(--w-semibold);
  line-height: 1.08;
  letter-spacing: -0.6px;
  color: var(--ink);
}
.profile-header .ph-title {
  margin-top: 2px;
  font-size: var(--fs-body);
  color: var(--ink-48);
  letter-spacing: var(--ls-body);
}
.profile-header .ph-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs);
  margin-top: var(--s-md);
}
.profile-header .ph-buttons {
  display: flex;
  gap: var(--s-xs);
  margin-top: var(--s-md);
}

/* Synapse Seal verified badge — restrained blue tint */
.seal {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xxs);
  height: 26px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--blue) 10%, var(--canvas));
  border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
  color: var(--blue);
  font-size: var(--fs-fine);
  font-weight: var(--w-semibold);
  letter-spacing: 0;
}
.seal svg {
  width: 13px;
  height: 13px;
}

/* --- Tabs ---------------------------------------------------------------- */
.tablist {
  display: flex;
  gap: var(--s-md);
  padding: 0 var(--s-lg);
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 0;
  background: var(--canvas);
  z-index: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.tablist::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  flex: 0 0 auto;
  padding: 14px 0;
  font-size: var(--fs-caption);
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-caption);
  color: var(--ink-48);
  white-space: nowrap;
  transition: color .16s ease;
}
.tab:hover {
  color: var(--ink-80);
}
.tab[aria-selected="true"] {
  color: var(--ink);
}
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--ink);
  border-radius: var(--r-pill);
}

.tabpanel {
  padding: var(--s-lg);
}
.tabpanel[hidden] { display: none; }

/* --- Panel sub-sections -------------------------------------------------- */
.panel-section {
  margin-bottom: var(--s-lg);
}
.panel-section:last-child { margin-bottom: 0; }
.panel-section .panel-head {
  font-size: var(--fs-fine);
  font-weight: var(--w-semibold);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-48);
  margin-bottom: var(--s-sm);
}
.panel-section p {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--ink-80);
}

/* --- List rows (reporting, members, work, tools, access) ----------------- */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  min-height: 44px;
}
.list-row:last-child { border-bottom: none; }
.list-row .lr-avatar,
.list-row .lr-glyph {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  object-fit: cover;
  background: var(--parchment);
  display: flex;
  align-items: center;
  justify-content: center;
}
.list-row .lr-glyph { border-radius: var(--r-sm); }
.list-row .lr-glyph svg { width: 16px; height: 16px; }
.list-row .lr-body {
  flex: 1 1 auto;
  min-width: 0;
}
.list-row .lr-name {
  font-size: var(--fs-caption);
  font-weight: var(--w-semibold);
  color: var(--ink);
  letter-spacing: var(--ls-caption);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .lr-meta {
  font-size: var(--fs-fine);
  color: var(--ink-48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover .lr-name { color: var(--blue); }

/* Reporting structure rail label (reports-to / current / direct-reports) */
.report-group + .report-group { margin-top: var(--s-md); }
.report-group .report-label {
  font-size: var(--fs-fine);
  color: var(--ink-48);
  letter-spacing: var(--ls-fine);
  margin-bottom: var(--s-xxs);
}
.report-group.current .lr-name { color: var(--ink); }

/* Definition pairs (label : value) used in tool/org/agent overviews */
.kv {
  display: flex;
  gap: var(--s-sm);
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  font-size: var(--fs-caption);
}
.kv:last-child { border-bottom: none; }
.kv .kv-key {
  flex: 0 0 38%;
  color: var(--ink-48);
  letter-spacing: var(--ls-caption);
}
.kv .kv-val {
  flex: 1 1 auto;
  color: var(--ink-80);
}

/* Rules / KPI / step bullets */
.bullets {
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
}
.bullets li {
  position: relative;
  padding-left: var(--s-md);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--ink-80);
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--chip);
}

/* ============================================================================
   6 · Status pills — restrained tints per state
   project: Shipped / Active / In Progress / Planned
   compliance: Compliant / Review due · workflow/sop: Live / Draft / Approved
   ============================================================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xxs);
  height: 24px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  font-size: var(--fs-fine);
  font-weight: var(--w-semibold);
  letter-spacing: 0;
  background: var(--pearl);
  border: 1px solid var(--divider);
  color: var(--ink-80);
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: currentColor;
}
/* green family — Shipped / Active / Live / Compliant / Approved */
.status-pill.is-shipped,
.status-pill.is-active,
.status-pill.is-live,
.status-pill.is-compliant,
.status-pill.is-approved {
  color: var(--t-workflow);
  background: color-mix(in srgb, var(--t-workflow) 9%, var(--canvas));
  border-color: color-mix(in srgb, var(--t-workflow) 20%, transparent);
}
/* blue family — In Progress */
.status-pill.is-in-progress {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 9%, var(--canvas));
  border-color: color-mix(in srgb, var(--blue) 20%, transparent);
}
/* amber/agent family — Review due / Draft */
.status-pill.is-review-due,
.status-pill.is-draft {
  color: var(--t-agent);
  background: color-mix(in srgb, var(--t-agent) 9%, var(--canvas));
  border-color: color-mix(in srgb, var(--t-agent) 20%, transparent);
}
/* neutral family — Planned */
.status-pill.is-planned {
  color: var(--ink-48);
  background: var(--pearl);
  border-color: var(--divider);
}

/* ============================================================================
   7 · Timeline — Activity tab, hairline rail
   ============================================================================ */
.timeline {
  position: relative;
  padding-left: var(--s-lg);
}
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--hairline);
}
.timeline .tl-item {
  position: relative;
  padding-bottom: var(--s-md);
}
.timeline .tl-item:last-child { padding-bottom: 0; }
.timeline .tl-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--s-lg) + 2px);
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--canvas);
  border: 2px solid var(--blue);
}
.timeline .tl-when {
  font-size: var(--fs-fine);
  color: var(--ink-48);
  letter-spacing: var(--ls-fine);
  margin-bottom: 2px;
}
.timeline .tl-text {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--ink-80);
}

/* ============================================================================
   8 · Buttons
   .btn-primary = Apple blue pill · .btn-ghost = transparent, 1px blue, blue text
   Active press scale(.96) inherits from tokens reset.
   ============================================================================ */
.btn-primary,
.btn-ghost,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xxs);
  height: 40px;
  padding: 0 var(--s-md);
  border-radius: var(--r-pill);
  font-size: var(--fs-caption);
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-caption);
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.btn-primary {
  background: var(--blue);
  color: var(--canvas);
  border: 1px solid var(--blue);
}
.btn-primary:hover {
  background: var(--blue-focus);
  border-color: var(--blue-focus);
}
.btn-ghost,
.ghost {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--blue);
}
.btn-ghost:hover,
.ghost:hover {
  background: color-mix(in srgb, var(--blue) 8%, transparent);
}
/* a quieter ghost: neutral secondary pill (used for "Present"/secondary header) */
.ghost.neutral {
  color: var(--ink-80);
  border-color: var(--hairline);
}
.ghost.neutral:hover {
  background: var(--parchment);
  border-color: var(--chip);
}
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.ghost:focus-visible {
  outline: 2px solid var(--blue-focus);
  outline-offset: 2px;
}

/* ============================================================================
   9 · Scrim — covers graph behind mobile drawer / bottom sheet
   ============================================================================ */
.scrim {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--black) 28%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 32;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.scrim[data-show="true"] {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================================
   10 · Responsive — mobile-first intent, verified ≤900 / ≤480
   ≤900: sidebar → off-canvas drawer (header toggle); graph full width;
         profile → full-width bottom sheet (max-height 85vh, slide from bottom).
   ≤480: tighten header; search shrinks; keep 44px touch targets.
   ============================================================================ */
@media (max-width: 900px) {
  .top .brand-company {
    display: none;                  /* reclaim width for search */
  }

  /* Sidebar becomes an off-canvas left drawer */
  aside.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 86vw;
    transform: translateX(-100%);
    transition: transform .26s var(--ease-out);
    box-shadow: var(--shadow-lg);   /* off-canvas drawer → top elevation */
    z-index: 38;
  }
  aside.sidebar[data-open="true"],
  .stage[data-sidebar="open"] aside.sidebar {
    transform: translateX(0);
  }

  /* graph fills the full row */
  div.graph {
    width: 100%;
  }

  /* Profile becomes a full-width bottom sheet */
  aside.profile {
    width: 100%;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    height: auto;
    max-height: 85vh;
    border-left: none;
    border-top: 1px solid var(--hairline);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  aside.profile[data-open="false"] {
    transform: translateY(100%);    /* slide down off-screen */
  }
  aside.profile[data-open="true"] {
    transform: translateY(0);
  }
  /* grab handle for the sheet */
  .profile-header {
    padding-top: var(--s-lg);
  }
  .profile-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--chip);
  }
  .profile-header { position: relative; }
}

@media (max-width: 480px) {
  header.top {
    gap: var(--s-xs);
    padding: 0 var(--s-sm);
  }
  /* Phone header: drop the inline search so the 7-view switcher gets the full
     freed width as a reachable scrollable strip. The brand logo stays (it's
     already a compact 34px chip). Search returns >480px. */
  .top-search {
    display: none;
  }
  .search-input {
    height: 40px;                   /* keep 40px field / 44px target band */
    padding-left: 34px;
    padding-right: 14px;
  }
  /* label-less action button on the tightest header */
  .legend-toggle .legend-label {
    display: none;
  }
  .legend-toggle {
    padding: 0;
    width: 44px;                    /* 44px touch target */
    min-width: 44px;
  }
  aside.sidebar {
    padding: var(--s-md);
  }
  .tablist {
    padding: 0 var(--s-md);
    gap: var(--s-sm);
  }
  .tabpanel,
  .profile-header {
    padding-left: var(--s-md);
    padding-right: var(--s-md);
  }
  /* keep every interactive row at a comfortable touch height */
  .filter-row,
  .list-row,
  .kv {
    min-height: 44px;
  }
  /* graph depth pills to a touch-safe 44px on phones */
  .graph .graph-depth-btn {
    width: 44px;
    height: 44px;
  }
}

/* ============================================================================
   11 · Motion & a11y preferences
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  aside.sidebar,
  aside.profile,
  .scrim {
    transition: none !important;
  }
}

/* Scrollbar polish for the two scroll regions (WebKit) */
.sidebar::-webkit-scrollbar,
.profile-scroll::-webkit-scrollbar {
  width: 8px;
}
.sidebar::-webkit-scrollbar-thumb,
.profile-scroll::-webkit-scrollbar-thumb {
  background: var(--chip);
  border-radius: var(--r-pill);
  border: 2px solid var(--canvas);
}
.sidebar::-webkit-scrollbar-track,
.profile-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================================================================
   12 · v3 — Connections block · Wikilinks · Run button (profile drawer)
   ============================================================================ */
/* Connections block: outgoing groups + backlinks, beneath the tabs. */
.profile-connections {
  margin-top: var(--s-xs);
  padding-top: var(--s-lg);
  border-top: 1px solid var(--divider);
}
.conn-block + .conn-block {
  margin-top: var(--s-md);
}
.conn-dir-label {
  font: var(--w-semibold) var(--fs-fine)/1 var(--font-text);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-48);
  margin-bottom: var(--s-xs);
}
.conn-group {
  margin-top: var(--s-sm);
}
.conn-group:first-of-type {
  margin-top: var(--s-xs);
}
.conn-rel {
  font-size: var(--fs-caption);
  color: var(--ink-48);
  letter-spacing: var(--ls-caption);
  margin-bottom: var(--s-xxs);
}
.conn-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs);
}

/* Wikilinks: inline [[Node Name]] → clickable, reads as text with a blue tint. */
.wikilink {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--blue) 32%, transparent);
  transition: border-color .14s ease, color .14s ease;
}
.wikilink:hover {
  border-bottom-color: var(--blue);
}
.wikilink:active {
  color: var(--blue-focus);
}
.wikilink:focus-visible {
  outline: 2px solid var(--blue-focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Run button (agent/person header). Disabled state = quiet, non-interactive. */
.run-open.is-disabled,
.run-open:disabled {
  color: var(--ink-48);
  border-color: var(--hairline);
  background: transparent;
  cursor: default;
  opacity: .7;
}
.run-open.is-disabled:hover,
.run-open:disabled:hover {
  background: transparent;
}

/* ============================================================================
   13 · Tactile interaction layer — spring press + hover lift + focus glow
   A premium feel applied to the named interactive surfaces. Press uses the
   --spring overshoot; hover lifts are gated to true-hover devices so a tap
   never sticks raised; reduced-motion strips every transform.
   ============================================================================ */

/* Resting elevation on the primary action pills (sit a hair off the canvas). */
.btn-primary,
.legend-toggle {
  box-shadow: var(--shadow-sm);
}

/* Spring press on the chrome buttons + interactive rows. The press scale wins
   over the generic button:active in tokens.css via the spring timing here. */
.btn-primary,
.btn-ghost,
.ghost,
.legend-toggle,
.filter-row,
.list-row.clickable,
.chip[role="button"],
button.chip,
a.chip,
.profile-close {
  transition: background .16s ease, border-color .16s ease, color .16s ease,
              box-shadow .18s ease, transform .14s var(--spring);
}
.btn-primary:active,
.btn-ghost:active,
.ghost:active,
.legend-toggle:active,
.filter-row:active,
.list-row.clickable:active,
.profile-close:active {
  transform: scale(.94);
}

/* Hover lift — only where a hover affordance already exists, true-hover only. */
@media (hover: hover) {
  .btn-primary:hover,
  .btn-ghost:hover,
  .ghost:hover,
  .legend-toggle:hover {
    transform: translateY(-1px) scale(1.02);
  }
  .btn-primary:hover {
    box-shadow: var(--shadow-md);
  }
}

/* Reduced-motion: keep the look, drop the motion. */
@media (prefers-reduced-motion: reduce) {
  .btn-primary,
  .btn-ghost,
  .ghost,
  .legend-toggle,
  .filter-row,
  .list-row.clickable,
  .chip[role="button"],
  button.chip,
  a.chip,
  .profile-close,
  .mini-card {
    transition: background .16s ease, border-color .16s ease, color .16s ease,
                box-shadow .18s ease;
  }
  .btn-primary:active,
  .btn-ghost:active,
  .ghost:active,
  .legend-toggle:active,
  .filter-row:active,
  .list-row.clickable:active,
  .profile-close:active,
  .btn-primary:hover,
  .btn-ghost:hover,
  .ghost:hover,
  .legend-toggle:hover,
  .mini-card:hover {
    transform: none;
  }
}

/* ============================================================================
   Living-Brain · shared ambient-veil primitive + brand-glow.
   A blurred SOLID veil (glow, NOT a flat-surface gradient) drifting opacity behind
   a view's content. Opacity-only animation = zero layout/scroll cost. Applied via
   class="has-ambient" (currently on #view-system).
   ============================================================================ */
.has-ambient { position: relative; isolation: isolate; }
.has-ambient::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--ambient-veil);
  filter: blur(60px);
  animation: ambient-drift 14s var(--ease-bio) infinite alternate;
}
@keyframes ambient-drift {
  0%   { opacity: .35; }
  100% { opacity: .7; }
}

/* Living-Brain reduced-motion kill for the shell layer (token --energy:0 calms the
   glow; keyframed animations are additionally hard-stopped here). */
@media (prefers-reduced-transparency: reduce), (prefers-reduced-motion: reduce) {
  .top .brand-logo { animation: none; filter: none; }
  .has-ambient::before { display: none; animation: none; }
}
