/* SHELEG Design — Workbench token layer (light default + dark twin).
   Copy verbatim; consume only var(--…) in components.
   Theme switch: set data-theme="dark" on :root. */
:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --ink: #1a1f2b;
  --muted: #5b6472;
  --border: #e6e9ef;
  --border-strong: #d7dce4;
  /* @role non-text: --accent, --info — 4.30:1 in both themes, just under AA. The accent
     fills buttons and marks selection and --accent-ink is the text that sits ON it;
     --info deliberately IS the accent hue, for "running / working", and it is a dot and a
     bar rather than a word. */
  --accent: #2f6feb;
  --accent-weak: #eaf0fe;
  --accent-ink: #ffffff; /* text ON the accent — 4.57:1 on --accent */
  --ok: #1a7f37;
  --ok-weak: #e6f4ea;
  --warn: #9a6700;
  --warn-weak: #fff3d6;
  --danger: #d1242f;
  --danger-weak: #fde8e9;
  --info: #2f6feb;
  --info-weak: #eaf0fe;

  --r-control: 6px;
  --r-card: 10px;
  --r-pill: 999px;

  --shadow-1: 0 4px 16px -8px rgba(26, 31, 43, 0.18); /* overlays only */

  --motion-ease: cubic-bezier(0.2, 0, 0, 1); /* ease-out; the only curve here */
  --dur-state: 0.18s; /* meaningful state transitions */
  --dur-hover: 0.12s; /* background/border/color only */

  --font-ui: -apple-system, "SF Pro", "Segoe UI", sans-serif;
  --font-data: ui-monospace, "SF Mono", Menlo, monospace;

  /* The scale the pack has always stated in prose, tokenised in 1.16.0. It was
     prose-only for five releases, which made the craft bar's "no ad-hoc font
     size anywhere in the diff" unachievable in this pack specifically — its own
     reference kit wrote twenty raw font-size declarations because there was
     nothing to reference. No value changed; they were lifted from the pack's
     Type section, not chosen. */
  --t-chip: 11px; /* chips, meta */
  --t-label: 12px; /* uppercase labels, tracked .1em */
  --t-body: 13px; /* body and dense UI — the workhorse */
  --t-card: 15px; /* card titles */
  --t-section: 20px; /* section headings */
  --t-page: 28px; /* page title */

  /* The 4px grid, likewise stated and not shipped. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  background-color: var(--bg);
  color: var(--ink);
  color-scheme: light; /* the theme is explicit — never let the UA pick */
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;
  --panel: #161b24;
  --panel-2: #1b212c;
  --ink: #e8ecf3;
  --muted: #8a93a6;
  --border: #232a36;
  --border-strong: #2c3441;
  --accent: #4b8bff;
  --accent-weak: #1b2740;
  --accent-ink: #0f1218; /* text ON the accent — 5.7:1. White on #4b8bff fails AA. */
  --ok: #3fb960;
  --ok-weak: #12281a;
  --warn: #d9a93f;
  --warn-weak: #2b2210;
  --danger: #e5534b;
  --danger-weak: #2d1517;
  --info: #4b8bff;
  --info-weak: #1b2740;
}

/* Light is the default register. To follow the OS instead, have the app set
   data-theme="dark" from a prefers-color-scheme listener — keep one switch,
   never two sources of truth for the theme. */

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-state: 0s;
    --dur-hover: 0s;
  }
}

/* @adapter — the semantic token contract (FIX-DS-01). Pack comparison mounts
   packs through these roles, so two packs can carry one component without a
   shared native vocabulary. NO CSS-swap promise: components keep consuming the
   pack's own tokens; the adapter exists for the comparison harness, and a role
   neither mapped nor declared @absent blocks the comparison BEFORE any render. */
