/* ==========================================================================
   Relay design system: app.css
   --------------------------------------------------------------------------
   Hand-written, no build step. Wherry's language: a calm surface
   ladder, one violet accent for everything interactive, Mona Sans for display,
   the system UI font for reading, mono for labels, IDs, timestamps and keys.

   Colour meaning is strict:
     violet (--accent, --link)  interactive: buttons, links, focus, selection
     green  (--ok)              verified / resolved / delivered, nothing else
     rose   (--danger)          danger / destructive / errors, nothing else
     amber  (--warn)            warning / waiting, nothing else
   The brand gradient is for brand moments only (logo, a hero underline).

   Themes: :root below holds the Relay (purple/black) value of every token;
   /css/themes.css overrides them under [data-theme="..."] (light,
   midnight, forest, sand, high-contrast, and system = light when the OS is).
   Colours appear only here and in themes.css: everything else uses tokens.

   Class vocabulary (other areas use these and do not restyle them):
   .btn .btn-primary .btn-secondary .btn-ghost .btn-danger .btn-sm .btn-block
   .field .hint .error .input .select .textarea .checkbox .check
   .card .page-header .page-title .lede .eyebrow .mono .muted .display*
   .badge .badge-ok .badge-danger .badge-warn .badge-accent
   .stack .row .grid .gap-1..4 .container .container-narrow
   .table .table-wrap .num .empty .flash .flash-ok .flash-error .kbd
   .avatar .tabs .pager .menu .confirm .kv .visually-hidden .skip-link
   Area-specific styles live in /css/<area>.css.

   Sections
     1. Fonts            9. Badges, kbd, avatars
     2. Tokens          10. Tables, key/value lists
     3. Reset & base    11. Tabs, pager
     4. Typography      12. Flash, empty state
     5. Layout utils    13. Menus, confirm-delete
     6. Buttons         14. App shell
     7. Forms           15. Auth, error pages
     8. Cards, headers  16. Brand, htmx, motion
   ========================================================================== */


/* 1. Fonts ================================================================ */

/* Mona Sans Display SemiExpanded (OFL, github/mona-sans v2.0.27, see
   /fonts/OFL.txt). Display use only: page titles and marketing. */
