/* dakit 0.2.0 0e283cd */
@layer dk.base, dk.components;

/* Generated by build.mjs from tokens/*.json — do not edit; edit the tokens and rebuild. */
:root {
  color-scheme: light;
  --dk-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --dk-font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --dk-text-xs: 11px;
  --dk-text-sm: 12px;
  --dk-text-md: 13px;
  --dk-text-body: 14px;
  --dk-text-lg: 16px;
  --dk-text-xl: 22px;
  --dk-text-page: 32px;
  --dk-leading-tight: 1.2;
  --dk-leading-normal: 1.5;
  --dk-weight-regular: 400;
  --dk-weight-medium: 500;
  --dk-weight-semibold: 600;
  --dk-weight-bold: 700;
  --dk-space-1: 4px;
  --dk-space-2: 8px;
  --dk-space-3: 12px;
  --dk-space-4: 16px;
  --dk-space-5: 20px;
  --dk-space-6: 24px;
  --dk-space-7: 32px;
  --dk-space-8: 40px;
  --dk-radius-none: 0;
  --dk-radius-sm: 4px;
  --dk-radius-md: 6px;
  --dk-radius-lg: 10px;
  --dk-radius-full: 999px;
  --dk-size-control-sm: 28px;
  --dk-size-control-md: 34px;
  --dk-size-control-lg: 40px;
  --dk-size-touch: 44px;
  --dk-size-sidebar: 240px;
  --dk-size-rail: 56px;
  --dk-size-topbar: 48px;
  --dk-size-menu: 256px;
  --dk-size-panel: 384px;
  --dk-size-split-list: 320px;
  --dk-size-measure: 896px;
  --dk-size-content-max: 1120px;
  --dk-bg-page: #ffffff;
  --dk-bg-surface: #ffffff;
  --dk-bg-muted: #f6f8fa;
  --dk-bg-hover: #eef1f4;
  --dk-bg-raised: #ffffff;
  --dk-bg-inset: rgba(36, 41, 47, 0.06);
  --dk-bg-backdrop: rgba(15, 23, 42, 0.4);
  --dk-text-primary: #24292f;
  --dk-text-heading: #0f172a;
  --dk-text-muted: #57606a;
  --dk-text-faint: #6e7681;
  --dk-text-link: #315f8f;
  --dk-text-link-hover: #244d78;
  --dk-text-on-accent: #ffffff;
  --dk-text-on-deep: #ffffff;
  --dk-border-default: #d0d7de;
  --dk-border-control-hover: #d0d7de;
  --dk-border-strong: #afb8c1;
  --dk-accent-default: #315f8f;
  --dk-accent-hover: #244d78;
  --dk-accent-soft: #edf5ff;
  --dk-accent-deep: #244d78;
  --dk-accent-deep-hover: #244d78;
  --dk-accent-deeper: #1c3d5e;
  --dk-focus-ring: rgba(49, 95, 143, 0.6);
  --dk-selection: #dde9f7;
  --dk-success-text: #116329;
  --dk-success-bg: #e6f6ea;
  --dk-warning-text: #7a5c00;
  --dk-warning-bg: #fff8c5;
  --dk-danger-text: #cf222e;
  --dk-danger-hover: #a40e26;
  --dk-danger-bg: #fff0ee;
  --dk-info-text: #315f8f;
  --dk-info-bg: #edf5ff;
  --dk-shadow-overlay: 0 8px 24px rgba(15, 23, 42, 0.16);
  --dk-spinner-size: 16px;
  --dk-spinner-size-lg: 24px;
  --dk-spinner-stroke: 2px;
  --dk-spinner-color: #315f8f;
  --dk-spinner-track: #d0d7de;
  --dk-spinner-duration: 800ms;
  --dk-loading-delay-busy: 150ms;
  --dk-loading-delay-overlay: 500ms;
  --dk-tabs-track: #f6f8fa;
  --dk-tabs-text: #57606a;
  --dk-tabs-hover: #eef1f4;
  --dk-tabs-hover-text: #24292f;
  --dk-tabs-selected: #edf5ff;
  --dk-tabs-selected-text: #315f8f;
  --dk-tabs-count: #57606a;
  --dk-tabs-disabled-text: #6e7681;
  --dk-tabs-focus: rgba(49, 95, 143, 0.6);
  --dk-tabs-radius: 6px;
  --dk-tabs-radius-item: 4px;
  --dk-tabs-pad: 4px;
  --dk-tabs-gap: 4px;
  --dk-tabs-height: 28px;
  --dk-tabs-height-sm: 24px;
  --dk-tabs-pad-x: 12px;
  --dk-tabs-pad-x-sm: 8px;
  --dk-gap-control: 12px;
  --dk-gap-block: 16px;
  --dk-gap-section: 24px;
  --dk-pad-cell: 8px 12px;
  --dk-pad-panel: 16px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --dk-bg-page: #0d1117;
  --dk-bg-surface: #161b22;
  --dk-bg-muted: #21262d;
  --dk-bg-hover: #293038;
  --dk-bg-raised: #32383f;
  --dk-bg-inset: rgba(230, 237, 243, 0.07);
  --dk-bg-backdrop: rgba(1, 4, 9, 0.5);
  --dk-text-primary: #e6edf3;
  --dk-text-heading: #f0f6fc;
  --dk-text-muted: #9198a1;
  --dk-text-faint: #8b949e;
  --dk-text-link: #58a6ff;
  --dk-text-link-hover: #79b8ff;
  --dk-text-on-accent: #0d1117;
  --dk-text-on-deep: #ffffff;
  --dk-border-default: #30363d;
  --dk-border-control-hover: #8b949e;
  --dk-border-strong: #6e7681;
  --dk-accent-default: #58a6ff;
  --dk-accent-hover: #79b8ff;
  --dk-accent-soft: rgba(88, 166, 255, 0.14);
  --dk-accent-deep: #1c3d5e;
  --dk-accent-deep-hover: #244d78;
  --dk-accent-deeper: #10233c;
  --dk-focus-ring: rgba(88, 166, 255, 0.55);
  --dk-selection: rgba(88, 166, 255, 0.35);
  --dk-success-text: #56d364;
  --dk-success-bg: rgba(46, 160, 67, 0.15);
  --dk-warning-text: #e3b341;
  --dk-warning-bg: rgba(187, 128, 9, 0.15);
  --dk-danger-text: #f85149;
  --dk-danger-hover: #ffa198;
  --dk-danger-bg: rgba(248, 81, 73, 0.12);
  --dk-info-text: #79b8ff;
  --dk-info-bg: rgba(88, 166, 255, 0.12);
  --dk-shadow-overlay: 0 8px 24px rgba(1, 4, 9, 0.6);
  --dk-spinner-color: #58a6ff;
  --dk-spinner-track: #30363d;
  --dk-tabs-track: #21262d;
  --dk-tabs-text: #9198a1;
  --dk-tabs-hover: #293038;
  --dk-tabs-hover-text: #e6edf3;
  --dk-tabs-selected: rgba(88, 166, 255, 0.14);
  --dk-tabs-selected-text: #58a6ff;
  --dk-tabs-count: #9198a1;
  --dk-tabs-disabled-text: #8b949e;
  --dk-tabs-focus: rgba(88, 166, 255, 0.55);
}

@layer dk.base {
/* --- base ---------------------------------------------------------------- */
/* Dakit base: reset and element defaults on top of the semantic tokens.
   Everything here uses --dk-* semantic roles only — never a raw color. */

/* Self-hosted fonts (SIL OFL). URLs are relative to dist/, where this file
   is bundled — importing dist/dakit.css wires the fonts up automatically. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("./fonts/inter-var.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  /* Mono maxes at 500: only 400/500 ship, so the 500 face also answers
     600/700 requests instead of letting the browser smear a fake bold. */
  font-weight: 500 700;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-500.woff2") format("woff2");
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--dk-bg-page);
  color: var(--dk-text-primary);
  font-family: var(--dk-font-sans);
  font-size: var(--dk-text-body);
  line-height: var(--dk-leading-normal);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

/* One dropdown everywhere: the native arrow hugs the right edge, so every
   select gets dakit's chevron, set 12px off it. The glyph is an image and
   cannot read a token, so its ink is baked to match --dk-text-muted per
   theme (light #57606a, dark #9198a1) and flipped here. color-scheme rides
   the same flip so the browser's own chrome (the opened dropdown, spinners,
   scrollbars) follows the theme even where an app styles nothing itself. */
:root {
  color-scheme: light;
  --dk-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2357606a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --dk-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239198a1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: calc(2 * var(--dk-space-3) + 10px); /* text clears the glyph */
  background-image: var(--dk-select-chevron);
  background-repeat: no-repeat;
  background-position: right var(--dk-space-3) center;
  cursor: pointer;
}

a { color: var(--dk-text-link); }
a:hover { color: var(--dk-text-link-hover); }

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: var(--dk-text-page); font-weight: var(--dk-weight-bold); line-height: var(--dk-leading-tight); color: var(--dk-text-heading); }
h2 { font-size: var(--dk-text-xl); font-weight: var(--dk-weight-semibold); line-height: var(--dk-leading-tight); color: var(--dk-text-heading); }
h3 { font-size: var(--dk-text-lg); font-weight: var(--dk-weight-semibold); line-height: var(--dk-leading-tight); color: var(--dk-text-heading); }
h4 { font-size: var(--dk-text-body); font-weight: var(--dk-weight-semibold); color: var(--dk-text-heading); }

strong { font-weight: var(--dk-weight-semibold); }

/* Quantities, timings, IDs, code: mono so data reads as data, not prose. */
code, kbd, samp { font-family: var(--dk-font-mono); font-size: 0.92em; background: var(--dk-bg-inset); padding: 1px 5px; border-radius: var(--dk-radius-sm); }
/* An inline command or ID is one chip; it never splits across lines. */
:not(pre) > code { white-space: nowrap; }

::selection { background: var(--dk-selection); }

:focus-visible { outline: 3px solid var(--dk-focus-ring); outline-offset: 2px; }

[hidden] { display: none !important; }

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

