/* ScarabHive UI kit -- tokens, themes and the standard controls.
 *
 * Panels and the shell style themselves ONLY through the tokens and pk-*
 * classes below; a colour value anywhere else is a bug. Every component sits
 * on a native element, so behaviour (focus, keyboard, forms) comes from the
 * browser. The catalogue of all of it renders at /ui/kit.
 *
 * Themes: <html data-theme="dark|light|system">. Each colour token holds its
 * light and dark value in one light-dark() pair, and color-scheme picks.
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  /* light value first, dark value second */
  --surface-0: light-dark(#f6f7f9, #0e1116);   /* app ground */
  --surface-1: light-dark(#eef0f3, #141820);   /* sidebars, dock */
  --surface-2: light-dark(#ffffff, #1a1f28);   /* windows, cards */
  --surface-3: light-dark(#e4e7ec, #232935);   /* hover, inputs */
  --overlay:   light-dark(rgb(15 23 42 / 0.32), rgb(0 0 0 / 0.55));

  --border-subtle:  light-dark(rgb(15 23 42 / 0.08), rgb(255 255 255 / 0.06));
  --border-default: light-dark(rgb(15 23 42 / 0.14), rgb(255 255 255 / 0.10));
  --border-strong:  light-dark(rgb(15 23 42 / 0.22), rgb(255 255 255 / 0.16));

  --text-primary:   light-dark(#161a20, #e6e9ef);
  --text-secondary: light-dark(#4a5260, #aab1bd);
  --text-muted:     light-dark(#5f6671, #868e9b);   /* >= 4.5:1 on surface-0..2 only */
  --text-on-accent: #ffffff;

  --accent:        light-dark(#2563eb, #2f6fdf);
  --accent-hover:  light-dark(#1d4ed8, #3d7df0);
  --accent-subtle: light-dark(rgb(37 99 235 / 0.10), rgb(47 111 223 / 0.18));
  --accent-text:   light-dark(#1d4ed8, #6ea2ff);
  --focus-ring:    light-dark(#1d4ed8, #6ea2ff);

  --ok:     light-dark(#1a7f37, #3fb950);
  --warn:   light-dark(#9a6700, #d29922);
  --danger: light-dark(#cf222e, #f85149);
  --info:   light-dark(#0969da, #58a6ff);
  --ok-subtle:     light-dark(rgb(26 127 55 / 0.10), rgb(63 185 80 / 0.15));
  --warn-subtle:   light-dark(rgb(154 103 0 / 0.10), rgb(210 153 34 / 0.15));
  --danger-subtle: light-dark(rgb(207 34 46 / 0.10), rgb(248 81 73 / 0.15));
  --info-subtle:   light-dark(rgb(9 105 218 / 0.10), rgb(88 166 255 / 0.15));
  --danger-hover:  light-dark(#a40e26, #ff6a61);

  --brand: light-dark(#a8841c, #c9a227);

  --field-bg: light-dark(#ffffff, #0e1116);   /* inputs: white on light, sunk on dark */

  --shadow-color: light-dark(rgb(15 23 42 / 0.16), rgb(0 0 0 / 0.5));
  --shadow-soft:  light-dark(rgb(15 23 42 / 0.06), rgb(0 0 0 / 0.28));
  /* light-dark() takes colours, not shadows */
  --shadow-sm: 0 1px 2px var(--shadow-soft);
  --shadow-overlay: 0 2px 6px var(--shadow-soft), 0 16px 40px var(--shadow-color);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, "SF Mono", Menlo, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --control-h-sm: 28px;
  --control-h-md: 32px;
  --control-h-lg: 36px;

  --duration-fast: 120ms;
  --duration-base: 160ms;
}

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

@media (prefers-reduced-motion: reduce) {
  :root { --duration-fast: 0ms; --duration-base: 0ms; }
}

/* -------------------------------------------------------------------- base */
/* Only for documents that opt in with class="pk-root" on <html>. The element
 * rules sit in :where(), so any component class overrides them. */

.pk-root {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* hidden hides, whatever display a component sets */
:where(.pk-root) [hidden] { display: none !important; }
:where(.pk-root) *, :where(.pk-root) *::before, :where(.pk-root) *::after { box-sizing: border-box; }
:where(.pk-root) body { margin: 0; }
:where(.pk-root) :focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
:where(.pk-root) ::selection { background: var(--accent-subtle); }
:where(.pk-root) a { color: var(--accent-text); text-decoration: none; }
:where(.pk-root a:hover) { text-decoration: underline; }
:where(.pk-root) :is(h1, h2, h3) { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
:where(.pk-root) h1 { font-size: var(--text-xl); }
:where(.pk-root) h2 { font-size: var(--text-lg); }
:where(.pk-root) h3 { font-size: var(--text-md); }
:where(.pk-root) :is(code, kbd, samp, pre) { font-family: var(--font-mono); font-size: 0.92em; }
:where(.pk-root) ::-webkit-scrollbar { width: 10px; height: 10px; }
:where(.pk-root) ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
:where(.pk-root) ::-webkit-scrollbar-track { background: transparent; }

/* A panel document: header row, a body that scrolls both ways beneath it.
 * The body, not a table box, is what scrolls sideways: a table box's scrollbar
 * sits at the table's end, often far below the view, so a panel pushed
 * narrow showed its content cut off with no scrollbar in reach. */
.pk-panel { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--surface-2); }
.pk-page-header {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 44px; padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 10; background: var(--surface-2);
}
.pk-page-title { font-size: var(--text-md); font-weight: 600; margin: 0; }
/* In a frame the shell's tab or window bar carries the title; the toolbar stays. */
[data-framed] .pk-page-title { display: none; }
[data-framed] .pk-page-header { justify-content: flex-end; min-height: 0; }
[data-framed] .pk-page-header:has(> .pk-toolbar:empty) { display: none; }
/* scroll-padding: a row the keyboard moves to is scrolled clear of a sticky table head (its height: padding, one
 * line of --text-xs, the border) instead of counting as visible beneath it */
.pk-page-body { --pk-scroll-pad-top: var(--space-4); scroll-padding-top: calc(var(--space-2) * 3 + var(--text-xs) * 1.5 + 1px); flex: 1; min-height: 0; overflow: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }
/* A scrolling column squeezes children that clip (a code block, a table box) instead of scrolling past them. */
:where(.pk-page-body) > * { flex-shrink: 0; }

/* ------------------------------------------------------------------- icons */

.pk-icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px;
}
.pk-icon--sm { width: 14px; height: 14px; }
@keyframes pk-spin { to { transform: rotate(360deg); } }

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

.pk-btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text-primary);
  --btn-border: var(--border-default);
  --btn-bg-hover: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h-md); padding: 0 var(--space-3);
  font: 500 var(--text-sm)/1 var(--font-ui);
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-border); border-radius: var(--radius-md);
  cursor: pointer; white-space: nowrap; user-select: none;
  box-shadow: var(--btn-shadow, var(--shadow-sm));
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);
}
.pk-btn:hover:not(:disabled) { background: var(--btn-bg-hover); }
.pk-btn:active:not(:disabled) { transform: translateY(1px); }
.pk-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pk-btn--primary { --btn-bg: var(--accent); --btn-fg: var(--text-on-accent); --btn-border: transparent; --btn-bg-hover: var(--accent-hover); }
.pk-btn--danger { --btn-bg: var(--danger); --btn-fg: var(--text-on-accent); --btn-border: transparent; --btn-bg-hover: var(--danger-hover); }
.pk-btn--ghost { --btn-shadow: none; --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-secondary); --btn-bg-hover: var(--surface-3); }
.pk-btn--ghost:hover:not(:disabled) { color: var(--text-primary); }
.pk-btn--sm { height: var(--control-h-sm); padding: 0 var(--space-2); font-size: var(--text-xs); }
.pk-btn--lg { height: var(--control-h-lg); padding: 0 var(--space-4); font-size: var(--text-md); }
.pk-btn--icon { width: var(--control-h-md); padding: 0; }
.pk-btn--icon.pk-btn--sm { width: var(--control-h-sm); }
/* pressed, or the current item of a list (a machine, an agent): marked, and still marked under the pointer */
.pk-btn[aria-pressed="true"], .pk-btn[aria-current="true"] {
  --btn-bg: var(--accent-subtle); --btn-fg: var(--accent-text); --btn-border: transparent;
  --btn-bg-hover: var(--accent-subtle); --btn-shadow: none;
}

/* ------------------------------------------------------------------ inputs */

.pk-input, .pk-select, .pk-textarea {
  width: 100%; height: var(--control-h-md); padding: 0 var(--space-3);
  font: 400 var(--text-sm)/1.4 var(--font-ui); color: var(--text-primary);
  background-color: var(--field-bg); border: 1px solid var(--border-default); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.pk-textarea { height: auto; min-height: 72px; padding: var(--space-2) var(--space-3); resize: vertical; }
.pk-select { appearance: none; padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.pk-input::placeholder, .pk-textarea::placeholder { color: var(--text-muted); }
.pk-input:hover, .pk-select:hover, .pk-textarea:hover { border-color: var(--border-strong); }
.pk-input:focus, .pk-select:focus, .pk-textarea:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--accent-subtle); }
.pk-input:disabled, .pk-select:disabled, .pk-textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.pk-input[aria-invalid="true"], .pk-textarea[aria-invalid="true"] { border-color: var(--danger); }
.pk-input--sm, .pk-select--sm { height: var(--control-h-sm); font-size: var(--text-xs); }
.pk-input--mono { font-family: var(--font-mono); }

.pk-search { position: relative; display: flex; align-items: center; }
.pk-search > .pk-icon { position: absolute; left: var(--space-3); color: var(--text-muted); pointer-events: none; }
.pk-search > .pk-input { padding-left: calc(var(--space-3) + 16px + var(--space-2)); }

/* One icon picked from a grid (iconPicker() in panel-kit.js): radios, so the form carries the pick and arrow keys move it */
.pk-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: var(--space-1); min-width: 0; margin: 0; padding: 0; border: 0; }
.pk-icon-grid > legend { margin-bottom: var(--space-1); padding: 0; }
.pk-icon-grid > label {
  position: relative; display: inline-flex; align-items: center; justify-content: center; height: var(--control-h-md);
  border-radius: var(--radius-md); color: var(--text-secondary); cursor: pointer;
}
.pk-icon-grid > label:hover { background: var(--surface-3); color: var(--text-primary); }
.pk-icon-grid > label:has(input:checked) { background: var(--accent-subtle); color: var(--accent-text); }
.pk-icon-grid > label:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.pk-icon-grid input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }

.pk-check, .pk-radio, .pk-switch { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.pk-check input, .pk-radio input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.pk-switch input {
  appearance: none; margin: 0; position: relative; flex: none;
  width: 30px; height: 18px; border-radius: 9px;
  background: var(--surface-3); border: 1px solid var(--border-default);
  transition: background var(--duration-fast);
}
.pk-switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-secondary); transition: transform var(--duration-fast), background var(--duration-fast);
}
.pk-switch input:checked { background: var(--accent); border-color: transparent; }
.pk-switch input:checked::after { transform: translateX(12px); background: var(--text-on-accent); }

.pk-field { display: flex; flex-direction: column; gap: var(--space-1); }
/* a switch in a field: as tall as an input in the field beside it, so their help lines start level */
.pk-field .pk-switch { min-height: var(--control-h-md); }
.pk-field > .pk-label, .pk-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
.pk-help { font-size: var(--text-xs); color: var(--text-muted); }
.pk-error { font-size: var(--text-xs); color: var(--danger); }
.pk-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 480px; }
.pk-form-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* -------------------------------------------------------------------- tabs */

/* Each tab as wide as its text while they all fit; short of room they give way down to five characters and an
   ellipsis, then the row scrolls sideways -- the wheel turns it too, and the chosen tab is brought into sight
   (panel-kit.js; a nav of a.pk-tab links too, its current page brought into sight). 4.5em: five characters of our
   labels in Inter and the ellipsis take up to 4.1em. A shorter label keeps its own width, where the browser has
   calc-size() (Chromium 129+); elsewhere it is padded out to the least width. The line under the row is a shadow: a
   border would be cut off by the scrolling box, and with it the marker of the chosen tab that sits on it.
   flex-shrink 0: a scrolling box has no least height of its own, and a column short of room squeezed the row to
   nothing; in a row, a .pk-tabs that is to give way sideways gets flex: 1 1 auto. */
.pk-tabs {
  display: flex; flex-shrink: 0; gap: var(--space-1); box-shadow: inset 0 -1px 0 var(--border-subtle);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.pk-tab {
  position: relative; display: block; flex: 0 1 auto;
  min-width: var(--pk-tab-min, calc(4.5em + var(--pk-tab-lead, 0px) + 2 * var(--space-3)));
  height: var(--control-h-md); padding: 0 var(--space-3);
  font: 500 var(--text-sm)/var(--control-h-md) var(--font-ui); color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
  background: none; border: 0; cursor: pointer;
}
@supports (min-width: calc-size(max-content, size)) {
  .pk-tab { min-width: var(--pk-tab-min, calc-size(max-content, min(size, 4.5em + var(--pk-tab-lead, 0px) + 2 * var(--space-3)))); }
}
.pk-tab:has(> :is(.pk-icon, .pk-dot):first-child) { --pk-tab-lead: 20px; }  /* an icon or dot ahead of the text */
.pk-tab:hover { color: var(--text-primary); }
.pk-tab:focus-visible { outline-offset: -2px; }  /* inside: the scrolling row would cut a ring outside off */
/* a.pk-tab in a nav: the pages of one panel, the current one marked with aria-current="page" */
a.pk-tab { text-decoration: none; }
.pk-tab[aria-selected="true"], .pk-tab[aria-current="page"] { color: var(--text-primary); }
.pk-tab[aria-selected="true"]::after, .pk-tab[aria-current="page"]::after {
  content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: 0;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.pk-tab-count { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
/* in a tab, room for the count as it comes and goes: the label keeps its width */
.pk-tab > .pk-tab-count { display: inline-block; min-width: 2ch; line-height: 1; }

/* ----------------------------------------------------------------- dialogs */

.pk-dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  padding: 0; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
}
.pk-dialog--wide { width: min(720px, calc(100vw - 32px)); }
/* Resizable at its corner (the kit keeps the size per panel): the form fills it, a .pk-field--grow takes the room
   left, the buttons stay in view at the bottom. */
.pk-dialog--resizable {
  width: min(840px, calc(100vw - 32px)); height: min(680px, calc(100vh - 64px));
  min-width: min(360px, calc(100vw - 32px)); min-height: min(320px, calc(100vh - 64px)); max-width: calc(100vw - 32px);
  resize: both; overflow: hidden;
}
.pk-dialog--resizable[open] { display: flex; flex-direction: column; }
.pk-dialog--resizable > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pk-dialog--resizable .pk-dialog-body { flex: 1; min-height: 0; }
.pk-dialog--resizable .pk-form { max-width: none; }
.pk-field--grow { flex: 1 1 auto; min-height: 140px; }
.pk-field--grow > .pk-textarea { flex: 1; resize: none; }
.pk-dialog::backdrop { background: var(--overlay); }
.pk-dialog[open] { animation: pk-pop var(--duration-base) ease-out; }
@keyframes pk-pop { from { opacity: 0; transform: translateY(4px) scale(0.99); } }
.pk-dialog-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-4) 0; }
.pk-dialog-title { font-size: var(--text-lg); font-weight: 600; margin: 0; }
.pk-dialog-body { --pk-scroll-pad-top: var(--space-3); padding: var(--space-3) var(--space-4); color: var(--text-secondary); font-size: var(--text-sm); overflow: auto; }
.pk-dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-4); }

.pk-drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: none; width: min(420px, 100vw);
  border-radius: 0; border-width: 0 0 0 1px;
}
/* the head stays where it is, the body scrolls ([open]: a display of its own would show a closed dialog) */
.pk-drawer[open] { display: flex; flex-direction: column; overflow: hidden; }
.pk-drawer > .pk-dialog-body { flex: 1; min-height: 0; }

/* -------------------------------------------------------------------- menus */

.pk-menu {
  /* the height stays capped by placeMenu and scrolls: every menu is a popover, and those scroll by themselves */
  min-width: 180px; padding: var(--space-1); margin: 0;
  color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
}
.pk-menu-item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  height: var(--control-h-md); padding: 0 var(--space-2);
  font: 400 var(--text-sm)/1 var(--font-ui); color: var(--text-primary); text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.pk-menu-item:hover, .pk-menu-item:focus-visible { background: var(--surface-3); outline: none; }
.pk-menu-item:disabled { opacity: 0.5; cursor: not-allowed; background: none; }
.pk-menu-item--danger { color: var(--danger); }
.pk-menu-separator { height: 1px; margin: var(--space-1) 0; background: var(--border-subtle); border: 0; }
.pk-menu-label { padding: var(--space-2) var(--space-2) var(--space-1); font-size: var(--text-xs); font-weight: 500; color: var(--text-muted); }

kbd.pk-kbd {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
  font: 500 11px/1 var(--font-mono); color: var(--text-muted);
  background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ toasts */

.pk-toasts {
  position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 10000;
  display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none;
}
.pk-toast {
  --toast-accent: var(--info);
  display: flex; align-items: flex-start; gap: var(--space-2); max-width: 380px;
  padding: var(--space-3); font-size: var(--text-sm); pointer-events: auto;
  color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border-default); border-left: 3px solid var(--toast-accent);
  border-radius: var(--radius-md); box-shadow: var(--shadow-overlay);
  animation: pk-pop var(--duration-base) ease-out;
}
.pk-toast > .pk-icon { color: var(--toast-accent); margin-top: 2px; }
.pk-toast--ok { --toast-accent: var(--ok); }
.pk-toast--warn { --toast-accent: var(--warn); }
.pk-toast--error { --toast-accent: var(--danger); }

/* ------------------------------------------------------- badges and status */

.pk-badge {
  --badge-fg: var(--text-secondary); --badge-bg: var(--surface-3);
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 20px; padding: 0 var(--space-2);
  font: 500 var(--text-xs)/1 var(--font-ui); color: var(--badge-fg); background: var(--badge-bg);
  border-radius: 10px; white-space: nowrap;
}
.pk-badge--ok { --badge-fg: var(--ok); --badge-bg: var(--ok-subtle); }
.pk-badge--warn { --badge-fg: var(--warn); --badge-bg: var(--warn-subtle); }
.pk-badge--danger { --badge-fg: var(--danger); --badge-bg: var(--danger-subtle); }
.pk-badge--info { --badge-fg: var(--info); --badge-bg: var(--info-subtle); }
.pk-badge--accent { --badge-fg: var(--accent-text); --badge-bg: var(--accent-subtle); }

.pk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; display: inline-block; }
.pk-dot--ok { background: var(--ok); }
.pk-dot--warn { background: var(--warn); }
.pk-dot--danger { background: var(--danger); }
.pk-dot--info { background: var(--info); }

/* ------------------------------------------------------ cards and numbers */

.pk-card {
  background: var(--surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm);
}
.pk-card-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.pk-card-title { font-size: var(--text-sm); font-weight: 600; margin: 0; }
.pk-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.pk-stat { padding: var(--space-3); background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.pk-stat-label { font-size: var(--text-xs); color: var(--text-muted); }
.pk-stat-value { font-size: var(--text-xl); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

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

/* As wide as the table needs (its cells still wrap first), never a scroll box of its own: the panel body
 * scrolls, and a sticky head sticks to it. clip only rounds the corners. */
.pk-table-wrap { width: fit-content; min-width: 100%; overflow: clip; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.pk-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.pk-table th {
  /* sticky holds at the scroller's content edge: pulled up by its padding, the head meets the top without a gap */
  position: sticky; top: calc(-1 * var(--pk-scroll-pad-top, 0px)); z-index: 1; text-align: left; white-space: nowrap;
  padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: 500; color: var(--text-muted);
  background: var(--surface-1); border-bottom: 1px solid var(--border-subtle);
}
.pk-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.pk-table tbody tr:last-child td { border-bottom: 0; }
.pk-table tbody tr:hover td { background: var(--surface-1); }
.pk-table tr[aria-selected="true"] td { background: var(--accent-subtle); }
/* cells edited in place (data-pk-edit, panel-kit.js): a hint under the pointer, the input fills the cell */
.pk-table[data-pk-edit] td[data-edit] { cursor: text; }
.pk-table[data-pk-edit] td[data-edit]:hover { box-shadow: inset 0 0 0 1px var(--border-default); }
.pk-table[data-pk-edit] td[data-edit]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.pk-table td.pk-cell--editing { padding: 2px; }
.pk-cell-input { height: calc(var(--control-h-md) - 4px); min-width: 8ch; padding: 0 var(--space-2); }
.pk-num > .pk-cell-input { text-align: right; }
.pk-table td[aria-busy="true"] { opacity: 0.6; }
.pk-table .pk-num { text-align: right; font-variant-numeric: tabular-nums; }
.pk-table th[aria-sort] { cursor: pointer; }
.pk-table th[aria-sort="ascending"]::after { content: " ↑"; }
.pk-table th[aria-sort="descending"]::after { content: " ↓"; }
.pk-table th:is([aria-sort="ascending"], [aria-sort="descending"]) { color: var(--text-primary); }
/* the head of a data-pk-sort table: the kit wraps its text in this button */
.pk-table .pk-sort { font: inherit; color: inherit; text-align: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.pk-table .pk-sort:hover { color: var(--text-primary); }
/* resizable columns (panel-kit.js): a grip on each head's right edge but the last; once a width is set the table
 * lays out fixed, a cell of text that does not fit ends in "…" (whole on hover), a cell holding blocks wraps */
.pk-col-grip { position: absolute; top: 0; right: 0; bottom: 0; width: 7px; cursor: col-resize; touch-action: none; }
.pk-col-grip::after { content: ""; position: absolute; top: 25%; bottom: 25%; right: 0; width: 1px; background: var(--border-default); }
.pk-col-grip:hover::after, .pk-col-grip.is-dragging::after { top: 0; bottom: 0; width: 2px; background: var(--accent); }
.pk-table--sized { table-layout: fixed; }
.pk-table--sized :is(th, td) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-table--sized td:has(> :is(div, p, pre, ul, ol, dl, details, table, form)) { white-space: normal; overflow-wrap: anywhere; }
.pk-table--measuring td:is(td) { white-space: nowrap; }  /* while a fit measures: what a cell needs unwrapped */
/* the head's button gives way first, the sort arrow after it (th::after) stays in the cell */
.pk-table--sized .pk-sort { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.pk-table--sized th:is([aria-sort="ascending"], [aria-sort="descending"]) .pk-sort { max-width: calc(100% - 1.25em); }

/* ---------------------------------------------------------- layout helpers */

.pk-toolbar { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; flex-wrap: wrap; }
.pk-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pk-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.pk-grow { flex: 1; min-width: 0; }
.pk-muted { color: var(--text-muted); }
.pk-secondary { color: var(--text-secondary); }
.pk-mono { font-family: var(--font-mono); font-size: 0.92em; }
.pk-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ----------------------------------------------------- empty and loading */

.pk-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-8) var(--space-4); text-align: center; color: var(--text-muted); font-size: var(--text-sm);
}
.pk-stats > .pk-empty { grid-column: 1 / -1; }  /* a notice in place of the figures spans the row */
.pk-empty > .pk-icon { width: 28px; height: 28px; color: var(--text-muted); stroke-width: 1.5; }
.pk-empty-title { font-size: var(--text-md); font-weight: 600; color: var(--text-secondary); }

.pk-spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none;
  border: 2px solid var(--border-default); border-top-color: var(--accent);
  animation: pk-spin 0.8s linear infinite;
}
.pk-skeleton {
  display: block; height: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-3), var(--surface-1), var(--surface-3));
  background-size: 200% 100%; animation: pk-shimmer 1.4s ease-in-out infinite;
}
@keyframes pk-shimmer { to { background-position: -200% 0; } }

/* A drop target for files: .pk-drop--over while something is dragged over it. */
.pk-drop { border-radius: var(--radius-lg); outline: 2px dashed transparent; outline-offset: var(--space-1); }
.pk-drop--over { outline-color: var(--accent); background: var(--accent-subtle); }
.pk-progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.pk-progress::-webkit-progress-bar { background: var(--surface-3); }
.pk-progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
.pk-progress::-moz-progress-bar { background: var(--accent); }

/* ------------------------------------------------------ code and key/value */

.pk-code {
  margin: 0; padding: var(--space-3); overflow: auto; max-height: 480px;
  font: 400 var(--text-xs)/1.55 var(--font-mono); color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  white-space: pre-wrap; word-break: break-word;
}
.pk-kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-4); margin: 0; font-size: var(--text-sm); }
.pk-kv dt { color: var(--text-muted); }
.pk-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* JSON for reading: every level open; a text runs on from its key and wraps back to the left edge,
   a nested object or list goes indented under its key */
.pk-json { font-size: var(--text-sm); line-height: 1.55; color: var(--text-primary); overflow-wrap: anywhere; }
.pk-json-object { display: flex; flex-direction: column; gap: var(--space-1); }
.pk-json-field--nested > :not(.pk-json-key) {
  margin: 2px 0 var(--space-1) var(--space-1); padding-left: var(--space-3); border-left: 2px solid var(--border-subtle);
}
.pk-json-key { font-weight: 600; color: var(--accent-text); }
.pk-json-key::after { content: ": "; font-weight: 400; color: var(--text-muted); white-space: pre; }
.pk-json-list { margin: 0; padding-left: var(--space-5); }
.pk-json-field--nested > .pk-json-list { padding-left: var(--space-5); }  /* room for the bullets beside the rule */
.pk-json-list > li + li { margin-top: var(--space-1); }
.pk-json-list > li::marker { color: var(--text-muted); }
.pk-json-string { white-space: pre-wrap; }
.pk-json-number { font: 400 var(--text-xs)/1.55 var(--font-mono); color: var(--warn); }
.pk-json-null { font-style: italic; color: var(--text-muted); }

/* YAML text coloured by yamlCode(): spans around the text, which stays as it is */
.pk-yaml-key { color: var(--accent-text); }
.pk-yaml-string { color: var(--ok); }
.pk-yaml-number, .pk-yaml-word { color: var(--warn); }
.pk-yaml-comment { color: var(--text-muted); font-style: italic; }
.pk-yaml-punct { color: var(--text-secondary); }
.pk-yaml-tag, .pk-yaml-anchor { color: var(--info); }

/* --------------------------------------------------------- session scope */

pk-session { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ----------------------------------------------------------- refresh ctrl */

pk-refresh { display: inline-flex; align-items: center; gap: 2px; }
pk-refresh .pk-refresh-auto { font-variant-numeric: tabular-nums; border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: var(--space-1); }
/* the chevron joins the interval into one pill and wears its pressed colour */
pk-refresh .pk-refresh-pick { width: 16px; padding: 0; margin-left: -2px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
pk-refresh:has(.pk-refresh-auto[aria-pressed="true"]) .pk-refresh-pick { --btn-bg: var(--accent-subtle); --btn-fg: var(--accent-text); }
.pk-refresh-menu { min-width: 128px; }
.pk-refresh-menu .pk-menu-item { height: var(--control-h-sm); font-variant-numeric: tabular-nums; }
.pk-refresh-menu .pk-menu-item[aria-pressed="false"] > .pk-icon { visibility: hidden; }

/* ------------------------------------------------------------ page layout */

/* a row of filters above a list: fields side by side, wrapping, their controls on one line */
.pk-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2) var(--space-3); }
.pk-filters > .pk-field { min-width: 140px; }
/* a bare select in a filter row: as wide as its choices, beside the search */
.pk-filters > .pk-select { width: auto; }

/* a list beside the detail of the chosen entry; the detail stays in view while the list scrolls */
.pk-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-4); align-items: start; }
.pk-split > :last-child { position: sticky; top: var(--space-3); max-height: calc(var(--pk-body-height, 100vh) - 2 * var(--space-3)); overflow: auto; }
@media (max-width: 760px) { .pk-split { grid-template-columns: minmax(0, 1fr); } .pk-split > :last-child { position: static; max-height: none; } }