/* Jost: the Relay wordmark (the logo's spaced capitals; also Tesseract's brand face). */
@font-face {
  font-family: "Jost";
  src: url("/fonts/Jost-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Mona Sans Display";
  src: url("/fonts/MonaSansDisplaySemiExpanded-ExtraBold.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Mona Sans Display";
  src: url("/fonts/MonaSansDisplaySemiExpanded-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* Metric-matched fallbacks: Arial Bold scaled to Mona Sans's average advance
   width (English letter frequencies) with its ascent/descent, so the swap
   doesn't reflow. Mona: UPM 1000, ascent 1090, descent 320, no line gap. */
@font-face {
  font-family: "Mona Sans Display Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Arial");
  font-weight: 800;
  size-adjust: 105.8%;
  ascent-override: 103%;
  descent-override: 30.2%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Mona Sans Display Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Arial");
  font-weight: 600;
  size-adjust: 102.1%;
  ascent-override: 106.8%;
  descent-override: 31.3%;
  line-gap-override: 0%;
}


/* 2. Tokens =============================================================== */

:root,
[data-theme="relay"],
[data-theme="system"] {
  color-scheme: dark;

  /* Surfaces, darkest to lightest. */
  --inset: #060606;
  --bg: #0A0A0A;
  --surface: #121212;
  --raised: #1A1A1A;
  --hover: #202020;

  /* Borders. --border-control is for form controls, whose edge must reach
     3:1 against any surface (WCAG 1.4.11); the subtle ones are decoration. */
  --border: #232323;
  --border-strong: #343434;
  --border-control: #6B6B6B;
  --border-control-hover: #858585;
  --border-hover: #4A4A4A;

  /* Text. --text-3 is for small meta text on --bg, --surface and --raised
     only (4.7:1 on --raised); never on tinted fills. */
  --text: #F5F5F5;
  --text-2: #A3A3A3;
  --text-3: #858585;
  --on-accent: #FFFFFF;
  --on-danger: #0A0A0A;

  /* The one accent. White text sits on --accent (5.3:1), never on
     --accent-hover (4.4:1): hover is shown with a ring, not a lighter fill. */
  --accent: #6D4BF6;
  --accent-hover: #7C5DF8;
  --link: #A190FF;
  --accent-soft: rgba(109, 75, 246, 0.16);
  --accent-line: rgba(109, 75, 246, 0.45);
  --link-line: rgba(161, 144, 255, 0.45);
  /* The focus ring: at least 3:1 against every surface. */
  --focus: var(--accent);

  /* Semantic colours (strict meaning, see header). */
  --ok: #34D399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --ok-line: rgba(52, 211, 153, 0.35);
  --danger: #FB7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --danger-line: rgba(251, 113, 133, 0.4);
  --warn: #FBBF24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --warn-line: rgba(251, 191, 36, 0.35);
  --info: #60A5FA;
  --info-soft: rgba(96, 165, 250, 0.12);
  --info-line: rgba(96, 165, 250, 0.35);

  /* Presence balls: green, yellow, red, gray (3:1 on every surface). */
  --presence-online: #34D399;
  --presence-away: #FBBF24;
  /* Stars (amber): the filled star on starred conversations; >= 3:1 on every surface. */
  --star: #FBBF24;
  --presence-busy: #FB7185;
  --presence-offline: #737373;

  /* Selection, scrollbars, code. */
  --selection-bg: rgba(109, 75, 246, 0.45);
  --selection-text: #FFFFFF;
  --scrollbar-thumb: var(--border-strong);
  --scrollbar-track: transparent;
  --code-bg: var(--raised);
  --code-text: var(--text);
  --code-border: var(--border);
  --pre-bg: var(--inset);

  /* Overlays: dialog backdrop, translucent sticky bars, neutral washes. */
  --backdrop: rgba(0, 0, 0, 0.6);
  --glass: rgba(10, 10, 10, 0.86);
  --wash-1: rgba(255, 255, 255, 0.015);
  --wash-2: rgba(255, 255, 255, 0.025);
  --wash-3: rgba(255, 255, 255, 0.04);

  /* Charts (Reports): bars, categorical series (also the workspace badges)
     and a sequential ramp for the heatmap, few (dark) to many (light). */
  --chart-bar: var(--accent);
  --chart-bar-hover: var(--link);
  --chart-grid: var(--border);
  --chart-1: #C4B5FF;
  --chart-2: #8CCBFF;
  --chart-3: #6EE7CF;
  --chart-4: #F7C873;
  --chart-5: #FFA8B9;
  --chart-6: #BFE57A;
  --heat-0: var(--raised);
  --heat-1: #2B2160;
  --heat-2: #3F2E99;
  --heat-3: #5A3DD6;
  --heat-4: #7C5DF8;
  --heat-5: #B3A5FF;

  /* Customer avatars (visitors, contacts), data-hue="1"…"10" from relay_store::visitor_name::hue:
     rose, orange, amber, lime, emerald, cyan, blue, indigo, purple, fuchsia. Initials are
     ≥ 4.5:1 on their fill (7:1 in high contrast); every theme sets all twenty. */
  --avatar-1-bg: #881337;
  --avatar-1-fg: #FECDD3;
  --avatar-2-bg: #7C2D12;
  --avatar-2-fg: #FED7AA;
  --avatar-3-bg: #78350F;
  --avatar-3-fg: #FDE68A;
  --avatar-4-bg: #365314;
  --avatar-4-fg: #D9F99D;
  --avatar-5-bg: #064E3B;
  --avatar-5-fg: #A7F3D0;
  --avatar-6-bg: #164E63;
  --avatar-6-fg: #A5F3FC;
  --avatar-7-bg: #1E3A8A;
  --avatar-7-fg: #BFDBFE;
  --avatar-8-bg: #312E81;
  --avatar-8-fg: #C7D2FE;
  --avatar-9-bg: #581C87;
  --avatar-9-fg: #E9D5FF;
  --avatar-10-bg: #701A75;
  --avatar-10-fg: #F5D0FE;

  /* The app rail: its background and the current item's block (the elevator). */
  --rail-bg: var(--bg);
  --rail-current: var(--accent-soft);

  /* Loading placeholders. */
  --skeleton: var(--raised);
  --skeleton-shine: var(--hover);

  /* Brand moments only. */
  --brand-gradient: linear-gradient(90deg, #9747FA 0%, #6D4BF6 50%, #4B87FB 100%);

  /* Type. */
  --font-display: "Mona Sans Display", "Mona Sans Display Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --tracking-display: -0.035em;
  --tracking-mono: 0.04em;

  /* Shape. */
  --radius-card: 12px;
  --radius-control: 8px;
  --radius-pill: 999px;
  --shadow-pop: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-accent: 0 8px 24px rgba(109, 75, 246, 0.35);
  --glow: rgba(109, 75, 246, 0.13);

  /* Spacing (4px base). */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Layout. */
  --container: 1180px;
  --container-narrow: 820px;
  --gutter: 24px;
  --rail-w: 88px;
  --rail-w-collapsed: 60px;
  --topbar-h: 56px;

  /* Motion. */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur-1: 150ms;
  --dur-2: 200ms;
  --dur-3: 250ms;
}


/* 3. Reset & base ========================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* The app is denser than marketing and help pages. */
body.app {
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol {
  margin: 0;
}

ul[class], ol[class] {
  list-style: none;
  padding: 0;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

svg {
  flex-shrink: 0;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

table {
  border-collapse: collapse;
}

hr {
  height: 1px;
  margin: var(--space-5) 0;
  border: 0;
  background: var(--border);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

/* One focus style everywhere: a 2px ring in --focus (3:1 or better on every
   surface in every theme). Mouse clicks don't show it; keyboard focus always does. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* The app's top bar is sticky (and on phones the rail is a bottom tab bar):
   keep a focused or scrolled-to element clear of them (WCAG 2.4.11). */
html:has(> body.app) {
  scroll-padding-top: calc(var(--topbar-h) + var(--space-3));
}

[hidden] {
  display: none !important;
}


/* 4. Typography =========================================================== */

h1, h2, h3, h4 {
  text-wrap: balance;
  line-height: 1.25;
  font-weight: 600;
}

h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: 1rem; }

p, li, dd, figcaption {
  text-wrap: pretty;
}

a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--link-line);
  text-underline-offset: 3px;
  transition: color var(--dur-1) var(--ease), text-decoration-color var(--dur-1) var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

strong, b {
  font-weight: 600;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  padding: 0.1em 0.4em;
  border: 1px solid var(--code-border);
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--code-text);
}

pre {
  overflow-x: auto;
  padding: var(--space-4);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-control);
  background: var(--pre-bg);
  color: var(--code-text);
  line-height: 1.55;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
}

/* Display: Mona Sans 800 for page titles and marketing only. */
.display,
.display-xl,
.display-lg,
.display-md {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: var(--tracking-display);
  line-height: 1;
  text-wrap: balance;
}

.display-xl { font-size: clamp(42px, 6vw, 74px); line-height: 0.98; }
.display-lg { font-size: clamp(36px, 4.8vw, 56px); }
.display-md { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.05; }

.lede {
  color: var(--text-2);
  font-size: 1.0625em;
  line-height: 1.55;
  max-width: 62ch;
  text-wrap: pretty;
}

/* Mono labels: IDs, timestamps, figure captions, chapter numbers. Sentence
   case, never all-caps. */
.mono {
  font-family: var(--font-mono);
  font-size: 0.8667em;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: var(--tracking-mono);
  color: var(--text-2);
}

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

.small {
  font-size: 0.8667em;
}

.prose {
  max-width: 68ch;
}

.prose > * + * {
  margin-top: 1em;
}

.prose h2 { margin-top: 2em; }
.prose h3 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.35em; }

.prose blockquote {
  padding-left: var(--space-4);
  border-left: 2px solid var(--border-strong);
  color: var(--text-2);
}


/* 5. Layout utilities ===================================================== */

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container-narrow {
  width: 100%;
  max-width: calc(var(--container-narrow) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

.row-between {
  justify-content: space-between;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--space-4);
}

/* Grid and flex children may shrink below their content (long code lines,
   URLs, tables scroll inside instead of widening the page). */
.grid > *,
.stack > * {
  min-width: 0;
}

/* Gap scale: 1 = 4px, 2 = 8px, 3 = 16px, 4 = 24px. Declared after the
   layout classes so they win at equal specificity. */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-4); }
.gap-4 { gap: var(--space-5); }

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur-1) var(--ease);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  outline: 2px solid var(--text);
  outline-offset: 2px;
}


