/* ClearPath's look: Matt's demo (its final Callandor layer, demo/index.html) on the Callandor
   brand (callandor-web). One stylesheet for the screen, plus print.css for documents.

   - docs/design.md gives the markup for every class here. Templates use those classes and
     nothing else, so add a class here (and to the guide) before using it in a template.
   - Colours are tokens on :root. Light first, then dark (prefers-color-scheme), each checked
     for WCAG 2.2 AA: 4.5:1 for text, 3:1 for form borders and focus rings. Re-check any
     colour you change.
   - The Content Security Policy allows styles and fonts from this site only, so fonts are
     self-hosted (fonts/, SIL Open Font License, see fonts/OFL.txt) and nothing is inline.
   - Sections, in order: fonts, tokens, base (with icons), shell (with search and the account
     menu), page head, containers (with card grids, tooltips and popover cards), buttons (with
     icon buttons and the busy spinner), status, figures, journey, tables, tabs, forms,
     documents (with guide cards), comments and audit, empty states, messages, front page,
     older templates, narrow screens, motion and forced colours. Anything after those belongs
     to the journey pages.
   - Tooltips, popover cards and busy buttons get a little help from ui.js (Esc, anchoring,
     spinning on click); each works without it. */

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Manrope";
  src: url("fonts/Manrope-VariableFont_wght.a27b33912e9a.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cinzel";
  src: url("fonts/Cinzel-Regular.cc74902d7efc.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Marcellus";
  src: url("fonts/Marcellus-Regular.d8d78c8d074b.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* Brand (callandor-web/src/styles/global.css and the demo's v5 layer) */
  --deep-teal: #0e3d3d;
  --teal-2: #14504f;
  --teal-3: #0a2f2f;
  --petrol: #163f43;
  --aqua: #4baca5;
  --steel: #6f8b8d;
  --silver: #c6cdd3;
  --navy: #1f2937;
  --ice: #f5f7f8;
  --cream: #e4decd;

  /* Surfaces and text */
  --paper: #f7f6f2;
  --surface: #ffffff;
  --sunk: #fbfaf6;
  --ink: #1f2937;
  --muted: #5b6472;
  --line: #e3ded2;
  --line-strong: #cfc8b8;
  --field-line: #7d8580;

  /* The accent is Deep Teal on light pages, a lighter teal on dark ones */
  --accent: #0e3d3d;
  --accent-2: #14504f;
  --accent-soft: #e6efee;
  --on-accent: #ffffff;
  --accent-ink: #2f7f79;
  --brass: #7a5c1f;
  --focus: #0e3d3d;

  /* Status, each strong colour passes 4.5:1 on its soft background */
  --red: #b3261e;
  --red-soft: #f8e4e2;
  --amber: #8a5a0a;
  --amber-soft: #f6ecd9;
  --green: #22683f;
  --green-soft: #e0f0e6;
  --blue: #2c5f9e;
  --blue-soft: #e2eaf5;
  --purple: #6b3fa0;
  --purple-soft: #f1ebf8;
  --on-status: #ffffff;

  /* The rail stays Deep Teal in both themes */
  --rail-1: #0e3d3d;
  --rail-2: #0b3232;
  --rail-ink: #e6ecee;
  --rail-muted: #b9c9c9;
  --rail-hover: rgba(255, 255, 255, 0.07);
  --rail-on: rgba(255, 255, 255, 0.12);
  --rail-focus: #e6ecee;

  /* Type */
  --font-body: "Manrope", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Marcellus", Georgia, serif;
  --font-display: "Cinzel", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* Shape */
  --radius: 4px;
  --radius-sm: 3px;
  --content: 1080px;
  --gutter: 32px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a1a1c;
    --surface: #0f2a2c;
    --sunk: #0c2224;
    --ink: #f5f7f8;
    --muted: #a3b4b6;
    --line: #24413f;
    --line-strong: #3a5957;
    --field-line: #6b8a88;

    --accent: #7cc4be;
    --accent-2: #9ad3ce;
    --accent-soft: #143a3c;
    --on-accent: #071f20;
    --accent-ink: #7cc4be;
    --brass: #d7a85c;
    --focus: #7cc4be;

    --red: #f2958d;
    --red-soft: #3a2120;
    --amber: #e8bb68;
    --amber-soft: #352a14;
    --green: #7fcf9e;
    --green-soft: #15322a;
    --blue: #94b8ea;
    --blue-soft: #18293d;
    --purple: #c7a6f0;
    --purple-soft: #2a2238;
    --on-status: #071f20;

    --rail-1: #0b2b2c;
    --rail-2: #071f20;

    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  text-wrap: balance;
}
h1,
h2 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0.005em;
}
h1 {
  font-size: clamp(1.65rem, 1.25rem + 1.3vw, 2.3rem);
}
h2 {
  font-size: 1.45rem;
}
h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h4 {
  font-size: 0.95rem;
  font-weight: 700;
}
p {
  margin: 0;
  text-wrap: pretty;
}
/* Running text: paragraphs and lists that follow each other get a little space */
:where(p, ul, ol, dl) + :where(p, ul, ol, dl) {
  margin-top: 0.75em;
}
ul,
ol {
  padding-left: 1.3em;
}
li + li {
  margin-top: 0.25em;
}
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: 2px;
}
strong,
b {
  font-weight: 700;
}
img,
svg {
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
::selection {
  background: var(--accent);
  color: var(--on-accent);
}
.num {
  font-variant-numeric: tabular-nums;
}
/* Icons from icons.svg, sized to the text beside them */
.icon {
  flex: none;
  width: 1.25em;
  height: 1.25em;
  vertical-align: -0.25em;
  overflow: visible;
}
.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  transform: translateY(-160%);
}
.skip:focus {
  transform: none;
}

/* ---------- Shell: rail, top bar and content ---------- */
.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  --focus: var(--rail-focus);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 16px 18px;
  background: linear-gradient(180deg, var(--rail-1) 0%, var(--rail-2) 100%);
  color: var(--rail-ink);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.cl-mark {
  display: block;
  width: auto;
  height: 32px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.1;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ffffff;
}
.brand-sub {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--rail-muted);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  margin: 14px 10px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rail-muted);
}
.nav-label:first-child {
  margin-top: 0;
}
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--rail-ink);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.nav a:hover {
  background: var(--rail-hover);
}
.nav a[aria-current="page"],
.nav a.on {
  background: var(--rail-on);
  color: #ffffff;
  font-weight: 700;
}
/* The current page also gets a bar, so it doesn't rely on colour alone */
.nav a[aria-current="page"]::before,
.nav a.on::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--aqua);
}
.nav .tag {
  margin-left: auto;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}
