@layer tokens, base, components, overrides;

/* space-grotesk-latin-400-normal */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(./fonts/space-grotesk-latin-400-normal.woff2) format('woff2');
}
/* space-grotesk-latin-500-normal */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(./fonts/space-grotesk-latin-500-normal.woff2) format('woff2');
}
/* space-grotesk-latin-600-normal */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(./fonts/space-grotesk-latin-600-normal.woff2) format('woff2');
}
/* space-grotesk-latin-700-normal */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(./fonts/space-grotesk-latin-700-normal.woff2) format('woff2');
}
/* jetbrains-mono-latin-400-normal */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(./fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2');
}
/* jetbrains-mono-latin-500-normal */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(./fonts/jetbrains-mono-latin-500-normal.woff2) format('woff2');
}

/*
 * Primitive tokens. Raw values, no job.
 *
 * These are the Register palette: warm paper as the ground, navy as ink
 * and as action, gold reserved for the seal. Components do not name
 * these. They bind to semantic roles, so a theme can remap intent
 * without a hunt through component files.
 *
 * The status hues are not brand colours. They exist only to name an
 * operational state, and they stay off the gold.
 */

@layer tokens {
  :root {
    /*
     * Paper. The warm ground is the system's first tell: a record, not
     * a dashboard. Sheet is a panel, grid is the one cold surface, kept
     * for dense fields of mono values.
     */
    --di-paper: #f4f1e8;
    --di-sheet: #fcfbf7;
    --di-grid: #ffffff;
    --di-sunken: #eae5d7;
    --di-wash: #fbf9f2;
    --di-ivory: #f7f4ec;

    /* Rules. Four weights, from hairline to the tick scale. */
    --di-rule-100: #efebe0;
    --di-rule-300: #dcd5c3;
    --di-rule-400: #c3b9a2;
    --di-rule-500: #bfb49b;

    /*
     * Navy is the ink and the only filled control on paper. There is no
     * invented accent: what writes is what acts.
     */
    --di-navy-950: #061631;
    --di-navy-900: #0a1f44;
    --di-navy-800: #122e5e;
    --di-navy-700: #1d4280;
    --di-navy-600: #4a5570;
    --di-navy-500: #5b6478;
    --di-navy-200: #c1c8d8;
    --di-navy-100: #e6e9f0;
    --di-navy-50: #f2f5fa;
    --di-ink: #0a1f44;

    /*
     * Gold means sealed. Gold 500 is the mark, Gold 600 the hollow ring
     * a model's claim gets, Gold 700 the only gold that may be read as
     * text on paper. Gold never fills a surface in daylight.
     */
    --di-gold-700: #7a5c0e;
    --di-gold-600: #a6811f;
    --di-gold-500: #c9a24a;
    --di-gold-400: #d9b45e;
    --di-gold-200: #e3d0a2;
    --di-gold-100: #f7edd5;
    --di-gold-50: #fbf6e8;

    /*
     * Status. Each word clears 5:1 on its own wash and on paper. Keep
     * this set: a second yellow, or a generic traffic-light green or
     * red, breaks the register.
     */
    --di-ok-800: #155230;
    --di-ok-700: #1c6b3c;
    --di-ok-200: #c2d6be;
    --di-ok-100: #e7efe5;
    --di-warn-800: #6e4708;
    --di-warn-700: #8a5a0a;
    --di-warn-200: #e3d0a2;
    --di-warn-100: #f7edd5;
    --di-danger-800: #8a1b1b;
    --di-danger-700: #9e2020;
    --di-danger-200: #e5c2b9;
    --di-danger-100: #f8e6e2;

    /*
     * The night sheet. Navy can no longer act as the accent on a navy
     * ground, so gold fills the committing control. That is the single
     * exception to the gold rule, and it exists only after dark.
     */
    --di-night-950: #071229;
    --di-night-900: #0c1b37;
    --di-night-800: #1b2f56;
    --di-night-700: #2a4373;
    --di-night-600: #3a5185;
    --di-night-300: #a8b6d2;
    --di-night-100: #f2f5fb;
    --di-night-paper: #f2f0e6;
    --di-night-gold-ink: #241a02;
    --di-night-ok-900: #0e2a1a;
    --di-night-ok-700: #235939;
    --di-night-ok-300: #6edb97;
    --di-night-danger-900: #2e1414;
    --di-night-danger-700: #5e2323;
    --di-night-danger-300: #ff9b9b;

    /* Two families. --di-font-display was a third name for this one. */
    --di-font-sans: "Space Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --di-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    /* A console scale: 13px is the body, the mono track runs beneath it. */
    --di-font-size-100: 0.625rem;
    --di-font-size-200: 0.6875rem;
    --di-font-size-300: 0.75rem;
    --di-font-size-400: 0.8125rem;
    --di-font-size-500: 1rem;
    --di-font-size-600: 1.25rem;
    --di-font-size-700: 1.75rem;
    --di-font-size-800: 2.125rem;
    /*
     * The display tier. The console never goes here; the brand pages do,
     * and they were setting 40-64px by hand. A tier the system owns beats
     * a clamp invented in a stylesheet nothing else can see.
     */
    --di-font-size-900: 2.75rem;
    --di-font-size-1000: 3.5rem;

    --di-weight-regular: 400;
    --di-weight-medium: 500;
    --di-weight-semibold: 600;
    --di-weight-bold: 700;

    --di-leading-tight: 1.1;
    --di-leading-snug: 1.35;
    --di-leading-body: 1.5;

    --di-tracking-tight: -0.015em;
    --di-tracking-ui: 0.01em;
    --di-tracking-mono: 0.04em;
    --di-tracking-eyebrow: 0.12em;

    /* Moderate, not round: 4px micro, 6px control, 8px panel. */
    --di-radius-s: 4px;
    --di-radius-m: 6px;
    --di-radius-l: 8px;
    --di-radius-xl: 12px;

    /*
     * Space. Named by value, so `--di-space-12` is 12px and a wrong number
     * is visible in the diff rather than behind an index.
     *
     * Fine at the bottom, coarse at the top, because that is where the
     * density is: a 28px control cannot be padded on a 4px grid, and the
     * radius ramp already steps 4/6/8 for the same reason. Above 16 the
     * steps widen, because nothing between two sections needs that
     * precision. Anything not on this ramp is drift — `pnpm lint:tokens`
     * fails on it.
     */
    --di-space-2: 2px;
    --di-space-4: 4px;
    --di-space-6: 6px;
    --di-space-8: 8px;
    --di-space-12: 12px;
    --di-space-16: 16px;
    --di-space-24: 24px;
    --di-space-32: 32px;
    --di-space-48: 48px;

    /* Control heights. The console runs dense; 32px is the standard. */
    --di-h-dense: 28px;
    --di-h-ctl: 32px;
    --di-h-comfort: 36px;
    --di-h-row: 40px;

    /* Motion stays under 240ms, ease-out, one change at a time. */
    --di-duration: 120ms;
    --di-duration-slow: 200ms;
    --di-ease: cubic-bezier(0.16, 1, 0.3, 1);
  }
}
/*
 * Semantic tokens. Intent, not appearance.
 *
 * Daylight is the register as drawn: paper ground, navy ink, gold seal.
 * The night sheet remaps the same roles so a component never branches
 * on the theme. Gold fills the committing control after dark because
 * navy cannot act as an accent on a navy ground.
 */