/* 6. Buttons ============================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-hover), var(--shadow-accent);
}

.btn-secondary {
  background: var(--raised);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--hover);
  border-color: var(--border-hover);
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--raised);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
  gap: 6px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-block {
  width: 100%;
}

/* On narrow screens long labels wrap instead of pushing the page sideways
   (WCAG 1.4.10 reflow at 320px). */
@media (max-width: 720px) {
  .btn {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}


/* 7. Forms ================================================================ */

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > label,
.field-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.field .optional {
  margin-left: 6px;
  font-weight: 400;
  color: var(--text-2);
}

.hint {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
}

.error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--danger);
}

.error svg {
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-control);
  background: var(--inset);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  transition:
    border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease),
    background-color var(--dur-1) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
  opacity: 1;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-control-hover);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  outline-color: var(--danger);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: not-allowed;
}

.input[readonly] {
  background: var(--surface);
  border-color: var(--border-strong);
}

.input.mono {
  font-size: 14px;
}

.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

/* Native select with a CSS-drawn chevron (no images, CSP-friendly). */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.select option {
  background: var(--raised);
  color: var(--text);
}

/* Checkbox / radio: native control, violet when checked. */
.checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
}

.check .checkbox {
  margin-top: 2px;
}

.check .hint {
  display: block;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-2);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
  margin-bottom: var(--space-3);
  font-weight: 600;
}