/* Utilities */
.dk-mono { font-family: var(--dk-font-mono); }
.dk-muted { color: var(--dk-text-muted); }
.dk-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

}
@layer dk.components {
/* --- components ----------------------------------------------------------- */
/* Dakit components: the small shared vocabulary (buttons, fields, cards,
   chips, tables). Class prefix is dk-. Rules:
   - semantic tokens only, never primitive ramps or raw colors
   - sizes come from --dk-size-*, spacing from --dk-space-*, text from --dk-text-*
   - keep this file small: app-specific layout belongs in the app */

/* --- buttons --------------------------------------------------------------- */

.dk-button {
  height: var(--dk-size-control-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--dk-space-2);
  border: 1px solid transparent;
  border-radius: var(--dk-radius-md);
  padding: 0 var(--dk-space-4);
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-medium);
  white-space: nowrap;
  text-decoration: none;
}

.dk-button--sm { height: var(--dk-size-control-sm); padding: 0 var(--dk-space-3); font-size: var(--dk-text-sm); }
.dk-button--lg { height: var(--dk-size-control-lg); padding: 0 var(--dk-space-5); font-size: var(--dk-text-body); }

.dk-button--primary { background: var(--dk-accent-default); color: var(--dk-text-on-accent); }
.dk-button--primary:hover { background: var(--dk-accent-hover); }

/* Secondary = muted surface + neutral border + primary text (the family
   recipe); quiet controls gain --dk-border-control-hover on hover. */
.dk-button--secondary { border-color: var(--dk-border-default); background: var(--dk-bg-muted); color: var(--dk-text-primary); }
.dk-button--secondary:hover { border-color: var(--dk-border-control-hover); background: var(--dk-bg-hover); }

.dk-button--danger { border-color: var(--dk-border-default); background: transparent; color: var(--dk-danger-text); }
.dk-button--danger:hover { background: var(--dk-danger-bg); }

/* Disabled is one role-based treatment for every variant, so a gated primary
   can't read as an enabled one in either theme: muted fill, muted text
   (contrast-checked as text.muted on bg.muted), neutral border, no hover. */
.dk-button:disabled,
.dk-button:disabled:hover {
  border-color: var(--dk-border-default);
  background: var(--dk-bg-muted);
  color: var(--dk-text-muted);
  cursor: not-allowed;
}

/* --- fields ----------------------------------------------------------------- */

.dk-label { display: block; margin-bottom: var(--dk-space-1); color: var(--dk-text-heading); font-size: var(--dk-text-sm); font-weight: var(--dk-weight-semibold); }
.dk-hint { margin-top: var(--dk-space-1); color: var(--dk-text-muted); font-size: var(--dk-text-sm); }

.dk-input, .dk-select, .dk-textarea {
  width: 100%;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  /* background-color, not the shorthand: the base layer's select chevron is a
     background-image and must survive. */
  background-color: var(--dk-bg-page);
  color: var(--dk-text-primary);
  padding: 0 var(--dk-space-3);
  height: var(--dk-size-control-md);
  font-size: var(--dk-text-md);
}
.dk-textarea { height: auto; min-height: 76px; padding: var(--dk-space-2) var(--dk-space-3); resize: vertical; }
/* Keep the class's own clearance for the base layer's chevron rather than
   inheriting it from the element rule's higher specificity. */
.dk-select { padding-right: calc(2 * var(--dk-space-3) + 10px); }
.dk-input::placeholder, .dk-textarea::placeholder { color: var(--dk-text-faint); }
.dk-input:hover, .dk-select:hover, .dk-textarea:hover { border-color: var(--dk-border-strong); }
.dk-input:focus-visible, .dk-select:focus-visible, .dk-textarea:focus-visible { outline: 3px solid var(--dk-focus-ring); outline-offset: 2px; }

/* --- cards & surfaces ------------------------------------------------------- */

.dk-card {
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-surface);
  padding: var(--dk-pad-panel);
}
.dk-card--muted { background: var(--dk-bg-muted); }

/* --- chips & status ---------------------------------------------------------- */

.dk-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--dk-space-1);
  padding: 1px var(--dk-space-2);
  border: 1px solid var(--dk-border-strong);
  border-radius: var(--dk-radius-full);
  background: var(--dk-bg-muted);
  color: var(--dk-text-muted);
  font-size: var(--dk-text-xs);
  line-height: 1.6;
  white-space: nowrap;
}

.dk-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--dk-space-1);
  padding: 1px var(--dk-space-2);
  border: 1px solid transparent;
  border-radius: var(--dk-radius-sm);
  font-size: var(--dk-text-xs);
  font-weight: var(--dk-weight-medium);
  white-space: nowrap;
}
.dk-badge--success { color: var(--dk-success-text); background: var(--dk-success-bg); }
.dk-badge--warning { color: var(--dk-warning-text); background: var(--dk-warning-bg); }
.dk-badge--danger { color: var(--dk-danger-text); background: var(--dk-danger-bg); }
.dk-badge--info { color: var(--dk-info-text); background: var(--dk-info-bg); }

.dk-dot { width: 8px; height: 8px; border-radius: var(--dk-radius-full); display: inline-block; flex: none; }
.dk-dot--success { background: var(--dk-success-text); }
.dk-dot--warning { background: var(--dk-warning-text); }
.dk-dot--danger { background: var(--dk-danger-text); }
.dk-dot--info { background: var(--dk-info-text); }
.dk-dot--neutral { background: var(--dk-text-faint); }

/* --- tables ------------------------------------------------------------------- */

.dk-table { width: 100%; border-collapse: collapse; font-size: var(--dk-text-md); }
.dk-table th {
  text-align: left;
  color: var(--dk-text-muted);
  font-size: var(--dk-text-xs);
  font-weight: var(--dk-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--dk-pad-cell);
  border-bottom: 1px solid var(--dk-border-default);
}
.dk-table td { padding: var(--dk-pad-cell); border-bottom: 1px solid var(--dk-border-default); vertical-align: top; }
.dk-table tbody tr:hover td { background: var(--dk-bg-hover); }

/* Register footer band: count, "Load more" and pagination live inside the
   bordered container, never flush below it. Place it as the container's
   last child (after the table). */
.dk-table-footer,
.dk-panel__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dk-gap-control);
  /* gap-block above and below: the band's controls keep the same 16px from
     the rows that every control keeps from a block */
  padding: var(--dk-gap-block) var(--dk-space-4);
  border-top: 1px solid var(--dk-border-default);
  background: var(--dk-bg-muted);
  color: var(--dk-text-muted);
  font-size: var(--dk-text-sm);
}
/* A .dk-table's last row already draws the divider above the band. */
.dk-table + .dk-table-footer { border-top: 0; }

/* --- layout rhythm ---------------------------------------------------------------
   Three primitives so apps stop inventing gaps: a stack (vertical rhythm), a
   cluster (a wrapping row of controls), and a toolbar (one filter/action bar
   above a register). The gaps are the --dk-gap-* roles. */

.dk-stack { display: flex; flex-direction: column; gap: var(--dk-stack-gap, var(--dk-gap-block)); }
.dk-stack--tight { --dk-stack-gap: var(--dk-space-2); }
.dk-stack--section { --dk-stack-gap: var(--dk-gap-section); }

/* 12px between controls, also as the row gap when the group wraps. */
.dk-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-gap-control); min-width: 0; }

/* Search + filters on the left, count, then actions pushed right; it wraps as
   one unit and keeps the block gap above the register it controls. */
.dk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--dk-gap-control);
  margin-bottom: var(--dk-gap-block);
  min-width: 0;
}
.dk-toolbar__end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-gap-control); margin-left: auto; }

/* Collection header (docs/guidelines.md "Action placement"): the create
   action sits right after the collection's title, so the eye that reads
   "Schedules" lands on "+ New schedule"; meta (a count) and secondary
   actions trail. It wraps as a unit: title and create stay together. Inside
   a .dk-split__head or .dk-toolbar, use __lead/__trail directly. Built by
   dist/collection.js (dakitCollection.header / headerMarkup). */
.dk-collection-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--dk-space-2) var(--dk-gap-control); min-width: 0; }
.dk-collection-header__lead { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-3); min-width: 0; }
.dk-collection-header__lead > :is(h1, h2, h3, h4) { margin: 0; }
.dk-collection-header__title { color: var(--dk-text-heading); font-size: var(--dk-text-lg); font-weight: var(--dk-weight-semibold); overflow-wrap: anywhere; }
.dk-collection-header__trail { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-2); margin-left: auto; }
.dk-collection-header__meta { color: var(--dk-text-muted); font-size: var(--dk-text-sm); }
/* "+ New schedule": a small button with a leading plus; 44px on touch like every .dk-button. */
.dk-collection-create { display: inline-flex; align-items: center; gap: var(--dk-space-1); white-space: nowrap; }
.dk-collection-create__icon { display: inline-flex; }
.dk-collection-create__icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* --- dialogs ---------------------------------------------------------------------
   <dialog class="dk-dialog"> with head / body / foot children (a wrapping
   <form> sits between as display: contents). The body scrolls; head and
   foot stay put. At phone width the dialog becomes a full-screen sheet with
   the foot kept at the bottom. Load dist/dialogs.js once per page and
   clicking the backdrop closes the dialog. */
.dk-dialog {
  /* Wider dialogs set --dk-dialog-width; the phone sheet ignores it. */
  width: min(var(--dk-dialog-width, 560px), calc(100vw - 2 * var(--dk-space-4)));
  max-height: calc(100dvh - 2 * var(--dk-space-7));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-lg);
  background: var(--dk-bg-surface);
  color: var(--dk-text-primary);
  box-shadow: var(--dk-shadow-overlay);
  overscroll-behavior: contain;
}
.dk-dialog[open] { display: flex; flex-direction: column; }
.dk-dialog > form { display: contents; }
.dk-dialog::backdrop { background: var(--dk-bg-backdrop); }
.dk-dialog__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--dk-gap-control);
  padding: var(--dk-space-4) var(--dk-space-5);
  border-bottom: 1px solid var(--dk-border-default);
}
.dk-dialog__head h2 { min-width: 0; font-size: var(--dk-text-lg); font-weight: var(--dk-weight-semibold); overflow-wrap: anywhere; }
.dk-dialog__head > div:not(.dk-tabs) { min-width: 0; display: grid; gap: var(--dk-space-1); }
.dk-dialog__head p { margin: 0; color: var(--dk-text-muted); font-size: var(--dk-text-sm); }
.dk-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: var(--dk-gap-block);
  padding: var(--dk-space-5);
}
/* Primary last (at the end), Cancel before it; a destructive action is
   separated to the start with margin-right: auto. */
