/*
 * The app's one stylesheet. Every colour, font, size, shadow and duration is a token on :root, in
 * two layers: the palette (the brand's colours, the only hex values in the app) and the semantic
 * names every rule below reads. Re-theming is a change to the palette or to the mapping, never to
 * a rule; a test refuses a colour named anywhere else and proves the text pairings meet WCAG AA.
 * The palette is the Ahbrain brand set (v1.1, November 2026). Flare fails as text on a light surface,
 * so it is a fill and a focus ring only, with Midnight text on it; Ember is the accent's text
 * colour; Haze is secondary text on Midnight and nowhere else. docs/design.md is the full system.
 */
:root {
  /* 1. Palette: the brand's colours, the only hex values in this file. */
  --brand-midnight: #17182F;
  --brand-flare: #EB5D2B;
  --brand-ember: #BF3F12;
  --brand-paper: #F4F1EA;
  --brand-white: #FFFFFF;
  --brand-haze: #8A93B8;
  --brand-neutral: #E6E8F0;

  /* 2. Semantic: what every rule below reads. Change the mapping, not the rules. */
  --canvas: var(--brand-paper);
  --surface: var(--brand-white);
  --surface-raised: var(--brand-midnight);
  --on-raised: var(--brand-white);
  --on-accent: var(--brand-midnight);
  --ink: var(--brand-midnight);
  --ink-muted: color-mix(in srgb, var(--brand-midnight) 72%, var(--brand-white));
  --accent: var(--brand-flare);
  --accent-ink: var(--brand-ember);
  --accent-soft: color-mix(in srgb, var(--brand-flare) 10%, var(--brand-white));
  --line: color-mix(in srgb, var(--brand-midnight) 12%, var(--brand-white));
  --line-strong: color-mix(in srgb, var(--brand-midnight) 28%, var(--brand-white));
  --hover: color-mix(in srgb, var(--brand-midnight) 5%, var(--brand-white));
  /* A neutral status's fill: a pill. Heavier than a row's hover, which stays the mix above. */
  --fill-neutral: var(--brand-neutral);
  --focus: var(--brand-flare);
  /* The dark region's own shades: muted text (Haze, which fails on a light ground, so no rule
     outside the top bar and the sidebar reads it), a hairline, and the hover and current fills. */
  --on-raised-muted: var(--brand-haze);
  --raised-line: color-mix(in srgb, var(--brand-white) 14%, var(--brand-midnight));
  --raised-hover: color-mix(in srgb, var(--brand-white) 8%, var(--brand-midnight));
  --raised-active: color-mix(in srgb, var(--brand-white) 13%, var(--brand-midnight));
  /* The logo's "brain" on the dark region: the brand's Paper, not the chrome's White. */
  --logo-word-reversed: var(--brand-paper);
  --shadow-1: 0 1px 2px color-mix(in srgb, var(--brand-midnight) 8%, transparent);
  --shadow-2: 0 6px 18px -6px color-mix(in srgb, var(--brand-midnight) 18%, transparent);
  /* The shade at a listing's edge while more of it lies that way, out of view. */
  --scroll-shade: color-mix(in srgb, var(--brand-midnight) 16%, transparent);
  /* Behind a dialog: the screen dimmed, so the dialog reads as the one thing in front. */
  --backdrop: color-mix(in srgb, var(--brand-midnight) 45%, transparent);

  /* 3. Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  /* Headings and numbers. Inter stands in while the display face loads, then Arial as the brand
     asks. */
  --font-display: "Bricolage Grotesque", "Inter", system-ui, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;
  --leading-tight: 1.2;
  --leading: 1.5;
  --tracking-caps: 0.08em;
  --tracking-display: -0.02em;
  --leading-relaxed: 1.65;

  /* 4. Space and shape */
  --space-half: 0.125rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-9: 2.25rem;
  --space-10: 2.5rem;
  --space-11: 2.75rem;
  --space-12: 3rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-pill: 999px;
  --border: 1px solid var(--line);
  --border-strong: 1px solid var(--line-strong);

  /* 5. Motion */
  --dur-fast: 120ms;
  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --lift: translateY(-1px);

  /* 6. Layout */
  --sidebar-width: 17rem;
  --content-width: 52rem;
  --topbar-height: 3.5rem;
  --badge-size: 1.25rem;
  --chevron-size: 0.45rem;
}

