/* ─────────────────────────────────────────────────────────────────
   Arrange — v8 · Mulde
   German: hollow, depression, trough. The field is a sculpted object.
   Components live in pockets and extrude as pucks. The orange dot
   sits in the field, adjacent to whatever is active.

   Furtherance of v6 (whiter, plainer field) + v4 (mechanism vocabulary).
   The field interacts with components AS an object — not a backdrop.
   ───────────────────────────────────────────────────────────────── */

@layer tokens, base, primitives, components, utilities;

/* ─────────────────────────────────────────────────────────────────
   A. TOKENS
   ───────────────────────────────────────────────────────────────── */
@layer tokens {
  :root {
    /* Field — pillowy white. Whiter than v7. */
    --field:          #fbfaf6;
    --field-2:        #f4f2ec;
    --field-3:        #ebe9e2;
    --field-edge:     rgba(20, 18, 14, 0.06);

    /* Compatibility aliases — v1–v7 token names alive */
    --surface:        var(--field);
    --surface-2:      var(--field-2);
    --surface-3:      var(--field-3);
    --surface-edge:   var(--field-edge);
    --plane:          var(--field);
    --plane-2:        var(--field-2);
    --plane-3:        var(--field-3);
    --plane-edge:     var(--field-edge);
    --paper:          var(--field);
    --paper-2:        var(--field-2);
    --paper-3:        var(--field-3);

    /* Ink — neutral graphite */
    --ink:            #1c1b18;
    --ink-2:          #4a4842;
    --ink-3:          #8a877f;

    --rule:           rgba(20, 18, 14, 0.10);
    --rule-soft:      rgba(20, 18, 14, 0.05);
    --hair:           1px;

    /* The accent — burnt orange, the universal "this is on" color.
       Inherits Carter's v3 burnt sienna lineage, slightly warmed. */
    --orange:         #d96b35;
    --orange-soft:    rgba(217, 107, 53, 0.12);
    --orange-line:    rgba(217, 107, 53, 0.50);

    /* Standard accent slot points at orange */
    --accent:         var(--orange);
    --accent-ink:     #ffffff;
    --accent-wash:    var(--orange-soft);
    --accent-line:    var(--orange-line);

    /* Status — kept restrained. Same orange for negative, since the screenshots
       use orange as the only chromatic. Add subtle distinguishers for warn/positive. */
    --status-positive:      #4a7a3a;
    --status-positive-wash: rgba(74, 122, 58, 0.10);
    --status-warning:       #a87a32;
    --status-warning-wash:  rgba(168, 122, 50, 0.12);
    --status-negative:      var(--orange);
    --status-negative-wash: var(--orange-soft);
    --status-info:          var(--orange);
    --status-info-wash:     var(--orange-soft);

    /* Type */
    --font-sans:    "Inter", "Helvetica Neue", Helvetica, system-ui, sans-serif;
    --font-mono:    "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;

    --w-regular: 400;
    --w-medium:  500;
    --w-bold:    600;

    --t-xs:  11px;
    --t-sm:  13px;
    --t-md:  15px;
    --t-lg:  18px;
    --t-xl:  26px;
    --t-2xl: 40px;
    --t-3xl: 56px;

    --lh-tight: 1.12;
    --lh-base:  1.5;

    --tracking-eyebrow:    0.10em;
    --tracking-display:    -0.018em;
    --tracking-display-xl: -0.024em;
    --tracking-label:      0.02em;

    /* Space (4px scale) */
    --s-1:  4px;  --s-2:  8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 24px;  --s-6: 32px;  --s-7: 48px; --s-8: 64px; --s-9: 96px;

    /* Radius — pillowy, generous. Continuous curvature. */
    --r-sm:   4px;
    --r-md:  12px;
    --r-lg:  20px;
    --r-xl:  28px;
    --r-2xl: 40px;
    --r-pill: 999px;

    /* Motion — soft, almost reluctant */
    --m-instant: 100ms;
    --m-quick:   180ms;
    --m-base:    260ms;
    --m-slow:    400ms;
    --ease:      cubic-bezier(0.2, 0, 0, 1);
    --ease-soft: cubic-bezier(0.32, 1.10, 0.42, 1);    /* gentle settle */
    --ease-press: cubic-bezier(0.4, 0, 0.2, 1);

    /* ════════════════════════════════════════════════════════════
       POCKETS — recessed regions of the field where pucks live.
       Soft, ambient, multi-directional. NOT directional spotlights.
       The pocket is part of the field; the puck is part of the pocket.
       ════════════════════════════════════════════════════════════ */
    --pocket-shallow:
      inset 0 1px 2px rgba(20, 18, 14, 0.06),
      inset 0 -1px 1px rgba(255, 255, 255, 0.50);
    --pocket-mid:
      inset 0 2px 5px rgba(20, 18, 14, 0.08),
      inset 0 -1px 2px rgba(255, 255, 255, 0.55);
    --pocket-deep:
      inset 0 3px 8px rgba(20, 18, 14, 0.10),
      inset 0 -1px 3px rgba(255, 255, 255, 0.60);

    /* ════════════════════════════════════════════════════════════
       PUCKS — pieces that sit in pockets or extrude above the field.
       The puck has:
         - A soft radial highlight at top-left (suggests ambient light from above)
         - A soft directional drop shadow at bottom (sits on the field)
         - An ultra-thin dark ring at the base (sitting recessed in)
       These three together make the puck read as a physical object,
       without resorting to gradients-pretending-to-be-plastic.
       ════════════════════════════════════════════════════════════ */
    --puck-flush:
      0 0 0 1px rgba(20, 18, 14, 0.04),
      0 1px 0 rgba(20, 18, 14, 0.05);
    --puck-resting:
      0 0 0 1px rgba(20, 18, 14, 0.04),
      0 1px 2px rgba(20, 18, 14, 0.06),
      0 4px 10px rgba(20, 18, 14, 0.06);
    --puck-extruded:
      0 0 0 1px rgba(20, 18, 14, 0.05),
      0 2px 4px rgba(20, 18, 14, 0.07),
      0 8px 20px rgba(20, 18, 14, 0.10);

    /* Field ambient — used on .field-card containers. The field itself
       is one object resting slightly above the page. */
    --field-ambient:
      0 1px 2px rgba(20, 18, 14, 0.04),
      0 8px 24px rgba(20, 18, 14, 0.06),
      0 16px 48px rgba(20, 18, 14, 0.04);

    /* Legacy compatibility aliases (v3/v4/v7 names → v8 vocabulary) */
    --rout-shallow:  var(--pocket-shallow);
    --rout-mid:      var(--pocket-mid);
    --rout-deep:     var(--pocket-deep);
    --rout-deepest:  var(--pocket-deep);
    --inset-cut:     var(--pocket-mid);
    --inset-deep:    var(--pocket-deep);
    --e0: 0 0 0 0 transparent;
    --e1: var(--puck-resting);
    --e2: var(--puck-extruded);
    --e3: var(--field-ambient);

    /* Control metrics */
    --control-h-sm: 28px;
    --control-h-md: 38px;
    --control-h-lg: 48px;
  }

  [data-theme="ink"] {
    /* Dark — deep neutral graphite, but still pillowy */
    --field:    #1c1c19;
    --field-2:  #232320;
    --field-3:  #2b2b27;
    --field-edge: rgba(255, 248, 235, 0.07);

    --ink:        #ebe8e0;
    --ink-2:      #b0aca3;
    --ink-3:      #7a766e;

    --rule:       rgba(255, 248, 235, 0.10);
    --rule-soft:  rgba(255, 248, 235, 0.04);

    --orange:       #e88550;
    --orange-soft:  rgba(232, 133, 80, 0.16);
    --orange-line:  rgba(232, 133, 80, 0.50);

    --accent:       var(--orange);
    --accent-ink:   #1c1c19;
    --accent-wash:  var(--orange-soft);
    --accent-line:  var(--orange-line);

    --status-positive: #7ab070;
    --status-warning:  #d4a040;
    --status-negative: var(--orange);

    /* Pockets on dark — softer, deeper */
    --pocket-shallow:
      inset 0 1px 2px rgba(0, 0, 0, 0.45),
      inset 0 -1px 1px rgba(255, 255, 255, 0.04);
    --pocket-mid:
      inset 0 2px 5px rgba(0, 0, 0, 0.50),
      inset 0 -1px 2px rgba(255, 255, 255, 0.05);
    --pocket-deep:
      inset 0 3px 8px rgba(0, 0, 0, 0.55),
      inset 0 -1px 3px rgba(255, 255, 255, 0.05);

    --puck-flush:
      0 0 0 1px rgba(255, 255, 255, 0.04),
      0 1px 0 rgba(0, 0, 0, 0.20);
    --puck-resting:
      0 0 0 1px rgba(255, 255, 255, 0.04),
      0 1px 2px rgba(0, 0, 0, 0.45),
      0 4px 10px rgba(0, 0, 0, 0.35);
    --puck-extruded:
      0 0 0 1px rgba(255, 255, 255, 0.05),
      0 2px 4px rgba(0, 0, 0, 0.50),
      0 8px 20px rgba(0, 0, 0, 0.50);

    --field-ambient:
      0 1px 2px rgba(0, 0, 0, 0.35),
      0 8px 24px rgba(0, 0, 0, 0.45),
      0 16px 48px rgba(0, 0, 0, 0.40);
  }
}