.dk-dialog__foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--dk-gap-control);
  padding: var(--dk-space-3) var(--dk-space-5);
  border-top: 1px solid var(--dk-border-default);
}
.dk-dialog__foot > .dk-button--danger:first-child,
.dk-dialog__foot > .dk-dialog__start { margin-right: auto; }

/* One flat sheet: controls share the panel surface instead of an inset fill. */
.dk-dialog :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) { background-color: var(--dk-bg-surface); }

@media (max-width: 820px) {
  .dk-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .dk-dialog__head { min-height: 64px; padding: var(--dk-space-2) var(--dk-space-4); }
  .dk-dialog__body { padding: var(--dk-space-4); }
  .dk-dialog__foot { padding: var(--dk-space-3) var(--dk-space-4) calc(var(--dk-space-3) + env(safe-area-inset-bottom, 0px)); }
}

/* --- loading: spinner, busy trigger, loading overlay, toast (docs/dialog-loading.md)
   A dialog that needs data opens only when the data is in. Until then the
   trigger carries aria-busy="true": a busy .dk-button / .dk-icon-button keeps
   its size and swaps its label for a spinner after --dk-loading-delay-busy, so
   fast loads never flicker. A slow load (or a trigger with no room for a
   spinner, like a row) gets .dk-loading: the dialog's own backdrop with a
   small centred status, so the page goes backdrop -> finished dialog in one
   swap and nothing reflows. dist/dialogs.js (openWhenReady) drives all of it. */

.dk-spinner,
:is(.dk-button, .dk-icon-button)[aria-busy="true"]::before {
  width: var(--dk-spinner-size);
  height: var(--dk-spinner-size);
  flex: none;
  border-radius: var(--dk-radius-full);
  /* A ring: a 30% arc over the track, hollowed by a radial mask. */
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--dk-spinner-stroke) - 0.5px), black calc(100% - var(--dk-spinner-stroke)));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--dk-spinner-stroke) - 0.5px), black calc(100% - var(--dk-spinner-stroke)));
  animation: dk-spin var(--dk-spinner-duration) linear infinite, dk-reveal 1ms var(--dk-loading-delay-busy) backwards;
}
.dk-spinner {
  display: inline-block;
  vertical-align: middle;
  color: var(--dk-spinner-color);
  background: conic-gradient(currentColor 0 30%, var(--dk-spinner-track) 0);
}
.dk-spinner--lg { width: var(--dk-spinner-size-lg); height: var(--dk-spinner-size-lg); }
/* Inside a control the ring takes the control's text colour: the arc in
   full, the track at a quarter (derived from the role, not a literal). */
:is(.dk-button, .dk-icon-button) .dk-spinner,
:is(.dk-button, .dk-icon-button)[aria-busy="true"]::before { color: inherit; background: conic-gradient(currentColor 0 30%, color-mix(in srgb, currentColor 25%, transparent) 0); }

@keyframes dk-spin { to { transform: rotate(1turn); } }
/* Hidden for the delay (backwards fill), then shown: no flash on fast loads. */
@keyframes dk-reveal { from, to { opacity: 0; } }

/* Busy is not disabled: the trigger keeps its colours and its focus (a
   disabled button drops focus to <body>), the label stays in the
   accessibility tree, and the box never changes size. */
[aria-busy="true"] { cursor: progress; }
:is(.dk-button, .dk-icon-button)[aria-busy="true"] {
  position: relative;
  animation: dk-busy-label 1ms var(--dk-loading-delay-busy) forwards;
}
:is(.dk-button, .dk-icon-button)[aria-busy="true"] > * { animation: dk-busy-child 1ms var(--dk-loading-delay-busy) forwards; }
:is(.dk-button, .dk-icon-button)[aria-busy="true"]::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
}
@keyframes dk-busy-label { to { -webkit-text-fill-color: transparent; } }
/* Opacity, never visibility/display: a hidden child leaves the accessibility
   tree, and a button labelled by a <span> would lose its accessible name. */
@keyframes dk-busy-child { to { opacity: 0; } }

/* The loading overlay is a modal <dialog class="dk-loading"> (padding 0, per
   the dialogs.js contract), so Escape and a backdrop click cancel the load. */
.dk-loading {
  margin: auto;
  padding: 0;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-lg);
  background: var(--dk-bg-raised);
  color: var(--dk-text-muted);
  box-shadow: var(--dk-shadow-overlay);
}
.dk-loading::backdrop { background: var(--dk-bg-backdrop); }
.dk-loading__body { display: flex; align-items: center; gap: var(--dk-space-3); padding: var(--dk-space-3) var(--dk-space-4); font-size: var(--dk-text-body); }
/* The overlay is already the delayed state: its spinner shows at once. */
.dk-loading .dk-spinner { animation-delay: 0s; }

/* Toast: a transient message above everything, bottom centre. --danger is
   the load-error toast (message + Retry + dismiss); the tint sits on the
   page colour so its contrast is the verified danger.text-on-danger.bg pair. */
.dk-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dk-space-6) + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  translate: -50% 0;
  width: max-content;
  max-width: calc(100vw - 2 * var(--dk-space-4));
  display: flex;
  align-items: center;
  gap: var(--dk-space-3);
  padding: var(--dk-space-2) var(--dk-space-2) var(--dk-space-2) var(--dk-space-4);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-raised);
  color: var(--dk-text-primary);
  box-shadow: var(--dk-shadow-overlay);
  font-size: var(--dk-text-md);
}
.dk-toast__message { min-width: 0; overflow-wrap: anywhere; }
.dk-toast--danger { background: linear-gradient(var(--dk-danger-bg), var(--dk-danger-bg)), var(--dk-bg-page); color: var(--dk-danger-text); }
.dk-toast--danger .dk-icon-button { color: var(--dk-danger-text); }

@media (prefers-reduced-motion: reduce) {
  /* No rotation: a still ring (plus aria-busy) still reads as loading. */
  .dk-spinner,
  :is(.dk-button, .dk-icon-button)[aria-busy="true"]::before { animation: dk-reveal 1ms var(--dk-loading-delay-busy) backwards; }
}

/* --- touch sizing ------------------------------------------------------------------
   Phone widths and coarse pointers get 44px controls. A checkbox stays 16px
   to the eye; its .dk-check label carries the 44px hit area. */
.dk-check { display: inline-flex; align-items: center; gap: var(--dk-space-2); cursor: pointer; }
.dk-check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--dk-accent-default); cursor: pointer; }

@media (max-width: 820px), (pointer: coarse) {
  .dk-button, .dk-input, .dk-select { min-height: var(--dk-size-touch); }
  .dk-textarea { min-height: max(76px, var(--dk-size-touch)); }
  .dk-check { min-width: var(--dk-size-touch); min-height: var(--dk-size-touch); justify-content: center; }
  /* A check with a text label keeps its box at the start of the line. */
  :is(.dk-callout, .dk-auth-card, .dk-menu) .dk-check { justify-content: flex-start; }
  /* Standalone text links (Switch account, Manage CLI sessions) get a 44px
     hit area from 16px inline padding, which doesn't move the line. */
  :is(.dk-auth-page__identity, .dk-auth-card__foot) a { padding-block: var(--dk-space-4); }
  .dk-auth-page__brand { min-height: var(--dk-size-touch); }
}

/* --- misc ---------------------------------------------------------------------- */

.dk-divider { border: 0; border-top: 1px solid var(--dk-border-default); margin: var(--dk-space-4) 0; }

/* Form footer action row: primary first, then Cancel/back (the family recipe). */
.dk-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dk-gap-control);
  align-items: center;
  padding: var(--dk-space-3) var(--dk-space-4);
  margin-top: var(--dk-space-4);
  border-top: 1px solid var(--dk-border-default);
  background: var(--dk-bg-muted);
  border-radius: 0 0 var(--dk-radius-md) var(--dk-radius-md);
}

/* --- shared workspace vocabulary (docs/shell.md §9) ------------------------------ */

.dk-skip-link {
  position: fixed;
  top: var(--dk-space-2);
  left: var(--dk-space-2);
  z-index: 70;
  padding: var(--dk-space-2) var(--dk-space-3);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-surface);
  color: var(--dk-text-link);
  font-size: var(--dk-text-md);
  transform: translateY(-200%);
}
.dk-skip-link:focus-visible { transform: none; }

/* Icon-only button: always carries an aria-label. */
.dk-icon-button {
  position: relative;
  width: 32px;
  height: 32px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--dk-radius-md);
  background: transparent;
  color: var(--dk-text-muted);
}
.dk-icon-button:hover,
.dk-icon-button[data-dk-popover-trigger][aria-expanded="true"] { background: var(--dk-bg-hover); color: var(--dk-text-primary); }
.dk-icon-button--sm { width: 24px; height: 24px; border-radius: var(--dk-radius-sm); }
.dk-icon-button > svg { width: 20px; height: 20px; }
.dk-icon-button--sm > svg { width: 16px; height: 16px; }

/* Unread / item count. Hidden at 0 (setCount sets [hidden]); 99+ cap. Never danger. */
.dk-count {
  display: inline-grid;
  place-items: center;
  flex: none;
  height: 16px;
  min-width: 16px;
  padding: 0 var(--dk-space-1);
  border-radius: var(--dk-radius-full);
  background: var(--dk-bg-hover);
  color: var(--dk-text-muted);
  font-family: var(--dk-font-mono);
  font-size: var(--dk-text-xs);
  font-weight: var(--dk-weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 16px;
}
.dk-icon-button > .dk-count {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--dk-accent-default);
  color: var(--dk-text-on-accent);
}