/*
 * Inter for text and Bricolage Grotesque for display, self-hosted: the policy refuses a font from
 * any other origin. One variable file per family, style and script range, so a page in plain
 * English fetches only the latin files, and Inter's italic only where something is italic.
 * Bricolage has no italic, and a heading is never set in one. The URLs are relative so the
 * production manifest rewrites them to their hashed names. docs/packages.md records the versions,
 * licences and hashes.
 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-5.3.0-latin-ext-wght-normal.1ad231aac0a8.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: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-5.3.0-latin-wght-normal.260c81a4759b.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: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-5.3.0-latin-ext-wght-italic.f877664ba06a.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: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-5.3.0-latin-wght-italic.0a81fe197e0d.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: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-5.3.0-latin-ext-wght-normal.b1ae2c312cfb.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: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-5.3.0-latin-wght-normal.ada540c0e24a.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;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading);
  color: var(--ink);
  background: var(--canvas);
}

a {
  color: var(--accent-ink);
  text-underline-offset: 0.15em;
  transition: color var(--dur-fast) var(--ease);
}

/* A prose link (a body link, a search hit's title) darkens to the ink on hover. A link with a
   class is a component (a button, a sidebar link, the brand) with a hover of its own, which this
   would otherwise override: ink on a primary button's hover fill, or on the Midnight sidebar. */
a:not([class]):hover {
  color: var(--ink);
}

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

h1,
h2,
h3 {
  margin: var(--space-6) 0 var(--space-3);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

/* The display face is for the two headings that title a screen and its parts; an h3 is a label
   inside a part and stays in the text face. */
h1 {
  margin-top: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-display);
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

/* --- The frame: top bar, sidebar, content -------------------------------------------------- */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "top"
    "nav"
    "main";
}

/* The top bar and the sidebar are the one dark region, so the chrome reads apart from the
   content on the light canvas. */
.topbar {
  grid-area: top;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  min-height: var(--topbar-height);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-raised);
  color: var(--on-raised);
  border-bottom: 1px solid var(--raised-line);
}

/* The home link is the logo and nothing else. Its padding, with the top bar's own, is the logo's
   clear space: the height of its capital A (about 23px at this width) on every side. */
.brand {
  display: block;
  flex: none;
  padding: var(--space-4) var(--space-2);
  border-radius: var(--radius-sm);
}

/* The Ahbrain logo: the pack's outlines, coloured here. The "Ah" and its macron are the accent
   wherever the logo sits; "brain" is the ink on a light card and Paper on the dark region. */
.logo {
  display: block;
  height: auto;
}

/* 112px: over the 96px the brand sets as the horizontal logo's least width on screen. */
.brand .logo {
  width: 7rem;
}

.logo-ah {
  fill: var(--accent);
}

.logo-word {
  fill: var(--ink);
}

.brand .logo-word {
  fill: var(--logo-word-reversed);
}

/* The stacked logo's tile is the app icon: White letters on Midnight, as the dark region is. */
.logo-tile {
  fill: var(--surface-raised);
}

.logo-tile-ah {
  fill: var(--on-raised);
}

.who {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  min-width: 0;
  font-size: var(--text-sm);
}

.who-name {
  overflow-wrap: anywhere;
}

/* On the narrowest phones the name would push Sign out onto a row of its own; the account
   screen still says who is signed in. */
@media (max-width: 29.99rem) {
  .who-name {
    display: none;
  }
}

.topbar .button-quiet {
  padding: var(--space-1) var(--space-3);
  border-color: var(--raised-line);
  background: none;
  color: var(--on-raised);
}

.topbar .button-quiet:hover {
  background: var(--raised-hover);
  border-color: var(--on-raised-muted);
}

/* The sidebar is a disclosure, so it folds behind "Menu" on a phone with no script. Its gutter is
   the top bar's, so the menu's icon starts under the logo's left edge. */