.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 8px;
  font-size: 0.8rem;
  color: var(--rail-muted);
}
.rail-foot a {
  color: var(--rail-ink);
}
/* The rail is too narrow for the strapline between two rules: one rule above it instead */
.rail-foot .cl-strap {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  letter-spacing: 0.16em;
}
.rail-foot .cl-strap::after {
  display: none;
}
.cl-strap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--silver);
}
.cl-strap::before,
.cl-strap::after {
  content: "";
  flex: none;
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  min-height: 64px;
  padding: 12px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.tb-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  min-width: 0;
}
.tb-title strong {
  font-size: 1.05rem;
}
/* The top bar's right-hand end: search, then the account menu */
.tb-end {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-left: auto;
}
.tb-search {
  position: relative;
  width: clamp(200px, 26vw, 320px);
}
.tb-search .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  translate: 0 -50%;
  color: var(--muted);
  pointer-events: none;
}
.tb-search input[type="search"] {
  min-height: 40px;
  padding: 7px 14px 7px 38px;
  border-radius: 99px;
  background: var(--sunk);
  font-size: 0.9rem;
}
.tb-search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* Notifications in the top bar (decision 0039): a bell, and how many are new */
.tb-notices {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border-radius: 99px;
  color: var(--ink);
}
.tb-notices:hover,
.tb-notices[aria-current="page"] {
  background: var(--sunk);
}
.tb-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--teal-2);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
/* Opening a notification is a POST (Fable's P4-2): its form sits inline, its button reads as
   a link. */
.notification-list .inline-form {
  display: inline;
}
.notification-list .is-unread {
  border-left: 3px solid var(--teal-2);
}

/* The signed-in person: a button that opens the account menu */
.account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  padding: 3px 8px 3px 3px;
  border: 1px solid transparent;
  border-radius: 99px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  anchor-name: --account;
  transition: background-color 0.15s ease;
}
.account-btn:hover,
.account:has(.menu:popover-open) .account-btn {
  border-color: var(--line);
  background: var(--accent-soft);
}
.account-btn > .icon {
  color: var(--muted);
  transition: rotate 0.15s ease;
}
.account:has(.menu:popover-open) .account-btn > .icon {
  rotate: 180deg;
}
/* (.who on its own is a comment's author; these are the signed-in person) */
:is(.account-btn, .menu-head, .pe-bar) .who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
  font-size: 0.86rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.who-name {
  font-weight: 700;
  color: var(--ink);
}

/* A person's photo, or their initials on teal when there's none */
.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  user-select: none;
}
.avatar :is(img, canvas) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.lg {
  width: 96px;
  height: 96px;
  font-family: var(--font-heading);
  font-size: 2.1rem;
  font-weight: 400;
}

/* A menu that opens over the page (a popover): links, and buttons that look like them */
.menu {
  width: 290px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow:
    0 18px 44px -18px rgba(0, 0, 0, 0.4),
    0 2px 6px -2px rgba(0, 0, 0, 0.12);
}
.menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  padding: 10px 10px 14px;
  border-bottom: 1px solid var(--line);
}
.menu :is(a, button) {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu :is(a, button):hover,
.menu a[aria-current="page"] {
  background: var(--accent-soft);
}
.menu :is(a, button) .icon {
  color: var(--accent-ink);
}
.menu hr {
  margin: 6px 0;
}
/* The account menu hangs below its button where the browser can anchor it, and at the top
   right of the window where it can't */
.account-menu {
  position: fixed;
  inset: 64px var(--gutter) auto auto;
  margin: 0;
}
@supports (position-area: bottom) {
  .account-menu {
    inset: auto;
    margin-top: 6px;
    position-anchor: --account;
    position-area: bottom span-left;
    position-try-fallbacks: flip-inline;
  }
}
.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: 32px var(--gutter) 56px;
}
.content > * {
  min-width: 0;
  max-width: 100%;
}
/* The skip link moves focus to the page itself, which needs no ring */
main[tabindex="-1"]:focus {
  outline: 0;
}

/* ---------- Page head ---------- */
.lede {
  max-width: 68ch;
  font-size: 1.05rem;
  color: var(--muted);
}
h1 + .lede {
  margin-top: -8px;
}
.why {
  display: block;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
}
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.crumbs {
  font-size: 0.85rem;
  color: var(--muted);
}
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}
.crumbs li {
  margin: 0;
}
.crumbs:not(:has(ol)) {
  display: flex;
  flex-wrap: wrap;
}
.crumbs li + li::before,
.crumbs > :is(a, span) + :is(a, span)::before {
  content: "›";
  content: "›" / "";
  margin: 0 10px;
  color: var(--muted);
}
.crumbs a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.crumbs a:hover {
  text-decoration: underline;
}
.crumbs [aria-current="page"] {
  color: var(--ink);
}

/* ---------- Containers ---------- */
.card {
  min-width: 0;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card h2 {
  font-size: 1.25rem;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stack > * {
  min-width: 0;
}
.callout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.callout > :is(h2, h3) {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}
.callout > * {
  max-width: 100%;
}
.callout > :is(p, ul, ol) + :is(p, ul, ol) {
  margin-top: 0;
}
.c-ret {
  border-left-color: var(--red);
  background: var(--red-soft);
}
.c-ret > :is(h2, h3),
.c-ret strong {
  color: var(--red);
}
.c-info {
  border-left-color: var(--blue);
  background: var(--blue-soft);
}
.c-warn {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}
.c-warn > :is(h2, h3) {
  color: var(--amber);
}
.c-with {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.c-done {
  border-left-color: var(--green);
  background: var(--green-soft);
}
.grid2,
.grid3,
.grid4 {
  display: grid;
  align-items: start;
}
.grid2 {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
}
.grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.grid4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.grid2 > *,
.grid3 > *,
.grid4 > * {
  min-width: 0;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.between {
  justify-content: space-between;
}
.row > :is(p, ul, ol) + :is(p, ul, ol) {
  margin-top: 0;
}

/* An even grid of cards: as many columns as fit, every card the same height. `.wide` and
   `.narrow` change how small a card may get. A card's `.card-foot` sits at its bottom. */
.cards {
  --card-min: 230px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min)), 1fr));
  grid-auto-rows: 1fr;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cards.wide {
  --card-min: 300px;
}
.cards.narrow {
  --card-min: 180px;
}
.cards > * {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  margin: 0;
}
.cards > li + li {
  margin-top: 0;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.card-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}
.card-icon .icon {
  width: 22px;
  height: 22px;
}
.card.muted {
  border-style: dashed;
  background: transparent;
}

/* Links that jump within the page or filter it, as a row of rounded chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chips > li + li {
  margin-top: 0;
}
.chips a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}
.chips a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.chips a[aria-current] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

/* Tooltips. A `.has-tip` holds the thing that can be focused and its `.tip`, which the
   thing names with aria-describedby. The tip shows on hover and on keyboard focus, stays
   while the pointer is over it, and Esc hides it (ui.js). `.below`, `.start` and `.end`
   move it when it would run off the screen. */
.has-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.tip {
  position: absolute;
  z-index: 40;
  bottom: calc(100% + 8px);
  left: 50%;
  translate: -50% 0;
  display: none;
  width: max-content;
  max-width: min(260px, 80vw);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  white-space: normal;
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.45);
}
/* A bridge over the gap, so the pointer can move onto the tip without losing it */
.tip::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 10px;
}
.tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  border: 5px solid transparent;
  border-top-color: var(--ink);
}
.has-tip:is(:hover, :has(:focus-visible)) > .tip {
  display: block;
}
.has-tip.tip-off > .tip {
  display: none;
}
.tip.below {
  top: calc(100% + 8px);
  bottom: auto;
}
.tip.below::before {
  top: auto;
  bottom: 100%;
}
.tip.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--ink);
}
.tip.start {
  left: 0;
  translate: none;
}
.tip.start::after {
  left: 16px;
}
.tip.end {
  left: auto;
  right: 0;
  translate: none;
}
.tip.end::after {
  left: auto;
  right: 16px;
  translate: 50% 0;
}
/* Where the browser can anchor it, the tip floats above everything, so a scrolling table
   can't clip it */