/* 8. Cards & page headers ================================================= */

.card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card > h2,
.card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin: var(--space-5) calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--wash-1);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}

.page-header > :first-child {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.page-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-wrap: balance;
}

.page-header .lede {
  font-size: 15px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.section + .section {
  margin-top: var(--space-7);
}

.section-title {
  margin-bottom: var(--space-4);
  font-size: 17px;
  font-weight: 600;
}


/* 9. Badges, kbd, avatars ================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-ok,
.badge-danger,
.badge-warn {
  font-weight: 600;
}

.badge-ok::before,
.badge-danger::before,
.badge-warn::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.badge-danger { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.badge-warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.badge-accent { border-color: var(--accent-line); background: var(--accent-soft); color: var(--link); }

/* Numeric counter pill (unread counts, tab counts). */
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.count-accent {
  background: var(--accent);
  color: var(--on-accent);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--raised);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  vertical-align: middle;
}

.kbd + .kbd {
  margin-left: 3px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--raised);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }

/* "You" / the signed-in user. */
.avatar-accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--link);
}

/* A teammate's uploaded picture (relay_web::components::teammate_avatar): square PNG
   re-encoded by the server, clipped to the circle. */
.avatar-img { overflow: hidden; background: var(--raised); }
.avatar-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-xl { width: 96px; height: 96px; font-size: 32px; }

