

/* ============================================================================
   Design tokens and global control rules: docs/design/tokens.css, verbatim
   (tests/design-tokens.test.ts holds the two in step). Source of truth is
   docs/design/stratum.tokens.json; the rules are docs/design/DESIGN.md.
   The standalone auth pages reference these same custom properties, so renames
   here must be mirrored in src/routes/{login,signup,email-auth}.tsx (the
   deprecated aliases at the end of :root exist for them).
   ========================================================================== */

/* The reset comes before the token block's control rules, not after: those
   are :where() rules with no specificity, so a later reset zeroed every
   input's and select's padding and put the text against the border. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* The UI is dark-only today. This line makes every native control
     (select, date input, scrollbar, checkbox) render in its dark form,
     which is what fixes the white branch <select> on iOS. Remove only when
     a light theme ships and sets `light dark`. */
  color-scheme: dark;

  /* ---- Surfaces: elevation is expressed by surface step, not shadow ---- */
  --bg-page: #0a0a0a;     /* level 0: page */
  --bg-panel: #0d0d0d;    /* level 0.5: nav bar, inset code panes */
  --bg-card: #111111;     /* level 1: cards */
  --bg-raised: #1a1a1a;   /* level 2: controls, badges, inline code, hover fill */
  --bg-overlay: #1f1f1f;  /* level 3: menus, popovers, the only shadowed surface */
  --bg-hover: #222222;    /* hover fill on level-2 controls */

  /* ---- Borders ----
     Decorative structure (cards, dividers) may be low contrast.
     Anything that identifies a control's boundary or state must reach 3:1
     (WCAG 2.2 SC 1.4.11), so controls use --border-control. */
  --border: #1e1e1e;          /* card edges, row dividers (decorative) */
  --divider: #222222;         /* section rules (decorative) */
  --border-strong: #333333;   /* emphasized decorative edge */
  --border-control: #636a73;  /* inputs, selects, secondary buttons: 3.6:1 on page, 3.2:1 on raised */
  --border-hover: #7d858f;    /* control border on hover */

  /* ---- Text: four steps; faint is ornament only ---- */
  --text-primary: #f0f0f0;  /* headings, values */
  --text-body: #cccccc;     /* running text */
  --text-muted: #9aa4ad;    /* labels, meta (7.4:1 on card) */
  --text-faint: #6e7681;    /* separators, decoration only; never information */
  --text-on-accent: #0a0a0a;

  /* ---- Accent (blue) ---- */
  --accent-solid: #7ca9f7;        /* primary button fill: dark text on it is 8.4:1 */
  --accent-solid-hover: #a8c8f8;
  --accent-text: #7ca9f7;         /* links, active tab, focus ring */
  --accent-text-hover: #a8c8f8;
  --accent-surface: #16233d;      /* info badge fill; accent-text on it is 6.6:1 */
  --accent-border: #2a5aae;
  --focus-ring: #7ca9f7;          /* 8.4:1 on page; outline 2px, offset 2px */

  /* ---- Status: each state has a fg, a surface and a border ---- */
  --success-text: #4ade80;   --success-surface: #1a3d2b;  --success-border: rgba(74, 222, 128, 0.3);
  --warning-text: #f7c97c;   --warning-surface: #3e3a1a;  --warning-border: rgba(247, 201, 124, 0.3);
  --danger-text: #f87171;    --danger-surface: #3d1a1a;   --danger-border: #6e2a2a;
  --danger-text-soft: #fca5a5;
  --merged-text: #c084fc;    --merged-surface: #2d1a5e;
  --info-text: var(--accent-text); --info-surface: var(--accent-surface);
  /* Diff */
  --diff-add-bg: rgba(74, 222, 128, 0.12); --diff-add-text: #b9f0cd;
  --diff-del-bg: rgba(248, 113, 113, 0.12); --diff-del-text: #f5c2c2;
  --diff-gutter-text: #8a8f98;

  /* ---- Type ----
     Two families. Mono is the UI voice; prose is for long-form user content
     (READMEs, issue and change descriptions, comments). */
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-prose: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Seven sizes. Nothing else. (Body is 14px; rem = 16px.) */
  --text-xs: 0.75rem;     /* 12px  badges, footnotes */
  --text-sm: 0.8125rem;   /* 13px  meta, table headers, secondary labels */
  --text-base: 0.875rem;  /* 14px  body, buttons, tabs, controls */
  --text-md: 1rem;        /* 16px  card titles, h3; inputs on phones */
  --text-lg: 1.25rem;     /* 20px  page/crumb title, h2 */
  --text-xl: 1.5rem;      /* 24px  h1 on detail pages */
  --text-display: 2.5rem; /* 40px  error code, marketing hero only */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 700;

  --leading-tight: 1.25;  /* headings */
  --leading-normal: 1.6;  /* UI text */
  --leading-prose: 1.7;   /* long-form prose */

  /* ---- Space: 4px grid ---- */
  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 0.125rem; /* 2px  badge vertical padding, checkbox margin */
  --space-1: 0.25rem;    /* 4px */
  --space-2: 0.5rem;     /* 8px */
  --space-3: 0.75rem;    /* 12px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.25rem;    /* 20px  card padding */
  --space-6: 1.5rem;     /* 24px  section gap */
  --space-8: 2rem;       /* 32px  page padding (desktop) */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* ---- Size ---- */
  --control-h: 2.25rem;       /* 36px: buttons, inputs, selects (desktop) */
  --control-h-sm: 1.75rem;    /* 28px: dense table actions; never below 24px (WCAG 2.5.8) */
  --control-h-touch: 2.75rem; /* 44px: every control at <=640px */
  --control-check: 1.25rem;   /* 20px: checkbox and radio; 24px target with its --space-0-5 margin */
  --content-max: 1100px;
  /* The page's side margin: .main, and the footer that lines up with it. */
  --page-gutter: var(--space-6);  /* 24px; 16px at <=640px (below) */
  --prose-max: 72ch;

  /* ---- Shape ---- */
  --radius-sm: 4px;    /* controls, badges, inline code */
  --radius-md: 6px;    /* cards, panels, menus */
  --radius-full: 999px;/* avatars, dot indicators only */

  /* ---- Elevation: one shadow, overlays only ---- */
  --shadow-overlay: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-strong);

  /* ---- Motion ---- */
  --duration-fast: 120ms;  /* hover, color */
  --duration-base: 180ms;  /* open/close of menus and details */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);

  /* ---- Breakpoints (reference values; CSS can't use vars in @media) ----
     phone  <= 640px   tablet <= 960px   desktop > 960px */

  /* ---- Deprecated aliases: kept so the auth pages keep working.
     Do not use in new code; delete once src/routes/{login,signup,email-auth}
     reference the names above. ---- */
  --accent: var(--accent-surface);
  --accent-hover: #1f4a8e;
  --error-text: var(--danger-text);
  --error-text-soft: var(--danger-text-soft);
  --error-bg: rgba(248, 113, 113, 0.1);
  --error-border: rgba(248, 113, 113, 0.3);
  --success-bg: rgba(74, 222, 128, 0.1);
  --bg-primary: var(--bg-page);
  --bg-secondary: var(--bg-card);
  --bg-tertiary: var(--bg-raised);
  --text-secondary: var(--text-muted);
  --text-tertiary: var(--text-muted);
}

/* ---- Global rules every page gets for free ---- */

/* One focus style for everything focusable (WCAG 2.2 SC 2.4.7, 2.4.11). */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Headings never leave a one-word last line; paragraphs avoid orphans. */
h1, h2, h3, h4 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }

/* Every text field, select and textarea is styled here, not per form.
   Wrapped in :where() so the rule has no specificity: a component that needs
   a different control (a visually hidden toggle, a search box's width) wins
   with a single class, and a page never has to fight these to restyle one. */
:where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="image"])),
:where(select),
:where(textarea) {
  font: inherit;
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-page);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-sm);
  min-height: var(--control-h);
  padding: 0 var(--space-3);
}
:where(textarea) { padding: var(--space-2) var(--space-3); min-height: 6rem; }
:where(input, select, textarea):hover { border-color: var(--border-hover); }
:where(input, textarea)::placeholder { color: var(--text-muted); }
:where(input, select, textarea):disabled { opacity: 0.5; cursor: not-allowed; }

/* A select draws its own chevron (two gradients, no image, CSP-safe). */
:where(select) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-8);
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 50%,
    calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* A 20px box with 2px around it: the 24px target WCAG 2.2 SC 2.5.8 asks for,
   whether or not the control sits in a <label> that widens it further. */
:where(input[type="checkbox"], input[type="radio"]) {
  width: var(--control-check); height: var(--control-check);
  margin: var(--space-0-5);
  flex-shrink: 0;
  accent-color: var(--accent-solid);
  cursor: pointer;
}

@media (max-width: 640px) {
  /* DESIGN.md › Layout: 16px side margins on phones. */
  :root { --page-gutter: var(--space-4); }
  /* 16px stops iOS Safari zooming the page when a field gets focus. */
  :where(input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea) { font-size: var(--text-md); }
  :where(input:not([type="checkbox"], [type="radio"], [type="hidden"]), select), .btn { min-height: var(--control-h-touch); }
}

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

/* Windows High Contrast / forced colors: keep boundaries visible. */
@media (forced-colors: active) {
  .btn, .badge, .card, input, select, textarea { border: 1px solid CanvasText; }
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

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

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

.nav a { text-decoration: none; }

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  margin-right: auto;
}
.nav-brand:hover { text-decoration: none; color: var(--accent-text); }

.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/*
 * The account menu: a <details> whose summary is the signed-in name and whose
 * panel drops below it, right-aligned to the bar's edge. No script: the
 * browser owns open/closed, Enter/Space toggling, and aria-expanded.
 */
.nav-user-menu { position: relative; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-user::-webkit-details-marker { display: none; }
.nav-user::after {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 0.15s;
}
.nav-user-menu[open] > .nav-user::after { transform: translateY(0.1em) rotate(-135deg); }
.nav-user:hover,
.nav-user-menu[open] > .nav-user { color: var(--text-primary); background: var(--bg-raised); }
.nav-user:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}
/* On an account page, the name reads as the current section like a nav link would. */
.nav-user-current { color: var(--text-primary); }
.nav-user-name { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }

.nav-user-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.35rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.nav-user-handle {
  margin: 0 0 0.25rem;
  padding: 0.35rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.nav-user-panel .nav-auth-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.5rem;
}
.nav-user-panel .nav-logout-form { display: block; }
.nav-auth-link:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 1px;
}

.nav-auth-link {
  color: var(--accent-text);
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.15s;
}

.nav-auth-link:hover {
  background: var(--accent-surface);
  text-decoration: none;
}