/* a side pane (a list, its filters) beside the main one: the viewer drags its corner to set its width, which the kit
   keeps for the panel (initSidebars); a narrow panel stacks the two, the side pane at full width */
.pk-sidebar-layout { flex: 1 1 auto; min-height: 0; display: flex; }
.pk-sidebar-layout > :not(.pk-sidebar) { flex: 1 1 auto; min-width: 0; }
.pk-sidebar {
  flex: none; width: 18rem; min-width: 11rem; max-width: 50%; resize: horizontal; overflow: auto;
  border-right: 1px solid var(--border-subtle);
}
@media (max-width: 640px) {
  .pk-sidebar-layout { flex-direction: column; }
  /* !important: over the width dragged on a wider panel, which the kit keeps inline */
  .pk-sidebar { width: auto !important; max-width: none; max-height: 40vh; resize: none; border-right: 0; border-bottom: 1px solid var(--border-subtle); }
}

/* a section that folds */
.pk-details { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 0 var(--space-3); }
.pk-details > summary {
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0;
  font-size: var(--text-sm); font-weight: 600; cursor: pointer; list-style: none;
}
.pk-details > summary::-webkit-details-marker { display: none; }
.pk-details > summary::before { content: "▸" / ""; color: var(--text-muted); }
.pk-details[open] > summary::before { content: "▾" / ""; }
.pk-details[open] { padding-bottom: var(--space-3); }