@layer tokens {
  :root,
  :root[data-theme="light"] {
    color-scheme: light;

    --di-bg-page: var(--di-paper);
    --di-bg-surface: var(--di-sheet);
    --di-bg-grid: var(--di-grid);
    --di-bg-subtle: var(--di-sunken);
    --di-bg-row-hover: var(--di-wash);
    --di-bg-disabled: var(--di-sunken);
    --di-canvas: var(--di-sunken);
    --di-canvas-dot: rgba(10, 31, 68, 0.22);

    --di-text: var(--di-ink);
    --di-text-press: var(--di-navy-950);
    --di-text-muted: var(--di-navy-600);
    --di-text-subtle: var(--di-navy-500);
    --di-text-disabled: #6e6a5e;
    --di-text-on-strong: #ffffff;

    --di-border: var(--di-rule-300);
    --di-border-strong: var(--di-rule-500);
    --di-border-input: var(--di-rule-400);
    --di-rule: var(--di-rule-300);
    --di-rule-hairline: var(--di-rule-100);

    /*
     * The one ornament: an 8px tick scale. It closes a header or any
     * block that reports a measured value.
     */
    --di-tick: repeating-linear-gradient(
      to right,
      var(--di-rule-500) 0 1px,
      transparent 1px 8px
    );

    --di-chart-series: var(--di-ink);
    --di-chart-accent: var(--di-gold-500);
    --di-chart-baseline: var(--di-border-input);
    --di-chart-muted: var(--di-rule-300);
    --di-chart-muted-strong: var(--di-rule-500);
    --di-chart-band: rgba(10, 31, 68, 0.1);

    --di-fill-strong: var(--di-ink);
    --di-fill-strong-hover: var(--di-navy-950);
    --di-focus: var(--di-ink);
    --di-focus-halo: rgba(10, 31, 68, 0.18);

    /*
     * The seal. A filled dot is recorded and verifiable. There is no
     * `--di-accent`: it was an alias of exactly these two values, and a
     * token named "accent" contradicts the one rule the palette has —
     * gold means sealed, not important.
     */
    --di-seal: var(--di-gold-500);
    --di-seal-ink: var(--di-gold-700);
    --di-seal-bg: var(--di-gold-100);
    --di-seal-border: var(--di-gold-200);
    /* The hollow ring. A model inferred it; nothing has been sealed. */
    --di-ai-ring: var(--di-gold-600);
    --di-ai-surface: var(--di-gold-50);
    --di-ai-ink: var(--di-warn-800);

    /*
     * An inverted surface: the toast, the tooltip, the sign-in footer, the
     * rail. A component on navy re-points its own roles from these rather
     * than typing a hex — three of them were doing that, with #ffffff,
     * #b8c4dc and #b9c4d8 all meaning "muted on navy".
     */
    --di-inverse-bg: var(--di-ink);
    --di-inverse-raised: var(--di-navy-800);
    --di-inverse-border: var(--di-navy-800);
    --di-inverse-text: #ffffff;
    --di-inverse-muted: var(--di-night-300);
    /* Gold read against that ground. Seal ink is gold 700 and unreadable here. */
    --di-inverse-seal: var(--di-gold-400);

    --di-index-col: 38px;
    --di-index-col-sm: 26px;

    --di-sidebar-bg: var(--di-navy-900);
    --di-sidebar-raised: var(--di-navy-800);
    --di-sidebar-fg: var(--di-night-paper);
    --di-sidebar-muted: #93a1bd;
    --di-sidebar-active: var(--di-navy-800);
    --di-sidebar-edge: rgba(242, 240, 230, 0.12);
    --di-sidebar-focus: var(--di-gold-400);

    --di-status-ok-fg: var(--di-ok-800);
    --di-status-ok-bg: var(--di-ok-100);
    --di-status-ok-border: var(--di-ok-200);
    --di-status-ok-dot: var(--di-ok-700);
    --di-status-ok-on-navy: #9dc8ae;
    --di-status-warn-fg: var(--di-warn-800);
    --di-status-warn-bg: var(--di-warn-100);
    --di-status-warn-border: var(--di-gold-200);
    --di-status-warn-dot: var(--di-warn-700);
    --di-status-danger-fg: var(--di-danger-800);
    --di-status-danger-bg: var(--di-danger-100);
    --di-status-danger-border: var(--di-danger-200);
    --di-status-danger-dot: var(--di-danger-700);
    --di-status-recorded-fg: var(--di-ink);
    --di-status-recorded-bg: var(--di-navy-100);
    --di-status-recorded-border: var(--di-navy-200);
    --di-status-recorded-dot: var(--di-ink);
    --di-status-neutral-fg: var(--di-navy-600);
    --di-status-neutral-bg: var(--di-sunken);
    --di-status-neutral-border: var(--di-rule-300);
    --di-status-neutral-dot: var(--di-navy-500);

    /*
     * Two roles, because there are two families and the split is the
     * point: --di-font-ui is what a person reads, --di-font-code is what a
     * machine wrote. --di-font-body was a second name for the first.
     */
    --di-font-ui: var(--di-font-sans);
    --di-font-code: var(--di-font-mono);

    --di-radius-control: var(--di-radius-m);
    --di-radius-micro: var(--di-radius-s);
    --di-radius-surface: var(--di-radius-l);
    --di-radius-container: var(--di-radius-xl);
    --di-radius-pill: 999px;

    /*
     * Depth is drawn, not blurred. Only a detached plane — a menu, a
     * modal, a toast — earns a shadow, and it stays a technical one.
     */
    --di-shadow-plane: 0 2px 4px rgba(10, 31, 68, 0.06),
      0 10px 24px rgba(10, 31, 68, 0.08);
    --di-shadow-window: 0 1px 2px rgba(10, 31, 68, 0.05),
      0 30px 60px -32px rgba(10, 31, 68, 0.45);
    --di-scrim: rgba(10, 31, 68, 0.62);

    --di-tile-bg: var(--di-navy-100);
    --di-tile-fg: var(--di-ink);
    --di-tile-inverse-bg: var(--di-ink);
    --di-tile-inverse-fg: var(--di-sheet);

    --di-badge-neutral-bg: var(--di-navy-800);
    --di-badge-neutral-fg: var(--di-night-paper);
    --di-badge-alert-bg: #5c1d2a;
    --di-badge-alert-fg: var(--di-sheet);
    --di-badge-seal-bg: #3a3118;
    --di-badge-seal-fg: #e4c98a;
  }

  :root[data-theme="dark"] {
    color-scheme: dark;

    --di-bg-page: var(--di-night-950);
    --di-bg-surface: var(--di-night-900);
    --di-bg-grid: var(--di-night-900);
    --di-bg-subtle: var(--di-night-800);
    --di-bg-row-hover: var(--di-night-800);
    --di-bg-disabled: var(--di-night-800);
    --di-canvas: #030914;
    --di-canvas-dot: rgba(242, 245, 251, 0.16);

    --di-text: var(--di-night-100);
    --di-text-press: #ffffff;
    --di-text-muted: var(--di-night-300);
    --di-text-subtle: var(--di-night-300);
    --di-text-disabled: #7b89a6;
    --di-text-on-strong: var(--di-night-gold-ink);

    --di-border: var(--di-night-700);
    --di-border-strong: var(--di-night-600);
    --di-border-input: var(--di-night-700);
    --di-rule: var(--di-night-800);
    --di-rule-hairline: var(--di-night-800);

    --di-tick: repeating-linear-gradient(
      to right,
      var(--di-night-700) 0 1px,
      transparent 1px 8px
    );

    --di-chart-series: var(--di-night-100);
    --di-chart-accent: var(--di-gold-400);
    --di-chart-baseline: var(--di-night-700);
    --di-chart-muted: var(--di-night-800);
    --di-chart-muted-strong: var(--di-night-600);
    --di-chart-band: rgba(242, 245, 251, 0.12);

    /* After dark, gold is the fill. Navy has nothing left to act against. */
    --di-fill-strong: var(--di-gold-500);
    --di-fill-strong-hover: var(--di-gold-400);
    --di-focus: var(--di-gold-400);
    --di-focus-halo: rgba(217, 180, 94, 0.28);

    --di-seal: var(--di-gold-500);
    --di-seal-ink: var(--di-gold-400);
    --di-seal-bg: #33280f;
    --di-seal-border: #5a4718;
    --di-ai-ring: var(--di-gold-400);
    --di-ai-surface: #241d0c;
    --di-ai-ink: var(--di-gold-400);

    --di-inverse-bg: var(--di-night-800);
    --di-inverse-raised: var(--di-night-700);
    --di-inverse-border: var(--di-night-700);
    --di-inverse-text: #ffffff;
    --di-inverse-muted: var(--di-night-300);
    --di-inverse-seal: var(--di-gold-400);

    --di-sidebar-bg: #030914;
    --di-sidebar-raised: var(--di-night-900);
    --di-sidebar-fg: var(--di-night-paper);
    --di-sidebar-muted: var(--di-night-300);
    --di-sidebar-active: var(--di-night-800);
    --di-sidebar-edge: rgba(242, 240, 230, 0.08);
    --di-sidebar-focus: var(--di-gold-400);

    --di-status-ok-fg: var(--di-night-ok-300);
    --di-status-ok-bg: var(--di-night-ok-900);
    --di-status-ok-border: var(--di-night-ok-700);
    --di-status-ok-dot: var(--di-night-ok-300);
    --di-status-ok-on-navy: var(--di-night-ok-300);
    --di-status-warn-fg: var(--di-gold-400);
    --di-status-warn-bg: #2b2413;
    --di-status-warn-border: #574a24;
    --di-status-warn-dot: var(--di-gold-400);
    --di-status-danger-fg: var(--di-night-danger-300);
    --di-status-danger-bg: var(--di-night-danger-900);
    --di-status-danger-border: var(--di-night-danger-700);
    --di-status-danger-dot: var(--di-night-danger-300);
    --di-status-recorded-fg: var(--di-night-100);
    --di-status-recorded-bg: var(--di-night-800);
    --di-status-recorded-border: var(--di-night-700);
    --di-status-recorded-dot: var(--di-night-300);
    --di-status-neutral-fg: var(--di-night-300);
    --di-status-neutral-bg: var(--di-night-800);
    --di-status-neutral-border: var(--di-night-700);
    --di-status-neutral-dot: var(--di-night-300);

    --di-shadow-plane: 0 2px 4px rgba(0, 0, 0, 0.4),
      0 10px 24px rgba(0, 0, 0, 0.45);
    --di-shadow-window: 0 30px 60px -28px rgba(0, 0, 0, 0.7);
    --di-scrim: rgba(3, 9, 20, 0.72);

    --di-tile-bg: var(--di-night-800);
    --di-tile-fg: var(--di-night-100);
    --di-tile-inverse-bg: var(--di-gold-500);
    --di-tile-inverse-fg: var(--di-night-gold-ink);

    --di-badge-neutral-bg: var(--di-night-700);
    --di-badge-neutral-fg: var(--di-night-paper);
    --di-badge-alert-bg: #6e2a38;
    --di-badge-alert-fg: var(--di-night-100);
    --di-badge-seal-bg: #4a3d1c;
    --di-badge-seal-fg: #f0d48a;
  }
}
/* Per-component slots. A screen can restyle one control without editing it. */