/* The link to the page the reader is on: quiet, not clickable-blue. */
.nav-auth-link[aria-current="page"] {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.nav-logout-form { display: inline; }
button.nav-auth-link {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.9rem; line-height: inherit;
}

/*
 * The phone menu. A nav that carries the toggle (the app, when signed in)
 * collapses its links behind a menu button below 640px; one without it (the
 * docs site, the signed-out app) keeps them inline, since a lone "sign in"
 * fits. The toggle is a checkbox so the menu works with no client script: the
 * label is the button, and the checked state shows the links. Below 640px the
 * input is visually hidden rather than display:none so it keeps its place in
 * the tab order and the label shows its focus ring; at wider widths it is
 * display:none, because a control with no visible label must not be reachable
 * by Tab.
 *
 * The button is a 44px icon (DESIGN.md, "Navigation"): three lines drawn in
 * CSS that turn into a cross while the menu is open. No border, and no hover
 * fill on touch screens, where :hover sticks after a tap.
 */
.nav-menu-toggle { display: none; }
.nav-menu-button { display: none; }
.nav-menu-close { display: none; }

@media (max-width: 640px) {
  .nav { padding: 0.6rem 1rem; }

  .nav-menu-toggle {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .nav-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--control-h-touch);
    height: var(--control-h-touch);
    margin-right: calc(-1 * var(--space-2));
    color: var(--text-body);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--duration-fast), color var(--duration-fast);
  }
  @media (hover: hover) {
    .nav-menu-button:hover { background-color: var(--bg-raised); color: var(--text-primary); }
  }
  .nav-menu-toggle:focus-visible ~ .nav-menu-button {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
  }
  /*
   * The glyph is drawn on the label itself: its background is the middle
   * line, ::before and ::after the top and bottom, and the three fold into a
   * cross while the menu is open. The words "Menu" and "Close" stay in the
   * markup, visually hidden, as the button's accessible name in each state.
   */
  .nav-menu-button {
    position: relative;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 1.125rem 2px;
    background-position: center;
    background-repeat: no-repeat;
  }
  .nav-menu-button::before,
  .nav-menu-button::after {
    content: "";
    position: absolute;
    left: calc(50% - 0.5625rem);
    top: calc(50% - 1px);
    width: 1.125rem;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    transition: transform var(--duration-fast);
  }
  .nav-menu-button::before { transform: translateY(-6px); }
  .nav-menu-button::after { transform: translateY(6px); }
  .nav-menu-toggle:checked ~ .nav-menu-button { background-size: 0 0; }
  .nav-menu-toggle:checked ~ .nav-menu-button::before { transform: rotate(45deg); }
  .nav-menu-toggle:checked ~ .nav-menu-button::after { transform: rotate(-45deg); }
  .nav-menu-open,
  .nav-menu-close {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .nav-menu-toggle:checked ~ .nav-menu-button .nav-menu-open { display: none; }
  .nav-menu-toggle:checked ~ .nav-menu-button .nav-menu-close { display: inline; }
  /* Forced colors repaint backgrounds as Canvas, which would erase the lines. */
  @media (forced-colors: active) {
    .nav-menu-button,
    .nav-menu-button::before,
    .nav-menu-button::after { forced-color-adjust: none; }
    .nav-menu-button { color: CanvasText; background-color: Canvas; }
    .nav-menu-button::before,
    .nav-menu-button::after { background: CanvasText; }
  }

  .nav-menu-toggle ~ .nav-auth {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
  }
  .nav-menu-toggle:checked ~ .nav-auth { display: flex; }
  .nav-menu-toggle ~ .nav-auth .nav-logout-form { display: block; }
  /*
   * Inside the phone menu the account menu is a row like the rest, and its
   * panel opens in place, indented under the name, rather than floating over
   * the page.
   */
  .nav-menu-toggle ~ .nav-auth .nav-user { min-height: 2.75rem; padding: 0.5rem; }
  .nav-menu-toggle ~ .nav-auth .nav-user-panel {
    position: static;
    min-width: 0;
    padding: 0 0 0 1rem;
    background: none;
    border: none;
    box-shadow: none;
  }
  /* A 39-character username (or a long display name) must wrap, not run off
     a phone-width panel. */
  .nav-menu-toggle ~ .nav-auth .nav-user,
  .nav-menu-toggle ~ .nav-auth .nav-user-handle {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .nav-menu-toggle ~ .nav-auth .nav-user-name { max-width: none; min-width: 0; }
  /* Full-width rows at least 44px tall, so a thumb hits one link and not two. */
  .nav-menu-toggle ~ .nav-auth .nav-auth-link {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.5rem;
    text-align: left;
  }
}

/* The content column. The footer (.site-footer) uses the same width and
   gutter, so the page, its rule and the footer text share one left edge. */
.main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8) var(--page-gutter);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); overflow-wrap: anywhere; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text-body); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.card-link {
  display: block;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.card-link:hover { border-color: var(--border-hover); text-decoration: none; }
.card-title { font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); }

.table-scroll { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 500; font-size: 0.85rem; }
.table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--bg-card); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table a { color: var(--accent-text); }
/* Identifiers in a cell stay whole; the table scrolls sideways instead. */
.table code { white-space: nowrap; }
.table .cell-num { font-variant-numeric: tabular-nums; }
/* Long text (an evaluator's reason, a check's summary) is prose, and a row that
   holds some lines up at the top: a name halfway down a tall row reads as
   belonging to nothing. */
.table .cell-block { font-family: var(--font-prose); line-height: var(--leading-prose); max-width: 72ch; }
.table:has(.cell-block) td { vertical-align: top; }
/* Each run's evidence is its own table; fixed columns line the tables up. */
.evidence-table { table-layout: fixed; }
.evidence-table th:nth-child(1) { width: 10rem; }
.evidence-table th:nth-child(2) { width: 6.5rem; }
.evidence-table th:nth-child(3) { width: 5.5rem; }

/* Phone tables (SI-12, DESIGN.md › Layout › Tables). At <=640px a table with
   more than two columns is a stacked list: one block per row, the .cell-primary
   cell on the first line, the other cells as meta on the second, a .cell-block
   cell (long text) on a line of its own and .cell-actions last. A cell whose
   value means nothing alone names itself with data-label ("Score 92%").
   The header row stays in the markup, visually hidden, for screen readers. */
@media (max-width: 640px) {
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-stack thead {
    position: absolute; width: 1px; height: 1px;
    clip-path: inset(50%); overflow: hidden; white-space: nowrap;
  }
  .table-stack tr {
    display: flex; flex-wrap: wrap; align-items: baseline;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) 0; border-bottom: 1px solid var(--border);
  }
  .table-stack tr:last-child { border-bottom: none; }
  .table-stack td {
    display: block; width: auto; max-width: 100%; min-width: 0; padding: 0;
    border-bottom: none; text-align: left;
    color: var(--text-muted); font-size: var(--text-sm); overflow-wrap: anywhere;
  }
  .table-stack td:empty { display: none; }
  .table-stack td.cell-primary { order: -1; flex-basis: 100%; color: var(--text-primary); font-size: var(--text-base); }
  .table-stack td.cell-block { flex-basis: 100%; max-width: none; color: var(--text-body); font-size: var(--text-base); }
  .table-stack td.cell-actions { flex-basis: 100%; }
  /* Evidence reads "LLM review · failed · Score 41%" on one line, the reason under it. */
  .table-stack.evidence-table td.cell-primary { flex-basis: auto; font-weight: var(--weight-medium); }
  .table-stack td[data-label]::before { content: attr(data-label) " "; }
  /* An identifier keeps to one line and is cut with an ellipsis, never
     broken one character per line. */
  .table-stack code {
    display: inline-block; max-width: 100%; overflow: hidden;
    text-overflow: ellipsis; vertical-align: bottom;
  }
  .table-stack.commit-table td.commit-message {
    max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}

/* Sentence case, xs/500 (DESIGN.md "Badges"). */
.badge {
  display: inline-block;
  white-space: nowrap;
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  background: var(--bg-raised);
  color: var(--text-muted);
}
.badge-open     { background: var(--info-surface); color: var(--info-text); }
.badge-approved { background: var(--success-surface); color: var(--success-text); }
.badge-merged   { background: var(--merged-surface); color: var(--merged-text); }
.badge-rejected { background: var(--danger-surface); color: var(--error-text); }
.badge-public   { background: var(--success-surface); color: var(--success-text); margin-left: 0.5rem; font-size: 0.75rem; }

/* Status badges (sync + import cards) */
.badge-info     { background: var(--info-surface); color: var(--info-text); }
.badge-success  { background: var(--success-surface); color: var(--success-text); }
.badge-warning  { background: var(--warning-surface); color: var(--warning-text); }
.badge-error    { background: var(--danger-surface); color: var(--error-text); }
.badge-resolved { background: var(--success-surface); color: var(--success-text); }
.badge-conflict { background: var(--warning-surface); color: var(--warning-text); }

/* README styling */
.readme-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
}

.btn {
  /* One shape for every button and button-styled link: a fixed control
     height with the label centred in it. Flex, not inline-block, so a link
     centres its label the way a <button> does, including at the 44px phone
     height (an inline-block link sat its text at the top of the box). */
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-decoration: none;
  line-height: var(--leading-tight);
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-hover); color: var(--text-primary); text-decoration: none; }
/* The one primary action per region: a solid fill, the most prominent control on the page. */
.btn-primary { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--text-on-accent); }
.btn-primary:hover { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); color: var(--text-on-accent); }
.btn-danger  { background: var(--danger-surface); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger:hover  { background: var(--danger-surface); border-color: var(--danger-text); color: var(--danger-text-soft); }
/* After the base rule, which sets the desktop height: every button is a 44px target on a phone. */
@media (max-width: 640px) { .btn { min-height: var(--control-h-touch); } }

.empty-state { padding: 2rem 0; color: var(--text-muted); text-align: center; }
.empty-state-hint { margin-top: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }
/* The one next action an empty state offers sits clear of the sentence above it. */
.empty-state > .btn { margin-top: var(--space-4); }

/* The signed-out home: what Stratum is, in a line, and the ways in. */
.welcome { max-width: var(--prose-max); padding: var(--space-6) 0; }
.welcome-title {
  font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight);
  margin-bottom: var(--space-4);
}
.welcome-lead { color: var(--text-body); }
.welcome-lead + .welcome-lead { margin-top: var(--space-3); }
.welcome-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }

.file-list { list-style: none; }
.file-item { padding: 0.3rem 0; border-bottom: 1px solid #161616; font-size: 0.85rem; color: var(--text-body); }
.file-item:last-child { border-bottom: none; }

/* The value column may hold an email at 320px: it must shrink and wrap, never overflow the card. */
.detail-list { display: grid; grid-template-columns: minmax(6rem, 140px) minmax(0, 1fr); gap: 0.4rem 1rem; }
.detail-list dt { color: var(--text-muted); font-size: 0.85rem; }
.detail-list dd { color: var(--text-body); overflow-wrap: anywhere; }

.action-row { display: flex; gap: 0.75rem; margin-top: 1rem; }

.issue-list { margin-top: 0.35rem; padding-left: 1rem; color: var(--error-text-soft); }

.mono { font-family: 'JetBrains Mono', monospace; }
.text-muted { color: var(--text-muted); }
.commit-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; display: grid; gap: 0.25rem; }
.commit-list li { overflow-wrap: anywhere; }
.earlier-runs { margin-top: 1rem; }
.earlier-runs summary { cursor: pointer; color: var(--text-muted); }
.earlier-runs > div { margin-top: 0.75rem; }

/* Import Progress Styles */
.import-progress-card {
  border-left: 4px solid var(--accent-text);
}

.import-progress-card[data-import-status="completed"] {
  border-left-color: var(--success-text);
}

.import-progress-card[data-import-status="failed"] {
  border-left-color: var(--error-text);
}

.import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.import-header h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: -1px;
}

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

.icon-success { color: var(--success-text); }
.icon-error { color: var(--error-text); }
.icon-cancelled { color: var(--text-muted); }

.badge-queued { background: var(--bg-raised); color: var(--text-muted); }
.badge-cloning { background: var(--accent); color: var(--accent-text); }
.badge-processing { background: var(--warning-surface); color: var(--warning-text); }
.badge-syncing { background: var(--accent); color: var(--accent-text); }
.badge-completed { background: var(--success-surface); color: var(--success-text); }
.badge-failed { background: var(--danger-surface); color: var(--error-text); }
.badge-cancelled { background: var(--bg-raised); color: var(--text-muted); }

.import-source {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 0.85rem;
}

.import-source p {
  margin: 0.25rem 0;
  color: var(--text-muted);
}

.progress-section {
  margin: 1rem 0;
}

.progress-bar {
  height: 8px;
  background: var(--bg-raised);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7ca9f7, #a8c8f8);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.current-file {
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.errors-section {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #1a0a0a;
  border: 1px solid var(--danger-surface);
  border-radius: 6px;
}

.errors-section h3 {
  color: var(--error-text);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.error-list {
  list-style: none;
  font-size: 0.8rem;
}

.error-item {
  padding: 0.25rem 0;
  color: var(--error-text-soft);
  border-bottom: 1px solid #2d1a1a;
}

.error-item:last-child {
  border-bottom: none;
}

.more-errors {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.logs-section {
  margin-top: 1rem;
}

.logs-section details {
  font-size: 0.85rem;
}

.logs-section summary {
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

.log-list {
  list-style: none;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--bg-raised);
}

.log-item:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-info .log-message { color: var(--text-muted); }
.log-warn .log-message { color: var(--warning-text); }
.log-error .log-message { color: var(--error-text); }

.actions-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-secondary { background: var(--bg-raised); border-color: var(--border-control); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-hover); color: var(--text-primary); }

.error-alert {
  margin: 1rem 0;
  padding: 1rem;
  background: #1a0a0a;
  border: 1px solid #5d2a2a;
  border-radius: 6px;
}

.error-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.error-header h3 {
  font-size: 0.95rem;
  color: var(--error-text);
  margin: 0;
}

.error-icon { font-size: 1rem; }

.error-description {
  font-size: 0.85rem;
  color: var(--error-text-soft);
  margin: 0 0 0.75rem;
}

.troubleshooting-section { margin-top: 0.75rem; }

.troubleshooting-section h4 {
  font-size: 0.85rem;
  color: var(--warning-text);
  margin: 0 0 0.4rem;
}

.troubleshooting-tips {
  padding-left: 1.25rem;
  margin: 0;
}

.troubleshooting-tips li {
  font-size: 0.82rem;
  color: var(--text-body);
  padding: 0.15rem 0;
}

.error-action { margin-top: 0.75rem; }

.failed-actions { display: flex; gap: 0.5rem; }

.retry-form { display: inline; }

.delete-form { display: inline; }

.technical-errors summary { color: var(--text-muted); cursor: pointer; padding: 0.5rem 0; font-size: 0.85rem; }

/* File Tree */
.file-tree { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; }
.file-tree-dir { border: none; }
.file-tree-dir > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0;
  color: var(--text-body);
  user-select: none;
}
.file-tree-dir > summary::before { content: "▶  "; font-size: 0.7rem; }
.file-tree-dir[open] > summary::before { content: "▼  "; font-size: 0.7rem; }
.file-tree-dir > summary::-webkit-details-marker { display: none; }
.file-tree-dir > summary::marker { content: ""; }
.file-tree-children { padding-left: 1.25rem; }
.file-tree-file { padding: 0.2rem 0; }
.file-tree-file a { color: var(--text-body); text-decoration: none; display: block; }
.file-tree-file a:hover { color: var(--text-primary); text-decoration: underline; }
.file-tree-notice { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.75rem; font-style: italic; }
.file-tree-controls { margin-bottom: 0.5rem; }
.file-tree-toggle-btn { background: none; border: none; color: var(--accent-text); font-size: 0.8rem; cursor: pointer; padding: 0; font-family: inherit; }
.file-tree-toggle-btn:hover { color: var(--accent-text-hover); text-decoration: underline; }

/* Activity Feed: who, what, when. The actor column has one width so every
   description starts on the same edge; on a phone the actor and time share
   the first line and the description wraps below. */
.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-item {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--divider);
  font-size: var(--text-sm);
}
.activity-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
/* An agent's long name is clipped, never its "agent" tag. */
.activity-who .actor-name { display: flex; align-items: baseline; gap: var(--space-1); min-width: 0; overflow-wrap: normal; }
.activity-who .actor-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.activity-who .activity-actor-agent { flex-shrink: 0; }
.activity-system { color: var(--text-muted); }
.activity-description { min-width: 0; color: var(--text-body); overflow-wrap: anywhere; }
.activity-description a { color: var(--accent-text); text-decoration: none; }
.activity-description a:hover { text-decoration: underline; }
.activity-count { color: var(--text-muted); }
.activity-time { color: var(--text-muted); font-size: var(--text-xs); white-space: nowrap; }
@media (max-width: 640px) {
  .activity-item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "actor time" "description description";
    row-gap: var(--space-1);
  }
  .activity-who { grid-area: actor; }
  .activity-time { grid-area: time; }
  .activity-description { grid-area: description; }
}
/* The agent tag beside an agent's name (ActorName). */
.activity-actor-agent {
  font-size: var(--text-xs);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--merged-surface);
  color: var(--merged-text);
}

/* Webhooks */
.webhook-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 480px; }
.webhook-form > label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--text-body); }
.webhook-help { font-size: 0.8rem; color: var(--text-muted); }
.webhook-card { margin-top: 1rem; }
.webhook-card-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.webhook-url { font-size: 0.85rem; color: var(--accent-text); margin-right: 0.5rem; word-break: break-all; }
.webhook-actions { display: flex; gap: 0.5rem; }
.webhook-meta { font-size: 0.8rem; color: var(--text-muted); margin: 0.5rem 0 0; word-break: break-all; }
.webhook-deliveries { margin-top: 0.75rem; font-size: 0.85rem; }
.webhook-deliveries summary { cursor: pointer; color: var(--text-muted); }
.webhook-deliveries ul { list-style: none; padding: 0.5rem 0 0; margin: 0; }
.webhook-delivery { display: flex; gap: 0.75rem; align-items: baseline; padding: 0.25rem 0; flex-wrap: wrap; }
.webhook-delivery-type { font-family: 'JetBrains Mono', monospace; color: var(--text-body); }
.webhook-delivery-meta { color: var(--text-muted); }
.webhook-delivery-time { color: var(--text-muted); margin-left: auto; }
.btn-small, .btn-sm { font-size: var(--text-sm); padding: var(--space-1) var(--space-2); min-height: var(--control-h-sm); }
/* Dense actions grow to a full control on phones: still compact, never under 36px to tap. */
@media (max-width: 640px) { .btn-small, .btn-sm { min-height: var(--control-h); } }

/* Deployments (SI-26). Status tones come from the shared badge-* classes;
   skipped and superseded are neutral on purpose: neither is a failure, and
   colouring them like one would make "nothing was configured to deploy" look
   like a broken build. The list is one block per deployment: a grid on
   desktop, stacked at <=640px, so nothing runs off a phone. */
.badge-neutral { background: var(--bg-raised); color: var(--text-muted); }
.deploy-list { list-style: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.deploy-row {
  position: relative;
  display: grid; grid-template-columns: 9rem minmax(0, 1fr) 4.5rem 6.5rem 6rem;
  gap: var(--space-4); align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--duration-fast) var(--ease-out);
}
/* A reader gets no actions column. */
.deploy-list-readonly .deploy-row { grid-template-columns: 9rem minmax(0, 1fr) 4.5rem 6.5rem; }
.deploy-row:last-child { border-bottom: 0; }
.deploy-row:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.deploy-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.deploy-row:only-child { border-radius: var(--radius-md); }
.deploy-row:hover { background: var(--bg-raised); }
.deploy-row-name { color: var(--text-primary); font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.deploy-row-name:hover { color: var(--text-primary); }
/* The whole row opens the deployment; the name keeps the focus ring. */
.deploy-row-name::after { content: ""; position: absolute; inset: 0; }
.deploy-row-meta {
  display: flex; flex-wrap: wrap; align-items: baseline;
  margin-top: var(--space-1); font-size: var(--text-sm); color: var(--text-muted);
}
.deploy-row-mi { white-space: nowrap; }
.deploy-row-mi + .deploy-row-mi::before { content: "·"; color: var(--text-faint); margin: 0 var(--space-2); }
/* The change it ships, by title: one line, cut with an ellipsis, the full title on hover. */
.deploy-row-change {
  margin-top: var(--space-1); font-size: var(--text-sm); color: var(--text-body);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.deploy-row-duration, .deploy-row-when { font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deploy-row-duration { color: var(--text-body); text-align: right; }
.deploy-row-when { color: var(--text-muted); text-align: right; }
/* Above the row's link, so the button acts rather than opening the deployment. */
.deploy-row-actions { position: relative; z-index: 1; display: flex; justify-content: flex-end; }
.deploy-sha { font-size: var(--text-sm); color: var(--text-body); background: none; padding: 0; }
.deploy-sha-full { user-select: all; overflow-wrap: anywhere; color: var(--text-body); background: none; padding: 0; }
.deploy-target-none { font-style: italic; }
.deploy-title { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.deploy-title .badge { font-size: var(--text-xs); }
.deploy-reason { margin: 0 0 var(--space-4); color: var(--text-body); overflow-wrap: anywhere; }
.deploy-reason-failed {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  background: var(--danger-surface); color: var(--danger-text);
}
.card > .deploy-reason:last-child { margin-bottom: 0; }
.detail-list + .deploy-reason { margin-top: var(--space-4); }
.deploy-log-title { font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-tight); margin-bottom: var(--space-1); }

@media (max-width: 640px) {
  .deploy-row, .deploy-list-readonly .deploy-row { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); padding: var(--space-3); }
  .deploy-row-status { grid-column: 1; grid-row: 1; }
  .deploy-row-when { grid-column: 2; grid-row: 1; }
  .deploy-row-main { grid-column: 1 / -1; grid-row: 2; }
  .deploy-row-duration { display: none; }
  .deploy-row-actions { grid-column: 1 / -1; grid-row: 3; justify-content: flex-start; margin-top: var(--space-2); }
  .deploy-row-actions:empty { display: none; }
  /* Label over value: a 140px label column left the commit three lines tall. */
  .deploy-details { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .deploy-details dd + dt { margin-top: var(--space-3); }
}
.deploy-log {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-3); overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-body); margin: var(--space-3) 0 0;
}
.secret-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; }
.secret-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--text-body); }
.btn-link { background: none; border-color: transparent; color: var(--accent-text); }