/* text to read: a comfortable measure, stored line breaks kept */
.pk-prose { max-width: 72ch; font-size: var(--text-md); line-height: 1.65; overflow-wrap: anywhere; }
.pk-prose p { margin: 0 0 var(--space-3); }
.pk-prose--breaks { white-space: pre-wrap; }
.pk-prose ul, .pk-prose ol { margin: 0 0 var(--space-3); padding-left: var(--space-5); }
.pk-prose h1, .pk-prose h2, .pk-prose h3 { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-lg); line-height: 1.3; }
.pk-prose h1 { font-size: var(--text-xl); }
.pk-prose > :first-child { margin-top: 0; }
.pk-prose blockquote { margin: 0 0 var(--space-3); padding-left: var(--space-3); border-left: 3px solid var(--border-strong); color: var(--text-secondary); }
.pk-prose code { font-family: var(--font-mono); font-size: 0.92em; padding: 0 0.25em; border-radius: var(--radius-sm); background: var(--surface-3); }
/* The markdown editor (panel-kit.js initMarkdownEditors): toolbar above the textarea, preview in its place. */
.pk-md-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.pk-md-preview { max-width: none; min-height: 72px; overflow: auto; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-1); }
.pk-field--grow > .pk-md-preview { flex: 1; }

/* a message in place: an error, a warning, a note, a success (see notice() in panel-kit.js) */
.pk-callout {
  margin: 0; padding: var(--space-2) var(--space-3); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md); background: var(--surface-1); font-size: var(--text-sm); color: var(--text-primary);
}
.pk-callout--danger { border-left-color: var(--danger); background: var(--danger-subtle); }
.pk-callout--warn { border-left-color: var(--warn); background: var(--warn-subtle); }
.pk-callout--info { border-left-color: var(--info); background: var(--info-subtle); }
.pk-callout--ok { border-left-color: var(--ok); background: var(--ok-subtle); }

