/* Living Brain app — the design-token sheet and the handful of components
 * the three pages need. The tokens, fonts and component shapes are the
 * livingbrain.wiki website's (`assets/livingbrain.css` in
 * Livingbrain-wiki/website), so the app and the site read as one product: a
 * flat stylesheet, oklch() tokens, no build step, dark by default with light
 * following the system unless the person has chosen.
 *
 * Every length here is fluid (clamp, %, min/max) or auto: nothing has a fixed
 * pixel width, so the layout cannot overflow a 360 px viewport. Anything that
 * could be wider than its column — long slugs, URLs, tokens — sets
 * `overflow-wrap: anywhere`.
 *
 *   Colours (oklch)        dark                 light
 *     --bg       page      0.16  0.014 215      0.975 0.006 190
 *     --bg2      surface   0.195 0.016 215      0.995 0.003 190
 *     --bg3      sunken    0.235 0.018 215      0.945 0.009 190
 *     --ink      text      0.95  0.008 200      0.22  0.02  220
 *     --ink2     body      0.80  0.014 205      0.40  0.02  215
 *     --ink3     labels    0.68  0.016 210      0.47  0.02  215
 *     --accent   alive     0.86  0.16  162      0.48  0.11  165
 *   As on the site, the accent is kept for the primary action, focus and
 *   things that are live; everything else is ink on a quiet surface.

   fonts
   ---------------------------------------------------------------- */

/* Self-hosted, the same files as the website (OFL; latin subsets, variable),
   so `font-src 'self'` in `_headers` covers them and no third-party font
   request is ever made. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/bricolage-grotesque.85f55a58a3.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: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/hanken-grotesk.1f21c6eaa0.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: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono.2c32b9b3ee.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;
}

/*   tokens
   ---------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --f-display: "Bricolage Grotesque", system-ui, sans-serif;
  --f-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --bg: oklch(0.16 0.014 215);
  --bg2: oklch(0.195 0.016 215);
  --bg3: oklch(0.235 0.018 215);
  --ink: oklch(0.95 0.008 200);
  --ink2: oklch(0.8 0.014 205);
  --ink3: oklch(0.68 0.016 210);
  --line: oklch(0.34 0.018 215);
  --line2: oklch(0.265 0.016 215);
  --field-line: oklch(0.5 0.02 215);
  --accent: oklch(0.86 0.16 162);
  --accent-ink: oklch(0.2 0.05 165);
  --accent-soft: oklch(0.86 0.16 162 / 0.13);
  --warn: oklch(0.85 0.085 85);
  --bad: oklch(0.8 0.08 25);
  --glow: 0 0 10px var(--accent);
  --header-bg: oklch(0.16 0.014 215 / 0.84);

  /* The brain map's node colours: the website's graph palette
     (Livingbrain-wiki/website assets/livingbrain.css), extended. */
  --graph-edge: oklch(0.72 0.04 200);
  --t-person: oklch(0.8 0.075 235);
  --t-project: oklch(0.79 0.075 295);
  --t-decision: oklch(0.85 0.085 85);
  --t-customer: oklch(0.8 0.08 25);
  --t-fact: oklch(0.62 0.02 210);
  --t-system: oklch(0.8 0.07 190);
  --t-topic: oklch(0.82 0.06 140);
  --t-agents: oklch(0.86 0.16 162);
  --t-session: oklch(0.76 0.09 320);
  --t-github: oklch(0.85 0.01 250);
  --t-source: oklch(0.78 0.08 55);

  /* The older names, kept so nothing that reads them goes blank. */
  --bg-raised: var(--bg2);
  --bg-sunken: var(--bg3);

  /* type: the site's scale, display headings in Bricolage */
  --step-0: 1rem;
  --step-1: clamp(1.2rem, 1.1rem + 0.5vw, 1.35rem);
  --step-2: clamp(1.45rem, 1.2rem + 1.2vw, 2rem);
  --step-3: clamp(2.1rem, 1.5rem + 3vw, 3.6rem);

  --space-1: 0.4rem;
  --space-2: 0.75rem;
  --space-3: clamp(1rem, 0.85rem + 0.6vw, 1.25rem);
  --space-4: clamp(1.5rem, 1.1rem + 1.6vw, 2.5rem);
  --space-5: clamp(2.5rem, 1.6rem + 4vw, 5rem);

  --radius: 10px;
  --radius-card: 16px;
  --measure: 68ch;
  --gutter: 20px;
}

/* Light follows the system only while the person has not chosen. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: oklch(0.975 0.006 190);
    --bg2: oklch(0.995 0.003 190);
    --bg3: oklch(0.945 0.009 190);
    --ink: oklch(0.22 0.02 220);
    --ink2: oklch(0.4 0.02 215);
    --ink3: oklch(0.47 0.02 215);
    --line: oklch(0.84 0.012 200);
    --line2: oklch(0.9 0.01 200);
    --field-line: oklch(0.62 0.015 210);
    --accent: oklch(0.48 0.11 165);
    --accent-ink: oklch(0.99 0.01 165);
    --accent-soft: oklch(0.48 0.11 165 / 0.1);
    --warn: oklch(0.5 0.11 70);
    --bad: oklch(0.5 0.13 30);
    --glow: none;
    --header-bg: oklch(0.975 0.006 190 / 0.86);
    --graph-edge: oklch(0.45 0.03 210);
    --t-person: oklch(0.5 0.11 240);
    --t-project: oklch(0.48 0.12 300);
    --t-decision: oklch(0.58 0.12 75);
    --t-customer: oklch(0.5 0.13 30);
    --t-fact: oklch(0.6 0.02 210);
    --t-system: oklch(0.5 0.09 200);
    --t-topic: oklch(0.52 0.1 145);
    --t-agents: oklch(0.48 0.11 165);
    --t-session: oklch(0.5 0.13 325);
    --t-github: oklch(0.4 0.02 250);
    --t-source: oklch(0.55 0.12 55);
  }
}

/* An explicit choice beats the system, in both directions. */
:root[data-theme="light"] {
  --graph-edge: oklch(0.45 0.03 210);
  --t-person: oklch(0.5 0.11 240);
  --t-project: oklch(0.48 0.12 300);
  --t-decision: oklch(0.58 0.12 75);
  --t-customer: oklch(0.5 0.13 30);
  --t-fact: oklch(0.6 0.02 210);
  --t-system: oklch(0.5 0.09 200);
  --t-topic: oklch(0.52 0.1 145);
  --t-agents: oklch(0.48 0.11 165);
  --t-session: oklch(0.5 0.13 325);
  --t-github: oklch(0.4 0.02 250);
  --t-source: oklch(0.55 0.12 55);

  color-scheme: light;
  --bg: oklch(0.975 0.006 190);
  --bg2: oklch(0.995 0.003 190);
  --bg3: oklch(0.945 0.009 190);
  --ink: oklch(0.22 0.02 220);
  --ink2: oklch(0.4 0.02 215);
  --ink3: oklch(0.47 0.02 215);
  --line: oklch(0.84 0.012 200);
  --line2: oklch(0.9 0.01 200);
  --field-line: oklch(0.62 0.015 210);
  --accent: oklch(0.48 0.11 165);
  --accent-ink: oklch(0.99 0.01 165);
  --accent-soft: oklch(0.48 0.11 165 / 0.1);
  --warn: oklch(0.5 0.11 70);
  --bad: oklch(0.5 0.13 30);
  --glow: none;
  --header-bg: oklch(0.975 0.006 190 / 0.86);
}