.nav {
  grid-area: nav;
  background: var(--surface-raised);
  color: var(--on-raised);
  padding: 0 var(--space-4);
}

/* Only on a phone: from 48rem the sidebar's own padding stands whatever the disclosure's state. */
@media (max-width: 47.99rem) {
  .nav[open] {
    padding-bottom: var(--space-3);
  }

  .nav[open] > summary {
    margin-bottom: var(--space-2);
  }
}

/* The negative margin gives the hover fill room around the row while the icon, the label and the
   chevron stay on the top bar's gutter. */
.nav > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 calc(-1 * var(--space-2));
  padding: var(--space-2);
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-sm);
}

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

/* Three bars drawn from gradients in the text colour. The margin is the brand link's own padding,
   so the bars start under the logo's left edge. */
.nav > summary::before {
  content: "";
  flex: none;
  width: 1.125rem;
  height: 0.75rem;
  margin-left: var(--space-2);
  background:
    linear-gradient(currentColor, currentColor) center top / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) center bottom / 100% 2px no-repeat;
}

/* The same chevron a section's pages open with, at the row's right edge under Sign out. */
.nav > summary::after {
  content: "";
  flex: none;
  width: var(--chevron-size);
  height: var(--chevron-size);
  margin: 0 var(--space-1) 0 auto;
  border-right: 2px solid var(--on-raised-muted);
  border-bottom: 2px solid var(--on-raised-muted);
  transform: rotate(45deg);
  transition: transform var(--dur) var(--ease);
}

.nav[open] > summary::after {
  transform: rotate(-135deg);
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-group + .nav-group {
  margin-top: var(--space-5);
}

.nav-heading {
  margin: 0 0 var(--space-1);
  padding: 0 var(--space-3);
  color: var(--on-raised-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* A link is a row with room to hit; the current one carries the accent bar on its left edge. */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--on-raised-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  overflow-wrap: anywhere;
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.nav-link:hover {
  background: var(--raised-hover);
  color: var(--on-raised);
}

.nav-link[aria-current="page"] {
  background: var(--raised-active);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--on-raised);
  font-weight: var(--weight-semibold);
}

/* A section with generated pages: its summary is the section's link, and the marker beside it
   opens the list without leaving the screen. */
.nav-section > summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
}

.nav-section > summary::-webkit-details-marker {
  display: none;
}

.nav-section > summary > .nav-link {
  flex: 1;
}

.nav-section > summary::after {
  content: "";
  flex: none;
  width: var(--chevron-size);
  height: var(--chevron-size);
  margin: 0 var(--space-3);
  border-right: 2px solid var(--on-raised-muted);
  border-bottom: 2px solid var(--on-raised-muted);
  transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease);
}

.nav-section[open] > summary::after {
  transform: rotate(45deg);
}

.nav-pages {
  margin: var(--space-1) 0 var(--space-2) var(--space-3);
  padding-left: var(--space-2);
  border-left: 1px solid var(--raised-line);
}

.nav-pages .nav-link {
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
  font-size: var(--text-xs);
}

/* The pending count beside Approvals: the one filled accent in the sidebar. */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--badge-size);
  margin-left: auto;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: var(--badge-size);
}

.main {
  grid-area: main;
  min-width: 0;
  padding: var(--space-4);
}

.content {
  max-width: var(--content-width);
  overflow-wrap: anywhere;
}

/* The audit screens are tables of seven columns: they take the main column's whole width, as a
   page of prose would not. */
.content-wide {
  max-width: none;
}