/* previous / next */
pk-pager { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); font-size: var(--text-sm); }
pk-pager .pk-pager-label { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* a table whose rows are chosen (data-pk-select) */
table[data-pk-select] > tbody > tr[data-id] { cursor: pointer; }
table[data-pk-select] > tbody > tr[data-id]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* a bar in a tone */
.pk-progress--ok::-webkit-progress-value { background: var(--ok); }
.pk-progress--ok::-moz-progress-bar { background: var(--ok); }
.pk-progress--warn::-webkit-progress-value { background: var(--warn); }
.pk-progress--warn::-moz-progress-bar { background: var(--warn); }
.pk-progress--danger::-webkit-progress-value { background: var(--danger); }
.pk-progress--danger::-moz-progress-bar { background: var(--danger); }

/* the chosen entry of a list in a menu (suggestions) */
.pk-menu-item[aria-selected="true"] { background: var(--surface-3); }

/* a value in a tone, as text */
.pk-text--ok { color: var(--ok); }
.pk-text--warn { color: var(--warn); }
.pk-text--danger { color: var(--danger); }
.pk-text--info { color: var(--info); }

/* code shown in full, without the height cap */
.pk-code--full { max-height: none; }

/* ------------------------------------------------------------------ status */
/* One status set for runs, stages and jobs: an icon in a tone, its word beside it when wanted. Markup from status()
   in panel-kit.js or the status() macro -- the icons are theirs. A pill (--pill) is the badge of a page header. */
.pk-status {
  --status: var(--text-muted);
  display: inline-flex; align-items: center; gap: var(--space-1); flex: none;
  font: 500 var(--text-xs)/1 var(--font-ui); color: var(--status); white-space: nowrap;
}
.pk-status--running { --status: var(--info); }
.pk-status--success { --status: var(--ok); }
.pk-status--failed { --status: var(--danger); }
.pk-status--canceled, .pk-status--manual { --status: var(--text-secondary); }
.pk-status--waiting, .pk-status--paused { --status: var(--warn); }
.pk-status--running > .pk-icon { animation: pk-spin 1.2s linear infinite; }
.pk-status--pill {
  height: 22px; padding: 0 var(--space-2); border-radius: 11px;
  background: color-mix(in srgb, var(--status) 14%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  .pk-status--running > .pk-icon { animation: none; }
}

/* ---------------------------------------------------------------- pipeline */
/* Stages as columns, their jobs beneath, joined by lines (a CI pipeline graph). Every job is as tall as --pk-job-h,
   so the line joining a stage's jobs runs from the first one's middle to the last one's. Scrolls sideways when the
   stages do not fit. */
.pk-pipeline {
  --pk-job-h: 30px; --pk-pipeline-gap: var(--space-8);
  display: flex; align-items: flex-start; overflow-x: auto; padding-bottom: var(--space-2); scrollbar-width: thin;
}
.pk-pipeline-stage { flex: none; display: flex; flex-direction: column; gap: var(--space-2); padding: 0 calc(var(--pk-pipeline-gap) / 2); }
.pk-pipeline-stage:first-child { padding-left: 0; }
.pk-pipeline-stage:last-child { padding-right: 0; }
.pk-pipeline-stage-title {
  display: flex; align-items: center; gap: var(--space-1); margin: 0; padding-left: var(--space-1);
  font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}
.pk-pipeline-jobs { position: relative; display: flex; flex-direction: column; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.pk-pipeline-jobs > li { position: relative; display: flex; }
.pk-pipeline-stage:not(:first-child) .pk-pipeline-jobs > li::before,
.pk-pipeline-stage:not(:last-child) .pk-pipeline-jobs > li::after {
  content: ""; position: absolute; top: calc(50% - 1px); width: calc(var(--pk-pipeline-gap) / 2);
  border-top: 2px solid var(--border-strong);
}
.pk-pipeline-jobs > li::before { right: 100%; }
.pk-pipeline-jobs > li::after { left: 100%; }
.pk-pipeline-stage:not(:first-child) .pk-pipeline-jobs::before,
.pk-pipeline-stage:not(:last-child) .pk-pipeline-jobs::after {
  content: ""; position: absolute; top: calc(var(--pk-job-h) / 2 - 1px); bottom: calc(var(--pk-job-h) / 2 - 1px);
  border-left: 2px solid var(--border-strong);
}
.pk-pipeline-jobs::before { left: calc(var(--pk-pipeline-gap) / -2 - 1px); }
.pk-pipeline-jobs::after { right: calc(var(--pk-pipeline-gap) / -2 - 1px); }
.pk-pipeline .pk-job { width: 100%; min-width: 9rem; max-width: 16rem; }

/* a job: a pill with its status, name and duration -- a button or link when it opens something */
.pk-job {
  display: inline-flex; align-items: center; gap: var(--space-2); height: var(--pk-job-h, 30px); min-width: 0;
  padding: 0 var(--space-3) 0 var(--space-2);
  font: 400 var(--text-sm)/1 var(--font-ui); color: var(--text-primary); text-align: left; text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--border-default); border-radius: calc(var(--pk-job-h, 30px) / 2);
}
:is(button, a).pk-job { cursor: pointer; }
:is(button, a).pk-job:hover { background: var(--surface-3); text-decoration: none; }
.pk-job[aria-current="true"] { border-color: var(--accent); background: var(--accent-subtle); }
.pk-job-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-job-time { flex: none; font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
/* several jobs behind one pill: the count where the time would be */
.pk-job-count {
  flex: none; min-width: 20px; height: 18px; padding: 0 var(--space-1); border-radius: 9px;
  font-size: var(--text-xs); line-height: 18px; text-align: center; color: var(--text-secondary); background: var(--surface-3);
}

/* the inline row of stage icons in a list (a mini pipeline graph): short lines between them */
.pk-pipeline--mini { display: inline-flex; align-items: center; overflow: visible; padding: 0; gap: 0; }
.pk-pipeline--mini > * { position: relative; display: inline-flex; }
.pk-pipeline--mini > * + * { margin-left: var(--space-3); }
.pk-pipeline--mini > * + *::before {
  content: ""; position: absolute; right: calc(100% + 2px); top: calc(50% - 0.5px); width: calc(var(--space-3) - 4px);
  border-top: 1px solid var(--border-strong);
}
.pk-pipeline--mini > :is(button, a) { padding: 0; background: none; border: 0; border-radius: 50%; cursor: pointer; }

/* ---------------------------------------------------------------- timeline */
/* What happened, newest last: an icon on a line, who, what, when, and an optional body (a comment, a decision). */
.pk-timeline { margin: 0; padding: 0; list-style: none; }
.pk-timeline-item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--space-3); padding-bottom: var(--space-4); }
.pk-timeline-item:last-child { padding-bottom: 0; }
.pk-timeline-item:not(:last-child)::before {
  content: ""; position: absolute; left: 11px; top: 26px; bottom: 2px; border-left: 2px solid var(--border-subtle);
}
.pk-timeline-icon {
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  color: var(--text-secondary); background: var(--surface-1); border: 1px solid var(--border-subtle);
}
.pk-timeline-icon > .pk-status { gap: 0; }
.pk-timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-1); min-height: 24px; padding-top: 2px; font-size: var(--text-sm); color: var(--text-secondary); }
.pk-timeline-actor { font-weight: 600; color: var(--text-primary); }
.pk-timeline-time { color: var(--text-muted); font-size: var(--text-xs); white-space: nowrap; }
.pk-timeline-time::before { content: "· "; }
.pk-timeline-body {
  margin-top: var(--space-2); padding: var(--space-2) var(--space-3); font-size: var(--text-sm); overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
}

