/* ════════════════════════════════════════════════════════════
   USER GUIDE: /user-guide  (Counsel help centre)
   Ivory header with the X logo, a Counsel page head (rule + small
   caps over a Newsreader headline), a hairline contents rail with
   search, and numbered sections set like the features brief. Tokens
   only, so the night edition (theme-boot.js) follows the workspace.

   Mobile first (prompt 034): the rules with no media query are the
   phone's. Under 900 px the contents are a "Contents" bar under the
   site header that opens a sheet from the bottom (search, then the
   list in 48 px rows); from 900 px they are the sticky rail.
════════════════════════════════════════════════════════════ */

.ug-body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  --ug-header-h: 64px;
  --ug-max: 1200px;
}

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

.ug-eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.ug-eyebrow--muted { color: var(--text-muted); }

/* ── Page head ──────────────────────────────────────────── */

.ug-hero { border-bottom: 1px solid var(--border-subtle); }
.ug-hero__inner {
  max-width: calc(var(--ug-max) + 48px);
  margin: 0 auto;
  padding: 48px 16px 40px;
  box-sizing: border-box;
}
.ug-kicker { display: flex; align-items: center; gap: 12px; margin: 0 0 28px; }
.ug-kicker::before { content: ''; width: 32px; height: 1px; background: var(--text-primary); }
.ug-hero h1 {
  margin: 0;
  font-family: var(--font-title, 'Newsreader', Georgia, serif);
  font-weight: 450;
  font-size: 42px;
  line-height: 1.04;
  letter-spacing: -0.022em;
  color: var(--text-primary);
  font-variation-settings: "opsz" 72;
}
.ug-hero h1 em { font-style: normal; font-weight: inherit; color: var(--text-secondary); }
.ug-hero__lede {
  max-width: 640px;
  margin: 24px 0 0;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.ug-hero__meta { display: flex; align-items: baseline; gap: 12px; margin: 28px 0 0; }
.ug-hero__meta time { font-family: var(--font-serif); font-size: 18px; color: var(--text-primary); }

/* ── Layout: rail + articles ────────────────────────────── */

.ug-layout {
  max-width: calc(var(--ug-max) + 48px);
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
  display: block;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
}
.ug-side { grid-column: 1 / span 3; }
.ug-main { grid-column: 5 / span 8; min-width: 0; max-width: none; padding: 32px 0 64px; }

/* Phone and tablet: a slim "Contents" bar that stays under the header */
.ug-side {
  position: sticky;
  top: var(--ug-header-h);
  z-index: 10;
  align-self: start;
  margin: 0 -16px;
  padding: 6px 16px;
  box-sizing: border-box;
  background: var(--surface-canvas);
  border-bottom: 1px solid var(--border-subtle);
  scrollbar-width: none;
}
.ug-side::-webkit-scrollbar { display: none; }
/* An open sheet sits above the header and the page */
body.xs-sheet-open .ug-side { z-index: 95; }

.ug-toc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--surface-elevated);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
}
.ug-toc > summary::-webkit-details-marker { display: none; }
.ug-toc > summary:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.ug-toc > summary svg { width: 16px; height: 16px; color: var(--text-muted); transform: rotate(180deg); }
.ug-side__title { display: none; }

/* The sheet: the list rises from the bottom over a dimmed page */
.ug-toc:not([open]) > .ug-toc__panel { display: none; }
.ug-toc[open]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 8, 13, 0.62);
}
.ug-toc[open] > .ug-toc__panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 91;
  max-height: min(82dvh, 720px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-subtle);
  border-radius: 20px 20px 0 0;
  background: var(--surface-elevated);
  box-shadow: 0 -30px 80px -20px rgba(0, 0, 0, 0.9);
  animation: ug-sheet-in 220ms ease-out;
}
@keyframes ug-sheet-in { from { transform: translateY(24px); opacity: 0; } }
.ug-sheet__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  background: var(--surface-elevated);
}
.ug-sheet__title { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-primary); }

