:root {
  color-scheme: light dark;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-sunken: #f4f4f5;
  --text: #18181b;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #18181b;
  --accent-soft: #ececef;
  --selected: #e4e4e7;
  --tone-info: #1971c2;
  --tone-info-soft: #e3f0fc;
  --tone-warning: #c25e00;
  --tone-warning-soft: #fff0e0;
  --tone-completed: #2b8a3e;
  --tone-completed-soft: #e5f6e9;
  --tone-error: #c92a2a;
  --tone-error-soft: #fdeaea;
  --tone-muted: #71717a;
  --tone-muted-soft: #f4f4f5;
  --tone-neutral: #3f3f46;
  --tone-neutral-soft: #f4f4f5;
  --space-black: #343a40;
  --space-red: #e03131;
  --space-green: #2f9e44;
  --space-yellow: #f08c00;
  --space-blue: #1c7ed6;
  --space-magenta: #c2255c;
  --space-cyan: #1098ad;
  --space-white: #ced4da;
  --space-orange: #ffa726;
  --space-brown: #a5693c;
  --space-none: #adb5bd;
  /* Extra tag hues for values Nia does not know in advance, such as catalog categories and handlers. */
  --hue-violet: #7950f2;
  --hue-lime: #74b816;
  --hue-grape: #ae3ec9;
  --hue-teal: #0ca678;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-hover: 0 4px 12px rgb(16 24 40 / 12%);
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, monospace;
  --topbar-height: 52px;
  --rail-width: 248px;
  --rail-collapsed-width: 52px;
  /* Left inset of rail rows, which centers their 8px dots under the rail toggle and the collapsed rail's dots. */
  --rail-dot-inset: calc((var(--rail-collapsed-width) - 1px) / 2 - 4px);
  --tabs-height: 46px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --surface: #17171a;
    --surface-sunken: #121214;
    --text: #ececee;
    --text-muted: #a1a1aa;
    --border: #27272a;
    --border-strong: #3f3f46;
    --accent: #f4f4f5;
    --accent-soft: #1f1f23;
    --selected: #2a2a2f;
    --tone-info: #74b9f5;
    --tone-info-soft: #13283d;
    --tone-warning: #ffa726;
    --tone-warning-soft: #3a2710;
    --tone-completed: #7fd492;
    --tone-completed-soft: #15301d;
    --tone-error: #ff8a80;
    --tone-error-soft: #3a1818;
    --tone-muted: #8b8b94;
    --tone-muted-soft: #1f1f23;
    --tone-neutral: #d4d4d8;
    --tone-neutral-soft: #1f1f23;
    --space-black: #868e96;
    --space-white: #e9ecef;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-hover: 0 6px 16px rgb(0 0 0 / 50%);
  }
}

* {
  box-sizing: border-box;
}

/* The layout always spans the full window width, so a scrollbar that appears on long pages covers the right margin
   instead of shifting the content, and short pages show neither a scrollbar nor a reserved gutter. */
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  width: 100vw;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The right padding matches the content's, so the search ends where the content does. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--gap-4);
  height: var(--topbar-height);
  padding: 0 var(--gap-6) 0 var(--gap-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  flex: none;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--surface);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand:hover,
.brand:focus-visible {
  text-decoration: none;
}

.crumbs {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: var(--gap-2);
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.crumbs a {
  color: var(--text-muted);
}

.crumbs a:hover {
  color: var(--text);
}

.crumbs span[aria-current] {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
}

.separator {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

/* Search of the current scope, folded into its magnifier at the right end of the top bar like the rail toggle. Focus
   unfolds it leftwards into the field; an active query tints the magnifier. */
.topbar .search {
  flex: none;
  width: 30px;
  margin-left: auto;
  transition: width 0.15s ease;
}

.topbar .search input {
  height: 30px;
  padding: 0 0 0 30px;
  border-color: transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 0.88rem;
  cursor: pointer;
}

.topbar .search input::placeholder {
  color: transparent;
}

.topbar .search input::-webkit-search-cancel-button {
  display: none;
}

.topbar .search-icon {
  left: 7px;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.topbar .search:hover input {
  background: var(--accent-soft);
}

.topbar .search:hover .search-icon {
  stroke: var(--text);
}

.topbar .search:focus-within {
  width: min(320px, 100%);
}

.topbar .search:focus-within input {
  padding: 0 12px 0 30px;
  border-color: var(--border-strong);
  background: var(--surface);
  cursor: text;
}

.topbar .search:focus-within input::placeholder {
  color: var(--text-muted);
}

.topbar .search:has(input:not(:placeholder-shown)) .search-icon {
  stroke: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .topbar .search {
    transition: none;
  }
}

/* Application shell: Space rail, section tabs and content */

.shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-height));
}

/* The short top padding centers the rail's first row, General, on the section bar's labels and starts the first project
   heading at the bar's bottom border. */
.rail {
  position: sticky;
  top: var(--topbar-height);
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: start;
  height: calc(100vh - var(--topbar-height));
  padding: var(--gap-1) 0 var(--gap-3);
  overflow-y: auto;
  scrollbar-width: thin;
  border-right: 1px solid var(--border);
  background: var(--surface-sunken);
}

.rail-projects,
.rail-project {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-project {
  position: relative;
}

.rail-project.dragging {
  opacity: 0.45;
}

/* While a project is dragged, a white line led by a ring marks the gap where it will drop, before or after a
   project. */
.rail-project.drop-before::before,
.rail-project.drop-after::after {
  position: absolute;
  right: var(--gap-3);
  left: calc(var(--rail-dot-inset) - 1px);
  z-index: 2;
  height: 10px;
  background:
    radial-gradient(circle at 5px 50%, transparent 2.5px, var(--text) 3px 4px, transparent 4.5px) no-repeat,
    linear-gradient(var(--text), var(--text)) right center / calc(100% - 9px) 2px no-repeat;
  content: "";
  pointer-events: none;
}

.rail-project.drop-before::before {
  top: -6px;
}

.rail-project.drop-after::after {
  bottom: -6px;
}

/* General, the home, is the rail's first heading, at the top of the rail without the margin that separates projects. */
.rail-group.rail-general {
  margin-top: 0;
}

/* A heading's signals, General's over the machine and a project's over its Spaces, sit where the Space rows' signals
   do; a project heading's actions take their place while it is hovered or focused. */
.rail-group .rail-signals {
  position: absolute;
  top: 50%;
  right: var(--gap-4);
  transform: translateY(calc(-50% + 0.06em));
  pointer-events: none;
}

.rail-project .rail-group:is(:hover, :focus-within) .rail-signals {
  opacity: 0;
}

/* A folded project hides its Spaces, all but the current one, while the rail is expanded. */
.shell:not(.rail-collapsed) .rail-project.folded > .rail-link:not([aria-current]) {
  display: none;
}

/* A project heading is as tall as a Space row, so its hover and selection match theirs. */
.rail-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  min-height: 32px;
  margin-top: var(--gap-2);
  padding: 2px var(--gap-4) 2px var(--rail-dot-inset);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  user-select: none;
}