/* ------------------------------------------------------------- detail page */
/* One thing's page: a header across the top (status, title, meta, actions), the main column and a sidebar on the
   right with its facts in sections; a narrow panel stacks the sidebar under the main column. */
.pk-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 18rem); gap: var(--space-4) var(--space-6); align-items: start; }
.pk-detail-head {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2) var(--space-4);
  padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-subtle);
}
.pk-detail-head > :first-child { flex: 1 1 24rem; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.pk-detail-title { margin: 0; font-size: var(--text-xl); font-weight: 600; overflow-wrap: anywhere; }
.pk-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); font-size: var(--text-sm); color: var(--text-secondary); }
.pk-detail-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* a long branch or path in the meta row or a timeline head wraps instead of widening the page */
:is(.pk-detail-meta, .pk-timeline-head) > * { min-width: 0; overflow-wrap: anywhere; }
.pk-detail-main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.pk-detail-aside { position: sticky; top: 0; display: flex; flex-direction: column; font-size: var(--text-sm); padding-left: var(--space-4); border-left: 1px solid var(--border-subtle); }
.pk-detail-aside > section { padding: var(--space-3) 0; }
.pk-detail-aside > section:first-child { padding-top: 0; }
.pk-detail-aside > section + section { border-top: 1px solid var(--border-subtle); }
.pk-detail-aside h3 { margin: 0 0 var(--space-1); font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); }
@media (max-width: 760px) {
  .pk-detail-layout { grid-template-columns: minmax(0, 1fr); }
  .pk-detail-aside { position: static; padding: var(--space-3) 0 0; border-left: 0; border-top: 1px solid var(--border-subtle); }
}


