/* =============================================================================
   Interface Design — the bench surface
   -----------------------------------------------------------------------------
   Builds on global.css tokens. Accent is mint (body[data-accent="mint"]).

   Two languages, one seam:
     · OUTER (masthead, rail, panel containers) speaks SITE language so this page
       reads as a sibling of the Comorbidity Atlas and the CS Taxonomy —
       --radius-sm containers, pill stats, the same eyebrow/lead rhythm.
     · INNER (everything inside a bench) speaks INSTRUMENT language from the
       ratified taste corpus — r2 (2px) square corners, dense articulated chrome,
       depth by RECESSION (inset wells) not elevation, spine-as-state, mono
       numerals. Ink lives at zone boundaries, not inside zones.

   Accent discipline: mint carries STATE only (active bench, live dial, changed
   value, selected rung). Structure is neutral --fg mixes. No accent-derived
   surface tint anywhere.
============================================================================= */

.idf-wrap {
  padding: 2.5rem 0 5rem;
  max-width: 1240px;
  margin: 0 auto;

  /* instrument constants — the ratified defaults, in one place */
  --r2: 2px;              /* corner verdict: r2 primary (e-05 E, "this looks beautiful") */
  --r8: 8px;              /* r8 acceptable — used only where a zone needs softening */
  --spine: 3px;           /* uniform spine (e-07) — accent carries state, not rainbow */
  --well-a: .07;          /* well depth alpha (dialed, e-2026-07-15d) */
  --well-blur: 6px;       /* well blur   (dialed) */
  --chrome-pad: 9px;      /* control cluster pad (e-07) */
  --chrome-gap: 7px;      /* control cluster gap (e-07) */
  --zone-pad: 11px;       /* zone interior pad (dialed) */
}

/* ---------- masthead (site language) -------------------------------------- */
.idf-masthead { max-width: 780px; margin-bottom: 2.5rem; }
.idf-back {
  display: block; width: fit-content;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em;
  color: var(--fg-mute); text-decoration: none;
  margin-bottom: 1.5rem;
  transition: color var(--t-base) var(--ease);
}
.idf-back:hover { color: var(--accent); }
.idf-eyebrow {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .18em;
  color: var(--accent);
  display: inline-flex; align-items: center; gap: .55rem;
  margin-bottom: 1rem;
}
.idf-eyebrow-dot {
  width: 8px; height: 8px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.idf-masthead h1 {
  font-size: clamp(2.4rem, 6vw, 4.25rem);
  font-weight: 900; letter-spacing: -0.045em; line-height: 1;
  margin: 0 0 1.1rem;
}
.idf-lead {
  font-size: 19px; line-height: 1.6;
  color: var(--fg-dim); max-width: 66ch;
  margin: 0 0 1.75rem;
}
.idf-lead em { color: var(--fg); font-style: normal; font-weight: 650; }
.idf-stats { display: flex; flex-wrap: wrap; gap: .6rem; }
.idf-stat {
  font-family: var(--mono); font-size: 12px; color: var(--fg-dim);
  padding: .4rem .75rem;
  border: 1px solid var(--border); border-radius: 99px;
  background: var(--mat-1);
}
.idf-stat strong { color: var(--accent); font-weight: 700; }

.idf-foot {
  margin-top: 1.35rem;
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  color: var(--fg-mute); max-width: 92ch;
}
.idf-mono, .idf-foot .idf-mono {
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border-hi);
}

/* ---------- layout: rail + main (anatomy C2, ranked #1) -------------------- */
.idf-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 2.25rem;
  align-items: start;
}

/* ---------- rail ---------------------------------------------------------- */
.idf-rail { position: sticky; top: 96px; }
.idf-rail-toggle {
  display: none; width: 100%;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: .8rem 1rem;
  background: var(--mat-1);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  color: var(--fg); cursor: pointer;
}
.idf-track { margin-bottom: 1.5rem; }
.idf-track-head {
  display: flex; align-items: baseline; gap: .55rem;
  margin-bottom: .55rem; padding-bottom: .45rem;
  border-bottom: 1px solid var(--border);
}
.idf-track-n {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--accent); letter-spacing: .05em;
}
.idf-track-title {
  font-size: 12px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--fg-dim);
}
.idf-track-gloss {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.5;
  color: var(--fg-mute);
  margin: -.2rem 0 .5rem;
}
.idf-track-benches { display: flex; flex-direction: column; gap: 1px; }

/* Rail row: spine-active (A4 doc-switcher #1 — spine marks the selection).
   No border box, no underline: ink at the zone boundary only. */