/* ─────────────────────────────────────────────────────────────────
   B. BASE
   ───────────────────────────────────────────────────────────────── */
@layer base {
  *, *::before, *::after { box-sizing: border-box; }

  html {
    font-family: var(--font-sans);
    font-size: var(--t-md);
    line-height: var(--lh-base);
    color: var(--ink);
    background: var(--field-2);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
  }

  body {
    margin: 0;
    background: var(--field-2);
    color: var(--ink);
    min-height: 100vh;
  }

  h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: var(--w-bold);
    line-height: var(--lh-tight);
    color: var(--ink);
    letter-spacing: var(--tracking-display);
  }
  h1 { font-size: var(--t-3xl); letter-spacing: var(--tracking-display-xl); }
  h2 { font-size: var(--t-2xl); }
  h3 { font-size: var(--t-xl); }
  h4 { font-size: var(--t-lg); font-weight: var(--w-medium); }

  p { margin: 0; }

  a {
    color: var(--orange);
    text-decoration: none;
    border-bottom: 1px solid var(--orange-line);
    transition: color var(--m-quick) var(--ease);
  }
  a:hover { color: var(--ink); border-bottom-color: var(--ink); }

  ::selection { background: var(--orange-soft); color: var(--ink); }

  hr { border: 0; height: 1px; background: var(--rule); margin: var(--s-5) 0; }

  code, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      transition-duration: 0.001ms !important;
    }
  }
}