:root[data-theme="dark"] {
  --graph-edge: oklch(0.72 0.04 200);
  --t-person: oklch(0.8 0.075 235);
  --t-project: oklch(0.79 0.075 295);
  --t-decision: oklch(0.85 0.085 85);
  --t-customer: oklch(0.8 0.08 25);
  --t-fact: oklch(0.62 0.02 210);
  --t-system: oklch(0.8 0.07 190);
  --t-topic: oklch(0.82 0.06 140);
  --t-agents: oklch(0.86 0.16 162);
  --t-session: oklch(0.76 0.09 320);
  --t-github: oklch(0.85 0.01 250);
  --t-source: oklch(0.78 0.08 55);

  color-scheme: dark;
  --bg: oklch(0.16 0.014 215);
  --bg2: oklch(0.195 0.016 215);
  --bg3: oklch(0.235 0.018 215);
  --ink: oklch(0.95 0.008 200);
  --ink2: oklch(0.8 0.014 205);
  --ink3: oklch(0.68 0.016 210);
  --line: oklch(0.34 0.018 215);
  --line2: oklch(0.265 0.016 215);
  --field-line: oklch(0.5 0.02 215);
  --accent: oklch(0.86 0.16 162);
  --accent-ink: oklch(0.2 0.05 165);
  --accent-soft: oklch(0.86 0.16 162 / 0.13);
  --warn: oklch(0.85 0.085 85);
  --bad: oklch(0.8 0.08 25);
  --glow: 0 0 10px var(--accent);
  --header-bg: oklch(0.16 0.014 215 / 0.84);
}

/*   base
   ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  font-family: var(--f-display);
  font-weight: 600;
  text-wrap: balance;
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: var(--step-3);
  line-height: 1;
  letter-spacing: -0.04em;
}
h2 {
  font-size: var(--step-2);
  line-height: 1.08;
  letter-spacing: -0.03em;
}
h3 {
  font-size: var(--step-1);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 var(--space-3);
  max-width: var(--measure);
}

a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

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

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

code {
  background: var(--bg3);
  border-radius: 5px;
  padding: 0.1em 0.35em;
}

pre {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  overflow-x: auto;
  line-height: 1.7;
}

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

hr {
  border: 0;
  border-top: 1px solid var(--line2);
  margin: var(--space-4) 0;
}

/* A visible focus ring everywhere, never removed. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* `hidden` always wins: the pages toggle the editor, the save button and the
   token reveal with it, and a component's own `display` must not undo that. */
[hidden] {
  display: none !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink3);
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  :where(a, button, input, select, textarea, .btn) {
    transition: color 150ms, background-color 150ms, border-color 150ms,
      box-shadow 200ms, filter 150ms, transform 150ms var(--ease);
  }
}

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

/*   layout
   ---------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main.wrap {
  flex: 1 0 auto;
  padding-block: var(--space-4) var(--space-5);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus {
  left: 8px;
  color: var(--accent-ink);
}

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

/*   header: the website's sticky, blurred bar
   ---------------------------------------------------------------- */

.hd {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line2);
}

.hd__in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding-block: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-end: auto;
  text-decoration: none;
  color: var(--ink);
  border-radius: 6px;
}

.brand:hover {
  color: var(--ink);
}

/* The mark: a ring with the live node at its centre, as on the site. */
.mark {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: grid;
  place-items: center;
}

.mark span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--glow);
}

.brand__word {
  font-family: var(--f-display);
  font-weight: 650;
  font-size: 19px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand__word span {
  font-family: var(--f-mono);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink3);
}

.brand__word--sm {
  font-size: 17px;
}
.brand__word--sm span {
  font-size: 12px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 14px;
}

.nav a {
  padding: 6px 9px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--ink2);
}

.nav a:hover {
  color: var(--ink);
  background: var(--bg2);
}

.nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--bg2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* The theme toggle. `app.js` writes its label with `textContent`, so the
   half-filled disc is drawn by `::before` and survives the relabel. */
.theme-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.theme-btn::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.theme-btn:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--ink3);
  background: transparent;
}

/* Phones: the toggle shows only its disc, as on the site. `app.js` sets an
   aria-label on it, so the accessible name does not depend on the text. */
@media (max-width: 420px) {
  .theme-btn {
    font-size: 0;
    gap: 0;
    padding: 0 10px;
  }
}

/* Narrow screens: brand and theme on the first row, the nav on its own. */
@media (max-width: 40rem) {
  .hd__in .nav {
    order: 3;
    flex: 1 1 100%;
    margin-inline: -9px;
  }
}

/*   footer
   ---------------------------------------------------------------- */

.ft {
  border-top: 1px solid var(--line2);
}

.ft__in {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 28px;
  padding-block: 24px 32px;
  font-size: 14px;
  color: var(--ink3);
}

.ft__brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ft__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.ft__nav a {
  color: var(--ink2);
}

.ft__nav a:hover {
  color: var(--accent);
}

/*   type helpers
   ---------------------------------------------------------------- */

/* The site's mono, uppercase kicker above a heading. */
.eyebrow {
  margin: 0 0 14px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink3);
}

.lede {
  max-width: 36em;
  font-size: clamp(17px, 1.6vw, 19px);
  line-height: 1.6;
  color: var(--ink2);
  text-wrap: pretty;
}

.muted {
  color: var(--ink2);
}

.tiny {
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink3);
}

.tiny code {
  font-size: 1em;
}

.page-head {
  margin-bottom: var(--space-4);
}

.page-head h1 {
  margin-bottom: var(--space-3);
}

.section-h {
  margin-top: var(--space-5);
}

/*   surfaces
   ---------------------------------------------------------------- */

.card {
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  padding: clamp(18px, 3vw, 24px);
  min-width: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

/* The site's `.tag`: a dashed, mono, uppercase status chip. */
.pill {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink3);
  white-space: nowrap;
}

p.pill {
  margin-bottom: 0;
}

.pill[data-state="off"],
.pill[data-state="disabled"] {
  color: var(--ink3);
}

.pill[data-state="on"],
.pill[data-state="live"] {
  color: var(--accent);
  border: 1px solid var(--accent);
}

.pill[data-state="warn"] {
  color: var(--warn);
  border: 1px solid var(--warn);
}

/* a personal access token is one unbroken string: break it rather than let it
   widen the column or overflow the card. */
#token-value {
  overflow-wrap: anywhere;
  flex: 2 1 14rem;
}

/*   controls
   ---------------------------------------------------------------- */

/* Default buttons are the site's ghost button; `data-variant="primary"` and
   `.btn--primary` are its accent button. */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0.5rem 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

button:hover:not(:disabled),
.btn:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  color: var(--ink3);
  border-style: dashed;
  background: transparent;
}

button[data-variant="primary"],
.btn--primary {
  min-height: 50px;
  padding-inline: 20px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-size: 16px;
  font-weight: 650;
}

button[data-variant="primary"]:hover:not(:disabled),
.btn--primary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  filter: brightness(1.08);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

button[data-variant="primary"]:active:not(:disabled) {
  transform: translateY(1px);
}

button[data-variant="primary"]:disabled {
  cursor: progress;
  border-style: solid;
  color: var(--accent-ink);
  filter: saturate(0.6);
}

/* compact buttons inside table rows */
.table button {
  min-height: 34px;
  padding: 0.25rem 12px;
  font-size: 14px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: var(--space-1);
}

input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  min-height: 50px;
  padding: 0 16px;
  width: 100%;
  max-width: 100%;
}

.card :where(input, select, textarea) {
  background: var(--bg);
}

select {
  padding-inline-end: 12px;
}

textarea {
  min-height: 12rem;
  padding: 14px 16px;
  resize: vertical;
  font-family: var(--f-mono);
  font-size: 14px;
  line-height: 1.6;
}

:where(input, select, textarea):hover:not(:disabled) {
  border-color: var(--ink3);
}

/* The site's field focus: accent border and a soft halo, on top of the
   global outline so keyboard focus stays unmistakable. */
:where(input, select, textarea):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