.dk-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--dk-space-1);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-sm);
  background: var(--dk-bg-surface);
  color: var(--dk-text-muted);
  font-family: var(--dk-font-mono);
  font-size: var(--dk-text-xs);
  line-height: 1;
}

.dk-avatar {
  position: relative;
  width: 28px;
  height: 28px;
  flex: none;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--dk-radius-full);
  background: var(--dk-accent-soft);
  color: var(--dk-accent-default);
  font-size: var(--dk-text-xs);
  font-weight: var(--dk-weight-semibold);
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}
/* js/avatar.js lays the photo over the initials, so a slow, missing or
   failed photo still leaves the person's letters. */
.dk-avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dk-avatar--xs { width: 20px; height: 20px; }
.dk-avatar--sm { width: 24px; height: 24px; }
.dk-avatar--lg { width: 36px; height: 36px; font-size: var(--dk-text-md); }

/* Callout: neutral = muted fill + neutral border; status = tinted fill only. */
.dk-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--dk-space-3);
  padding: var(--dk-space-3) var(--dk-space-4);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-muted);
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
}
.dk-callout--info { background: var(--dk-info-bg); color: var(--dk-info-text); border-color: transparent; }
.dk-callout--success { background: var(--dk-success-bg); color: var(--dk-success-text); border-color: transparent; }
.dk-callout--warning { background: var(--dk-warning-bg); color: var(--dk-warning-text); border-color: transparent; }
.dk-callout--danger { background: var(--dk-danger-bg); color: var(--dk-danger-text); border-color: transparent; }
.dk-callout__icon { width: 16px; height: 1lh; flex: none; } /* one line tall, so the glyph centres on the first line */
.dk-callout__body { flex: 1 1 auto; min-width: 0; display: grid; gap: var(--dk-space-1); }
.dk-callout__title { font-weight: var(--dk-weight-semibold); }
.dk-callout__actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-2); }

/* Page and section headers: no rule under them; space separates. */
.dk-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--dk-gap-block); min-width: 0; }
.dk-page-header__main { flex: 1 1 auto; min-width: 0; display: grid; gap: var(--dk-space-1); }
.dk-page-header__crumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-1); color: var(--dk-text-muted); font-size: var(--dk-text-sm); }
.dk-page-header__crumb a { color: inherit; text-decoration: none; }
.dk-page-header__crumb a:hover { color: var(--dk-text-link-hover); text-decoration: underline; }
.dk-page-header__title { font-size: var(--dk-text-xl); font-weight: var(--dk-weight-semibold); line-height: var(--dk-leading-tight); letter-spacing: -0.01em; color: var(--dk-text-heading); overflow-wrap: anywhere; }
.dk-page-header__title--page { font-size: var(--dk-text-page); }
.dk-page-header__subtitle { color: var(--dk-text-muted); font-size: var(--dk-text-md); }
.dk-page-header__actions { flex: 0 0 auto; max-width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-2); margin-left: auto; }
.dk-page-header__meta { color: var(--dk-text-faint); font-family: var(--dk-font-mono); font-size: var(--dk-text-sm); }
.dk-section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--dk-gap-control); }
.dk-section-header__title { font-size: var(--dk-text-lg); font-weight: var(--dk-weight-semibold); color: var(--dk-text-heading); }

/* --- segmented control (docs/segmented.md) -----------------------------------
   The one look for view switchers and single-choice list filters: a rounded
   track holding segments; the selected segment is the kit selection
   (accent-soft fill, neutral border, accent text). Never separate pills,
   never an underline. Selected = aria-current="page" (route links),
   aria-selected="true" (role="tablist"), aria-checked="true"
   (role="radiogroup") or aria-pressed="true" (multi-select toggles).
   It never wraps: segments that don't fit scroll inside the track, with
   neutral scroll shadows at the clipped edge. dist/tabs.js adds arrow keys. */
.dk-tabs {
  --dk-tabs-shadow: color-mix(in srgb, var(--dk-text-heading) 14%, transparent);
  display: inline-flex;
  align-self: flex-start;
  width: fit-content;
  align-items: center;
  gap: var(--dk-tabs-gap);
  max-width: 100%;
  padding: var(--dk-tabs-pad);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-tabs-radius);
  /* Scroll shadows: covers scroll with the segments (local) and hide the
     fixed shadows (scroll) once that edge is reached. */
  background:
    linear-gradient(to right, var(--dk-tabs-track) 30%, transparent) left / var(--dk-space-6) 100% no-repeat local,
    linear-gradient(to left, var(--dk-tabs-track) 30%, transparent) right / var(--dk-space-6) 100% no-repeat local,
    linear-gradient(to right, var(--dk-tabs-shadow), transparent) left / var(--dk-space-3) 100% no-repeat scroll,
    linear-gradient(to left, var(--dk-tabs-shadow), transparent) right / var(--dk-space-3) 100% no-repeat scroll,
    var(--dk-tabs-track);
  scrollbar-width: none;
}
.dk-tabs::-webkit-scrollbar { display: none; }
.dk-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--dk-space-2);
  flex: none;
  height: var(--dk-tabs-height);
  margin: 0;
  padding: 0 var(--dk-tabs-pad-x);
  border: 1px solid transparent;
  border-radius: var(--dk-tabs-radius-item);
  background: transparent;
  color: var(--dk-tabs-text);
  font: inherit;
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.dk-tab:hover { background: var(--dk-tabs-hover); color: var(--dk-tabs-hover-text); text-decoration: none; }
.dk-tab:focus-visible { outline: 2px solid var(--dk-tabs-focus); outline-offset: -2px; }
.dk-tab:is([aria-current="page"], [aria-selected="true"], [aria-checked="true"], [aria-pressed="true"]) {
  border-color: var(--dk-border-default);
  background: var(--dk-tabs-selected);
  color: var(--dk-tabs-selected-text);
  font-weight: var(--dk-weight-semibold);
}
.dk-tab:is(:disabled, [aria-disabled="true"]) { background: transparent; color: var(--dk-tabs-disabled-text); cursor: not-allowed; }
/* The count rides inside the segment: mono, no pill. */
.dk-tab .dk-count { height: auto; min-width: 0; padding: 0; background: transparent; color: var(--dk-tabs-count); font-family: var(--dk-font-mono); font-size: var(--dk-text-xs); font-weight: var(--dk-weight-semibold); font-variant-numeric: tabular-nums; }
.dk-tab:is([aria-current="page"], [aria-selected="true"], [aria-checked="true"], [aria-pressed="true"]) .dk-count { color: inherit; }
.dk-tab:is(:disabled, [aria-disabled="true"]) .dk-count { color: inherit; }
.dk-tabs--sm .dk-tab { height: var(--dk-tabs-height-sm); padding: 0 var(--dk-tabs-pad-x-sm); font-size: var(--dk-text-sm); }
/* On a phone the track spans the content width; segments share it and
   scroll inside it when they don't fit. */
@media (max-width: 820px) {
  .dk-tabs { display: flex; align-self: stretch; width: 100%; }
  .dk-tab { flex: 1 0 auto; }
}

/* Stat strip: one register. Each cell draws a neutral 1px hairline on its
   right and bottom edge; the strip clips the outer ones, so a short last
   row leaves plain surface, not a filled gap. */
.dk-stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  overflow: hidden;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-surface);
}
.dk-stat { display: grid; align-content: start; gap: var(--dk-space-1); padding: var(--dk-space-3) var(--dk-space-4); min-width: 0; box-shadow: 1px 0 0 var(--dk-border-default), 0 1px 0 var(--dk-border-default); }
.dk-stat__label { color: var(--dk-text-muted); font-size: var(--dk-text-sm); font-weight: var(--dk-weight-medium); }
.dk-stat__value { color: var(--dk-text-heading); font-family: var(--dk-font-mono); font-size: var(--dk-text-xl); font-weight: var(--dk-weight-medium); font-variant-numeric: tabular-nums; line-height: var(--dk-leading-tight); }
.dk-stat__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-2); color: var(--dk-text-faint); font-size: var(--dk-text-xs); }

/* Facts list. */
.dk-dl { display: grid; grid-template-columns: minmax(112px, max-content) minmax(0, 1fr); gap: var(--dk-space-2) var(--dk-space-4); margin: 0; align-items: baseline; }
.dk-dl dt { color: var(--dk-text-muted); font-size: var(--dk-text-sm); }
.dk-dl dd { margin: 0; min-width: 0; color: var(--dk-text-primary); font-size: var(--dk-text-md); overflow-wrap: anywhere; }
.dk-dl--divided { gap: 0 var(--dk-space-4); }
.dk-dl--divided > :is(dt, dd) { padding-block: var(--dk-space-2); border-top: 1px solid var(--dk-border-default); }
.dk-dl--divided > :is(dt, dd):nth-child(-n + 2) { border-top: 0; }
.dk-dl--stacked { grid-template-columns: minmax(0, 1fr); gap: var(--dk-space-1); }
.dk-dl--stacked dd + dt { margin-top: var(--dk-space-2); }
.dk-dl__note { display: block; color: var(--dk-text-muted); font-family: var(--dk-font-sans); font-size: var(--dk-text-sm); }

/* Empty state: why it is empty + one safe next action. No illustration. */
.dk-empty { display: grid; justify-items: center; gap: var(--dk-space-2); padding: var(--dk-space-8) var(--dk-space-6); text-align: center; }
.dk-empty--compact { padding: var(--dk-space-6) var(--dk-space-4); }
.dk-empty__title { color: var(--dk-text-heading); font-size: var(--dk-text-body); font-weight: var(--dk-weight-semibold); }
.dk-empty__desc { max-width: 44ch; color: var(--dk-text-muted); font-size: var(--dk-text-md); }
.dk-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--dk-space-2); margin-top: var(--dk-space-2); }