/* ─────────────────────────────────────────────────────────────────
   C. THE FIELD-CARD — the foundational v8 container
   ───────────────────────────────────────────────────────────────── */
@layer primitives {
  /* A field-card is a soft pillow of the white field, lifted slightly above
     the page (which is field-2). Everything that needs grouping sits in one.
     The field is the OBJECT. Components live inside it. */
  .field-card {
    background: var(--field);
    border-radius: var(--r-lg);
    box-shadow: var(--field-ambient);
    padding: var(--s-6);
  }
  .field-card--lg { padding: var(--s-7); border-radius: var(--r-xl); }
  .field-card--sm { padding: var(--s-4); border-radius: var(--r-md); }

  /* The indicator dot — the universal v8 "this is on" mark.
     Belongs to the FIELD, not the control. Position with absolute. */
  .indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--orange);
    flex-shrink: 0;
  }
  .indicator--lg { width: 8px; height: 8px; }
  .indicator--sm { width: 5px; height: 5px; }
  .indicator--muted { background: var(--ink-3); }

  /* Eyebrow */
  .eyebrow {
    font-size: var(--t-xs);
    font-weight: var(--w-medium);
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
    color: var(--ink-3);
  }
}

/* ─────────────────────────────────────────────────────────────────
   D. PRIMITIVES — pucks sitting in pockets
   ───────────────────────────────────────────────────────────────── */