.idf-bench-link {
  display: flex; align-items: center; gap: .5rem;
  padding: 6px 8px 6px 9px;
  border-left: var(--spine) solid transparent;
  text-decoration: none; color: var(--fg-mute);
  transition: background .22s var(--ease), color .22s var(--ease), border-color .22s var(--ease);
}
.idf-bench-link:hover { background: color-mix(in srgb, var(--fg) 5%, transparent); color: var(--fg-dim); }
.idf-bench-link.active {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  color: var(--fg);
}
.idf-bench-name { font-size: 13.5px; line-height: 1.3; font-weight: 500; flex: 1; }
.idf-bench-link.active .idf-bench-name { font-weight: 650; }

/* Kind marks — square r2 tags, role-tiered, never filled pills. */
.idf-kind {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 1px 4px; border-radius: var(--r2);
  border: 1px solid var(--border-hi); color: var(--fg-mute);
  flex: none;
}
.idf-kind-bench { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.idf-kind-spec  { color: var(--fg-mute); }

/* ---------- the bench ----------------------------------------------------- */
.idb {
  background: var(--mat-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.idb-head {
  padding: 1.15rem 1.35rem 1rem;
  border-bottom: 1px solid var(--border);
}
.idb-crumb {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--fg-mute); margin-bottom: .45rem;
}
.idb-crumb b { color: var(--accent); font-weight: 700; }
.idb-title {
  font-size: 23px; font-weight: 800; letter-spacing: -.022em;
  margin: 0 0 .35rem;
}
.idb-gloss {
  font-size: 14.5px; line-height: 1.55;
  color: var(--fg-dim); max-width: 78ch; margin: 0;
}
.idb-gloss code {
  font-family: var(--mono); font-size: .9em;
  color: var(--fg); background: color-mix(in srgb, var(--fg) 7%, transparent);
  padding: 1px 4px; border-radius: var(--r2);
}

/* body: stage | dials — the three-pane instrument, inspector on the right */
.idb-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  align-items: stretch;
}
.idb-body.no-dials { grid-template-columns: minmax(0, 1fr); }

/* ---------- stage: roomy, quiet content inside dense articulated chrome ---- */
.idb-stage-wrap {
  padding: 1.5rem 1.5rem 1.35rem;
  min-width: 0;
  background:
    linear-gradient(color-mix(in srgb, var(--fg) 2.5%, transparent), color-mix(in srgb, var(--fg) 2.5%, transparent));
}
.idb-stage-label {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--fg-mute); margin-bottom: .7rem;
  display: flex; align-items: center; gap: .5rem;
}
.idb-stage-label::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.idb-stage { min-width: 0; }

/* A framed specimen: the well. Depth by RECESSION (dialed 0.07 / blur 6). */
.sp-well {
  background: color-mix(in srgb, var(--bg-deep) 62%, var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: inset 0 1px var(--well-blur) rgba(10, 15, 26, var(--well-a));
  padding: var(--zone-pad);
}
:root[data-theme="dark"] .sp-well {
  box-shadow: inset 0 1px var(--well-blur) rgba(0, 0, 0, calc(var(--well-a) * 5));
}

/* Rulers — the measurement overlay. This is the whole point: the number is
   visible on the thing, not only in the readout. */
.sp-ruler {
  position: relative;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  outline: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
}
.sp-tick {
  font-family: var(--mono); font-size: 9px; font-weight: 500;
  color: var(--accent-2); letter-spacing: .02em;
  white-space: nowrap;
}
:root[data-theme="dark"] .sp-tick { color: var(--accent); }

/* ---------- dials: dense, sunk, articulated ------------------------------- */
.idb-dials {
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--fg) 4%, transparent);
  padding: var(--chrome-pad);
  display: flex; flex-direction: column; gap: var(--chrome-gap);
  min-width: 0;
}
.idb-dials-head {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--fg-mute);
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.idb-dials-head .idb-live {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  color: var(--fg-mute); letter-spacing: .08em;
}
.idb-dials-head .idb-live i {
  width: 5px; height: 5px; background: var(--accent);
  box-shadow: 0 0 6px var(--accent); font-style: normal;
}

.idb-dgroup { display: flex; flex-direction: column; gap: 2px; }
.idb-dgroup-label {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--fg-mute); margin-bottom: 2px;
}
/* Label slot is sized to the LARGEST member so every label renders in full —
   the max-sizing law. No truncation, and no ellipsis: "i hate ellipses. it's
   like you're telling me that there's more, but that i can't see it."  */