/* Customers (visitors, contacts): one of ten colours picked from their id
   (relay_web::components::customer_avatar). Teammates keep the neutral circle. */
.avatar[data-hue] { border-color: transparent; }
.avatar[data-hue="1"] { background: var(--avatar-1-bg); color: var(--avatar-1-fg); }
.avatar[data-hue="2"] { background: var(--avatar-2-bg); color: var(--avatar-2-fg); }
.avatar[data-hue="3"] { background: var(--avatar-3-bg); color: var(--avatar-3-fg); }
.avatar[data-hue="4"] { background: var(--avatar-4-bg); color: var(--avatar-4-fg); }
.avatar[data-hue="5"] { background: var(--avatar-5-bg); color: var(--avatar-5-fg); }
.avatar[data-hue="6"] { background: var(--avatar-6-bg); color: var(--avatar-6-fg); }
.avatar[data-hue="7"] { background: var(--avatar-7-bg); color: var(--avatar-7-fg); }
.avatar[data-hue="8"] { background: var(--avatar-8-bg); color: var(--avatar-8-fg); }
.avatar[data-hue="9"] { background: var(--avatar-9-bg); color: var(--avatar-9-fg); }
.avatar[data-hue="10"] { background: var(--avatar-10-bg); color: var(--avatar-10-fg); }

.timestamp {
  color: var(--text-2);
  white-space: nowrap;
}


/* 10. Tables, key/value lists ============================================= */

.table-wrap {
  /* Positioned, so visually hidden text in a wide table is clipped by this
     scroller instead of widening the page (reflow at 320px). */
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.table {
  width: 100%;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.table caption {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  color: var(--text-2);
  font-size: 13px;
}

.table th {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: bottom;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
  white-space: nowrap;
}

.table td {
  padding: 12px var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

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

.table tbody tr:hover {
  background: var(--wash-2);
}

.table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
}

.table a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.table a:hover {
  color: var(--link);
}

.kv {
  display: grid;
  grid-template-columns: minmax(96px, max-content) 1fr;
  gap: 10px var(--space-5);
  font-size: 14px;
}

.kv dt {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: var(--tracking-mono);
  line-height: 1.6;
}

.kv dd {
  min-width: 0;
  overflow-wrap: anywhere;
}


/* 11. Tabs, pager ========================================================= */

.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px 12px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}

.tabs a::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--dur-2) var(--ease);
}

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

.tabs a[aria-current="page"],
.tabs a[aria-selected="true"] {
  color: var(--text);
}

.tabs a[aria-current="page"]::after,
.tabs a[aria-selected="true"]::after {
  transform: scaleX(1);
}

.tabs a:focus-visible {
  outline-offset: -2px;
  border-radius: 6px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) 0;
}

.pager-end {
  color: var(--text-2);
  font-size: 13px;
}


/* 12. Flash, empty state ================================================== */

.flash-region:empty {
  display: none;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 12px var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  animation: flash-in var(--dur-3) var(--ease);
}

/* components::view_only_note: a viewer's "You have view-only access." */
.flash.view-only {
  margin-bottom: var(--space-4);
  color: var(--text-2);
}
.flash.view-only strong { color: var(--text); }

.flash svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--text-2);
}

.flash-ok { border-color: var(--ok-line); }
.flash-ok svg { color: var(--ok); }
.flash-error { border-color: var(--danger-line); }
.flash-error svg { color: var(--danger); }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  background: var(--raised);
  color: var(--text-2);
}

.empty-icon svg {
  width: 20px;
  height: 20px;
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
}

.empty p {
  max-width: 46ch;
  color: var(--text-2);
  font-size: 15px;
}

.empty .row {
  justify-content: center;
  margin-top: var(--space-2);
}


/* 13. Menus, confirm-delete =============================================== */

/* <details class="menu"><summary>..</summary><div class="menu-panel">..</div></details>
   Works without JS; app.js adds Escape and click-outside to close. */