/* Search */
.ug-search { position: relative; margin: 0 0 16px; }
.ug-search > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.ug-search input {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 36px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--surface-input);
  border: 1px solid var(--border-control);
  border-radius: var(--r-md);
}
.ug-search input::placeholder { color: var(--text-faint); }
.ug-search input::-webkit-search-cancel-button { display: none; }
.ug-search__key {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-elevated);
  border: 1px solid var(--border-control);
  border-bottom-width: 2px;
  border-radius: var(--r-md);
}
.ug-search input:focus + .ug-search__key,
.ug-search input:not(:placeholder-shown) + .ug-search__key { display: none; }

/* Contents */
.ug-nav__group {
  margin: 28px 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ug-nav__group:first-child { margin-top: 0; }
.ug-nav__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-subtle); }
.ug-nav { padding: 0 0 8px; }
.ug-nav__list a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.ug-nav__list a:hover { color: var(--text-primary); }
.ug-nav__list a.is-active { color: var(--text-primary); font-weight: 500; }
.ug-nav__num {
  flex-shrink: 0;
  width: 20px;
  font-family: var(--font-sans);
  font-style: normal;
  color: var(--text-muted);
  font-variant-numeric: lining-nums;
}
.ug-nav__list a.is-active .ug-nav__num { color: var(--text-primary); }
.ug-nav__list li[hidden],
.ug-nav__group[hidden] { display: none; }
.ug-nav__empty { margin: 8px 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.ug-nav__empty a { color: var(--text-primary); border-bottom: 1px solid var(--border-control); text-decoration: none; }

/* ── Articles ───────────────────────────────────────────── */

.ug-section {
  scroll-margin-top: calc(var(--ug-header-h) + 72px);
  padding-bottom: 44px;
  margin-bottom: 44px;
  border-bottom: 1px solid var(--border-subtle);
}
.ug-section[hidden] { display: none; }

.ug-secno { display: flex; align-items: center; gap: 14px; margin: 0; }
.ug-secno__n {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 15px;
  line-height: 1;
  color: var(--text-secondary);
  font-variant-numeric: lining-nums;
}
.ug-secno__bar { width: 28px; height: 1px; background: var(--border-control); }
.ug-secno__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.ug-section h2 {
  margin: 18px 0 16px;
  font-family: var(--font-title, 'Newsreader', Georgia, serif);
  font-size: 29px;
  font-weight: 450;
  line-height: 1.1;
  letter-spacing: -0.016em;
  color: var(--text-primary);
  font-variation-settings: "opsz" 48;
}
.ug-section .ug-section__summary {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-secondary);
}
.ug-section h3 {
  margin: 40px 0 12px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}
.ug-section p {
  margin: 0 0 12px;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-primary);
}
.ug-section a { color: var(--text-primary); text-decoration: none; border-bottom: 1px solid var(--border-control); }
.ug-section a:hover { border-bottom-color: var(--text-primary); }
.ug-section strong { font-weight: 600; color: var(--text-primary); }

/* An on-screen label: a button, tab or field name */
.ug-ui { font-weight: 600; color: var(--text-primary); }

/* Numbered steps: italic serif numerals between hairlines */
.ug-steps {
  list-style: none;
  counter-reset: ug-step;
  margin: 0 0 16px;
  padding: 0;
  border-top: 1px solid var(--border-subtle);
}
.ug-steps > li {
  counter-increment: ug-step;
  position: relative;
  padding: 12px 0 12px 40px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text-primary);
}
.ug-steps > li::before {
  content: counter(ug-step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 13px;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
  font-variant-numeric: lining-nums;
}

.ug-list { list-style: none; margin: 0 0 16px; padding: 0; }
.ug-list li {
  position: relative;
  margin: 0;
  padding: 6px 0 6px 20px;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text-primary);
}
.ug-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 17px;
  width: 8px;
  height: 1px;
  background: var(--text-muted);
}

/* Notes: a vellum panel; cautions: a warning wash. Mint is kept for AI. */
.ug-callout {
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: var(--r-lg);
  background: var(--surface-recessed);
  border: 1px solid var(--border-subtle);
}
.ug-section .ug-callout p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--text-primary); }
.ug-callout--warn { background: var(--status-warning-soft); border-color: transparent; box-shadow: inset 2px 0 0 var(--status-warning); }