/* ------------------------------------------------------------ guide viewer */
/* <pk-guide> (static/kit/guide.js): an AmigaGuide page. The guide's pens map onto the tokens. */
pk-guide { display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; }
pk-guide[address] { flex: 1 1 0; }  /* the page's own viewer fills the page and scrolls itself */
.pk-guide-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.pk-guide-search { margin-left: auto; }
/* This box scrolls both ways, not the page inside it: a sideways scrollbar at the page's end would sit far below
   the view (see .pk-panel above) */
.pk-guide-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.pk-guide-page {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  line-height: 1.5;
  tab-size: 8;
  outline: none;
}
.pk-guide-line { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1lh; margin: 0; }
.pk-guide-pre { white-space: pre; overflow-wrap: normal; }
.pk-guide-center { text-align: center; }
.pk-guide-right { text-align: right; }
.pk-guide-problems { margin-top: var(--space-3); }

.pk-guide-b { font-weight: 700; }
.pk-guide-i { font-style: italic; }
.pk-guide-u { text-decoration: underline; }
.pk-guide-fg-shine { color: var(--brand); }
.pk-guide-fg-highlight { color: var(--accent-text); }
.pk-guide-fg-shadow { color: var(--text-muted); }
.pk-guide-fg-fill { color: var(--accent); }
.pk-guide-fg-filltext { color: var(--text-on-accent); }
.pk-guide-fg-background { color: var(--surface-0); }
.pk-guide-bg-text { background: var(--text-primary); color: var(--surface-0); }
.pk-guide-bg-shine { background: var(--surface-3); }
.pk-guide-bg-shadow { background: var(--border-strong); }
.pk-guide-bg-fill { background: var(--accent); color: var(--text-on-accent); }
.pk-guide-bg-filltext { background: var(--text-primary); color: var(--surface-0); }
.pk-guide-bg-highlight { background: var(--accent-subtle); }