/* Issues */
.page-header-actions { display: flex; gap: 0.5rem; }
.page-nav {
  display: flex; gap: 0.75rem; align-items: center; justify-content: center;
  margin-top: 1rem;
}
.btn-disabled { opacity: 0.4; cursor: default; }
.issues-filter { display: flex; gap: 1rem; margin-bottom: 1rem; font-size: 0.9rem; flex-wrap: wrap; }
.issues-filter a { color: var(--text-muted); text-decoration: none; }
.issues-filter a:hover { color: var(--text-body); }
.issues-filter-active { color: var(--text-primary) !important; font-weight: 600; }
.issues-list { list-style: none; padding: 0; margin: 0; }
.issues-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--divider);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.issues-title { color: #e8e8e8; text-decoration: none; flex: 1; min-width: 200px; }
.issues-title:hover { color: var(--accent-text); }
.issues-linked-change { font-size: var(--text-xs); color: var(--accent-text); overflow-wrap: anywhere; min-width: 0; }
.issue-linked-card { margin-top: var(--space-4); }
.issue-linked-change { margin: 0; overflow-wrap: anywhere; }
.issues-meta { color: var(--text-muted); font-size: 0.8rem; }
.issue-status-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.issue-body { margin-top: 1rem; }
.issue-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 560px; }
.issue-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--text-body); }
.issue-label { background: #2a2a1a; color: #e0d080; text-decoration: none; text-transform: none; }
.issue-label:hover { color: #f0e4a0; }
.issues-search { display: inline-flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.issues-search-label { color: var(--text-muted); font-size: var(--text-sm); }
@media (max-width: 640px) {
  .issues-search { flex-basis: 100%; margin-left: 0; }
  /* Sizing only: the field's look comes from the global control rule. */
  .issues-search > input { flex: 1 1 0; width: 0; min-width: 0; }
}
.issue-comments { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.issue-comments h2 { font-size: 1rem; margin: 0; }
.issue-comment .issues-meta { margin-bottom: 0.5rem; }

/* Syntax highlighting (server-side lexer) */
.tok-comment { color: var(--text-muted); font-style: italic; }
.tok-string { color: #9ecbff; }
.tok-number { color: #f8c555; }
.tok-keyword { color: #f97583; }

/* Diff viewer */
.diff-view { display: flex; flex-direction: column; gap: 0.75rem; }
.diff-empty { color: var(--text-muted); font-size: 0.85rem; }
.diff-file { border: 1px solid #2a2a2a; border-radius: 6px; overflow: hidden; }
.diff-file-header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: 0.5rem 0.75rem; background: #181818; cursor: pointer;
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem;
}
.diff-file-path { color: #e8e8e8; word-break: break-all; }
.diff-file-stats { flex-shrink: 0; }
.diff-stat-add { color: var(--success-text); }
.diff-stat-del { color: var(--error-text); }
.diff-file-body {
  margin: 0; padding: 0.5rem 0; overflow-x: auto;
  font-size: 0.8rem; line-height: 1.5; background: var(--bg-panel);
}
.diff-line { display: block; padding: 0 0.75rem; white-space: pre; }
.diff-lineno {
  display: inline-block; width: 3em; text-align: right; padding-right: 0.75em;
  /* Line numbers are content, not decoration — readers use them to find the
     line a comment anchors to — so they need the 4.5:1 body-text ratio.
     #8a8f98 on the #0d0d0d diff body is ~5.6:1; the old #4b5563 was ~2.6:1. */
  color: #8a8f98; user-select: none;
}
.diff-line:target { background: rgba(124, 183, 255, 0.18); outline: 1px solid #7cb7ff; }
.diff-add { background: rgba(74, 222, 128, 0.12); color: #b9f0cd; }
.diff-del { background: rgba(248, 113, 113, 0.12); color: #f5c2c2; }
.diff-hunk { color: var(--accent-text); background: #14181f; }
.diff-meta { color: var(--text-muted); font-style: italic; }

/* Present for assistive tech, removed from the visual layout. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; border: 0; clip-path: inset(50%); overflow: hidden;
  white-space: nowrap;
}

/* Unified/split toggle: hidden checkbox + sibling selectors, no client JS.
   The instant client-side switch (vs. GitHub's full reload) is deliberate. */
.diff-split-toggle { position: absolute; opacity: 0; pointer-events: none; }
.diff-split-label {
  align-self: flex-end; cursor: pointer; user-select: none;
  font-size: 0.8rem; color: var(--accent-text); border: 1px solid #2a2a2a;
  border-radius: 6px; padding: 0.25rem 0.6rem; background: #181818;
}
.diff-split-label:hover { border-color: var(--accent-text); }
.diff-split-toggle:focus-visible ~ .diff-split-label { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.diff-label-split { display: none; }
.diff-split-toggle:checked ~ .diff-split-label .diff-label-unified { display: none; }
.diff-split-toggle:checked ~ .diff-split-label .diff-label-split { display: inline; }

/* Split view: hidden until the toggle is checked, then replaces unified. */
.diff-split { display: none; }
.diff-split-toggle:checked ~ .diff-file .diff-file-body { display: none; }
.diff-split-toggle:checked ~ .diff-file .diff-split {
  display: table; width: 100%; table-layout: fixed; border-collapse: collapse;
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; line-height: 1.5;
  background: var(--bg-panel);
}
.diff-cell {
  width: 50%; padding: 0 0.75rem; white-space: pre-wrap; word-break: break-all;
  vertical-align: top; border-left: 1px solid #1c1c1c;
}
.diff-cell:first-child { border-left: none; }

/* Settings.
   The global reset zeroes every margin, so the help copy, lists and forms
   here put back the spacing that keeps one card's paragraphs apart. */
.settings-help { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.75rem; }
.settings-help:last-child { margin-bottom: 0; }
.settings-help-error { color: var(--error-text); }
ul.settings-help { padding-left: 1.25rem; }
.settings-help li { margin: 0.25rem 0; }
.settings-help code { font-size: 0.8rem; background: var(--bg-raised); padding: 0.05em 0.3em; border-radius: 3px; color: var(--text-body); }
.settings-details { margin: 0 0 0.75rem; font-size: 0.85rem; }
.settings-details summary { cursor: pointer; color: var(--accent-text); padding: 0.25rem 0; }
.settings-details[open] summary { margin-bottom: 0.5rem; }
.settings-notice { color: var(--text-body); }
.card-error { border-color: var(--danger-border); }
.card-error .settings-notice { color: var(--error-text-soft); }
.card-success { border-color: var(--success-border); }
.settings-token-reveal { border: 1px solid #2d4f2d; background: #101a10; }
.settings-token {
  display: block; padding: 0.6rem 0.75rem; background: var(--bg-panel);
  border: 1px solid var(--border-strong); border-radius: 4px; word-break: break-all;
  font-size: 0.85rem; color: #9ecbff;
}

/* A card jumped to sits clear of the top edge and lights up briefly. */
.card:target { border-color: var(--accent-border); scroll-margin-top: 1rem; }

/* Forms: stacked fields, inputs and selects styled alike, controls tall enough to tap. */
.settings-form, .settings-agent-form {
  display: flex; flex-direction: column; gap: 0.75rem; max-width: 420px; margin: 1rem 0;
}
.settings-form:last-child, .settings-agent-form:last-child { margin-bottom: 0; }
.settings-form + .settings-form { padding-top: 1rem; border-top: 1px solid var(--divider); }
.settings-form label, .settings-agent-form label {
  display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--text-body);
}
.settings-form .settings-help { margin: -0.35rem 0 0; }
.settings-form .btn, .settings-inline-form .btn { align-self: flex-start; }
.settings-inline-form { display: flex; align-items: center; gap: 0.75rem 1.25rem; flex-wrap: wrap; margin-top: 1rem; }
.settings-inline-form .checkbox-label { min-height: var(--control-h); }
.settings-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Danger zone (project + account deletion) */
.danger-zone { border-color: var(--danger-border); }
.danger-zone h2, .danger-zone h3 { color: var(--error-text); }
.danger-zone p { color: var(--text-body); }
.danger-zone form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
/* The confirm field's label sits over it, so the delete button lines up with the field. */
.danger-zone form:has(.danger-confirm) { align-items: flex-end; }
.danger-confirm { display: flex; flex-direction: column; gap: var(--space-1); color: var(--text-body); font-size: var(--text-sm); }
.danger-zone input[type="text"] { min-width: 220px; }

/* Sync status (repo page banner + sync page) */
.sync-status-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.sync-status-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.sync-provider { color: var(--text-body); font-weight: 600; font-size: 0.9rem; }
.sync-source-link { font-size: 0.8rem; color: var(--accent-text); word-break: break-all; }
.sync-status-badge { flex-shrink: 0; display: flex; gap: 0.5rem; }
.sync-status-details { display: flex; gap: 0.35rem 1.5rem; flex-wrap: wrap; font-size: 0.85rem; }
.sync-detail { display: flex; gap: 0.4rem; align-items: baseline; }
.sync-label { color: var(--text-muted); }
.sync-value { color: var(--text-body); }
.sync-commit { color: var(--accent-text); font-size: 0.8rem; }
.sync-error { border-color: var(--danger-border); }
.sync-error-message {
  margin-top: 0.75rem; padding: 0.6rem 0.75rem; border-radius: 4px;
  background: #1a0a0a; border: 1px solid var(--danger-surface);
  color: var(--error-text-soft); font-size: 0.85rem;
}

/* Sync page */
.status-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.status-indicator { font-size: 1.1rem; flex-shrink: 0; }
.status-info { flex: 1; min-width: 200px; }
.status-info h2 { margin-bottom: 0.15rem; }
.status-meta { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.status-actions { flex-shrink: 0; }
.icon-idle { color: var(--text-muted); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem 1.5rem; }
.info-item label {
  display: block; color: var(--text-muted); font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}
.info-item a, .info-item span, .info-item code { font-size: 0.85rem; word-break: break-all; }
.error-hint { color: var(--error-text-soft); font-size: 0.8rem; text-decoration: underline dotted; cursor: help; }
.form-group { margin-bottom: 1rem; }
.form-group > label { display: block; color: var(--text-body); font-size: 0.85rem; margin-bottom: 0.25rem; }
.form-group select:disabled { color: var(--text-muted); }
.checkbox-label, .form-group > label.checkbox-label {
  display: flex; align-items: center; gap: 0.5rem; color: var(--text-body); cursor: pointer; margin-bottom: 0;
}
.help-text { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }
.error-message {
  margin-top: 0.75rem; padding: 0.6rem 0.75rem; border-radius: 4px;
  background: #1a0a0a; border: 1px solid var(--danger-surface); color: var(--error-text-soft); font-size: 0.85rem;
}
.btn-success { background: var(--success-surface); border-color: var(--success-border); color: var(--success-text); }
.btn-info { background: var(--info-surface); border-color: var(--accent-border); color: var(--info-text); }

/* Diff file header (diff view) */
.file-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.file-path { color: #e8e8e8; font-size: 0.85rem; word-break: break-all; }
.diff-label { color: var(--text-body); font-weight: 600; }

/* Costs */
.cost-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; color: var(--text-body); }
.cost-list li { padding: 0.2rem 0; }
.eval-cost { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Change reviews and comments */
.review-empty { color: var(--text-muted); font-size: 0.85rem; }
.review-list, .comment-list { list-style: none; padding: 0; margin: 0; }
.review-item {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--divider); font-size: 0.85rem; flex-wrap: wrap;
}
.review-reviewer { color: var(--text-body); font-size: 0.8rem; }
.review-comment { color: var(--text-body); flex: 1; }
.review-time { color: var(--text-muted); font-size: 0.75rem; margin-left: auto; }
.review-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.comment-item { padding: 0.6rem 0; border-bottom: 1px solid var(--divider); }
.comment-meta { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.8rem; color: var(--text-muted); }
.comment-body {
  white-space: pre-wrap; word-break: break-word; font-family: inherit;
  margin: 0.35rem 0 0; color: #ddd; font-size: 0.9rem;
}
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; max-width: 560px; }
.comment-form textarea {
  background: var(--bg-card); border: 1px solid var(--border-strong); color: #eee;
  padding: 0.5rem; border-radius: 4px; font-family: inherit;
}
.comment-form button { align-self: flex-start; }
/* A visible label over a single field (DESIGN.md › Form controls). */
.field-label { display: block; color: var(--text-body); font-size: var(--text-sm); }

/* Change page on a phone (SI-24): every row wraps rather than widening the page. */
.change-meta { overflow-wrap: anywhere; }
.comment-meta, .review-actions { flex-wrap: wrap; }
.review-item { flex-direction: column; align-items: stretch; gap: 0; }
.review-actions .review-comment-form { flex-basis: 100%; min-width: 0; }
.actor-name { overflow-wrap: anywhere; }

/* Line comment threads (beneath the diff) */
.line-threads { display: flex; flex-direction: column; gap: 1rem; }
.line-thread { border: 1px solid #222; border-radius: 6px; padding: 0.6rem 0.75rem; }
.line-thread-resolved { opacity: 0.7; border-color: #1c2e1c; }
.line-thread-header {
  display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap;
  font-size: 0.85rem; padding-bottom: 0.25rem; border-bottom: 1px solid #1c1c1c;
}
.line-thread-anchor { color: #7cb7ff; text-decoration: none; }
.line-thread-anchor:hover { text-decoration: underline; }
.line-thread-side { color: #888; font-size: 0.75rem; }
.line-thread-replies {
  list-style: none; margin: 0; padding-left: 1.5rem; border-left: 2px solid #222;
}
.line-thread-actions { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }

/* File Viewer */
.file-viewer-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin-bottom: 0;
  color: var(--text-muted);
}
.file-viewer-breadcrumb a { color: var(--accent-text); text-decoration: none; }
.file-viewer-breadcrumb a:hover { text-decoration: underline; }
.file-viewer-breadcrumb .sep { color: var(--text-faint); }
.file-viewer-breadcrumb-current { color: var(--text-primary); }
.file-viewer-content { padding: 0; overflow: hidden; }
.file-viewer-content pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #d4d4d4;
  line-height: 1.6;
  background: var(--bg-panel);
}
.file-viewer-message { padding: 1.5rem; color: var(--text-muted); font-style: italic; font-size: 0.85rem; margin: 0; }

/* Repo page two-column layout */
.repo-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  align-items: start;
}

.repo-sidebar { position: sticky; top: 1rem; }
.repo-main { min-width: 0; }

@media (max-width: 700px) {
  .repo-layout { grid-template-columns: 1fr; }
  .repo-sidebar { position: static; }
}

/*
 * Rendered Markdown: READMEs, Markdown files, issue bodies, comments, change
 * descriptions and review text all come through renderMarkdown() and wear this
 * one class (DESIGN.md, "Markdown"). Running text is in the prose face and
 * stops at 72ch; code and tables may use the full width.
 */
.readme-card h2 { margin-bottom: var(--space-4); }
.markdown-body { overflow-wrap: anywhere; min-width: 0;
  font-family: var(--font-prose); font-size: var(--text-base); line-height: var(--leading-prose); color: var(--text-body);
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body :where(p, li, dd, blockquote, .md-alert, h1, h2, h3, h4, h5, h6) { max-width: var(--prose-max); }
.markdown-body :where(h1, h2, h3, h4, h5, h6) {
  font-family: var(--font-prose); color: var(--text-primary); line-height: var(--leading-tight);
  text-wrap: balance; margin: var(--space-6) 0 var(--space-2); scroll-margin-top: var(--space-4);
}
.markdown-body h1 { font-size: var(--text-xl); padding-bottom: var(--space-2); border-bottom: 1px solid var(--divider); }
.markdown-body h2 { font-size: var(--text-lg); padding-bottom: var(--space-1); border-bottom: 1px solid var(--divider); }
.markdown-body h3 { font-size: var(--text-md); }
.markdown-body :where(h4, h5, h6) { font-size: var(--text-base); }
/* A README renders two levels down (# is an <h3>): the card's "README" is the
   <h2> it sits under and the project is the page's <h1> (SI-25). Its headings
   keep the look their Markdown level had. */
.readme-card .markdown-body h3 { font-size: var(--text-xl); padding-bottom: var(--space-2); border-bottom: 1px solid var(--divider); }
.readme-card .markdown-body h4 { font-size: var(--text-lg); padding-bottom: var(--space-1); border-bottom: 1px solid var(--divider); }
.readme-card .markdown-body h5 { font-size: var(--text-md); }
.markdown-body p { margin: var(--space-3) 0; text-wrap: pretty; }
.markdown-body a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 0.15em; }
.markdown-body a:hover { color: var(--accent-text-hover); }
/* A badge row ([![CI](…)](…)) is a row of pictures, not underlined text. */
.markdown-body a:has(> img) { text-decoration: none; }
.markdown-body code {
  font-family: var(--font-mono); font-size: 0.875em; /* relative to the line it sits in */
  background: var(--bg-raised); padding: var(--space-0-5) var(--space-1); border-radius: var(--radius-sm); color: var(--text-primary);
}
.markdown-body pre {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); overflow-x: auto; margin: var(--space-3) 0;
  font-family: var(--font-mono); font-size: var(--text-sm); line-height: var(--leading-normal);
  white-space: pre; overflow-wrap: normal;
}
.markdown-body pre code { background: none; padding: 0; font-size: inherit; color: var(--text-body); border-radius: 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--border-strong); margin: var(--space-3) 0;
  padding: 0 0 0 var(--space-4); color: var(--text-muted);
}
.markdown-body :where(ul, ol) { padding-left: var(--space-6); margin: var(--space-3) 0; }
.markdown-body li { margin: var(--space-1) 0; }
.markdown-body li > :where(ul, ol) { margin: var(--space-1) 0; }
.markdown-body li:has(> input[type="checkbox"]) { list-style: none; margin-left: calc(-1 * var(--space-6)); padding-left: var(--space-1); }
.markdown-body li > input[type="checkbox"] {
  width: 1rem; height: 1rem; margin: 0 var(--space-2) 0 0; vertical-align: -0.15em; cursor: default;
}
.markdown-body table { display: block; overflow-x: auto; border-collapse: collapse; font-size: var(--text-sm); margin: var(--space-3) 0; }
.markdown-body th { background: var(--bg-raised); color: var(--text-primary); font-weight: var(--weight-medium); text-align: left; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); }
.markdown-body td { padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); color: var(--text-body); }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); vertical-align: middle; }
.markdown-body hr { border: none; border-top: 1px solid var(--divider); margin: var(--space-6) 0; }
.markdown-body details { margin: var(--space-3) 0; }
.markdown-body summary { cursor: pointer; color: var(--text-muted); }

/* GitHub alerts (> [!NOTE]): a callout in the status color its meaning maps to. */
.md-alert {
  --md-alert-color: var(--accent-text);
  margin: var(--space-4) 0; padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--md-alert-color); color: var(--text-body);
}
.md-alert > :last-child { margin-bottom: 0; }
.md-alert p { margin: var(--space-2) 0; }
.md-alert .md-alert-title {
  margin: 0 0 var(--space-1); color: var(--md-alert-color);
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-bold);
}
.md-alert-tip { --md-alert-color: var(--success-text); }
.md-alert-warning { --md-alert-color: var(--warning-text); }
.md-alert-caution { --md-alert-color: var(--danger-text); }

/* Callout: a result or caution about what is next to it, in the status color
   its meaning maps to. Same look as a Markdown alert (.md-alert); used outside
   rendered Markdown, e.g. the import size check on the new-project form. */
.callout {
  --callout-color: var(--accent-text);
  margin: 0 0 var(--space-5); padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--callout-color); color: var(--text-body);
  font-size: var(--text-base); line-height: var(--leading-prose);
}
.callout-warning { --callout-color: var(--warning-text); }
.callout-danger { --callout-color: var(--danger-text); }
.callout p { margin: var(--space-2) 0; }
.callout .callout-title {
  margin: 0 0 var(--space-1); color: var(--callout-color);
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-bold);
}
.callout .callout-subtitle {
  margin: var(--space-3) 0 var(--space-1); color: var(--text-primary);
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-bold);
}
.callout-list { margin: var(--space-1) 0; padding-left: var(--space-5); }
.callout-list li { margin: var(--space-1) 0; overflow-wrap: anywhere; }

/* user-select: all lets one click grab the whole command — no copy button, no JS. */
.cli-hint {
  display: inline-block; text-align: left; margin: 0.75rem auto 0.25rem;
  padding: 0.7rem 1rem; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.8rem; line-height: 1.7; color: var(--text-body);
  user-select: all; overflow-x: auto; max-width: 100%; white-space: pre;
}

.webhook-events { border: none; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.webhook-events legend { font-size: 0.85rem; color: var(--text-body); padding: 0; margin-bottom: 0.35rem; }
.webhook-events-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.25rem 1rem; padding-left: 1.4rem;
}
.webhook-events .checkbox-label { font-size: var(--text-sm); }

.token-reveal-row { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap; }
.token-reveal-row .settings-token { flex: 1; min-width: 240px; }

/* Settings: invite codes. The share link stays on one line — the table
   scrolls sideways on a phone — because a link broken one character per line
   was 300px tall and unreadable. */
.invite-share-link { white-space: nowrap; font-size: 0.8rem; color: var(--accent-text); }

/* New project form: CSS-only mode toggle (script only re-points the action) */
.mode-toggle { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.mode-toggle label {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.45rem 0.9rem; border: 1px solid var(--border-strong);
  border-radius: 4px; cursor: pointer; color: var(--text-muted);
  font-size: 0.9rem; user-select: none;
}
.mode-toggle label:hover { color: var(--text-body); border-color: var(--border-hover); }
.mode-toggle label:has(input:checked) {
  background: var(--accent); border-color: var(--accent-border); color: var(--accent-text);
}
.mode-toggle label:has(input:focus-visible) { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.mode-toggle input[type="radio"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

.new-project-form .form-field { margin-bottom: 1.1rem; }
.new-project-form .form-field > label:not(.checkbox-label) { display: block; color: var(--text-body); font-size: 0.85rem; margin-bottom: 0.35rem; }
.new-project-form input[type="text"],
.new-project-form input[type="url"],
.new-project-form select { width: 100%; }

/* Import-mode fields appear (and blank-only ones hide) with the toggle. */
.new-project-form .import-only { display: none; }
.new-project-form:has(input[name="mode"][value="import"]:checked) .import-only { display: block; }
.new-project-form:has(input[name="mode"][value="import"]:checked) .blank-only { display: none; }
.new-project-form .submit-label-import { display: none; }
.new-project-form:has(input[name="mode"][value="import"]:checked) .submit-label-blank { display: none; }
.new-project-form:has(input[name="mode"][value="import"]:checked) .submit-label-import { display: inline; }

.project-header { margin-bottom: 1.5rem; }
.project-header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.project-crumb {
  display: flex; align-items: baseline; gap: 0.4rem;
  font-size: 1.25rem; overflow-wrap: anywhere;
}
/* The crumb is the page's <h1> on section pages (SI-25) and a <p> on pages
   with a title of their own; both read as the crumb, not as a heading. */
.project-crumb-title {
  display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap;
  font-size: var(--text-lg); font-weight: 400; line-height: var(--leading-tight);
}
.project-crumb-namespace { color: var(--text-muted); }
.project-crumb-sep { color: var(--text-faint); }
.project-crumb-name { font-weight: 700; color: var(--text-primary); }
.project-crumb-name:hover { color: var(--accent-text); text-decoration: none; }
/*
 * Project tabs (DESIGN.md, "Tabs"). Every tab is inline above 640px; on a
 * phone the first four stay and the rest move into a "More" <details> menu,
 * with the active tab always among the four. No invisible scroller.
 */
.project-tabs {
  display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid var(--border);
}
.project-tab {
  display: inline-flex; align-items: center; min-height: var(--control-h);
  padding: 0 var(--space-3); color: var(--text-muted); font-size: var(--text-base);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}
.project-tab:hover { color: var(--text-body); text-decoration: none; }
.project-tab-active { color: var(--text-primary); border-bottom-color: var(--accent-text); }
/* "More" is a tab that opens the shared menu (see "Menus" below); the extra
   class outranks .menu's own display. */
.project-tabs .project-tabs-more { display: none; }
.project-tabs-more-summary { cursor: pointer; list-style: none; user-select: none; gap: var(--space-2); }
.project-tabs-more-summary::-webkit-details-marker { display: none; }
.project-tabs-more[open] > .project-tabs-more-summary { color: var(--text-primary); }
.project-tabs-more[open] > .project-tabs-more-summary .menu-chevron { transform: translateY(2px) rotate(-135deg); }
/* Inset, so the tab row's edge does not cut the ring. */
.project-tabs-more-summary:focus-visible { outline-offset: -2px; }

/* The fourth tab moves into "More" only on the narrowest phones. */
.project-tabs-more .menu-item-narrow { display: none; }

@media (max-width: 640px) {
  .project-tab { min-height: var(--control-h-touch); padding: 0 var(--space-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .project-tab-overflow { display: none; }
  .project-tabs .project-tabs-more { display: flex; flex: none; margin-left: auto; }
}
@media (max-width: 389px) {
  .project-tab-overflow-narrow { display: none; }
  .project-tabs-more .menu-item-narrow { display: list-item; }
}

/*
 * The branch picker (DESIGN.md, "Pickers") is the shared menu: its summary
 * names the branch on screen and keeps a long name to one line.
 */
.ref-picker .menu-summary { max-width: 16rem; }
.ref-picker-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-picker .menu-panel { left: auto; right: 0; min-width: 16rem; max-height: none; max-width: min(28rem, calc(100vw - 2 * var(--space-4))); }
.ref-picker .menu-item { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .ref-picker .menu-panel { left: 0; right: auto; }
}

/* A Markdown file opens rendered; its source is one disclosure below. */
.file-viewer-markdown { padding: var(--space-5); }
.file-viewer-source { padding: 0; }
.file-viewer-source > summary {
  display: flex; align-items: center; min-height: var(--control-h); padding: 0 var(--space-5);
  color: var(--text-muted); font-size: var(--text-sm); cursor: pointer;
}
.file-viewer-source > summary:hover { color: var(--text-body); }
.file-viewer-source[open] > summary { border-bottom: 1px solid var(--border); }
.file-viewer-source pre { margin: 0; padding: var(--space-4) var(--space-5); overflow-x: auto; font-size: var(--text-sm); }
@media (max-width: 640px) {
  .file-viewer-markdown { padding: var(--space-4); }
  .file-viewer-source > summary { min-height: var(--control-h-touch); padding: 0 var(--space-4); }
}

.error-page { max-width: 30rem; margin: var(--space-16) auto; text-align: center; }
/* The code is ornament (aria-hidden; the h1 says it in words), so --text-faint is allowed. */
.error-page-code {
  font-size: var(--text-display); font-weight: var(--weight-bold); color: var(--text-faint);
  line-height: 1; font-variant-numeric: tabular-nums;
}
.error-page-title {
  font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight);
  margin: var(--space-3) 0 var(--space-2);
}
.error-page-hint { color: var(--text-muted); margin-bottom: var(--space-6); overflow-wrap: anywhere; }
.error-page-actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }

/* Repo sync line: where the project syncs from and how it stands, one line
   under the header (SI-16). */
.repo-sync-line {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3);
  margin: 0 0 var(--space-4); font-size: var(--text-sm); color: var(--text-body);
}
.repo-sync-line a { color: var(--accent-text); overflow-wrap: anywhere; }
.repo-sync-when { color: var(--text-muted); }
.repo-sync-error { flex-basis: 100%; margin: 0; color: var(--error-text-soft); overflow-wrap: anywhere; }

/* Commit table */
.commit-table { table-layout: fixed; width: 100%; }
.commit-sha { width: 72px; font-size: 0.8rem; color: var(--text-muted); }
.commit-message { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }
.commit-author { width: 160px; font-size: 0.82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit-date { width: 7rem; font-size: 0.82rem; color: var(--text-muted); text-align: right; }
/* At <=640px the commit table stacks (.table-stack): message first, then SHA, author and date. */

/* Site footer — carries the AGPL §13 source offer, so it is a legal notice
   rather than an ornament: --text-muted (7.3:1), never --text-faint. The
   separators are the only decorative part. */
/* The footer box is .main's content box (its width less the gutter on each
   side), not its padded box: the rule then spans the content and the text
   starts on the content's left edge at every width. */
.site-footer {
  width: min(calc(100% - 2 * var(--page-gutter)), calc(var(--content-max) - 2 * var(--page-gutter)));
  margin: 0 auto; padding: var(--space-6) 0 var(--space-8);
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); color: var(--text-muted);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent-text); }
.site-footer-sep { color: var(--text-faint); }

/* Usage: the 80% banner in the shared chrome, and the /settings/usage page.
   No dismiss control and no script — the banner is markup the layout either
   renders or does not. */
.usage-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1rem; margin-bottom: 1.5rem; padding: 0.75rem 1rem;
  background: var(--warning-surface); border: 1px solid var(--warning-text);
  border-radius: 6px; color: var(--warning-text); font-size: 0.85rem;
}
.usage-banner a { color: var(--warning-text); text-decoration: underline; white-space: nowrap; }

/* Repo page: the cached view is of an earlier commit and a refresh is running.
   Informational, not a warning — nothing is wrong, the page is catching up. */
.repo-behind-notice {
  display: block; margin-bottom: 1rem; padding: 0.6rem 1rem;
  border: 1px solid var(--border-strong); border-radius: 6px;
  color: var(--text-muted); font-size: 0.85rem;
}

.usage-meter { padding: 0.85rem 0; border-bottom: 1px solid var(--divider); }
.usage-meter:first-of-type { padding-top: 0; }
.usage-meter:last-child { border-bottom: none; padding-bottom: 0; }
.usage-meter-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.25rem 1rem; margin-bottom: 0.5rem;
}
.usage-meter-name { font-weight: 600; color: var(--text-primary); }
.usage-meter-figure { font-size: 0.85rem; color: var(--text-body); }
/* Words, not an empty bar: an unlimited meter has no fraction to draw. */
.usage-unlimited { color: var(--success-text); }
.usage-blocked { color: var(--error-text); }
.usage-meter .progress-bar { margin-bottom: 0.5rem; }

/* ============================================================================
   Menus: a <details> whose panel is a list of links (DESIGN.md "Pickers").
   Works with no script; the panel is the one shadowed surface.
   ========================================================================== */
.menu { position: relative; display: inline-block; }
.menu-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-3);
  background: var(--bg-raised); color: var(--text-primary);
  border: 1px solid var(--border-control); border-radius: var(--radius-sm);
  font-size: var(--text-base); white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}