@layer primitives {

  /* ════════ Button — a puck resting on the field ════════ */
  .btn {
    --_bg: var(--field);
    --_fg: var(--ink);
    --_shadow: var(--puck-resting);
    --_shadow-hover: var(--puck-extruded);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: var(--control-h-md);
    padding: 0 var(--s-4);
    font-family: var(--font-sans);
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    letter-spacing: var(--tracking-label);
    line-height: 1;
    color: var(--_fg);
    background: var(--_bg);
    border: 0;
    border-radius: var(--r-pill);
    box-shadow: var(--_shadow);
    cursor: pointer;
    user-select: none;
    transition:
      box-shadow var(--m-quick) var(--ease-soft),
      transform  var(--m-quick) var(--ease-soft),
      background-color var(--m-quick) var(--ease),
      color var(--m-quick) var(--ease);
  }
  .btn:hover {
    box-shadow: var(--_shadow-hover);
    transform: translateY(-1px);
  }
  .btn:active {
    box-shadow: var(--pocket-shallow);
    transform: translateY(0);
    transition: all var(--m-instant) var(--ease-press);
  }
  .btn:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
  .btn[disabled] {
    opacity: 0.4;
    box-shadow: var(--puck-flush);
    cursor: not-allowed;
    pointer-events: none;
  }

  .btn--primary {
    --_bg: var(--orange);
    --_fg: #ffffff;
  }
  .btn--ghost {
    --_bg: transparent;
    --_shadow: none;
    --_shadow-hover: none;
  }
  .btn--ghost:hover { background: var(--field-2); transform: none; }
  .btn--danger {
    --_fg: var(--orange);
  }
  .btn--danger:hover {
    background: var(--orange);
    color: #ffffff;
  }
  .btn--ink {
    --_bg: var(--ink);
    --_fg: var(--field);
  }

  .btn--sm { height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--t-xs); }
  .btn--lg { height: var(--control-h-lg); padding: 0 var(--s-5); font-size: var(--t-md); }
  .btn--icon { width: var(--control-h-md); padding: 0; }
  .btn--icon.btn--sm { width: var(--control-h-sm); }
  .btn--icon.btn--lg { width: var(--control-h-lg); }

  /* Squarish variant (when pill doesn't read right) */
  .btn--square { border-radius: var(--r-md); }

  /* ════════ Input — recessed pocket in the field ════════ */
  .input, .select, .textarea {
    display: block;
    width: 100%;
    height: var(--control-h-md);
    padding: 0 var(--s-4);
    font-family: var(--font-sans);
    font-size: var(--t-sm);
    color: var(--ink);
    background: var(--field);
    border: 0;
    border-radius: var(--r-pill);
    box-shadow: var(--pocket-mid);
    transition: box-shadow var(--m-quick) var(--ease);
  }
  .input::placeholder, .textarea::placeholder { color: var(--ink-3); }
  .input:hover, .select:hover, .textarea:hover {
    box-shadow: var(--pocket-mid), 0 0 0 1px var(--rule);
  }
  .input:focus, .select:focus, .textarea:focus {
    outline: none;
    box-shadow:
      var(--pocket-mid),
      0 0 0 3px var(--orange-soft),
      0 0 0 1px var(--orange);
  }
  .textarea {
    height: auto;
    padding: var(--s-3) var(--s-4);
    line-height: var(--lh-base);
    resize: vertical;
    border-radius: var(--r-md);
  }
  .select {
    appearance: none;
    background-image:
      linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
      linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
    background-position: calc(100% - 16px) center, calc(100% - 11px) center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: var(--s-6);
  }

  .checkbox, .radio {
    appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    background: var(--field);
    border-radius: var(--r-sm);
    box-shadow: var(--pocket-mid);
    cursor: pointer;
    display: inline-grid;
    place-content: center;
    vertical-align: middle;
    transition: background-color var(--m-quick) var(--ease), box-shadow var(--m-quick) var(--ease);
  }
  .radio { border-radius: var(--r-pill); }
  .checkbox:checked, .radio:checked {
    background: var(--orange);
    box-shadow: var(--puck-resting);
  }
  .checkbox:checked::after {
    content: "";
    width: 9px; height: 5px;
    border-left: 1.5px solid #ffffff;
    border-bottom: 1.5px solid #ffffff;
    transform: rotate(-45deg) translate(1px, -1px);
  }
  .radio:checked::after {
    content: "";
    width: 7px; height: 7px;
    border-radius: var(--r-pill);
    background: #ffffff;
  }

  .field { display: flex; flex-direction: column; gap: var(--s-2); }
  .field__label {
    font-size: var(--t-xs);
    font-weight: var(--w-medium);
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
  }
  .field__hint { font-size: var(--t-xs); color: var(--ink-3); }

  /* ════════ Card — a pillowy region of the field ════════
     The card IS a feature of the field, not a separate object on it. */
  .card {
    background: var(--field);
    border-radius: var(--r-lg);
    box-shadow: var(--puck-resting);
    padding: var(--s-5);
  }
  .card--flush  { padding: 0; }
  .card--panel  { background: var(--field-2); box-shadow: var(--puck-flush); }
  .card--lifted { box-shadow: var(--puck-extruded); }
  .card--floating { box-shadow: var(--field-ambient); }
  .card__head {
    display: flex; align-items: baseline; justify-content: space-between;
    padding-bottom: var(--s-3);
    margin-bottom: var(--s-3);
    border-bottom: 1px solid var(--rule-soft);
  }
  .card__title { font-size: var(--t-md); font-weight: var(--w-bold); }
  .card__meta  { font-size: var(--t-sm); color: var(--ink-3); }

  /* ════════ Table — print inside the field ════════ */
  .table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-sm);
    color: var(--ink);
  }
  .table th {
    text-align: left;
    font-weight: var(--w-medium);
    font-size: var(--t-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
    color: var(--ink-3);
    padding: var(--s-3);
    border-bottom: 1px solid var(--ink);
    white-space: nowrap;
  }
  .table td {
    padding: var(--s-3);
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: top;
  }
  .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
  .table td.mono { font-family: var(--font-mono); font-size: 0.92em; color: var(--ink-2); }
  .table tbody tr:hover td { background: var(--field-2); }
  .table tbody tr[aria-selected="true"] td { background: var(--orange-soft); }

  /* ════════ Tag — small puck riding on the field ════════ */
  .tag {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    height: 22px;
    padding: 0 var(--s-3);
    font-size: var(--t-xs);
    font-weight: var(--w-medium);
    line-height: 1;
    letter-spacing: var(--tracking-label);
    color: var(--ink-2);
    background: var(--field);
    border-radius: var(--r-pill);
    box-shadow: var(--puck-flush);
    white-space: nowrap;
  }
  .tag--accent   { color: var(--orange);          background: var(--orange-soft); }
  .tag--positive { color: var(--status-positive); background: var(--status-positive-wash); }
  .tag--warning  { color: var(--status-warning);  background: var(--status-warning-wash); }
  .tag--negative { color: var(--status-negative); background: var(--status-negative-wash); }

  /* ════════ Dot — generic status circle (legacy) ════════ */
  .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--r-pill);
    background: var(--ink-3);
    flex-shrink: 0;
  }
  .dot--positive { background: var(--status-positive); }
  .dot--warning  { background: var(--status-warning); }
  .dot--negative { background: var(--status-negative); }
  .dot--info     { background: var(--orange); }

  /* ════════ Tabs (segmented) — a recessed strip with one extruded cap ════════ */
  .tabs {
    display: inline-flex;
    padding: 4px;
    background: var(--field);
    border-radius: var(--r-pill);
    box-shadow: var(--pocket-mid);
    gap: 2px;
  }
  .tabs__tab {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--ink-3);
    padding: 0 var(--s-4);
    height: 30px;
    border-radius: var(--r-pill);
    cursor: pointer;
    transition:
      background-color var(--m-quick) var(--ease),
      color var(--m-quick) var(--ease),
      box-shadow var(--m-quick) var(--ease);
  }
  .tabs__tab:hover { color: var(--ink-2); }
  .tabs__tab[aria-selected="true"] {
    background: var(--field);
    color: var(--ink);
    box-shadow: var(--puck-resting);
  }

  /* ════════ Kbd ════════ */
  .kbd {
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    padding: 2px 7px;
    color: var(--ink-2);
    background: var(--field);
    border-radius: var(--r-sm);
    box-shadow: var(--puck-resting);
  }

  .divider { height: 1px; background: var(--rule-soft); margin: var(--s-4) 0; }
}