/* A link is a button, as on the Workbench. The frame is a shadow, not a border: a border would widen the label
   and push every column after it out of line. */
.pk-guide-button {
  color: var(--text-primary);
  text-decoration: none;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  border-radius: var(--radius-sm);
}
a.pk-guide-button:hover { background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--accent); }
a.pk-guide-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.pk-guide-web .pk-icon { margin-left: 2px; vertical-align: -2px; }
.pk-guide-broken { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); text-decoration: line-through; cursor: not-allowed; }
.pk-guide-inert { color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border-default); cursor: not-allowed; }
.pk-guide-image { max-width: 100%; height: auto; vertical-align: middle; }

.pk-guide-hit { padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.pk-guide-snippet { margin-top: var(--space-1); font-family: var(--font-ui); font-size: var(--text-sm); color: var(--text-secondary); }

/* A Markdown file in the viewer (a README, a docs/*.md page, an @embed-ed .md): prose, rendered and sanitised by the server */
.pk-guide-md { font-family: var(--font-ui); white-space: normal; max-width: 90ch; }
.pk-guide-md :is(h1, h2, h3, h4, h5, h6) { margin: var(--space-4) 0 var(--space-2); line-height: 1.3; }
.pk-guide-md h1 { font-size: var(--text-xl); }
.pk-guide-md h2 { font-size: var(--text-lg); }
.pk-guide-md :is(h3, h4, h5, h6) { font-size: var(--text-md); }
.pk-guide-md :is(ul, ol) { margin: 0 0 var(--space-3); padding-left: var(--space-6); }
.pk-guide-md li { margin: var(--space-1) 0; }
.pk-guide-md a { color: var(--accent-text); }
.pk-guide-md a:not([href]) { color: inherit; }
.pk-guide-md code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-3); padding: 0 3px; border-radius: var(--radius-sm); }
.pk-guide-md pre { font-family: var(--font-mono); font-size: var(--text-sm); background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-3); overflow-x: auto; margin: 0 0 var(--space-3); }
.pk-guide-md pre code { background: none; padding: 0; font-size: inherit; }
.pk-guide-md blockquote { margin: 0 0 var(--space-3); padding: var(--space-1) var(--space-3); border-left: 3px solid var(--border-strong); color: var(--text-secondary); }
.pk-guide-md table { border-collapse: collapse; margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.pk-guide-md :is(th, td) { border: 1px solid var(--border-default); padding: var(--space-1) var(--space-2); text-align: left; vertical-align: top; }
.pk-guide-md th { background: var(--surface-1); }
.pk-guide-md hr { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-4) 0; }