.rail-group:hover {
  background: var(--accent-soft);
}

/* The project name leads to the work of all its Spaces; its overlay makes the whole heading that link. */
.rail-group-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.rail-group-name::after {
  position: absolute;
  inset: 0;
  content: "";
}

.rail-group:hover .rail-group-name,
.rail-group-name[aria-current] {
  color: var(--text);
  text-decoration: none;
}

/* The selected project is marked like a selected Space. */
.shell:not(.rail-collapsed) .rail-group:has(.rail-group-name[aria-current]) {
  background: var(--selected);
  box-shadow: inset 2px 0 0 var(--accent);
  color: var(--text);
}

/* The grip is the only drag handle and takes Alt with the arrow keys; it sits above the heading link. It is as wide
   as the signals' column, so its dots center on the same vertical line as the markers and bells it replaces. */
.rail-grip {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 20px;
  border-radius: var(--radius-sm);
  cursor: grab;
}

.rail-grip:active {
  cursor: grabbing;
}

.grip {
  width: 8px;
  height: 14px;
  fill: currentcolor;
  opacity: 0;
  transition: opacity 120ms ease;
}

.rail-group:hover .grip,
.rail-group:focus-within .grip {
  opacity: 1;
}

/* Fold button, the first of the heading's three actions at its right end; like the others, it shows only while the
   heading is hovered or focused, its chevron pointing right while the project is folded. */
.rail-fold {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 120ms ease;
}

.rail-fold:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.rail-group:hover .rail-fold,
.rail-group:focus-within .rail-fold {
  opacity: 1;
}

.fold-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  transition: transform 120ms ease;
}

.rail-project.folded .fold-icon {
  transform: rotate(-90deg);
}

/* New Space link of a project group; it shows with the grip. */
.rail-add {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: auto;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 120ms ease;
}

.rail-add .icon {
  width: 14px;
  height: 14px;
}

.rail-add:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.rail-group:hover .rail-add,
.rail-group:focus-within .rail-add {
  opacity: 1;
}

@media (hover: none) {
  .rail-add,
  .rail-fold {
    opacity: 1;
  }
}

/* The toggle sits centered over the collapsed rail's dots, left of its 1px border, so it lines up in both states. */
.rail-toggle {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: calc((var(--rail-collapsed-width) - 1px) / 2 - 15px - var(--gap-4));
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

/* Only the script makes the toggle work, so it shows only with scripting. A media query paints it with the page; a
   `hidden` attribute that the script removed would leave it out of the first paint of every navigation. */
@media (scripting: none) {
  .rail-toggle {
    display: none;
  }
}

.rail-toggle:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.rail-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.5;
}

/* Positioned, so the visually hidden signal text stays inside the rail, which scrolls, instead of widening the page. */
.rail-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  min-height: 32px;
  padding: 4px var(--gap-4) 4px var(--rail-dot-inset);
  color: var(--text);
  font-size: 0.9rem;
}

.rail-link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.rail-link[aria-current] {
  background: var(--selected);
  box-shadow: inset 2px 0 0 var(--accent);
  font-weight: 600;
}

.signal-error {
  --signal: var(--tone-error);
}

.signal-warning {
  --signal: var(--tone-warning);
}

.signal-info {
  --signal: var(--tone-info);
}

.signal-completed {
  --signal: var(--tone-completed);
}

.signal-muted {
  --signal: var(--tone-muted);
}

.signal-neutral {
  --signal: var(--tone-neutral);
}

@media (min-width: 761px) {
  .shell.rail-collapsed {
    grid-template-columns: var(--rail-collapsed-width) minmax(0, 1fr);
  }

  .rail-collapsed .rail .marker,
  .rail-collapsed .rail-group-name,
  .rail-collapsed .rail-add,
  .rail-collapsed .rail-fold,
  .rail-collapsed .rail-grip {
    display: none;
  }

  /* The name stays available to assistive technology; pointer users get the rail tooltip. */
  .rail-collapsed .rail-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .rail-collapsed .rail-group {
    height: 1px;
    min-height: 0;
    margin: var(--gap-3) var(--gap-3) var(--gap-2);
    padding: 0;
    background: var(--border);
    pointer-events: none;
  }

  .rail-collapsed .rail-link {
    justify-content: center;
    padding: 4px 0;
  }

  .rail-collapsed .dot {
    width: 10px;
    height: 10px;
    transform: none;
  }

  .rail-collapsed .rail-link.has-signals:not(.has-decisions)::after {
    position: absolute;
    top: 7px;
    left: calc(50% + 3px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tone-muted);
    box-shadow: 0 0 0 2px var(--surface-sunken);
    content: "";
  }

  /* With decisions waiting, the bell takes the marker's corner. */
  .rail-collapsed .rail-signals {
    position: absolute;
    top: 3px;
    left: calc(50% + 2px);
  }

  /* Collapsed headings are separators; their Spaces' dots carry the signals. */
  .rail-collapsed .rail-group .rail-signals {
    display: none;
  }

  .rail-collapsed .rail .bell {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--surface-sunken);
  }
}

.rail-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--space-color, var(--space-none));
}

/* Dots and rail signals sit beside mostly lowercase labels, whose visual center is the x-height center, about 0.06em
   below the line box center that flex alignment uses; the nudge scales with the font. */
.dot,
.rail-signals,
.space-ref::before {
  transform: translateY(0.06em);
}

/* Breadcrumbs mix the Space dot with chevrons and capitalized record labels, so the dot centers on the line like the
   chevrons, between the x-height and cap-height centers. */
.crumbs .space-ref::before {
  transform: none;
}

/* Status labels start with a capital, so their dot centers between the x-height and cap-height centers. Measured
   offsets from the line box center differ by control because the font metrics round per size. */
.status-option .status-dot {
  transform: translateY(0.035em);
}

/* Rail signals: one indicator per row, a bell while decisions wait on the operator, otherwise one small neutral dot
   for any active work; the tooltip carries the counts. */
/* The bell and the marker share one column width, so both center on the same vertical line. */
.rail-signals {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 13px;
}

.bell {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--tone-info);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.marker {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Rail tooltip, placed by web.js beside the hovered or focused entry of the collapsed rail. */
.rail-tip {
  position: fixed;
  z-index: 50;
  max-width: 18rem;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-hover);
  color: var(--text);
  font-size: 0.82rem;
  pointer-events: none;
}

.rail-tip[hidden] {
  display: none;
}

.content {
  min-width: 0;
}