.menu-summary::-webkit-details-marker { display: none; }
.menu-summary:hover { background: var(--bg-hover); border-color: var(--border-hover); }
/* The chevron is drawn, like the select's, so it matches every control. */
.menu-chevron {
  width: var(--space-2); height: var(--space-2);
  border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-2px) rotate(45deg);
}
.menu[open] > .menu-summary .menu-chevron { transform: translateY(2px) rotate(-135deg); }
.menu-panel {
  position: absolute; z-index: 10; top: calc(100% + var(--space-1)); left: 0;
  min-width: 12rem; max-height: 20rem; overflow-y: auto;
  list-style: none; padding: var(--space-1) 0;
  background: var(--bg-overlay); border-radius: var(--radius-md); box-shadow: var(--shadow-overlay);
}
.menu-item {
  display: block; padding: var(--space-2) var(--space-3);
  color: var(--text-body); white-space: nowrap;
}
.menu-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.menu-item[aria-current="true"] { color: var(--text-primary); font-weight: var(--weight-medium); }
.menu-item[aria-current="true"]::before { content: "✓"; color: var(--accent-text); margin-right: var(--space-2); }
.menu-item:not([aria-current="true"]) { padding-left: calc(var(--space-3) + 1.5ch); }
/* A panel at the right edge of its row opens leftward, so it stays on screen. */
.menu-panel-end { left: auto; right: 0; }
.menu-heading { padding: var(--space-2) var(--space-3) var(--space-1); color: var(--text-muted); font-size: var(--text-sm); }
.menu-list { list-style: none; }
/* A link past the list ("View all branches"), set apart by a rule. */
.menu-footer {
  display: block; margin-top: var(--space-1); padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--divider); font-size: var(--text-sm);
}
@media (max-width: 640px) {
  .menu-summary { min-height: var(--control-h-touch); }
  .menu-item, .menu-footer { display: flex; align-items: center; min-height: var(--control-h-touch); padding-top: 0; padding-bottom: 0; }
}