/* The AmigaGuide extensions: headings, list items, quotes, rules, code blocks, tables, inline code, struck text */
/* blank lines in the guide give the spacing, as on the Amiga: the blocks add little of their own */
.pk-guide-h1 { font-size: var(--text-xl); font-weight: 700; margin: var(--space-1) 0 0; }
.pk-guide-h2 { font-size: var(--text-lg); font-weight: 700; margin: var(--space-1) 0 0; }
.pk-guide-h3 { font-weight: 700; }
.pk-guide-level-1 { --pk-guide-indent: 3ch; }
.pk-guide-level-2 { --pk-guide-indent: 6ch; }
.pk-guide-level-3 { --pk-guide-indent: 9ch; }
:is(.pk-guide-bullet, .pk-guide-number) { position: relative; padding-left: var(--pk-guide-indent); }
.pk-guide-marker { position: absolute; left: calc(var(--pk-guide-indent) - 3ch); width: 2.5ch; text-align: right; color: var(--text-muted); }
.pk-guide-quote { margin: var(--space-1) 0; padding-left: var(--space-3); border-left: 3px solid var(--border-strong); color: var(--text-secondary); }
.pk-guide-rule { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-3) 0; }
.pk-guide-codeblock { margin: var(--space-1) 0; padding: var(--space-3); overflow-x: auto; font-size: var(--text-sm); line-height: 1.5;
  background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.pk-guide-table-wrap { overflow-x: auto; margin: var(--space-1) 0; }
.pk-guide-table { border-collapse: collapse; font-size: var(--text-sm); }
.pk-guide-table :is(th, td) { padding: var(--space-1) var(--space-2); border: 1px solid var(--border-default); text-align: left; vertical-align: top; white-space: normal; }
.pk-guide-table th { background: var(--surface-1); }
.pk-guide-tt { background: var(--surface-3); border-radius: var(--radius-sm); }
/* Syntax colours of a code block (Prism tokens), the chat's palette (static/css/chat.css) */
pk-guide .token:is(.comment, .prolog, .doctype, .cdata) { color: var(--text-muted); font-style: italic; }
pk-guide .token:is(.punctuation, .operator) { color: var(--text-secondary); }
pk-guide .token:is(.keyword, .atrule, .important, .selector) { color: var(--accent-text); }
pk-guide .token:is(.string, .char, .attr-value, .inserted) { color: var(--ok); }
pk-guide .token:is(.number, .boolean, .constant, .symbol) { color: var(--warn); }
pk-guide .token:is(.function, .class-name, .builtin) { color: var(--info); }
pk-guide .token:is(.property, .tag, .attr-name, .variable) { color: var(--text-primary); }
pk-guide .token:is(.deleted, .regex) { color: var(--danger); }
.pk-guide-s { text-decoration: line-through; }
.pk-guide-u.pk-guide-s { text-decoration: underline line-through; }