:root {
  --sem-surface: var(--bg);
  --sem-surface-raised: var(--panel);
  --sem-text: var(--ink);
  --sem-text-muted: var(--muted);
  --sem-line: var(--border);
  --sem-primary: var(--accent);
  --sem-on-primary: var(--accent-ink);
  --sem-positive: var(--ok);
  --sem-caution: var(--warn);
  --sem-negative: var(--danger);
}

/* ── components ── */

/* Everything below consumes var(--…) only. Colour never appears as a literal:
   the two themes above are the whole palette, and a value with no token is a
   gap in the pack rather than something to inline here. */

/* Heading — the type ramp made visible: 28 page / 20 section / 15 card title. */
.wb-heading {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  text-wrap: balance;
}
.wb-heading--1 {
  font-size: var(--t-page);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.wb-heading--2 {
  font-size: var(--t-section);
  font-weight: 700;
  line-height: 1.3;
}
.wb-heading--3 {
  font-size: var(--t-card);
  font-weight: 600;
  line-height: 1.4;
}

/* Rule — elevation is a border in this pack, so the divider is the same 1px. */
.wb-rule {
  height: 0;
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.wb-rule--strong {
  border-top-color: var(--border-strong);
}

/* Button — primary is the accent fill (one per view), secondary the bordered
   ghost, ghost the bare one. Hover moves background/border/colour only. */
.wb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  font-family: var(--font-ui);
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  cursor: pointer;
  transition:
    background-color var(--dur-hover) var(--motion-ease),
    border-color var(--dur-hover) var(--motion-ease),
    color var(--dur-hover) var(--motion-ease);
}
.wb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.wb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.wb-btn--sm {
  min-height: 26px;
  padding: 4px 10px;
  font-size: var(--t-label);
}
.wb-btn--md {
  min-height: 32px;
  padding: 6px 12px;
  font-size: var(--t-body);
}
.wb-btn--lg {
  min-height: 40px;
  padding: 8px 16px;
  font-size: var(--t-card);
}
.wb-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  /* --accent-ink, not --panel: the role is "text on the accent" and it flips
     with the theme. Borrowing the surface token happens to look right here and
     is exactly how a token name stops meaning one thing. */
  color: var(--accent-ink);
}
.wb-btn--primary:hover:not(:disabled) {
  /* One step toward the ink — which darkens in light and lightens in dark,
     because the pack has no separate hover token and inventing one would be
     a second accent hue. */
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 88%, var(--ink));
}
.wb-btn--secondary {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--ink);
}
.wb-btn--secondary:hover:not(:disabled) {
  background: var(--panel-2);
}
.wb-btn--ghost {
  background: transparent;
  color: var(--muted);
}
.wb-btn--ghost:hover:not(:disabled) {
  background: var(--panel-2);
  color: var(--ink);
}

/* DestructiveButton — the pack's third button: a red-border ghost that fills
   on hover. It borrows .wb-btn's geometry rather than restating it, because
   three inline copies of an atom is how a token layer rots. The fill is
   --danger-weak and the label stays --danger: there is no "text on danger"
   token, and a solid fill would need one. */
.wb-btn--destructive {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.wb-btn--destructive:hover:not(:disabled) {
  background: var(--danger-weak);
}
.wb-btn--destructive:focus-visible {
  outline-color: var(--danger);
}
.wb-btn--armed {
  background: var(--danger-weak);
  /* The 2px inset the pack already uses for selected/active, in the danger
     hue. A state indicator, not a shadow doing decoration. */
  box-shadow: inset 0 0 0 1px var(--danger);
}

/* Card — panel + border + a title row that carries its meta on the right. */
.wb-card {
  box-sizing: border-box;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--ink);
}
.wb-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.wb-card__title {
  margin: 0;
  font-size: var(--t-card);
  font-weight: 600;
  color: var(--ink);
}
.wb-card__meta {
  font-family: var(--font-data);
  font-size: var(--t-chip);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wb-card__body {
  display: block;
}

/* Chip — the mono atom: 11px, 1px border, pill radius, 2x8 padding. */
.wb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  padding: 2px 8px;
  font-family: var(--font-data);
  font-size: var(--t-chip);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--muted);
}
.wb-chip--neutral {
  background: var(--panel);
  border-color: var(--border);
  color: var(--muted);
}
.wb-chip--accent {
  background: var(--accent-weak);
  border-color: var(--accent-weak);
  color: var(--accent);
}
.wb-chip--selected {
  background: var(--accent-weak);
  border-color: var(--accent);
  color: var(--accent);
}