/* ============================================================================
   Form actions (SI-28): a form's submit and its Cancel sit together at the
   foot of the form, never apart in the page header (on a phone that is a
   screen away). One primary; Cancel is the secondary beside it.
   ========================================================================== */
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* "Nov 24, 2026" or "3h ago" is one token: it never breaks across lines. */
time { white-space: nowrap; }

/* ============================================================================
   Changes list (forge #21): state tabs, author and text filters, rows grouped
   by who the change waits on. Desktop is a five-column grid; at <=640px each
   row stacks (badge and time, title, meta, blocker) so nothing is off-screen.
   ========================================================================== */
.changes-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-6);
}
.changes-states {
  display: inline-flex; border: 1px solid var(--border-control);
  border-radius: var(--radius-sm); overflow: hidden;
}
.changes-states a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  /* The group's own 1px border makes it a control's height overall. */
  min-height: calc(var(--control-h) - 2px); padding: 0 var(--space-3);
  color: var(--text-body); border-right: 1px solid var(--border-control);
  transition: background-color var(--duration-fast) var(--ease-out);
}
.changes-states a:last-child { border-right: 0; }
.changes-states a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.changes-states a[aria-current="page"] { background: var(--bg-raised); color: var(--text-primary); font-weight: var(--weight-medium); }
/* Inset ring: the default outline would be clipped by the group's overflow. */
.changes-states a:focus-visible { outline-offset: -2px; }
.changes-state-count { color: var(--text-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; font-weight: var(--weight-regular); }
.changes-filters { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.changes-search { display: flex; align-items: center; gap: var(--space-2); }
.changes-search-label { color: var(--text-muted); font-size: var(--text-sm); }
.changes-search input { width: 14rem; }
.changes-filtered { color: var(--text-muted); font-size: var(--text-sm); margin: calc(-1 * var(--space-3)) 0 var(--space-6); }

.change-group { margin-bottom: var(--space-8); }
.change-group-head { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-1); }
.change-group-head h2 { font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-tight); }
.change-group-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.change-group-hint { color: var(--text-muted); font-size: var(--text-sm); margin-bottom: var(--space-3); max-width: var(--prose-max); }