/* Switch: button[role=switch][aria-checked], or a .dk-switch span inside such a row. */
.dk-switch {
  position: relative;
  width: 32px;
  height: 20px;
  flex: none;
  display: inline-block;
  border: 1px solid var(--dk-border-strong);
  border-radius: var(--dk-radius-full);
  background: var(--dk-bg-inset);
}
.dk-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: var(--dk-radius-full);
  background: var(--dk-text-muted);
}
.dk-switch[aria-checked="true"],
[aria-checked="true"] > .dk-switch { border-color: transparent; background: var(--dk-accent-default); }
.dk-switch[aria-checked="true"]::after,
[aria-checked="true"] > .dk-switch::after { transform: translateX(12px); background: var(--dk-text-on-accent); }
@media (prefers-reduced-motion: no-preference) {
  .dk-switch, .dk-switch::after { transition: transform 120ms ease, background-color 120ms ease; }
}

/* Menu / popover surface. Rows are one line, 32px. */
.dk-menu {
  display: grid;
  gap: 0;
  min-width: 200px;
  padding: var(--dk-space-1);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-lg);
  background: var(--dk-bg-surface);
  box-shadow: var(--dk-shadow-overlay);
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
}
/* Pointer-opened menus focus the container itself; it is not a control. */
.dk-menu:focus { outline: none; }
.dk-menu__item {
  display: flex;
  align-items: center;
  gap: var(--dk-space-2);
  width: 100%;
  min-height: 32px;
  padding: 0 var(--dk-space-2);
  border: 0;
  border-radius: var(--dk-radius-md);
  background: transparent;
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-medium);
  text-align: left;
  text-decoration: none;
}
.dk-menu__item:hover { background: var(--dk-bg-hover); color: var(--dk-text-primary); }
.dk-menu__item:focus-visible { outline-offset: -2px; }
.dk-menu__item > svg { width: 16px; height: 16px; flex: none; color: var(--dk-text-muted); }
.dk-menu__item > .dk-switch, .dk-menu__item > .dk-kbd, .dk-menu__item > .dk-menu__check { margin-left: auto; }
.dk-menu__item[aria-checked="true"][role="radio"],
.dk-menu__item[aria-checked="true"][role="menuitemradio"] { background: var(--dk-accent-soft); color: var(--dk-accent-default); }
.dk-menu__check { width: 16px; height: 16px; flex: none; visibility: hidden; }
[aria-checked="true"] > .dk-menu__check { visibility: visible; color: currentColor; }
.dk-menu__item--danger,
.dk-menu__item--danger > svg { color: var(--dk-danger-text); }
.dk-menu__item--danger:hover { background: var(--dk-danger-bg); color: var(--dk-danger-text); }
.dk-menu__label { display: flex; align-items: flex-end; height: 24px; padding: 0 var(--dk-space-2) var(--dk-space-1); color: var(--dk-text-faint); font-size: var(--dk-text-xs); font-weight: var(--dk-weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; }
.dk-menu__sep { height: 0; margin: var(--dk-space-1) 0; border: 0; border-top: 1px solid var(--dk-border-default); }
.dk-menu__identity { display: grid; gap: 0; padding: var(--dk-space-2); min-width: 0; }
.dk-menu__name { color: var(--dk-text-heading); font-weight: var(--dk-weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-menu__email { color: var(--dk-text-muted); font-size: var(--dk-text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-menu__meta { display: flex; justify-content: space-between; gap: var(--dk-space-2); padding: var(--dk-space-1) var(--dk-space-2); color: var(--dk-text-faint); font-family: var(--dk-font-mono); font-size: var(--dk-text-xs); }
.dk-menu form { display: contents; }

/* Code block + copy. Code and secrets are never truncated. */
.dk-code-block {
  display: flex;
  align-items: flex-start;
  gap: var(--dk-space-3);
  padding: var(--dk-space-2) var(--dk-space-2) var(--dk-space-2) var(--dk-space-3);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-inset);
}
.dk-code-block pre { flex: 1 1 auto; min-width: 0; margin: 0; padding: var(--dk-space-1) 0; overflow-x: auto; }
.dk-code-block code { padding: 0; background: none; color: var(--dk-text-primary); font-size: var(--dk-text-sm); white-space: pre; }
/* Copy reserves the width of "Copied" before the first click, so the label
   swap never moves the button. The reserve is an invisible zero-height line. */
.dk-button[data-dk-copy] { flex-direction: column; gap: 0; }
.dk-button[data-dk-copy]::after { content: "Copied"; height: 0; overflow: hidden; visibility: hidden; }

/* Tag input (dist/tag-input.js, docs/tag-input.md): a multi-select combobox.
   The field looks like .dk-input and holds the chosen values as removable
   chips plus a text input that filters a listbox popup below it. Chips are
   neutral (muted fill, neutral border); the active option takes the hover
   fill, never a colored edge. */
.dk-tag-input { position: relative; min-width: 0; }
.dk-tag-input__field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dk-space-1);
  min-height: var(--dk-size-control-md);
  padding: var(--dk-space-1);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-page);
  cursor: text;
}
.dk-tag-input__field:hover { border-color: var(--dk-border-strong); }
.dk-tag-input__field:has(> .dk-tag-input__input:focus-visible) { outline: 3px solid var(--dk-focus-ring); outline-offset: 2px; }
.dk-tag-input.is-disabled .dk-tag-input__field { background: var(--dk-bg-muted); cursor: not-allowed; }
.dk-tag-input.is-disabled .dk-tag-input__field:hover { border-color: var(--dk-border-default); }
.dk-tag-input__chips { display: contents; margin: 0; padding: 0; list-style: none; }
.dk-tag-input__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--dk-space-1);
  max-width: 100%;
  min-height: 24px;
  padding: 0 0 0 var(--dk-space-2);
  border: 1px solid var(--dk-border-strong);
  border-radius: var(--dk-radius-full);
  background: var(--dk-bg-muted);
  color: var(--dk-text-primary);
  font-size: var(--dk-text-sm);
  line-height: var(--dk-leading-tight);
}
.dk-tag-input__chip > .dk-tag-input__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-tag-input__icon { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 16px; height: 16px; color: var(--dk-text-muted); }
.dk-tag-input__icon > svg { width: 16px; height: 16px; }
.dk-tag-input__remove {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--dk-radius-full);
  background: transparent;
  color: var(--dk-text-muted);
  cursor: pointer;
}
.dk-tag-input__remove > svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dk-tag-input__remove:hover { background: var(--dk-bg-hover); color: var(--dk-text-primary); }
.dk-tag-input__remove:focus-visible { outline: 3px solid var(--dk-focus-ring); outline-offset: 0; }
.dk-tag-input__remove:disabled { cursor: not-allowed; color: var(--dk-text-muted); background: transparent; }
.dk-tag-input__input {
  flex: 1 1 96px;
  min-width: 96px;
  height: 24px;
  padding: 0 var(--dk-space-1);
  border: 0;
  background: transparent;
  color: var(--dk-text-primary);
  font: inherit;
  font-size: var(--dk-text-md);
}
.dk-tag-input__input:focus, .dk-tag-input__input:focus-visible { outline: none; }
.dk-tag-input__input::placeholder { color: var(--dk-text-faint); }
.dk-tag-input__input:disabled { cursor: not-allowed; }
.dk-tag-input__popup {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: var(--dk-space-1);
  max-height: min(288px, 50vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--dk-space-1);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-lg);
  background: var(--dk-bg-surface);
  box-shadow: var(--dk-shadow-overlay);
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
}
.dk-tag-input__popup[hidden], .dk-tag-input__listbox[hidden], .dk-tag-input__empty[hidden] { display: none; }
.dk-tag-input__group + .dk-tag-input__group { margin-top: var(--dk-space-1); padding-top: var(--dk-space-1); border-top: 1px solid var(--dk-border-default); }
.dk-tag-input__group-label { display: flex; align-items: flex-end; height: 24px; padding: 0 var(--dk-space-2) var(--dk-space-1); color: var(--dk-text-faint); font-size: var(--dk-text-xs); font-weight: var(--dk-weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; }
.dk-tag-input__option {
  display: flex;
  align-items: center;
  gap: var(--dk-space-2);
  min-height: 32px;
  padding: 0 var(--dk-space-2);
  border-radius: var(--dk-radius-md);
  cursor: pointer;
  user-select: none;
}
.dk-tag-input__option > .dk-tag-input__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-tag-input__option.is-active { background: var(--dk-bg-hover); }
.dk-tag-input__match { padding: 0; background: transparent; color: inherit; font-weight: var(--dk-weight-semibold); }
.dk-tag-input__empty { padding: var(--dk-space-2); color: var(--dk-text-muted); font-size: var(--dk-text-sm); }
@media (max-width: 820px), (pointer: coarse) {
  .dk-tag-input__field { min-height: var(--dk-size-touch); }
  .dk-tag-input__chip { min-height: 32px; }
  .dk-tag-input__remove { width: 32px; height: 32px; }
  .dk-tag-input__input { height: 32px; font-size: var(--dk-text-lg); }
  .dk-tag-input__option { min-height: var(--dk-size-touch); }
}

/* Field-level error (role="alert", linked via aria-describedby). */
.dk-field-error { margin-top: var(--dk-space-1); color: var(--dk-danger-text); font-size: var(--dk-text-sm); }

/* Skeleton block for loading states. */
.dk-skeleton { display: block; height: 12px; border-radius: var(--dk-radius-sm); background: var(--dk-bg-hover); }

@media (max-width: 820px), (pointer: coarse) {
  .dk-icon-button { width: var(--dk-size-touch); height: var(--dk-size-touch); }
  .dk-menu__item, .dk-tab { min-height: var(--dk-size-touch); }
  /* The first code line centres on the 44px Copy button. */
  .dk-code-block pre { padding-block: var(--dk-space-3); }
}

/* A keyboard hint means nothing without a keyboard. */
@media (pointer: coarse) {
  .dk-kbd { display: none; }
}

/* --- device login (docs/device-login.md) ------------------------------------------- */

.dk-auth-page { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; background: var(--dk-bg-page); }
/* The bar is 48px for a normal identity. A long address wraps (never clips),
   the bar grows, and Switch account stays whole on the last line. */
.dk-auth-page__bar { min-height: var(--dk-size-topbar); display: flex; align-items: center; justify-content: space-between; gap: var(--dk-space-4); padding: var(--dk-space-1) var(--dk-space-4); min-width: 0; }
.dk-auth-page__brand { flex: none; display: inline-flex; align-items: center; color: var(--dk-text-heading); font-size: var(--dk-text-body); font-weight: var(--dk-weight-semibold); text-decoration: none; }
/* The wordmark (.dk-auth-page__brand or a .dk-brand) never yields width to the identity. */
.dk-auth-page__bar .dk-brand { flex: none; }
.dk-auth-page__identity { min-width: 0; color: var(--dk-text-muted); font-size: var(--dk-text-sm); text-align: right; overflow-wrap: anywhere; }
.dk-auth-page__identity a { white-space: nowrap; }
.dk-auth-page__main { display: grid; justify-items: center; align-content: start; padding: var(--dk-space-8) var(--dk-space-4); }

.dk-auth-card {
  width: min(416px, 100%);
  display: grid;
  gap: var(--dk-space-6);
  padding: var(--dk-space-7);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-lg);
  background: var(--dk-bg-surface);
}
.dk-auth-card__head { display: grid; gap: var(--dk-space-2); }
.dk-auth-card__title { display: flex; align-items: center; gap: var(--dk-space-2); font-size: var(--dk-text-xl); font-weight: var(--dk-weight-semibold); line-height: var(--dk-leading-tight); color: var(--dk-text-heading); }
/* A focus target for screen readers, not a control: no ring. */
.dk-auth-card__title:focus { outline: none; }
.dk-auth-card__title > svg { width: 20px; height: 20px; flex: none; }
.dk-auth-card__icon--success { color: var(--dk-success-text); }
.dk-auth-card__lede { color: var(--dk-text-muted); font-size: var(--dk-text-body); overflow-wrap: anywhere; }
.dk-auth-card__body { display: grid; gap: var(--dk-space-4); }
.dk-auth-card__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--dk-space-3); }
.dk-auth-card__actions > .dk-button { width: 100%; }
.dk-auth-card__actions > .dk-button:only-child { grid-column: 1 / -1; }
.dk-auth-card__foot { display: grid; gap: var(--dk-space-1); padding-top: var(--dk-space-4); border-top: 1px solid var(--dk-border-default); color: var(--dk-text-muted); font-size: var(--dk-text-sm); }