/* ─────────────────────────────────────────────────────────────────
   E. MECHANISMS — v4 vocabulary, rebuilt as pockets and pucks
   ───────────────────────────────────────────────────────────────── */
@layer primitives {

  /* ════════ Toggle — orange pill OR white pill with orange dot ════════
     Two visual styles, both honest to the screenshots.

     Style A (default): the track is recessed in the field. The knob is a
     white puck riding inside. When ON, the entire track fills warm orange
     and the knob slides to the right (the screenshot's "orange pill" idiom).

     Style B (--soft): the track stays white. When ON, a small orange dot
     appears beside the knob's active end (the field-dot idiom). */

  .toggle {
    --_track-w: 52px;
    --_track-h: 28px;
    --_knob-d: 22px;
    --_inlay: var(--orange);

    position: relative;
    display: inline-block;
    width: var(--_track-w);
    height: var(--_track-h);
    border-radius: var(--r-pill);
    background: var(--field);
    box-shadow: var(--pocket-mid);
    cursor: pointer;
    vertical-align: middle;
    transition: background-color var(--m-base) var(--ease);
  }
  .toggle__knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: var(--_knob-d);
    height: var(--_knob-d);
    border-radius: var(--r-pill);
    background: var(--field);
    box-shadow: var(--puck-resting);
    transition: transform var(--m-base) var(--ease-soft), background-color var(--m-base) var(--ease);
  }
  .toggle__inlay {
    /* Inlay marker — small dot at the off-end, invisible by default */
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: var(--r-pill);
    background: var(--orange);
    opacity: 0;
    transition: opacity var(--m-quick) var(--ease) var(--m-quick);
  }
  .toggle.is-on .toggle__knob {
    transform: translateX(calc(var(--_track-w) - var(--_knob-d) - 6px));
  }
  .toggle.is-on .toggle__inlay { opacity: 1; }

  /* Style A — filled orange track when ON (the screenshot idiom) */
  .toggle.is-on { background: var(--_inlay); box-shadow: var(--pocket-mid); }
  .toggle.is-on .toggle__knob {
    background: var(--field);
  }
  .toggle.is-on .toggle__inlay { display: none; } /* dot redundant when track filled */

  /* Style B — soft (track stays white, dot appears beside knob) */
  .toggle--soft.is-on { background: var(--field); }

  .toggle--lg { --_track-w: 64px; --_track-h: 34px; --_knob-d: 28px; }
  .toggle--sm { --_track-w: 40px; --_track-h: 22px; --_knob-d: 16px; }

  /* ════════ Knob — milled puck sitting in a pocket ════════
     A circular pocket cut into the field. A white puck sits inside,
     flush with the field. A small orange dot is positioned in the field
     ABOVE the knob to indicate "this is the active knob." */
  .knob-group {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-3);
    position: relative;
  }
  /* The dot above — placed in the field, ABOVE the knob */
  .knob-group__active-dot {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px; height: 6px;
    border-radius: var(--r-pill);
    background: var(--orange);
    opacity: 0;
    transition: opacity var(--m-quick) var(--ease);
  }
  .knob-group.is-active .knob-group__active-dot { opacity: 1; }

  .knob {
    --_d: 64px;
    --_pocket-pad: 6px;
    --_marker: var(--orange);

    position: relative;
    width: var(--_d);
    height: var(--_d);
    padding: var(--_pocket-pad);
    border-radius: var(--r-pill);
    background: var(--field);
    box-shadow: var(--pocket-mid);
    cursor: pointer;
    border: 0;
    color: inherit;
  }
  /* The puck */
  .knob::after {
    content: "";
    position: absolute;
    inset: var(--_pocket-pad);
    border-radius: var(--r-pill);
    background: var(--field);
    box-shadow: var(--puck-resting);
    transform-origin: 50% 50%;
    transform: rotate(var(--_rot, 0deg));
    transition: transform var(--m-base) var(--ease-soft);
  }
  /* The position marker — small orange dot near the puck's edge */
  .knob::before {
    content: "";
    position: absolute;
    z-index: 2;
    left: 50%;
    top: calc(var(--_pocket-pad) + 6px);
    transform-origin: 50% calc(var(--_d) / 2 - 6px);
    transform: translateX(-50%) rotate(var(--_rot, 0deg));
    width: 5px;
    height: 5px;
    border-radius: var(--r-pill);
    background: var(--_marker);
    transition: transform var(--m-base) var(--ease-soft);
  }

  .knob-group__labels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: var(--font-sans);
    font-size: var(--t-xs);
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
  }
  .knob-group__value { color: var(--ink); font-weight: var(--w-bold); text-transform: none; letter-spacing: 0; }

  /* ════════ Push button (deep) — calculator-key press ════════ */
  .btn-deep {
    --_bg: var(--field);
    --_fg: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: var(--control-h-md);
    padding: 0 var(--s-4);
    font-family: var(--font-sans);
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    letter-spacing: var(--tracking-label);
    line-height: 1;
    color: var(--_fg);
    background: var(--_bg);
    border: 0;
    border-radius: var(--r-md);
    box-shadow: var(--puck-resting);
    cursor: pointer;
    transform: translateY(0);
    transition:
      box-shadow var(--m-quick) var(--ease-soft),
      transform  var(--m-quick) var(--ease-soft),
      background-color var(--m-quick) var(--ease);
  }
  .btn-deep:hover { box-shadow: var(--puck-extruded); transform: translateY(-1px); }
  .btn-deep:active {
    box-shadow: var(--pocket-mid);
    transform: translateY(1px);
    transition: all var(--m-instant) var(--ease-press);
  }
  .btn-deep--primary { --_bg: var(--orange); --_fg: #ffffff; }
  .btn-deep--ink     { --_bg: var(--ink); --_fg: var(--field); }

  /* ════════ Segmented (deep) — rocker switch panel ════════
     Recessed strip. Inactive cells flush. Active cell extruded.
     A small orange dot floats ABOVE the active cell, in the field. */
  .segmented-deep {
    position: relative;
    display: inline-flex;
    padding: 5px;
    background: var(--field);
    border-radius: var(--r-md);
    box-shadow: var(--pocket-mid);
    gap: 2px;
  }
  .segmented-deep__seg {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    color: var(--ink-3);
    padding: 0 var(--s-4);
    height: 32px;
    min-width: 64px;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    position: relative;
    transition:
      background-color var(--m-quick) var(--ease),
      color var(--m-quick) var(--ease),
      box-shadow var(--m-quick) var(--ease-soft),
      transform var(--m-quick) var(--ease-soft);
  }
  .segmented-deep__seg:hover { color: var(--ink-2); }
  .segmented-deep__seg.is-active {
    background: var(--field);
    color: var(--ink);
    box-shadow: var(--puck-resting);
    transform: translateY(-1px);
  }
  /* The orange dot above the active segment — floating in the field */
  .segmented-deep__seg.is-active::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: var(--r-pill);
    background: var(--orange);
  }

  /* ════════ Slot button — two-state mode key ════════
     Off: flush in field. On: extruded + dot above. */
  .slot-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: var(--control-h-md);
    padding: 0 var(--s-5);
    font-family: var(--font-sans);
    font-size: var(--t-sm);
    font-weight: var(--w-medium);
    letter-spacing: var(--tracking-label);
    line-height: 1;
    color: var(--ink-3);
    background: var(--field);
    border: 0;
    border-radius: var(--r-pill);
    box-shadow: var(--pocket-shallow);
    cursor: pointer;
    transition: all var(--m-quick) var(--ease-soft);
  }
  .slot-btn.is-on {
    color: var(--ink);
    box-shadow: var(--puck-resting);
    transform: translateY(-1px);
  }
  /* Field dot — orange dot above when active */
  .slot-btn.is-on::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: var(--r-pill);
    background: var(--orange);
  }

  /* ════════ Fader — long pocket with traveling puck ════════ */
  .fader {
    --_h: 26px;
    --_track-h: 8px;
    --_thumb-d: 20px;

    position: relative;
    display: block;
    width: 100%;
    height: var(--_h);
    user-select: none;
    cursor: pointer;
  }
  .fader__track {
    position: absolute;
    left: 0; right: 0; top: 50%;
    transform: translateY(-50%);
    height: var(--_track-h);
    border-radius: var(--r-pill);
    background: var(--field);
    box-shadow: var(--pocket-mid);
  }
  .fader__fill {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--orange);
    width: 50%;
    transition: width var(--m-quick) var(--ease);
  }
  .fader__thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--_thumb-d);
    height: var(--_thumb-d);
    border-radius: var(--r-pill);
    background: var(--field);
    box-shadow: var(--puck-extruded);
    transform: translate(-50%, -50%);
    transition: box-shadow var(--m-quick) var(--ease);
  }
  .fader:hover .fader__thumb { box-shadow: var(--puck-extruded), 0 0 0 6px var(--orange-soft); }
  .fader__value {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 9px;
    background: var(--ink);
    color: var(--field);
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    border-radius: var(--r-pill);
    box-shadow: var(--puck-extruded);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--m-quick) var(--ease);
    white-space: nowrap;
  }
  .fader:hover .fader__value, .fader.is-active .fader__value { opacity: 1; }

  /* ════════ LED — small chromatic dot, optionally lit ════════ */
  .led {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--r-pill);
    background: var(--ink-3);
    box-shadow: var(--pocket-shallow);
    transition: background-color var(--m-quick) var(--ease);
    flex-shrink: 0;
  }
  .led.is-on { background: var(--orange); }

  /* ════════ Five-cell rocker — the iconic screenshot composition ════════
     A long recessed strip with circular pockets. One puck extrudes when active. */
  .rocker {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    padding: 8px 12px;
    background: var(--field);
    border-radius: var(--r-pill);
    box-shadow: var(--pocket-mid);
    position: relative;
  }
  .rocker__cell {
    appearance: none;
    border: 0;
    background: var(--field);
    width: 38px;
    height: 38px;
    border-radius: var(--r-pill);
    box-shadow: var(--pocket-shallow);
    cursor: pointer;
    position: relative;
    transition:
      box-shadow var(--m-quick) var(--ease-soft),
      transform  var(--m-quick) var(--ease-soft);
  }
  .rocker__cell:hover { box-shadow: var(--puck-flush); }
  .rocker__cell.is-active {
    box-shadow: var(--puck-extruded);
    transform: translateY(-1px);
  }
  /* The orange dot ABOVE the active cell, in the field */
  .rocker__cell.is-active::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: var(--r-pill);
    background: var(--orange);
  }
}