:where(input, select, textarea):disabled {
  cursor: not-allowed;
  color: var(--ink3);
  border-style: dashed;
}

input[aria-invalid="true"] {
  border-color: var(--bad);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

fieldset {
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: var(--space-3);
  margin: 0 0 var(--space-3);
  min-width: 0;
}

legend {
  padding-inline: 6px;
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

/*   notices: errors, confirmations and empty states
   ---------------------------------------------------------------- */

.notice {
  display: flex;
  gap: 10px;
  align-items: baseline;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-block: var(--space-2);
  background: var(--bg3);
  color: var(--ink);
  font-size: 15px;
}

/* the site's status dot, in the notice's tone */
.notice::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--ink3);
  transform: translateY(-1px);
}

.notice[hidden] {
  display: none;
}

/* A notice that holds a block of content (the token reveal) stacks it. */
.notice:has(> p) {
  display: block;
}
.notice:has(> p)::before {
  display: none;
}

.notice[data-tone="ok"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.notice[data-tone="ok"]::before {
  background: var(--accent);
  box-shadow: var(--glow);
}

.notice[data-tone="warn"] {
  border-color: var(--warn);
}
.notice[data-tone="warn"]::before {
  background: var(--warn);
}

.notice[data-tone="bad"] {
  border-color: var(--bad);
}
.notice[data-tone="bad"]::before {
  background: var(--bad);
}

.notice:empty {
  display: none;
}

/*   sign-in
   ---------------------------------------------------------------- */

/* A plain, centred sign-in panel near the top of the viewport. The width cap
   sits on the panel itself: `main.shell__main` sets its own max-width. */
.signin-panel {
  max-width: 400px;
  margin-inline: auto;
  padding-block: clamp(16px, 8vh, 72px) var(--space-5);
}

.signin-panel p {
  max-width: none;
}

.signin-card {
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  padding: clamp(24px, 4vw, 32px);
  min-width: 0;
}

.signin-card h1 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 8px;
}

.signin-card__sub {
  margin: 0 0 24px;
  text-align: center;
  color: var(--ink2);
  font-size: 15px;
}

.signin-form {
  display: grid;
  gap: 8px;
  margin: 0;
}

.signin-form > label {
  margin: 0;
}

.signin-form > input {
  margin-bottom: 4px;
}

.signin-form > button,
.signin-card__alt {
  width: 100%;
  min-height: 50px;
  box-sizing: border-box;
  margin: 0;
}

.signin-card #email-status {
  margin-bottom: 0;
}

.signin-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

.signin-divider::before,
.signin-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line2);
}

.signin-foot {
  margin: 20px 0 8px;
  text-align: center;
  font-size: 14px;
  color: var(--ink2);
}

.signin-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 13px;
}

.signin-links a {
  color: var(--ink2);
}

.signin-links a:hover {
  color: var(--accent);
}

/* The methods list (the "steps" list on the home page) keeps its grid. */
.methods {
  list-style: none;
  margin: var(--space-3) 0 var(--space-4);
  padding: 0;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.methods > li {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  padding: 20px;
  min-width: 0;
}

.methods > li > strong {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.methods > li > .muted {
  font-size: 15px;
}

.methods > li > .btn,
.methods > li > button {
  width: 100%;
  margin-top: auto;
}

/*   the session: checking, the signed-in home, and the header bar
   ---------------------------------------------------------------- */

/* "Checking your session…": the dot pulses while nothing else is shown. */
.checking::before {
  background: var(--accent);
  box-shadow: var(--glow);
}

@media (prefers-reduced-motion: no-preference) {
  .checking::before {
    animation: lb-pulse 1.2s var(--ease) infinite alternate;
  }
}

@keyframes lb-pulse {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 1;
  }
}

.home__ws {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  min-width: 0;
}

.facts > div {
  min-width: 0;
}

.facts dt {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink3);
}

.facts dd {
  margin: 2px 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.steps {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.steps > .steps__wide {
  grid-column: 1 / -1;
}

/* An endpoint or a command: one long string that wraps instead of widening
   the card. */
.endpoint {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: var(--bg3);
  overflow-wrap: anywhere;
  white-space: normal;
}

.howto {
  margin: 0;
  padding-inline-start: 1.25rem;
  display: grid;
  gap: var(--space-2);
  color: var(--ink2);
  font-size: 15px;
}

.howto .endpoint {
  margin-top: 6px;
}

/* The header's "Signed in as …" and Sign out. */
.session-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
  color: var(--ink3);
}

.session-bar[hidden] {
  display: none;
}

.session-bar__who {
  min-width: 0;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-bar__who strong {
  color: var(--ink);
  font-weight: 600;
}

/* A header-sized ghost button, the same box as the theme toggle. */
.hd-btn {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink2);
}

/* Narrow screens: brand and theme stay on the first row; who is signed in
   and Sign out take the second, the nav the third. */
@media (max-width: 40rem) {
  .hd__in .session-bar {
    order: 2;
    flex: 1 1 100%;
    justify-content: space-between;
  }
  .session-bar__who {
    max-width: none;
  }
}

/* Phones: no room for the name, so Sign out joins the brand's row and the
   name stays readable to a screen reader only. */
@media (max-width: 30rem) {
  .hd__in .session-bar {
    order: 0;
    flex: 0 0 auto;
  }
  .session-bar__who {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/*   settings
   ---------------------------------------------------------------- */

.settings {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
  align-items: start;
}

.settings section {
  min-width: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
  max-width: none;
}

.row > label {
  flex: 1 1 10rem;
  margin-bottom: 0;
}

.row > select,
.row > input:not([type="checkbox"]) {
  flex: 2 1 12rem;
  width: auto;
  min-width: 0;
}

/* the table scrolls inside its own box rather than widen the page */
.table-scroll {
  overflow-x: auto;
  margin-inline: -4px;
  padding-inline: 4px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

/* Cells keep their words whole; a narrow screen scrolls the table inside
   `.table-scroll` instead of breaking "openrouter" into four lines. */
.table-scroll .table {
  min-width: 30rem;
}

.table-scroll .table :where(th, td) {
  overflow-wrap: normal;
}

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

.table th {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
}

.table th,
.table td {
  text-align: left;
  border-bottom: 1px solid var(--line2);
  padding: 10px 12px 10px 0;
  vertical-align: top;
}

.table td.muted,
.table td[colspan] {
  color: var(--ink2);
  font-style: normal;
}

/*   the settings page: a section nav beside the sections
   ---------------------------------------------------------------- */

.settings-page {
  max-width: 1120px;
}

.settings-layout {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 60rem) {
  .settings-layout {
    grid-template-columns: 12rem minmax(0, 1fr);
  }
}

.settings-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}

/* Desktop: a sticky list on the left. */
.snav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 15px;
}

.snav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--ink2);
  text-decoration: none;
  border-inline-start: 2px solid transparent;
}

.snav a:hover {
  color: var(--ink);
  background: var(--bg2);
}

.snav a[aria-current="true"] {
  color: var(--ink);
  background: var(--bg2);
  border-inline-start-color: var(--accent);
}

@media (min-width: 60rem) {
  .snav {
    position: sticky;
    top: 88px;
  }
}

/* Phones and tablets: a segmented control pinned under the header. */
@media (max-width: 59.99rem) {
  .snav {
    flex-direction: row;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line2);
    border-radius: 12px;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .snav a {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    padding: 0 6px;
    border-inline-start: 0;
    font-size: 14px;
    white-space: nowrap;
  }
  .snav a[aria-current="true"] {
    background: var(--bg3);
    box-shadow: inset 0 -2px 0 var(--accent);
  }
}

@media (max-width: 400px) {
  .snav a {
    font-size: 13px;
    padding: 0 2px;
  }
}