.dk-code-input {
  height: var(--dk-size-control-lg);
  font-family: var(--dk-font-mono);
  font-size: var(--dk-text-xl);
  font-weight: var(--dk-weight-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.dk-code-input::placeholder { letter-spacing: 0.12em; text-transform: none; }
.dk-code-input[aria-invalid="true"] { border-color: var(--dk-border-strong); }

@media (max-width: 480px) {
  .dk-auth-page__main { padding: var(--dk-space-6) var(--dk-space-4); }
  .dk-auth-card { padding: var(--dk-space-5); gap: var(--dk-space-5); }
  .dk-auth-card .dk-dl { grid-template-columns: minmax(0, 1fr); gap: var(--dk-space-1); }
  .dk-auth-card .dk-dl dd + dt { margin-top: var(--dk-space-2); }
}

/* --- list–detail split (docs/list-detail.md) ---------------------------------------
   A list pane and the selected item's detail pane fill the content area; each
   pane scrolls on its own and the page itself does not. .dk-main turns into a
   flex column while it hosts a split; app wrappers between it and the split
   carry .dk-fill so the height reaches the split. */

.dk-main:has(.dk-split:not([hidden])) { display: flex; flex-direction: column; }
.dk-main:has(.dk-split:not([hidden])) > .dk-main__inner { flex: 1 1 auto; min-height: 0; width: 100%; }
.dk-fill { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }
/* Only the split (or the next .dk-fill) grows; headers, stat strips and
   toolbars above it keep their natural height instead of being squeezed. */
.dk-fill > :not(.dk-split, .dk-fill),
.dk-main:has(.dk-split:not([hidden])) > .dk-main__inner > :not(.dk-split, .dk-fill) { flex-shrink: 0; }

.dk-split {
  --dk-split-list: var(--dk-size-split-list);
  display: grid;
  /* The stored or app-set width is clamped, so a narrow window never loses the detail. */
  grid-template-columns: clamp(240px, var(--dk-split-list), 50%) minmax(0, 1fr);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-surface);
}
.dk-split__list,
.dk-split__detail { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dk-split__list { border-right: 1px solid var(--dk-border-default); }

/* Pane header band: outside the scroller, so it never scrolls away. */
.dk-split__head {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dk-space-2) var(--dk-gap-control);
  min-height: var(--dk-size-topbar);
  padding: var(--dk-space-2) var(--dk-space-4);
  border-bottom: 1px solid var(--dk-border-default);
  background: var(--dk-bg-muted);
  min-width: 0;
}
.dk-split__title { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--dk-text-heading); font-size: var(--dk-text-md); font-weight: var(--dk-weight-semibold); overflow-wrap: anywhere; }
.dk-split__title:focus { outline: none; }
.dk-split__count { color: var(--dk-text-muted); font-family: var(--dk-font-mono); font-size: var(--dk-text-sm); font-variant-numeric: tabular-nums; }
/* A toolbar row inside a pane (search, filter chips): no gap-block below, the band pads it. */
.dk-split__tools { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-2); padding: var(--dk-space-2) var(--dk-space-4); border-bottom: 1px solid var(--dk-border-default); }
.dk-split__tools > .dk-input { flex: 1 1 160px; min-width: 0; }

.dk-split__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scroll-padding-top: calc(var(--dk-split-sticky-height, 0px) + var(--dk-space-2)); }
.dk-split__detail > .dk-split__scroll { padding: var(--dk-pad-panel); }
.dk-split__detail > .dk-split__scroll--flush { padding: 0; }
/* A header inside the detail scroller that stays put (section nav, actions). */
.dk-split__sticky { position: sticky; top: 0; z-index: 1; background: var(--dk-bg-surface); }
.dk-split__foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dk-gap-control);
  padding: var(--dk-space-2) var(--dk-space-4);
  border-top: 1px solid var(--dk-border-default);
  color: var(--dk-text-muted);
  font-size: var(--dk-text-sm);
}

/* Rows. Selection is the accent-soft fill + accent name; the row keeps its
   neutral divider, and hover never replaces the selected fill. */
.dk-split__items { margin: 0; padding: 0; list-style: none; }
.dk-split__item {
  display: grid;
  gap: var(--dk-space-1);
  width: 100%;
  min-width: 0;
  padding: var(--dk-space-3) var(--dk-space-4);
  border: 0;
  border-bottom: 1px solid var(--dk-border-default);
  border-radius: 0;
  background: transparent;
  color: var(--dk-text-primary);
  font: inherit;
  font-size: var(--dk-text-md);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.dk-split__item:hover { background: var(--dk-bg-hover); }
.dk-split__item:focus-visible { outline: 3px solid var(--dk-focus-ring); outline-offset: -3px; }
.dk-split__item[aria-current="true"],
.dk-split__item[aria-current="page"],
.dk-split__item[aria-selected="true"] { background: var(--dk-accent-soft); }
.dk-split__name { display: flex; align-items: center; gap: var(--dk-space-2); min-width: 0; color: var(--dk-text-heading); font-weight: var(--dk-weight-medium); overflow-wrap: anywhere; }
.dk-split__item[aria-current="true"] .dk-split__name,
.dk-split__item[aria-current="page"] .dk-split__name,
.dk-split__item[aria-selected="true"] .dk-split__name { color: var(--dk-accent-default); font-weight: var(--dk-weight-semibold); }
.dk-split__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dk-space-1) var(--dk-space-2); min-width: 0; color: var(--dk-text-muted); font-size: var(--dk-text-sm); }

/* Nothing selected: the detail pane says what to do. Holds a .dk-empty. */
.dk-split__empty { flex: 1 1 auto; display: grid; place-content: center; min-height: 0; }

/* Back to the list: only where one pane shows at a time. */
.dk-split__back {
  display: none;
  align-items: center;
  gap: var(--dk-space-1);
  height: var(--dk-size-touch);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dk-text-link);
  font: inherit;
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-medium);
  text-decoration: none;
  cursor: pointer;
}
/* No padding, so the label lines up with the pane title under it. */
.dk-split__back:hover { text-decoration: underline; }
.dk-split__back > svg { width: 16px; height: 16px; flex: none; }

/* Optional resize grip on the list's edge (role=separator, dist/split.js). */
.dk-split__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 2;
  width: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(50%);
  cursor: col-resize;
  touch-action: none;
}
.dk-split__handle::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: transparent; }
.dk-split__handle:hover::after,
.dk-split__handle[data-dragging]::after { background: var(--dk-border-strong); }
.dk-split__handle:focus-visible { outline: 3px solid var(--dk-focus-ring); outline-offset: -3px; }

/* One pane at a time: the list, or the selected item with Back. The app sets
   data-view="detail" from the URL (an item id in it), "list" otherwise. */
@media (max-width: 820px) {
  .dk-split { grid-template-columns: minmax(0, 1fr); }
  .dk-split__list { border-right: 0; }
  .dk-split[data-view="detail"] > .dk-split__list,
  .dk-split:not([data-view="detail"]) > .dk-split__detail { display: none; }
  .dk-split__back { display: inline-flex; }
  .dk-split__handle { display: none; }
}
@media (max-width: 820px), (pointer: coarse) {
  .dk-split__item { min-height: var(--dk-size-touch); align-content: center; }
}

/* --- shell ----------------------------------------------------------------- */
/* Dakit app shell — the contract is docs/shell.md; behaviour is js/shell.js.
   Sidebar = navigation only: brand row (+ bell), optional search, nav, one
   account row. Collapses to a working 56px icon rail. Popovers open beside
   the sidebar column, never over it. Same rules in both themes. */

/* --- frame ------------------------------------------------------------------ */

