/* Wiki styles. Colors and fonts come only from the brand tokens at the top of :root:
   --bg, --panel, --line, --ink, --muted, --accent, --link, --button, --on-button, --font-body, --font-head.
   --accent is for fills and decoration; text that needs contrast uses --ink, --muted or --link.
   Primary buttons are --button with --on-button text.
   Layout: 220px sections | page | 220px "On this page" from 1200px. Below 1200px the contents list
   sits above the body, and below 900px the sidebar folds into the "Menu" toggle. No JavaScript. */

/* The look: warm cream surfaces, near-black ink and one bright orange, set in Poppins. No company name or logo: the
   mark in public/brand/ is a plain icon. The orange is too light for small text (under 3:1 on cream), so it only fills
   buttons and draws accents; text that needs to read as a link uses the darker --link. Contrast ratios (WCAG):
   - --link (#b33800) on --bg 5.5:1, on --panel 4.9:1;
   - --on-button (#262423) on --button 4.7:1, and higher on the lighter hover fill (82% --button, 18% --bg);
   - --ink on --bg 14:1, on --panel 12.7:1; --muted on --bg 6.5:1, on --panel 5.9:1. */

/* Poppins 400/500/600 (SIL Open Font License, public/brand/fonts/OFL-poppins.txt), in two subsets from
   @fontsource/poppins. Latin-ext covers Polish and French letters (ł, ś, ż, œ). Where ranges overlap the later rule
   wins, so each weight lists latin-ext first, as fontsource does. */
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/brand/fonts/poppins-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/brand/fonts/poppins-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/brand/fonts/poppins-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/brand/fonts/poppins-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/brand/fonts/poppins-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/brand/fonts/poppins-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #faf4e8; /* cream */
  --panel: #f1e8d6; /* raised surfaces */
  --line: #e4d9c4; /* borders and rules */
  --ink: #262423; /* text */
  --muted: #5c5752; /* secondary text */
  --accent: #ff5100; /* orange: fills and accents only, never small text */
  --link: #b33800; /* link and accent text */
  --button: #ff5100; /* primary button fill: the orange */
  --on-button: #262423; /* text on a --button fill */
  --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: var(--font-body);

  color-scheme: light; /* no dark mode */
}

:root {
  --topbar-h: 64px;
  --side-w: 220px;
  --col-gap: 40px;
  --gutter: 16px;
  --radius: 8px;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 16px 40px -16px color-mix(in srgb, var(--ink) 35%, transparent);
  --wash: color-mix(in srgb, var(--panel) 45%, var(--bg)); /* between --bg and --panel */
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 20px); /* anchors land below the sticky top bar */
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-head);
  color: var(--ink);
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

img {
  max-width: 100%;
  height: auto;
}

video {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

summary {
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

::selection {
  background: color-mix(in srgb, var(--accent) 28%, var(--bg));
  color: var(--ink);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 50;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* A small chevron drawn with borders; rotate it to point another way. */
.nav-toggle > summary::after,
.user-menu > summary::after,
.nav-sub > summary::before,
.breadcrumb li + li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transition: transform 150ms ease;
}

/* ---------- Buttons and chips ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.button:hover {
  background: var(--panel);
}

.button--primary {
  border-color: var(--button);
  background: var(--button);
  color: var(--on-button);
  font-weight: 600;
}

.button--primary:hover {
  border-color: color-mix(in srgb, var(--button) 82%, var(--bg));
  background: color-mix(in srgb, var(--button) 82%, var(--bg)); /* a little lighter; --on-button stays at AA contrast on it */
}

.button--small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.chip--limited::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.empty-note {
  color: var(--muted);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
}

/* The logo is decoration next to the name (alt=""), so the name is the link's text. */
.brand-logo {
  display: block;
  width: auto;
  height: 32px;
}

.brand-wiki {
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}

.search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 420px;
}

.search::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 13px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='m20 20-4.6-4.6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='m20 20-4.6-4.6'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search input:hover {
  border-color: color-mix(in srgb, var(--muted) 35%, var(--line));
}