/* Sections land below the sticky header when a nav link is followed. */
.sect {
  scroll-margin-top: 140px;
}

.sect__head {
  margin-bottom: var(--space-3);
}

.sect__head h2 {
  margin-bottom: 6px;
}

.sect__head p {
  margin: 0;
}

.sect__head--row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.sect__head--row h2 {
  margin: 0;
}

.sect h3 {
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
}

/* small ghost buttons: card actions, copy, show/hide. 44px tall on touch. */
.btn-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
}

@media (pointer: coarse) {
  .btn-sm {
    min-height: 44px;
  }
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--bad);
  background: transparent;
  color: var(--bad);
}

/*   forms: one rhythm for every field
   ---------------------------------------------------------------- */

.connect {
  border-top: 1px solid var(--line2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  display: grid;
  gap: 22px;
}

/* a field focused by validation lands below the sticky header */
.connect :where(input, fieldset) {
  scroll-margin-top: 140px;
}

.connect > h3 {
  margin: 0;
}

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

.field > label,
.field > .label {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
}

.hint {
  margin: 0;
  font-size: 14px;
  color: var(--ink3);
}

.field-error {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--bad);
}

.field-error:empty {
  display: none;
}

/* the API key: the field with its Show/Hide button inside the same row */
.secret {
  display: flex;
  gap: 8px;
}

.secret > input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--f-mono);
  font-size: 15px;
}

.secret > button {
  flex: 0 0 auto;
  min-height: 50px;
  min-width: 4.5rem;
}

/* a read-only endpoint reads as a value, not as a field to type in */
input[readonly] {
  color: var(--ink2);
  background: var(--bg2);
  border-style: dashed;
  font-family: var(--f-mono);
  font-size: 14px;
}

.card input[readonly] {
  background: var(--bg2);
}

#base-url {
  font-family: var(--f-mono);
  font-size: 14px;
}

.vars,
.custom-fields {
  display: grid;
  gap: 22px;
}

.vars:empty {
  display: none;
}

.picked {
  margin: -10px 0 0;
  font-size: 14px;
  color: var(--ink3);
}

.picked:empty {
  display: none;
}

.picked strong {
  color: var(--ink);
  font-weight: 600;
}

.model-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

/* the provider picker: popular cards, then every provider behind a search */
.choice__grid--providers {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
}

/* a provider's name never splits mid-word, whatever the column width does
   (the body breaks anywhere to keep long URLs tamed; these names are short) */
.choice__grid--providers .choice__text strong {
  overflow-wrap: normal;
  word-break: normal;
}

.picker {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.picker > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

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

.picker > summary::after {
  content: "+";
  margin-inline-start: auto;
  font-family: var(--f-mono);
  color: var(--ink3);
}

.picker[open] > summary::after {
  content: "−";
}

.picker__count {
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink3);
}

.picker__body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

/* the full list is the same card grid as the popular one, just scrollable */
.picker__cards {
  max-height: 26rem;
  overflow-y: auto;
  padding: 2px;
}

.picker__source {
  font-size: 13px;
}

/* a provider's mark: the vendor's logo, or its initials when none is licensed.
   One neutral tile in both themes, like the rows it sits in. Not the header's
   `.mark` ring, which is a different, older class. */
.provider-mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg3);
  color: var(--ink);
}

.provider-mark svg {
  width: 20px;
  height: 20px;
}

.provider-mark--letters {
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
}

/* radio cards: role, provider and token access */
.choice {
  border: 0;
  padding: 0;
  margin: 0;
}

.choice > legend {
  padding: 0;
  margin-bottom: 8px;
  font-family: var(--f-body);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.choice__grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
}

.choice__grid--two {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.choice__card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  font-weight: 400;
}

.choice__card:hover {
  border-color: var(--ink3);
}

/* The radio itself is not the UI: the card's checked border and background
   are. The input stays focusable for keyboards; only its box is taken away
   (the sr pattern, kept local so the card keeps its own grid flow). */
.choice__card input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.choice__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.choice__text strong {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
}

.choice__text span {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink3);
}

.choice__card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice__card:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* model name suggestions */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border-style: dashed;
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--ink2);
}

@media (pointer: coarse) {
  .chip {
    min-height: 44px;
  }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.form-actions .hint {
  flex: 1 1 16rem;
}

@media (max-width: 480px) {
  .form-actions > button {
    flex: 1 1 100%;
  }
}

/*   model slots: three job cards — Main, Triage, Research
   ---------------------------------------------------------------- */

.slots {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.slots__note {
  margin: 0 0 10px;
}

.slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  min-width: 0;
}

.slot__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.slot__head {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.slot__role {
  margin: 0;
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: normal;
  word-break: normal;
}

.slot__hint {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink3);
}

.slot__line {
  margin: 0;
  font-size: 14.5px;
  overflow-wrap: normal;
  word-break: normal;
}

.slot .tiny {
  margin: 0;
}

.slot__actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.slot__actions .btn-sm {
  flex: 1 1 0;
}

/*   tokens: a table on wide screens, cards on narrow ones
   ---------------------------------------------------------------- */

.table-cards .table td.cell-actions {
  text-align: right;
  padding-right: 0;
  vertical-align: middle;
}

.table-cards .table td {
  vertical-align: middle;
}

.table-cards .table td:nth-child(2) {
  font-family: var(--f-mono);
  font-size: 14px;
}

@media (max-width: 40rem) {
  .table-cards {
    overflow: visible;
    margin: 0;
    padding: 0;
  }
  .table-cards .table {
    min-width: 0;
  }
  .table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table-cards tbody {
    display: grid;
    gap: 10px;
  }
  .table-cards tr {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }
  .table-cards .table td {
    display: contents;
    border: 0;
    padding: 0;
  }
  .table-cards .table td[data-label]::before {
    content: attr(data-label);
    font-size: 13px;
    color: var(--ink3);
  }
  .table-cards .table td[colspan] {
    display: block;
    grid-column: 1 / -1;
  }
  .table-cards td.cell-actions .btn-sm {
    grid-column: 1 / -1;
    margin-top: 8px;
    width: 100%;
  }
}

/*   multiselect: chips over a searchable list of native checkboxes
   ---------------------------------------------------------------- */

.ms {
  display: grid;
  gap: 10px;
}

.ms__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ms__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 32px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 14px;
}

.ms__chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms__x {
  min-height: 28px;
  min-width: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink2);
  font-size: 18px;
  line-height: 1;
}

.ms__x:hover,
.ms__x:focus-visible {
  background: var(--bg3);
  color: var(--ink);
}

.ms__none {
  font-size: 14px;
}

.ms__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ms__list {
  display: block;
  max-height: 15rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: var(--bg);
}

.ms__group {
  margin: 8px 8px 2px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

.ms__opt {
  display: flex;
  flex-wrap: wrap;
  height: auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 0 0 2px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 400;
  min-width: 0;
}

.ms__opt:hover {
  background: var(--bg2);
}

.ms__opt:has(input:checked) {
  background: var(--accent-soft);
}

.ms__label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ms__hint {
  margin-left: auto;
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 40rem) {
  /* the hint goes under the name, beside the box's column */
  .ms__hint {
    flex-basis: 100%;
    margin-left: 30px;
    white-space: normal;
  }
}

.ms__empty {
  margin: 0;
}

/* a short set of plain checkboxes (spaces, kinds) */
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.checks > legend {
  float: left;
  width: 100%;
  margin-bottom: 4px;
}

.checks > label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  font-weight: 400;
}

.checks > .field-error {
  flex-basis: 100%;
}

/* A plain warning under a field: the choice is allowed, but it may reach no one. */
.field-warning {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--warn);
}

.field-warning:empty {
  display: none;
}