.dk-shell {
  --dk-shell-col: var(--dk-size-sidebar);
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: var(--dk-shell-col) minmax(0, 1fr);
  grid-template-areas: "side main";
  height: 100dvh;
  overflow: hidden;
  background: var(--dk-bg-page);
}
.dk-shell[data-sidebar="collapsed"] { --dk-shell-col: var(--dk-size-rail); }

.dk-main {
  grid-area: main;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--dk-space-6) var(--dk-space-7);
}
.dk-main:focus { outline: none; }
.dk-main__inner {
  max-width: var(--dk-size-content-max);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--dk-gap-section);
}
.dk-main__inner--narrow { max-width: var(--dk-size-measure); }

.dk-topbar,
.dk-sidebar__close,
.dk-search__rail,
.dk-brand__tile { display: none; }

/* --- sidebar ------------------------------------------------------------------ */

.dk-sidebar {
  grid-area: side;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--dk-bg-muted);
  border-right: 1px solid var(--dk-border-default);
}

.dk-sidebar__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--dk-space-1);
  height: 48px;
  padding: 0 var(--dk-space-2) 0 var(--dk-space-3);
}

.dk-brand {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--dk-space-2);
  height: 32px;
  padding: 0 var(--dk-space-1);
  border: 1px solid transparent;
  border-radius: var(--dk-radius-md);
  background: transparent;
  color: var(--dk-text-heading);
  text-align: left;
  text-decoration: none;
}
a.dk-brand:hover { color: var(--dk-text-heading); }
button.dk-brand:hover,
button.dk-brand[aria-expanded="true"] { background: var(--dk-bg-hover); }
.dk-brand__name {
  min-width: 0;
  overflow: hidden;
  font-size: var(--dk-text-body);
  font-weight: var(--dk-weight-semibold);
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dk-brand__scope {
  min-width: 0;
  overflow: hidden;
  color: var(--dk-text-muted);
  font-size: var(--dk-text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dk-brand__chev { width: 16px; height: 16px; flex: none; margin-left: auto; color: var(--dk-text-muted); }
.dk-brand__tile {
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-surface);
  color: var(--dk-text-heading);
  font-family: var(--dk-font-mono);
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-semibold);
}

.dk-sidebar__search { flex: none; padding: 0 var(--dk-space-2) var(--dk-space-2); }
.dk-search {
  display: flex;
  align-items: center;
  gap: var(--dk-space-2);
  height: 32px;
  padding: 0 var(--dk-space-1) 0 var(--dk-space-2);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-md);
  background: var(--dk-bg-surface);
  color: var(--dk-text-muted);
  cursor: text;
}
.dk-search:hover { border-color: var(--dk-border-control-hover); }
.dk-search:has(input:focus-visible) { outline: 3px solid var(--dk-focus-ring); outline-offset: 2px; }
.dk-search > svg { width: 16px; height: 16px; flex: none; }
.dk-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
}
.dk-search input::placeholder { color: var(--dk-text-muted); }

.dk-sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--dk-border-strong) transparent;
  scrollbar-gutter: auto;
  /* Scroll shadows: the covers scroll with the content (local) and hide the
     fixed neutral shadows (scroll) once that edge is reached. */
  --dk-scroll-shadow: color-mix(in srgb, var(--dk-text-heading) 14%, transparent);
  background:
    linear-gradient(var(--dk-bg-muted) 30%, transparent) top / 100% var(--dk-space-6) no-repeat local,
    linear-gradient(transparent, var(--dk-bg-muted) 70%) bottom / 100% var(--dk-space-6) no-repeat local,
    linear-gradient(var(--dk-scroll-shadow), transparent) top / 100% var(--dk-space-3) no-repeat scroll,
    linear-gradient(transparent, var(--dk-scroll-shadow)) bottom / 100% var(--dk-space-3) no-repeat scroll;
  display: flex;
  flex-direction: column;
  gap: var(--dk-space-4);
  padding: var(--dk-space-1) var(--dk-space-2) var(--dk-space-3);
}
.dk-nav-group { display: grid; gap: var(--dk-space-1); }
.dk-nav-group__label {
  display: flex;
  align-items: flex-end;
  height: 24px;
  padding: 0 var(--dk-space-2) var(--dk-space-1);
  color: var(--dk-text-muted);
  font-size: var(--dk-text-xs);
  font-weight: var(--dk-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  user-select: none;
}

.dk-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--dk-space-2);
  width: 100%;
  height: 32px;
  padding: 0 var(--dk-space-2);
  border: 1px solid transparent;
  border-radius: var(--dk-radius-md);
  background: transparent;
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-medium);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.dk-nav-item:hover { background: var(--dk-bg-hover); color: var(--dk-text-heading); }
.dk-nav-item:focus-visible { outline-offset: -2px; }
.dk-nav-item__icon { width: 20px; height: 20px; flex: none; color: var(--dk-text-muted); }
.dk-nav-item:hover .dk-nav-item__icon { color: var(--dk-text-primary); }
.dk-nav-item__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dk-nav-item[aria-current="page"] { background: var(--dk-accent-soft); color: var(--dk-accent-default); font-weight: var(--dk-weight-semibold); }
.dk-nav-item[aria-current="page"] .dk-nav-item__icon { color: var(--dk-accent-default); }
.dk-nav-item[aria-current="page"] .dk-count { background: var(--dk-bg-surface); color: var(--dk-accent-default); }

.dk-sidebar__foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--dk-space-1);
  height: 52px;
  padding: 0 var(--dk-space-2);
  border-top: 1px solid var(--dk-border-default);
}

.dk-account-trigger {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--dk-space-2);
  height: 36px;
  padding: 0 var(--dk-space-2);
  border: 1px solid transparent;
  border-radius: var(--dk-radius-md);
  background: transparent;
  color: var(--dk-text-primary);
  font-size: var(--dk-text-md);
  font-weight: var(--dk-weight-medium);
  text-align: left;
}
.dk-account-trigger:hover,
.dk-account-trigger[aria-expanded="true"] { background: var(--dk-bg-hover); }
.dk-account-trigger__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-account-trigger__chev { width: 16px; height: 16px; flex: none; color: var(--dk-text-muted); }
.dk-account-trigger--compact { flex: none; width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: var(--dk-radius-full); }

/* Visually hidden, still named: rail labels and compact triggers. */
.dk-account-trigger--compact :is(.dk-account-trigger__name, .dk-account-trigger__chev) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- collapsed icon rail (desktop only) ---------------------------------------- */