.menu {
  position: relative;
}

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

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

.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 248px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  background: var(--raised);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  transform-origin: top right;
  animation: menu-in var(--dur-1) var(--ease);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.menu-header {
  display: grid;
  gap: 2px;
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  transition: background-color var(--dur-1) var(--ease);
}

.menu-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-2);
}

.menu-item:hover {
  background: var(--hover);
}

.menu-item:focus-visible {
  outline-offset: -2px;
}

.menu-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.menu form {
  margin: 0;
}

/* Confirm-delete without JS: the summary reveals a panel holding the real
   POST form. */
.confirm > summary {
  list-style: none;
}

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

.confirm > summary > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.confirm[open] > summary .when-closed,
.confirm:not([open]) > summary .when-open {
  display: none;
}

.confirm-panel {
  display: grid;
  gap: var(--space-3);
  max-width: 460px;
  margin-top: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-card);
  background: var(--surface);
  animation: flash-in var(--dur-2) var(--ease);
}

.confirm-panel p {
  font-size: 14px;
  color: var(--text-2);
}

.confirm-panel strong {
  color: var(--text);
}

.confirm-panel form {
  margin: 0;
}


/* 14. App shell =========================================================== */

/* body.app > .shell: [ rail | topbar / flash / main ]. On phones the rail
   becomes a bottom tab bar. */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.rail {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-4);
  height: 100vh;
  height: 100dvh;
  padding: 12px 10px;
  border-right: 1px solid var(--border);
  background: var(--rail-bg);
}

.rail-brand {
  display: grid;
  place-items: center;
  height: 44px;
  border-radius: 10px;
  text-decoration: none;
}

.rail-brand .mark {
  width: 30px;
  height: 30px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Full bleed: the items reach both edges of the rail (its padding is 10px). */
  margin: 0 -10px;
}

.rail-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 2px 9px;
  border-radius: 0;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}

.rail-link svg {
  width: 20px;
  height: 20px;
}

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

.rail-link:hover {
  background: var(--raised);
  color: var(--text);
}

.rail-link[aria-current="page"] {
  background: var(--rail-current);
  color: var(--text);
}

.rail-link[aria-current="page"] svg {
  color: var(--link);
}

/* The current item: a square block across the whole rail, with the accent bar down its
   full height on the left edge. The rail is rendered `data-elevator` (JS assumed): one
   shared .rail-indicator draws the block and rides between items like an elevator. It stays
   invisible until /js/app.js has put it on the floor of the page we came from, so a page
   that paints before its scripts run never shows the block on the new item first.
   Without JS, /css/rail-nojs.css (in <noscript>) lets the link draw the block itself. */
.rail-link[aria-current="page"]::before,
.rail-indicator::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--accent);
}

.rail-indicator {
  display: none;
}

.rail[data-elevator] .rail-indicator {
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 0;
  background: var(--rail-current);
  opacity: 0;
  pointer-events: none;
}

.rail[data-elevator] .rail-indicator.is-placed {
  opacity: 1;
}

.rail[data-elevator] .rail-indicator.is-moving {
  transition:
    transform 380ms cubic-bezier(0.45, 0, 0.2, 1),
    height 380ms cubic-bezier(0.45, 0, 0.2, 1);
}

.rail[data-elevator] .rail-indicator[hidden] {
  display: none;
}

.rail[data-elevator] .rail-nav {
  position: relative;
  z-index: 1;
}

.rail[data-elevator] .rail-link[aria-current="page"] {
  background: transparent;
}

.rail[data-elevator] .rail-link[aria-current="page"]::before {
  display: none;
}

.rail-link .count {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  box-shadow: 0 0 0 2px var(--rail-bg);
}

/* Collapse / expand (wave 9): the last item of the rail, a real form (relay_web::layout::
   rail_toggle). Icon-only, named by its .rail-label, which shows as a tooltip. The » icon
   is mirrored to « while the rail is expanded. */