@layer tokens {
  :root {
    --di-button-radius: var(--di-radius-control);
    --di-button-height: var(--di-h-ctl);
    --di-button-primary-bg: var(--di-fill-strong);
    --di-button-primary-fg: var(--di-text-on-strong);
    --di-button-primary-bg-hover: var(--di-fill-strong-hover);
    --di-button-secondary-bg: var(--di-bg-surface);
    --di-button-secondary-border: var(--di-border-input);

    --di-field-bg: var(--di-bg-surface);
    --di-field-border: var(--di-border-input);
    --di-field-radius: var(--di-radius-micro);
    --di-field-height: var(--di-h-ctl);

    --di-panel-bg: var(--di-bg-surface);
    --di-panel-border: var(--di-border);
    --di-panel-radius: var(--di-radius-surface);
    --di-panel-index-bg: var(--di-bg-page);

    --di-card-bg: var(--di-bg-surface);
    --di-card-border: var(--di-border);
    --di-card-radius: var(--di-radius-surface);

    --di-table-bg: var(--di-bg-grid);
    --di-table-row-height: var(--di-h-row);
    --di-table-rule: var(--di-rule-hairline);

    /* One line of label text. A control mark centres on it, so a
       single-line choice reads as centred and a described one does not. */
    --di-choice-line: calc(var(--di-font-size-400) * var(--di-leading-snug));
    --di-choice-mark: 16px;

    /* A waiting bar breathes rather than sweeping. One cycle, and how
       far apart two rows start, so a screen can retune the wait. */
    --di-skeleton-breath: 1400ms;
    --di-skeleton-stagger: 90ms;
    --di-skeleton-rest: 0.38;

    --di-pill-radius: var(--di-radius-pill);
    --di-pill-height: 20px;
  }
}
@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html,
  body {
    margin: 0;
    padding: 0;
  }

  body {
    background: var(--di-bg-page);
    color: var(--di-text);
    font-family: var(--di-font-ui);
    font-size: var(--di-font-size-400);
    font-weight: var(--di-weight-regular);
    line-height: var(--di-leading-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1,
  h2,
  h3,
  h4,
  p {
    margin: 0;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  button {
    cursor: pointer;
  }

  table {
    border-collapse: collapse;
  }

  svg.lucide {
    stroke-width: 1.5px;
  }

  img,
  svg {
    display: block;
  }

  :focus {
    outline: none;
  }

  /*
   * Navy on paper, gold on the night sheet and the navy rail. The
   * prototype rang the focus in seal gold throughout; gold on paper
   * measures 2.1:1, under the 3:1 a focus indicator has to clear, so
   * the ring follows the ground it sits on.
   */
  :focus-visible {
    outline: 2px solid var(--di-focus);
    outline-offset: 2px;
  }

  ::selection {
    background: var(--di-seal-bg);
    color: var(--di-text);
  }

  .di-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -var(--di-space-2);
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .di-quiet {
    font-size: var(--di-font-size-300);
    color: var(--di-text-muted);
  }

  /* Identifiers, timestamps and measured values run in the mono track. */
  .di-mono {
    font-family: var(--di-font-code);
    font-variant-numeric: tabular-nums;
  }

  /*
   * The one ornament in the system: an 8px tick scale. It closes a
   * header, or any block that reports a measured value.
   */
  .di-tick-rule {
    height: 5px;
    background-image: var(--di-tick);
  }

  .di-tick-rule-thin {
    height: 3px;
  }

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

@layer tokens, base, components, overrides;
@layer components {
  .di-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--di-space-6);
    height: var(--di-button-height);
    padding: 0 var(--di-space-12);
    border: 1px solid transparent;
    border-radius: var(--di-button-radius);
    font-family: var(--di-font-ui);
    font-size: var(--di-font-size-400);
    font-weight: var(--di-weight-medium);
    letter-spacing: var(--di-tracking-ui);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color var(--di-duration) var(--di-ease),
      border-color var(--di-duration) var(--di-ease),
      color var(--di-duration) var(--di-ease);
  }

  .di-btn > svg {
    width: 16px;
    height: 16px;
    flex: none;
  }

  .di-btn-dense {
    height: var(--di-h-dense);
    padding: 0 var(--di-space-12);
    font-size: var(--di-font-size-300);
  }

  .di-btn-md {
    height: var(--di-h-ctl);
  }

  .di-btn-comfort {
    height: var(--di-h-comfort);
    padding: 0 var(--di-space-16);
    font-size: var(--di-font-size-500);
  }

  .di-btn-icon {
    width: var(--di-h-ctl);
    padding: 0;
  }

  .di-btn-icon.di-btn-dense {
    width: var(--di-h-dense);
  }

  .di-btn-icon.di-btn-comfort {
    width: var(--di-h-comfort);
  }

  /* The one filled control on the sheet. */
  .di-btn-primary {
    border-color: var(--di-button-primary-bg);
    background: var(--di-button-primary-bg);
    color: var(--di-button-primary-fg);
  }

  .di-btn-primary:hover:not(:disabled, [aria-disabled="true"]) {
    border-color: var(--di-button-primary-bg-hover);
    background: var(--di-button-primary-bg-hover);
  }

  .di-btn-secondary {
    border-color: var(--di-button-secondary-border);
    background: var(--di-button-secondary-bg);
    color: var(--di-text);
  }

  .di-btn-secondary:hover:not(:disabled, [aria-disabled="true"]) {
    border-color: var(--di-text);
    background: var(--di-bg-page);
  }

  .di-btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--di-text);
    text-decoration: underline;
    text-decoration-color: var(--di-seal);
    text-underline-offset: 3px;
  }

  .di-btn-ghost:hover:not(:disabled, [aria-disabled="true"]) {
    background: var(--di-bg-subtle);
  }

  /*
   * Destructive reads as a normal control until it is hovered. A red
   * fill sitting in a toolbar invites the press it is trying to guard.
   */
  .di-btn-danger {
    border-color: var(--di-button-secondary-border);
    background: var(--di-button-secondary-bg);
    color: var(--di-status-danger-fg);
  }

  .di-btn-danger:hover:not(:disabled, [aria-disabled="true"]) {
    border-color: var(--di-status-danger-dot);
    background: var(--di-status-danger-bg);
  }

  /* Seals a record: gold, and the only gold control in daylight. */
  .di-btn-seal {
    border-color: var(--di-seal-border);
    background: var(--di-seal-bg);
    color: var(--di-seal-ink);
  }

  .di-btn-seal:hover:not(:disabled, [aria-disabled="true"]) {
    border-color: var(--di-seal);
  }

  /* Acts on a model's proposal, so it carries the ring's edge. */
  .di-btn-inferred {
    border-color: var(--di-ai-ring);
    background: var(--di-bg-surface);
    color: var(--di-text);
  }

  .di-btn-inferred:hover:not(:disabled, [aria-disabled="true"]) {
    background: var(--di-ai-surface);
  }

  .di-btn:disabled,
  .di-btn[aria-disabled="true"] {
    cursor: not-allowed;
    border-color: var(--di-border);
    background: var(--di-bg-disabled);
    color: var(--di-text-disabled);
    text-decoration: none;
  }

  .di-btn-loading {
    cursor: progress;
  }

  .di-btn-spinner {
    width: 11px;
    height: 11px;
    flex: none;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: var(--di-radius-pill);
    animation: di-btn-spin 700ms linear infinite;
  }

  @keyframes di-btn-spin {
    to {
      transform: rotate(360deg);
    }
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-card {
    background: var(--di-card-bg);
    border: 1px solid var(--di-card-border);
    border-radius: var(--di-card-radius);
    min-width: 0;
  }

  .di-card-pad {
    padding: var(--di-space-16) var(--di-space-16);
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-panel {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--di-panel-border);
    border-radius: var(--di-panel-radius);
    background: var(--di-panel-bg);
  }

  /* The cold surface. Reserved for an extract from the record. */
  .di-panel-grid {
    background: var(--di-bg-grid);
    border-color: var(--di-border-strong);
  }

  .di-panel.is-danger {
    border-color: var(--di-status-danger-border);
  }

  .di-panel-index {
    width: var(--di-index-col);
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--di-space-12) 0;
    border-right: 1px solid var(--di-panel-border);
    background: var(--di-panel-index-bg);
  }

  .di-panel-index-sm {
    width: var(--di-index-col-sm);
  }

  .di-panel.is-danger .di-panel-index {
    border-right-color: var(--di-status-danger-border);
    background: var(--di-status-danger-bg);
  }

  .di-panel-index-label {
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-100);
    font-weight: var(--di-weight-medium);
    font-variant-numeric: tabular-nums;
    color: var(--di-text-subtle);
  }

  .di-panel.is-danger .di-panel-index-label {
    color: var(--di-status-danger-fg);
  }

  .di-panel-index-rule {
    width: 1px;
    flex: 1;
    margin-top: var(--di-space-8);
    background: var(--di-rule);
  }

  .di-panel-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  .di-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--di-space-12);
    padding: var(--di-space-8) var(--di-space-12);
    border-bottom: 1px solid var(--di-rule-hairline);
  }

  .di-panel-title {
    font-size: var(--di-font-size-400);
    font-weight: var(--di-weight-semibold);
    letter-spacing: var(--di-tracking-tight);
    color: var(--di-text);
  }

  .di-panel-meta {
    flex: none;
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-200);
    font-variant-numeric: tabular-nums;
    color: var(--di-text-subtle);
  }

  .di-panel-content {
    --di-panel-pad: var(--di-space-16);
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--di-panel-pad);
  }

  .di-panel-content-flush {
    --di-panel-pad: 0px;
  }

  /*
   * The footer is written as a child, so it has to reach back out through
   * the content padding to sit on the panel's own edges. When the panel is
   * flush the padding is zero and these margins come to nothing.
   */
  .di-panel-footer {
    display: flex;
    align-items: center;
    gap: var(--di-space-8);
    margin: var(--di-panel-pad) calc(-1 * var(--di-panel-pad)) calc(-1 * var(--di-panel-pad));
    margin-top: auto;
    padding: var(--di-space-8) var(--di-space-12);
    border-top: 1px solid var(--di-rule-hairline);
    background: var(--di-bg-page);
  }

  .di-panel-note {
    margin-top: var(--di-space-8);
    font-size: var(--di-font-size-300);
    line-height: var(--di-leading-snug);
    color: var(--di-text-muted);
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-field textarea.di-control {
    height: auto;
    min-height: 76px;
    padding: var(--di-space-8) var(--di-space-8);
    line-height: var(--di-leading-snug);
    resize: vertical;
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-notice {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--di-border);
    border-radius: var(--di-radius-surface);
    background: var(--di-bg-surface);
  }

  /* The icon column echoes the panel's index: a notice is also a record. */
  .di-notice-icon {
    display: flex;
    justify-content: center;
    width: var(--di-index-col);
    flex: none;
    padding-top: var(--di-space-12);
    border-right: 1px solid var(--di-border);
    background: var(--di-bg-page);
  }

  .di-notice-icon > svg {
    width: 17px;
    height: 17px;
  }

  .di-notice-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--di-space-16);
    padding: var(--di-space-12) var(--di-space-12);
  }

  .di-notice-title {
    font-size: var(--di-font-size-400);
    font-weight: var(--di-weight-semibold);
    letter-spacing: var(--di-tracking-tight);
    line-height: var(--di-leading-snug);
    color: var(--di-text);
  }

  .di-notice-body {
    margin-top: var(--di-space-2);
    font-size: var(--di-font-size-300);
    line-height: var(--di-leading-snug);
    color: var(--di-text-muted);
  }

  .di-notice-action {
    flex: none;
    align-self: center;
  }

  .di-notice-neutral .di-notice-icon {
    color: var(--di-text-muted);
  }

  .di-notice-ok {
    border-color: var(--di-status-ok-border);
  }

  .di-notice-ok .di-notice-icon {
    border-right-color: var(--di-status-ok-border);
    background: var(--di-status-ok-bg);
    color: var(--di-status-ok-fg);
  }

  .di-notice-warn {
    border-color: var(--di-status-warn-border);
  }

  .di-notice-warn .di-notice-icon {
    border-right-color: var(--di-status-warn-border);
    background: var(--di-status-warn-bg);
    color: var(--di-status-warn-fg);
  }

  .di-notice-danger {
    border-color: var(--di-status-danger-border);
  }

  .di-notice-danger .di-notice-icon {
    border-right-color: var(--di-status-danger-border);
    background: var(--di-status-danger-bg);
    color: var(--di-status-danger-fg);
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 var(--di-space-6);
    border-radius: var(--di-radius-pill);
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-100);
    font-weight: var(--di-weight-medium);
    font-variant-numeric: tabular-nums;
    line-height: 1;
  }

  .di-badge-neutral {
    background: var(--di-badge-neutral-bg);
    color: var(--di-badge-neutral-fg);
  }

  .di-badge-alert {
    background: var(--di-badge-alert-bg);
    color: var(--di-badge-alert-fg);
  }

  .di-badge-seal {
    background: var(--di-badge-seal-bg);
    color: var(--di-badge-seal-fg);
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--di-space-4);
    height: var(--di-pill-height);
    padding: 0 var(--di-space-8);
    border: 1px solid transparent;
    border-radius: var(--di-pill-radius);
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-100);
    font-weight: var(--di-weight-medium);
    letter-spacing: var(--di-tracking-mono);
    line-height: 1;
    white-space: nowrap;
  }

  .di-pill-dot {
    width: 5px;
    height: 5px;
    flex: none;
    border-radius: var(--di-radius-pill);
    background: currentColor;
    position: relative;
    top: -0.5px; /* optical centre on the uppercase mono label */
  }

  .di-pill-ring {
    background: transparent;
    border: 1.5px solid var(--di-ai-ring);
  }

  .di-pill-ok {
    border-color: var(--di-status-ok-border);
    background: var(--di-status-ok-bg);
    color: var(--di-status-ok-fg);
  }

  .di-pill-ok .di-pill-dot {
    background: var(--di-status-ok-dot);
  }

  .di-pill-warn {
    border-color: var(--di-status-warn-border);
    background: var(--di-status-warn-bg);
    color: var(--di-status-warn-fg);
  }

  .di-pill-warn .di-pill-dot {
    background: var(--di-status-warn-dot);
  }

  .di-pill-danger {
    border-color: var(--di-status-danger-border);
    background: var(--di-status-danger-bg);
    color: var(--di-status-danger-fg);
  }

  .di-pill-danger .di-pill-dot {
    background: var(--di-status-danger-dot);
  }

  .di-pill-recorded {
    border-color: var(--di-status-recorded-border);
    background: var(--di-status-recorded-bg);
    color: var(--di-status-recorded-fg);
  }

  .di-pill-recorded .di-pill-dot {
    background: var(--di-status-recorded-dot);
  }

  .di-pill-neutral {
    border-color: var(--di-status-neutral-border);
    background: var(--di-status-neutral-bg);
    color: var(--di-status-neutral-fg);
  }

  .di-pill-neutral .di-pill-dot {
    background: var(--di-status-neutral-dot);
  }

  .di-pill-inferred {
    border-color: var(--di-seal-border);
    background: var(--di-ai-surface);
    color: var(--di-ai-ink);
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-tabs {
    display: flex;
    gap: var(--di-space-2);
    border-bottom: 1px solid var(--di-border);
  }

  .di-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--di-space-6);
    height: var(--di-h-comfort);
    padding: 0 var(--di-space-12);
    margin-bottom: -var(--di-space-2);
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--di-text-muted);
    font-size: var(--di-font-size-400);
    font-weight: var(--di-weight-medium);
    white-space: nowrap;
    transition: color var(--di-duration) var(--di-ease),
      border-color var(--di-duration) var(--di-ease);
  }

  .di-tab:hover:not(:disabled) {
    color: var(--di-text);
  }

  .di-tab.is-active {
    border-bottom-color: var(--di-fill-strong);
    color: var(--di-text);
  }

  .di-tab:disabled {
    color: var(--di-text-disabled);
    cursor: not-allowed;
  }

  .di-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 var(--di-space-4);
    border-radius: var(--di-radius-pill);
    background: var(--di-bg-subtle);
    color: var(--di-text-muted);
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-100);
    line-height: 1;
  }

  .di-tabpanel {
    padding-top: var(--di-space-16);
  }
}