/* "This creates 6 grants" */
.preview {
  margin: 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.preview:empty {
  display: none;
}

/* a list's filters and its bulk actions */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.bulkbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
}

.bulkbar__all {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-weight: 600;
}

.bulkbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.table-cards .table td.cell-select {
  width: 2.5rem;
  vertical-align: middle;
}

/* with a selection column first, the second column is a name again */
.table-cards .table-select td:nth-child(2) {
  font-family: inherit;
  font-size: inherit;
}

.table-cards .table-select td:nth-child(3) {
  font-family: var(--f-mono);
  font-size: 14px;
}

@media (max-width: 40rem) {
  .table-cards .table td.cell-select {
    display: block;
    grid-column: 1 / -1;
    width: auto;
  }
  .bulkbar__actions {
    margin-left: 0;
    width: 100%;
  }
  .bulkbar__actions .btn-sm {
    flex: 1 1 0;
  }
}

/* the one-time token reveal */
.reveal {
  display: grid;
  gap: 12px;
  margin-top: var(--space-3);
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
}

.reveal__note {
  margin: 0;
}

.reveal > button {
  justify-self: start;
}

/* a value and its Copy button */
.copybox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
}

.copybox > code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 0;
  background: none;
  font-size: 13.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}

.copybox > button {
  flex: 0 0 auto;
  align-self: center;
}

/* Phones: the value gets the full width and Copy sits under it. */
@media (max-width: 30rem) {
  .copybox {
    flex-wrap: wrap;
    padding: 10px 10px 10px 14px;
  }
  .copybox > code {
    flex-basis: 100%;
    padding: 0;
  }
  .copybox > button {
    margin-inline-start: auto;
  }
}

#token-value {
  flex: 1 1 auto;
}

/* the Connect panel's three recipes */
.recipes {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.recipes > li {
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line2);
}

.recipes h3 {
  margin: 0;
  font-size: 16px;
}

/* "Built with": collapsed at the bottom */
.disclosure {
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  padding: 0 clamp(18px, 3vw, 24px);
}

.disclosure > summary {
  display: flex;
  align-items: center;
  min-height: 52px;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink2);
  list-style: none;
}

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

.disclosure > summary::after {
  content: "+";
  margin-inline-start: auto;
  font-family: var(--f-mono);
  color: var(--ink3);
}

.disclosure[open] > summary::after {
  content: "−";
}

.disclosure[open] {
  padding-bottom: 18px;
}

/* toasts and the confirm dialog */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg3);
  color: var(--ink);
  font-size: 15px;
  box-shadow: 0 10px 30px oklch(0 0 0 / 0.35);
}

.toast[data-tone="ok"] {
  border-color: var(--accent);
}

.toast[data-tone="warn"] {
  border-color: var(--warn);
}

.toast[data-tone="bad"] {
  border-color: var(--bad);
}

/* "Living Brain was updated" (assets/update.js): the toast, plus a button. */
.update-notice {
  display: flex;
  align-items: center;
  gap: 12px;
}

.update-notice__reload {
  flex: none;
}

.dialog {
  width: min(28rem, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg2);
  color: var(--ink);
}

.dialog::backdrop {
  background: oklch(0 0 0 / 0.55);
}

.dialog h2 {
  font-size: var(--step-1);
  margin: 0 0 8px;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--space-3);
}

.dialog .btn-danger {
  border-color: var(--bad);
  color: var(--bad);
}

/*   wiki
   ---------------------------------------------------------------- */

.wiki-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}

.wiki-toolbar .status {
  margin-inline-start: auto;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
}

.editor {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  align-items: start;
}

.editor > * {
  min-width: 0;
}

.prose {
  max-width: var(--measure);
  color: var(--ink2);
  line-height: 1.65;
}

.prose :where(h1, h2, h3, strong) {
  color: var(--ink);
}

.prose h1 {
  font-size: var(--step-2);
}
.prose h2 {
  font-size: var(--step-1);
  margin-top: var(--space-4);
}
.prose h3 {
  font-size: 1.1rem;
  margin-top: var(--space-3);
}

.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.prose ul,
.prose ol {
  padding-inline-start: 1.4em;
  margin: 0 0 var(--space-3);
}

.prose blockquote {
  margin: 0 0 var(--space-3);
  padding-inline-start: var(--space-3);
  border-inline-start: 2px solid var(--accent);
  color: var(--ink2);
}

/* an article with nothing in it yet (no page loaded) draws no empty box */
article.prose:empty {
  display: none;
}

/* the closing note under a page */
main > p.tiny:last-child {
  margin-top: var(--space-4);
}

.aside-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  align-items: start;
}

.aside-grid > * {
  min-width: 0;
}

.aside-grid h3 {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

/* the site's wiki chips */
.backlinks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.backlinks a {
  display: inline-flex;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink2);
  text-decoration: none;
}

.backlinks a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.citations {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.citations li {
  border-inline-start: 2px solid var(--accent);
  padding-inline-start: var(--space-2);
}

.citations .quote {
  display: block;
  color: var(--ink2);
  font-size: 0.92em;
}

/*   a standalone message page (the magic-link verify form)
   ---------------------------------------------------------------- */

.solo {
  max-width: 34rem;
}

.solo form {
  margin-block: var(--space-3);
}

.solo form button {
  width: 100%;
}

/*   models: the Main picker, the provider cards and the detail sheet
   ---------------------------------------------------------------- */

#models {
  container-type: inline-size;
}

.model-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  margin: 0 0 var(--space-3);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.model-bar > label {
  margin: 0;
}

.model-bar select,
.sheet select {
  min-width: 0;
  text-overflow: ellipsis;
}

.model-bar > .hint {
  margin: 0;
}

.models__sub {
  margin: var(--space-3) 0 4px;
  font-size: 18px;
}

/* The grid: square cards, two across on a phone, three, then four. */
.mcards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