@supports (anchor-scope: all) and (position-area: top) {
  .has-tip {
    anchor-scope: --tip;
  }
  .has-tip > :first-child {
    anchor-name: --tip;
  }
  .tip,
  .tip.below,
  .tip.start,
  .tip.end {
    position: fixed;
    inset: auto;
    translate: none;
    margin: 8px 0;
    position-anchor: --tip;
    position-area: top;
    position-try-fallbacks: flip-block;
  }
  .tip.below {
    position-area: bottom;
  }
  .tip.start {
    position-area: top span-right;
  }
  .tip.end {
    position-area: top span-left;
  }
  .tip::after {
    display: none;
  }
}

/* An info button: a small round "i" that shows a tip */
.tip-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: help;
}
.tip-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.tip-btn .icon {
  width: 20px;
  height: 20px;
}

/* Popover cards: detail that opens over the page when a button is clicked (the popover
   attribute). The browser closes them on Esc and on a click elsewhere. They open in the
   middle of the screen, or next to their button where ui.js can anchor them. */
.pop {
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(75vh, 560px);
  padding: 16px 18px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 48px -18px rgba(0, 0, 0, 0.45);
}
.pop:popover-open {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pop::backdrop {
  background: rgba(10, 26, 28, 0.2);
}
.pop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.pop-head > :is(h2, h3, h4) {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}
.pop-head .icon-btn {
  margin: -8px -10px 0 0;
}
@supports (position-area: bottom) {
  .pop.anchored {
    inset: auto;
    margin: 6px 0;
    position-area: bottom span-right;
    position-try-fallbacks:
      flip-block,
      flip-inline,
      flip-block flip-inline;
  }
  .pop.anchored::backdrop {
    background: transparent;
  }
}

/* Dialogs: a box over a dimmed page for a task that needs the whole screen, such as the photo
   editor. The browser's own <dialog> opened with showModal() keeps the keyboard inside it,
   and Esc closes it. `.dialog-head`, `.dialog-body` and `.dialog-foot` are its parts. */
.dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px -24px rgba(0, 0, 0, 0.55);
}
.dialog[open] {
  display: flex;
  flex-direction: column;
}
.dialog::backdrop {
  background: rgba(7, 31, 32, 0.6);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 22px;
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
  font-size: 1.3rem;
}
.dialog-body {
  min-height: 0;
  padding: 20px 22px;
  overflow: auto;
}
.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.btn:hover {
  background: var(--accent-soft);
}
.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.btn.primary:hover {
  border-color: var(--accent-2);
  background: var(--accent-2);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--accent-soft);
}
.btn.small {
  min-height: 32px;
  padding: 4px 11px;
  font-size: 0.84rem;
}
.btn.big {
  min-height: 48px;
  padding: 11px 22px;
  font-size: 1rem;
}
.btn.danger {
  border-color: var(--red);
  color: var(--red);
}
.btn.danger:hover {
  background: var(--red-soft);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled:hover {
  background: transparent;
}
.btn.primary:disabled:hover {
  background: var(--accent);
}
.linkbtn {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.linkbtn:hover {
  text-decoration-thickness: 2px;
}

/* A button or link that's just an icon. Its words go in visually hidden text inside it,
   and usually in a tooltip too. `.small` is 32px; `.outline` gives it a border. */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}
.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}
.icon-btn .icon {
  width: 24px;
  height: 24px;
}
.icon-btn.small {
  width: 32px;
  height: 32px;
}
.icon-btn.small .icon {
  width: 20px;
  height: 20px;
}
.icon-btn.outline {
  border-color: var(--accent);
}
.btn .icon {
  width: 1.15em;
  height: 1.15em;
}

/* Busy: a spinner over the button's words while something happens (`.is-busy`, or
   aria-busy="true"). ui.js sets it for anything marked data-busy. */
.btn,
.icon-btn {
  --busy: var(--accent);
}
.btn.primary {
  --busy: var(--on-accent);
}
.btn.danger {
  --busy: var(--red);
}
:is(.btn, .icon-btn):is(.is-busy, [aria-busy="true"]) {
  position: relative;
  color: transparent;
  pointer-events: none;
}
:is(.btn, .icon-btn):is(.is-busy, [aria-busy="true"])::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid var(--busy);
  border-right-color: transparent;
  border-radius: 50%;
  animation: cp-spin 0.75s linear infinite;
}
@keyframes cp-spin {
  to {
    rotate: 360deg;
  }
}