.change-list { list-style: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.change-row {
  position: relative;
  display: grid; grid-template-columns: 10rem minmax(0, 1fr) 8rem 7rem 5.5rem;
  gap: var(--space-4); align-items: start;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--duration-fast) var(--ease-out);
}
.change-row:last-child { border-bottom: 0; }
.change-row:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.change-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.change-row:only-child { border-radius: var(--radius-md); }
.change-row:hover { background: var(--bg-raised); }
.change-row-status .badge { vertical-align: top; }
.change-row-title {
  color: var(--text-primary); font-weight: var(--weight-medium);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.change-row-title:hover { color: var(--text-primary); }
/* The whole row opens the change; the title keeps the global focus ring. */
.change-row-title::after { content: ""; position: absolute; inset: 0; }
.change-row-meta {
  display: flex; flex-wrap: wrap; align-items: baseline;
  margin-top: var(--space-1); font-size: var(--text-sm); color: var(--text-muted);
}
.change-row-mi { white-space: nowrap; }
.change-row-mi + .change-row-mi::before { content: "·"; color: var(--text-faint); margin: 0 var(--space-2); }
/* The workspace is its own token: never joined to the title, never broken mid-name on desktop. */
.change-row-ws { color: var(--text-body); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.change-agent-tag {
  margin-left: var(--space-1); padding: 0 var(--space-1);
  font-size: var(--text-xs); color: var(--text-muted);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.change-row-blocker { margin-top: var(--space-1); font-size: var(--text-sm); }
.change-row-blocker-warn { color: var(--warning-text); }
.change-row-blocker-info { color: var(--text-body); }
.change-row-gates, .change-row-pr, .change-row-when { font-size: var(--text-sm); white-space: nowrap; font-variant-numeric: tabular-nums; }
.change-row-gates { color: var(--text-body); }
.change-row-when { color: var(--text-muted); text-align: right; }
.change-gates-ok { color: var(--success-text); }
.change-gates-bad { color: var(--danger-text); }
.change-gates-run { color: var(--accent-text); }
.change-row-none { color: var(--text-muted); }
/* Above the row's link, so it opens GitHub rather than the change. */
.change-pr { position: relative; z-index: 1; }
.change-row-phone { display: none; }
.changes-pages { display: flex; justify-content: center; gap: var(--space-2); margin-top: var(--space-6); }

@media (max-width: 960px) {
  .change-row { grid-template-columns: 9rem minmax(0, 1fr) 7.5rem 5.5rem; }
  .change-row-pr { display: none; }
  .change-row-meta .change-row-phone:has(.change-pr) { display: inline; }
}

@media (max-width: 640px) {
  .changes-toolbar { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  /* Four equal cells, the count under the label, so "Merged 128" fits at 320px. */
  .changes-states { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .changes-states a {
    flex-direction: column; justify-content: center; gap: 0;
    min-height: var(--control-h-touch); padding: var(--space-1); line-height: var(--leading-tight);
  }
  .changes-filters { flex-direction: column; align-items: stretch; }
  .changes-author .menu-summary { width: 100%; justify-content: space-between; min-height: var(--control-h-touch); }
  .changes-search { width: 100%; }
  /* A zero basis: a field's intrinsic width (about 20 characters) would
     otherwise set the form's minimum and push the page sideways at 320px. */
  .changes-search input { flex: 1 1 0; width: 0; min-width: 0; }
  .changes-search .btn { min-height: var(--control-h-touch); }
  .changes-filtered { margin-top: 0; }
  .change-row { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); padding: var(--space-3); }
  .change-row-status { grid-column: 1; grid-row: 1; }
  .change-row-when { grid-column: 2; grid-row: 1; }
  .change-row-main { grid-column: 1 / -1; grid-row: 2; }
  .change-row-gates, .change-row-pr { display: none; }
  .change-row-meta .change-row-phone { display: inline; }
  /* The workspace gets its own line, so the meta after it never runs off the edge. */
  .change-row-ws { flex-basis: 100%; white-space: normal; overflow-wrap: anywhere; }
  .change-row-ws + .change-row-mi::before { content: none; margin: 0; }
  .change-pr { display: inline-block; padding: var(--space-1) 0; }
}

/* ============================================================================
   Off-system pages on the system (SI-27): the email sign-in pages, GitHub App
   setup, project settings, the settings section tabs and the workspaces empty
   state.
   ========================================================================== */

/* Auth shell (src/ui/components/auth-shell.tsx): the sign-in page's look — the
   wordmark bar, one centered card, the source offer — for the pages a magic
   link lands on. */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth-shell-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: var(--space-8) var(--space-4);
}
.auth-shell-card {
  width: 100%; max-width: 26rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-8);
}
.auth-shell-status { color: var(--success-text); font-size: var(--text-sm); margin-bottom: var(--space-2); }
.auth-shell-title {
  font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight);
  color: var(--text-primary); margin-bottom: var(--space-4);
}
.auth-shell-lead { color: var(--text-body); }
.auth-shell-lead + .auth-shell-lead { margin-top: var(--space-3); }
.auth-shell-alert {
  margin-top: var(--space-4); padding: var(--space-3) var(--space-4);
  background: var(--danger-surface); border: 1px solid var(--danger-border); border-radius: var(--radius-sm);
  color: var(--danger-text-soft);
}
.auth-shell-form { display: flex; flex-direction: column; gap: var(--space-5); margin-top: var(--space-6); }
.auth-shell-field { display: flex; flex-direction: column; gap: var(--space-2); }
.auth-shell-field label { color: var(--text-body); font-size: var(--text-sm); }
.auth-shell-code { font-size: var(--text-lg); text-align: center; font-variant-numeric: tabular-nums; }
.auth-shell-actions { margin-top: var(--space-6); }
.auth-shell-submit {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: var(--control-h);
}
/* The telemetry consent box (TelemetryConsentField) inside an auth card. */
.auth-shell .checkbox-group { display: flex; align-items: flex-start; gap: var(--space-2); }
.auth-shell .checkbox-group input { margin-top: var(--space-1); }
.auth-shell .checkbox-label { display: block; color: var(--text-body); }
.auth-shell .input-hint {
  margin-top: var(--space-1); padding-left: calc(1.15rem + var(--space-2));
  color: var(--text-muted); font-size: var(--text-sm);
}
/* The sign-in page: a notice for an editor that is connecting, field help,
   the remember-me box, the "or" rule between the email form and the
   providers, and the link to sign up. */
.auth-shell-notice {
  margin-top: var(--space-4); padding: var(--space-3) var(--space-4);
  background: var(--accent-surface); border: 1px solid var(--accent-border); border-radius: var(--radius-sm);
  color: var(--text-body);
}
.auth-shell-alert a { color: var(--danger-text-soft); text-decoration: underline; }
.auth-shell-help { color: var(--text-muted); font-size: var(--text-sm); }
.auth-shell-check { display: flex; align-items: center; gap: var(--space-2); }
.auth-shell-check label { color: var(--text-body); font-size: var(--text-sm); cursor: pointer; }
.auth-shell-divider {
  display: flex; align-items: center; gap: var(--space-4);
  margin: var(--space-6) 0; color: var(--text-muted); font-size: var(--text-sm);
}
.auth-shell-divider::before,
.auth-shell-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border-strong); }
.auth-shell-providers { display: flex; flex-direction: column; gap: var(--space-2); }
.auth-shell-icon { width: var(--space-4); height: var(--space-4); flex-shrink: 0; }
.auth-shell-alt {
  margin-top: var(--space-6); padding-top: var(--space-6); border-top: 1px solid var(--border);
  color: var(--text-body); text-align: center;
}
/* The sign-up forms (src/routes/signup.tsx, oauth-signup.tsx): the live
   username check under the field, the field and help text it colours, and
   the advisory line above the submit button. */