.idb-drow {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) 46px;
  gap: 6px; align-items: center;
}
.idb-drow > label {
  font-size: 11px; color: var(--fg-dim); line-height: 1.2;
}
.idb-drow.changed > label { color: var(--fg); }
.idb-drow input[type=range] {
  width: 100%; height: 14px; accent-color: var(--accent);
  cursor: ew-resize; background: transparent;
}
.idb-drow input[type=range]:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* Value: click-to-edit — single click, edit in place, blur/Enter commits,
   invalid input reverts (his spec, e-13 A#1). */
.idb-dval {
  font-family: var(--mono); font-size: 10.5px; font-variant-numeric: tabular-nums;
  text-align: right; color: var(--fg-dim);
  padding: 1px 3px; border-radius: var(--r2);
  border: 1px solid transparent; cursor: text;
  transition: background .22s var(--ease), color .22s var(--ease);
}
.idb-dval:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
.idb-drow.changed .idb-dval { color: var(--accent-2); font-weight: 700; }
:root[data-theme="dark"] .idb-drow.changed .idb-dval { color: var(--accent); }
.idb-dval input {
  width: 100%; font: inherit; text-align: right;
  border: none; outline: none; padding: 0;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--fg); border-radius: var(--r2);
}

/* ---------- presets ------------------------------------------------------- */
.idb-presets { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 2px; }
.idb-preset {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 3px 6px; border-radius: var(--r2);
  border: 1px solid var(--border-hi);
  background: transparent; color: var(--fg-dim);
  cursor: pointer;
  transition: background .22s var(--ease), color .22s var(--ease), border-color .22s var(--ease);
}
.idb-preset:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--fg); }
.idb-preset.on {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  color: var(--accent-2); font-weight: 700;
}
:root[data-theme="dark"] .idb-preset.on { color: var(--accent); }

/* ---------- actions: filled primary, tint-well secondary, ink third ------- */
.idb-actions {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-top: auto; padding-top: var(--chrome-gap);
  border-top: 1px solid var(--border);
}
.idb-btn {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: .04em;
  height: 26px; padding: 0 9px;
  border-radius: var(--r2); border: 1px solid transparent;
  cursor: pointer;
  transition: background .22s var(--ease), color .22s var(--ease),
              border-color .22s var(--ease), box-shadow .22s var(--ease);
}
/* A3 soft-depth primary: faint top gradient + small lift */
.idb-btn-primary {
  background: linear-gradient(color-mix(in srgb, #fff 16%, var(--accent)), var(--accent));
  color: var(--accent-fg);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent);
}
.idb-btn-primary:hover { background: linear-gradient(color-mix(in srgb, #fff 24%, var(--accent)), var(--accent)); }
/* activation strips the fill to outline — "fill means go" (e-07 A#1) */
.idb-btn-primary:active {
  background: transparent; color: var(--accent-2);
  border-color: var(--accent); box-shadow: none;
}
:root[data-theme="dark"] .idb-btn-primary:active { color: var(--accent); }
/* tint well secondary (e-11 B#1): borderless, accent @ 12% ground */
.idb-btn-tint {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-2);
}
:root[data-theme="dark"] .idb-btn-tint { color: var(--accent); }
.idb-btn-tint:hover { background: color-mix(in srgb, var(--accent) 19%, transparent); }
.idb-btn-tint:active { background: color-mix(in srgb, var(--accent) 6%, transparent); }
/* ink third — quiet, and never underlined */
.idb-btn-ink { background: transparent; color: var(--fg-mute); }
.idb-btn-ink:hover { color: var(--fg); background: color-mix(in srgb, var(--fg) 7%, transparent); }
.idb-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);
}

/* ---------- readout ------------------------------------------------------- */
.idb-readout {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding: .85rem 1.35rem 1rem;
  background: color-mix(in srgb, var(--fg) 2%, transparent);
}
.idb-readout-head {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--fg-mute);
  display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem;
}
.idb-readout-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }
/* Structure here is ALIGNMENT, not rules: a shared key column and a shared
   value edge. Column rules and dot leaders are explicitly not structure —
   "i want the shite aligned, not 'boxed'. the alignment gives it structure."  */
.idb-lines {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.85;
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 0 2rem;
}
.idb-line { display: grid; grid-template-columns: 132px minmax(0, auto); gap: .75rem; align-items: baseline; }
.idb-line-k { color: var(--fg-mute); }
.idb-line-v { color: var(--fg); font-weight: 500; }
.idb-line.changed .idb-line-v { color: var(--accent-2); font-weight: 700; }
:root[data-theme="dark"] .idb-line.changed .idb-line-v { color: var(--accent); }

/* export output — the model bridge, shown as raw text on purpose */
.idb-out {
  display: none; margin-top: .8rem;
  font-family: var(--mono); font-size: 11px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  color: var(--fg-dim);
  background: color-mix(in srgb, var(--bg-deep) 55%, var(--bg-elev));
  border: 1px solid var(--border);
  border-left: var(--spine) solid var(--accent);
  border-radius: var(--r2);
  padding: 10px 12px;
  max-height: 260px; overflow: auto;
}
.idb-out.on { display: block; }