@container (min-width: 34rem) {
  .mcards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

@container (min-width: 46rem) {
  .mcards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.mcards__item {
  display: block;
  min-width: 0;
}

.mcard {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: clamp(10px, 3.2cqi, 16px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  text-align: start;
  font-weight: 400;
}

.mcard:hover:not(:disabled) {
  border-color: var(--ink3);
  background: var(--bg3);
}

.mcard:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mcard--on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mcard__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.mcard__top .pill {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The logo: the self-hosted SVG as a mask, filled with the text colour, so
   one file reads in both themes. */
.mcard__logo {
  flex: none;
  display: block;
  width: clamp(26px, 7cqi, 36px);
  height: clamp(26px, 7cqi, 36px);
  background-color: currentColor;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

[data-logo="anthropic"] {
  -webkit-mask-image: url(logos/anthropic.1cc599f6eb.svg);
  mask-image: url(logos/anthropic.1cc599f6eb.svg);
}
[data-logo="claude"] {
  -webkit-mask-image: url(logos/claude.2d6fda79eb.svg);
  mask-image: url(logos/claude.2d6fda79eb.svg);
}
[data-logo="openai"] {
  -webkit-mask-image: url(logos/openai.2b4a04ddc2.svg);
  mask-image: url(logos/openai.2b4a04ddc2.svg);
}
[data-logo="zai"] {
  -webkit-mask-image: url(logos/zai.c997179dc3.svg);
  mask-image: url(logos/zai.c997179dc3.svg);
}
[data-logo="deepseek"] {
  -webkit-mask-image: url(logos/deepseek.7a55a0a739.svg);
  mask-image: url(logos/deepseek.7a55a0a739.svg);
}
[data-logo="openrouter"] {
  -webkit-mask-image: url(logos/openrouter.9148696e3a.svg);
  mask-image: url(logos/openrouter.9148696e3a.svg);
}
[data-logo="minimax"] {
  -webkit-mask-image: url(logos/minimax.ef95e28b29.svg);
  mask-image: url(logos/minimax.ef95e28b29.svg);
}
[data-logo="kimi"] {
  -webkit-mask-image: url(logos/kimi.01fb4be700.svg);
  mask-image: url(logos/kimi.01fb4be700.svg);
}
[data-logo="qwen"] {
  -webkit-mask-image: url(logos/qwen.83896c41e9.svg);
  mask-image: url(logos/qwen.83896c41e9.svg);
}
[data-logo="custom"] {
  -webkit-mask-image: url(logos/custom.79b481735e.svg);
  mask-image: url(logos/custom.79b481735e.svg);
}
[data-logo="jev"] {
  -webkit-mask-image: url(logos/jev.894e5bd902.svg);
  mask-image: url(logos/jev.894e5bd902.svg);
}

.mcard__name {
  margin-top: auto;
  font-family: var(--f-display);
  font-size: clamp(15px, 3.6cqi, 18px);
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.mcard > * {
  flex-shrink: 0;
}

.mcard__desc {
  flex: 0 1 auto;
  min-height: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: clamp(12px, 2.9cqi, 14px);
  line-height: 1.35;
  color: var(--ink3);
}

.mcard__badges,
.sheet__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sheet__badges {
  margin: 0 0 6px;
}

.mcard__badge {
  display: inline-block;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ink2);
  background: var(--bg2);
  overflow-wrap: anywhere;
}

.mcard__badge[data-badge="1"] {
  border-color: var(--accent);
  color: var(--ink);
}

.mcard__badge[data-badge="2"] {
  border-color: var(--warn);
}

/* "Optional": the Jev card, which no job needs. */
.mcard__badge[data-badge="3"] {
  border-style: dashed;
}

/* On a phone the cards are small: one line of description, smaller badges. */
@container (max-width: 25rem) {
  .mcard__desc {
    -webkit-line-clamp: 1;
  }
  /* A subscription card's two-line name and badge fill it; the sheet says
     the rest. */
  .mcard[data-kind="runner"] .mcard__desc {
    display: none;
  }
  .mcard__badge {
    padding: 1px 6px;
    font-size: 10.5px;
  }
}

/* the detail sheet */
.sheet {
  width: min(40rem, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.sheet__logo {
  width: 36px;
  height: 36px;
  margin-top: 2px;
}

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

.sheet__title h2 {
  margin: 0 0 2px;
}

.sheet__title p {
  margin: 0;
}

.sheet__close-form {
  flex: none;
}

#sheet-protocol:empty {
  display: none;
}

.sheet__connected h3,
.sheet__runner h3 {
  margin: var(--space-3) 0 6px;
  font-size: 16px;
}

.sheet__uses {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sheet__uses li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.sheet__use-actions {
  display: flex;
  gap: 6px;
}

.sheet .connect {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
}

.sheet__runner {
  display: grid;
  gap: 14px;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line2);
}

.sheet__runner .hint {
  margin: 0;
}

/* Jev's sheet: its state line, and the privacy note set apart. */
.jev__state {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.jev__privacy {
  padding: 10px 12px;
  border-inline-start: 3px solid var(--line);
  background: var(--bg3);
  border-radius: 6px;
}

.sheet__jev .field {
  display: grid;
  gap: 6px;
}

.sheet__jev .field .btn-sm {
  justify-self: start;
}

/* The Z.AI Coding Plan on your device: the key form steps aside for the runner. */
.sheet__form.plan-device > :not(h3):not(.coding-plan) {
  display: none;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 600;
}

.check input {
  width: 20px;
  min-height: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--accent);
}

.coding-plan .hint {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--warn);
  background: var(--bg3);
  border-radius: 6px;
}

.coding-plan .coding-plan__device {
  margin-top: 12px;
  font-weight: 400;
}

/* The sheet's own messages: pinned to its foot while it scrolls, opaque in
   every tone so the form never shows through. */
.notice.sheet__result {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-block: 16px 0;
  background: var(--bg3);
}

.notice.sheet__result[data-tone="ok"] {
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg3);
}

/* Empty, it stays rendered (with no box), so a screen reader announces the
   first message put into it. */
.notice.sheet__result:empty {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
}

.notice.sheet__result:empty::before {
  display: none;
}

.model-pick {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.model-pick select {
  flex: 1 1 auto;
  min-width: 0;
}

.model-pick .btn-sm {
  flex: none;
  min-height: 50px;
}

@media print {
  .hd,
  .ft,
  .wiki-toolbar,
  .skip {
    display: none;
  }
}

/* The workspace switcher in Settings → Members (ADR 0004). */
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.plain-list li { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* Settings → Usage & limits: the budget cards and their usage bars. */
.budget-form {
  display: grid;
  gap: var(--space-4);
}

.budget-cards {
  display: grid;
  gap: 16px;
}

.budget-card {
  gap: 14px;
}

.budget-card__title {
  margin: 0;
}

.budget-advanced {
  display: grid;
  gap: 14px;
}

.usebar {
  display: grid;
  gap: 6px;
}

.usebar__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 14px;
}

.usebar__label {
  font-weight: 600;
}

.usebar__text {
  color: var(--ink3);
  font-variant-numeric: tabular-nums;
}

.usebar__track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--bg3);
  overflow: hidden;
}

.usebar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--accent);
}

.usebar[data-tone="near"] .usebar__fill {
  background: var(--warn);
}

.usebar[data-tone="over"] .usebar__fill {
  background: var(--bad);
}

.usebar[data-tone="over"] .usebar__text {
  color: var(--bad);
}

/*   the app shell: top bar, sidebar, drawer, palette
     (docs/ux-navigation.md; built by `shell.js` from `nav.js`)
   ---------------------------------------------------------------- */

:root {
  --sidebar-w: 15rem;
  --sidebar-rail: 3.75rem;
  --topbar-h: 58px;
}

.topbar__in {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-h);
  padding: 8px clamp(12px, 2vw, 20px);
}

.topbar .brand {
  margin-inline-end: 0;
  flex-shrink: 0;
}

/* The menu button: phones and tablets only, where the sidebar is a drawer. */
.topbar__menu {
  display: none;
  flex: 0 0 auto;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border-color: var(--line);
}
.burger,
.burger::before,
.burger::after {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.burger {
  position: relative;
}
.burger::before,
.burger::after {
  content: "";
  position: absolute;
  left: 0;
}
.burger::before {
  top: -5px;
}
.burger::after {
  top: 5px;
}

/* The workspace switcher and the user menu: a button and a dropdown. */
.ws,
.user {
  position: relative;
  min-width: 0;
}

.ws__btn,
.user__btn {
  min-height: 36px;
  max-width: 100%;
  padding: 0 10px;
  gap: 8px;
  border-color: var(--line2);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.ws__btn::after {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
}

.ws__name {
  min-width: 0;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user__btn {
  padding: 0 10px 0 4px;
  font-weight: 500;
}

.user__avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--f-display);
  font-weight: 650;
  font-size: 14px;
}

.user .session-bar__who {
  max-width: 10rem;
}

/* Avatars: an uploaded picture, or initials on one of eight colours chosen
   from the person's (or workspace's) id, so the same one is always the same
   colour (`assets/profile.js`). `.avatar.avatar--tN` outranks the plain
   `.user__avatar` tint the user button had before. */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--f-display);
  font-weight: 650;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}