/* Tables: caps header over an ink rule, hairline rows */
.ug-table-wrap { margin: 20px 0; overflow-x: auto; }
.ug-table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.ug-table th {
  padding: 0 16px 12px 0;
  border-bottom: 1px solid var(--text-primary);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ug-table td {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  color: var(--text-secondary);
}
.ug-table td:last-child, .ug-table th:last-child { padding-right: 0; }
.ug-table td:first-child { color: var(--text-primary); }
.ug-table--group td:first-child {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 16px;
  color: var(--text-muted);
}


/* Keys */
.ug-keys { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; vertical-align: baseline; }
.ug-plus { color: var(--text-muted); font-size: 13px; }
.ug-section kbd,
.ug-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  box-sizing: border-box;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-elevated);
  border: 1px solid var(--border-control);
  border-bottom-width: 2px;
  border-radius: var(--r-md);
}

/* Footer */
.ug-footer { padding-top: 8px; }
.ug-footer p { margin: 0 0 8px; font-size: 15px; color: var(--text-secondary); }
.ug-footer a { color: var(--text-primary); text-decoration: none; border-bottom: 1px solid var(--border-control); }
.ug-footer .ug-footer__meta { font-size: 13px; color: var(--text-muted); }
.ug-footer .ug-footer__meta a { color: var(--text-muted); }

/* ── Larger screens ─────────────────────────────────────── */

/* Large phones and small tablets: the sheet is a centred column */
@media (min-width: 600px) {
  .ug-body { --ug-header-h: 72px; }
  .ug-hero__inner { padding: 56px 20px 48px; }
  .ug-hero h1 { font-size: clamp(40px, 5.4vw, 68px); }
  .ug-hero__lede { font-size: 18px; }
  .ug-layout { padding: 0 20px; }
  .ug-side { margin: 0 -20px; padding: 6px 20px; }
  .ug-main { padding: 40px 0 72px; }
  .ug-toc[open] > .ug-toc__panel { max-width: 560px; margin: 0 auto; }
  .ug-section { padding-bottom: 64px; margin-bottom: 64px; }
  .ug-section h2 { font-size: 36px; }
  .ug-table td:first-child, .ug-table--group td:nth-child(2) { white-space: nowrap; }
}

/* Tablets and up: the sticky contents rail beside the articles */
@media (min-width: 900px) {
  .ug-hero__inner { padding: 88px 24px 72px; }
  .ug-layout { display: grid; padding: 0 24px; }
  .ug-main { max-width: 72ch; padding: 72px 0 120px; }
  .ug-side {
    z-index: auto;
    max-height: calc(100vh - var(--ug-header-h));
    overflow: visible;
    overflow-y: auto;
    margin: 0;
    padding: 72px 0 40px;
    background: none;
    border-bottom: 0;
  }
  .ug-toc > summary { display: none; }
  .ug-toc[open]::before { content: none; }
  .ug-toc[open] > .ug-toc__panel {
    position: static;
    z-index: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: visible;
    overscroll-behavior: auto;
    padding: 0;
    border-top: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    animation: none;
  }
  .ug-sheet__head { display: none; }
  .ug-search { margin: 0 0 32px; }
  .ug-search input { height: var(--ctl-h); font-size: 14px; }
  .ug-search__key { display: inline-flex; }
  .ug-nav { padding: 0; }
  .ug-nav__list a { align-items: normal; min-height: 0; padding: 10px 0; font-size: 14px; }
  .ug-section { scroll-margin-top: calc(var(--ug-header-h) + 32px); }
  .ug-plus { font-size: 12px; }
  .ug-section kbd,
  .ug-keys kbd { min-width: 22px; height: 22px; font-size: 11.5px; }
}

@media print {
  .ug-side, .skip-link { display: none !important; }
  .ug-layout { display: block; padding: 0; }
  .ug-main { max-width: none; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ug-toc[open] > .ug-toc__panel { animation: none; }
}

/* The guide's headings keep the title serif in both themes (prompt 038). This
   outranks the dark theme's rule for every h1 and h2 in system.css, which
   loads after this sheet. */
:root[data-theme] .ug-hero h1,
:root[data-theme] .ug-section h2 {
  font-family: var(--font-title, 'Newsreader', Georgia, serif);
  font-weight: 450;
  letter-spacing: -0.012em;
}