.tabs {
  position: sticky;
  top: var(--topbar-height);
  z-index: 1;
  display: flex;
  gap: var(--gap-1);
  height: var(--tabs-height);
  /* The right padding matches the content's, so page actions end where the content does. */
  padding: 0 var(--gap-6) 0 var(--gap-5);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab-list {
  display: flex;
  flex: none;
  gap: var(--gap-1);
}

/* Page loads within the panel animate only the section bar's tabs; the rest of the page swaps at once. Each tab keeps
   one transition name across pages, named by its link's last segment and Work by being first. A group's tab, such as
   Settings, shares its name with the group's first section, which links where the tab does, so the tab turns into the
   group's sections, the others sliding out of it, and back, while the tabs after them slide along. */
@view-transition {
  navigation: auto;
}

:root {
  view-transition-name: none;
}

.tab-list > .tab:first-child {
  view-transition-name: tab-work;
}

.tab[href$="/status"] {
  view-transition-name: tab-status;
}

.tab[href$="/guards"] {
  view-transition-name: tab-guards;
}

.tab[href$="/testing"] {
  view-transition-name: tab-testing;
}

.tab[href$="/instructions"] {
  view-transition-name: tab-instructions;
}

.tab[href$="/skills"] {
  view-transition-name: tab-skills;
}

.tab[href$="/docs"] {
  view-transition-name: tab-docs;
}

.tab[href$="/settings"] {
  view-transition-name: tab-settings;
}

::view-transition-group(*) {
  animation-duration: 220ms;
  animation-timing-function: ease;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

.tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--gap-2);
  padding: 0 var(--gap-3);
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab[aria-current] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

main {
  min-width: 0;
  padding: var(--gap-5) var(--gap-6) var(--gap-6);
  container: content / inline-size;
}

main.solo {
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 760px) {
  .shell {
    display: block;
  }

  /* With scripting the rail is a drawer over the content, opened from the top bar's toggle and closed on every page;
     without it the rail stays above the content. */
  .rail {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  @media (scripting: enabled) {
    .rail {
      position: fixed;
      top: var(--topbar-height);
      bottom: 0;
      left: 0;
      z-index: 30;
      /* The wide rail aligns to the start, which would size the fixed drawer to its links instead of the window. */
      align-self: stretch;
      width: min(var(--rail-width), 85vw);
      overscroll-behavior: contain;
      border-right: 1px solid var(--border);
      border-bottom: none;
      box-shadow: var(--shadow-hover);
      transform: translateX(-100%);
      visibility: hidden;
      transition: transform 0.2s ease, visibility 0.2s;
    }

    .rail-open .rail {
      transform: none;
      visibility: visible;
    }

    /* Dims the content behind the open drawer; a click there closes it. */
    .shell.rail-open::before {
      position: fixed;
      inset: var(--topbar-height) 0 0;
      z-index: 29;
      background: rgb(0 0 0 / 45%);
      content: "";
    }
  }

  @media (scripting: enabled) and (prefers-reduced-motion: reduce) {
    .rail {
      transition: none;
    }
  }

  .tabs {
    padding: 0 var(--gap-4) 0 var(--gap-2);
  }

  .topbar {
    padding-right: var(--gap-4);
  }

  main {
    padding: var(--gap-5) var(--gap-4) var(--gap-6);
  }

  /* The unfolded search covers the breadcrumbs. */
  .topbar .search:focus-within {
    position: absolute;
    right: var(--gap-4);
    left: var(--gap-4);
    z-index: 1;
    width: auto;
  }
}

/* Summary filters */

.filters {
  display: grid;
  gap: var(--gap-3);
  margin-bottom: var(--gap-5);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-4);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
}

.check {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  padding: 6px var(--gap-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.chip-filter:hover {
  border-color: var(--text-muted);
  text-decoration: none;
}

/* Count badge of filter chips and section headings. */
.count-badge {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tone-neutral-soft);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

.chip-filter[aria-current] {
  border-color: var(--signal, var(--accent));
  box-shadow: 0 0 0 1px var(--signal, var(--accent));
}

.chip-filter[aria-current] .check,
.chip-filter[aria-current] .count-badge {
  color: var(--signal, var(--accent));
}

.chip-filter[aria-current] .count-badge {
  background: color-mix(in srgb, var(--signal, var(--accent)) 20%, transparent);
}

/* The active search among the filters it narrows; a long query ends in an ellipsis before its cross. */
.search-chip span {
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-link {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.clear-link:hover {
  color: var(--text);
}

.search {
  position: relative;
}

.search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.search input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-muted);
  stroke-linecap: round;
  stroke-width: 2;
  transform: translateY(-50%);
}

.records-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  margin: var(--gap-5) 0 var(--gap-2);
}

.records-head h2 {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  margin: 0;
  font-size: 1.05rem;
}

.records-head .icon-btn {
  margin-left: auto;
}

/* Pending decisions wait on the operator, so their list stands out: a bell before the heading and the pending tone
   around the table and on its header. */
.records-waiting .records-head h2 .bell {
  width: 16px;
  height: 16px;
  stroke: var(--tone-info);
}

.records-waiting .work {
  border-color: var(--tone-info);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tone-info) 45%, transparent), var(--shadow);
}

.records-waiting .work th {
  background: var(--tone-info-soft);
  color: var(--tone-info);
}

.records-waiting .work tbody tr {
  background: color-mix(in srgb, var(--tone-info) 5%, transparent);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
}

.icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.filters + .records .records-head {
  margin-top: 0;
}

.list-more {
  margin: var(--gap-2) 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}


.space-black {
  --space-color: var(--space-black);
}

.space-red {
  --space-color: var(--space-red);
}

.space-green {
  --space-color: var(--space-green);
}

.space-yellow {
  --space-color: var(--space-yellow);
}

.space-blue {
  --space-color: var(--space-blue);
}

.space-magenta {
  --space-color: var(--space-magenta);
}

.space-cyan {
  --space-color: var(--space-cyan);
}

.space-white {
  --space-color: var(--space-white);
}

.space-orange {
  --space-color: var(--space-orange);
}

.space-brown {
  --space-color: var(--space-brown);
}

.space-none {
  --space-color: var(--space-none);
}

.space-ref {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  color: var(--text);
  white-space: nowrap;
}

.space-ref::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--space-color, var(--space-none));
  content: "";
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

/* Separate borders round the table without clipping, so status menus can open past its edge. Fixed column widths keep
   every list of a page aligned; the title takes the rest. */
.work {
  table-layout: fixed;
  border: 1px solid var(--border);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
}

.work th:first-child {
  border-top-left-radius: var(--radius);
}

.work th:last-child {
  border-top-right-radius: var(--radius);
}

.work tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}

.work tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}

.work th {
  padding: var(--gap-2) var(--gap-3);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

/* Sortable headers keep one size, weight and color; the active column shows its direction instead. */
.work th .sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
}

.work th .sort:hover {
  color: var(--text);
  text-decoration: none;
}