.avatar--sm {
  width: 22px;
  height: 22px;
  font-size: 10px;
}
.avatar--xl {
  width: 96px;
  height: 96px;
  font-size: 36px;
}
.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.avatar--img {
  background: var(--bg3);
}
.avatar.avatar--t0 { background: oklch(0.72 0.11 25); color: oklch(0.24 0.05 25); }
.avatar.avatar--t1 { background: oklch(0.76 0.11 65); color: oklch(0.26 0.05 65); }
.avatar.avatar--t2 { background: oklch(0.8 0.1 100); color: oklch(0.27 0.05 100); }
.avatar.avatar--t3 { background: oklch(0.76 0.12 150); color: oklch(0.25 0.05 150); }
.avatar.avatar--t4 { background: oklch(0.75 0.09 195); color: oklch(0.25 0.04 195); }
.avatar.avatar--t5 { background: oklch(0.72 0.1 240); color: oklch(0.24 0.05 240); }
.avatar.avatar--t6 { background: oklch(0.72 0.11 290); color: oklch(0.24 0.05 290); }
.avatar.avatar--t7 { background: oklch(0.73 0.11 335); color: oklch(0.24 0.05 335); }
.avatar__preview {
  border: 1px solid var(--line);
}
.avatar__preview[hidden],
.avatar[hidden] {
  display: none;
}
.menu__item .avatar {
  margin-inline-end: 8px;
}
.person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* The picture-and-name editors (Settings → Account, and the workspace's at
   the head of Members). */
.profile {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  margin-block: var(--space-2) var(--space-3);
}
.profile__pic {
  flex: 0 0 auto;
}
.profile__pic-actions {
  display: grid;
  gap: 6px;
  flex: 1 1 16rem;
  min-width: 0;
}

/* The picture picker: one square you click or drop an image on. With an
   image picked it becomes the cropper — drag to move, the slider or the
   wheel to zoom — and the circle shows what a round avatar keeps. */
.pic-picker {
  position: relative;
  display: grid;
  place-items: center;
  width: 9rem;
  height: 9rem;
  overflow: hidden;
  border: 1px dashed var(--field-line);
  border-radius: 14px;
  background: var(--bg3);
  color: var(--ink3);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.pic-picker:hover,
.pic-picker.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.pic-picker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pic-picker[aria-disabled="true"] {
  cursor: default;
}
.pic-picker .avatar--xl {
  width: 100%;
  height: 100%;
  border-radius: 0;
  font-size: 48px;
}
.pic-picker__label {
  position: absolute;
  inset: auto 0 0;
  padding: 6px 0;
  background: oklch(0 0 0 / 0.55);
  color: oklch(1 0 0 / 0.92);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
  pointer-events: none;
}
.pic-picker:hover .pic-picker__label,
.pic-picker:focus-visible .pic-picker__label,
.pic-picker.is-over .pic-picker__label {
  opacity: 1;
}
.pic-picker[aria-disabled="true"] .pic-picker__label {
  display: none;
}
.pic-picker.is-cropping {
  border-style: solid;
  border-color: var(--line);
  cursor: grab;
  touch-action: none;
}
.pic-picker.is-cropping:active {
  cursor: grabbing;
}
.pic-picker.is-cropping .pic-picker__label {
  display: none;
}
.pic-picker canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.pic-picker__guide {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 100vmax oklch(0 0 0 / 0.42);
  outline: 1px solid oklch(1 0 0 / 0.6);
  pointer-events: none;
}
.pic-picker__guide[hidden] {
  display: none;
}
.pic-picker__zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 9rem;
  color: var(--ink3);
  font-size: 12px;
}
.pic-picker__zoom[hidden] {
  display: none;
}
.pic-picker__zoom input {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}
.profile__name {
  max-width: 32rem;
  margin-bottom: var(--space-4);
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 80;
  display: grid;
  gap: 2px;
  min-width: 14rem;
  max-width: min(20rem, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  box-shadow: 0 16px 40px oklch(0 0 0 / 0.35);
}
.ws .menu {
  left: 0;
}
.user .menu {
  right: 0;
}

.menu__item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink2);
  font-size: 14px;
  font-weight: 500;
  text-align: start;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.menu__item:hover:not(:disabled),
.menu__item:focus-visible {
  background: var(--bg3);
  color: var(--ink);
}
.menu__item[aria-current="true"],
.menu__item[aria-current="true"]:disabled {
  color: var(--ink);
  border-style: none;
  cursor: default;
}
.menu__hint {
  color: var(--ink3);
  font-weight: 400;
}
.menu__label,
.menu__note {
  margin: 0;
  padding: 6px 12px 4px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
}
.menu__note {
  text-transform: none;
  letter-spacing: 0;
}

/* The search trigger: a field-shaped button in the middle of the bar. */
.topbar__search {
  flex: 1 1 14rem;
  justify-content: space-between;
  min-width: 0;
  max-width: 30rem;
  min-height: 38px;
  margin-inline: auto;
  padding: 0 8px 0 14px;
  border-color: var(--line2);
  background: var(--bg);
  color: var(--ink3);
  font-size: 14px;
  font-weight: 400;
}
.topbar__search::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  margin-inline-end: 2px;
}
.topbar__search-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-align: start;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__kbd,
kbd {
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink3);
  background: var(--bg2);
}

.topbar #header-signin {
  min-height: 36px;
  padding-inline: 14px;
  font-size: 14px;
}

/* The page under the bar: the sidebar beside a column of main + footer. */
.shell {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

.shell__col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100dvh - var(--topbar-h));
}

.shell__col > main {
  flex: 1 0 auto;
}

main.shell__main {
  max-width: 1120px;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-inline-end: 1px solid var(--line2);
  background: var(--bg);
}

.sidebar__nav {
  flex: 1 0 auto;
  padding: 14px 10px 8px;
}

.sidebar__group + .sidebar__group {
  margin-top: 14px;
}

.sidebar__label {
  margin: 0 0 4px;
  padding: 0 10px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink3);
}

.sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
}

.sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

a.sidebar__link:hover {
  color: var(--ink);
  background: var(--bg2);
}

.sidebar__link[aria-current="page"] {
  color: var(--ink);
  background: var(--bg2);
}
.sidebar__link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar__link[aria-current="page"] .ico {
  color: var(--accent);
}