/* ---------- Status: pills, workflow states, badges and tags ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}
.pill::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.p-red {
  background: var(--red-soft);
  color: var(--red);
}
.p-amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.p-green {
  background: var(--green-soft);
  color: var(--green);
}
.p-blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.p-neutral {
  background: var(--accent-soft);
  color: var(--accent);
}
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}
.s-new {
  border-color: var(--line-strong);
  background: var(--paper);
  color: var(--muted);
}
.s-go {
  background: var(--amber-soft);
  color: var(--amber);
}
.s-with {
  background: var(--accent-soft);
  color: var(--accent);
}
.s-ret {
  background: var(--red-soft);
  color: var(--red);
}
.s-ready {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.s-done {
  background: var(--green);
  color: var(--on-status);
}
.s-na {
  border-color: var(--line-strong);
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}
.badge-int,
.badge-vis {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-int {
  background: var(--purple);
  color: var(--on-status);
}
.badge-vis {
  border-color: var(--blue);
  color: var(--blue);
}
.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.marking {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--brass);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* ---------- Figures ---------- */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi .v {
  color: var(--ink);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .k,
.kpi .l {
  color: var(--muted);
  font-size: 0.82rem;
}
.card.kpi {
  align-self: stretch;
  position: relative;
  overflow: hidden;
}
.card.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

/* ---------- Journey stepper ---------- */
.journey {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  margin: 0;
  padding: 0;
  list-style: none;
}
.journey li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0 4px;
  color: var(--muted);
  text-align: center;
}
/* The line joining each step to the one before */
.journey li::before {
  content: "";
  position: absolute;
  top: 11px;
  left: -50%;
  right: 50%;
  height: 2px;
  background: var(--line-strong);
}
.journey li:first-child::before {
  display: none;
}
.journey li.j-done::before,
.journey li.j-now::before {
  background: var(--accent);
}
.journey a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}
.journey a:hover .j-c,
.journey a:hover .j-n {
  color: var(--accent);
  text-decoration: underline;
}
.j-dot {
  position: relative;
  z-index: 1;
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}
.j-done .j-dot {
  border-color: var(--accent);
  background: var(--accent);
}
/* A tick, drawn with borders */
.j-done .j-dot::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid var(--on-accent);
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.j-now .j-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.j-now .j-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.j-n {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}
.j-c {
  font-size: 0.8rem;
  line-height: 1.3;
}
.j-n + .j-c {
  font-size: 0.75rem;
}
.j-now .j-c:first-of-type,
.j-now .j-n {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Tables ---------- */
.tablewrap {
  max-width: 100%;
  overflow-x: auto;
}
table.plain,
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.plain caption,
table.table caption {
  padding-bottom: 8px;
  text-align: left;
  font-weight: 700;
}
table.plain :is(th, td),
table.table :is(th, td) {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.plain thead th,
table.table thead th {
  border-bottom-color: var(--line-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
table.plain tbody th,
table.table tbody th {
  font-weight: 600;
}
table.plain tbody tr:last-child > *,
table.table tbody tr:last-child > * {
  border-bottom: 0;
}
table.plain td.num,
table.plain th.num {
  text-align: right;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: inset 0 -1px 0 var(--line-strong);
  scrollbar-width: thin;
}
.tabs a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 9px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover {
  border-bottom-color: var(--line-strong);
  color: var(--ink);
}
.tabs a[aria-current="page"],
.tabs a.on {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.tabs .tag {
  color: inherit;
}
/* Tabs and the rail's links can sit in a scrolling row, which would clip a ring outside them */
.tabs a:focus-visible,
.nav a:focus-visible {
  outline-offset: -3px;
}

/* ---------- Forms ---------- */
form {
  margin: 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 44rem;
  min-width: 0;
}
.field > label,
.field > .label,
fieldset > legend {
  font-weight: 600;
}
.field > label .why {
  margin-top: 2px;
}
input:is([type="text"], [type="email"], [type="date"], [type="number"], [type="search"], [type="url"], [type="tel"], [type="password"], :not([type])),
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
input[type="number"],
input[type="date"] {
  max-width: 16rem;
}
textarea {
  min-height: 104px;
  resize: vertical;
}
input[type="file"] {
  max-width: 100%;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.choice input {
  flex: none;
  margin-top: 2px;
}
fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
fieldset > legend {
  margin-bottom: 6px;
  padding: 0;
}
.yn {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.yn > :not(legend, label) {
  flex-basis: 100%;
  margin-bottom: 8px;
}
.yn > label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 18px 8px 12px;
  border: 1px solid var(--field-line);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.yn > label + label {
  margin-left: -1px;
}
.yn > label:first-of-type {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.yn > label:last-of-type {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.yn > label:has(input:checked) {
  z-index: 1;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.yn > label:has(input:checked) input {
  accent-color: var(--on-accent);
}
.yn > label:has(input:focus-visible) {
  z-index: 2;
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.yn > label input:focus-visible {
  outline: 0;
}
.field.has-error {
  padding-left: 14px;
  border-left: 4px solid var(--red);
}
.err {
  margin: 0;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 700;
}
.field.has-error :is(input, select, textarea),
[aria-invalid="true"] {
  border-color: var(--red);
}
.req {
  margin-left: 4px;
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
input[type="range"] {
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* The photo editor (profiles/profile.html, photo-editor.js): a square frame showing the photo
   inside the circle it's shown in, its controls, and previews at the sizes ClearPath uses */
.pe-body {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 28px;
}
.pe-tool {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.pe-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--sunk);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.pe-frame.is-dragging {
  cursor: grabbing;
}
.pe-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.pe-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pe-row input[type="range"] {
  flex: 1;
}
.pe-label {
  flex: none;
  font-size: 0.88rem;
  font-weight: 600;
}
.pe-value {
  flex: none;
  min-width: 7.5em;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.pe-previews {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  min-width: 0;
}
.pe-previews h3 {
  font-size: 0.95rem;
}
.pe-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
}
.pe-preview figcaption {
  color: var(--muted);
  font-size: 0.82rem;
}
/* The top bar's account button, as it will look with this photo */
.pe-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 14px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
}

/* ---------- Documents (readiness case, Letter of Authority, guides) ---------- */
.doc {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 820px;
  padding: 44px 52px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  box-shadow:
    0 1px 0 var(--line),
    0 12px 32px -24px rgba(0, 0, 0, 0.35);
  overflow-wrap: break-word;
}
.doc > .marking {
  display: block;
  align-self: stretch;
  padding: 0;
  border: 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.doc h1 {
  font-size: 1.9rem;
}
.doc h2 {
  font-size: 1.35rem;
}
.doc h3 {
  font-size: 1rem;
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.doc :is(th, td) {
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  text-align: left;
  vertical-align: top;
}
.doc th {
  background: var(--sunk);
  font-weight: 700;
}
.doc ol,
.doc ul {
  margin: 0;
}
.doc .draft {
  color: var(--muted);
  font-style: italic;
}
.doc .sign {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 10px;
  border-top: 1px solid var(--line-strong);
}

/* Document cards (the guides): a miniature of the document's first page, its title, and a
   foot with a label and a download icon. The `.peek` (the summary) slides over the miniature
   on hover and keyboard focus. The title's link (`.stretch`) makes the whole card clickable;
   the foot stays above it, so its own links still work. */
.doc-card {
  --thumb: 150px;
  position: relative;
  gap: 0;
  padding: 0;
  overflow: hidden;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.doc-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 14px 30px -22px rgba(0, 0, 0, 0.5);
}
.doc-card:has(.stretch:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.doc-card .stretch:focus-visible {
  outline: 0;
}
.doc-card .stretch::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.doc-card > .thumb {
  height: var(--thumb);
  padding: 16px 22px 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgba(14, 61, 61, 0.05) 1px, transparent 1px) 0 0 / 14px 14px,
    linear-gradient(90deg, rgba(14, 61, 61, 0.05) 1px, transparent 1px) 0 0 / 14px 14px,
    var(--sunk);
}
.doc-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px 0;
}
.doc-card-body h3 {
  /* Room for two lines, so cards match across groups as well as within one */
  min-height: 2.6em;
  font-size: 0.98rem;
  line-height: 1.3;
}
.doc-card-body h3 a {
  color: var(--ink);
  text-decoration: none;
}
.doc-card:hover .doc-card-body h3 a {
  color: var(--accent);
}
.doc-card > .card-foot {
  position: relative;
  z-index: 2;
  padding: 10px 12px 12px 18px;
}
.peek {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  height: var(--thumb);
  margin: 0;
  padding: 16px 18px;
  overflow: hidden;
  /* Nearly solid, so the words keep their contrast over the white miniature */
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.45;
  opacity: 0;
  translate: 0 6px;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    translate 0.15s ease;
}
.doc-card:is(:hover, :has(:focus-visible)) .peek {
  opacity: 1;
  translate: 0 0;
}

/* The miniature itself: a sheet of paper whose headings come from the document, with grey
   lines for its text. It's decoration (aria-hidden="true"), never read out. It stays white in
   the dark theme, because it pictures a Word file (as the guide page's own paper does). */
.doc-thumb {
  --paper-ink: #1f2937;
  --paper-muted: #5b6472;
  --paper-line: #cfc8b8;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 10px 14px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: #ffffff;
  color: var(--paper-muted);
  box-shadow: 0 6px 16px -10px rgba(0, 0, 0, 0.35);
  color-scheme: light;
  font-size: 7px;
  line-height: 1.3;
  transition: translate 0.2s ease;
}
.doc-card:hover .doc-thumb {
  translate: 0 -3px;
}
.doc-thumb > * {
  flex: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dt-marking {
  align-self: center;
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.dt-title {
  margin: 2px 0 3px;
  color: var(--paper-ink);
  font-family: var(--font-heading);
  font-size: 11px;
  line-height: 1.15;
  white-space: normal;
}
.dt-h {
  margin-top: 2px;
  color: var(--paper-ink);
  font-weight: 700;
}
.dt-lines {
  height: 13px;
  background: repeating-linear-gradient(
    to bottom,
    var(--paper-line) 0 1.5px,
    transparent 1.5px 4.5px
  );
}
.dt-lines:nth-of-type(even) {
  width: 82%;
}

/* ---------- Comments and the audit trail ---------- */
.log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}
.log > li + li {
  margin-top: 0;
}
.log-e {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
}
/* Who, a badge and when share the first line (when wraps under if there's no room);
   everything else takes a line of its own */
.log-e > * {
  flex: 1 1 100%;
  min-width: 0;
}
.log-e > :is(.who, .badge-int, .badge-vis, .tag, .state, .when) {
  flex: 0 0 auto;
}
.log-e > .who {
  font-weight: 700;
}
.log-e > .when {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}
.log-e > :is(p, ul, ol) + :is(p, ul, ol) {
  margin-top: 0;
}
.log-e.int,
.log-e:has(> .badge-int) {
  border-left-color: var(--purple);
  background: var(--purple-soft);
}
.log-e.ret {
  border-left-color: var(--red);
}
.log.audit .log-e {
  border-left-color: var(--line-strong);
}
/* A comment thread's replies sit one level in, and keep the thread's colour (decision 0042) */
.log.replies {
  padding-left: 16px;
}
.log.replies .log-e {
  border-left-color: inherit;
}
.thread > details.reply > summary {
  cursor: pointer;
  color: var(--blue);
}

/* ---------- Empty states ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.empty > :is(h2, h3) {
  color: var(--ink);
}
.empty > :is(p, ul, ol) + :is(p, ul, ol) {
  margin-top: 0;
}

/* ---------- Messages ---------- */
.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.messages > .callout + .callout {
  margin-top: 0;
}

/* ---------- Front page (signed out) ---------- */
.front {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.15fr);
  min-height: 100vh;
}
.front-brand {
  --focus: var(--rail-focus);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: 40px clamp(24px, 4vw, 56px);
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 70% at 50% -15%, rgba(22, 63, 67, 0.9), transparent 70%),
    radial-gradient(ellipse 80% 55% at 8% 105%, rgba(10, 47, 47, 0.95), transparent 72%),
    linear-gradient(180deg, var(--rail-1) 0%, var(--rail-2) 100%);
  color: var(--rail-ink);
}
/* Faint blueprint grid, as on callandor.io */
.front-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(198, 205, 211, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(198, 205, 211, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 30%, transparent 85%);
  pointer-events: none;
}
.front-brand > * {
  position: relative;
}
.front-crest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin: auto 0;
  text-align: center;
}
.front-crest .cl-mark {
  height: clamp(110px, 18vh, 180px);
}
.front-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem);
  letter-spacing: 0.24em;
  line-height: 1.1;
  text-transform: uppercase;
  color: #ffffff;
}
.front-by {
  margin-top: -4px;
  color: var(--rail-muted);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}
.front-brand .cl-strap {
  justify-content: center;
}
.front-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  width: 100%;
  max-width: 720px;
  padding: 56px clamp(24px, 5vw, 72px);
}
.front-main h1 {
  max-width: 20ch;
  font-size: clamp(1.9rem, 1.3rem + 2vw, 2.8rem);
  line-height: 1.12;
}
.front-main .lede {
  margin-top: 0;
}
.phases {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px solid var(--line-strong);
  list-style: none;
  counter-reset: phase;
}
.phases li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 14px 14px 0 0;
  counter-increment: phase;
  font-size: 0.85rem;
  color: var(--muted);
}
.phases li::before {
  content: counter(phase, decimal-leading-zero);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.phases strong {
  color: var(--ink);
  font-size: 0.95rem;
}

/* ---------- Older templates (kept working until they move to the classes above) ---------- */
.note {
  color: var(--muted);
  font-size: 0.88rem;
}
.list {
  padding-left: 1.2em;
}
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 18px;
  margin: 0;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.upload,
.review {
  display: grid;
  gap: 10px;
  max-width: 44rem;
}
/* A file's preview (documents/preview.html): an image, or a PDF's pages on canvases. */
.preview img,
.preview canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.preview canvas + canvas {
  margin-top: 12px;
}
/* A defence cell's protective marking, above and below a preview (decision 0034). */
.marking {
  margin: 0;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.06em;
}
/* The uploader's queue (static/clearpath/upload.js): one row per file. */
.upload-queue {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.upload-queue:empty {
  display: none;
}
.upload-queue li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
}
.upload-queue .name {
  overflow-wrap: anywhere;
}
.upload-queue progress {
  grid-column: 1;
  width: 100%;
  accent-color: var(--accent);
}
.upload-queue .state {
  grid-column: 1 / -1;
  color: var(--muted);
}
.message {
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.message.error {
  border-left-color: var(--red);
  background: var(--red-soft);
}

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .grid4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 980px) {
  :root {
    --gutter: 20px;
  }
  /* One column: the rail keeps its own height and the page takes the rest */
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  /* The rail becomes a bar across the top: the brand, then the links in one row */
  .rail {
    position: static;
    height: auto;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding: 10px var(--gutter) 0;
  }
  .brand {
    padding: 2px 0;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
  }
  .cl-mark {
    height: 26px;
  }
  .rail .nav {
    flex-basis: 100%;
    flex-direction: row;
    gap: 2px;
    margin: 0 calc(-1 * var(--gutter));
    padding: 0 var(--gutter) 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  }
  .rail .nav-label,
  .rail-foot {
    display: none;
  }
  .rail .nav a {
    flex: none;
    white-space: nowrap;
  }
  .rail .nav a[aria-current="page"]::before,
  .rail .nav a.on::before {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: -6px;
    width: auto;
    height: 3px;
    border-radius: 3px 3px 0 0;
  }
  .rail:not(:has(.nav)) {
    padding-bottom: 10px;
  }
  .grid2,
  .front {
    grid-template-columns: minmax(0, 1fr);
  }
  .front {
    grid-template-rows: auto minmax(0, 1fr);
  }
  .grid3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .front-brand {
    gap: 20px;
    padding: 28px var(--gutter);
  }
  .front-crest {
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    text-align: left;
  }
  .front-crest .cl-mark {
    height: 72px;
  }
  .front-name {
    font-size: 1.5rem;
  }
  .front-by {
    margin-top: 2px;
  }
  .front-main {
    max-width: none;
    padding: 32px var(--gutter) 48px;
  }
}
@media (max-width: 640px) {
  .dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
  .dialog-head,
  .dialog-body,
  .dialog-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
  .pe-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .pe-tool {
    align-items: stretch;
  }
  .pe-frame {
    width: min(100%, 320px);
    align-self: center;
  }
  .pe-previews {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .pe-previews h3 {
    flex-basis: 100%;
  }
  :root {
    --gutter: 16px;
  }
  .content {
    padding-top: 22px;
    padding-bottom: 40px;
    gap: 16px;
  }
  .topbar {
    min-height: 0;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  /* Search takes the row; the account button shrinks to the photo, its words kept for
     screen readers */
  .tb-end {
    width: 100%;
    margin: 0;
  }
  .tb-search {
    flex: 1 1 auto;
    width: auto;
  }
  .account-btn {
    padding-right: 4px;
  }
  .account-btn .who {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .account-menu {
    inset: 112px var(--gutter) auto auto;
  }
  .card {
    padding: 16px;
  }
  .grid3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .doc {
    padding: 24px 18px;
  }
  .doc table,
  table.table {
    display: block;
    overflow-x: auto;
  }
  .journey .j-c {
    font-size: 0.7rem;
  }
  .journey .j-n + .j-c {
    display: none;
  }
  .phases {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 14px;
  }
  .front-crest .cl-mark {
    height: 56px;
  }
  .front-brand .cl-strap {
    display: none;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
}
@media (max-width: 480px) {
  /* Two document cards a row on a phone, so a long list of guides scrolls half as far */
  .cards:has(> .doc-card) {
    --card-min: 140px;
    gap: 10px;
  }
  .doc-card {
    --thumb: 112px;
  }
  .doc-card > .thumb {
    padding: 10px 12px 0;
  }
  .doc-card-body {
    padding: 10px 12px 0;
  }
  .doc-card-body h3 {
    font-size: 0.88rem;
  }
  .doc-card > .card-foot {
    flex-wrap: nowrap;
    gap: 4px;
    padding: 6px 6px 8px 12px;
  }
  .doc-card > .card-foot .icon-btn {
    flex: none;
    width: 34px;
    height: 34px;
  }
  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .facts dd + dt {
    margin-top: 8px;
  }
}

/* ---------- Motion and forced colours ---------- */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
  .skip {
    transition: transform 0.15s ease;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* A still, dotted ring says "busy" without spinning */
  :is(.btn, .icon-btn):is(.is-busy, [aria-busy="true"])::after {
    animation: none;
    border-style: dotted;
    border-right-color: var(--busy);
  }
  .doc-card:hover .doc-thumb,
  .peek {
    translate: none;
  }
}
/* Windows high contrast: draw the edges that backgrounds alone were showing */
@media (forced-colors: active) {
  .pill,
  .state,
  .badge-int,
  .tag,
  .callout,
  .card,
  .empty {
    border: 1px solid CanvasText;
  }
  .nav a[aria-current="page"],
  .tabs a[aria-current="page"] {
    outline: 2px solid LinkText;
  }
  .j-dot,
  .j-done .j-dot::after {
    border-color: CanvasText;
  }
  .tip,
  .pop,
  .menu,
  .dialog,
  .pe-frame {
    border: 1px solid CanvasText;
  }
  .chips a[aria-current],
  .menu a[aria-current="page"] {
    outline: 2px solid LinkText;
  }
  :is(.btn, .icon-btn):is(.is-busy, [aria-busy="true"])::after {
    border-color: ButtonText;
    border-right-color: transparent;
  }
}

/* ---------- Journey pages: the project head's key facts, task lists, folds ----------
   Added with the JSP 453 journey. `.sumline` is a strip of short facts (a <dl> whose pairs
   are each wrapped in a <div>); `.tasks` is a to-do list on the home page and overview;
   `.doc-tabs` switches a generated document between authorities. */
.sumline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 0;
}
.sumline > div {
  min-width: 0;
}
.sumline dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sumline dd {
  margin: 2px 0 0;
  font-weight: 600;
}
.sumline dd .why {
  font-weight: 400;
}
.tasks,
.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.tasks li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.tasks li:first-child {
  border-top: 0;
  padding-top: 0;
}
.plain-list li {
  padding: 4px 0;
}
.fold {
  margin-top: 18px;
}
.fold > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.fold[open] > summary {
  margin-bottom: 10px;
}
.doc-tabs {
  display: flex;
  gap: 4px;
}
.doc-tabs a {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
.doc-tabs a[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
}
@media print {
  .doc-tabs {
    display: none;
  }
}

/* ---------- To do matrix, rail lists, summaries and popovers ----------
   Added after Josh's click-through (6 November 2026). `.chip` is one control's mark as a
   small square (G, A, R, N/A; blank where it doesn't apply), used in the matrix, its key and
   the column counts. `.tip-layer` is the floating summary that tips.js shows for `.tipped`
   elements. `.pop` styles native popovers; tips.js moves an open one next to its button
   (`.is-anchored`), and without script it stays centred. */
.chip {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
}
button.chip {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
button.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(14, 61, 61, 0.25);
}
.c-green {
  background: var(--green);
  color: var(--surface);
}
.c-amber {
  background: var(--amber);
  color: var(--surface);
}
.c-red {
  background: var(--red);
  color: var(--surface);
}
.c-blue {
  background: var(--blue);
  color: var(--surface);
}
.c-none {
  border: 1px dashed var(--line-strong);
  background: transparent;
}
/* Needed at a later stage, or good practice: shown, but lighter, as it doesn't count yet */
.chip.is-later {
  opacity: 0.55;
}
.chip-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--aqua);
}
.todo-head {
  align-items: flex-end;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.8rem;
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .chip {
  min-width: 26px;
  height: 20px;
  font-size: 0.65rem;
}
.waiting {
  margin: 0 0 18px;
}
.waiting > summary .count,
.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.6;
}
.waiting-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px 28px;
}
.waiting-lists h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

/* The floating summary and the popovers */
.tip-layer {
  position: fixed;
  z-index: 1000;
  max-width: 320px;
  padding: 8px 11px;
  border-radius: var(--radius);
  background: var(--navy);
  color: #ffffff;
  font-size: 0.8rem;
  line-height: 1.45;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}
.tip-layer[hidden] {
  display: none;
}
/* Popover cards are the shared .pop (Containers section, placed by ui.js); these are only
   the rail's booking card's own parts. The rail's text styles mustn't leak into the card. */
.rail .pop {
  text-align: left;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}
.pop > :is(p, ul) {
  margin: 0;
}
.pop .pop-title {
  font-weight: 800;
}
.pop .pop-sub {
  font-weight: 700;
  font-size: 0.86rem;
}
.pop .pop-note {
  padding: 6px 10px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.86rem;
}
.pop-docs {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}
.pop-docs li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}
.pop a {
  color: var(--accent);
}
.pop .btn.primary {
  color: var(--on-accent);
}

/* The rail: Projects opens to list your projects */
.nav-group > summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--rail-ink);
  font-size: 0.92rem;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
}
.nav-group > summary::-webkit-details-marker {
  display: none;
}
.nav-group > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.nav-group[open] > summary::after {
  transform: rotate(45deg);
}
.nav-group > summary:hover {
  background: var(--rail-hover);
}
.nav-group > summary:focus-visible {
  outline: 2px solid var(--rail-focus);
  outline-offset: 2px;
}
.nav-group > summary.on {
  color: #ffffff;
  font-weight: 700;
}
.nav-group .nav-count {
  margin-left: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}
.nav-sub {
  margin: 2px 0 6px 12px;
  padding: 0 0 0 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  list-style: none;
}
.nav .nav-sub a {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.86rem;
}
.nav .nav-sub a.on::before {
  left: -9px;
}
.nav .nav-sub .nav-all {
  color: var(--rail-muted);
}

/* The rail: each board's next sitting */
.rail-boards {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.rb-head {
  margin: 0 0 6px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.rail-foot .rb-head a {
  color: var(--rail-muted);
  text-decoration: none;
}
.rail-boards ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.rb {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rail-foot .rb > a {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  color: var(--rail-muted);
  font-weight: 400;
  text-decoration: none;
}
.rail-foot .rb > a:hover {
  background: var(--rail-hover);
  color: var(--rail-ink);
}
.rb-grants .rb-name,
.rb-booked .rb-name {
  color: #ffffff;
  font-weight: 700;
}
.rb-date {
  font-variant-numeric: tabular-nums;
}
.rb-dot {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.rb-dot::before {
  content: "";
  display: block;
  width: 9px;
  height: 9px;
  margin: auto;
  border-radius: 50%;
  background: #5fd08a;
  box-shadow: 0 0 0 3px rgba(95, 208, 138, 0.25);
}
.rb-dot:focus-visible {
  outline: 2px solid var(--rail-focus);
}

/* Boards pages */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.bcard h2 {
  margin: 0;
}
.bcard h2 a {
  color: inherit;
  text-decoration: none;
}
.bcard-grants {
  border-top: 3px solid var(--accent);
}
.sittings {
  margin: 0;
  padding: 0;
  list-style: none;
}
.sittings li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.sittings li:first-child {
  border-top: 0;
}
.s-date {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tag-booked {
  border-color: var(--green);
  color: var(--green);
  text-decoration: none;
}
form.inline {
  display: inline;
}
@media (prefers-reduced-motion: reduce) {
  button.chip,
  .nav-group > summary::after {
    transition: none;
  }
  button.chip:hover {
    transform: none;
  }
}
@media print {
  .tip-layer,
  .pop {
    display: none;
  }
}

/* ---------- Project pages: the HLD link, "About the project", the ribbon, the TRRA cards ----------
   `.ragbar` is the readiness case's stacked bar (SVG rectangles, partials/ragbar.html).
   `.ribbon` boxes the controls still to bring to amber; `.rbox` is one of them. `.tcard` is
   one control on the TRRA's card view, edged in its colour. */
.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.title-row h1 {
  margin-bottom: 0;
}
.icon {
  flex: none;
  width: 18px;
  height: 18px;
}
.hld-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
}
.hld-link:hover {
  border-color: var(--accent);
}
.about {
  margin: 4px 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.about > summary {
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.about[open] > summary {
  border-bottom: 1px solid var(--line);
}
.about-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.about-body > .stack > p {
  margin: 0;
}
.about-edit {
  margin-top: 0;
}
.about-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 18px;
}
.about-fields .wide {
  grid-column: 1 / -1;
}
.ragbar-wrap {
  display: grid;
  gap: 10px;
}
.ragbar {
  display: block;
  width: 100%;
  height: 14px;
  border-radius: 99px;
  overflow: hidden;
}
.seg-track {
  fill: var(--line);
}
.seg-green {
  fill: var(--green);
}
.seg-amber {
  fill: var(--amber);
}
.seg-red {
  fill: var(--red);
}
.seg-blue {
  fill: var(--blue);
}
.ragbar-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.82rem;
}
.ragbar-key li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ribbon {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--amber);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--amber-soft);
}
.ribbon h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--amber);
}
.ribbon-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rbox {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.rbox:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(14, 61, 61, 0.12);
}
.rbox-text {
  display: grid;
  min-width: 0;
}
.rbox-name {
  font-weight: 700;
  line-height: 1.3;
}
.rbox-meta {
  color: var(--muted);
  font-size: 0.78rem;
}
.trra-switch {
  margin-bottom: 14px;
}
.trra-domain h2 {
  margin: 22px 0 10px;
}
.trra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.trra-grid > li {
  display: flex;
}
.tcard {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 132px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.tcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(14, 61, 61, 0.14);
}
.t-green {
  border-top-color: var(--green);
}
.t-amber {
  border-top-color: var(--amber);
}
.t-red {
  border-top-color: var(--red);
}
.t-blue {
  border-top-color: var(--blue);
}
/* A control first needed at a later stage: quieter, but never faded, so its text keeps
   WCAG 2.2 AA contrast (axe, tests/test_browser.py; opacity took the owner label to 2.6:1). */
.tcard.is-later {
  background: var(--paper);
  border-style: dashed;
}
.tcard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tcard-owner {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-align: right;
}
.tcard-name {
  font-weight: 800;
  line-height: 1.3;
}
.tcard-docs {
  display: grid;
  gap: 4px;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.78rem;
}
.docbar {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  overflow: hidden;
}
.docbar-track {
  fill: var(--line);
}
.docbar-fill {
  fill: var(--green);
}
.tcard-note {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
}
.tcard .tag {
  align-self: flex-start;
}
@media (prefers-reduced-motion: reduce) {
  .rbox,
  .tcard {
    transition: none;
  }
  .tcard:hover {
    transform: none;
  }
}
@media print {
  .about,
  .trra-switch {
    display: none;
  }
}

/* ---------- Search results ---------- */
.search-form {
  display: flex;
  gap: 8px;
  max-width: 680px;
  margin-bottom: 18px;
}
.search-form input {
  flex: 1;
}
.search-results {
  display: grid;
  gap: 22px;
}
.search-results h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.search-results .tag {
  text-decoration: none;
}
mark {
  padding: 0 2px;
  border-radius: 2px;
  background: var(--amber-soft);
  color: inherit;
  font-weight: 700;
}

/* ---------- To do heat map ----------
   The RAG colours take their tone from the Callandor palette (a teal-leaning green, brass amber,
   a brick red and a slate blue for not applicable) while staying plainly red, amber and green.
   Text on each passes WCAG AA. Used by the heat map, the chips, the stacked bar and the TRRA
   cards. `.hcell` is one filled cell; `.is-yours` gives it a bold border; `.is-later` is a pale
   tint for controls not needed yet. matrix.js adds `.is-hot`, `.is-near` and `.is-cross`. */
:root {
  --rag-green: #2f7a5a;
  --rag-amber: #d9a441;
  --rag-red: #b0463c;
  --rag-blue: #4b7189;
  --rag-on: #ffffff;
  --rag-on-amber: #2b2006;
  --rag-yours: #0b2526;
}
@media (prefers-color-scheme: dark) {
  :root {
    --rag-yours: #f5f7f8;
  }
}
.c-green,
.f-green {
  background: var(--rag-green);
  color: var(--rag-on);
}
.c-amber,
.f-amber {
  background: var(--rag-amber);
  color: var(--rag-on-amber);
}
.c-red,
.f-red {
  background: var(--rag-red);
  color: var(--rag-on);
}
.c-blue,
.f-blue {
  background: var(--rag-blue);
  color: var(--rag-on);
}
.seg-green,
.docbar-fill {
  fill: var(--rag-green);
}
.seg-amber {
  fill: var(--rag-amber);
}
.seg-red {
  fill: var(--rag-red);
}
.seg-blue {
  fill: var(--rag-blue);
}
.t-green {
  border-top-color: var(--rag-green);
}
.t-amber {
  border-top-color: var(--rag-amber);
}
.t-red {
  border-top-color: var(--rag-red);
}
.t-blue {
  border-top-color: var(--rag-blue);
}
.todo-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 24px;
  margin-bottom: 10px;
}
.todo-head h1 {
  margin: 0;
}
.todo-head .legend {
  margin: 0;
}
.key {
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
}
.key.f-none {
  border: 1px dashed var(--line-strong);
  background: transparent;
}
.key.is-yours {
  box-shadow: inset 0 0 0 2px var(--rag-yours);
}
.key-text {
  font-style: italic;
}
.waiting {
  margin: 0 0 10px;
  padding: 8px 14px;
}
.waiting[open] {
  padding-bottom: 14px;
}
.waiting > summary {
  margin: 0;
}
.matrix-wrap {
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  min-height: 300px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.heat {
  border-collapse: separate;
  border-spacing: 2px;
  background: var(--surface);
  font-size: 0.78rem;
}
.heat th,
.heat td {
  padding: 0;
  text-align: left;
}
.heat thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 8px 6px 6px;
  background: var(--surface);
  box-shadow: 0 2px 0 var(--line-strong);
  vertical-align: bottom;
}
.heat .h-corner {
  left: 0;
  z-index: 6;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.h-col {
  min-width: 104px;
  max-width: 160px;
  transition: background-color 0.12s ease;
}
.h-col.is-cross {
  background: var(--accent-soft);
}
.h-name {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}
.h-name:hover {
  text-decoration: underline;
}
.h-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
.h-count {
  min-width: 24px;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}
.h-status {
  display: block;
  width: 100%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}
.h-status.is-ready {
  color: var(--rag-green);
}
.h-step {
  display: inline-block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
}
.heat .h-group {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 22px;
  min-width: 22px;
  border-radius: 2px;
  background: var(--sunk);
  vertical-align: middle;
}
.h-group > span[aria-hidden] {
  display: block;
  margin: 0 auto;
  padding: 6px 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.heat .h-row {
  position: sticky;
  left: 24px;
  z-index: 3;
  height: 22px;
  min-width: 220px;
  max-width: 260px;
  padding: 0 10px 0 6px;
  background: var(--surface);
  font-weight: 600;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.h-row.is-cross {
  background: var(--accent-soft);
  color: var(--accent);
}
.h-control {
  display: block;
  max-width: 248px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.heat tbody + tbody > tr:first-child > * {
  border-top: 6px solid var(--surface);
}
.heat .hc {
  position: relative;
  height: 22px;
  min-width: 104px;
}
.hcell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0 4px;
  border: 0;
  border-radius: 2px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
span.hcell {
  cursor: default;
}
.hcell.f-none {
  background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line) 5px 6px);
}
.hcell.is-later.f-green,
.drawer-band.is-later.f-green {
  background: color-mix(in srgb, var(--rag-green) 28%, var(--surface));
  color: var(--ink);
}
.hcell.is-later.f-amber,
.drawer-band.is-later.f-amber {
  background: color-mix(in srgb, var(--rag-amber) 28%, var(--surface));
  color: var(--ink);
}
.hcell.is-later.f-red,
.drawer-band.is-later.f-red {
  background: color-mix(in srgb, var(--rag-red) 28%, var(--surface));
  color: var(--ink);
}
.hcell.is-later.f-blue,
.drawer-band.is-later.f-blue {
  background: color-mix(in srgb, var(--rag-blue) 28%, var(--surface));
  color: var(--ink);
}
.hcell.is-yours {
  box-shadow: inset 0 0 0 2.5px var(--rag-yours);
  font-weight: 800;
}
button.hcell:hover,
.hcell.is-hot {
  z-index: 2;
  transform: scale(1.14);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}
.hcell.is-yours:hover,
.hcell.is-yours.is-hot {
  box-shadow:
    inset 0 0 0 2.5px var(--rag-yours),
    0 4px 12px rgba(0, 0, 0, 0.28);
}
.hcell.is-near {
  z-index: 1;
  transform: scale(1.05);
}
.hcell:focus-visible {
  z-index: 2;
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.tip-layer {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.tip-layer.is-in {
  opacity: 1;
  transform: none;
}

/* The drawer a cell opens: a panel on the right, or a sheet from the bottom on a phone */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(400px, 100vw);
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 18px 20px 0;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: -14px 0 32px rgba(0, 0, 0, 0.18);
  overflow-y: auto;
  font-size: 0.9rem;
  text-align: left;
}
.drawer:popover-open {
  animation: drawer-in 0.22s ease-out;
}
@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
}
.drawer::backdrop {
  background: rgba(10, 26, 28, 0.18);
}
.drawer-head {
  position: relative;
  padding-right: 40px;
}
.drawer-kicker {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.drawer-kicker a {
  color: var(--accent);
}
.drawer h2 {
  margin: 2px 0 12px;
  font-size: 1.25rem;
}
.drawer-x {
  position: absolute;
  top: -6px;
  right: -8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.drawer-x:hover {
  background: var(--accent-soft);
  color: var(--ink);
}
.drawer-band {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-weight: 800;
}
.drawer-next {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.drawer-next.is-yours {
  border: 2px solid var(--rag-yours);
}
.drawer-facts {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}
.drawer-facts > div {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px;
}
.drawer-facts dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.drawer-facts dd {
  margin: 0;
}
.drawer-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  font-style: italic;
}
.drawer-sub {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 16px 0 6px;
  font-size: 0.95rem;
}
.drawer-docs {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}
.drawer-docs li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.drawer-docs a {
  color: var(--accent);
}
.drawer-go {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px -20px 0;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
@media (max-width: 700px) {
  .matrix-wrap {
    max-height: calc(100dvh - 120px);
  }
  .heat .h-row {
    min-width: 128px;
    max-width: 150px;
  }
  .h-control {
    max-width: 138px;
  }
  .h-col,
  .heat .hc {
    min-width: 84px;
  }
  .drawer {
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    max-height: 82dvh;
    border-left: 0;
    border-top: 1px solid var(--line-strong);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -14px 32px rgba(0, 0, 0, 0.2);
  }
  .drawer:popover-open {
    animation-name: sheet-in;
  }
  @keyframes sheet-in {
    from {
      opacity: 0;
      transform: translateY(40px);
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .hcell,
  .h-col,
  .heat .h-row,
  .tip-layer {
    transition: none;
  }
  button.hcell:hover,
  .hcell.is-hot,
  .hcell.is-near {
    transform: none;
  }
  .drawer:popover-open {
    animation: none;
  }
}
@media print {
  .matrix-wrap {
    max-height: none;
    overflow: visible;
  }
  .drawer {
    display: none;
  }
}

/* Narrow screens: the rail is a bar across the top, so Projects is a plain link there */
.nav .nav-narrow {
  display: none;
}
@media (max-width: 980px) {
  .nav .nav-narrow {
    display: flex;
  }
  .nav .nav-group {
    display: none;
  }
}

/* ---------- What needs you today (public/today.py) ---------- */
.today-list > li {
  padding-left: 10px;
  border-left: 3px solid var(--line-strong);
}
.today-list > li.today-red {
  border-left-color: var(--red);
}
.today-list > li.today-amber {
  border-left-color: var(--amber, var(--line-strong));
}