/* Stat — quiet panel-2 tile, label above, tabular value, source underneath. */
.wb-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-sizing: border-box;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.wb-stat__label {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.wb-stat__value {
  font-family: var(--font-data);
  font-size: var(--t-page);
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.wb-stat__source {
  font-family: var(--font-ui);
  font-size: var(--t-chip);
  line-height: 1.4;
  color: var(--muted);
}

/* StatusDot — 8px, one hue per state, never decoration. */
.wb-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: var(--t-label);
  color: var(--ink);
}
.wb-status__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--muted);
}
.wb-status__label {
  color: var(--ink);
}
.wb-status--running .wb-status__dot {
  background: var(--info);
}
.wb-status--ok .wb-status__dot {
  background: var(--ok);
}
.wb-status--warn .wb-status__dot {
  background: var(--warn);
}
.wb-status--danger .wb-status__dot {
  background: var(--danger);
}
.wb-status--idle .wb-status__dot {
  background: var(--muted);
}

/* DataTable — 34px rows, sticky panel-2 header, hairline dividers, numbers
   right-aligned in the data face. The wrapper is the scroll container the
   sticky header sticks to. */
.wb-table-wrap {
  max-height: 420px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.wb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-ui);
  font-size: var(--t-body);
  color: var(--ink);
}
.wb-table__caption {
  caption-side: top;
  padding: 12px 12px 8px;
  text-align: left;
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.wb-table__th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  padding: 0 12px;
  text-align: left;
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.wb-table__td {
  height: 34px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
}
.wb-table__row:first-child .wb-table__td {
  border-top: 0;
}
.wb-table__row:hover .wb-table__td {
  background: var(--panel-2);
}
.wb-table__row--selected { background-color: var(--accent-weak); box-shadow: inset 2px 0 0 0 var(--accent); }
.wb-table__th--num,
.wb-table__td--num {
  text-align: right;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* ProgressBar — 5px bordered track, accent fill, semantic fill when the bar
   is reporting a state rather than a quantity. */
.wb-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: var(--t-label);
  color: var(--muted);
}
.wb-progress__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.wb-progress__label {
  color: var(--muted);
}
.wb-progress__readout {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.wb-progress__track {
  box-sizing: border-box;
  height: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.wb-progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width var(--dur-state) var(--motion-ease);
}
.wb-progress--accent .wb-progress__fill {
  background: var(--accent);
}
.wb-progress--ok .wb-progress__fill {
  background: var(--ok);
}
.wb-progress--warn .wb-progress__fill {
  background: var(--warn);
}
.wb-progress--danger .wb-progress__fill {
  background: var(--danger);
}

/* SegmentedControl — the pill triad of a product UI: one panel-2 trough, the
   chosen option lifted onto panel. */
.wb-seg {
  display: inline-flex;
  gap: 2px;
  box-sizing: border-box;
  padding: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.wb-seg__opt {
  padding: 4px 12px;
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color var(--dur-hover) var(--motion-ease),
    border-color var(--dur-hover) var(--motion-ease),
    color var(--dur-hover) var(--motion-ease);
}
.wb-seg__opt:hover {
  color: var(--ink);
}
.wb-seg__opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.wb-seg__opt[aria-pressed="true"] {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--ink);
}

/* EmptyState — one dim sentence and one action. No illustration, no frame. */
.wb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}
.wb-empty__message {
  margin: 0;
  max-width: 65ch;
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--muted);
}