.sidebar__text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ico {
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar__collapse {
  display: flex;
  justify-content: flex-start;
  text-align: start;
  gap: 10px;
  min-height: 40px;
  margin: 8px 10px 12px;
  padding: 0 10px;
  border-color: transparent;
  color: var(--ink3);
  font-size: 13px;
  font-weight: 500;
}

/* Collapsed (desktop): a rail of icons; the labels stay for screen readers
 * through the links' text, hidden only visually. */
body[data-nav-collapsed="true"] .shell {
  grid-template-columns: var(--sidebar-rail) minmax(0, 1fr);
}
body[data-nav-collapsed="true"] .sidebar__nav {
  padding-inline: 8px;
}
body[data-nav-collapsed="true"] .sidebar__label {
  height: 1px;
  margin: 10px 8px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: var(--line2);
}
body[data-nav-collapsed="true"] .sidebar__link,
body[data-nav-collapsed="true"] .sidebar__collapse {
  justify-content: center;
  padding: 0;
}
body[data-nav-collapsed="true"] .sidebar__collapse {
  margin-inline: 8px;
}
body[data-nav-collapsed="true"] .sidebar__text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
body[data-nav-collapsed="true"] .sidebar__link[aria-current="page"]::before {
  left: -8px;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: oklch(0 0 0 / 0.5);
}

/* Phones and tablets: the sidebar is an off-canvas drawer. */
@media (max-width: 55.99rem) {
  .topbar__menu {
    display: inline-flex;
  }
  .shell,
  body[data-nav-collapsed="true"] .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 70;
    width: min(18rem, 86vw);
    height: 100dvh;
    border-inline-end: 1px solid var(--line);
    background: var(--bg2);
    box-shadow: 0 0 40px oklch(0 0 0 / 0.4);
    transform: translateX(-105%);
    visibility: hidden;
  }
  body[data-nav="open"] .sidebar {
    transform: none;
    visibility: visible;
  }
  .sidebar__collapse {
    display: none;
  }
  body[data-nav-collapsed="true"] .sidebar__text {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
  }
  body[data-nav-collapsed="true"] .sidebar__label {
    height: auto;
    margin: 0 0 4px;
    padding: 0 10px;
    color: var(--ink3);
    background: none;
  }
  body[data-nav-collapsed="true"] .sidebar__link {
    justify-content: flex-start;
    padding: 0 10px;
  }
  .sidebar__link {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .sidebar {
    transition: transform 200ms var(--ease), visibility 200ms;
  }
}

/* Narrow phones: the search trigger keeps its icon and shortcut-less label,
 * the user button its avatar. */
@media (max-width: 40rem) {
  .topbar__in {
    gap: 8px;
  }
  .topbar .brand__word {
    display: none;
  }
  .topbar__kbd {
    display: none;
  }
  .ws__name {
    max-width: 7rem;
  }
  .user .session-bar__who {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .user__btn {
    padding: 0 4px;
  }
  .topbar .theme-btn {
    font-size: 0;
    gap: 0;
    padding: 0 10px;
  }
}

/* The narrowest phones: the theme toggle steps aside for the switcher
 * (the user menu and the palette both still switch the theme). */
@media (max-width: 26rem) {
  .topbar .theme-btn {
    display: none;
  }
  .topbar .brand {
    display: none;
  }
}

/* The sign-in page, signed out: no sidebar, no search — just the door. */
body[data-page="signin"]:not([data-session="signed-in"]) :is(.sidebar, .topbar__menu, .topbar__search, .scrim) {
  display: none;
}
body[data-page="signin"]:not([data-session="signed-in"]) .shell {
  grid-template-columns: minmax(0, 1fr);
}
body[data-page="signin"]:not([data-session="signed-in"]) .topbar .brand {
  display: flex;
  margin-inline-end: auto;
}
body[data-page="signin"]:not([data-session="signed-in"]) .topbar .theme-btn {
  display: inline-flex;
}
body[data-page="signin"]:not([data-session="signed-in"]) .topbar .brand__word {
  display: inline;
}

/* Breadcrumbs on a page and a transcript. */
.crumbs {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--ink3);
}
.crumbs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.crumbs__list li {
  display: inline-flex;
  min-width: 0;
  overflow-wrap: anywhere;
}
.crumbs__list li + li::before {
  content: "/";
  margin-inline-end: 4px;
  color: var(--line);
}
.crumbs a {
  color: var(--ink2);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--accent);
}
.crumbs [aria-current="page"] {
  color: var(--ink2);
}

/* Home: where to go, as cards. */
.jump {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
}
.jump__card {
  display: grid;
  gap: 6px;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  background: var(--bg2);
  color: var(--ink);
  text-decoration: none;
}
.jump__card:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.jump__card .muted {
  font-size: 14px;
}

/* Settings, one tab at a time: no section nav (the sidebar is it), and a
 * tab of one section keeps that section's heading for screen readers only. */
.settings-layout--tabs {
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 60rem) {
  .settings-layout--tabs {
    grid-template-columns: minmax(0, 1fr);
  }
}
.sect--solo > .sect__head {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The command palette: a modal near the top of the screen. */
.palette {
  width: min(40rem, calc(100vw - 24px));
  max-height: min(34rem, calc(100dvh - 24px));
  margin: max(12px, 10vh) auto auto;
  padding: 0;
  overflow: hidden;
}
.palette__panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}
.palette__input {
  min-height: 56px;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line2);
  border-radius: 0;
  background: transparent;
  font-size: 17px;
}
.palette__input:focus-visible {
  outline: none;
  box-shadow: none;
}
.palette__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 6px;
}
.palette__group {
  padding: 10px 12px 4px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}
.palette__opt {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.palette__opt--active {
  background: var(--accent-soft);
}
.palette__label {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.palette__detail {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--ink3);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette__none {
  padding: 14px 12px;
  color: var(--ink3);
}
.palette__foot {
  max-width: none;
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line2);
}

/* GitHub rows: the mark sits on the text line, and a GitHub link keeps the
   link colour rather than the citation's plain text. */
.github-row .ico {
  flex: none;
  margin-right: 0.35em;
  vertical-align: -3px;
}

/* GitHub setup: the owner choice is two plain radios on one line. */
.github-owner {
  border: 0;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.github-owner legend {
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.github-owner label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.github-owner input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.github-owner span {
  white-space: nowrap;
}

/* Imports → upload: a drop zone for notes or a whole folder. */
.upload {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.upload[hidden] {
  display: none;
}
.dropzone {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--space-4) var(--space-3);
  border: 1.5px dashed var(--field-line);
  border-radius: 14px;
  background: var(--bg2);
  color: var(--ink2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dropzone.is-busy {
  cursor: progress;
  opacity: 0.7;
}
.dropzone__icon {
  color: var(--accent);
}
.dropzone__title {
  color: var(--ink);
  font-weight: 600;
}
.dropzone__hint {
  max-width: 34rem;
  color: var(--ink3);
  font-size: 0.875rem;
}
.dropzone__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}
.upload__options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.segmented {
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
}
.segmented label {
  position: relative;
  padding: 5px 12px;
  border-radius: 7px;
  color: var(--ink2);
  font-size: 0.875rem;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label:has(input:checked) {
  background: var(--accent-soft);
  color: var(--ink);
}
.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
}
.upload__project {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink3);
  font-size: 0.875rem;
}
.upload__project input {
  width: 12rem;
  max-width: 100%;
}
/* ------------------------------------------------------------- dreaming
 * The Dreaming page (dreaming.html): the settings card, the status strip and
 * the log of what the brain changed. Plain rows, no table: a change reads as a
 * sentence, with the names in bold and the refused ones muted. */

.dream-page .dream-form {
  display: grid;
  gap: 1rem;
}

.dream-row + .dream-row {
  margin-top: 0.4rem;
}

.dream-row {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.dream-switch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.dream-switch input {
  margin: 0;
}

.dream-strip {
  margin: 0;
  color: var(--ink2);
  overflow-wrap: anywhere;
}

.dream-log {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.dream-log > li {
  list-style: none;
  margin: 0;
}

.dream-item {
  padding: 0.75rem 0.9rem;
  border-radius: 0.6rem;
  background: var(--bg2);
  border: 1px solid color-mix(in oklch, var(--ink) 10%, transparent);
  min-width: 0;
}

.dream-item > div {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.dream-item__what strong {
  color: var(--ink);
  font-weight: 650;
}

.dream-item__detail,
.dream-item__meta {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  color: var(--ink3);
}

.dream-item.is-muted {
  background: transparent;
  border-style: dashed;
}

.dream-item.is-muted .dream-item__what {
  color: var(--ink3);
}

.dream-page select:disabled,
.dream-page input:disabled {
  opacity: 0.6;
}

.upload__progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink2);
  font-size: 0.875rem;
}
.upload__progress[hidden] {
  display: none;
}
.upload__progress progress {
  flex: 0 1 16rem;
  height: 6px;
  accent-color: var(--accent);
/* New workspace: the switcher's item and form, and the Account form. */
.menu__item--new {
  gap: 8px;
  color: var(--accent);
}
.menu__plus {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px dashed currentColor;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
}
.menu__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 6px;
}
.menu__form input {
  min-width: 0;
}
.menu__form .menu__note {
  grid-column: 1 / -1;
  padding: 0 2px;
}
.menu__form .menu__note:empty {
  display: none;
}
.inline-create {
  display: grid;
  gap: 6px;
  max-width: 32rem;
  margin-block: var(--space-2) var(--space-3);
}
.inline-create__row {
  display: flex;
  gap: 8px;
}
.inline-create__row input {
  flex: 1;
  min-width: 0;
}