@media (min-width: 48rem) {
  .app {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "top top"
      "nav main";
  }

  /* No one signed in, or a page saying they have left: no sidebar, so no empty column. */
  .app-bare {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "main";
  }

  .topbar {
    flex-wrap: nowrap;
    padding: var(--space-2) var(--space-6);
  }

  /* The wider gutter is the logo's clear space by itself, so the logo's left edge sits on the
     sidebar's text beneath it. */
  .brand {
    padding-left: 0;
  }

  /* Always open on a wide screen, and held in view while the content scrolls: the summary goes,
   * and the content shows whatever the disclosure's state. A browser without ::details-content
   * keeps the summary's toggle. */
  /* A full viewport tall, so the dark column reaches the foot of the screen however short the
     sidebar's list; the grid cell ends it at the foot of the page. */
  .nav {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    overflow-y: auto;
    padding: var(--space-5) var(--space-3);
  }

  .nav > summary {
    display: none;
  }

  /* Opaque too, whatever the disclosure's state: the fade below would otherwise leave a closed
     sidebar invisible on a wide screen. */
  .nav::details-content {
    content-visibility: visible;
    display: block;
    opacity: 1;
  }

  .main {
    padding: var(--space-8) var(--space-10);
  }
}

/* --- Components ---------------------------------------------------------------------------- */
/*
 * Every class a screen uses is defined once here, reading tokens only, and a test refuses a class
 * a template uses that this sheet lacks. A new screen is built from these; a new component is
 * added here and documented in docs/design.md in the same commit.
 */

/* Labels and text ---------------------------------------------------------------------------- */

/* A small capitalised label above a heading: what kind of thing the screen is about. */
.eyebrow {
  display: block;
  margin: 0 0 var(--space-2);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.hint {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.path {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

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

/* Cards -------------------------------------------------------------------------------------- */

/* Content sits on white cards against the canvas. */
.card {
  margin: var(--space-4) 0;
  padding: var(--space-5);
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

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

.card > :last-child > :last-child {
  margin-bottom: 0;
}

/* The counts on a section's screen and Browse's root: numbers, never a chart. Each is a
   tile with its label beneath the number; the label stays first in the source for a screen
   reader, so the tile reverses the order on screen. The helper runs are a list, so that tile
   takes the whole row and reads top down. */
.counts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-6);
}

.count {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.count dt {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
}

.count dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
}

.count-list {
  grid-column: 1 / -1;
  flex-direction: column;
}

.count-list dt {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* The helper runs are a list of words, not a number, so they stay in the text face. */
.count-list dd {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: var(--leading);
}

/* Pills and badges --------------------------------------------------------------------------- */

/* A short fact about a thing: its visibility, its status, a role. Outlined on the neutral fill so
   it reads as a label, not a button. */
.pill {
  display: inline-flex;
  align-items: center;
  padding: var(--space-half) var(--space-2);
  border: var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--fill-neutral);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading);
  white-space: nowrap;
}

/* Something refused or failed, such as a denied row in the audit log: tinted in the accent, so it
   stands out in a long column of plain pills. */
.pill-problem {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Several pills in one cell or value, wrapping on a narrow column. */
.pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* Buttons ------------------------------------------------------------------------------------ */

/* One primary action per screen, in the accent; everything else is a plain or quiet button. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.button:hover {
  background: var(--hover);
  border-color: var(--ink-muted);
  transform: var(--lift);
}

.button:active {
  transform: none;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}

/* Midnight on Ember is under AA, so the darker hover fill takes the light text. */
.button-primary:hover {
  border-color: var(--accent-ink);
  background: var(--accent-ink);
  color: var(--on-raised);
  box-shadow: var(--shadow-2);
}

.button-quiet {
  border-color: var(--line);
  background: none;
}

.button-quiet:hover {
  background: var(--hover);
  border-color: var(--line-strong);
}

/* A button across its whole container: the sign-in card's two ways in. */
.button-wide {
  width: 100%;
}

.inline {
  display: inline;
  margin: 0;
}

/* A row of actions, wrapping on a phone. */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

/* Notices and empty states ------------------------------------------------------------------- */

/* Information the reader should notice; a problem (a refusal, a failed save) carries the accent. */
.notice {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border: var(--border);
  border-left: 4px solid var(--surface-raised);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.notice-problem {
  border-color: var(--accent-soft);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

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

.notice > :last-child {
  margin-bottom: 0;
}

/* Nothing to show: said plainly, in the space the listing would have taken. */
.empty {
  margin: var(--space-4) 0;
  padding: var(--space-8) var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-muted);
  text-align: center;
}

/* The bare screens ------------------------------------------------------------------------- */

/* Signing in, signed out, a refusal, not found: one centred card with the stacked logo above the
   heading, a readable width on any screen. With no sidebar the column itself is centred too. */
.app-bare .content {
  margin-inline: auto;
}

.bare {
  max-width: 28rem;
  margin: var(--space-6) auto;
  padding: var(--space-6);
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}

/* 128px, centred as the stacked logo is drawn: over the 64px the brand sets as its least width. */
.logo-stacked {
  width: 8rem;
  margin: 0 auto var(--space-5);
}

.bare h1 {
  font-size: var(--text-2xl);
}

.bare > :last-child,
.bare > :last-child > :last-child {
  margin-bottom: 0;
}

/* "or" between the two ways in, on a hairline. */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-2);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: var(--border);
}

/* Listings ----------------------------------------------------------------------------------- */

/*
 * A table of rows, a card of its own or flush inside one: <div class="listing"><table>. The div
 * is the card and the scroll box, so a table wider than the column scrolls inside it rather than
 * widening the page, and the table is a real table across the whole box at every width. A table
 * that is itself the scroll box (display: block) sizes its rows to their content, so the
 * hairlines stopped short of the card's edge.
 *
 * The four backgrounds are the scroll cue: a shade at whichever edge has more table beyond it.
 * The two covers scroll with the content (local) and hide the shades (scroll, pinned to the box)
 * once that edge is reached, so a table that fits shows no shade at all.
 */
.listing {
  max-width: 100%;
  margin: var(--space-4) 0;
  overflow-x: auto;
  border: var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left / var(--space-8) 100%
      no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right / var(--space-8) 100%
      no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shade), transparent) left /
      var(--space-3) 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shade), transparent) right /
      var(--space-3) 100% no-repeat scroll,
    var(--surface);
  box-shadow: var(--shadow-1);
  font-size: var(--text-sm);
}