@layer tokens, base, components, overrides;
@layer components {
  .di-table-wrap {
    overflow: hidden;
    border: 1px solid var(--di-border-strong);
    border-radius: var(--di-radius-surface);
    background: var(--di-table-bg);
  }

  .di-table-toolbar {
    display: flex;
    align-items: center;
    gap: var(--di-space-8);
    padding: var(--di-space-8) var(--di-space-12);
    border-bottom: 1px solid var(--di-border);
    background: var(--di-bg-page);
  }

  /* The table scrolls inside its own frame; the page does not. */
  .di-table-scroll {
    overflow-x: auto;
  }

  .di-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--di-font-size-400);
  }

  .di-table th {
    height: 32px;
    padding: 0 var(--di-space-12);
    border-bottom: 1px solid var(--di-border);
    background: var(--di-bg-page);
    text-align: left;
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-200);
    font-weight: var(--di-weight-medium);
    letter-spacing: var(--di-tracking-eyebrow);
    text-transform: uppercase;
    color: var(--di-text-muted);
    white-space: nowrap;
  }

  .di-table th.is-sorted {
    color: var(--di-text);
  }

  .di-table-sort {
    margin-left: var(--di-space-4);
  }

  .di-table td {
    height: var(--di-table-row-height);
    padding: 0 var(--di-space-12);
    border-bottom: 1px solid var(--di-table-rule);
    color: var(--di-text);
    vertical-align: middle;
  }

  .di-table tbody tr:last-child td {
    border-bottom: 0;
  }

  .di-table tbody tr:hover td {
    background: var(--di-bg-row-hover);
  }

  .di-table tbody tr.is-active td {
    background: var(--di-bg-page);
  }

  /* The ordinal column: the row's handle, never its content. */
  .di-table-index {
    width: var(--di-index-col);
    padding: 0 !important;
    border-right: 1px solid var(--di-table-rule);
    background: var(--di-bg-page);
    text-align: center;
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-100);
    font-variant-numeric: tabular-nums;
    color: var(--di-text-subtle);
  }

  .di-table tbody tr.is-danger .di-table-index {
    background: var(--di-status-danger-bg);
    color: var(--di-status-danger-fg);
  }

  .di-table .is-end {
    text-align: right;
  }

  .di-table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--di-space-12);
    padding: var(--di-space-8) var(--di-space-12);
    border-top: 1px solid var(--di-border);
    background: var(--di-bg-page);
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-200);
    color: var(--di-text-muted);
  }

  .di-cell {
    display: flex;
    flex-direction: column;
    gap: var(--di-space-2);
    min-width: 0;
  }

  .di-cell-primary {
    font-size: var(--di-font-size-400);
    line-height: var(--di-leading-snug);
    color: var(--di-text);
  }

  .di-cell-secondary {
    font-family: var(--di-font-code);
    font-size: var(--di-font-size-200);
    line-height: var(--di-leading-snug);
    color: var(--di-text-subtle);
  }

  .di-cell-lead {
    display: flex;
    align-items: center;
    gap: var(--di-space-8);
    min-width: 0;
  }

  .di-cell-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: none;
    border-radius: var(--di-radius-micro);
    background: var(--di-bg-subtle);
    color: var(--di-text-muted);
  }

  .di-cell-icon > svg {
    width: 14px;
    height: 14px;
  }
}