.search input:focus-visible {
  outline-offset: 1px;
  background: var(--bg);
}

.topbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* User menu: a <details> dropdown. */
.user-menu {
  position: relative;
}

.user-menu > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px 0 6px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 150ms ease;
}

.user-menu > summary:hover,
.user-menu[open] > summary {
  background: var(--panel);
}

.user-menu > summary::after {
  margin: -4px 0 0 2px;
  transform: rotate(45deg);
}

.user-menu[open] > summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.user-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 270px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.user-menu-name {
  margin: 0;
  font-weight: 600;
}

.user-menu-email {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.user-menu-panel ul {
  margin: 14px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.user-menu-panel form {
  margin: 0;
}

/* "Sign out" is a POST form; its button looks like the links above it. */
.user-menu-panel a,
.user-menu-panel button {
  display: block;
  margin: 0 -8px;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
}

.user-menu-panel button {
  width: calc(100% + 16px);
  border: 0;
  background: none;
  font-family: inherit;
  line-height: inherit;
  text-align: left;
  cursor: pointer;
}

.user-menu-panel a:hover,
.user-menu-panel button:hover {
  background: var(--panel);
}

/* ---------- Page grid ---------- */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.main {
  min-width: 0;
  padding: 28px 0 80px;
}

/* ---------- Sidebar ---------- */

.nav-toggle {
  margin-top: 16px;
}

.nav-toggle > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
  font-weight: 500;
}

.nav-toggle > summary::after {
  margin-top: -4px;
  transform: rotate(45deg);
}

.nav-toggle[open] > summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

.sidebar {
  display: none;
  font-size: 14px;
  line-height: 1.4;
}

.nav-toggle[open] + .sidebar {
  display: block;
  padding: 8px 0 20px;
  border-bottom: 1px solid var(--line);
}

.nav-section + .nav-section {
  margin-top: 20px;
}

.nav-heading {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.nav-heading a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list .nav-list {
  margin: 2px 0 4px 10px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.nav-list li {
  position: relative;
}

.nav-list a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

.has-sub > a {
  padding-right: 34px; /* room for the toggle */
}

/* Stands in for the sub-pages below the sidebar's last level. */
.nav-list a.nav-more {
  color: var(--muted);
}

.sidebar a:hover {
  background: var(--wash);
  color: var(--ink);
}

.sidebar a[aria-current="page"] {
  background: var(--panel);
  color: var(--link);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Sub-level toggle: a 28px button at the right end of its row. */
.nav-sub > summary {
  position: absolute;
  top: 1px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--muted);
}

.nav-sub > summary:hover {
  background: var(--panel);
  color: var(--ink);
}

.nav-sub > summary::before {
  margin-left: -2px;
  transform: rotate(-45deg);
}

.nav-sub[open] > summary::before {
  margin: -3px 0 0;
  transform: rotate(45deg);
}

.nav-empty {
  margin: 8px 10px;
  color: var(--muted);
}

/* ---------- Page header ---------- */

.page-head {
  margin-bottom: 28px;
}

.page-head-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 10px;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb li + li::before {
  margin: 0 10px 1px 6px;
  opacity: 0.7;
  transform: rotate(-45deg);
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--link);
  text-decoration: underline;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.page-actions .button {
  margin-right: 6px;
}

.page-actions a:not(.button) {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.page-actions a:not(.button):hover {
  background: var(--panel);
  color: var(--ink);
}

.page-head h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 1.4vw + 20px, 38px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.home-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- On this page ---------- */

.toc-col {
  margin: 0 0 28px;
}

.toc {
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
  font-size: 14px;
  line-height: 1.4;
}

.toc-title,
.section-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding: 4px 0;
  color: var(--ink);
  text-decoration: none;
}

.toc .toc-h3 a {
  padding-left: 14px;
  color: var(--muted);
  font-size: 13px;
}

.toc a:hover {
  color: var(--link);
  text-decoration: underline;
}

/* ---------- Prose (rendered Markdown) ---------- */

.prose {
  max-width: 70ch;
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose dl,
.prose pre,
.prose table,
.prose blockquote,
.prose .callout {
  margin: 0 0 1.15em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-weight: 600;
  line-height: 1.3;
}

.prose h1 {
  margin: 2em 0 0.6em;
  font-size: 1.75rem;
}

.prose h2 {
  margin: 2.1em 0 0.6em;
  font-size: 1.4rem;
  letter-spacing: -0.005em;
}

.prose h3 {
  margin: 1.8em 0 0.5em;
  font-size: 1.15rem;
}

.prose h4,
.prose h5,
.prose h6 {
  margin: 1.6em 0 0.4em;
  font-size: 1rem;
}

.prose a {
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
  transition: text-decoration-color 150ms ease;
}

.prose a:hover {
  text-decoration-color: currentColor;
}

.prose strong {
  font-weight: 600;
}

.prose ul,
.prose ol {
  padding-left: 1.5em;
}

.prose li {
  margin: 0.3em 0;
}

.prose li > ul,
.prose li > ol {
  margin: 0.3em 0;
}

.prose li::marker {
  color: var(--muted);
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.prose hr {
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.prose img,
.prose video {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* A portrait phone clip stops short of the window's height; with the width left auto it keeps its shape. */
.prose video {
  max-height: 80vh;
}

.prose code {
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.prose pre {
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 14px;
  line-height: 1.6;
  tab-size: 2;
}

.prose pre code {
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: inherit;
}

.prose table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.5;
}

.prose th,
.prose td {
  padding: 8px 14px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--panel);
  font-weight: 600;
}

.prose tbody tr:nth-child(2n) td {
  background: var(--wash);
}

/* Task lists (markdown-it-task-lists, read-only checkboxes). */
.prose .contains-task-list {
  padding-left: 0.25em;
  list-style: none;
}

.prose .task-list-item-checkbox {
  margin: 0 0.55em 0 0;
  vertical-align: -0.1em;
  accent-color: var(--accent);
}

/* Wiki links: a missing page gets a dashed underline (editors can create it); plain text for everyone else. */
.prose .wikilink--missing {
  text-decoration-style: dashed;
  text-decoration-color: currentColor;
}

.wikilink--plain {
  color: inherit;
  text-decoration: none;
}

/* Callouts: > [!note], > [!tip], > [!warning] */
.prose .callout {
  margin: 1.5em 0;
  padding: 14px 18px;
  border-left: 3px solid var(--muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--panel);
}

.callout > :last-child {
  margin-bottom: 0;
}

.prose .callout__title {
  margin: 0 0 0.3em;
  font-weight: 600;
}

.prose .callout--tip {
  border-left-color: var(--accent);
}

.prose .callout--warning {
  border-left-color: var(--link);
  background: color-mix(in srgb, var(--accent) 9%, var(--bg));
}

.prose .callout--warning .callout__title {
  color: var(--link);
}

/* highlight.js tokens, from the brand tokens only. */
.hljs-comment,
.hljs-quote,
.hljs-meta {
  color: var(--muted);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-doctag {
  color: var(--link);
}

.hljs-string,
.hljs-regexp,
.hljs-template-tag,
.hljs-template-variable,
.hljs-link {
  color: color-mix(in srgb, var(--link) 55%, var(--ink));
}

.hljs-title,
.hljs-section,
.hljs-selector-id,
.hljs-selector-class,
.hljs-name {
  color: var(--ink);
  font-weight: 600;
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-property,
.hljs-params,
.hljs-type,
.hljs-built_in {
  color: var(--ink);
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 600;
}

.hljs-addition {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.hljs-deletion {
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--muted);
}

/* ---------- Below the body: sub-pages and "Linked from" ---------- */

.sub-pages,
.linked-from {
  max-width: 70ch;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.linked-from {
  margin-top: 32px;
}

.link-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 2px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list a {
  display: block;
  padding: 4px 0;
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
}

.link-list a:hover {
  text-decoration-color: currentColor;
}

/* ---------- Home ---------- */

.home-grid {
  display: grid;
  gap: 40px;
  margin-top: 48px;
}

.recent-list,
.section-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.recent-list li:first-child {
  padding-top: 0;
}

.recent-list a {
  font-weight: 500;
  text-decoration: none;
}

.recent-list a:hover {
  text-decoration: underline;
}

.recent-meta {
  color: var(--muted);
  font-size: 13px;
}

.section-list {
  display: grid;
  gap: 8px;
}

.section-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.section-card:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.section-card-title {
  font-weight: 500;
}

.section-card-count {
  flex: none;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Forms ---------- */

.field {
  display: grid;
  gap: 6px;
  margin: 0 0 20px;
}

.field-label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.field-optional,
.field-hint {
  color: var(--muted);
  font-weight: 400;
}

.field-hint {
  margin: 0;
  font-size: 13px;
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 150ms ease;
}

.input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.input:hover {
  border-color: color-mix(in srgb, var(--muted) 35%, var(--line));
}

.input:focus-visible {
  outline-offset: 1px;
}

.input[aria-invalid="true"] {
  border-color: var(--link);
}

/* A native select with the chevron drawn by the wrapper, like the other chevrons. */
.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.select {
  padding-right: 40px;
  text-overflow: ellipsis;
  cursor: pointer;
}

.notice {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--panel);
  font-size: 14px;
  line-height: 1.55;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 4px;
}

.notice--warning,
.notice--error {
  background: color-mix(in srgb, var(--accent) 9%, var(--bg));
}

.notice--warning {
  border-left-color: var(--accent);
}

.notice--error {
  border-left-color: var(--link);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}

.form-cancel {
  padding: 8px 2px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.form-cancel:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* ---------- New page ---------- */

.new-form {
  max-width: 560px;
}

.new-form .form-actions {
  margin-top: 28px;
}

/* ---------- Editor: title, toolbar, Markdown and preview side by side, summary, Save ---------- */

.edit-form {
  /* Height of the Markdown pane (and of the preview pane, side by side); both scroll inside. */
  --pane-h: clamp(320px, 60vh, 560px);
}

.edit-head {
  margin-bottom: 16px;
}

.title-input {
  height: auto;
  padding: 8px 14px;
  font-family: var(--font-head);
  font-size: clamp(22px, 0.8vw + 18px, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.editor-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.editor-tabs {
  display: none; /* shown by .has-tabs, which the editor script sets */
  gap: 4px;
  padding: 6px 10px 0;
  border-bottom: 1px solid var(--line);
}

.has-tabs .editor-tabs {
  display: flex;
}

.editor-tabs button {
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.editor-tabs button:hover {
  color: var(--ink);
}

.editor-tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

/* Headings only for the no-JavaScript form, where both versions show one under the other; the tabs name them otherwise. */
.panel-heading {
  margin: 0;
  padding: 14px 18px 0;
  font-size: 15px;
}

.has-tabs .panel-heading {
  display: none;
}

.editor-panel[hidden] {
  display: none;
}

.editor-panel + .editor-panel {
  border-top: 1px solid var(--line);
}

.has-tabs .editor-panel + .editor-panel {
  border-top: 0;
}

.ai-hint {
  margin: 6px 18px 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  background: var(--wash);
}

.toolbar-group {
  display: flex;
  gap: 2px;
}

.toolbar-group + .toolbar-group {
  padding-left: 5px;
  border-left: 1px solid var(--line);
}

.editor-toolbar button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.editor-toolbar button:hover:not(:disabled) {
  background: var(--panel);
  color: var(--ink);
}

.editor-toolbar button:active:not(:disabled) {
  background: var(--line);
}

/* Until the editor script runs (and without JavaScript) the buttons can't do anything. */
.editor-toolbar button:disabled {
  opacity: 0.45;
  cursor: default;
}

.editor-toolbar svg {
  display: block;
  width: 18px;
  height: 18px;
}

.editor-status,
.pane-status {
  min-width: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.editor-status {
  padding: 4px 6px;
}

.editor-status.is-error,
.pane-status.is-error {
  color: var(--link);
}

.editor-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.editor-pane,
.preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-pane {
  height: var(--pane-h);
}

/* The pane in use gets an accent line along its top edge. */
.editor-pane:focus-within {
  box-shadow: inset 0 2px 0 var(--accent);
}

.pane-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-right: 18px;
}

.pane-label {
  margin: 0;
  padding: 10px 18px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* The plain textarea (no JavaScript) and CodeMirror fill the pane the same way. */
.editor-source,
.editor-pane .cm-editor {
  flex: 1 1 auto;
  min-height: 0;
}

.editor-source {
  width: 100%;
  margin: 0;
  padding: 8px 18px 24px;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  resize: none;
}

.editor-source:focus-visible {
  outline: none; /* the pane shows focus */
}

.editor-pane .cm-scroller,
.preview-pane .prose {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.preview-pane {
  border-top: 1px solid var(--line);
}

.preview-pane .prose {
  padding: 8px 18px 28px;
}

.edit-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 24px;
  margin-top: 20px;
}

.edit-summary {
  flex: 1 1 320px;
  max-width: 640px;
  margin: 0;
}

.edit-footer .form-actions {
  padding-bottom: 2px;
}

/* ---------- Bare pages (sign-in, no access, not found) ---------- */

/* One card in the middle of the window, on the cream background. */
.bare-main {
  max-width: 480px;
  margin: clamp(32px, 10vh, 96px) auto 80px;
  padding: 40px clamp(20px, 6vw, 40px);
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 520px) {
  .bare-main {
    margin: 24px var(--gutter) 48px;
  }
}

/* A page of reading text (the privacy page): the same card, wider. */
.bare-main--wide {
  max-width: 720px;
}

.privacy h2 {
  margin-top: 28px;
  font-size: 20px;
}

.privacy ul {
  padding-left: 20px;
}

.bare-footer {
  margin: -56px auto 40px;
  text-align: center;
  font-size: 14px;
}

.bare-footer a {
  color: var(--muted);
}

.bare-logo {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 0 20px;
}

.bare-main h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 1.4vw + 18px, 32px);
  font-weight: 600;
  line-height: 1.2;
}

.bare-lede {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.signin-action {
  margin: 24px 0 20px;
}

/* The one thing to do on the page: a full-width button. */
.signin-action .button {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

.signin-help {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.dev-users {
  display: grid;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.dev-users form {
  margin: 0;
}

.dev-users button {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.dev-users button:hover {
  border-color: var(--accent);
  background: var(--panel);
}

/* ---------- Wider screens ---------- */

@media (min-width: 600px) {
  .home-grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

@media (max-width: 599px) {
  /* Only the logo shows; the name stays the link's text for screen readers (as .visually-hidden). */
  .brand-wiki {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Leave the search box room on phones. */
  .topbar-actions .button--primary {
    padding: 0 12px;
  }

  .user-menu > summary {
    padding: 0 6px;
  }

  .user-menu > summary::after {
    display: none;
  }

  .user-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Sidebar beside the page; "On this page" stays above the body. */
@media (min-width: 900px) {
  :root {
    --gutter: 24px;
  }

  .shell {
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    column-gap: var(--col-gap);
  }

  /* The search box lines up with the page column. */
  .brand {
    width: calc(var(--side-w) + var(--col-gap) - 12px);
  }

  .nav-toggle {
    display: none;
  }

  .sidebar,
  .nav-toggle[open] + .sidebar {
    display: block;
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    height: calc(100vh - var(--topbar-h));
    margin-left: -10px; /* link text lines up with the logo */
    padding: 28px 16px 48px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }

  .main {
    grid-column: 2;
    padding-top: 32px;
  }
}

/* Markdown and preview side by side, each the same height and scrolling on its own, sized so the
   whole form fits on the screen below the top bar. */
@media (min-width: 1100px) {
  .edit-form {
    --pane-h: clamp(380px, calc(100vh - 360px), 900px);
  }

  .editor-panes {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .preview-pane {
    height: var(--pane-h);
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .preview-pane .prose {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
}

/* Three columns: the contents list moves to the right and stays in view. The main element spans
   the page and contents columns as a subgrid, so the page column is the same with or without a list. */
@media (min-width: 1200px) {
  .shell {
    grid-template-columns: var(--side-w) minmax(0, 1fr) var(--side-w);
  }

  .main {
    grid-column: 2 / 4;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side-w); /* fallback without subgrid */
    grid-template-columns: subgrid;
    grid-template-rows: auto 1fr;
    align-content: start;
  }

  .main > .page-head {
    grid-column: 1;
    grid-row: 1;
  }

  .main > .main-body {
    grid-column: 1;
    grid-row: 2;
  }

  .main > .toc-col {
    grid-column: 2;
    grid-row: 1 / 3;
    margin: 0;
  }

  /* The editor has no contents list, so it takes the contents column too. */
  .main:has(> .main-body > .edit-form) > .page-head,
  .main:has(> .main-body > .edit-form) > .main-body {
    grid-column: 1 / -1;
  }

  .toc {
    position: sticky;
    top: calc(var(--topbar-h) + 32px);
    max-height: calc(100vh - var(--topbar-h) - 64px);
    padding: 2px 0 2px 16px;
    overflow-y: auto;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: none;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
}

/* ---------- Motion and print ---------- */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* ---------- History, diff and recent changes ---------- */

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.history-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.history-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.history-main > a:first-child {
  font-weight: 500;
}

.history-who,
.history-when {
  color: var(--muted);
  font-size: 14px;
}

.history-summary {
  margin: 4px 0 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.history-links {
  display: flex;
  gap: 16px;
  margin: 4px 0 0;
  font-size: 14px;
}

.revision-banner {
  margin: 0 0 24px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}

.revision-banner--current {
  border-left-color: var(--line);
}

.revision-banner p {
  margin: 0;
  font-weight: 500;
}

.revision-banner .revision-banner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 400;
}

.revision-banner form {
  margin: 0;
}

.diff {
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
}

.diff-row {
  min-height: 1.6em;
  padding: 0 12px 0 32px;
  position: relative;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-row--add {
  background: color-mix(in srgb, var(--ink) 9%, var(--bg));
}

.diff-row--del {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
}

.diff-row--add::before,
.diff-row--del::before {
  position: absolute;
  left: 12px;
  font-weight: 600;
}

.diff-row--add::before {
  content: "+";
}

.diff-row--del::before {
  content: "\2212"; /* minus sign */
}

.diff ins,
.diff del {
  display: block;
  text-decoration: none;
}

.diff-row--skipped {
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding-left: 12px;
}

@media print {
  .skip-link,
  .topbar,
  .nav-toggle,
  .sidebar,
  .toc-col,
  .page-actions {
    display: none !important;
  }

  .shell {
    display: block;
    padding: 0;
  }

  .main {
    padding: 0;
  }
}

/* ---------- Search results ---------- */

.search-count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.search-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-results > li {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.search-results > li:last-child {
  border-bottom: 1px solid var(--line);
}

.search-title {
  font-weight: 500;
  font-size: 18px;
}

.search-results .breadcrumb {
  margin: 2px 0 0;
}

.search-snippet {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.search-snippet mark {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--ink);
  border-radius: 2px;
  padding: 0 1px;
}

.search-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Page settings, rules and trash ---------- */

.input--narrow {
  max-width: 140px;
}

.rules-form {
  max-width: 560px;
}

.rules-note {
  margin: 0 0 16px;
}

.choice-set {
  min-width: 0;
  padding: 0;
  border: 0;
}

.choice-set legend {
  padding: 0;
  margin-bottom: 8px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
  cursor: pointer;
}

.choice input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.choice-meta {
  color: var(--muted);
  font-size: 13px;
}

.trash-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.trash-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.trash-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.trash-title {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.trash-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Admin console: overview, people, groups, Trash and audit log ---------- */

.muted {
  color: var(--muted);
}

/* Admin pages are tables and forms, so they take the contents column too, like the editor. */
@media (min-width: 1200px) {
  .main:has(> .main-body > .admin) > .page-head,
  .main:has(> .main-body > .admin) > .main-body {
    grid-column: 1 / -1;
  }
}

.admin {
  container: admin / inline-size;
}

/* Sub-nav: tabs on a rule. It scrolls sideways on its own if it ever runs out of room. */
.admin-nav {
  margin: 0 0 24px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.admin-nav ul {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-nav a {
  display: block;
  padding: 10px 12px 12px;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}

.admin-nav a:hover {
  background: var(--wash);
  color: var(--ink);
}

.admin-nav a:focus-visible {
  outline-offset: -2px; /* the scroll box would clip an outer ring */
}

.admin-nav a[aria-current] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.admin-head .breadcrumb {
  margin-bottom: 6px;
}

.admin-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

.admin-title h1 {
  margin: 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-lead {
  max-width: 70ch;
  margin: 8px 0 0;
  color: var(--muted);
}

.admin-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.admin-meta-email {
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Chips: role, status and group. Admin is tinted with the brand color, editor is filled, viewer is outlined. */
.chip--admin {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  color: var(--link); /* 4.7:1 on the tint */
}

.chip--editor {
  color: var(--ink);
}

.chip--viewer,
.chip--off,
.chip--group {
  padding: 2px 9px; /* the 1px border keeps the size of the other chips */
  border: 1px solid color-mix(in srgb, var(--muted) 40%, var(--line));
  background: transparent;
}

.chip--off {
  border-style: dashed;
}

.chip--you {
  background: var(--ink);
  color: var(--bg);
}

.chip--group {
  border-color: var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.chip--group:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Overview tiles: one, two or four across, never three and a stray. */
.stat-grid {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@container admin (min-width: 460px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Five cards: three and two on a medium screen, one row on a wide one. */
@container admin (min-width: 700px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container admin (min-width: 1000px) {
  .stat-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* How full file storage is: an orange bar on the panel colour, darker past 80%. */
.stat-meter {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 4px;
  background: var(--panel);
}

.stat-meter::-webkit-meter-bar {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

.stat-meter::-webkit-meter-optimum-value {
  border-radius: 4px;
  background: var(--accent);
}

.stat-meter::-webkit-meter-suboptimum-value {
  border-radius: 4px;
  background: var(--link);
}

.stat-meter::-moz-meter-bar {
  border-radius: 4px;
  background: var(--accent);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--wash);
}

/* The number above its label; in the markup the label comes first. */
.stat-figure {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  margin: 0;
}

.stat-figure dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.stat-figure dd {
  margin: 0;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.stat-breakdown {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.stat-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.stat-breakdown dt {
  color: var(--muted);
}

.stat-breakdown dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.stat-link {
  margin-top: auto;
  font-size: 14px;
  font-weight: 500;
}

.stat-link::after {
  content: "\2192";
  content: "\2192" / "";
  display: inline-block; /* keeps the arrow out of the underline */
  margin-left: 6px;
}

/* Sections and cards */
.admin-section {
  margin-top: 48px;
}

.admin-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 0 0 14px;
}

.admin-section-head h2,
.admin-card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.admin-section-head a {
  font-size: 14px;
  font-weight: 500;
}

.admin-section-hint {
  margin: -6px 0 14px;
}

.admin-card {
  max-width: 720px;
  margin-top: 48px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--wash);
}

.admin-card--form {
  margin-top: 0;
}

/* "Add a person" and "New group" in the header jump here. */
.admin-card:target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.admin-card-title {
  margin-bottom: 16px;
}

.admin-form .form-actions {
  margin-top: 8px;
}

.form-row {
  display: grid;
  column-gap: 16px;
}

@container admin (min-width: 640px) {
  .form-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  column-gap: 16px;
}

/* People carry an email after the name, so they get wider columns. */
.choice-grid--people {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.choice-grid--people .muted {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.field-static {
  overflow-wrap: anywhere;
}

.notice--done {
  border-left-color: var(--ink);
}

/* Filters above a table: GET forms, no JavaScript. */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--wash);
}

.filter-field {
  display: grid;
  flex: 1 1 180px;
  gap: 6px;
  min-width: 0;
  max-width: 240px;
}

.filter-field--grow {
  flex-basis: 260px;
  max-width: 420px;
}

.filter-field .field-label {
  font-size: 13px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px 16px;
}

.filter-bar .button {
  height: 42px; /* as tall as the inputs */
}

.filter-count {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

/* Tables: comfortable rows on hairline separators. Narrower than 700px they become stacked cards. */
.table-wrap {
  container-type: inline-size;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: baseline;
}

.admin-table th:last-child,
.admin-table td:last-child {
  padding-right: 0;
}

.admin-table thead th {
  padding-top: 4px;
  padding-bottom: 10px;
  border-bottom-color: color-mix(in srgb, var(--muted) 35%, var(--line));
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-transform: uppercase;
}

.admin-table tbody th {
  font-weight: 500;
}

.cell-primary a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.cell-primary a:hover {
  color: var(--link);
  text-decoration: underline;
}

.cell-email,
.audit-details {
  overflow-wrap: anywhere;
}

.admin-table time {
  white-space: nowrap;
}

.admin-table tr.is-off :is(th, td),
.admin-table tr.is-off .cell-primary a {
  color: var(--muted);
}

.audit-what {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.audit-code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
}

.audit-details {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

@container (max-width: 699px) {
  .admin-table,
  .admin-table tbody,
  .admin-table th,
  .admin-table td {
    display: block;
  }

  .admin-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .admin-table tr {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--wash);
  }

  .admin-table tr + tr {
    margin-top: 10px;
  }

  .admin-table th,
  .admin-table td {
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  /* The row's heading (a name, or an audit entry's action) leads the card. */
  .admin-table .cell-primary {
    order: -1;
    margin-bottom: 2px;
    font-size: 15px;
  }

  .admin-table td[data-label] {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
    justify-items: start; /* chips keep their own width */
  }

  .admin-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

@media (max-width: 599px) {
  /* All five tabs fit across a 375px phone. */
  .admin-nav a {
    padding: 10px 8px 12px;
    font-size: 13px;
  }

  .stat-card,
  .admin-card {
    padding: 16px;
  }

  .filter-bar {
    padding: 12px;
  }
}

/* ---------- Human | AI switch and the AI version ---------- */

.view-switch {
  display: inline-flex;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
  overflow: hidden;
}

.view-switch a {
  padding: 6px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.view-switch a:hover {
  background: var(--panel);
  color: var(--ink);
}

.view-switch a[aria-current="page"] {
  background: var(--button);
  color: var(--on-button);
}

.ai-version-intro {
  margin: 0 0 12px;
  color: var(--muted);
}

.ai-version-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  min-height: 32px;
}

.ai-text {
  margin: 0 0 24px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A token shown once, ready to select in one click and wrapped so it never runs off a narrow screen. */
.token-value {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 14px;
  overflow-wrap: anywhere;
  user-select: all;
}

/* ---------- Your account: the token guide ---------- */

/* A value with its Copy button and the "Copied" status next to it. */
.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.copy-row .token-value {
  flex: 1 1 320px;
}

.token-guide > summary,
.connect-steps > summary {
  list-style: none;
  cursor: pointer;
}

.token-guide > summary h2 {
  display: inline;
}

.token-guide > summary::before,
.connect-steps > summary::before {
  content: "▸ ";
  color: var(--muted);
}

.token-guide[open] > summary::before,
.connect-steps[open] > summary::before {
  content: "▾ ";
}

/* Your account: the steps for each AI tool, folded under the /mcp address. */
.connect-steps {
  margin-top: 16px;
}

.token-steps {
  display: grid;
  gap: 18px;
  margin: 16px 0 0;
  padding-left: 22px;
}

.token-os {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.token-code {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