.listing > table {
  width: 100%;
  border-collapse: collapse;
}

/* Inside a card a listing is already on a raised surface: no second shadow, and flush with the
   card's foot when it is the last thing in it. */
.card > .listing {
  box-shadow: none;
}

.card > .listing:last-child {
  margin-bottom: 0;
}

.listing th,
.listing td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border);
  text-align: left;
  vertical-align: top;
  /* A word in a cell stays whole; only a path or a request id, which have no spaces to break
     at, breaks where it must. */
  overflow-wrap: normal;
}

.listing tbody tr:last-child > * {
  border-bottom: 0;
}

.listing th {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
}

.listing td:first-child {
  font-weight: var(--weight-semibold);
}

.listing tbody tr {
  transition: background-color var(--dur) var(--ease);
}

.listing tbody tr:hover {
  background: var(--hover);
}

/* A path or an email breaks at the <wbr> the break_at filter puts after a path's every "/", or
   before an email's "@" and every ".", and mid-segment only when one segment alone is wider than
   the column. break-word rather than anywhere: anywhere lets a column shrink to one character, so
   the table squeezed a path column to a sliver while its neighbours stayed wide. */
.listing .path {
  font-weight: var(--weight-regular);
  overflow-wrap: break-word;
}

/* A date stays on one line. Where it shares a cell (the audit log's date, time and request id),
   each part is its own span, so the column narrows to the date alone and the rest wraps. */
.listing .date {
  white-space: nowrap;
}

/* A section's listings sit flush in its card, under the heading. */
.card > h2 + .listing {
  margin-bottom: 0;
}

/* The meta strip ----------------------------------------------------------------------------- */

/* A thing's facts as key and value: stacked pairs on a phone, a row of columns from 48rem. */
.meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: var(--text-sm);
}

.meta dt {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  line-height: var(--leading);
  text-transform: uppercase;
}

.meta dd {
  margin: 0;
  font-weight: var(--weight-medium);
}

/* A strip with many facts or long values (a person's grants, the operator's jobs): it stays as
   key and value rows at every width rather than becoming a row of columns. */
.meta-rows {
  gap: var(--space-2) var(--space-6);
}