.rail-toggle-form {
  margin: auto -10px 0;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.rail-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}

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

.rail-toggle:focus-visible {
  outline-offset: -2px;
}

.rail-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform var(--dur-3) var(--ease);
}

.shell:not([data-rail="collapsed"]) .rail-toggle svg {
  transform: scaleX(-1);
}

/* A label shown as a tooltip beside the rail on hover and keyboard focus: the toggle's
   always, every item's while the rail is collapsed. It stays in the accessibility tree
   (opacity, not display), so it keeps naming the link or button. Esc hides it until the
   pointer or focus leaves (data-tips="off", /js/app.js; WCAG 1.4.13); the pointer can move
   onto it (a bridge over the gap) without it vanishing.
   Collapsed: a narrow, icon-only rail; the grid column animates to the new width (instant
   under reduced motion, app.css's motion rule). Desktop only: phones keep the bottom bar. */
@media (min-width: 721px) {
  .shell {
    transition: grid-template-columns var(--dur-3) var(--ease);
  }

  .rail-toggle .rail-label,
  .shell[data-rail="collapsed"] .rail-link .rail-label {
    position: absolute;
    top: 50%;
    left: calc(100% + 8px);
    z-index: 40;
    padding: 5px 9px;
    border-radius: 6px;
    background: var(--text);
    color: var(--bg);
    box-shadow: var(--shadow-card);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%);
    transition: opacity var(--dur-1) var(--ease);
  }

  .rail-toggle .rail-label::before,
  .shell[data-rail="collapsed"] .rail-link .rail-label::before {
    content: "";
    position: absolute;
    top: 0;
    right: 100%;
    bottom: 0;
    width: 10px;
  }

  .rail-toggle:hover .rail-label,
  .rail-toggle:focus-visible .rail-label,
  .shell[data-rail="collapsed"] .rail-link:hover .rail-label,
  .shell[data-rail="collapsed"] .rail-link:focus-visible .rail-label {
    opacity: 1;
    pointer-events: auto;
  }

  .rail[data-tips="off"] .rail-label {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .shell[data-rail="collapsed"] {
    grid-template-columns: var(--rail-w-collapsed) minmax(0, 1fr);
  }

  .shell[data-rail="collapsed"] .rail-link {
    padding: 11px 2px;
  }

  .shell[data-rail="collapsed"] .rail-link .count {
    top: 3px;
    left: calc(50% + 3px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
  }
}

.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
}

.topbar-brand {
  display: none;
}

.topbar-ws {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  flex-shrink: 1;
}

.topbar-ws-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 15px;
}

.topbar-ws-slug {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.topbar-slot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

/* Cmd+K trigger: a real link to the search page; JS may upgrade it to a
   palette. Rendered only when search is enabled. */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  width: 232px;
  height: 34px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}

.search-trigger svg {
  width: 16px;
  height: 16px;
}

.search-trigger .kbd {
  margin-left: auto;
  height: 20px;
  font-size: 11px;
}

.search-trigger:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.user-menu > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 4px;
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background-color var(--dur-1) var(--ease);
}

.user-menu > summary:hover,
.user-menu[open] > summary {
  background: var(--raised);
  color: var(--text);
}

.user-menu > summary .chev {
  width: 14px;
  height: 14px;
  transition: transform var(--dur-2) var(--ease);
}

.user-menu[open] > summary .chev {
  transform: rotate(180deg);
}

.flash-region {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--gutter) 0;
}

.content {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: var(--space-6) var(--gutter) var(--space-8);
}

.content:focus {
  outline: none;
}

/* Full-bleed pages (the inbox's panes) manage their own padding. */
.content-bleed {
  padding: 0;
}

.content-narrow {
  max-width: calc(var(--container-narrow) + 2 * var(--gutter));
}