/* ─────────────────────────────────────────────────────────────────
   F. COMPONENTS
   ───────────────────────────────────────────────────────────────── */
@layer components {
  .page-head {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: var(--s-5) 0 var(--s-4);
    border-bottom: 1px solid var(--ink);
    margin-bottom: var(--s-5);
  }
  .page-head__title { font-size: var(--t-3xl); letter-spacing: var(--tracking-display-xl); }
  .page-head__meta {
    font-family: var(--font-mono);
    font-size: var(--t-sm);
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
  }

  .shell {
    display: grid;
    grid-template-columns: 340px 1fr;
    min-height: 480px;
    background: var(--field);
    border-radius: var(--r-lg);
    box-shadow: var(--field-ambient);
    overflow: hidden;
  }
  .shell__rail {
    border-right: 1px solid var(--rule-soft);
    background: var(--field-2);
    overflow-y: auto;
  }
  .shell__main {
    background: var(--field);
    overflow-y: auto;
    padding: var(--s-5);
  }

  .empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; gap: var(--s-2);
    padding: var(--s-7) var(--s-5);
    color: var(--ink-3);
  }
  .empty__title { font-size: var(--t-md); font-weight: var(--w-bold); color: var(--ink-2); }
}

/* ─────────────────────────────────────────────────────────────────
   G. UTILITIES
   ───────────────────────────────────────────────────────────────── */
@layer utilities {
  .stack       { display: flex; flex-direction: column; gap: var(--s-3); }
  .stack--lg   { gap: var(--s-5); }
  .row         { display: flex; align-items: center; gap: var(--s-3); }
  .row--baseline { align-items: baseline; }
  .row--between  { justify-content: space-between; }

  .muted   { color: var(--ink-3); }
  .mono    { font-family: var(--font-mono); }
  .tabular { font-variant-numeric: tabular-nums; }
  .nowrap  { white-space: nowrap; }
  .grow    { flex: 1 1 0; min-width: 0; }

  .obj-flush    { box-shadow: var(--puck-flush); }
  .obj-resting  { box-shadow: var(--puck-resting); }
  .obj-extruded { box-shadow: var(--puck-extruded); }
  .obj-pocket   { box-shadow: var(--pocket-mid); background: var(--field); }
  .obj-pocket-deep { box-shadow: var(--pocket-deep); background: var(--field); }
}