.auth-shell-username-status {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); color: var(--text-muted);
}
.auth-shell-username-status:empty { display: none; }
.auth-shell-username-status.is-available { color: var(--success-text); }
.auth-shell-username-status.is-taken,
.auth-shell-username-status.is-error { color: var(--danger-text-soft); }
.auth-shell-field input.is-error { border-color: var(--danger-text-soft); }
.auth-shell-field input.is-success { border-color: var(--success-text); }
.auth-shell-help.is-error { color: var(--danger-text-soft); }
.auth-shell-help.is-success { color: var(--success-text); }
.auth-shell-form-end { display: flex; flex-direction: column; gap: var(--space-2); }
.auth-shell-submit-status { color: var(--text-muted); font-size: var(--text-sm); text-align: center; }
.auth-shell-submit-status:empty { display: none; }
@media (max-width: 640px) {
  .auth-shell-main { align-items: flex-start; padding: var(--space-6) var(--space-4); }
  .auth-shell-card { padding: var(--space-5); }
  /* Re-assert the 44px phone target: .auth-shell-submit comes after the .btn rule. */
  .auth-shell-submit { min-height: var(--control-h-touch); }
}

/* A one-line outcome above a page's content: not a card, which holds more. */
.page-notice {
  display: block; margin-bottom: var(--space-6); padding: var(--space-3) var(--space-4);
  background: var(--bg-card); border: 1px solid var(--accent-border); border-radius: var(--radius-md);
  color: var(--text-body);
}

/* GitHub App setup: three numbered steps, one sentence each. */
.setup-intro { color: var(--text-body); max-width: var(--prose-max); margin: calc(-1 * var(--space-2)) 0 var(--space-6); }
.setup-steps {
  list-style: none; margin-bottom: var(--space-6);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.setup-step {
  display: grid; grid-template-columns: var(--space-8) minmax(0, 1fr); gap: var(--space-4);
  padding: var(--space-5); border-bottom: 1px solid var(--border);
}
.setup-step:last-child { border-bottom: 0; }
.setup-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--space-8); height: var(--space-8);
  border: 1px solid var(--border-control); border-radius: var(--radius-sm);
  color: var(--text-primary); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums;
}
.setup-step-body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); min-width: 0; }
.setup-step-title {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  min-height: var(--space-8);
  font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-tight);
}
.setup-step-text { color: var(--text-muted); max-width: var(--prose-max); }
.setup-step-blocked { color: var(--text-body); }
.setup-step-text code { font-size: var(--text-sm); color: var(--text-body); overflow-wrap: anywhere; }
.install-unconfirmed { display: flex; flex-direction: column; gap: var(--space-2); }
.install-list { list-style: none; align-self: stretch; border-top: 1px solid var(--border); }
/* Fixed columns, so every row's "Linked to" and actions line up with the next. */
.install-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 12rem 22rem;
  gap: var(--space-2) var(--space-4); align-items: center;
  padding: var(--space-3) 0; border-bottom: 1px solid var(--border);
}
.install-row:last-child { border-bottom: 0; padding-bottom: 0; }
.install-account { display: flex; flex-direction: column; min-width: 0; }
.install-login { color: var(--text-primary); font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.install-meta { color: var(--text-muted); font-size: var(--text-sm); }
.install-linked { overflow-wrap: anywhere; }
.install-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.install-link-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.install-link-form label { color: var(--text-muted); font-size: var(--text-sm); }
.install-link-form select { max-width: 14rem; }
.setup-details { color: var(--text-muted); max-width: var(--prose-max); }
.setup-details summary { cursor: pointer; color: var(--accent-text); }
.setup-details p { margin-top: var(--space-2); }
@media (max-width: 960px) {
  .install-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .install-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 640px) {
  .setup-step { gap: var(--space-3); padding: var(--space-4); }
  .install-row { grid-template-columns: minmax(0, 1fr); }
  .install-link-form { width: 100%; }
  .install-link-form select { flex: 1; min-width: 0; max-width: none; }
}

/* Project settings: card titles, the mirror's state and its form. */
.settings-card-title {
  font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-tight);
  color: var(--text-primary); margin-bottom: var(--space-3);
}
.danger-zone .settings-card-title { color: var(--danger-text); }
.settings-points { padding-left: var(--space-5); }
.settings-points li { margin: 0 0 var(--space-1); }
.settings-after-form { margin-top: var(--space-4); }
.mirror-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); }
.mirror-form {
  display: flex; flex-direction: column; gap: var(--space-4);
  max-width: 40rem; margin-top: var(--space-5); padding-top: var(--space-5);
  border-top: 1px solid var(--divider);
}
.settings-stack-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 40rem; }
.settings-stack-form .settings-help { margin: 0; }
.mirror-field { display: flex; flex-direction: column; gap: var(--space-2); }
.mirror-field > label:not(.checkbox-label) { color: var(--text-body); font-size: var(--text-sm); }
.mirror-field input[type="text"] { width: 100%; max-width: 24rem; }
.mirror-field .checkbox-label { min-height: var(--control-h); }
.mirror-field-help { margin: 0; padding-left: calc(1.15rem + var(--space-2)); }
.secret-list { list-style: none; border-top: 1px solid var(--border); }
.secret-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2) var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border);
}
.secret-row:last-child { border-bottom: 0; padding-bottom: 0; }
.secret-row-main { display: flex; flex-direction: column; min-width: 0; }
.secret-row-name { color: var(--text-primary); overflow-wrap: anywhere; }
.secret-row-meta { color: var(--text-muted); font-size: var(--text-sm); }

/* Section tabs (src/ui/components/section-tabs.tsx). The whole row on wide
   screens; on narrow ones the first few stay and "More" lists the rest. Each
   tab is in the row and in the menu, and the media queries below show each in
   exactly one place, so nothing scrolls out of sight. */
.section-tabs {
  display: flex; align-items: flex-end; gap: var(--space-1);
  margin-bottom: var(--space-5); border-bottom: 1px solid var(--border);
}
.section-tabs-row { display: flex; gap: var(--space-1); list-style: none; min-width: 0; }
.section-tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); margin-bottom: -1px;
  color: var(--text-muted); font-size: var(--text-base); white-space: nowrap;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.section-tab:hover { color: var(--text-body); text-decoration: none; border-bottom-color: var(--border-strong); }
.section-tabs-more { position: relative; display: none; }
.section-tabs-more > summary { list-style: none; user-select: none; }
.section-tabs-more > summary::-webkit-details-marker { display: none; }
.section-tabs-more[open] > summary { color: var(--text-primary); }
.section-tabs-more[open] > summary .menu-chevron { transform: translateY(2px) rotate(-135deg); }
.section-tabs-panel { left: auto; right: 0; }
.section-tabs-panel .menu-item:not([aria-current="true"]) { padding-left: var(--space-3); }
@media (max-width: 640px) {
  .section-tab { min-height: var(--control-h-touch); padding: 0 var(--space-3); }
  .section-tabs-more { display: block; margin-left: auto; }
  .section-tabs-row > li:nth-child(n + 5) { display: none; }
  .section-tabs-panel > li:nth-child(-n + 4) { display: none; }
}
/* Four tabs do not fit a phone held upright; three do, then two. */
@media (max-width: 480px) {
  .section-tabs-row > li:nth-child(4) { display: none; }
  .section-tabs-panel > li:nth-child(4) { display: list-item; }
}
@media (max-width: 360px) {
  .section-tabs-row > li:nth-child(3) { display: none; }
  .section-tabs-panel > li:nth-child(3) { display: list-item; }
}

/* A command to run, in its own box and selected whole in one click
   (user-select: all), since a copy button would need script. It wraps at its
   spaces rather than running off a phone's edge; the wrap is only visual, so
   what is selected and pasted is still the one line. */
.empty-state-narrow { max-width: 40rem; margin: 0 auto; }
.cli-command {
  display: block; width: 100%; margin: var(--space-3) 0 var(--space-1);
  padding: var(--space-3) var(--space-4); text-align: left;
  background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-body);
  white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; cursor: text;
}
.cli-command-hint { color: var(--text-muted); font-size: var(--text-sm); margin-bottom: var(--space-3); }

/* Inline form errors (src/ui/components/field-error.tsx), in place of the
   browser's validation bubbles. Last in the sheet so the invalid border wins
   over each form's own input and focus rules at equal specificity. */
.field-error {
  display: flex; align-items: baseline; gap: 0.4rem;
  margin: 0.35rem 0 0; color: var(--error-text-soft); font-size: 0.8rem; line-height: 1.45;
}
.field-error::before {
  /* The empty alt text keeps the glyph out of what a screen reader announces;
     a browser without the syntax drops the second line and keeps the first. */
  content: "!"; content: "!" / ""; flex-shrink: 0; display: inline-grid; place-items: center;
  width: 1.1em; height: 1.1em; border-radius: 50%;
  background: var(--danger-surface); color: var(--error-text); font-weight: 700; font-size: 0.75rem;
}
.field-error[hidden] { display: none; }
.settings-form .field-error { margin-top: -0.4rem; }
.webhook-form .field-error { margin-top: -0.4rem; }
.webhook-events .field-error { margin: 0 0 0.5rem; }
.secret-field { display: flex; flex-direction: column; }
/* The :not() lifts these to (0,2,2), over the forms' own (0,2,1) input rules
   such as .new-project-form input[type="text"]. */
form input[aria-invalid="true"]:not([type="checkbox"]),
form select[aria-invalid="true"]:not([multiple]),
form textarea[aria-invalid="true"]:not([readonly]) {
  border-color: var(--error-text);
}
form input[aria-invalid="true"]:focus-visible, form textarea[aria-invalid="true"]:focus-visible {
  border-color: var(--error-text); outline-color: var(--error-text);
}