/* ---------- datasheet ----------------------------------------------------- */
.idb-spec { border-top: 1px solid var(--border); padding: 1.1rem 1.35rem 1.35rem; }
.idb-spec-group { margin-bottom: 1.1rem; }
.idb-spec-group:last-child { margin-bottom: 0; }
.idb-spec-label {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--fg-mute);
  display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem;
}
.idb-spec-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.idb-spec-row {
  display: grid; grid-template-columns: minmax(140px, 1.1fr) minmax(96px, auto) minmax(0, 1.6fr);
  gap: .35rem 1.1rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--hairline);
  align-items: baseline;
}
.idb-spec-row:last-child { border-bottom: none; }
.idb-spec-n { font-size: 12.5px; color: var(--fg); font-weight: 500; }
.idb-spec-v {
  font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--accent-2); font-weight: 700;
}
:root[data-theme="dark"] .idb-spec-v { color: var(--accent); }
.idb-spec-note { font-size: 11.5px; line-height: 1.5; color: var(--fg-mute); }
.idb-spec-note b { color: var(--fg-dim); font-weight: 600; }

/* provenance marks — where a number comes from, always visible */
.idb-src {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 0 3px; border-radius: var(--r2);
  border: 1px solid var(--border-hi); color: var(--fg-mute);
  margin-left: .4rem; white-space: nowrap;
}
.idb-src-apple { color: var(--fg-dim); }
.idb-src-ratified {
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
:root[data-theme="dark"] .idb-src-ratified { color: var(--accent); }
.idb-src-derived { opacity: .8; }

/* ---------- fork / decision diagram (Mac App Store track) ----------------- */
.sp-fork { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sp-path {
  border: 1px solid var(--border);
  border-top: var(--spine) solid var(--fg-mute);
  border-radius: var(--r2);
  padding: 10px 11px;
  background: var(--bg-elev);
}
.sp-path.on { border-top-color: var(--accent); }
.sp-path-h {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg); margin-bottom: 6px;
}
.sp-path-sub { font-family: var(--mono); font-size: 10px; color: var(--fg-mute); margin-bottom: 8px; }
.sp-req { display: flex; flex-direction: column; gap: 3px; }
.sp-req-row {
  display: flex; gap: 7px; align-items: baseline;
  font-size: 12px; line-height: 1.45; color: var(--fg-dim);
}
.sp-req-mark {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  flex: none; width: 1.1em; text-align: center;
}
.sp-req-mark.yes { color: var(--accent-2); }
:root[data-theme="dark"] .sp-req-mark.yes { color: var(--accent); }
.sp-req-mark.no  { color: var(--fg-mute); }

/* ---------- generic specimen primitives shared by benches ----------------- */
.sp-row { display: flex; align-items: center; }
.sp-col { display: flex; flex-direction: column; }
.sp-cap {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--fg-mute);
}
.sp-note { font-family: var(--mono); font-size: 10.5px; line-height: 1.6; color: var(--fg-mute); }
.sp-note b { color: var(--fg-dim); font-weight: 600; }

/* a laddered comparison strip — several values of the same thing, side by side */
.sp-ladder { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.sp-rung {
  flex: 1 1 92px; min-width: 88px;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--bg-elev);
  padding: 8px;
  cursor: pointer; text-align: left;
  font: inherit; color: inherit;
  transition: border-color .22s var(--ease), background .22s var(--ease);
}
.sp-rung:hover { border-color: var(--border-hi); }
.sp-rung.on {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.sp-rung-n {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg-mute); margin-bottom: 6px; display: block;
}
.sp-rung.on .sp-rung-n { color: var(--accent-2); }
:root[data-theme="dark"] .sp-rung.on .sp-rung-n { color: var(--accent); }

/* ---------- responsive ---------------------------------------------------- */
@media (max-width: 1120px) {
  .idb-body { grid-template-columns: minmax(0, 1fr); }
  .idb-dials { border-left: none; border-top: 1px solid var(--border); }
  .idb-dgroup, .idb-presets, .idb-actions { max-width: 640px; }
}
@media (max-width: 860px) {
  .idf-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .idf-rail { position: static; }
  .idf-rail-toggle { display: block; }
  .idf-rail-inner {
    display: none; margin-top: .75rem;
    padding: .9rem 1rem;
    background: var(--mat-1);
    border: 1px solid var(--border); border-radius: var(--radius-xs);
  }
  .idf-rail[data-open] .idf-rail-inner { display: block; }
  .idb-head { padding: 1rem 1.05rem .9rem; }
  .idb-stage-wrap { padding: 1.15rem 1.05rem 1.05rem; }
  .idb-readout, .idb-spec { padding-left: 1.05rem; padding-right: 1.05rem; }
  .sp-fork { grid-template-columns: 1fr; }
  .idb-spec-row { grid-template-columns: 1fr; gap: .1rem; padding: 7px 0; }
}