@media (min-width: 821px) {
  .dk-shell[data-sidebar="collapsed"] :is(
    .dk-brand__name, .dk-brand__scope, .dk-brand__chev,
    .dk-nav-group__label, .dk-nav-item__label,
    .dk-account-trigger__name, .dk-account-trigger__chev
  ) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .dk-shell[data-sidebar="collapsed"] .dk-sidebar__head {
    flex-direction: column;
    height: auto;
    padding: var(--dk-space-2) 0;
  }
  .dk-shell[data-sidebar="collapsed"] .dk-brand { flex: none; width: 36px; height: 36px; padding: 0; justify-content: center; }
  .dk-shell[data-sidebar="collapsed"] .dk-brand__tile { display: grid; }
  .dk-shell[data-sidebar="collapsed"] :is(.dk-sidebar__head, .dk-sidebar__foot) .dk-icon-button { width: 36px; height: 36px; }
  .dk-shell[data-sidebar="collapsed"] .dk-sidebar__search { display: flex; justify-content: center; padding: 0 0 var(--dk-space-2); }
  .dk-shell[data-sidebar="collapsed"] .dk-search { display: none; }
  .dk-shell[data-sidebar="collapsed"] .dk-search__rail { display: grid; width: 36px; height: 36px; }
  .dk-shell[data-sidebar="collapsed"] .dk-sidebar__nav { scrollbar-width: none; align-items: center; gap: var(--dk-space-1); padding: var(--dk-space-1) 0 var(--dk-space-3); }
  .dk-shell[data-sidebar="collapsed"] .dk-nav-group { width: 40px; justify-items: center; }
  .dk-shell[data-sidebar="collapsed"] .dk-nav-group + .dk-nav-group { padding-top: var(--dk-space-2); border-top: 1px solid var(--dk-border-default); }
  .dk-shell[data-sidebar="collapsed"] .dk-nav-item { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .dk-shell[data-sidebar="collapsed"] .dk-nav-item .dk-count {
    position: absolute;
    top: var(--dk-space-1);
    right: var(--dk-space-1);
    width: 8px;
    height: 8px;
    min-width: 0;
    padding: 0;
    background: var(--dk-accent-default);
    font-size: 0;
  }
  .dk-shell[data-sidebar="collapsed"] .dk-sidebar__foot {
    flex-direction: column;
    height: auto;
    padding: var(--dk-space-2) 0;
  }
  .dk-shell[data-sidebar="collapsed"] .dk-account-trigger { flex: none; width: 36px; height: 36px; padding: 0; justify-content: center; }
}

@media (min-width: 821px) {
  .dk-shell[data-sidebar="collapsed"] .dk-sidebar__nav::-webkit-scrollbar { display: none; }
}

/* Rail label echo; aria-hidden, positioned by shell.js. */
.dk-tooltip {
  position: fixed;
  z-index: 80;
  padding: var(--dk-space-1) var(--dk-space-2);
  border: 1px solid var(--dk-border-default);
  border-radius: var(--dk-radius-sm);
  background: var(--dk-bg-surface);
  box-shadow: var(--dk-shadow-overlay);
  color: var(--dk-text-primary);
  font-size: var(--dk-text-sm);
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
}

/* --- popovers: beside the column, aligned with their trigger ----------------------- */

.dk-shell [data-dk-popover] {
  position: fixed;
  z-index: 40;
  top: var(--dk-space-2);
  left: calc(var(--dk-shell-col) + var(--dk-space-2));
  max-width: calc(100vw - var(--dk-shell-col) - 2 * var(--dk-space-2));
  max-height: calc(100dvh - 2 * var(--dk-space-2));
  overflow-y: auto;
}
.dk-shell .dk-account-menu { top: auto; bottom: var(--dk-space-2); width: var(--dk-size-menu); }
.dk-shell .dk-brand-menu { width: var(--dk-size-menu); }

/* --- notification panel ------------------------------------------------------------ */

.dk-shell .dk-notif-panel {
  width: var(--dk-size-panel);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.dk-notif-panel__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--dk-space-2);
  min-height: 44px;
  padding: var(--dk-space-1) var(--dk-space-2) var(--dk-space-1) var(--dk-space-4);
  border-bottom: 1px solid var(--dk-border-default);
}
.dk-notif-panel__title { color: var(--dk-text-heading); font-size: var(--dk-text-md); font-weight: var(--dk-weight-semibold); }
/* Focus lands on the title when the panel opens; it is not a control, so no ring. */
.dk-notif-panel__title:focus { outline: none; }
.dk-notif-panel__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.dk-notif-panel__day {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  height: 28px;
  padding: 0 var(--dk-space-4) var(--dk-space-1);
  background: var(--dk-bg-surface);
  color: var(--dk-text-faint);
  font-size: var(--dk-text-xs);
  font-weight: var(--dk-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dk-notif-panel__new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  border-bottom: 1px solid var(--dk-border-default);
  background: var(--dk-bg-muted);
  color: var(--dk-text-link);
  font-size: var(--dk-text-sm);
  font-weight: var(--dk-weight-medium);
}
.dk-notif-panel__new:hover { background: var(--dk-bg-hover); }
.dk-notif-panel__foot {
  flex: none;
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 var(--dk-space-4);
  border-top: 1px solid var(--dk-border-default);
  font-size: var(--dk-text-md);
}
.dk-notif-panel__foot a { text-decoration: none; }
.dk-notif-panel__foot a:hover { text-decoration: underline; }
.dk-notif-panel__status { padding: var(--dk-space-3) var(--dk-space-4); display: grid; gap: var(--dk-space-3); }

.dk-notif-item {
  position: relative;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  column-gap: var(--dk-space-3);
  padding: var(--dk-space-3) var(--dk-space-4);
  border-top: 1px solid var(--dk-border-default);
  font-size: var(--dk-text-md);
}
.dk-notif-panel__day + .dk-notif-item,
.dk-notif-panel__body > .dk-notif-item:first-child { border-top: 0; }
.dk-notif-item:hover { background: var(--dk-bg-hover); }
.dk-notif-item:has(.dk-notif-item__link:focus-visible) { outline: 3px solid var(--dk-focus-ring); outline-offset: -3px; }
.dk-notif-item__marker { height: 1lh; display: flex; align-items: center; }
.dk-notif-item__main { min-width: 0; display: grid; }
.dk-notif-item__link { color: var(--dk-text-primary); font-weight: var(--dk-weight-medium); text-decoration: none; }
.dk-notif-item__link:hover { color: inherit; }
.dk-notif-item__link:focus-visible { outline: none; }
.dk-notif-item__link::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.dk-notif-item[data-unread="true"] .dk-notif-item__link { color: var(--dk-text-heading); font-weight: var(--dk-weight-semibold); }
.dk-notif-item__desc { overflow: hidden; color: var(--dk-text-muted); font-size: var(--dk-text-sm); text-overflow: ellipsis; white-space: nowrap; }
/* Time and the mark-read button share one cell: hover/focus swaps them, so
   unread and read rows keep the same height. Touch shows both, stacked. */
.dk-notif-item__side { display: grid; justify-items: end; align-content: start; }
.dk-notif-item__side > * { grid-area: 1 / 1; }
.dk-notif-item__time { color: var(--dk-text-faint); font-family: var(--dk-font-mono); font-size: var(--dk-text-xs); line-height: 1lh; white-space: nowrap; }
.dk-notif-item__read { position: relative; z-index: 1; opacity: 0; }
.dk-notif-item:not([data-unread="true"]) .dk-notif-item__read { display: none; }
.dk-notif-item:is(:hover, :focus-within) .dk-notif-item__read { opacity: 1; }
.dk-notif-item[data-unread="true"]:is(:hover, :focus-within) .dk-notif-item__time { visibility: hidden; }
@media (pointer: coarse) {
  .dk-notif-item__side { gap: var(--dk-space-1); }
  .dk-notif-item__side > * { grid-area: auto; }
  .dk-notif-item__read { opacity: 1; }
  .dk-notif-item[data-unread="true"] .dk-notif-item__time { visibility: visible; }
  /* Two lines so a trailing date ("Due 12 Oct") isn't what the ellipsis eats. */
  .dk-notif-item__desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; }
}

/* --- topbar shell (2–3 destinations) ----------------------------------------------- */

.dk-shell--topbar {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--dk-size-topbar) minmax(0, 1fr);
  grid-template-areas: "bar" "main";
}
.dk-shell__bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: var(--dk-space-4);
  min-width: 0;
  padding: 0 var(--dk-space-4);
  border-bottom: 1px solid var(--dk-border-default);
  background: var(--dk-bg-muted);
}
.dk-shell__bar .dk-brand { flex: none; }
.dk-shell__nav { display: flex; align-items: center; gap: var(--dk-space-1); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.dk-shell__nav .dk-nav-item { width: auto; flex: none; }
.dk-shell__end { display: flex; align-items: center; gap: var(--dk-space-1); margin-left: auto; }
.dk-shell--topbar [data-dk-popover],
.dk-shell--topbar .dk-account-menu {
  top: calc(var(--dk-size-topbar) + var(--dk-space-1));
  bottom: auto;
  left: auto;
  right: var(--dk-space-4);
  max-width: calc(100vw - 2 * var(--dk-space-4));
  max-height: calc(100dvh - var(--dk-size-topbar) - var(--dk-space-4));
}

/* --- mobile: bar + modal drawer ------------------------------------------------------ */

@media (max-width: 820px) {
  .dk-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--dk-size-topbar) minmax(0, 1fr);
    grid-template-areas: "bar" "main";
  }
  .dk-topbar {
    grid-area: bar;
    display: flex;
    align-items: center;
    gap: var(--dk-space-1);
    min-width: 0;
    padding: 0 var(--dk-space-1);
    border-bottom: 1px solid var(--dk-border-default);
    background: var(--dk-bg-muted);
  }
  /* The app wordmark (a home link); the page title lives once, in the h1. */
  .dk-topbar__title {
    flex: 0 1 auto;
    align-self: stretch;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    padding: 0 var(--dk-space-1);
    border-radius: var(--dk-radius-sm);
    text-decoration: none;
    color: var(--dk-text-heading);
    font-size: var(--dk-text-body);
    font-weight: var(--dk-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dk-topbar__end { display: flex; align-items: center; margin-left: auto; }
  .dk-topbar .dk-account-trigger { flex: none; width: var(--dk-size-touch); height: var(--dk-size-touch); padding: 0; justify-content: center; }
  .dk-topbar :is(.dk-account-trigger__name, .dk-account-trigger__chev) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }

  .dk-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(288px, calc(100vw - 48px));
    border-right: 0;
    box-shadow: var(--dk-shadow-overlay);
    transform: translateX(-100%);
    visibility: hidden;
  }
  /* Opening shows the drawer at once and slides only its transform, so it can
     take focus in the same task; closing keeps visibility on its transition
     so the drawer stays visible while it slides out. (With visibility
     transitioned on open too, the drawer stayed hidden until a frame ticked,
     and a busy page could leave the modal drawer open with focus on body.) */
  .dk-shell[data-drawer="open"] .dk-sidebar { transform: none; visibility: visible; transition-property: transform; }
  .dk-sidebar__toggle { display: none; }
  .dk-sidebar__close { display: grid; }
  .dk-sidebar__head { height: var(--dk-size-topbar); }
  .dk-sidebar__foot:not(:has(.dk-account-trigger)) { display: none; }
  .dk-scrim { position: fixed; inset: 0; z-index: 45; background: var(--dk-bg-backdrop); }

  .dk-main { padding: var(--dk-space-4); }

  .dk-shell [data-dk-popover],
  .dk-shell .dk-account-menu,
  .dk-shell .dk-notif-panel {
    z-index: 60;
    top: calc(var(--dk-size-topbar) + var(--dk-space-2));
    bottom: auto;
    left: var(--dk-space-2);
    right: var(--dk-space-2);
    width: auto;
    max-width: none;
    max-height: calc(100dvh - var(--dk-size-topbar) - var(--dk-space-4));
  }
  .dk-shell__bar { gap: var(--dk-space-2); padding: 0 var(--dk-space-2); }
  .dk-shell--topbar .dk-account-trigger--compact { width: var(--dk-size-touch); height: var(--dk-size-touch); }
}

/* --- touch: phone widths and coarse pointers ----------------------------------------
   Every shell control is a 44px target. The rail keeps its 56px column; its
   44px controls fit inside it. */

@media (max-width: 820px), (pointer: coarse) {
  .dk-brand, .dk-nav-item, .dk-search, .dk-account-trigger { height: var(--dk-size-touch); }
}
@media (min-width: 821px) and (pointer: coarse) {
  .dk-shell[data-sidebar="collapsed"] .dk-nav-group { width: var(--dk-size-touch); }
  .dk-shell[data-sidebar="collapsed"] :is(
    .dk-brand, .dk-nav-item, .dk-search__rail, .dk-account-trigger,
    .dk-sidebar__head .dk-icon-button, .dk-sidebar__foot .dk-icon-button
  ) { width: var(--dk-size-touch); height: var(--dk-size-touch); }
}

@media (max-width: 820px) and (prefers-reduced-motion: no-preference) {
  .dk-sidebar { transition: transform 180ms ease, visibility 180ms; }
}
/* Reduced motion: base.css gives every property of every element a 0.01ms
   transition, so each control in the drawer would transition its own
   inherited visibility and stay hidden (unfocusable) until a frame ticks.
   In the open drawer they flip with it instead. */
@media (max-width: 820px) and (prefers-reduced-motion: reduce) {
  .dk-shell[data-drawer="open"] .dk-sidebar * { transition-property: none; }
}

}