/* Arrows stay hidden until the header is hovered or focused, except the active column's direction. */
.sort-arrow {
  visibility: hidden;
  width: 0.38em;
  height: 0.38em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.work th:hover .sort-arrow,
.work th .sort:focus-visible .sort-arrow,
.work th .sort-active .sort-arrow {
  visibility: visible;
}

.sort-ascending {
  margin-top: 0.2em;
  transform: rotate(-135deg);
}

.sort-descending {
  margin-bottom: 0.2em;
  transform: rotate(45deg);
}

/* Every cell centers its text, tags, pills and actions on the row's middle. */
.work td {
  padding: var(--gap-3);
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.work tbody tr:hover {
  background: var(--surface-sunken);
}

/* web.js opens the row's primary link from anywhere in the row outside its controls. */
.work tbody tr:has(.row-link) {
  cursor: pointer;
}

.work .number,
.work .date {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.work .col-space {
  width: 10rem;
}

.work .col-number {
  width: 3.75rem;
}

.work .col-priority {
  width: 7.5rem;
}

.work .col-date {
  width: 7rem;
}

.work .col-time {
  width: 4.5rem;
}

.work .col-state {
  width: 9.5rem;
}

/* Catalog lists: the name carries any state that needs attention and its description below it; the status column
   holds the enable switch. */
.work .col-category,
.work .col-handler {
  width: 9.5rem;
}

.work .col-origin {
  width: 6.5rem;
}

.work .col-switch {
  width: 6.5rem;
}

/* Docs lists: the passage that matched a search, under the doc's description. */
.doc-passage {
  margin-top: var(--gap-1);
}

/* Docs lists: a doc's audit states, one pill per kind of finding, wrap inside their column. */
.docs .col-state {
  width: 11.5rem;
}

/* A doc page's details: each audit finding's message with the line it names muted under it. */
.doc-findings {
  display: grid;
  gap: var(--gap-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-findings li {
  overflow-wrap: anywhere;
}

.work .title .pill {
  margin-left: var(--gap-2);
}

.switch-form {
  display: flex;
}

/* A provider's switch is a link to its confirmation, so the switch also sizes as an inline block. */
.switch {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  flex: none;
  width: 36px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-sunken);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.switch::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  content: "";
  transition: transform 0.15s ease;
}

.switch[aria-checked="true"] {
  border-color: var(--tone-completed);
  background: var(--tone-completed);
}

.switch[aria-checked="true"]::after {
  background: var(--surface);
  transform: translateX(16px);
}

.switch:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

@media (prefers-reduced-motion: reduce) {
  .switch,
  .switch::after {
    transition: none;
  }
}

.row-note {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* A list row's description keeps to one line; its tooltip holds the full text. */
.row-description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work .space,
.work .title {
  overflow-wrap: anywhere;
}

.work .state {
  white-space: nowrap;
}

/* Lists turn into stacked cards when the content area, not the viewport, is too narrow for the fixed columns. */
@container content (max-width: 720px) {
  .work thead,
  .work colgroup,
  .work td:empty {
    display: none;
  }

  .work,
  .work tbody,
  .work tr,
  .work td {
    display: block;
    width: 100%;
  }

  .work tr {
    padding: var(--gap-2) 0;
    border-top: 1px solid var(--border);
  }

  .work tr:first-child {
    border-top: none;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .work tr:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .work td {
    display: flex;
    gap: var(--gap-3);
    padding: var(--gap-1) var(--gap-3);
    border-top: none;
  }

  .work td::before {
    flex: 0 0 6.5rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    content: attr(data-label);
  }

  /* A title cell stacks its link, pills and notes, such as a one-line description, beside its label. */
  .work td.title {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    row-gap: 0;
  }

  .work td.title > * {
    grid-column: 2;
    min-width: 0;
  }

  .work td.title > .pill {
    justify-self: start;
    margin: var(--gap-1) 0 0;
  }

  .status-options {
    right: auto;
    left: 0;
  }
}

/* Pills and chips */

.pill {
  display: inline-block;
  padding: 2px var(--gap-2);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill::first-letter {
  text-transform: uppercase;
}

.chip {
  display: inline-block;
  margin: 1px 0;
  padding: 1px var(--gap-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Colored tag of a record's type or priority: square corners keep it apart from the rounded status pill. The text
   mixes the hue with the page text, so it stays legible in both schemes. */
.tag {
  display: inline-block;
  padding: 1px var(--gap-2);
  border: 1px solid color-mix(in srgb, var(--tag) 40%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tag) 14%, transparent);
  color: color-mix(in srgb, var(--tag) 70%, var(--text));
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag-red {
  --tag: var(--space-red);
}

.tag-green {
  --tag: var(--space-green);
}

.tag-blue {
  --tag: var(--space-blue);
}

.tag-cyan {
  --tag: var(--space-cyan);
}

.tag-magenta {
  --tag: var(--space-magenta);
}

.tag-orange {
  --tag: var(--space-orange);
}

.tag-yellow {
  --tag: var(--space-yellow);
}

.tag-brown {
  --tag: var(--space-brown);
}

.tag-violet {
  --tag: var(--hue-violet);
}

.tag-lime {
  --tag: var(--hue-lime);
}

.tag-grape {
  --tag: var(--hue-grape);
}

.tag-teal {
  --tag: var(--hue-teal);
}

.tag-neutral {
  --tag: var(--tone-muted);
}

/* Tags side by side that wrap as one group, such as a doc's tags. */
.tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--gap-1);
}

/* A doc's tags the audit flags: one only this doc carries keeps its color inside an amber outline, and a parent tag
   the doc lacks shows dashed in amber. */
.tag-flagged {
  outline: 1px solid var(--tone-warning);
  outline-offset: 1px;
}

.tag-missing {
  border: 1px dashed var(--tone-warning);
  background: transparent;
  color: var(--tone-warning);
}

/* A tag that stands for Nia itself, such as Nia's own origin, looks like the Nia mark of the top bar. */
.tag-nia {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tone-info {
  color: var(--tone-info);
}

.tone-warning {
  color: var(--tone-warning);
}

.tone-completed {
  color: var(--tone-completed);
}

.tone-error {
  color: var(--tone-error);
}

.tone-muted {
  color: var(--tone-muted);
}

.tone-neutral {
  color: var(--tone-neutral);
}

.pill.tone-info {
  background: var(--tone-info-soft);
}

.pill.tone-warning {
  background: var(--tone-warning-soft);
}

.pill.tone-completed {
  background: var(--tone-completed-soft);
}

.pill.tone-error {
  background: var(--tone-error-soft);
}

.pill.tone-muted {
  background: var(--tone-muted-soft);
}

.pill.tone-neutral {
  background: var(--tone-neutral-soft);
}

/* Detail metadata */

.meta {
  display: grid;
  gap: 0;
  margin: 0 0 var(--gap-5);
  padding: var(--gap-2) var(--gap-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Label and value share their first baseline, so a smaller label lines up with a larger value or a tag. */
.field {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--gap-1) var(--gap-4);
  padding: var(--gap-2) 0;
  border-top: 1px solid var(--border);
}

.field:first-child {
  border-top: none;
}

dt {
  flex: 0 0 11rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

dd {
  flex: 1 1 18rem;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Record pages start with the title; the section bar above already separates it from the top bar. */
.page-head h1 {
  margin-top: 0;
}

/* A record title followed by its status pill, as on Task and Report pages, centered on the title's line. */
.record-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  margin-bottom: var(--gap-2);
}

/* The record's name; the breadcrumbs already name its Space. */
.record-name {
  min-width: 0;
}

/* What a Task or Report is about, under its title: the Task's own title or the Report's summary. */
.record-subtitle {
  margin: 0 0 var(--gap-5);
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

/* A details card folded to its first field, such as a Report's priority; the rest unfolds below it. */
.meta-fold > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--gap-1) var(--gap-4);
  padding: var(--gap-2) 0;
  list-style: none;
  cursor: pointer;
}

.meta-fold > summary::-webkit-details-marker {
  display: none;
}

/* The chevron centers on the row; its two strokes draw only half of the rotated square, so it shifts by a quarter of
   that square's diagonal to center what is drawn. */
.meta-fold > summary::after {
  align-self: center;
  width: 0.45em;
  height: 0.45em;
  margin: 0 var(--gap-1) 0 auto;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  content: "";
  transform: translateY(-0.18em) rotate(45deg);
}

.meta-fold[open] > summary::after {
  transform: translateY(0.18em) rotate(-135deg);
}

.meta-fold .field-label {
  flex: 0 0 11rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.meta-fold > dl {
  margin: 0;
}

.meta-fold > dl > .field:first-child {
  border-top: 1px solid var(--border);
}

.prose {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.choices {
  display: grid;
  gap: var(--gap-2);
  padding-left: var(--gap-5);
}

.choices li {
  padding: var(--gap-2) var(--gap-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

/* Actions */

/* Page actions in the section bar are shorter so the bar keeps room around them. */
.tabs .btn {
  padding-top: 3px;
  padding-bottom: 3px;
}

/* Page actions at the end of the section bar, after the tabs. */
.bar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--gap-2);
  margin-left: auto;
}

.action-form {
  display: inline-flex;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  padding: 6px var(--gap-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--text-muted);
  background: var(--accent-soft);
  text-decoration: none;
}

/* Icon-only button, named by its tooltip and accessible label. The icon box takes one text line, so the button keeps
   the height of the text buttons beside it. */
.btn-icon {
  justify-content: center;
  padding-right: 6px;
  padding-left: 6px;
}

.btn-icon .icon {
  width: 16px;
  height: 1lh;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
  font-weight: 600;
}

.btn-primary:hover {
  border-color: var(--accent);
  background: var(--accent);
  opacity: 0.9;
}

/* Row status menu: the status pill opens the other statuses. */
.status-menu {
  position: relative;
  display: inline-block;
}

/* In a record's title the menu takes no line box of the title's size, so its pill stays centered on the title. */
.record-title .status-menu {
  display: flex;
}

.status-menu > summary {
  list-style: none;
  cursor: pointer;
}

.status-menu > summary::-webkit-details-marker {
  display: none;
}

.status-menu > summary::after {
  display: inline-block;
  width: 0.36em;
  height: 0.36em;
  margin: 0 0 0.22em 0.45em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  opacity: 0.7;
  transform: rotate(45deg);
}

.status-menu > summary:hover,
.status-menu[open] > summary {
  box-shadow: inset 0 0 0 1px currentColor;
}

.status-menu > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + var(--gap-1));
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 10rem;
  padding: var(--gap-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-hover);
}

.status-options .action-form {
  display: flex;
}

.status-option {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  width: 100%;
  padding: 6px var(--gap-2);
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.status-option:hover,
.status-option:focus-visible {
  background: var(--surface-sunken);
  text-decoration: none;
}

.status-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Alert: a condition that needs attention, with the action that resolves it at the end when one applies. */
.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-3);
  margin: 0 0 var(--gap-5);
  padding: var(--gap-3) var(--gap-4);
  border: 1px solid var(--tone-warning);
  border-radius: var(--radius);
  background: var(--tone-warning-soft);
}

.alert p {
  flex: 1 1 18rem;
  margin: 0;
}

.alert .action-form {
  margin-left: auto;
}

.actions-unavailable {
  margin: 0 0 var(--gap-5);
  padding: var(--gap-3) var(--gap-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-3);
  margin: 0 0 var(--gap-3);
  padding: var(--gap-3) var(--gap-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.confirm .confirm-warning {
  flex-basis: 100%;
  color: var(--tone-warning);
}

.confirm p {
  flex: 1 1 18rem;
  margin: 0;
}

.notice-ok {
  margin: 0 0 var(--gap-4);
  padding: var(--gap-3) var(--gap-4);
  border: 1px solid var(--tone-completed);
  border-radius: var(--radius);
  background: var(--tone-completed-soft);
}

/* An action or run outcome the operator can close: its message, then the close button at its end. */
.notice-closable {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-3);
}

.notice-closable > p {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.notice-close {
  flex: none;
  margin: -5px -8px -5px 0;
  color: inherit;
}

.answer-choices {
  list-style: none;
  padding-left: 0;
}

.answer-choices li {
  padding: 0;
  border: none;
  background: none;
}

.btn-choice {
  width: 100%;
  justify-content: flex-start;
  padding: var(--gap-2) var(--gap-3);
  text-align: left;
}

.answer-form {
  display: grid;
  gap: var(--gap-2);
  margin: var(--gap-4) 0 var(--gap-5);
}

.answer-form label {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.answer-form textarea {
  width: 100%;
  padding: var(--gap-2) var(--gap-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.answer-form .btn {
  justify-self: end;
}

.modal-body .answer-form {
  margin: 0;
}

/* Explanatory paragraphs of a confirmation dialog, above its actions. */
.dialog-text {
  margin: 0 0 var(--gap-3);
}

/* Destructive actions share the error tone: an outlined trigger, a red trash icon, a red confirmation with its warnings
   and a filled final button. Archiving and status changes keep their data and stay neutral. */
.btn-danger {
  border-color: var(--tone-error);
  color: var(--tone-error);
}

.btn-danger:hover {
  border-color: var(--tone-error);
  background: var(--tone-error-soft);
}

.btn-danger-primary {
  border-color: var(--tone-error);
  background: var(--tone-error);
  color: var(--surface);
  font-weight: 600;
}

.btn-danger-primary:hover {
  border-color: var(--tone-error);
  background: var(--tone-error);
  opacity: 0.9;
}

.icon-btn.icon-btn-danger {
  color: var(--tone-error);
}

.icon-btn.icon-btn-danger:hover {
  background: var(--tone-error-soft);
  color: var(--tone-error);
}

.confirm.danger,
.dialog-text.danger {
  border: 1px solid var(--tone-error);
  border-radius: var(--radius);
  background: var(--tone-error-soft);
}

.dialog-text.danger {
  padding: var(--gap-3) var(--gap-4);
}

.confirm.danger .confirm-warning {
  color: var(--tone-error);
  font-weight: 600;
}

/* Space color picker */

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
}

.swatch {
  display: inline-block;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  appearance: none;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--space-color, var(--space-none));
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
}

button.swatch:hover,
input.swatch:hover {
  box-shadow: 0 0 0 1px var(--text-muted);
}

.swatch[aria-pressed="true"],
.swatch:checked {
  box-shadow: 0 0 0 2px var(--accent);
}

/* No color: an empty ring with a diagonal stroke. */
.swatch.space-none {
  border: 1.5px solid var(--text-muted);
  background: linear-gradient(
    135deg,
    transparent calc(50% - 1px),
    var(--text-muted) calc(50% - 1px),
    var(--text-muted) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
}

.color-value {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
}

.color-value .swatch {
  width: 14px;
  height: 14px;
  border-width: 0;
  cursor: default;
}

/* Space forms: the Details card and the new Space card share one control style, so every control in a card has the
   same width and height. */

.field-edit {
  align-items: center;
}

.control {
  box-sizing: border-box;
  width: 100%;
  max-width: 26rem;
  height: 34px;
  margin: 0;
  padding: 0 var(--gap-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.control:hover {
  border-color: var(--text-muted);
}

.select {
  position: relative;
  display: block;
  max-width: 26rem;
}

select.control {
  padding-right: 34px;
  appearance: none;
  cursor: pointer;
}

.select .chevron {
  position: absolute;
  top: 50%;
  right: 11px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.inline-edit {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
}

.inline-edit .control {
  flex: 0 1 26rem;
  min-width: 0;
}

.inline-edit .btn,
.delete-form .btn {
  height: 34px;
}

.space-form .meta {
  margin-bottom: var(--gap-3);
}

/* Form and section actions sit at the right end of their content, in dialogs and pages alike. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--gap-2);
  margin: 0 0 var(--gap-5);
}

/* Reusable dialog: modal with a script, or open in place on the page that renders it without one. */
dialog.modal {
  width: min(40rem, calc(100vw - 2 * var(--gap-4)));
  max-height: calc(100vh - 4rem);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog.modal:not(:modal) {
  position: fixed;
  top: 2rem;
  z-index: 10;
}

/* A dialog holding a whole document is wider, and only its body scrolls, so its header and close control stay in
   view. */
dialog.modal-document {
  width: min(64rem, calc(100vw - 2 * var(--gap-4)));
}

dialog.modal-document[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

dialog.modal-document .modal-head h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2);
}

dialog.modal-document .modal-body {
  min-height: 0;
  overflow: auto;
}

dialog.modal::backdrop {
  background: rgb(0 0 0 / 45%);
}

.modal-head {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: var(--gap-3) var(--gap-3) var(--gap-3) var(--gap-4);
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-head .icon-btn {
  margin-left: auto;
}

.modal-body {
  padding: var(--gap-4);
}

.modal-body .meta,
.modal-body .form-actions {
  margin-bottom: 0;
}

/* With the script, a dialog's field shows one line; a value that does not fit ends in an ellipsis and its row, with a
   chevron at its end, unfolds to show all of it. */
.modal .meta {
  grid-template-columns: minmax(0, 1fr);
}

.modal .field-clamp:not(.field-expanded) > dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal .field-foldable {
  cursor: pointer;
}

.field-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  align-self: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.field-toggle:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.field-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  transition: transform 120ms ease;
}

.field-expanded .field-toggle svg {
  transform: rotate(180deg);
}

/* A dialog's list of where something is: each row is a whole link, highlighted under the pointer, with its label and
   an optional one-line detail, what it counts at its end and a chevron. */
.link-list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  list-style: none;
}

.link-list li + li {
  border-top: 1px solid var(--border);
}

.link-row {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: var(--gap-2) var(--gap-3) var(--gap-2) var(--gap-4);
  color: var(--text);
}

.link-row:hover,
.link-row:focus-visible {
  background: var(--accent-soft);
  text-decoration: none;
}

.link-row:focus-visible {
  outline-offset: -2px;
}

.link-row-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.link-row-label {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row-number {
  margin-right: var(--gap-2);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.link-row-detail {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row-aside {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--gap-2);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.link-row-chevron {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.modal-body h3.section-title a {
  color: var(--text);
}

/* Actions below a dialog's card keep the dialog's padding from it. */
.modal-body .meta + .form-actions {
  margin-top: var(--gap-4);
}

/* Persistent Environment of a numbered Space */

.environment h2 {
  margin: var(--gap-5) 0 var(--gap-2);
  font-size: 1.05rem;
}

.environment .meta {
  margin-bottom: var(--gap-3);
}

.environment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--gap-2);
}

.environment-actions .btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.running {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
}

.spinner {
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* A pending action (web.js): its icon, or the start of its label, turns into a spinner in the control's own color, and
   the control ignores further clicks until the next page arrives. */
.is-busy {
  cursor: progress;
}

.is-busy > svg,
.status-option.is-busy .status-dot {
  display: none;
}

.btn.is-busy::before,
.icon-btn.is-busy::before,
.status-option.is-busy::before {
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .btn.is-busy::before,
  .icon-btn.is-busy::before,
  .status-option.is-busy::before {
    animation: none;
  }
}

.blocked-url {
  color: var(--tone-warning);
}

/* Mutually exclusive choices of one setting, such as the interface language; the active one is the primary button. */
.choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
}

/* Settings pages center each label on its control and note. */
.settings .field {
  align-items: center;
}

/* A setting with a switch toggles it from anywhere on its row, through the script, and names an active one plainly. */
@media (scripting: enabled) {
  .setting-row {
    cursor: pointer;
  }
}

.setting-row:has(.switch[aria-checked="true"]) dt {
  color: var(--text);
  font-weight: 600;
}

/* A row a disabled feature blocks keeps its own state on a switch it cannot change, and reads as inactive. */
.setting-row.blocked {
  cursor: default;
}

.setting-row.blocked dt {
  color: var(--text-muted);
  font-weight: 400;
}

/* A section title that carries its feature's switch puts it in the column of the rows' switches: the card's border
   and padding, the label column and the gap after it. */
.section-switch {
  display: flex;
  align-items: center;
}

.section-switch-name {
  flex: 0 0 calc(1px + var(--gap-4) + 11rem + var(--gap-4));
}

/* One setting's control and what it needs, such as a provider's switch, a pending-settings pill and its restore. */
.setting-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2);
}

.field-note {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Several values of one field, such as Environment diagnostics, each on its own line. */
.field-line {
  display: block;
}

.field-line + .field-line {
  margin-top: var(--gap-2);
}

.confirm-delete {
  display: grid;
  gap: var(--gap-3);
}

.delete-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
}

.delete-form label {
  flex-basis: 100%;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.delete-form .control {
  flex: 0 1 26rem;
  min-width: 0;
}

/* Heading of one group of fields or one table on a page that shows several, such as the Status pages. */
.section-title {
  margin: var(--gap-5) 0 var(--gap-2);
  font-size: 1.05rem;
}

.section-title:first-child {
  margin-top: 0;
}

/* A part's heading or a temporary files card that breadcrumbs lead to, and a confirmation the script brings into view,
   stop below the sticky top bar and section bar. */
.section-title[id],
.temp-card[id],
.confirm {
  scroll-margin-top: calc(var(--topbar-height) + var(--tabs-height) + var(--gap-3));
  scroll-margin-bottom: var(--gap-3);
}

/* Rendered Markdown */

.markdown {
  padding: var(--gap-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: var(--gap-5) 0 var(--gap-2);
}

.markdown h2 {
  padding-bottom: var(--gap-2);
  border-bottom: 1px solid var(--border);
  font-size: 1.2rem;
}

.markdown h3 {
  font-size: 1.05rem;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown blockquote {
  margin: 0 0 var(--gap-3);
}

.markdown li {
  margin: var(--gap-1) 0;
}


.markdown a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.markdown a:hover {
  text-decoration-color: currentcolor;
}

.markdown code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.markdown pre {
  margin: 0 0 var(--gap-3);
  padding: var(--gap-3) var(--gap-4);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

.markdown pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* Context tab: one collapsed entry per agent notes or decisions file. */
.context-files {
  margin: 0 0 var(--gap-5);
}

.context-files h2 {
  margin: 0 0 var(--gap-2);
  font-size: 1.05rem;
}

.context-file {
  margin: 0 0 var(--gap-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.context-file > summary,
.context-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-1) var(--gap-3);
  padding: var(--gap-3) var(--gap-4);
  cursor: pointer;
}

.temp-table {
  margin-top: var(--gap-3);
}

/* Origin and content share the free width equally; the catalog's narrow origin column does not apply here. */
.temp-table .col-origin {
  width: auto;
}

.temp-table .col-files {
  width: 6rem;
}

/* The viewer's change column holds a date and a time together. */
.temp-table .col-modified {
  width: 10.5rem;
}

.temp-table .col-size {
  width: 7rem;
}

/* Cell padding plus the 30px trash button, so the button keeps the 16px right inset of the file cards' buttons. */
.temp-table .col-action {
  width: calc(var(--gap-3) + 30px + var(--gap-4));
}

.temp-table td:first-child {
  overflow-wrap: anywhere;
}

.temp-table .row-action {
  padding-top: var(--gap-2);
  padding-bottom: var(--gap-2);
  text-align: right;
}

/* Size, change and count chips sit at the right, just before the trash action. */
.context-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  margin-left: auto;
}

.context-row {
  align-items: center;
  cursor: default;
}

/* Row trash actions line up with the agent file cards' trash actions. */
.temp-table .row-action {
  padding-right: var(--gap-4);
}

.context-blocked {
  margin: var(--gap-2) 0 0;
  color: var(--tone-warning);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.context-name {
  font-weight: 600;
}

/* The general Settings' temporary files unfold in place: a project's card holds its Spaces' cards, and a Space's card
   its files, each below a divider inside the card. */
.temp-card .context-blocked {
  flex-basis: 100%;
  margin: 0;
}

.temp-children,
.temp-card > .space-files,
.temp-card > .temp-load {
  margin: 0;
  padding: var(--gap-3) var(--gap-4);
  border-top: 1px solid var(--border);
}

.temp-children > .context-file:last-child,
.space-files > .context-files:last-child {
  margin-bottom: 0;
}

.space-files h3 {
  margin: 0 0 var(--gap-2);
  font-size: 0.95rem;
}

.space-files .context-files {
  margin: 0 0 var(--gap-4);
}


.context-file > .markdown,
.context-file > .notice {
  margin: 0;
  padding: var(--gap-3) var(--gap-4) var(--gap-4);
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Temporary viewer: the way up, the entry's path and its chips, then the folder listing or the file content. */
.temp-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  margin: 0 0 var(--gap-4);
}

.temp-path {
  overflow-wrap: anywhere;
}

.temp-truncated {
  margin: 0 0 var(--gap-3);
  color: var(--tone-warning);
  font-size: 0.88rem;
}

.temp-content pre {
  max-height: none;
}

.markdown .frontmatter {
  margin: var(--gap-5) 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.markdown .frontmatter summary {
  padding: var(--gap-2) var(--gap-3);
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
}

.markdown .frontmatter pre {
  margin: 0;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-muted);
}

.markdown blockquote {
  padding: var(--gap-2) var(--gap-4);
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.markdown hr {
  margin: var(--gap-5) 0;
  border: none;
  border-top: 1px solid var(--border);
}

.table-wrap {
  margin: 0 0 var(--gap-3);
  overflow-x: auto;
}

.markdown th,
.markdown td {
  padding: var(--gap-2) var(--gap-3);
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.markdown th {
  background: var(--surface-sunken);
}

.notice {
  margin: 0 0 var(--gap-4);
  padding: var(--gap-4);
  border: 1px solid var(--tone-error);
  border-radius: var(--radius);
  background: var(--tone-error-soft);
}

@media (max-width: 560px) {
  main {
    padding: var(--gap-4) var(--gap-4) var(--gap-5);
  }

  .topbar {
    gap: var(--gap-3);
  }

  h1 {
    font-size: 1.35rem;
  }

  .markdown {
    padding: var(--gap-4);
  }

  dt {
    flex-basis: 100%;
  }
}

/* Test and review buttons of one row of a Testing table. */
.row-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--gap-2);
}

/* Testing headers such as `Audited/total` break at their slash instead of running into the next column. */
.testing-table th .sort {
  overflow-wrap: anywhere;
}

/* Testing cells break long paths anywhere, and the units table keeps its state, time and action columns narrow. */
.testing-table td {
  overflow-wrap: anywhere;
}

.testing-table .col-time {
  width: 7rem;
}

.testing-table .col-actions {
  width: 9rem;
}

/* A handler's units keep their numbers narrow so the name keeps most of the row, offer an own budget beside `Ejecutar`,
   and show their recent durations as a small fixed line. */
.testing-units .col-time {
  width: 5.5rem;
}

.testing-units .col-state {
  width: 8.5rem;
}

.testing-units .col-spark {
  width: 6rem;
}

.testing-units .col-actions {
  width: 12rem;
}

.testing-units .unit-name {
  display: block;
}

/* Group rows of a handler's units: the file or directory with its units and summed excess. */
.work .group-row th {
  border-top: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-size: 0.88rem;
  letter-spacing: normal;
  overflow-wrap: anywhere;
  text-transform: none;
}

.work .group-row .row-note {
  font-weight: 400;
}

@container content (max-width: 720px) {
  .work .group-row th {
    display: block;
  }
}

/* What a handler's cases above their limit share: its tables keep apart from each other and from the list below. */
.testing-shared {
  margin: 0 0 var(--gap-5);
}

.testing-shared .work {
  margin-bottom: var(--gap-4);
}

.testing-shared code {
  overflow-wrap: anywhere;
}

/* A failing count's change from the previous run: more fail in the error tone, fewer in the completed one. */
.row-note.trend-up {
  color: var(--tone-error);
}

.row-note.trend-down {
  color: var(--tone-completed);
}

/* Context lines of a handler's last run, such as its drift, under its headline figures. */
.testing-context {
  margin: 0 0 var(--gap-4);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.testing-context p {
  margin: 0 0 var(--gap-1);
}

/* Pages of a long list: previous and next around the range shown. */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--gap-3);
  margin: var(--gap-4) 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

/* A dialog's choice between options, such as an own budget's scope. */
.choices {
  display: grid;
  gap: var(--gap-1);
  margin: 0;
  padding: 0;
  border: none;
}

.choices legend {
  margin-bottom: var(--gap-1);
  padding: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.answer-form .choice {
  color: var(--text);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.dialog-warning {
  margin: 0;
  color: var(--tone-warning);
  font-size: 0.88rem;
}

/* Headline figures: four cards in a row, two by two when the content is narrow, the value colored only when it needs
   attention. */
.figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap-3);
  margin: 0 0 var(--gap-4);
}

@container content (min-width: 760px) {
  .figures {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* A card's label, value and note stack in the first column; its actions, the info button that opens its dialog and
   the forms that act on what it shows, sit at its top right beside them. */
.figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  column-gap: var(--gap-2);
  min-width: 0;
  margin: 0;
  padding: var(--gap-3) var(--gap-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.figure > * {
  grid-column: 1;
}

/* The card's title reads first, above its value; its note stays small and muted. */
.figure dt {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.figure dd {
  margin: 0;
}

.figure .figure-actions {
  display: flex;
  grid-row: 1 / span 3;
  grid-column: 2;
  align-self: start;
  gap: 2px;
  margin: -6px -10px 0 0;
}

.figure-actions .icon-btn {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

/* The value's row is one line of the value's size in every card, a number or a pill, so the notes of a row of cards
   line up and no card is taller than the rest. */
.figure .figure-value {
  display: flex;
  align-items: center;
  min-height: 1.3em;
  margin: 2px 0 4px;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.figure-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.figure-note .diff-stat {
  font-size: inherit;
}

/* Status cards in groups, such as Tasks and Plans, each under its heading. */
.figure-group + .figure-group {
  margin-top: var(--gap-2);
}

.figure-group .section-title {
  margin: 0 0 var(--gap-3);
}

.figure-error .figure-value {
  color: var(--tone-error);
}

.figure-warning .figure-value {
  color: var(--tone-warning);
}

.figure-info .figure-value {
  color: var(--tone-info);
}

.figure-completed .figure-value {
  color: var(--tone-completed);
}

/* A state's value, such as the installed Nia's, is its pill, a size up, centered in the value's row. */
.figure-value .pill {
  padding: 2px var(--gap-3);
  font-size: 0.88rem;
  line-height: 1.25;
}

/* The managed elements a project's sync would bring up to date, in its card's dialog. */
.status-elements {
  margin: 0;
  padding-left: var(--gap-4);
}

/* Charts: server-rendered inline SVG that scales to its column and takes the panel's tokens in both schemes. Hues are
   classes, such as the tag hues or `chart-hue-*`, which set `--tag`. */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
  gap: var(--gap-4);
  margin: 0 0 var(--gap-5);
}

.chart {
  min-width: 0;
  margin: 0;
  padding: var(--gap-3) var(--gap-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chart-title {
  margin: 0 0 var(--gap-2);
  font-size: 0.92rem;
  font-weight: 600;
}

.chart-plot {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-plot text {
  fill: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* A narrow column scales a chart down, so its labels grow back to a legible size. */
@container content (max-width: 520px) {
  .chart-plot text {
    font-size: 14px;
  }
}

.chart-hue-error {
  --tag: var(--tone-error);
}

.chart-hue-info {
  --tag: var(--tone-info);
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--tag, var(--text));
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.chart-mark {
  outline: none;
}

.chart-hit {
  fill: transparent;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--tag, var(--text));
  stroke-width: 2;
}

.chart-mark:hover .chart-dot,
.chart-mark:focus .chart-dot {
  fill: var(--tag, var(--text));
}

.chart-mark:focus-visible .chart-dot,
.chart-mark:focus-visible .chart-bar {
  stroke: var(--text);
  stroke-width: 2;
}

.chart-bar-within {
  fill: var(--tone-completed);
}

.chart-bar-improvable {
  fill: var(--tone-warning);
}

.chart-bar-fails {
  fill: var(--tone-error);
}

.chart-mark:hover .chart-bar {
  opacity: 0.8;
}

.chart-plot .chart-tip {
  visibility: hidden;
  fill: var(--text);
  font-weight: 600;
  paint-order: stroke;
  pointer-events: none;
  stroke: var(--surface);
  stroke-linejoin: round;
  stroke-width: 3px;
}

.chart-mark:hover .chart-tip,
.chart-mark:focus .chart-tip {
  visibility: visible;
}

.chart-marker {
  stroke: var(--text-muted);
  stroke-dasharray: 4 3;
  stroke-width: 1.25;
}

.chart-plot .chart-marker-label {
  fill: var(--text);
  font-weight: 600;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-1) var(--gap-3);
  margin: var(--gap-2) 0 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  list-style: none;
}

.chart-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: var(--gap-1);
  border-radius: 50%;
  background: var(--tag, var(--text));
}

.chart-note,
.chart-empty {
  margin: var(--gap-2) 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.chart-empty {
  padding: var(--gap-5) var(--gap-3);
  text-align: center;
}

/* A unit's recent durations: a fixed small line with its budget dashed. */
.sparkline {
  display: block;
  overflow: visible;
}

.sparkline-line {
  fill: none;
  stroke: var(--text-muted);
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.sparkline-dot {
  fill: var(--text);
}

.sparkline-reference {
  stroke: var(--border-strong);
  stroke-dasharray: 3 2;
  stroke-width: 1;
}

/* Uncommitted changes of a project's checkout: one folded card per file with its kind, path and line counts, which
   unfolds into its patch with old and new line numbers. The patch scrolls sideways instead of wrapping code. */
.diff-path {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.diff-arrow {
  color: var(--text-muted);
}

.diff-stat {
  display: inline-flex;
  gap: var(--gap-2);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.diff-file .diff-stat {
  margin-left: auto;
}

.diff-added {
  color: var(--tone-completed);
}

.diff-removed {
  color: var(--tone-error);
}

.diff-body {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.diff {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
}

.diff td {
  padding: 0 var(--gap-2);
  vertical-align: top;
}

.diff-number {
  width: 1%;
  min-width: 4ch;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  user-select: none;
}

.diff-code {
  white-space: pre;
}

.diff-add {
  background: color-mix(in srgb, var(--tone-completed) 15%, transparent);
}

.diff-del {
  background: color-mix(in srgb, var(--tone-error) 15%, transparent);
}

.diff-add .diff-number {
  color: var(--tone-completed);
}

.diff-del .diff-number {
  color: var(--tone-error);
}

.diff-hunk {
  background: color-mix(in srgb, var(--tone-info) 10%, transparent);
  color: var(--text-muted);
}

.diff-meta {
  color: var(--text-muted);
  font-style: italic;
}

.diff-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.diff-file .diff-note {
  padding: var(--gap-2) var(--gap-4);
  border-top: 1px solid var(--border);
}

.diff-error {
  color: var(--tone-error);
}