/* Forms -------------------------------------------------------------------------------------- */

.editor {
  display: grid;
  gap: var(--space-3);
}

.field {
  display: grid;
  gap: var(--space-1);
}

.editor label,
.field label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

/* Django's form.as_div: a field's help text and its errors, beneath the input. */
.editor .helptext {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.editor .errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.editor > div {
  display: grid;
  gap: var(--space-1);
}

/* The audit filters: several short fields side by side from a wide screen, the hint and the
   buttons across the whole row beneath them. */
.filters {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  align-items: start;
}

.filters > .hint,
.filters > .controls {
  grid-column: 1 / -1;
  margin: 0;
}

.editor textarea,
.editor input,
.editor select,
.field textarea,
.field input,
.field select,
.search input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

/* The browser's own arrow sits flush with the border whatever the padding, so it is replaced
   by a chevron drawn from two gradient triangles in a token colour, inset like the text. */
.editor select,
.field select {
  appearance: none;
  padding-right: var(--space-10);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position:
    right calc(var(--space-4) + 5px) center,
    right var(--space-4) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.editor input[type="checkbox"],
.editor input[type="radio"],
.field input[type="checkbox"],
.field input[type="radio"] {
  width: auto;
  justify-self: start;
  accent-color: var(--accent);
}

.editor textarea:hover,
.editor input:hover,
.editor select:hover,
.field textarea:hover,
.field input:hover,
.field select:hover,
.search input:hover {
  border-color: var(--ink-muted);
}

.editor textarea:focus,
.editor input:focus,
.editor select:focus,
.field textarea:focus,
.field input:focus,
.field select:focus,
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor textarea {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  resize: vertical;
}

/* The search screen's own field: larger than the top bar's, with its button beside it. */
.search {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.search input {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-lg);
}

/* A screen's heading with its one secondary action beside it, wrapping under it on a phone. */
.screen-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.screen-head > h1 {
  margin: 0;
}

/* Navigation within a screen ----------------------------------------------------------------- */

/* A long listing's pages: Previous, the page numbers with a gap where some are left out, and
   Next, wrapping on a phone. The current page is outlined in the accent. */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
}

.pager-page {
  display: inline-block;
  min-width: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border: var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-muted);
  font-weight: var(--weight-semibold);
  text-align: center;
  text-decoration: none;
  transition:
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.pager-page:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.pager-page[aria-current="page"] {
  border-color: var(--accent);
  color: var(--ink);
}

.pager-gap {
  color: var(--ink-muted);
}

.crumbs {
  margin-bottom: var(--space-2);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

/* The pages synced from a ClickUp board: a plain list of links with their dates. */
.synced {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0;
  padding: 0;
  list-style: none;
}

/* Search results ----------------------------------------------------------------------------- */

.hits {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.hits > li {
  padding: var(--space-4) var(--space-5);
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition:
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.hits > li:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-2);
}

.hits p {
  margin: var(--space-1) 0 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* Source and comparison ---------------------------------------------------------------------- */

/* A pending write's file on main beside the write's version; stacked at phone width. */
.side-by-side {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-4);
}

.side-by-side .eyebrow {
  margin-top: 0;
}

.source {
  max-height: 32rem;
  margin: var(--space-2) 0;
  padding: var(--space-3) var(--space-4);
  overflow: auto;
  border: var(--border);
  border-radius: var(--radius-md);
  background: var(--canvas);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A token or a command is copied exactly, so a wrap at phone width would put a break in it that
   looks like part of the text, and would lose a JSON block's indentation. It scrolls inside
   itself instead, and the template makes it focusable so a keyboard can scroll it. */
.source-line {
  white-space: pre;
  overflow-wrap: normal;
}

/* A disclosure inside a card: a quiet control that opens a form beneath it. */
.disclosure {
  margin-top: var(--space-4);
  border-top: var(--border);
  padding-top: var(--space-3);
}

.disclosure > summary {
  display: inline-block;
  padding: var(--space-1) 0;
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}

.disclosure > summary:hover {
  color: var(--ink);
}

.disclosure[open] > summary {
  margin-bottom: var(--space-3);
}

/* Frames ------------------------------------------------------------------------------------- */

/* A generated page's sandbox: as wide as the content, tall enough to read without a second
 * scrollbar on most pages. */
.generated {
  display: block;
  width: 100%;
  height: 75vh;
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

/* A modal dialog over the screen, opened by the browser from command="show-modal" with no script:
   a generated page's Data. The browser makes the screen behind it inert and keeps focus inside.
   Centred, as wide as the content column at most and the viewport less its gutters at least. Its
   head stays in view while its body scrolls, so Close is always on screen, even at phone width. */
.modal {
  width: min(var(--content-width), calc(100vw - var(--space-8)));
  max-width: none;
  max-height: calc(100dvh - var(--space-8));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}

/* Only while open: a display of its own on a closed dialog would show it. */
.modal[open] {
  display: flex;
  flex-direction: column;
}

.modal::backdrop {
  background: var(--backdrop);
}

.modal-head {
  flex: none;
  margin: 0;
  padding: var(--space-4) var(--space-6);
  border-bottom: var(--border);
}

.modal-head > h2 {
  margin: 0;
}

.modal-body {
  min-height: 0;
  padding: var(--space-6);
  overflow: auto;
}

/* The screen behind an open dialog stays where it is: inert, and not scrolled by the wheel. */
html:has(.modal[open]) {
  overflow: hidden;
}

/* A ClickUp board, framed from its share host. Tall enough to work in, never wider than the
   column, so the page never scrolls sideways at phone width. */
.board {
  display: block;
  width: 100%;
  height: 70vh;
  border: var(--border-strong);
  border-radius: var(--radius-md);
}

/* A page's body ------------------------------------------------------------------------------ */

.body {
  line-height: var(--leading-relaxed);
}

.body pre,
.body code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.body pre {
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  border: var(--border);
  border-radius: var(--radius-md);
  background: var(--canvas);
}

/* A wide table scrolls inside itself rather than widening the page. */
.body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.body th,
.body td {
  padding: var(--space-2) var(--space-3);
  border: var(--border-strong);
  text-align: left;
}

.body img {
  max-width: 100%;
  height: auto;
}

.body blockquote {
  margin: 0;
  padding-left: var(--space-4);
  border-left: 4px solid var(--accent);
  color: var(--ink-muted);
}

@media (min-width: 48rem) {
  h1 {
    font-size: var(--text-3xl);
  }

  .card {
    padding: var(--space-6);
  }

  .meta:not(.meta-rows) {
    grid-template-columns: none;
    grid-template-rows: auto auto;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, auto);
    justify-content: start;
    gap: var(--space-1) var(--space-8);
    padding: var(--space-4) var(--space-5);
  }
}

/* The audit's tables of six or seven columns: on a phone they would wrap every cell to a word or
   two, rows hundreds of pixels tall. Held at a readable width instead, such a table scrolls
   sideways in its box, with the shade at the edge saying there is more. A table that fits a phone
   is left to fit it. */
@media (max-width: 47.99rem) {
  .listing-wide > table {
    min-width: 60rem;
  }
}

/* --- Motion -------------------------------------------------------------------------------- */
/*
 * Each component declares its own hover, focus and active transitions above, on the motion
 * tokens. What lives here is motion that belongs to no one component. Nothing animates on load:
 * a transition runs only when someone hovers, focuses or opens something.
 */

/* A disclosure's content fades in as it opens: the sidebar on a phone, a section's generated
   pages, a form in a card. A disclosure rendered already open does not fade, as no style changes.
   A browser without ::details-content ignores both rules and opens it at once. */
details::details-content {
  opacity: 0;
  transition:
    opacity var(--dur) var(--ease),
    content-visibility var(--dur) var(--ease) allow-discrete;
}

details[open]::details-content {
  opacity: 1;
}

.nav > summary {
  transition: background-color var(--dur) var(--ease);
}

.nav > summary:hover {
  background: var(--raised-hover);
}

/* Someone who has asked for less motion gets none: every transition and animation is instant. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