@media (max-width: 720px) {
  :root {
    --gutter: 16px;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    flex-direction: row;
    height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
    background: var(--glass);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }

  .rail-brand,
  .rail-toggle-form {
    display: none;
  }

  .rail-nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    gap: 2px;
  }

  .rail-nav li {
    flex: 1 1 0;
    min-width: 0;
  }

  .rail-link {
    padding: 7px 0 6px;
    border-radius: 10px;
    font-size: 10.5px;
  }

  .rail-nav {
    margin: 0;
  }

  /* The bottom bar keeps the rounded highlight and no elevator. */
  .rail-link[aria-current="page"]::before,
  .rail[data-elevator] .rail-indicator {
    display: none;
  }

  .rail[data-elevator] .rail-link[aria-current="page"] {
    background: var(--accent-soft);
  }

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

  .topbar-brand {
    display: grid;
    place-items: center;
  }

  .topbar-brand .mark {
    width: 26px;
    height: 26px;
  }

  .topbar-ws-slug,
  .user-menu-name,
  .user-menu > summary .chev {
    display: none;
  }

  .user-menu > summary {
    padding: 4px;
  }

  .search-trigger {
    width: 36px;
    height: 36px;
    justify-content: center;
    padding: 0;
  }

  .search-trigger .search-label,
  .search-trigger .kbd {
    display: none;
  }

  .content {
    padding-top: var(--space-5);
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .content-bleed {
    padding: 0 0 calc(72px + env(safe-area-inset-bottom));
  }

  html:has(> body.app) {
    scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .page-title {
    font-size: 26px;
  }

  .page-header {
    margin-bottom: var(--space-5);
  }
}


/* 15. Auth & error pages ================================================== */

/* Centred single-card pages: login, signup, reset, invite, errors. */
.auth,
.error-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-7) var(--space-4);
  background:
    radial-gradient(60% 45% at 50% 0%, var(--glow), transparent 70%),
    var(--bg);
}

.auth-inner {
  display: grid;
  gap: var(--space-5);
  width: min(100%, 420px);
}

.auth-brand {
  justify-self: center;
  color: var(--text);
  text-decoration: none;
}

.auth-card {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.auth-card .lede {
  margin-top: var(--space-2);
  font-size: 15px;
}

.auth-foot {
  color: var(--text-2);
  font-size: 14px;
  text-align: center;
}

/* "Continue with Google" and the "or" rule under it (sign-in pages). */
.auth-alt {
  display: grid;
  gap: var(--space-4);
}

.btn-google svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-3);
  font-size: 13px;
}

.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-methods {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.auth-methods h2 {
  font-size: 16px;
  font-weight: 600;
}

.error-inner {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
  width: min(100%, 560px);
}

.error-code {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: var(--tracking-mono);
}

.error-code::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--border-control);
}

.error-inner .lede {
  font-size: 17px;
}

.error-inner .row {
  margin-top: var(--space-3);
}

@media (max-width: 480px) {
  .auth-card {
    padding: var(--space-5);
  }
}


/* 16. Brand, htmx, motion ================================================= */

/* The lockup keeps the logo's proportions: the gap is 0.31 × the mark, the capitals 0.30 × the
   mark (Jost's cap height is 0.70em, so the font size is 0.43 × the mark). */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.wordmark .mark {
  width: 40px;
  height: 40px;
}

.wordmark-text {
  font-family: "Jost", var(--font-sans);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.25em;
  line-height: 1;
  text-transform: uppercase;
}

/* A brand moment: gradient underline for a single hero word. */
.brand-underline {
  padding-bottom: 0.06em;
  background-image: var(--brand-gradient);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.08em;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.htmx-request.btn,
.htmx-request .btn[type="submit"] {
  cursor: progress;
}

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

  .btn:active {
    transform: none;
  }

  /* The rule above still runs every property through a 0.01 ms transition, which lags a
     frame behind: the rail's width and the elevator block must change in the same frame. */
  .shell,
  .rail-indicator {
    transition-property: none !important;
  }
}

.wordmark-link {
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-control);
}
