/* Manrope (SIL OFL 1.1, static/fonts/manrope/OFL.txt), served from here rather than Google
   Fonts: loading it from Google hands every reader's IP address to Google, which German courts
   have held unlawful without consent. A variable font: one file per subset holds every weight. */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/manrope/manrope-latin.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: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/manrope/manrope-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/manrope/manrope-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/manrope/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/manrope/manrope-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/manrope/manrope-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

:root {
  color-scheme: light dark;

  --color-bg: #f6f4f1;
  --color-bg-elevated: #ffffff;
  --color-bg-subtle: #eef1f2;
  --color-border: #e1e5e7;
  --color-text: #1b2a32;
  --color-text-muted: #5c6b72;
  --color-brand: #335c70;
  --color-brand-dark: #22404f;
  --color-accent: #ee7131;
  --color-accent-dark: #d1601f;
  /* Text and icons on the brand gradient (primary buttons, Send): white here; in the dark theme
     the gradient is light, so dark text - white on it measured 2.3:1. */
  --color-on-primary: #fff;
  /* Where that gradient ends: the darker orange, so white text keeps 4.5:1 across it. */
  --color-primary-end: var(--color-accent-dark);
  --shadow-soft: 0 1px 2px rgba(27, 42, 50, 0.06), 0 8px 24px rgba(27, 42, 50, 0.08);
  --shadow-lift: 0 2px 6px rgba(27, 42, 50, 0.1), 0 16px 40px rgba(27, 42, 50, 0.12);
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  /* Charts (the admin Usage page): two categorical slots, gridline and axis. */
  --viz-series-1: #2a78d6;
  --viz-series-2: #eb6834;
  --viz-grid: #e8ebed;
  --viz-axis: #c3c9cd;
  --viz-other: #a3adb2;
  /* A team's specialists (plan-sub-assistants §3): eight colours, kept per specialist. */
  --team-1: #2a78d6;
  --team-2: #d4572a;
  --team-3: #2b8a5f;
  --team-4: #8156c2;
  --team-5: #b83f74;
  --team-6: #9a6f06;
  --team-7: #1a8391;
  --team-8: #5f6d22;
  /* The composer's gauge (app/chat/compaction.py): how full the conversation is. */
  --gauge-ok: #2b8a5f;
  --gauge-amber: #b7791f;
  --gauge-red: #c2412d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0d161b;
    --color-bg-elevated: #16232a;
    --color-bg-subtle: #1c2b33;
    --color-border: #263640;
    --color-text: #eef2f4;
    --color-text-muted: #93a7af;
    --color-brand: #7bacc4;
    --color-brand-dark: #a9cbdc;
    --color-accent: #ff8a4c;
    --color-accent-dark: #ffab7a;
    --color-on-primary: #0d161b;
    --color-primary-end: var(--color-accent);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.45);
    --viz-series-1: #3987e5;
    --viz-series-2: #d95926;
    --viz-grid: #22323b;
    --viz-axis: #33454f;
    --viz-other: #5d6e76;
    --team-1: #3987e5;
    --team-2: #d95926;
    --team-3: #33a06f;
    --team-4: #9470d6;
    --team-5: #cc5288;
    --team-6: #b68a14;
    --team-7: #2399a8;
    --team-8: #7a8a2c;
    --gauge-ok: #4cb486;
    --gauge-amber: #e0a43a;
    --gauge-red: #ef6b55;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-brand);
}

/* Focus visible wherever the keyboard goes (plan-feedback-task-1 §10, I): a ring in the brand
   colour - 6.7:1 on the light background, 7.8:1 on the dark one. :where() keeps it at no
   specificity, so a control that draws its own ring still does; one that only says
   `outline: none` on :focus must draw something else (the composers ring their frame). */
:where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-primary-end) 100%);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  box-shadow: var(--shadow-lift);
}

.btn-secondary {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

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

.btn-block {
  width: 100%;
}

/* A small mouseover-only hint icon, for a detail that would be clutter as always-visible
   .field-hint text (e.g. next to a toggle whose effect isn't obvious from its label alone). */
.info-icon {
  display: inline-block;
  cursor: help;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* "?" help buttons and the note they open (script in base.html). The button is small and
   quiet next to a heading or a label; the note is a callout below it, in the reading size,
   for people who have never used a tool like this. Where a hover tooltip (.info-icon) suits a
   one-line aside for an admin, this is for the explanation a first-time member needs. */
.help-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.35rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.help-btn:hover,
.help-btn[aria-expanded="true"] {
  color: var(--color-bg);
  background: var(--color-brand);
  border-color: var(--color-brand);
}

.help-btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.help-panel {
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-brand);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--color-bg-subtle);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text);
}

.help-panel p,
.help-panel ul {
  margin: 0 0 0.5rem;
}

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

.help-panel ul {
  padding-left: 1.2rem;
}

.help-panel code {
  font-size: 0.85em;
}

/* A short lead paragraph under a page title telling a member what the page is. */
.page-intro {
  margin: 0 0 1rem;
  max-width: 78ch;
  font-size: 0.92rem;
  line-height: 1.5;
}

.doc-embed-toggle {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* A boxed, collapsible panel - used for "Advanced options" and the "Raw Claude output"
   section. Deliberately more contrast than a plain .usage-card: this holds actions/content
   that's secondary to the main Content editor above it, so it should read as a distinct,
   recessed area, not blend into the card it sits inside. */
.doc-expander {
  margin-top: 1.25rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.doc-expander > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--color-text);
}

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

.doc-expander > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--color-text-muted);
  transition: transform 0.15s ease;
  flex: none;
}

.doc-expander[open] > summary::before {
  transform: rotate(90deg);
}

.doc-expander > summary .field-hint {
  font-weight: 400;
}

/* A count chip on an expander's summary ("Inactive assistants 3"). The chip's own background
   is the subtle one, which is also the expander's, so it needs lifting to read as a chip. */
.doc-expander > summary .admin-tab-count {
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-weight: 600;
}

.doc-expander-body {
  padding: 0 1.1rem 1.1rem;
}

/* The workspace page's "how this works" expander: six step cards in a grid, then the example
   and the role table side by side. Structure over prose - the audience skims this once. */
.ws-guide {
  margin-top: 1rem;
}

.ws-guide-body {
  font-size: 0.88rem;
  line-height: 1.5;
}

.ws-guide-lead {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
}

.ws-guide-steps {
  list-style: none;
  counter-reset: ws-step;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.75rem;
}

.ws-guide-steps li {
  counter-increment: ws-step;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.6rem;
  row-gap: 0.35rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.ws-guide-steps li > strong::before {
  content: counter(ws-step) ". ";
  color: var(--color-brand);
}

.ws-guide-steps li > span:last-child {
  grid-column: 1 / -1;
  color: var(--color-text-muted);
}

.ws-guide-icon {
  width: 1.9rem;
  height: 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  font-size: 1rem;
  color: var(--color-brand);
}

.ws-guide-who {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  white-space: nowrap;
}

.ws-guide-columns {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.5rem;
  margin-top: 1.25rem;
}

@media (max-width: 800px) {
  .ws-guide-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ws-guide-columns h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.ws-guide-columns p {
  margin: 0.6rem 0 0;
}

.ws-guide-flow {
  margin: 0;
  padding-left: 1.3rem;
}

.ws-guide-flow li {
  margin-bottom: 0.35rem;
}

.ws-guide-flow li::marker {
  font-weight: 700;
  color: var(--color-brand);
}

.ws-guide-roles {
  border-collapse: collapse;
  width: 100%;
}

.ws-guide-roles th,
.ws-guide-roles td {
  text-align: left;
  vertical-align: top;
  padding: 0.4rem 0.6rem 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
}

.ws-guide-roles tr:last-child th,
.ws-guide-roles tr:last-child td {
  border-bottom: none;
}

.ws-guide-roles th {
  white-space: nowrap;
  padding-right: 1rem;
}

/* The assistant form's retrieval settings live in an expander at the end of the form. The
   fieldset inside keeps its layout but not its border - a box inside the expander's box would
   read as yet another level - and the nested head-start expander sits on the elevated
   background so it still stands out from the subtle one around it. */
.assistant-advanced .admin-checkbox-group {
  border: none;
  padding: 0;
}

.assistant-advanced .doc-expander {
  background: var(--color-bg-elevated);
}

/* What the chat model reads of the assistant with every message - orange once it is heavy. */
.assistant-prompt-size.is-heavy {
  color: #ea700b;
}

@media (prefers-color-scheme: dark) {
  .assistant-prompt-size.is-heavy {
    color: #fb923c;
  }
}

.doc-advanced-options .admin-inline-form {
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.doc-advanced-section {
  margin-top: 0.9rem;
  padding: 1rem 1.1rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.doc-advanced-section:first-child {
  margin-top: 0;
}

.doc-advanced-section h3 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}

.doc-async-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
}

.spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Subdued text-style action for something that's only relevant right after using the
   feature above it (e.g. dismissing a patch's scratch output once you've copied what you
   needed from it) - shouldn't compete visually with real form buttons. */
.btn-quiet {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-quiet:hover {
  color: var(--color-text);
  transform: none;
}

.doc-copy-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.md-cheatsheet-dialog {
  max-width: 520px;
  width: 90vw;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-lift);
}

.md-cheatsheet-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.md-cheatsheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.md-cheatsheet-header h2 {
  font-size: 1.05rem;
  margin: 0;
}

.md-cheatsheet-dialog .admin-table th,
.md-cheatsheet-dialog .admin-table td {
  font-size: 0.85rem;
}

/* ---------- Site header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  max-width: 1080px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--color-text);
}

.brand img {
  height: 34px;
  width: auto;
  display: block;
}

.brand-name {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--color-brand);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.header-actions a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.header-actions a:hover {
  color: var(--color-brand);
}

/* The signed-in pages' header (_app_header.html): the symbol in the corner, chips on the right,
   both on the same 2rem edge as the page content below. */
.site-header.app-header {
  max-width: none;
  margin: 0;
  padding: 0.85rem 2rem;
}

.header-actions .hdr-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2rem;
  padding: 0 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.header-actions a.hdr-chip:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.header-actions .hdr-chip.is-current {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.header-actions .hdr-chip-quiet {
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 500;
}

.header-actions .hdr-account {
  padding-left: 0.2rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.hdr-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: var(--color-brand);
  color: var(--color-on-primary, #fff);
  font-size: 0.75rem;
  font-weight: 700;
}

.header-actions {
  flex-wrap: nowrap;
}

/* ---------- Hero / home page ---------- */

.hero-wrap {
  max-width: 720px;
  margin: 3rem auto 4rem;
  padding: 0 1.5rem;
  text-align: center;
}

.hero-wrap h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0.5rem 0 0.75rem;
}

.hero-wrap p {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 2rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Auth pages (login / access) ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 45%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--color-brand) 18%, transparent), transparent 50%),
    var(--color-bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lift);
  padding: 2.5rem 2.25rem;
  text-align: center;
}

.auth-card img.symbol {
  height: 56px;
  width: auto;
  margin-bottom: 1.25rem;
}

.auth-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
}

.auth-card p.subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 1.75rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-card input[type="password"],
.auth-card input[type="text"] {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.95rem;
  text-align: center;
}

.auth-card input:focus {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}

.auth-error {
  background: color-mix(in srgb, #d1601f 12%, transparent);
  color: var(--color-accent-dark);
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.auth-footer {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.auth-footer a {
  color: var(--color-text-muted);
  text-decoration: underline;
}

/* ---------- Usage page ---------- */

.usage-page {
  /* Wide enough for the per-model table's seven columns; the table scrolls inside its own
     wrapper on narrower screens rather than pushing the page sideways. */
  max-width: none;
  margin: 2.5rem auto 4rem;
  padding: 0 2rem;
}

.usage-page h1 {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
}

.usage-page .subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0 0 2rem;
}

.usage-card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}

.usage-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.usage-progress-track {
  display: flex;
  height: 10px;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  overflow: hidden;
}

.usage-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-accent) 100%);
}

.usage-detail h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.usage-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 0;
}

.usage-stats dt {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0 0 0.2rem;
}

.usage-stats dd {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

/* ---------- Admin ---------- */

.admin-page {
  max-width: none;
  margin: 2.5rem auto 4rem;
  padding: 0 2rem;
}

.admin-nav {
  display: flex;
  gap: 1.25rem;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid var(--color-border);
  /* Seven sections don't fit a phone: the bar scrolls instead of the page. */
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.admin-nav a {
  padding: 0 0 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.admin-nav a.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.admin-page h1 {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 1.25rem;
}

.admin-page code {
  background: var(--color-bg-subtle);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.assistant-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 720px;
}

/* For forms built around a large text/code area (e.g. document content, raw output) that
   should use the page's full width instead of the readable-line-length cap above, which is
   right for short text fields but cramps a wide monitor for a multi-thousand-character box. */
.assistant-form-wide {
  max-width: none;
}

.assistant-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.assistant-form .field-hint {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.assistant-form input[type="text"],
.assistant-form select,
.assistant-form textarea {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.92rem;
  resize: vertical;
}

.assistant-form textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.assistant-form-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem !important;
}

/* A custom assistant whose base is gone (retired, no longer granted, deleted): it answers
   nothing until another base is chosen or the additions are kept on their own. */
.assistant-base-missing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, #c98a1a 14%, transparent);
  border: 1px solid color-mix(in srgb, #c98a1a 40%, transparent);
  color: #8a5c05;
  font-size: 0.88rem;
}

.assistant-base-missing[hidden] {
  display: none;
}

.assistant-base-missing p {
  margin: 0;
}

@media (prefers-color-scheme: dark) {
  .assistant-base-missing {
    color: #e5b35c;
  }
}

/* A custom assistant's own documents (app/documents/personal.py), in its dialog. */
.assistant-documents {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.assistant-documents-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.assistant-document-list {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.assistant-document-list:empty {
  display: none;
}

.assistant-document {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: 0.86rem;
}

.assistant-document-name {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 500;
}

.assistant-document-status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.assistant-document-status.is-error {
  color: #8a5c05;
}

@media (prefers-color-scheme: dark) {
  .assistant-document-status.is-error {
    color: #e5b35c;
  }
}

.assistant-document-actions {
  display: flex;
  gap: 0.3rem;
}

.assistant-document-actions button {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
}

.assistant-documents-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.modal-card-wide {
  max-width: 960px;
}

.document-viewer-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.document-viewer-bar .field-hint {
  flex: 1 1 auto;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.document-viewer-modes {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.document-viewer-mode {
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.document-viewer-mode.active {
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font-weight: 600;
}

.document-viewer-body {
  overflow-x: auto;
}

.document-viewer-source {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  line-height: 1.5;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  margin: 0;
}



.assistant-item-unavailable .assistant-btn {
  color: var(--color-text-muted);
}

.assistant-form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

.admin-page h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.admin-flash {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.admin-flash-ok {
  background: color-mix(in srgb, #2f9e58 14%, transparent);
  border: 1px solid color-mix(in srgb, #2f9e58 35%, transparent);
  color: #1f7a41;
}

.admin-flash-error {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  color: var(--color-accent-dark);
}

/* Neither success nor failure - a standing condition the reader should notice but not act on,
   e.g. "this page is talking to Stripe's sandbox". */
.admin-flash-warn {
  background: color-mix(in srgb, #c98a1a 14%, transparent);
  border: 1px solid color-mix(in srgb, #c98a1a 40%, transparent);
  color: #8a5c05;
}

@media (prefers-color-scheme: dark) {
  .admin-flash-warn {
    color: #e5b35c;
  }
}

.admin-inline-form {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.admin-inline-form input,
.admin-inline-form select {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  width: 140px;
}

.admin-inline-form input[type="file"] {
  width: auto;
  padding: 0.4rem 0.5rem;
}

.admin-inline-form select {
  width: auto;
}

.admin-hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.admin-table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  cursor: grab;
}

.admin-table-wrap.dragging {
  cursor: grabbing;
  user-select: none;
}

/* ── Page-level tabs ───────────────────────────────────────────────────────────────────
   One tab per concern on a page that would otherwise stack several unrelated tables (the
   workspace page: documents, assistants, members, tags). Same visual language as the plan
   editor's reference tabs below, but standing on the page rather than inside a card. The
   `hidden` attribute on the panels is what switches; the buttons only carry state. */

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 1.5rem 0 0;
  border-bottom: 1px solid var(--color-border);
}

.admin-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
}

.admin-tab:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

.admin-tab[aria-selected="true"] {
  color: var(--color-text);
  border-bottom-color: var(--color-brand);
}

.admin-tab:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: -2px;
}

.admin-tab-count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 0.3rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.admin-tab[aria-selected="true"] .admin-tab-count {
  color: var(--color-text);
}

.admin-tab-panel {
  padding-top: 0.25rem;
}

.admin-tab-panel > .admin-hint:first-child {
  margin-top: 0.75rem;
}

/* A panel whose content is boxed cards rather than a bare toolbar and table - the assistant
   edit page - needs room under the tab bar, since .usage-card carries no top margin of its
   own. */
.admin-tab-panel > .usage-card:first-child {
  margin-top: 1rem;
}

/* The admin Usage page's Overview: a row of figures, then charts in cards. */
.usage-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.usage-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.15rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.usage-kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.usage-kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

.usage-kpi-note {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.usage-kpis-compact {
  margin: 0.25rem 0 1rem;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.usage-kpis-compact .usage-kpi {
  box-shadow: none;
  background: var(--color-bg-subtle);
  border-color: transparent;
  padding: 0.7rem 0.85rem;
}

.usage-kpis-compact .usage-kpi-value {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

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

.usage-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.usage-chart {
  position: relative;
  width: 100%;
  margin: 0.5rem 0 0.75rem;
}

.usage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.usage-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.usage-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.usage-swatch-user { background: var(--viz-series-1); }
.usage-swatch-platform { background: var(--viz-series-2); }

/* Admin > Usage > Reconciliation: a model that recorded much less than its provider billed. */
.rec-gap {
  color: var(--gauge-red);
  font-weight: 600;
}

.rec-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.usage-table-toggle > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
}

.usage-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}

.usage-meter {
  height: 8px;
  border-radius: 4px;
  background: var(--color-bg-subtle);
  overflow: hidden;
}

.usage-meter > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--viz-series-1);
}

/* The hint and the primary action of a panel on one line, action to the right. */
.admin-tab-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-top: 0.75rem;
}

.admin-tab-toolbar .admin-hint {
  margin: 0;
  flex: 1 1 24rem;
}

/* The workspace's monthly processing budget: one line with a small fill bar in front of it,
   which is enough to see at a glance how close the cap is without a chart. */
.ws-budget {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin: 0.6rem 0 0;
}

.ws-budget-bar {
  display: inline-block;
  width: 6rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  overflow: hidden;
  vertical-align: middle;
}

.ws-budget-bar > span {
  display: block;
  height: 100%;
  background: var(--color-brand);
}

.ws-budget-exhausted .ws-budget-bar > span {
  background: var(--color-accent);
}

/* A create form boxed off from the table it feeds, so "add one" and "here are the ones you
   have" read as two things rather than a form floating under a table. */
.admin-tab-card {
  margin: 1rem 0;
}

.admin-tab-card h2 {
  margin-bottom: 0.75rem;
}

.admin-tab-card .field-hint {
  display: block;
  margin-top: 0.75rem;
}

/* Numeric cells in the plan margin breakdown: right-aligned with lining figures so the
   euro and dollar columns line up digit for digit down the calculation. */
/* ── Plan edit page ───────────────────────────────────────────────────────────────────
   Two columns: the form on the left, always in view, and reference material on the right
   in tabs. Before this the form sat below four reference panels, so editing a price meant
   scrolling past everything explaining it. */

.plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: 1.25rem;
}

.plan-head h1 {
  margin: 0;
}

.plan-head-summary {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.plan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.plan-editor {
  margin-bottom: 0;
}

/* The reference column stays put while the form is scrolled, and scrolls internally if its
   own content is taller than the viewport. */
.plan-aside {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.plan-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  flex-shrink: 0;
}

.plan-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
}

.plan-tab:hover {
  color: var(--color-text);
}

.plan-tab[aria-selected="true"] {
  color: var(--color-text);
  border-bottom-color: var(--color-brand);
  background: var(--color-bg-elevated);
}

.plan-tab:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: -2px;
}

.plan-panels {
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}

.plan-panel:focus-visible {
  outline: none;
}

.plan-panel > h2:first-child {
  margin-top: 0;
}

/* Save stays reachable from anywhere in a long form rather than only at the bottom. */
.plan-form-actions {
  position: sticky;
  bottom: -1.5rem;
  margin: 0 -1.75rem -1.5rem;
  padding: 1rem 1.75rem;
  background: var(--color-bg-elevated);
  border-top: 1px solid var(--color-border);
}

/* One column on anything narrower than a wide laptop: the two-column split needs real width
   for the form fields and the margin tables to both stay readable. Sticky is dropped with it,
   since a sticky block in a single-column flow just steals the screen. */
@media (max-width: 1180px) {
  .plan-layout {
    grid-template-columns: 1fr;
  }

  .plan-aside {
    position: static;
    max-height: none;
  }

  .plan-panels {
    overflow-y: visible;
  }
}

.admin-figure {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-row-total td {
  border-top: 2px solid var(--color-text-muted);
}

.admin-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

/* A cell carrying prose (a document's description, say). Every other cell is nowrap so
   tables scan well, but a two-sentence description in a nowrap cell drags the whole column
   out to its length. This wraps, caps the width, and clamps to two lines - the full text is
   on the title attribute and on the document's own page. */
.admin-table td.admin-cell-prose {
  white-space: normal;
  min-width: 16rem;
  max-width: 34rem;
}

/* Tags edited in place, one row each (the Tags tabs of a workspace and of the admin Library):
   the description takes what width is left, the actions sit side by side. */
.tag-table input,
.tag-table select {
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  width: 12rem;
}

.tag-table td.tag-table-wide {
  width: 100%;
}

.tag-table td.tag-table-wide input {
  width: 100%;
  min-width: 14rem;
}

.tag-table select {
  width: auto;
}

.tag-table input.tag-table-order {
  width: 4.5rem;
}

.tag-table td.tag-table-actions form {
  display: inline-block;
}

.tag-table tfoot td {
  border-bottom: 0;
  background: var(--color-bg-subtle);
}

.admin-cell-prose .admin-cell-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-clamp: 2;
}

.admin-table th {
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table th a {
  color: inherit;
  text-decoration: none;
}

.admin-table th a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.admin-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-model-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.admin-table input[type="text"],
.admin-table select {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  width: 100%;
  min-width: 120px;
}

.admin-num {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  width: 80px;
}

/* Drag-and-drop target for the document upload page. */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 2rem 1.5rem;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.upload-dropzone:hover,
.upload-dropzone:focus-visible {
  border-color: var(--color-brand);
}

.upload-dropzone.dragover {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 8%, var(--color-bg-subtle));
}

.upload-dropzone-text {
  font-weight: 600;
  margin: 0;
}

.upload-row-filename {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-row-remove-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}

.upload-row-remove-btn:hover {
  background: var(--color-border);
  color: var(--color-accent-dark);
}

.upload-row-remove-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.upload-status-ok {
  color: #1f7a41;
}

.upload-status-error {
  color: var(--color-accent-dark);
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
}

.admin-new-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.admin-new-form input,
.admin-new-form select {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.88rem;
}

.admin-status {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--color-bg-muted, rgba(127, 127, 127, 0.15));
  color: var(--color-text-muted);
}

.admin-status-ready {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.admin-status-processing,
.admin-status-pending {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

.admin-status-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* A document whose status is "error" is shown as "Check": the pipeline stopped somewhere, but
   what did come through is usually usable and often only a part needs redoing - orange, an
   invitation to look, rather than the red a kill switch gets. */
.admin-status-check {
  background: rgba(249, 115, 22, 0.16);
  color: #ea700b;
}

@media (prefers-color-scheme: dark) {
  .admin-status-check {
    color: #fb923c;
  }
}

.admin-row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.admin-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.admin-checkbox-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-checkbox-group legend {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0 0.3rem;
}

.admin-checkbox-group .field-hint {
  display: block;
  font-weight: 400;
  margin-top: 0.15rem;
}

.doc-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.doc-group-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--color-bg-elevated);
}

.doc-group-meta-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.doc-group-name-input {
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
}

.doc-group-priority-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.doc-group-priority-input {
  width: 4rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
}

.doc-group-meta-form textarea {
  font-size: 0.8rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  resize: vertical;
  font-family: inherit;
}

.doc-group-box-actions {
  display: flex;
  gap: 0.4rem;
}

.admin-row-unattached {
  opacity: 0.55;
}

.doc-groups-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.7rem;
  max-width: 320px;
}

.doc-group-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 400;
  white-space: nowrap;
}

.admin-version-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.admin-version-tabs a {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.85rem;
}

.admin-version-tabs a.active {
  background: var(--color-accent, var(--color-text));
  color: var(--color-bg);
  border-color: transparent;
}

.markdown-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  max-height: 480px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.55;
}

.markdown-preview :first-child {
  margin-top: 0;
}

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

.chat-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  position: relative;
}

.sidebar {
  /* Dragged by its right edge (#sidebar-resize, app.js), 220-480px. */
  width: var(--sidebar-width, 270px);
  flex-shrink: 0;
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1rem;
  gap: 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, padding 0.2s ease, transform 0.2s ease;
}

@media (min-width: 769px) {
  .chat-layout.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right: none;
  }

  /* The sidebar's handle: no width of its own, a strip over the border to grab. */
  .sidebar-resize {
    flex: 0 0 0;
    position: relative;
    z-index: 3;
    touch-action: none;
  }

  .sidebar-resize::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    width: 8px;
    cursor: col-resize;
  }

  .sidebar-resize:hover::after,
  .sidebar-resize:focus-visible::after,
  .sidebar-resizing .sidebar-resize::after {
    background: color-mix(in srgb, var(--color-brand) 35%, transparent);
  }

  .sidebar-resize:focus-visible {
    outline: none;
  }

  .sidebar-resizing {
    cursor: col-resize;
    user-select: none;
  }

  /* No easing while the hand moves it. */
  .sidebar-resizing .sidebar {
    transition: none;
  }

  .chat-layout.sidebar-collapsed .sidebar-resize,
  .chat-try .sidebar-resize {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar-resize {
    display: none;
  }
}

/* The Try tab of an assistant's page (app.chat.trying): the chat in a frame, one assistant,
   its test chats - the sidebar keeps only their history. */
.chat-try .sidebar-fold,
.chat-try .sidebar-account,
.chat-try .sidebar-footer,
.chat-try .sidebar-legal,
.chat-try .sidebar-brand,
.chat-try .history-search,
.chat-try .history-search-note {
  display: none !important;
}

.chat-try-note {
  margin: 0;
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Chat top bar (sidebar toggle) ---------- */

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem 0;
}

.chat-topbar-title {
  display: none;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--color-brand);
  letter-spacing: 0.02em;
}

.model-select {
  margin-left: auto;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  max-width: 220px;
  min-width: 0; /* shrinks on a phone instead of pushing the topbar past the screen */
}

.sidebar-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  cursor: pointer;
  padding: 0;
}

.sidebar-toggle:hover {
  border-color: var(--color-brand);
}

.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-text);
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    /* Not 100vh: on a phone that is the height with the browser's bars hidden, so the foot of
       the sidebar - account, legal links, language - sat underneath them. --app-height is the
       visible height (app.js updateAppHeight). */
    height: var(--app-height, 100dvh);
    padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
    width: min(82vw, 300px);
    z-index: 40;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lift);
  }

  .chat-layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .chat-layout.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(13, 22, 27, 0.45);
    z-index: 30;
  }

  .chat-topbar {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
  }

  .conversation-delete-btn,
  .assistant-item-icon-btn {
    opacity: 1;
  }

  .chat-topbar-title {
    display: inline;
  }

  .messages,
  .chat-form {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.25rem 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}

.sidebar-brand img {
  height: 26px;
  width: auto;
}

.sidebar-brand span {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-brand);
  letter-spacing: 0.02em;
}

/* Like .field-hint, but for a setting that is quietly not doing what it looks like it is doing
   - a ticked assistant that is switched off, say. Warm rather than red: nothing is broken. */
.admin-warn-hint {
  font-size: 0.78rem;
  font-weight: 600;
  color: #a8690c;
}

@media (prefers-color-scheme: dark) {
  .admin-warn-hint {
    color: #e5b35c;
  }
}

/* ---------- Sidebar account block ---------- */

/* The foot of the sidebar: who you are, what plan you're on, and the way to a better one, sat
   directly above the icon row. The rule above it closes off the scrolling history list, which
   otherwise runs straight into the account details. The gap inside separates "information" from
   "action" - they are not the same thing and shouldn't read as one control. */
.sidebar-account {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.9rem 0.25rem 0;
  border-top: 1px solid var(--color-border);
  /* The history list above takes the slack, so this must not be squeezed when it is long. */
  flex-shrink: 0;
}

/* Email on one line, the plan chip on its own line beneath it - an address of any length gets
   the full width rather than being squeezed by the chip, and the chip lines up under it. */
.sidebar-account-id {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  min-width: 0;
}

/* The email takes the full width. min-width:0 is what actually lets it truncate -
   a flex item's default min-width is auto, which refuses to shrink below its content and would
   overflow the 270px sidebar instead. */
.sidebar-account-email {
  align-self: stretch;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text);
}

.sidebar-plan {
  flex: none;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  max-width: 9ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A paid plan is worth showing as an earned state rather than a neutral label. */
.sidebar-plan-paid {
  background: color-mix(in srgb, var(--color-brand) 14%, transparent);
  border-color: color-mix(in srgb, var(--color-brand) 35%, transparent);
  color: var(--color-brand);
}

.sidebar-plan-admin {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--color-accent) 32%, transparent);
  color: var(--color-accent-dark);
}

/* The quiet form, for someone who already pays: still findable, not still selling. */
.sidebar-upgrade {
  display: block;
  padding: 0.42rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: border-color 0.12s ease, color 0.12s ease, box-shadow 0.15s ease,
    transform 0.15s ease;
}

.sidebar-upgrade:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

/* The loud form, for someone with no plan - the one thing in the sidebar carrying the brand
   gradient, so it reads as the primary action on the page without a second element competing. */
.sidebar-upgrade-strong {
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-primary-end) 100%);
  border-color: transparent;
  color: var(--color-on-primary);
  box-shadow: var(--shadow-soft);
}

.sidebar-upgrade-strong:hover {
  color: #fff;
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}

.sidebar-upgrade:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.sidebar-section h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.sidebar-history {
  flex: 1;
  /* Never squeezed away by long assistant lists: past this the whole sidebar scrolls. */
  min-height: 13rem;
  display: flex;
  flex-direction: column;
}

/* "Assistants" and "My Assistants" fold away (app.js setFolded): the header is the button,
   its chevron turning down while open; folded, it names the assistant in use. */
.sidebar-history-header h2 {
  min-width: 0;
}

/* Scoped to the header so it outranks `.sidebar-history-header button` (the "+ New" look). */
.sidebar-history-header .sidebar-fold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.15rem 0.2rem 0.15rem 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sidebar-history-header .sidebar-fold-toggle:hover {
  background: none;
  color: var(--color-brand);
}

.sidebar-fold-toggle .icon {
  width: 0.95rem;
  height: 0.95rem;
  stroke-width: 2.2;
  transition: transform 0.15s ease;
}

.sidebar-fold:not(.is-folded) .sidebar-fold-toggle .icon {
  transform: rotate(90deg);
}

.sidebar-fold-current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
  color: var(--color-brand);
}

.sidebar-fold:not(.is-folded) .sidebar-fold-current {
  display: none;
}

.sidebar-fold.is-folded h2 {
  margin-bottom: 0;
}

.sidebar-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-history-header button,
.sidebar-history-actions a {
  border: none;
  background: none;
  color: var(--color-brand);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.sidebar-history-header button:hover,
.sidebar-history-actions a:hover {
  background: var(--color-border);
}

.sidebar-history-actions a,
a.assistant-item-icon-btn,
a.assistant-btn {
  text-decoration: none;
}

.sidebar-history ul {
  overflow-y: auto;
}

/* Stroke icons (Lucide-style geometry): sized by font-size, coloured by currentColor, so
   an icon inherits whatever the surrounding link or button already is. */
.icon {
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* The footer nav is icons only - the label lives in the hover tooltip below, with
   aria-label carrying it for anyone not using a pointer. */
.sidebar-footer {
  display: flex;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.sidebar-footer-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-footer-link .icon {
  width: 1.15rem;
  height: 1.15rem;
}

.sidebar-footer-link:hover,
.sidebar-footer-link:focus-visible {
  color: var(--color-brand);
  background: var(--color-bg-subtle);
}

/* Tooltip above the icon. pointer-events stay off so it can never sit between the
   cursor and the link it describes. */
.sidebar-footer-link::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%) translateY(0.15rem);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}

.sidebar-footer-link:hover::after,
.sidebar-footer-link:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* The legal links, below the icon row. Small and muted, but readable text with no hover
   requirement - see the comment in chat.html. */
.sidebar-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  margin-top: 0.45rem;
  font-size: 0.72rem;
}

.sidebar-legal a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.sidebar-legal a:hover {
  color: var(--color-brand);
  text-decoration: underline;
}

.assistant-btn,
.conversation-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.12s ease;
}

.assistant-btn:hover,
.conversation-btn:hover {
  background: var(--color-bg-elevated);
}

.assistant-btn.active {
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-soft);
  font-weight: 700;
  color: var(--color-brand);
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.conversation-item .conversation-btn {
  flex: 1;
  min-width: 0;
}

.conversation-delete-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.conversation-item:hover .conversation-delete-btn,
.conversation-delete-btn:focus-visible {
  opacity: 1;
}

.conversation-delete-btn:hover {
  background: var(--color-border);
  color: var(--color-accent-dark);
}

.assistant-item {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.assistant-item .assistant-btn {
  flex: 1;
  min-width: 0;
}

.assistant-item-icon-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.assistant-item:hover .assistant-item-icon-btn,
.assistant-item-icon-btn:focus-visible {
  opacity: 1;
}

.assistant-item-icon-btn:hover {
  background: var(--color-border);
  color: var(--color-accent-dark);
}

/* ---------- The sidebar's assistants (app/chat/sidebar.py) ---------- */

/* Single lines, tight: the description is the row's tooltip. */
.sidebar-assistants .assistant-btn {
  padding: 0.3rem 0.55rem;
  font-size: 0.88rem;
}

.sidebar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-bottom: 0.5rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.sidebar-history-header .sidebar-icon-btn {
  padding: 0;
}

.sidebar-icon-btn:hover,
.sidebar-icon-btn[aria-expanded="true"] {
  background: var(--color-border);
  color: var(--color-brand);
}

.sidebar-icon-btn .icon {
  width: 1rem;
  height: 1rem;
}

.sidebar-fold.is-folded .sidebar-icon-btn {
  margin-bottom: 0;
}

.assistant-filter-row[hidden] {
  display: none;
}

.assistant-filter {
  margin-top: 0;
}

.assistant-group {
  margin-top: 0.45rem;
}

.assistant-group[hidden] {
  display: none;
}

.assistant-group-head {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  min-height: 24px;
}

.assistant-group-toggle {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.2rem 0.1rem 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.assistant-group-toggle:hover {
  color: var(--color-brand);
}

.assistant-group-toggle .icon {
  width: 0.85rem;
  height: 0.85rem;
  stroke-width: 2.2;
  transition: transform 0.15s ease;
}

.assistant-group:not(.is-folded) .assistant-group-toggle .icon,
.assistant-groups.is-filtering .assistant-group-toggle .icon {
  transform: rotate(90deg);
}

.assistant-group-label {
  flex-shrink: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-group-current {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--color-brand);
}

.assistant-group-current::before {
  content: "· ";
  color: var(--color-text-muted);
}

.assistant-group-current:empty,
.assistant-group:not(.is-folded) .assistant-group-current,
.assistant-groups.is-filtering .assistant-group-current {
  display: none;
}

.assistant-group-action {
  flex-shrink: 0;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  color: var(--color-brand);
  font-weight: 700;
  font-size: 0.78rem;
  text-decoration: none;
}

.assistant-group-action:hover {
  background: var(--color-border);
}

.assistant-group-head:hover .assistant-item-icon-btn,
.assistant-group-head .assistant-item-icon-btn[aria-expanded="true"],
.assistant-item .assistant-item-icon-btn[aria-expanded="true"] {
  opacity: 1;
}

.assistant-group-head[draggable="true"] {
  cursor: grab;
}

.assistant-group-list[hidden],
.assistant-entry[hidden] {
  display: none;
}

.assistant-group-empty {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.assistant-groups.is-filtering .assistant-group-empty {
  display: none;
}

.assistant-entry.is-dragging,
.assistant-group.is-dragging {
  opacity: 0.4;
}

/* Where a dragged assistant or group lands. */
.assistant-drop-line {
  height: 2px;
  margin: 1px 0.3rem;
  border-radius: 2px;
  background: var(--color-brand);
  list-style: none;
}

.assistant-group-head .assistant-drop-line {
  flex: 1;
  align-self: flex-end;
}

.assistant-menu {
  position: fixed;
  z-index: 70;
  min-width: 11rem;
  padding: 0.3rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
}

.assistant-menu[hidden] {
  display: none;
}

.assistant-menu-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.assistant-menu-item:hover,
.assistant-menu-item:focus-visible {
  background: var(--color-bg-subtle);
  outline: none;
}

.assistant-menu-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--color-brand);
}

.assistant-menu-item[aria-disabled="true"] {
  color: var(--color-text-muted);
  opacity: 0.55;
  cursor: default;
}

/* ---------- Assistant modal ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 22, 27, 0.5);
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lift);
  padding: 1.75rem;
}

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

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
}

.modal-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--color-border);
}

.deleted-assistant-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.deleted-assistant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.deleted-assistant-name {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deleted-assistant-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.deleted-assistant-empty {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin: 1rem 0 0;
}

/* ---------- Tips modal ---------- */

.tips-modal-card {
  max-width: 560px;
}

.tips-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tips-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}

.tips-section p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

.btn-danger {
  color: var(--color-accent-dark);
  border-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg);
  /* One column width shared by the message list and the composer, so they always line up.
     The percentage resolves against this pane rather than the viewport, so collapsing the
     sidebar widens the column too. Floor keeps it from shrinking below the old fixed 820px;
     ceiling stops a wide monitor from stretching it edge to edge. */
  --chat-column: clamp(820px, 72%, 1200px);
  /* Anchors .chat-dropzone and .chat-panel, both of which cover the conversation pane. */
  position: relative;
}

/* An in-place page - Usage, today - filling the conversation pane while leaving the sidebar
   alone, which is the whole reason it isn't a navigation. Opaque, unlike the drag overlay:
   this one is being read, so the thread underneath would only compete with it. */
.chat-panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.chat-panel[hidden] {
  display: none;
}

.chat-panel-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 0.75rem 0;
}

.chat-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.chat-panel-close:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.chat-panel-body {
  flex: 1;
  overflow-y: auto;
}

/* The report already spaces itself for a standalone page; inside the panel the close bar
   supplies the top margin. */
.usage-panel-page {
  margin-top: 0.5rem;
}

.chat-dropzone {
  position: absolute;
  inset: 0.75rem;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-brand);
  border-radius: var(--radius-xl);
  /* Translucent rather than opaque so the conversation stays visible underneath - a drag is a
     transient state, and blanking the thread makes it feel like a navigation. color-mix against
     transparent keeps it theme-correct without a second dark-mode rule. */
  background: color-mix(in srgb, var(--color-brand) 14%, transparent);
  backdrop-filter: blur(2px);
  /* The overlay sits above the messages, so let drag events through to .chat-main - otherwise
     entering it reads as leaving the pane and the overlay flickers. */
  pointer-events: none;
}

/* A class selector outranks the UA stylesheet's [hidden] { display: none }, so the display
   above would keep the overlay on screen permanently without this. */
.chat-dropzone[hidden] {
  display: none;
}

/* A solid panel rather than bare text: the label sits over whatever the conversation happens to
   contain, and a blurred backdrop alone doesn't guarantee it stays readable. */
.chat-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.9rem;
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lift);
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-brand);
}

.chat-dropzone-icon {
  font-size: 2rem;
  display: inline-flex;
  color: inherit;
}

.chat-dropzone-full {
  border-color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-text-muted) 8%, var(--color-bg));
}

.chat-dropzone-full .chat-dropzone-inner {
  color: var(--color-text-muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  /* The containing block of everything positioned inside a message - KaTeX's hidden MathML
     copy on every formula card above all. Without it those are placed against .chat-main at
     their spot in the unscrolled conversation and stretch the page far below the window. */
  position: relative;
  padding: 2rem 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: var(--chat-column);
  width: 100%;
  margin: 0 auto;
}

.message {
  /* Bubbles stay capped for readable line length even when the column is wider - the extra
     room goes to tables, code blocks and the composer, not to 200-character prose lines. */
  max-width: min(100%, 82ch);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-lg);
  line-height: 1.55;
  font-size: 0.96rem;
}

.message-user {
  align-self: flex-end;
  /* Never the full width, even on a phone: the indent is what says "you" at a glance. */
  max-width: min(88%, 82ch);
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message-assistant {
  align-self: flex-start;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 6px;
}

.message-content p:first-child {
  margin-top: 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* The row under a reply (app.js attachFeedbackUI): actions as icons on the left, what the
   reply is - sources, model, cost - on the right. The two halves wrap as wholes. */
.message-feedback {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.5rem;
  margin-left: -0.4rem; /* the icons' own padding lines their strokes up with the text */
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  margin-left: auto;
  min-width: 0;
}

.message-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.message-action[hidden] {
  display: none;
}

.message-action:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.message-action.active {
  color: var(--color-brand);
}

/* A thumb given is filled in, so the choice reads without a hover. */
.message-action.active .icon {
  fill: color-mix(in srgb, var(--color-brand) 18%, transparent);
}

/* In the user's own bubble (a pinned calculation's download) the icons take its white. */
.message-user .message-action {
  color: rgba(255, 255, 255, 0.8);
}

.message-user .message-action:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.feedback-comment-wrap {
  display: none;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.3rem;
}

.feedback-comment-wrap.open {
  display: flex;
}

.feedback-comment-input {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: inherit;
}

.feedback-comment-wrap .btn {
  align-self: flex-start;
}

/* Which model wrote the reply. Sits in the feedback row as a quiet label, not a control -
   no border or background, so it reads as metadata next to the buttons. */
.message-model {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: default;
}

/* "Auto: Sonnet 5.5" on a reply whose model Auto chose (app.js attachAutoChip). */
.message-auto {
  margin-bottom: 0.4rem;
}

.message-auto-chip {
  font-family: inherit;
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}

.message-auto-chip:hover,
.message-auto-chip[aria-expanded="true"] {
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.message-auto-info {
  margin-top: 0.35rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.message-auto-info p {
  margin: 0 0 0.25rem;
}

.message-auto-info p:last-child {
  margin-bottom: 0;
}

.message-auto-note {
  font-style: italic;
}

/* Sources as a small pill - book, word, count - since it is the one thing in the row worth
   opening on most replies. The admin's cost button shares the look. */
.message-sources-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--color-border);
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--color-text-muted);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.message-sources-toggle .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.message-sources-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.message-sources-toggle:hover,
.message-sources-toggle[aria-expanded="true"] {
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.message-sources-panel {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  margin: 0.3rem 0 0;
  padding: 0.5rem 0.7rem;
  list-style: none;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.message-sources-panel.open {
  display: flex;
}

.message-sources-panel li {
  word-break: break-word;
}

/* An admin's cost of a reply (app.js attachCostUI): the "$0.0123" button in the reply's row and
   the usage rows behind it, as on Admin > Usage. */
.message-cost-btn {
  font-variant-numeric: tabular-nums;
}

.message-cost-panel {
  width: 100%;
  margin: 0.3rem 0 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.message-cost-panel[hidden] {
  display: none;
}

.message-cost-total {
  margin: 0 0 0.4rem;
  color: var(--color-text);
}

.message-cost-table-wrap {
  overflow-x: auto;
}

.message-cost-table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.message-cost-table th,
.message-cost-table td {
  padding: 0.2rem 0.5rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.message-cost-table th {
  font-weight: 600;
  color: var(--color-text);
}

.message-cost-table .num {
  text-align: right;
}

.message-cost-note {
  display: block;
  font-size: 0.7rem;
  opacity: 0.85;
}

.message-sources-links {
  margin: 0.15rem 0 0.1rem;
  padding-left: 1.1rem;
  list-style: disc;
}

.message-sources-links a {
  color: var(--color-brand);
}

.message-thinking {
  margin-bottom: 0.5rem;
}

.message-thinking-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.message-thinking-toggle:hover {
  color: var(--color-brand);
}

/* Done, the dots give way to a chevron: the line opens the details. */
.message-thinking-toggle:not(.thinking-active) .thinking-dots {
  display: none;
}

.message-thinking-toggle:not(.thinking-active)::after {
  content: "";
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.message-thinking-toggle[aria-expanded="true"]:not(.thinking-active)::after {
  transform: rotate(45deg);
}

.message-thinking-toggle:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}

.thinking-dots {
  display: inline-flex;
  gap: 0.2rem;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
}

.thinking-active .thinking-dots span {
  animation: thinking-bounce 1.1s ease-in-out infinite;
}

.thinking-active .thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-active .thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes thinking-bounce {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.thinking-label {
  font-style: italic;
}

.message-thinking-panel {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.3rem 0 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.message-thinking-panel.open {
  display: flex;
}

.thinking-line {
  word-break: break-word;
}

/* The clock beside the stage ("Thinking · 0:42"): figures that don't jump as they change. */
.thinking-clock {
  font-variant-numeric: tabular-nums;
}

.thinking-note {
  margin: 0.15rem 0 0 0.3rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.thinking-note[hidden] {
  display: none;
}

/* The model's thinking: its own words, so set apart - muted, italic, labelled. */
.thinking-thought {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 0.55rem;
  border-left: 2px solid var(--color-border);
}

.thinking-thought-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.thinking-thought-text {
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 18rem;
  overflow-y: auto;
}

.thinking-narration {
  color: var(--color-text);
}

.message-download-select {
  margin-left: auto;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.message-download-select:hover {
  color: var(--color-text);
  background: var(--color-border);
  border-color: var(--color-border);
}

/* An icon with a <select> lying invisibly over it (app.js iconSelect, the topbar's download):
   the icon is what is seen, the browser's own list - a sheet on a phone - what opens. */
.icon-select {
  position: relative;
}

.icon-select select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* iOS zooms into any control under 16px when it opens */
}

.icon-select:focus-within {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 2rem 1.25rem;
  max-width: var(--chat-column);
  width: 100%;
  margin: 0 auto;
  position: relative; /* anchors .chat-jump just above it */
}

/* The empty chat (app.js syncEmptyChat): the assistant's name and description, then from 721px
   the composer in the middle under them, as the chat apps people know have it. The first
   message moves it to the foot; on a phone it stays there, where the keyboard opens. */
.chat-welcome {
  max-width: 40rem;
  margin: 12vh auto 0;
  text-align: center;
}

.chat-welcome h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.chat-welcome p {
  margin: 0.5rem 0 0;
  color: var(--color-text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 721px) {
  /* Both share the height: the intro sits at the foot of the upper part, the composer at the
     top of the lower one, a little above the middle. */
  .chat-main.chat-empty .messages {
    flex: 1 1 0;
    padding-bottom: 1.5rem;
  }

  .chat-main.chat-empty .messages > :first-child {
    margin-top: auto;
  }

  .chat-main.chat-empty .chat-form {
    flex: 1.2 1 0;
  }

  .chat-main.chat-empty .chat-welcome,
  .chat-main.chat-empty .best-match-intro {
    margin: 0 auto;
  }

  .chat-main.chat-empty .best-match-intro {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
  }

  .chat-main.chat-empty .best-match-intro h2 {
    font-size: 1.6rem;
    font-weight: 650;
  }

  .chat-main.chat-empty .team-intro {
    margin: 0.25rem auto 0;
  }
}

/* "Jump to the latest message" (app.js updateJump): floats over the foot of the conversation,
   centred on the column. */
.chat-jump {
  position: absolute;
  bottom: calc(100% + 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font-size: 1.1rem;
  box-shadow: var(--shadow-lift);
  cursor: pointer;
}

.chat-jump:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.chat-jump[hidden] {
  display: none;
}

/* Queued files sit inside the composer, above the text they go with. */
.chat-composer .chat-attachment-chip {
  margin: 0;
  padding: 0.6rem 0.75rem 0;
}

/* The composer: one box, the text on top across its full width, the tools and Send below. */
.chat-composer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.chat-composer:focus-within {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-soft), 0 0 0 3px color-mix(in srgb, var(--color-brand) 30%, transparent);
}

.chat-composer-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem 0.5rem;
}

.chat-composer-tools {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.chat-composer-tools .chat-attach-btn {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.chat-composer-tools .chat-attach-btn:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

/* The tips are help, not a tool: set apart at the end of the row. */
.chat-composer-tools #chat-tips-btn {
  margin-left: auto;
}

.chat-form .chat-send-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-primary-end) 100%);
  color: var(--color-on-primary);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-form .chat-send-btn .icon {
  stroke-width: 2.2;
}

.chat-form .chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.chat-form .chat-send-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Nothing typed yet: Send stays where it is, but quietly. */
.chat-composer:has(#chat-input:placeholder-shown) #chat-send-btn {
  opacity: 0.45;
  box-shadow: none;
}

.chat-form .chat-send-btn[hidden] {
  display: none;
}

/* Holds one .chat-attachment-item per pending file - wraps rather than scrolls, since a
   message can carry several. */
.chat-attachment-chip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.chat-attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.chat-attachment-item > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment-item button {
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
}

.chat-attachment-item button:hover {
  color: inherit;
}

/* Files Claude generated in the code-execution sandbox, offered as downloads under the reply. */
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.message-file {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  max-width: 100%;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-soft);
  font-size: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.message-file:hover {
  border-color: var(--color-brand);
}

.message-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.message-file-meta {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}


/* The box draws the border; the text field is bare inside it. */
.chat-composer textarea {
  display: block;
  width: 100%;
  resize: none;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0.8rem 1rem 0.35rem;
  min-height: 2.9rem;
  border: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: transparent;
  color: inherit;
  max-height: 240px;
  overflow-y: auto;
  box-sizing: border-box;
  transition: height 0.1s ease;
}

.chat-composer textarea:focus {
  outline: none;
}

.chat-composer textarea:disabled {
  cursor: progress;
}

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

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  padding: 1.5rem 1.25rem 2rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.site-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
  color: var(--color-brand);
}

/* The language switcher (templates/_language_switcher.html): inline next to the legal
   links, in the site footer and at the foot of the chat sidebar. The current language is a
   plain span, the others links; a thin separator between them. */
.lang-switcher {
  display: inline-flex;
  gap: 0.5rem;
  align-items: baseline;
}

.lang-switcher > * + *::before {
  content: "·";
  margin-right: 0.5rem;
  color: var(--color-text-muted);
}

.lang-switcher .lang-current {
  color: var(--color-text);
  font-weight: 600;
}

.sidebar-legal .lang-switcher {
  flex-basis: 100%;
  margin-top: 0.15rem;
}

/* ---------- Legal pages (terms / privacy / imprint) ---------- */

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.legal-back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.88rem;
}

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

.legal-nav {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
}

.legal-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.legal-nav a:hover {
  color: var(--color-brand);
}

.legal-page h1 {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
}

.legal-page h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2rem 0 0.6rem;
}

.legal-page p,
.legal-page li {
  line-height: 1.65;
  color: var(--color-text);
}

.legal-page ul {
  padding-left: 1.4rem;
  margin: 0.5rem 0 1rem;
}

.legal-page a {
  color: var(--color-brand);
}

.legal-meta {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin: 0 0 1.75rem;
}

/* Shown when a non-English reader is being served the English legal text, because no
   translation of that document exists yet - see app/legal/documents.py. */
.legal-untranslated {
  margin: 0 0 1.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.legal-disclaimer-note {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* ---------- Legal acceptance gate ---------- */

.auth-card--wide {
  max-width: 540px;
  text-align: left;
}

.auth-card--wide h1,
.auth-card--wide p.subtitle {
  text-align: center;
}

.legal-accept-box {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.legal-accept-box strong {
  display: block;
  margin-bottom: 0.4rem;
}

.legal-accept-box p {
  margin: 0;
  color: var(--color-text-muted);
  line-height: 1.55;
}

.legal-agree-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  cursor: pointer;
}

.legal-agree-row input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.legal-agree-row a {
  color: var(--color-brand);
}

/* Stop button - replaces Send in the same spot while a reply is generating, so the two never
   both apply. Dark rather than the brand gradient: it ends something. */
.chat-form .chat-stop-btn {
  background: var(--color-text);
  color: var(--color-bg);
}

/* A filled square: the universally understood "stop", and it needs no icon font. */
.chat-stop-icon {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: currentColor;
}

/* A class selector outranks the UA stylesheet's [hidden], same as .chat-dropzone above. */
.chat-stop-btn[hidden] {
  display: none;
}

.message-interrupted {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Totals row of the per-model usage table - separated from the rows it sums. */
.usage-model-table .usage-total-row td {
  border-top: 2px solid var(--color-border);
}


/* Sits under the allowance bar on /usage - the button plus its one line of explanation. */
/* Buttons on one row, their explanations beneath. Previously the note was a flex sibling of the
   buttons, so it wrapped mid-sentence and sat vertically centred against them. */
.usage-actions {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--color-border);
}

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

.usage-actions-notes {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

/* Bought credit, shown flush right so the gap to its left is the allowance still unspent.
   Deliberately a different hue from the allowance fill rather than a lighter shade of it: the
   two are different kinds of money, one that resets and one that doesn't. */
.usage-progress-topup {
  margin-left: auto;
  height: 100%;
  border-radius: 999px;
  background: repeating-linear-gradient(
    -45deg,
    var(--color-accent) 0 4px,
    color-mix(in srgb, var(--color-accent) 65%, transparent) 4px 8px
  );
}

.usage-legend {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.usage-legend li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.usage-swatch {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  transform: translateY(0.05rem);
}

.usage-swatch-plan {
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-accent) 100%);
}

.usage-swatch-topup {
  background: repeating-linear-gradient(
    -45deg,
    var(--color-accent) 0 3px,
    color-mix(in srgb, var(--color-accent) 65%, transparent) 3px 6px
  );
}

/* ---------- Public pricing page (/plans) ---------- */

.pricing-page {
  /* Wider than .usage-page: three plan cards need to sit side by side before they stack. */
  max-width: 1140px;
  margin: 2.5rem auto 4rem;
  padding: 0 1.5rem;
}

.pricing-page h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.pricing-page .subtitle {
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 2rem;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}

.pricing-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem 1.6rem 1.6rem;
}

/* The plan the reader is already on. Marked rather than hidden, so the page still reads as a
   full price list and they can see what the alternatives cost. */
.pricing-card-current {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-lift);
}

.pricing-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pricing-card-head h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.pricing-badge {
  flex: none;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-brand) 15%, transparent);
  color: var(--color-brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pricing-price {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0;
}

.pricing-amount {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.pricing-per {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.pricing-alt {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0.3rem 0 0;
}

.pricing-blurb {
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 1rem 0 0;
}

.pricing-features {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.pricing-features li {
  padding-left: 1.4rem;
  position: relative;
}

.pricing-features li::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.5em;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--color-brand);
}

/* Pushed to the bottom so the buttons line up across cards of different heights. */
.pricing-actions {
  margin-top: auto;
  padding-top: 1.5rem;
}

.pricing-second-action {
  margin-top: 0.5rem;
}

/* The order summary under a buy button (plans/plan-sellable.md D9). */
.order-summary { margin-top: 0.75rem; font-size: 0.85em; }
.order-summary p { margin: 0.3rem 0; }

.pricing-footnote {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 1.75rem 0 0;
}

/* Personal | For companies on /plans (plans/plan-organizations.md §6.1). */
.pricing-tabs {
  margin: 1.5rem 0 1.25rem;
}

.pricing-intro {
  max-width: 46rem;
  line-height: 1.6;
  margin: 0 0 1.25rem;
}

.company-buy {
  display: grid;
  gap: 0.75rem;
}

.company-buy label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.company-buy input[type="text"],
.company-buy input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-weight: 400;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
}

.company-buy-cadence {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  font-size: 0.9rem;
}

.company-buy-cadence legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.3rem;
}

.company-buy-cadence label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 400;
}

.company-buy-total {
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text-muted);
  min-height: 1.4em;
}

/* The terms box above "Continue to payment" (and Resubscribe): a checkbox row, not the
   stacked label of the fields above it. */
.company-buy label.company-buy-accept {
  display: flex;
  font-weight: 400;
  font-size: 0.85rem;
  margin-bottom: 0;
}

/* Several one-button forms sitting side by side in a table cell. The forms themselves are
   display:contents so they don't each become a block and stack the buttons vertically. */
.admin-row-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-row-actions form {
  display: contents;
}

/* For a number that only ever holds two or three characters - a sort order, a currency code. */
.admin-num-tiny {
  width: 58px;
  text-transform: uppercase;
}

.admin-nowrap {
  white-space: nowrap;
}

/* ---------- Top-up packs (/plans) ---------- */

/* Visually subordinate to the plan cards on purpose: a top-up is what you reach for when the
   subscription you already have runs short, not an alternative to buying one. Smaller cards, no
   shadow, a primary button nowhere in sight. */
.topup-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.topup-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}

.topup-intro {
  color: var(--color-text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0 0 1.25rem;
}

.topup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.topup-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem 1.2rem;
}

.topup-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.topup-credits {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.topup-credits span {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--color-text-muted);
}

.topup-blurb {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin: 0;
}

/* Pushed to the bottom so prices and buttons line up across cards of different heights. */
.topup-price {
  margin: auto 0 0.7rem;
  padding-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}


/* A plan that is cancelled but still running. Marked in the accent rather than the brand: it is
   a state the reader should notice, not one to celebrate, and it is temporary. */
.pricing-badge-ending {
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  color: var(--color-accent-dark);
}

.pricing-ending {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}

/* Document tags
   ------------------------------------------------------------------
   A fixed palette rather than a free colour per tag, so a library of chips stays coherent and
   nothing can be styled into illegibility. Each colour is one hue defined twice - a light tint
   with dark text, and the inverse under a dark scheme - which keeps contrast comfortable in
   both without needing a second class per theme. */
.tag-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
  background: var(--tag-bg, #e6eaec);
  color: var(--tag-fg, #35464f);
  border-color: var(--tag-border, #d3dade);
}

.tag-chip-slate  { --tag-bg: #e6eaec; --tag-fg: #35464f; --tag-border: #d3dade; }
.tag-chip-blue   { --tag-bg: #dce9f4; --tag-fg: #1f4c6e; --tag-border: #c3daea; }
.tag-chip-teal   { --tag-bg: #d7ecea; --tag-fg: #1c5551; --tag-border: #bcdedb; }
.tag-chip-green  { --tag-bg: #ddeddc; --tag-fg: #2a5429; --tag-border: #c3e0c2; }
.tag-chip-amber  { --tag-bg: #f8e8cd; --tag-fg: #6b4711; --tag-border: #eed7b0; }
.tag-chip-red    { --tag-bg: #f7dedb; --tag-fg: #77302a; --tag-border: #eec5c0; }
.tag-chip-purple { --tag-bg: #e6e0f2; --tag-fg: #443166; --tag-border: #d2c8e6; }
.tag-chip-pink   { --tag-bg: #f6dfea; --tag-fg: #6d2b4e; --tag-border: #ecc6da; }

@media (prefers-color-scheme: dark) {
  .tag-chip-slate  { --tag-bg: #2c383e; --tag-fg: #c7d3d9; --tag-border: #3d4b52; }
  .tag-chip-blue   { --tag-bg: #1f333f; --tag-fg: #a8cbe2; --tag-border: #2e4a5b; }
  .tag-chip-teal   { --tag-bg: #1b3937; --tag-fg: #9fd2cd; --tag-border: #2a5350; }
  .tag-chip-green  { --tag-bg: #22381f; --tag-fg: #b0d3ac; --tag-border: #33502f; }
  .tag-chip-amber  { --tag-bg: #3d3018; --tag-fg: #e2c185; --tag-border: #574427; }
  .tag-chip-red    { --tag-bg: #3d2523; --tag-fg: #e5aca5; --tag-border: #573734; }
  .tag-chip-purple { --tag-bg: #2f2740; --tag-fg: #c2b2e0; --tag-border: #443a5c; }
  .tag-chip-pink   { --tag-bg: #3b2431; --tag-fg: #e0aac6; --tag-border: #55354a; }
}

/* Chips sit inline in table cells and checkbox labels, so they need a little breathing room
   from whatever follows them rather than relying on a trailing space in the markup. */
.admin-table .tag-chip,
.assistant-form-checkbox .tag-chip {
  margin-right: 0.25rem;
}

/* The picker's tag filter hides rows with the `hidden` property. The UA stylesheet's
   [hidden] already wins over `tr`'s display, but stating it here means a later `.admin-table
   tr { display: ... }` rule can't silently break the filter. */
.admin-table tr[hidden] {
  display: none !important;
}

/* Document review workflow - the status badge and the comment thread on the document edit
   page (served under /admin and /workspaces alike), and the same badge on the workspace list.
   The badge reuses .admin-status's shape; the colours mirror the pipeline statuses so
   "Complete" reads like "ready" and "Please check" like "pending". */
.doc-review-status {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-bg-muted, rgba(127, 127, 127, 0.15));
  color: var(--color-text-muted);
}

.doc-review-status-in_review {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.doc-review-status-needs_check {
  background: rgba(234, 179, 8, 0.15);
  color: #b8860b;
}

.doc-review-status-complete {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.doc-review-form {
  margin: 0.75rem 0 1.25rem;
}

.doc-review-form .doc-review-note {
  flex: 1 1 260px;
}

.doc-review-form .doc-review-note input {
  width: 100%;
}

.doc-comments {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.5rem 0 1.25rem;
}

.doc-comment {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.doc-comment-status {
  background: var(--color-bg-subtle);
  border-style: dashed;
}

.doc-comment-meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.doc-comment-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

/* --- Formulas ------------------------------------------------------------------------
   The formula module (templates/_module_formula.html) and the calculation card
   (static/calc-card.js), which is shared between that page's "Try it" panel and the chat.
   KaTeX does the typesetting; these only place it. */

.formula-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .formula-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.formula-preview {
  min-height: 2.6rem;
  padding: 0.6rem 0.9rem;
  margin: -0.25rem 0 0.25rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 1.1rem;
}

.formula-preview:empty {
  display: none;
}

.formula-status-bad {
  color: #dc2626;
}

.formula-image-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 0.75rem;
}

.formula-image-btn {
  cursor: pointer;
}

.formula-image-model {
  max-width: 14rem;
}

.formula-section-title {
  display: block;
  font-weight: 600;
  margin: 0.5rem 0 0.4rem;
}

.formula-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.formula-variables-table input,
.formula-tests-table input {
  width: 100%;
  min-width: 5rem;
  padding: 0.3rem 0.45rem;
  font-size: 0.88rem;
}

.formula-variables-table td:nth-child(4) input {
  min-width: 12rem;
}

.formula-variables-table td:nth-child(5) input,
.formula-variables-table td:nth-child(6) input,
.formula-variables-table td:nth-child(7) input {
  min-width: 4.5rem;
  max-width: 7rem;
}

.formula-result-row td:first-child {
  font-weight: 600;
}

.formula-dimension-consistent {
  color: #16a34a;
}

.formula-dimension-inconsistent {
  color: #ea700b;
}

.formula-tests-passed {
  color: #16a34a;
}

.formula-tests-failed {
  color: #dc2626;
  white-space: pre-line;
}

.formula-try {
  position: sticky;
  top: 1rem;
  padding: 1rem 1.1rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.formula-try h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.formula-try-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.formula-try-field {
  display: grid;
  grid-template-columns: minmax(6rem, 40%) 1fr;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

.formula-try-field input {
  width: 100%;
  padding: 0.3rem 0.45rem;
}

.formula-try-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.formula-try-solve {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

.formula-inline-tex {
  font-size: 0.95rem;
  white-space: nowrap;
}

/* The calculation card. */

.calc-card {
  padding: 0.7rem 0.9rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-brand);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.calc-card-error {
  border-left-color: #dc2626;
}

.calc-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.calc-card-source {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.calc-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.25rem 0;
  border-top: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}

.calc-row-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.calc-row-value {
  min-width: 0;
}

/* The equation takes whatever height it needs (a fraction with a root inside is tall) and
   only ever scrolls sideways, when it is genuinely wider than the card. overflow-x alone
   would also clip vertically, which is what put a scrollbar on the right of every tall
   formula; the padding keeps the tallest glyphs off the clip edge. */
.calc-tex {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0.1rem;
}

.calc-tex .katex-display {
  margin: 0;
  text-align: left;
}

.calc-tex .katex-display > .katex {
  white-space: nowrap;
}

.calc-tex .katex {
  font-size: 1.12em;
}

.calc-inputs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.9rem;
  margin: 0;
}

.calc-inputs dt,
.calc-inputs dd {
  margin: 0;
}

.calc-result {
  font-size: 1rem;
}

.calc-result strong {
  font-size: 1.1rem;
}

.calc-error {
  color: #dc2626;
}

.calc-card-foot {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.calc-warning {
  margin-top: 0.35rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
  color: #8a5c05;
  background: color-mix(in srgb, #c98a1a 14%, transparent);
  border-radius: 6px;
}

@media (prefers-color-scheme: dark) {
  .calc-warning {
    color: #e5b35c;
  }
  .formula-dimension-consistent,
  .formula-tests-passed {
    color: #4ade80;
  }
  .formula-dimension-inconsistent {
    color: #fb923c;
  }
}

.formula-card {
  border-left-color: var(--color-accent);
}

.formula-card-description {
  margin: -0.15rem 0 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}


/* --- The formula playground (static/formula-play.js) --------------------------------------
   A dialog on one formula: the inputs on the left, the card those inputs make on the right
   (the same card "Pin to conversation" writes into the chat), the graph underneath. */

.calc-card-play {
  margin-left: auto;
  padding: 0.15rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-brand);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--color-brand) 45%, transparent);
  border-radius: 999px;
  cursor: pointer;
}

.calc-card-play:hover {
  background: color-mix(in srgb, var(--color-brand) 10%, transparent);
}

.fp-dialog {
  width: min(96vw, 1040px);
  max-height: 92vh;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  color: var(--color-text);
  padding: 1.1rem 1.4rem 1.3rem;
  box-shadow: var(--shadow-lift);
  font-size: 0.92rem;
}

.fp-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.fp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.fp-title {
  margin: 0;
  font-size: 1.15rem;
}

.fp-meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.fp-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  font: inherit;
  font-size: 1rem;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
}

.fp-close:hover {
  color: var(--color-text);
  border-color: var(--color-brand);
}

.fp-description {
  margin: 0.4rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.fp-body {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 760px) {
  .fp-dialog {
    padding: 0.9rem 0.9rem 1.1rem;
  }
  .fp-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .fp-input-hint {
    display: none;
  }
  .fp-input-symbol {
    width: auto;
  }
  .fp-input-value {
    min-width: 0;
  }
  .fp-fill label {
    flex-wrap: wrap;
  }
  .fp-fill-query {
    flex-basis: 100%;
  }
  .fp-graph-controls select,
  .fp-graph-controls label {
    max-width: 100%;
    min-width: 0;
  }
}

.fp-solve {
  margin: 0 0 0.75rem;
  padding: 0.45rem 0.7rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.fp-solve legend {
  padding: 0 0.3rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.fp-solve-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.fp-solve-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.fp-solve-name {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.fp-inputs {
  width: 100%;
  border-collapse: collapse;
}

.fp-inputs td {
  padding: 0.3rem 0.35rem;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}

.fp-input-symbol {
  width: 48%;
  padding-right: 0.6rem;
}

.fp-input-symbol .fp-symbol {
  white-space: nowrap;
}

/* A long variable name wraps rather than starving the inputs of width. */
.fp-input-name {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.fp-input-value {
  min-width: 10rem;
}

/* A grid with minmax(0, …) tracks: the inputs' intrinsic widths then don't count towards
   the table's minimum width, which is what let the dialog overflow on a phone. */
.fp-input-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 5rem);
  gap: 0.35rem;
  align-items: center;
}

.fp-input-value input {
  width: 100%;
  min-width: 0;
  padding: 0.3rem 0.45rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}



.fp-input-solving {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--color-text-muted);
}

.fp-input-target td {
  background: color-mix(in srgb, var(--color-brand) 7%, transparent);
}

.fp-input-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-align: right;
}

.fp-actions,
.fp-output-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.fp-auto {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.fp-card .calc-card {
  margin: 0;
}

.fp-convert {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.fp-convert input {
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.fp-converted {
  color: var(--color-text);
  font-weight: 600;
}

.fp-converted-error {
  font-weight: 400;
  color: #dc2626;
}

.fp-status {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.fp-graph {
  margin-top: 1rem;
  padding: 0.5rem 0.8rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.fp-graph summary {
  cursor: pointer;
  font-weight: 600;
}

.fp-graph-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.fp-graph-controls select,
.fp-graph-controls input {
  padding: 0.25rem 0.4rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.fp-graph-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.fp-chart-wrap {
  position: relative;
  height: 300px;
}

/* --- Formula pack import (admin formulas page) --------------------------------------------- */

.formula-import {
  margin: 0.75rem 0 1rem;
}

.formula-import-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.88rem;
}

.formula-import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.formula-import-row label {
  flex: 0 0 9rem;
  color: var(--color-text-muted);
}

.formula-import-row input,
.formula-import-row select {
  flex: 1 1 16rem;
  min-width: 0;
  max-width: 32rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.88rem;
}

.formula-import-check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  color: var(--color-text-muted);
}

.formula-import-check input {
  margin-top: 0.2rem;
}

.formula-import-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

/* --- Design checks: the verdict under a calculation card's result ------------------------- */

.calc-card-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  vertical-align: middle;
}

.calc-verdict {
  font-size: 0.95rem;
}

.calc-verdict strong {
  font-size: 1.05rem;
}

.calc-verdict-pass strong {
  color: #15803d;
}

.calc-verdict-fail strong {
  color: #dc2626;
}

.calc-verdict-bar {
  margin-top: 0.35rem;
  height: 0.5rem;
  max-width: 18rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-border) 70%, transparent);
  overflow: hidden;
}

.calc-verdict-fill {
  height: 100%;
  border-radius: 999px;
  background: #15803d;
}

.calc-verdict-fail .calc-verdict-fill {
  background: #dc2626;
}

@media (prefers-color-scheme: dark) {
  .calc-verdict-pass strong,
  .calc-verdict-pass .calc-verdict-fill { color: #4ade80; background-color: #4ade80; }
  .calc-verdict-pass strong { background-color: transparent; }
  .calc-verdict-fail strong,
  .calc-verdict-fail .calc-verdict-fill { color: #f87171; background-color: #f87171; }
  .calc-verdict-fail strong { background-color: transparent; }
}

.calc-case {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* "Use result in": the next formula a playground result can flow into. */
.fp-chain {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.fp-chain[hidden] {
  display: none; /* the class's display: flex would otherwise outrank the UA's [hidden] */
}

.fp-chain label {
  display: flex;
  flex: 1 1 14rem;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.fp-chain select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

/* --- The formula panel: what the assistant can calculate with ----------------------------- */

.chat-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.chat-topbar-btn:hover {
  background: var(--color-bg-subtle);
}

.chat-topbar-btn .icon {
  width: 1rem;
  height: 1rem;
}

.chat-topbar-btn[hidden] {
  display: none;
}

.formula-panel-page {
  max-width: 60rem;
  margin: 0.5rem auto 2rem;
  padding: 0 1rem;
}

.formula-panel-page h2 {
  margin: 0 0 0.35rem;
}

.formula-panel-intro {
  margin: 0 0 0.9rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.formula-panel-filter {
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
}

.formula-panel-row {
  cursor: pointer;
}

.formula-panel-row:hover td {
  background: var(--color-bg-subtle);
}

.formula-panel-open {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--color-brand);
  cursor: pointer;
  text-align: left;
}

.formula-panel-open:hover {
  text-decoration: underline;
}

.formula-panel-table td:nth-child(3) {
  white-space: nowrap;
}

.formula-panel-empty {
  color: var(--color-text-muted);
}

/* "Fill from": a value set (material, section, bar, bolt) filling the playground's inputs. */
.fp-fill {
  position: relative;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.fp-fill[hidden] {
  display: none;
}

.fp-fill label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fp-fill-query {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.fp-fill-results {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 16rem;
  overflow-y: auto;
  margin-top: 0.25rem;
  padding: 0.25rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
}

.fp-fill-results[hidden] {
  display: none;
}

.fp-fill-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.5rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
  color: var(--color-text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.fp-fill-item:hover,
.fp-fill-item:focus {
  background: var(--color-bg-subtle);
}

.fp-fill-kind {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.fp-fill-values {
  flex-basis: 100%;
  color: var(--color-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-fill-empty {
  padding: 0.4rem 0.5rem;
  color: var(--color-text-muted);
}

.fp-input-from {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

.calc-inputs-wide {
  grid-template-columns: max-content 1fr max-content 1fr;
}

@media (max-width: 560px) {
  .calc-inputs-wide {
    grid-template-columns: max-content 1fr;
  }
}

/* A text filter in a table toolbar (formulas lists, admin and workspace). */
.admin-filter-input {
  flex: 1 1 14rem;
  max-width: 24rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
}

/* The download control on a pinned calculation sits on the user's dark bubble. */
.message-pinned .message-download-select {
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.3);
}

.message-pinned .message-download-select:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.45);
}

.message-pinned .message-download-select option {
  color: var(--color-text);
  background: var(--color-bg-elevated);
}

.admin-inline-form .admin-inline-wide input {
  width: 320px;
  max-width: 100%;
}

/* --- Forms ----------------------------------------------------------------------------
   One renderer (static/form-kinds.js) draws a form in the chat's forms panel and in the
   form page's preview, so both look the same; the builder (static/form-builder.js) is the
   field list on the form page. */

.form-body {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-description {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  white-space: pre-line;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field-label {
  font-weight: 600;
}

.form-required {
  color: var(--color-accent-dark);
  font-weight: 600;
}

.form-field-help {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.form-input {
  width: 100%;
  max-width: 36rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
}

textarea.form-input {
  resize: vertical;
}

.form-input-date {
  width: auto;
}

.form-number {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 20rem;
}

.form-number-unit {
  color: var(--color-text-muted);
  white-space: nowrap;
}

.form-choices {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-choice {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  cursor: pointer;
}

.form-scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.form-scale-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 2rem;
  cursor: pointer;
  font-size: 0.9rem;
}

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

.form-section {
  padding-top: 0.6rem;
  border-top: 1px solid var(--color-border);
}

.form-section-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.form-section-text {
  margin: 0;
  color: var(--color-text-muted);
  white-space: pre-line;
}

.form-field-error {
  margin: 0;
  color: var(--color-accent-dark);
  font-size: 0.88rem;
}

.form-field-invalid .form-input,
.form-field-invalid .form-choices,
.form-field-invalid .form-scale {
  border-color: var(--color-accent);
  outline: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent);
  border-radius: var(--radius-md);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* The form page: builder on the left, the preview beside it. */

.form-edit-name {
  margin-bottom: 1rem;
}

.form-edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1000px) {
  .form-edit-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form-edit-side h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.form-edit-side h2 .field-hint {
  margin-left: 0.4rem;
  font-weight: 400;
}

.fb-prop-check input {
  width: auto;
  margin: 0;
}

.form-preview-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}

.form-preview-result {
  margin-top: 1rem;
}

.form-preview-result h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.form-preview-result pre {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  white-space: pre-wrap;
  font-size: 0.85rem;
}

.fb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fb-empty {
  padding: 1rem;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.fb-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.fb-item-open {
  border-color: color-mix(in srgb, var(--color-brand) 45%, var(--color-border));
}

.fb-item-head {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.fb-item-toggle {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fb-item-head-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.fb-kind {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.fb-item-label {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.fb-item-key {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.fb-item-actions {
  display: flex;
  flex-shrink: 0;
  padding-right: 0.35rem;
}

.fb-action {
  min-width: 1.9rem;
  padding: 0.2rem 0.35rem;
  text-decoration: none;
}

.fb-item-actions {
  align-items: center;
}

/* The on/off switch left of a field's or output's remove button. */
.fb-switch {
  position: relative;
  width: 2rem;
  height: 1.1rem;
  margin: 0 0.35rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--color-brand);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.fb-switch[aria-checked="false"] {
  background: var(--color-border);
}

.fb-switch-knob {
  position: absolute;
  top: 0.15rem;
  left: 1.05rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: left 0.15s;
}

.fb-switch[aria-checked="false"] .fb-switch-knob {
  left: 0.15rem;
}

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

.fb-item-off .fb-item-head-text > :not(.fb-off) {
  opacity: 0.5;
}

.fb-off {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0 0.45rem;
}

.fb-item-body[hidden] {
  display: none;
}

.fb-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.25rem 0.9rem 0.9rem;
  border-top: 1px solid var(--color-border);
}

.fb-prop {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.5rem;
}

.fb-prop-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.fb-prop-check {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.fb-prop-check .field-hint {
  flex-basis: 100%;
}

.fb-default .form-body {
  gap: 0;
}

.fb-add {
  display: block;
  margin-top: 0.75rem;
  max-width: 20rem;
}

/* The chat's forms panel. */

.forms-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.forms-panel-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.forms-panel-item:hover {
  border-color: color-mix(in srgb, var(--color-brand) 45%, var(--color-border));
}

.forms-panel-page #forms-panel-back {
  margin-bottom: 0.5rem;
}

.forms-panel-page h2 {
  margin: 0 0 0.35rem;
}

/* A submitted form in the thread: the user's bubble, wider, with its way back in. */

.message-form {
  max-width: min(100%, 44rem);
}

.message-form .message-content ul {
  padding-left: 1.2rem;
}

.message-form-bar .message-form-resubmit {
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 0.2rem 0.6rem;
  text-decoration: none;
}

.message-form-bar .message-form-resubmit:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.form-clear {
  align-self: flex-start;
  padding: 0.1rem 0;
}

/* A form the assistant suggested, under its answer. */
.message-form-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.form-suggestion-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--color-brand) 35%, var(--color-border));
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}

.form-suggestion-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.form-suggestion-text span {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* A plan for a big request (static/app.js renderPlanCard, app/chat/plans.py): the card under
   the reply that proposed it - its goal, the steps, questions, then Start / Edit / Revise /
   Just answer. A closed one (started, revised, answered without) keeps its steps, quieter. */
.message-plan-reply .message-content:empty { display: none; }
.plan-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--color-brand) 35%, var(--color-border));
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}
.plan-card.is-closed { border-color: var(--color-border); }
.plan-card.is-closed .plan-steps { color: var(--color-text-muted); }
.plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
}
.plan-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-brand);
}
.plan-status { font-size: 0.85rem; color: var(--color-text-muted); }
.plan-goal { margin: 0; font-weight: 600; }
.plan-result, .plan-loading, .plan-removed, .plan-estimate { margin: 0; font-size: 0.9rem; color: var(--color-text-muted); }
.plan-estimate { cursor: help; }
.plan-label { font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); }
.plan-steps {
  margin: 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.plan-step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
}
.plan-step-meta { font-size: 0.8rem; color: var(--color-text-muted); }
.plan-step-does, .plan-step-reads, .plan-step-note { margin: 0.1rem 0 0; font-size: 0.9rem; }
.plan-step-reads, .plan-step-note { color: var(--color-text-muted); }
.plan-step-note { font-style: italic; }
.plan-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-bg-elevated);
}
.plan-tag-pause {
  border-color: color-mix(in srgb, var(--color-accent) 55%, var(--color-border));
  color: var(--color-text);
}
.plan-tag-new {
  border-color: color-mix(in srgb, var(--color-brand) 55%, var(--color-border));
  color: var(--color-brand);
}
.plan-questions { display: flex; flex-direction: column; gap: 0.4rem; }
.plan-question { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
.plan-question input, .plan-revise textarea, .plan-edit-title, .plan-edit-note {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
}
.plan-answer { color: var(--color-text-muted); }
.plan-pause, .plan-edit-pause { font-size: 0.9rem; display: flex; align-items: center; gap: 0.35rem; }
.plan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.plan-just { margin-left: auto; }
.plan-actions[hidden], .plan-pause[hidden] { display: none; }
.plan-revise { display: flex; flex-direction: column; gap: 0.4rem; }
.plan-revise[hidden] { display: none; }
.plan-steps.is-editing { list-style: none; padding-left: 0; gap: 0.75rem; }
.plan-step-edit {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}
.plan-edit-row { display: flex; gap: 0.35rem; align-items: center; }
.plan-edit-title { font-weight: 600; min-width: 0; }
.plan-edit-tools { display: flex; gap: 0.15rem; flex-shrink: 0; }
.plan-edit-tools button { min-width: 2rem; min-height: 2rem; font-size: 1rem; }
.plan-edit-tools button:disabled { opacity: 0.35; cursor: default; }
/* Editing the rest of a paused plan: done steps and the final one locked, a step of one's own added. */
.plan-step-edit.is-locked {
  background: transparent;
  border-style: dashed;
  color: var(--color-text-muted);
}
.plan-step-edit.is-locked .plan-edit-row { gap: 0.5rem; flex-wrap: wrap; }
.plan-step-edit.is-locked .plan-step-title { font-weight: 600; }
.plan-step-edit .plan-step-meta { margin: 0; }
.plan-edit-add { display: flex; flex-direction: column; gap: 0.5rem; }
.plan-edit-add > .btn { align-self: flex-start; }
.plan-edit-add > .btn[hidden] { display: none; }
.plan-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}
.plan-add-form[hidden] { display: none; }
.plan-add-field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
.plan-add-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; }
/* Under Auto, each step's model in Edit: "Model [Normal v]" beside "Pause after it". */
.plan-edit-options { align-items: center; }
.plan-edit-tier-field { flex-direction: row; align-items: center; gap: 0.4rem; }
.plan-add-form select, .plan-edit-tier {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
}
.plan-progress[hidden], .plan-note-asked[hidden] { display: none; }
/* On the user's message that asked for a plan (or for none): a quiet label above its text. */
.message-plan-request {
  display: inline-block;
  margin-bottom: 0.35rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
}
@media (max-width: 720px) {
  .plan-card { padding: 0.75rem; }
  .plan-just { margin-left: 0; }
}

/* Outputs on the form page (static/form-outputs.js). */

.fo-outline-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.fo-outline-tools .fo-insert-answer,
.fo-outline-tools .fo-insert-embed,
.fo-outline-tools .fo-insert-sum {
  width: auto;
  max-width: 22rem;
}

.fo-chart-y .form-choice {
  display: block;
}

.fo-outline {
  font-size: 0.85rem;
  line-height: 1.45;
  resize: vertical;
}

.fo-columns-wrap {
  overflow-x: auto;
  margin: 0.25rem 0 0.5rem;
}

.fo-columns {
  width: 100%;
}

.fo-add-column {
  align-self: flex-start;
}

.fo-columns td {
  padding: 0.25rem;
  vertical-align: middle;
}

.fo-columns td .form-input {
  min-width: 5rem;
  padding: 0.3rem 0.45rem;
}

.fo-column-actions {
  white-space: nowrap;
}

.fo-rows {
  display: flex;
  gap: 1rem;
}

.fo-rows .fb-prop {
  max-width: 9rem;
}

.form-preview-note,
#outputs-preview {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  white-space: pre-wrap;
  font-size: 0.85rem;
  max-height: 70vh;
  overflow: auto;
}

.form-preview-result #preview-note-wrap h3 {
  margin-top: 0.9rem;
}

/* The chat: choosing outputs, and the cards they arrive as. */

.forms-panel-outputs {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.forms-panel-outputs[hidden] {
  display: none;
}

.forms-panel-outputs legend {
  padding: 0 0.35rem;
  font-weight: 600;
}

.forms-panel-outputs .field-hint {
  margin: 0.5rem 0 0;
}


.form-output-card {
  border: 1px solid color-mix(in srgb, var(--color-brand) 35%, var(--color-border));
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  overflow: hidden;
}

.form-output-superseded {
  border-color: var(--color-border);
  opacity: 0.8;
}

.form-output-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem 0.4rem 0.2rem;
  background: var(--color-bg-subtle);
}

.form-output-toggle {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.25rem 0.5rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.form-output-kind {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.form-output-badge {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-brand) 15%, transparent);
  color: var(--color-brand);
  font-size: 0.78rem;
}

.form-output-body {
  max-height: 60vh;
  overflow: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
}

.form-output-body[hidden] {
  display: none;
}

.form-output-document > :first-child {
  margin-top: 0;
}

.form-output-table-wrap {
  overflow-x: auto;
}

/* A chart output, on its own card or placed in a document (static/app.js outputChart). */
.form-output-chart {
  position: relative;
  height: 300px;
  max-width: 760px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.form-output-embed {
  margin: 0.75rem 0;
}

.form-output-table {
  border-collapse: collapse;
  font-size: 0.9rem;
  width: 100%;
}

.form-output-table th,
.form-output-table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.form-output-table th {
  background: var(--color-bg-subtle);
  font-weight: 600;
  white-space: nowrap;
}

.form-output-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.form-output-table .nowrap {
  white-space: nowrap;
}

/* The total row the server adds (app/forms/outputs.py table_totals). */
.form-output-table tfoot td {
  font-weight: 600;
  border-top: 2px solid var(--color-border);
  border-bottom: none;
}

/* A computed column's header: the formula is in its tooltip. */
.form-output-table th.form-output-computed::after {
  content: " ƒ";
  color: var(--color-text-muted);
  font-weight: 400;
}

/* {{sum:table.column}} in a document, filled in from the current table. */
.form-output-sum {
  font-variant-numeric: tabular-nums;
}

.form-output-appendix {
  margin-top: 0.75rem;
}

/* A form's files question (static/form-kinds.js "files"). */
.form-files {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.form-files-list {
  margin: 0;
  padding-left: 1.5rem;
  width: 100%;
}

.form-files-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--color-border);
}

.form-files-item::marker {
  color: var(--color-text-muted);
}

.form-files-name {
  overflow-wrap: anywhere;
}

/* A computed column on the form page's Outputs tab: its formula and inputs. */
.fo-formula-row td {
  background: var(--color-bg-subtle);
  padding: 0.5rem 0.75rem 0.75rem;
}

.fo-formula-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.fo-formula-line .fo-formula-pick {
  width: auto;
  max-width: 28rem;
}

.fo-formula-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.fo-formula-input {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.fo-formula-symbol {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.fo-columns td .fo-decimals {
  min-width: 3rem;
  width: 3.5rem;
}

.message-cut-short {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.message-cut-short .message-interrupted {
  margin-top: 0;
}

.form-output-retry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.form-output-document h1 { font-size: 1.3rem; }
.form-output-document h2 { font-size: 1.1rem; }
.form-output-document h3 { font-size: 1rem; }
.fo-columns td select.form-input { min-width: 7.5rem; }

/* Editing a form output by hand (static/app.js editOutputTable / editOutputDocument). */
.form-output-edit {
  font-size: 0.85rem;
  padding: 0.15rem 0.5rem;
}

.form-output-superseded .form-output-edit,
.form-output-editing .form-output-edit {
  display: none;
}

.form-output-editing .form-output-body {
  max-height: none;
}

.form-output-grid td {
  padding: 0.2rem 0.3rem;
}

.form-output-grid .form-output-cell {
  min-width: 6rem;
  padding: 0.3rem 0.45rem;
  font-size: 0.88rem;
}

.form-output-grid .form-output-fixed {
  font-weight: 600;
  white-space: nowrap;
}

.form-output-cell-invalid .form-output-cell {
  border-color: #dc2626;
  box-shadow: 0 0 0 1px #dc2626;
}

.form-output-add-row {
  margin-top: 0.5rem;
}

.form-output-edit-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.form-output-edit-error {
  flex: 1;
  color: #dc2626;
  font-size: 0.88rem;
}

.form-output-embed-chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  user-select: all;
}

.form-output-editor .toastui-editor-defaultUI {
  font-family: inherit;
}

.form-output-plain-editor {
  width: 100%;
}

/* The Markdown editor (static/md-editor.js) - Toast UI in Markdown mode. */
.md-editor-mount {
  margin-top: 0.35rem;
  font-weight: normal;
  /* A drag handle bottom right, like the plain textarea's; md-editor.js makes the editor
     follow the height. */
  resize: vertical;
  overflow: hidden;
  min-height: 180px;
}

.md-editor-mount .toastui-editor-defaultUI {
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
}

.md-editor-mount .toastui-editor-md-container,
.md-editor-mount .toastui-editor-contents {
  font-size: 0.92rem;
}

/* Markdown | Plain text under a Markdown field (static/md-editor.js): tabs hanging from the
   field's bottom edge, bottom right - the look of the editor's own mode switch in the chat. */
.md-mode-switch {
  display: flex;
  justify-content: flex-end;
  padding-right: 10px;
  margin-top: -1px;
  position: relative;
  font-weight: normal;
}

.md-mode-tab {
  width: 96px;
  height: 25px;
  margin-right: -1px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 0 0 4px 4px;
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.md-mode-tab.active {
  border-top-color: var(--color-bg-elevated, #fff);
  background: var(--color-bg-elevated, #fff);
  color: var(--color-text);
  cursor: default;
}

.md-mode-tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* "?" tips (the script and helpTip() in base.html, the `tip` macro in _tip.html): an
   explanation people need once or twice, floating under the "?" on hover or focus and kept
   open by a click. The page stays lean; the note is still in the page for screen readers. */
.tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: normal;
}

.tip-btn {
  width: 1.1rem;
  height: 1.1rem;
  font-size: 0.7rem;
}

.tip-pop {
  display: none;
  position: absolute;
  left: -0.5rem;
  top: calc(100% + 6px);
  z-index: 60;
  width: max-content;
  max-width: min(24rem, 80vw);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-brand);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lift);
  color: var(--color-text);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
}

/* Too near the right edge: the note opens leftwards from the "?". */
.tip-left .tip-pop {
  left: auto;
  right: -0.5rem;
}

.tip-pop p {
  margin: 0 0 0.4rem;
}

.tip-pop p:last-child {
  margin-bottom: 0;
}

/* A bridge over the gap, so the pointer can move onto the box without it closing. */
.tip-pop::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

.tip:hover .tip-pop,
.tip-btn:focus-visible + .tip-pop,
.tip-open .tip-pop {
  display: block;
}

/* "Build with Claude" (static/claude-assist.js) on the form, formula and assistant pages: a
   short conversation, the request box under it, Undo/Redo on the right. */
.assist > summary .field-hint {
  font-weight: normal;
  margin-left: 6px;
}

.assist-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  resize: vertical;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}

.assist-log[hidden] {
  display: none;
}

.assist-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.45;
}

.assist-msg p {
  margin: 0.3em 0;
}

.assist-msg ul,
.assist-msg ol {
  margin: 0.3em 0;
  padding-left: 1.3em;
}

.assist-user {
  align-self: flex-end;
  background: var(--color-brand);
  color: #fff;
  white-space: pre-wrap;
}

.assist-assistant {
  align-self: flex-start;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
}

.assist-error {
  align-self: flex-start;
  background: var(--color-bg-elevated);
  border: 1px solid #dc2626;
  color: #dc2626;
}

.assist-pending {
  align-self: flex-start;
  color: var(--color-text-muted);
  font-style: italic;
}

.assist-change {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
  padding-top: 4px;
}

.assist-warning {
  color: #b45309;
  font-size: 0.85rem;
}

.assist-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  resize: vertical;
}

.assist-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.assist-model-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.assist-spacer {
  flex: 1;
}

/* Sources in the "Build with Claude" panel: chips for uploads and library documents, the
   picker dialog for the latter. */
.assist-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 8px;
  font-size: 0.9rem;
}

.assist-sources-label {
  color: var(--color-text-muted);
}

.assist-source-list {
  display: contents;
  list-style: none;
}

.assist-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-subtle);
}

.assist-source-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 32ch;
}

.assist-source-detail {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.assist-source-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0 4px;
}

.assist-source-remove:hover:not(:disabled) {
  color: var(--color-text);
}

.assist-upload {
  cursor: pointer;
}

.assist-busy .assist-upload {
  opacity: 0.5;
  pointer-events: none;
}

.assist-dragging {
  outline: 2px dashed var(--color-brand);
  outline-offset: 2px;
}

.assist-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-lift);
}

.assist-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.assist-dialog-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
  max-height: calc(100vh - 66px);
  box-sizing: border-box;
}

.assist-dialog-inner h2 {
  margin: 0;
  font-size: 1.1rem;
}

.assist-pick-search,
.assist-pick-outline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  flex: 1;
}

.assist-pick-search[hidden],
.assist-pick-outline[hidden],
.assist-pick-sections[hidden] {
  display: none;
}

.assist-pick-outline p {
  margin: 0;
}

.assist-doc-query,
.assist-section-filter {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
}

.assist-doc-results,
.assist-section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 50vh;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.assist-doc-results > li,
.assist-section-list > li {
  border-bottom: 1px solid var(--color-border);
}

.assist-doc-results > li:last-child,
.assist-section-list > li:last-child {
  border-bottom: none;
}

.assist-doc-results > li.field-hint {
  padding: 8px 10px;
}

.assist-doc-pick {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.assist-doc-pick:hover,
.assist-doc-pick:focus-visible {
  background: var(--color-bg-subtle);
}

.assist-doc-desc {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.assist-pick-sections {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.assist-pick-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.assist-section {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  cursor: pointer;
}

.assist-section > span:nth-child(2) {
  flex: 1;
}

.assist-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* What Claude changed in a long text (a prompt, an instruction), folded under its reply. */
.assist-diff {
  margin-top: 6px;
  font-size: 0.85rem;
}

.assist-diff > summary {
  cursor: pointer;
  color: var(--color-text-muted);
}

.assist-diff-lines {
  max-height: 320px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.assist-diff-lines > span {
  display: block;
  min-height: 1.4em;
}

.assist-diff-add {
  background: rgba(22, 163, 74, 0.14);
}

.assist-diff-del {
  background: rgba(220, 38, 38, 0.12);
  text-decoration: line-through;
  text-decoration-color: rgba(220, 38, 38, 0.5);
}

.assist-diff-gap {
  color: var(--color-text-muted);
}

/* The form page's Consistency card: the deterministic warnings (every save) and Claude's
   stored review, greyed with an orange status line once the form changed since. */
.consistency-heading {
  font-size: 0.95rem;
  margin: 14px 0 6px;
}

.consistency-warnings {
  margin: 0;
  padding-left: 1.2rem;
  color: #b45309;
}

.consistency-warnings li + li {
  margin-top: 4px;
}

.consistency-stale {
  color: #b45309;
}

#consistency-review.is-stale {
  opacity: 0.6;
}

.consistency-findings {
  list-style: none;
  margin: 0;
  padding: 0;
}

.consistency-finding {
  border-top: 1px solid var(--color-border);
  padding: 8px 0;
}

.consistency-finding p {
  margin: 4px 0;
}

.consistency-severity {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
}

.consistency-severity-high {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.consistency-severity-medium {
  background: rgba(249, 115, 22, 0.16);
  color: #ea700b;
}

.consistency-severity-low {
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
}

.consistency-actions {
  margin-top: 10px;
}

@media (prefers-color-scheme: dark) {
  .consistency-warnings,
  .consistency-stale {
    color: #fbbf24;
  }
  .consistency-severity-high {
    color: #f87171;
  }
  .consistency-severity-medium {
    color: #fb923c;
  }
}

/* Fill from document (the chat's form dialog, app/forms/fill.py). */

.forms-panel-fill {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
}

.forms-panel-fill[hidden],
.forms-panel-fill-result[hidden],
.forms-panel-fill-attach[hidden] {
  display: none;
}

.forms-panel-fill-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.forms-panel-fill > .field-hint {
  margin: 0 0 0.5rem;
}

.forms-panel-fill-result {
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid #d97706;
  border-radius: var(--radius-md);
  background: rgba(217, 119, 6, 0.08);
}

.forms-panel-fill-result p {
  margin: 0.35rem 0 0;
}

/* "Documents first" (static/app.js resetFill): the form's files question in the fill box. */
.forms-panel-step {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.forms-panel-fill-docs-first {
  border-style: solid;
}

.forms-panel-fill-docs-first #forms-panel-fill-docs .form-field {
  margin-bottom: 0.75rem;
}

.forms-panel-fill-docs-first #forms-panel-fill-docs .form-field-label {
  display: none;
}

.form-fill-todo-link {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--color-brand);
  text-decoration: underline;
  cursor: pointer;
}

/* A required field the documents didn't settle - what is left to do. Red, where a filled
   field (to check) is amber. */
.form-field-todo {
  border-left: 3px solid #dc2626;
  padding: 0.3rem 0 0.3rem 0.6rem;
  background: rgba(220, 38, 38, 0.06);
  border-radius: var(--radius-md);
}

.form-field-todo .form-fill-missing {
  color: #b91c1c;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .form-field-todo {
    border-left-color: #f87171;
    background: rgba(248, 113, 113, 0.08);
  }
  .form-field-todo .form-fill-missing {
    color: #fca5a5;
  }
}

.forms-panel-fill-attach {
  display: flex;
  margin: 1rem 0 0;
}

.form-field-filled {
  border-left: 3px solid #d97706;
  padding-left: 0.6rem;
}

.form-field-unfilled {
  border-left: 3px solid var(--color-border);
  padding-left: 0.6rem;
}

.form-fill-evidence {
  margin-top: 0.35rem;
  font-size: 0.85rem;
}

.form-fill-evidence summary {
  cursor: pointer;
  color: #b45309;
}

.form-fill-evidence blockquote {
  margin: 0.35rem 0 0;
  padding: 0.3rem 0.6rem;
  border-left: 2px solid var(--color-border);
  color: var(--color-text-muted);
  white-space: pre-wrap;
}

.form-fill-evidence .field-hint {
  margin: 0.2rem 0 0;
}

.form-fill-missing {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

@media (prefers-color-scheme: dark) {
  .forms-panel-fill-result {
    border-left-color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
  }
  .form-field-filled {
    border-left-color: #fbbf24;
  }
  .form-fill-evidence summary {
    color: #fbbf24;
  }
}

/* --- Workspace page: the tab bar's two halves, the assistants overview ------------------- */

/* Tags and Members - how the workspace is organised - sit apart at the right of the bar, the
   content tabs (assistants, documents, forms, formulas) on the left. */
.admin-tab.admin-tab-split {
  margin-left: auto;
}

.ws-uses-none {
  color: var(--color-accent);
  font-weight: 700;
  cursor: help;
}

.admin-table td.ws-row-actions {
  text-align: right;
}

.ws-row-actions .btn + .btn {
  margin-left: 0.35rem;
}

.ws-guide-more {
  margin: 1rem 0 0;
}

/* --- "Ask for help" (templates/_workspace_help.html) ------------------------------------- */

.ws-help-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lift);
  cursor: pointer;
}

.ws-help-launcher span {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--color-brand);
  color: #fff;
  font-size: 0.85rem;
}

.ws-help-launcher[hidden] {
  display: none;
}

.ws-help {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(28rem, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elevated);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lift);
}

.ws-help[hidden] {
  display: none;
}

/* Wide screens keep the page readable beside the open panel. */
@media (min-width: 1100px) {
  body.ws-help-open {
    padding-right: 28rem;
  }
}

.ws-help-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.ws-help-head strong {
  margin-right: auto;
}

.ws-help-close {
  appearance: none;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.ws-help-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.ws-help-intro p {
  margin: 0 0 0.6rem;
}

.ws-help-examples {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ws-help-example {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.ws-help-example:hover {
  border-color: var(--color-brand);
}

.ws-help-msg {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.ws-help-msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--color-bg-subtle);
  white-space: pre-wrap;
}

.ws-help-msg-assistant {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.ws-help-msg-error {
  color: var(--color-accent);
  border: 1px dashed var(--color-accent);
}

.ws-help-msg-waiting {
  color: var(--color-text-muted);
  font-style: italic;
}

.ws-help-md > :first-child {
  margin-top: 0;
}

.ws-help-md > :last-child {
  margin-bottom: 0;
}

.ws-help-md ul,
.ws-help-md ol {
  padding-left: 1.2rem;
}

.ws-help-compose {
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 1rem 1rem;
}

.ws-help-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.ws-help-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.ws-help-actions .field-hint {
  font-size: 0.78rem;
}

/* --- Workspace pages: the head, the lists, the dialogs, and a phone layout ---------------- */

/* Text for screen readers only (a column heading over buttons, say). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Secondary text in the workspace lists reads quieter than what it qualifies. */
.ws-page .field-hint,
.ws-table .field-hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* The edit pages' "where you are": your workspaces / this workspace / the tab. */
.ws-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 1rem;
  font-size: 0.85rem;
}

.ws-crumbs a {
  color: var(--color-text-muted);
  font-weight: 600;
  text-decoration: none;
}

.ws-crumbs a:hover {
  color: var(--color-brand);
  text-decoration: underline;
}

.ws-crumbs a:last-of-type {
  color: var(--color-brand);
}

.ws-crumbs-sep {
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* The workspace switcher scrolls sideways rather than wrapping into a second row. */
.ws-switcher {
  overflow-x: auto;
  scrollbar-width: none;
}

.ws-switcher::-webkit-scrollbar {
  display: none;
}

.ws-switcher a {
  flex: none;
  white-space: nowrap;
}

/* Name, role, one line on what the role may do. */
.ws-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
}

.admin-page .ws-head h1 {
  margin: 0;
}

.ws-head-desc {
  margin: 0.45rem 0 0;
  max-width: 70ch;
  font-size: 0.95rem;
  line-height: 1.5;
}

.ws-head-role {
  max-width: 78ch;
  line-height: 1.5;
}

.ws-role-pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  color: var(--color-brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ws-role-pill-admin {
  color: var(--color-accent-dark);
}

/* A row's title, the small flags after it (inactive, read only), its tags underneath. */
.ws-row-title {
  font-weight: 700;
  text-decoration: none;
}

a.ws-row-title:hover {
  text-decoration: underline;
}

/* The workspace pages' header lines up with their content rather than with the narrower
   marketing pages. */
.ws-site-header {
  max-width: 1600px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* The simple view - the workspace home and an assistant's page - takes the whole width of the
   screen, header included; the tiles and the working panel use it. */
.admin-page.prj-home,
.admin-page.prj-page {
  max-width: none;
  padding: 0 2rem;
}

body:has(.prj-home, .prj-page) .ws-site-header {
  max-width: none;
  padding-left: 2rem;
  padding-right: 2rem;
}

@media (max-width: 720px) {
  .admin-page.prj-home,
  .admin-page.prj-page {
    padding: 0 1rem;
  }

  body:has(.prj-home, .prj-page) .ws-site-header {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

.ws-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.02rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: 0.1em;
}

.ws-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.admin-table .ws-row-tags .tag-chip {
  margin-right: 0;
}

.ws-table td {
  vertical-align: top;
}

/* "12 documents · 2 forms" - what an assistant is built from, in words. */
.ws-uses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.45rem;
}

.ws-uses li + li::before {
  content: "\00b7";
  margin-right: 0.45rem;
  color: var(--color-text-muted);
}

/* An empty tab says so and offers the one action that fills it. */
.ws-empty {
  margin: 1.25rem 0;
  padding: 2rem 1.25rem;
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.ws-empty p {
  margin: 0 0 0.9rem;
}

.ws-empty p:last-child {
  margin: 0;
}

.ws-tag-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ws-tag-filter select {
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
}

/* "New assistant" and "Invite someone": a small form in a dialog instead of a card that
   would stand between the tab bar and the list on every visit. The dialog has no padding of
   its own, so a click that lands on the dialog element itself is a click on the backdrop. */
.ws-dialog {
  padding: 0;
  width: min(30rem, calc(100vw - 2rem));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-lift);
}

.ws-dialog::backdrop {
  background: rgba(13, 22, 27, 0.45);
}

.ws-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem 1.4rem;
}

.admin-page .ws-dialog-body h2 {
  margin: 0;
}

.ws-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.ws-field input,
.ws-field select {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
}

/* A company's seats and billing (templates/_module_ws_billing.html). */
.ws-seat-form {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-border);
}

/* `.btn` sets its own display, which outranks the UA's [hidden]: the confirm button waits
   for the charge preview. */
.ws-seat-form [hidden] {
  display: none !important;
}

.ws-seat-form h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.ws-seat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

.ws-seat-count input {
  width: 6.5rem;
}

.ws-seat-preview {
  margin: 0.7rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  line-height: 1.5;
}

.ws-seat-line .tip {
  vertical-align: middle;
}

.ws-inline-hint {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.ws-seat-row .btn {
  margin-bottom: 0.15rem;
}

.ws-dialog .field-hint {
  margin: 0;
  line-height: 1.45;
}

.ws-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Workspace roles (plan-workspace-roles.md): the role cards on the Members tab, the role
   editor's permission groups and table, and the assistant pickers for people who only chat. */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.4;
}

.checkbox-label input {
  margin-top: 0.2rem;
  flex: none;
}

.ws-chat-choice {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  margin: 0.4rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 16rem;
  overflow-y: auto;
}

.ws-chat-choice legend {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.3rem;
}

.ws-chat-invite {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.ws-chat-invite .ws-field {
  flex: 1 1 16rem;
  max-width: 28rem;
}

.ws-chat-invite .ws-field input {
  width: 100%;
  box-sizing: border-box;
}

.ws-chat-access .checkbox-label {
  margin: 0.6rem 0;
}

.ws-roles-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ws-role-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.ws-role-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.ws-role-desc,
.ws-role-summary {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.ws-role-summary {
  color: var(--color-text-muted);
}

.ws-dialog-wide {
  width: min(44rem, calc(100vw - 2rem));
}

.ws-perm-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem 0.8rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ws-perm-group legend {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.3rem;
}

.ws-perm-table {
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ws-perm-table th,
.ws-perm-table td {
  padding: 0.3rem 0.6rem;
  text-align: center;
}

.ws-perm-table tbody th {
  text-align: left;
  font-weight: 400;
  cursor: help;
}

.ws-role-danger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.9rem 1.4rem 1.2rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.ws-role-danger select {
  margin-left: 0.4rem;
}

/* The list of one's workspaces, as cards. */
.ws-home-list {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1rem;
}

.ws-home-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-soft);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ws-home-card:hover {
  border-color: var(--color-brand);
  transform: translateY(-1px);
}

.ws-home-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-brand);
}

.ws-home-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

.ws-home-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* A phone. The header drops the e-mail address, the pages lose their wide margins, the tab
   bar scrolls sideways, and every `.ws-table` becomes a stack of cards: the first cell is the
   card's title, every other cell a line with its column's name (data-label) in front, an empty
   one is left out, the buttons go at the bottom. Inputs are 16px, below which iOS zooms the
   page on focus. */
@media (max-width: 720px) {
  .site-header,
  .site-header.app-header {
    padding: 0.85rem 1rem;
  }

  .header-actions {
    gap: 0.5rem;
    /* Admin's four chips and the account are wider than a phone: they wrap, right-aligned. */
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
  }

  .header-actions .hdr-account {
    padding-right: 0.2rem;
  }

  .header-email {
    display: none;
  }

  .brand img {
    height: 28px;
  }

  .admin-page {
    margin-top: 0.75rem;
    padding: 0 1rem;
  }

  .admin-page h1 {
    font-size: 1.4rem;
  }

  .usage-card {
    padding: 1.1rem;
  }

  .admin-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-tab {
    flex: none;
    padding: 0.6rem 0.7rem;
  }

  .admin-tab-toolbar .admin-hint {
    flex-basis: 100%;
  }

  .admin-filter-input {
    flex: 1 1 100%;
    max-width: none;
  }

  .admin-filter-input,
  .ws-tag-filter select,
  .ws-field input,
  .ws-field select,
  .ws-table input,
  .ws-table select,
  .ws-help-input {
    font-size: 16px;
  }

  .ws-table-wrap {
    overflow: visible;
    border: none;
    border-radius: 0;
    background: none;
    cursor: auto;
  }

  .ws-table,
  .ws-table tbody,
  .ws-table tfoot {
    display: block;
  }

  .ws-table thead {
    display: none;
  }

  .ws-table tr {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg-elevated);
  }

  .ws-table tfoot tr {
    background: var(--color-bg-subtle);
  }

  .ws-table td,
  .ws-table td.admin-cell-prose,
  .ws-table tfoot td {
    display: block;
    position: relative;
    min-width: 0;
    max-width: none;
    padding: 0 0 0 7.25rem;
    border: none;
    background: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .ws-table td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 6.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .ws-table td.ws-cell-main,
  .ws-table td:not([data-label]) {
    padding-left: 0;
  }

  .ws-table td.ws-cell-main {
    font-size: 0.95rem;
  }

  .ws-table td.ws-cell-empty {
    display: none;
  }

  .ws-table td.ws-cell-equation {
    overflow-x: auto;
  }

  .ws-table td.ws-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.3rem;
    text-align: left;
  }

  .ws-table .ws-row-actions .btn + .btn {
    margin-left: 0;
  }

  .ws-table .ws-row-actions .btn {
    padding: 0.55rem 1.2rem;
  }

  .ws-table.tag-table td.tag-table-wide {
    width: auto;
  }

  .ws-table.tag-table input,
  .ws-table.tag-table select,
  .ws-table.tag-table td.tag-table-wide input {
    width: 100%;
    min-width: 0;
  }

  .ws-table .admin-inline-form select {
    width: 100%;
  }

  .ws-uses {
    flex-direction: column;
  }

  .ws-uses li + li::before {
    content: none;
  }

  /* An expander's explanation goes under its title instead of squeezing beside it. */
  .ws-page .doc-expander > summary {
    flex-wrap: wrap;
  }

  .ws-page .doc-expander > summary .field-hint {
    flex-basis: 100%;
    padding-left: 1rem;
  }

  .ws-help-launcher {
    right: 1rem;
    bottom: 1rem;
    padding: 0.45rem;
    font-size: 0;
    gap: 0;
  }

  .ws-help-launcher span {
    width: 2.1rem;
    height: 2.1rem;
    font-size: 1.1rem;
  }
}

/* The guide page (docs/workspace-guide.md). */
.ws-guide-page {
  max-width: 52rem;
  line-height: 1.6;
}

.ws-guide-page table {
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.ws-guide-page th,
.ws-guide-page td {
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}

.ws-guide-page td:not(:first-child) {
  text-align: center;
}

.ws-guide-page hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

.ws-guide-page h1 {
  margin-top: 0.5rem;
}

.ws-guide-page h2 {
  font-size: 1.35rem;
  margin: 2rem 0 0.75rem;
}

.ws-guide-page h3 {
  font-size: 1.08rem;
  margin: 1.5rem 0 0.5rem;
}

/* The admin Library's bulk delete of assistants. */
.library-bulk {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
}

/* /admin/models (templates/admin_models.html, admin_model_edit.html): the model registry.
   A provider heading row inside a table, a row the Requesty catalog no longer lists, and the
   "Where models are used" matrix - per purpose a Standard and an EU-only column, each cell a
   tick (offered) and a radio button (the default). */
.admin-table tr.admin-group-row th {
  background: var(--color-bg-subtle);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.admin-table tr.admin-row-missing td {
  background: color-mix(in srgb, #ef4444 8%, transparent);
}

.model-matrix th.model-matrix-purpose {
  text-align: center;
  border-left: 1px solid var(--color-border);
}

.model-matrix th.model-matrix-res,
.model-matrix td.model-matrix-cell {
  text-align: center;
  padding: 0.4rem 0.5rem;
}

.model-matrix th.model-matrix-res:not(.model-matrix-eu),
.model-matrix td.model-matrix-cell:not(.model-matrix-eu) {
  border-left: 1px solid var(--color-border);
}

.model-matrix .model-matrix-eu {
  background: color-mix(in srgb, #22c55e 6%, transparent);
}

.model-matrix td.model-matrix-cell input {
  margin: 0 0.15rem;
}

.model-matrix td.model-matrix-cell input:disabled {
  opacity: 0.3;
}

.model-matrix-copy {
  display: inline;
}

.admin-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
}

.admin-facts dt {
  color: var(--color-text-muted);
}

.admin-facts dd {
  margin: 0;
}

.admin-table tr.admin-row-variant td {
  border-top: none;
}

.admin-table tr.admin-row-variant td:first-child {
  padding-left: 1.6rem;
}

.admin-report {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

.admin-report li {
  margin: 0.2rem 0;
}

.model-active {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.model-active-state {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* .admin-status sets display, which outranks the UA stylesheet's [hidden] - so the badge the
   Active switch hides needs this, or it shows on every row. */
.model-not-approved[hidden] {
  display: none;
}

/* A model's capabilities on /admin/models, small tags in one cell. */
.admin-cap {
  display: inline-block;
  margin: 0 0.25rem 0.2rem 0;
  padding: 0 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* The chat's model picker: the (i) popover beside it and the note on what a model can't do. */
.model-info-wrap {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  margin-left: -0.4rem;
}
@media (max-width: 768px) {
  .chat-topbar-btn span { display: none; } /* icon only on a phone: the model name needs the room */
  .chat-topbar-btn .items-panel-btn-count { display: inline; } /* a number, not a label */
}
.model-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.model-info-btn[hidden] { display: none; }
.model-info-btn:hover,
.model-info-btn[aria-expanded="true"] {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}
.model-info-btn .icon { width: 1.15rem; height: 1.15rem; }
.model-info {
  position: fixed; /* top and right set from the button by app.js */
  z-index: 40;
  width: min(22rem, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lift);
  font-size: 0.875rem;
  line-height: 1.45;
}
.model-info[hidden] { display: none; }
.model-info-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.4rem;
  font-size: 1rem;
}
.model-info-eu,
.model-info-strengths span {
  display: inline-block;
  padding: 0 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--color-text-muted);
}
.model-info-eu { border-color: var(--color-brand); color: var(--color-brand); }
.model-info-description { margin: 0 0 0.5rem; }
.model-info-strengths { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0 0 0.6rem; }
.model-info-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  margin: 0 0 0.6rem;
}
.model-info-facts dt { color: var(--color-text-muted); }
.model-info-facts dd { margin: 0; }
.model-info-note { margin: 0; color: var(--color-text-muted); font-size: 0.8rem; }
.model-info-eu-toggle {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--color-border);
}
.model-info-eu-toggle label { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.model-info-eu-toggle .model-info-note { margin-top: 0.25rem; }
/* Beside the picker while a chat runs in the EU only. */
/* "Auto (estimated)" left of the model list: on, Auto picks the model per message and the
   list is greyed - it is what answers again once Auto is off. */
.auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.auto-toggle[hidden] { display: none; }

.auto-toggle + .model-select {
  margin-left: 0;
}

.auto-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auto-toggle-track {
  position: relative;
  width: 1.9rem;
  height: 1.05rem;
  border-radius: 999px;
  background: var(--color-border);
  transition: background 0.15s;
}

.auto-toggle-thumb {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.auto-toggle[aria-checked="true"] {
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.auto-toggle[aria-checked="true"] .auto-toggle-track {
  background: var(--color-brand);
}

.auto-toggle[aria-checked="true"] .auto-toggle-thumb {
  transform: translateX(0.85rem);
}

.model-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.eu-badge {
  flex-shrink: 0;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-md);
  color: var(--color-brand);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: default;
}
.eu-badge[hidden] { display: none; }
.chat-model-note {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.chat-model-note[hidden] { display: none; }
.chat-topbar-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* /usage: a row naming who made the models below it, once there is more than one maker. */
.usage-group-row th {
  padding-top: 0.75rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
}

/* The composer's image mode (static/app.js setImageMode): the Image button lit while it is on,
   and a row of its settings above the input. */
.chat-composer-tools .chat-image-btn.is-active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}
.chat-composer-tools .chat-image-btn[hidden] { display: none; }
/* "Plan it first" (static/app.js applyPlanButton): lit while the next message asks for a plan. */
.chat-composer-tools .chat-plan-btn.is-active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-on-primary);
}
.chat-composer-tools .chat-plan-btn[hidden] { display: none; }

/* Dictation (static/app.js startRecording): red with the running time while it listens,
   pulsing while the words are turned into text. */
.chat-composer-tools .chat-mic-btn[hidden] { display: none; }
.chat-composer-tools .chat-mic-btn.is-recording {
  width: auto;
  padding: 0 0.6rem;
  gap: 0.3rem;
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}
.chat-composer-tools .chat-mic-btn.is-busy { animation: chat-mic-busy 1.2s ease-in-out infinite; }
.chat-composer-tools .chat-mic-btn:disabled { cursor: progress; }
.chat-mic-time { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.chat-mic-time:empty { display: none; }
@keyframes chat-mic-busy { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .chat-composer-tools .chat-mic-btn.is-busy { animation: none; opacity: 0.6; }
}
/* Dictation everywhere else (static/dictation.js, plans/plan-feedback-task-1.md §8): the same
   microphone beside the builder, the start page, Build with AI, the helper and the feedback
   dialog - quiet until it records, then red with the running time like the chat's. */
.dict-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.dict-btn[hidden] { display: none; }
.dict-btn .icon { width: 1.15rem; height: 1.15rem; }
.dict-btn:hover { background: var(--color-bg-subtle); color: var(--color-text); }
.dict-btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 1px; }
.dict-btn.is-recording { padding: 0 0.6rem; background: #c62828; border-color: #c62828; color: #fff; }
.dict-btn.is-busy { animation: chat-mic-busy 1.2s ease-in-out infinite; }
.dict-btn:disabled { cursor: progress; }
.dict-time { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.dict-time:empty { display: none; }
@media (prefers-reduced-motion: reduce) {
  .dict-btn.is-busy { animation: none; opacity: 0.6; }
}
/* In a text box's bottom-right corner: the box keeps room for it on the right. */
.dict-field { position: relative; display: block; }
.dict-field > textarea { display: block; width: 100%; box-sizing: border-box; padding-right: 2.75rem; }
.dict-field > .dict-btn { position: absolute; right: 0.3rem; bottom: 0.3rem; }

/* A recording's chip while it is transcribed. */
.chat-transcript-item.is-working { opacity: 0.7; font-style: italic; }
/* A transcript's download menu, on its chip and beside a sent one. */
.chat-transcript-download { margin-left: 0; padding: 0.05rem 0.25rem; }
.chat-image-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  margin-bottom: 0.4rem;
}
.chat-image-options[hidden] { display: none; }
.chat-image-options .model-select { max-width: 100%; }
.chat-image-options .model-select[hidden] { display: none; }
.chat-image-options-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-brand);
}
.chat-image-options-note {
  flex-basis: 100%;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* A picture a reply carries, and the one a request changes. */
.message-image {
  margin: 0;
  max-width: min(100%, 512px);
}
.message-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.message-image figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
}
.message-image figcaption a.btn-quiet { text-decoration: none; }
.message-image-label {
  color: var(--color-text-muted);
  margin-right: auto;
}
.message-image-thumb {
  display: block;
  max-width: 160px;
  max-height: 160px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: 0.4rem;
}
.message-image-meta {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  opacity: 0.8;
}
.chat-image-options .model-select { margin-left: 0; }
.chat-image-options #image-model { max-width: 22rem; }

/* The × on a queued file or picture: `.chat-form button` (the Send button's look) comes later
   in this file and would otherwise win. */
.chat-form .chat-attachment-item button {
  height: auto;
  padding: 0.1rem 0.3rem;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 1rem;
}
.chat-form .chat-attachment-item button:hover {
  transform: none;
  color: var(--color-text);
}

/* The chat on a phone: every pixel of width to the text, finger-sized targets, and nothing
   that makes iOS zoom in. */
@media (max-width: 768px) {
  /* Model and format side by side, wrapping only when the quality joins them. */
  .chat-image-options #image-model { flex: 2 1 11rem; max-width: 100%; min-width: 0; }
  .chat-image-options #image-shape,
  .chat-image-options #image-quality { flex: 1 1 6.5rem; min-width: 0; }
  .chat-image-options-note { font-size: 0.75rem; }

  .chat-form {
    padding: 0.4rem 0.6rem max(0.6rem, env(safe-area-inset-bottom));
  }
  /* iOS zooms the page into any text field under 16px on focus, and doesn't zoom back. */
  .chat-composer textarea { font-size: 16px; }
  .chat-composer-tools .chat-attach-btn,
  .chat-form .chat-send-btn { width: 2.5rem; height: 2.5rem; }
  .chat-composer-bar { padding: 0 0.35rem 0.35rem; }

  .messages {
    padding: 1rem 0.75rem 0.5rem;
  }
  .message { padding: 0.65rem 0.85rem; }

  .chat-topbar {
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
  }
  .chat-topbar-btn {
    flex-shrink: 0;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    padding: 0;
  }
  /* The list and Auto become one button opening the model sheet. */
  .chat-topbar #model-select,
  .chat-topbar .auto-toggle { display: none; }
  .chat-topbar .model-sheet-btn { display: inline-flex; }

  .message-action { width: 2.3rem; height: 2.3rem; }
  .message-sources-label { display: none; }
}

@media (max-width: 480px) {
  /* The name is in the sidebar; a crowded bar needs its room for the controls. */
  .chat-topbar:has(#formula-panel-btn:not([hidden]), #forms-panel-btn:not([hidden]), #conversation-download:not([style*="none"])) .chat-topbar-title {
    display: none;
  }
}

/* Auto (estimated)'s settings on Admin > Models > Settings: one row of their own. */
.admin-auto-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  flex-basis: 100%;
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.admin-auto-settings legend {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 0.3rem;
}

.admin-auto-settings label.admin-inline-wide {
  flex-basis: 100%;
}

.admin-auto-settings textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  resize: vertical;
}

/* The Settings tab of /admin/models: a section nav on the left, the sections as cards on the
   right, one form with a save bar that stays in view. Fields are a grid of label / input with
   its unit / default and range. */
.settings-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.settings-toc {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.88rem;
}

.settings-toc a {
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  text-decoration: none;
}

.settings-toc a:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.settings-section {
  scroll-margin-top: 1rem;
}

.settings-section h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.settings-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.settings-intro {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  max-width: 75ch;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.1rem 1.5rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.settings-field-wide {
  grid-column: 1 / -1;
}

.settings-label {
  font-weight: 500;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-field input,
.settings-field select,
.settings-field textarea {
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
}

.settings-control input {
  width: 120px;
}

.settings-field-wide input,
.settings-field textarea {
  width: 100%;
  max-width: 60rem;
}

.settings-field textarea {
  font-size: 0.82rem;
  resize: vertical;
}

.settings-unit,
.settings-default {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.settings-warn,
.settings-warn-static {
  color: #ea700b;
  font-size: 0.8rem;
}

@media (prefers-color-scheme: dark) {
  .settings-warn,
  .settings-warn-static {
    color: #fb923c;
  }
}

.settings-status {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.6rem 1.5rem;
  font-size: 0.88rem;
}

.settings-status li {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}

.settings-status strong {
  white-space: nowrap;
}

.settings-status-detail {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-more {
  margin-top: 1rem;
}

.settings-more summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.settings-savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lift);
}

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

@media (max-width: 860px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* "Where models are used" (admin_models.html): a row per feature, per column a default and
   the models also offered. */
.model-uses th.mu-feature {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
  color: var(--color-text);
  min-width: 14rem;
  max-width: 22rem;
  white-space: normal;
  vertical-align: top;
  text-align: left;
}

.mu-name {
  display: block;
  font-weight: 600;
}

.mu-note {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.model-uses td.mu-cell {
  vertical-align: top;
  min-width: 18rem;
}

.mu-line,
.mu-alts {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  align-items: start;
  gap: 0.5rem;
}

.mu-alts {
  margin-top: 0.45rem;
}

.mu-label {
  padding-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.mu-cell select {
  max-width: 100%;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
}

.mu-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.mu-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.2rem 0.15rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-subtle);
  font-size: 0.8rem;
}

.mu-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 0.3rem;
  border-radius: 999px;
}

.mu-chip-remove:hover {
  color: var(--color-text);
  background: var(--color-border);
}

.mu-cell select.mu-add {
  color: var(--color-text-muted);
}

.mu-twins {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.model-transfer {
  margin-top: 1.5rem;
}

.model-transfer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 0.75rem;
}

.model-import-report {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.model-import-report ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
  word-break: break-word;
}

/* ---------- Best match (app/ai/best_match.py) and hand-overs (app/chat/handover.py) ---------- */

/* The sidebar's first entry, set apart from the named assistants by its mark and a hairline. */
.best-match-item {
  padding-bottom: 0.35rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--color-border);
}

.best-match-mark {
  color: var(--color-accent);
  margin-right: 0.2rem;
}

.best-match-intro {
  max-width: 34rem;
  margin: 12vh auto 0;
  padding: 1.5rem 1.75rem;
  text-align: center;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.best-match-intro h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.best-match-intro p {
  margin: 0.4rem 0 0;
}

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

.best-match-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.9rem 0 0.4rem;
}

.best-match-list h3 {
  margin: 0.9rem 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.best-match-choice {
  padding: 0.35rem 0;
}

.best-match-mode {
  margin: 1.1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.best-match-mode legend {
  font-weight: 700;
  padding: 0 0.3rem;
}

.best-match-recommended {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent-dark);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.4rem;
}

/* The history search, across every assistant. */
.history-search {
  width: 100%;
  margin: 0.35rem 0 0.4rem;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-sizing: border-box;
}

.history-search-note {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.history-search-note[hidden] { display: none; }

.conversation-btn-thread {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  white-space: normal;
}

.conversation-btn-thread.active {
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-soft);
}

.conversation-title,
.conversation-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.conversation-snippet {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result mark,
.conversation-title mark {
  background: color-mix(in srgb, var(--color-accent) 30%, transparent);
  color: inherit;
  border-radius: 2px;
}

.conversation-thread-btn {
  font-size: 0.85rem;
}

/* A thread's timeline: a divider wherever the work moved to another assistant. */
.thread-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.thread-divider::before,
.thread-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border);
}

.thread-divider-handover {
  color: var(--color-accent-dark);
}

/* Above the composer under Best match: which assistant the next message goes to. */
.thread-target {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.thread-target[hidden] { display: none; }

.thread-target .model-select {
  font-size: 0.78rem;
  padding: 0.15rem 0.4rem;
}

.handover-card {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  border-left: 3px solid var(--color-accent);
  background: var(--color-bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.handover-card-head {
  font-weight: 700;
}

.handover-card-items {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
  color: var(--color-text-muted);
}

.handover-card details {
  margin-top: 0.3rem;
}

.handover-card summary {
  cursor: pointer;
  color: var(--color-text-muted);
}

.handover-card details p {
  margin: 0.3rem 0 0;
  white-space: pre-wrap;
}

.handed-over-to {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.message-best {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.4rem;
}

.message-best .message-auto-info {
  flex-basis: 100%;
  margin-top: 0;
}

.message-best-unsure {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.message-best-other {
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
}

.message-suggestion .message-content {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}

.message-suggestion .message-content p {
  margin: 0 0 0.45rem;
}

.suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.handover-items {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  margin: 0;
}

.handover-items .form-choice span {
  overflow-wrap: anywhere;
}

.message-found {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: var(--radius-md);
  transition: outline-color 0.6s ease;
}

/* `.chat-form button` is the Send button's look; the line above the composer wants quiet ones. */
.chat-form .thread-target button {
  height: auto;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: none;
  box-shadow: none;
  color: var(--color-brand);
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: underline;
}
.chat-form .thread-target button:hover {
  transform: none;
  color: var(--color-accent-dark);
}

/* The hand-over dialog borrows the assistant form: its ticks sit beside their text, and the
   brief and message are prose, not prompts. */
.assistant-form .handover-items .form-choice {
  flex-direction: row;
  align-items: baseline;
  font-weight: 400;
}
.assistant-form #handover-brief,
.assistant-form #handover-message {
  font-family: inherit;
  font-size: 0.9rem;
}

/* In the user's own (dark) bubble the hand-over card takes the bubble's colours. */
.message-user .handover-card {
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
}
.message-user .handover-card-items,
.message-user .handover-card summary {
  color: rgba(255, 255, 255, 0.78);
}

/* --- Model comparisons (/admin/models/compare) ------------------------------------------- */
.compare-crumbs { margin: 0 0 0.5rem; }
.compare-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.compare-effort { display: inline-flex; align-items: center; margin-right: 0.6rem; white-space: nowrap; }
#compare-model-filter { min-width: 14rem; }
.compare-test-list { list-style: none; margin: 0.25rem 0 0; padding: 0; display: grid; gap: 0.2rem; }
.compare-test-list label { display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.compare-task > summary { display: flex; align-items: center; gap: 0.35rem; }
.compare-weight {
  font-size: 0.75rem; padding: 0 0.4rem; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); color: var(--color-text-muted); white-space: nowrap;
}
.compare-weight-high, .compare-weight-very-high { color: var(--color-accent); border-color: var(--color-accent); }
.compare-difficulty { font-size: 0.75rem; padding: 0 0.35rem; margin-left: 0.25rem; border-radius: var(--radius-md); background: var(--color-bg-subtle); color: var(--color-text-muted); }
.compare-difficulty-hard, .compare-difficulty-very-hard { color: var(--color-text); font-weight: 600; }
.compare-tag { font-size: 0.75rem; color: var(--color-text-muted); background: var(--color-bg-subtle); padding: 0 0.35rem; border-radius: var(--radius-md); }
.compare-estimate-list { margin: 0.25rem 0 0.5rem 1rem; padding: 0; }
.compare-grid td .admin-status { margin: 0 0.25rem 0.15rem 0; display: inline-block; }
.compare-results tr.compare-best td:first-child { box-shadow: inset 3px 0 0 var(--color-brand); }
.compare-cases td { vertical-align: top; }
.compare-case-detail > td { padding-top: 0; border-top: none; }
.compare-answer { border-left: 2px solid var(--color-border); padding-left: 0.6rem; margin: 0.4rem 0; }
.compare-answer p { margin: 0.15rem 0; }
.compare-output { white-space: pre-wrap; max-height: 18rem; overflow: auto; }
#compare-test-filter { min-width: 16rem; }
.model-uses tr.mu-preselected > th { box-shadow: inset 3px 0 0 var(--color-accent); }

/* --- The model sheet: the chat's model picker on a phone (app.js renderModelSheet) -------- */

.model-sheet-btn {
  display: none; /* shown by the phone rules, in place of the list and the Auto switch */
  align-items: center;
  gap: 0.2rem;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  padding: 0.4rem 0.45rem 0.4rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.model-sheet-btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-sheet-btn.is-auto {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.model-sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: none;
  max-height: 85dvh;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-lift);
}

.model-sheet[open] {
  display: flex;
  flex-direction: column;
  animation: model-sheet-up 0.2s ease-out;
}

.model-sheet::backdrop {
  background: rgba(13, 22, 27, 0.45);
}

@keyframes model-sheet-up {
  from { transform: translateY(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .model-sheet[open] { animation: none; }
}

.model-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem 0.4rem;
}

.model-sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.model-sheet-body {
  overflow-y: auto;
  padding: 0.25rem 0.6rem max(1rem, env(safe-area-inset-bottom));
}

.model-sheet-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.model-sheet-row[hidden] {
  display: none;
}

.model-sheet-row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.model-sheet-row.is-selected {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 8%, transparent);
}

.model-sheet-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.model-sheet-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.model-sheet-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.model-sheet-rates {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.model-sheet-auto {
  margin-bottom: 0.25rem;
}

.model-sheet-maker {
  margin: 0.9rem 0.75rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.model-sheet-note {
  margin: 0.75rem 0.75rem 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ---------- The side panel: calculations, outputs and files of a chat -------------------
   (static/app.js renderItemsPanel.) The conversation keeps chips (.item-chip); the cards are
   in the panel - docked beside the chat from 1100px, a drawer over it below that, a sheet
   over everything on a phone. */

.message-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.55rem 0 0.2rem;
}

.message-items-files {
  margin: 0 0 0.45rem;
}

.item-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  min-height: 2rem;
  padding: 0.25rem 0.7rem 0.25rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--color-brand) 30%, var(--color-border));
  border-radius: 999px;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.item-chip:hover {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 7%, var(--color-bg-elevated));
}

.item-chip .icon {
  flex-shrink: 0;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--color-brand);
}

.item-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.item-chip-value {
  flex-shrink: 0;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 0.45rem;
  border-left: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Calculations folded into one chip: present, but behind the outputs. */
.item-chip-quiet {
  border-color: var(--color-border);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
}

.item-chip-quiet .item-chip-text {
  font-weight: 500;
}

.item-chip-pass .item-chip-value { color: #15803d; font-weight: 600; }
.item-chip-fail .item-chip-value { color: #dc2626; font-weight: 600; }
.item-chip-fail { border-color: color-mix(in srgb, #dc2626 45%, var(--color-border)); }

/* In the user's own bubble the chips take its colours. */
.message-user .item-chip {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
  color: inherit;
}

.message-user .item-chip:hover {
  background: rgba(255, 255, 255, 0.24);
}

.message-user .item-chip .icon,
.message-user .item-chip-value {
  color: inherit;
}

.items-panel-btn .items-panel-btn-count {
  min-width: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--color-brand);
  color: var(--color-bg-elevated);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}

.items-panel-btn[aria-expanded="true"] {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 10%, var(--color-bg-elevated));
}

.items-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
}

.items-panel[hidden] {
  display: none;
}

.items-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.items-tabs {
  display: flex;
  flex: 1;
  gap: 0.25rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.items-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.items-tab[hidden] {
  display: none;
}

.items-tab:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

.items-tab[aria-selected="true"] {
  color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 10%, var(--color-bg-elevated));
  border-color: color-mix(in srgb, var(--color-brand) 30%, transparent);
}

.items-tab .icon {
  width: 1rem;
  height: 1rem;
}

.items-tab-count {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.items-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* KaTeX's hidden MathML is positioned; keep it inside the scrolling body. */
  position: relative;
  padding: 0.9rem 1rem 1.5rem;
}

.items-panel-flash .items-card {
  animation: items-flash 0.9s ease;
}

@keyframes items-flash {
  from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 55%, transparent); }
  to { box-shadow: 0 0 0 3px transparent; }
}

.items-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.items-nav-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  cursor: pointer;
}

.items-nav-step:hover:not(:disabled) {
  border-color: var(--color-brand);
}

.items-nav-step:disabled {
  opacity: 0.35;
  cursor: default;
}

.items-nav-step .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.items-nav-select {
  flex: 1;
  min-width: 0;
  height: 2.1rem;
  padding: 0 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  text-overflow: ellipsis;
}

.items-nav-position {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.items-group {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* In the panel a card is the page: no scroll box of its own, the name on a line to itself. */
.items-card.form-output-card .form-output-body {
  max-height: none;
  overflow: visible;
}

.items-card .form-output-head {
  flex-wrap: wrap;
  row-gap: 0.35rem;
  padding: 0.5rem 0.75rem 0.55rem 0.4rem;
}

.items-card .form-output-toggle {
  flex: 1 1 100%;
  cursor: default;
}

.items-card .form-output-head > :nth-child(2) {
  margin-left: 0.5rem;
}

.items-card .form-output-head > .message-download-select {
  margin-left: auto;
}

.items-version-select {
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.78rem;
}

.items-older-note {
  margin: 0;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.items-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.6rem;
}

.items-locate {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.items-locate .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.items-files {
  list-style: none;
  margin: 0;
  padding: 0;
}

.items-files .items-group {
  margin: 1rem 0 0.4rem;
}

.items-files .items-group:first-child {
  margin-top: 0;
}

.items-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.items-file-current {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px var(--color-brand);
}

.items-file-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 14rem;
  min-width: 0;
}

.items-file-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--color-brand);
}

.items-file-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.items-file .message-image-thumb {
  flex-shrink: 0;
  width: 2.6rem;
  height: 2.6rem;
  max-width: none;
  margin: 0;
  object-fit: cover;
  border-radius: 6px;
}

.items-file-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.items-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 500;
}

.items-file-meta {
  font-size: 0.76rem;
  color: var(--color-text-muted);
}

.items-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.items-file-actions .btn-sm {
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
}

.items-panel-resize {
  display: none;
}

/* Docked: a column of its own, the chat narrows beside it. */
@media (min-width: 1100px) {
  .items-panel {
    position: relative;
    flex-shrink: 0;
    width: var(--items-width, clamp(380px, 34vw, 640px));
    max-width: 62vw;
  }

  .items-panel-resize {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    width: 8px;
    z-index: 2;
    cursor: col-resize;
    touch-action: none;
  }

  .items-panel-resize:hover,
  .items-resizing .items-panel-resize {
    background: color-mix(in srgb, var(--color-brand) 35%, transparent);
  }

  .items-resizing {
    cursor: col-resize;
    user-select: none;
  }
}

/* A tablet: a drawer over the right of the chat. */
@media (min-width: 769px) and (max-width: 1099px) {
  .items-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    width: min(540px, 88%);
    box-shadow: var(--shadow-lift);
  }
}

/* A phone: a sheet over everything, the close button where a thumb reaches it. */
@media (max-width: 768px) {
  .items-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--app-height, 100dvh);
    z-index: 45;
    border-left: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .items-panel-head {
    padding: 0.6rem 0.6rem 0.5rem 0.75rem;
  }

  .items-tab-label {
    display: none;
  }

  .items-tab[aria-selected="true"] .items-tab-label {
    display: inline;
  }

  .items-panel-body {
    padding: 0.75rem 0.75rem 1.5rem;
  }

  .item-chip-value {
    max-width: 9rem;
  }
}

@media (prefers-color-scheme: dark) {
  .item-chip-pass .item-chip-value { color: #4ade80; }
  .item-chip-fail .item-chip-value { color: #f87171; }
}

/* ---------- Feedback: the chat's dialog, the admin Inbox and the planner (plan-feedback.md) ---------- */

button.sidebar-footer-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.feedback-comment-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Under a rated reply's bar (a flex row): a line of its own. */
.message-feedback > .feedback-comment-note {
  width: 100%;
  padding-left: 0.4rem;
}

.feedback-dialog {
  width: min(34rem, calc(100vw - 2rem));
}

.feedback-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feedback-dialog-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.feedback-fields,
.feedback-sent {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.feedback-fields[hidden],
.feedback-sent[hidden] {
  display: none;
}

.feedback-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: none;
}

.feedback-kinds legend {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.feedback-kind input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.feedback-kind span {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--color-bg);
}

.feedback-kind input:checked + span {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 14%, var(--color-bg-elevated));
  color: var(--color-brand);
  font-weight: 600;
}

.feedback-kind input:focus-visible + span {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.feedback-dialog textarea {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  resize: vertical;
}

.feedback-pictures {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.feedback-pictures .field-hint {
  flex-basis: 100%;
  margin: 0;
}

.feedback-picture-list {
  display: flex;
  gap: 0.5rem;
}

.feedback-picture {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
}

.feedback-picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.feedback-picture-remove {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  line-height: 1;
  cursor: pointer;
}

.feedback-picture-add {
  cursor: pointer;
}

.feedback-conversation {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.88rem;
}

.feedback-conversation .field-hint {
  display: block;
}

.feedback-conversation[hidden] {
  display: none;
}

/* The admin nav's unread count, and the Inbox tab's. */
.admin-nav-badge {
  display: inline-block;
  min-width: 1.3em;
  padding: 0 0.4em;
  margin-left: 0.2rem;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
  vertical-align: 1px;
}

.admin-nav-badge[hidden] {
  display: none;
}

.fbk-filters {
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.fbk-state {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.fbk-state-link {
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.fbk-state-link.active {
  background: var(--color-brand);
  color: #fff;
}

.fbk-check {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.85rem;
}

.fbk-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}

.fbk-bulk select,
.fbk-filters select,
.fbk-item-actions select {
  max-width: min(100%, 22rem);
}

.fbk-bulk-count {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-right: 0.25rem;
}

.fbk-bulk-all {
  margin-left: auto;
}

.fbk-inbox {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 1100px) {
  .fbk-inbox:has(.fbk-detail:not([hidden])) {
    grid-template-columns: minmax(0, 1.5fr) minmax(24rem, 1fr);
  }
}

.fbk-detail {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.fbk-item-page .fbk-detail {
  position: static;
  max-height: none;
  max-width: 60rem;
}

.fbk-col-check {
  width: 2rem;
}

.fbk-row {
  cursor: pointer;
}

.fbk-row.fbk-selected td {
  background: var(--color-bg-subtle);
}

.fbk-when {
  white-space: nowrap;
}

.fbk-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  vertical-align: 1px;
}

.fbk-unread .fbk-dot {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.fbk-unread .fbk-text a {
  font-weight: 600;
}

.fbk-text {
  min-width: 16rem;
}

.fbk-text a {
  color: inherit;
  text-decoration: none;
}

.fbk-text a:hover {
  text-decoration: underline;
}

.fbk-kind {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
}

.fbk-kind-up { background: color-mix(in srgb, #2e9d5b 18%, transparent); color: #2e9d5b; }
.fbk-kind-down,
.fbk-kind-bug { background: color-mix(in srgb, #d0453b 16%, transparent); color: #d0453b; }
.fbk-kind-feature { background: color-mix(in srgb, #2a78d6 16%, transparent); color: #2a78d6; }

.fbk-pages {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.75rem;
}

.fbk-item h3 {
  font-size: 0.9rem;
  margin: 1.1rem 0 0.4rem;
}

.fbk-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.fbk-item-page .fbk-item-close {
  display: none;
}

.fbk-item-close {
  font-size: 1.4rem;
  text-decoration: none;
  line-height: 1;
}

.fbk-item-user {
  margin: 0.4rem 0;
}

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

.fbk-verbatim {
  white-space: pre-wrap;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--color-brand);
  background: var(--color-bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.fbk-md {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  overflow-x: auto;
}

.fbk-md > :first-child { margin-top: 0; }
.fbk-md > :last-child { margin-bottom: 0; }

.fbk-detail .fbk-md {
  max-height: 24rem;
  overflow-y: auto;
}

.fbk-pictures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.fbk-pictures img {
  max-width: 12rem;
  max-height: 9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.fbk-sources {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

.fbk-context {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 0.8rem;
  font-size: 0.85rem;
  margin: 0;
}

.fbk-context dt {
  color: var(--color-text-muted);
}

.fbk-context dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.fbk-conversation {
  list-style: none;
  padding: 0;
  max-width: 60rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fbk-msg-head {
  margin: 0 0 0.3rem;
}

.fbk-msg-user .fbk-md {
  background: var(--color-bg-subtle);
}

.fbk-msg-rated .fbk-md {
  border-color: var(--color-accent);
  border-width: 2px;
}

/* The planner */
.planner-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.planner-toolbar input[type="search"] {
  min-width: 14rem;
}

.planner-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(15rem, 1fr));
  gap: 1rem;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.planner-column {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  min-height: 12rem;
}

.planner-column-head {
  font-size: 0.95rem;
  margin: 0 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.planner-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-bg-elevated);
  border-radius: 999px;
  padding: 0 0.45rem;
}

.planner-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 6rem;
}

.planner-empty {
  margin: 0.5rem 0;
}

.planner-card {
  position: relative;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(27, 42, 50, 0.05);
}

.planner-card:hover,
.planner-card:focus-visible {
  border-color: var(--color-brand);
  outline: none;
}

.planner-priority-low { border-left-color: var(--color-border); }
.planner-priority-normal { border-left-color: #2a78d6; }
.planner-priority-high { border-left-color: var(--color-accent); }
.planner-priority-urgent { border-left-color: #d0453b; }

.planner-dragging {
  opacity: 0.4;
}

.planner-placeholder {
  height: 2.5rem;
  border: 2px dashed var(--color-brand);
  border-radius: var(--radius-md);
}

.planner-card-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
}

.planner-card-id {
  font-weight: 700;
  color: var(--color-text-muted);
}

.planner-kind,
.planner-prio {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-weight: 600;
}

.planner-kind-bug { color: #d0453b; background: color-mix(in srgb, #d0453b 14%, transparent); }
.planner-kind-feature { color: #2a78d6; background: color-mix(in srgb, #2a78d6 14%, transparent); }
.planner-prio-high { color: var(--color-accent); }
.planner-prio-urgent { color: #fff; background: #d0453b; }

.planner-card-menu {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.planner-card-menu:hover,
.planner-card-menu:focus-visible {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.planner-card-title {
  margin: 0.3rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.planner-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.planner-labels {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.planner-label {
  padding: 0 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.planner-brief-failed {
  color: #d0453b;
}

.planner-menu {
  position: absolute;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  padding: 0.3rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
}

.planner-menu button {
  text-align: left;
  border: none;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: 0.88rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.planner-menu button:hover,
.planner-menu button:focus-visible {
  background: var(--color-bg-subtle);
  outline: none;
}

.planner-older {
  margin-top: 0.75rem;
}

.planner-dialog {
  width: min(70rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-lift);
}

.planner-dialog::backdrop {
  background: rgba(13, 22, 27, 0.45);
}

.planner-dialog-small {
  width: min(36rem, calc(100vw - 2rem));
}

.planner-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.25rem 1.4rem;
}

.planner-form h2 {
  margin: 0;
  font-size: 1.15rem;
}

.planner-form label,
.planner-side label,
.planner-note {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.planner-form input,
.planner-form select,
.planner-form textarea,
.planner-dialog input,
.planner-dialog select,
.planner-dialog textarea {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 400;
}

.planner-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.6rem;
}

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

.planner-form-actions {
  justify-content: flex-end;
}

.planner-actions {
  margin-top: 0.8rem;
}

.planner-dialog-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.planner-title-input {
  flex: 1;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
}

.planner-close {
  font-size: 1.5rem;
  text-decoration: none;
}

.planner-dialog-body {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem 1.25rem 1.25rem;
}

.planner-side {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.planner-side .btn-danger {
  align-self: flex-start;
}

.planner-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.8rem;
}

.planner-tab {
  border: none;
  background: none;
  padding: 0 0 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}

.planner-tab[aria-selected="true"] {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.planner-tab-body textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

.planner-md {
  font-size: 0.9rem;
  overflow-x: auto;
}

.planner-md h2 { font-size: 1.1rem; margin: 0 0 0.4rem; }
.planner-md h3 { font-size: 0.95rem; margin: 1rem 0 0.3rem; }

.planner-writing {
  color: var(--color-brand);
  font-weight: 600;
}

.planner-fb {
  border-top: 1px solid var(--color-border);
  padding-top: 0.6rem;
  margin-top: 0.6rem;
}

.planner-fb-head {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
}

.planner-fb-actions {
  margin: 0.3rem 0 0;
}

.planner-file {
  margin-right: 0.6rem;
  font-size: 0.85rem;
}

.planner-copy-area {
  position: fixed;
  left: -9999px;
}

@media (max-width: 900px) {
  .planner-board {
    grid-template-columns: repeat(4, minmax(15rem, 80vw));
  }

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

/* ===== The simple view (plans/plan-assistant-builder.md §2) =============================
   The workspace's home as tiles, and an assistant's project page in tiles with a drawer
   behind each card (static/assistant-project.js). Prefix `prj-`. */

/* The workspace's own cards under its name: Members, Tags, where work runs (a switch), how it
   works. Smaller than the assistant tiles - they are about the workspace, not its work. */
.prj-ws-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0;
}

/* A notice or banner right under the cards (a company past due, support access) - not flush. */
.prj-ws-cards + .admin-flash {
  margin-top: 1rem;
}

.prj-tile.prj-ws-card {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  min-height: 0;
  padding: 0.8rem 1rem;
}

.prj-ws-card-icon {
  flex-shrink: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.prj-ws-card-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.prj-ws-card .prj-tile-title {
  font-size: 0.95rem;
}

.prj-ws-card-sub {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.prj-ws-card.is-static {
  cursor: default;
}

.prj-ws-card.is-static:hover {
  transform: none;
}

/* A switch drawn as one: the track and its knob, at the card's right. */
.prj-toggle {
  position: relative;
  flex-shrink: 0;
  width: 2.4rem;
  height: 1.35rem;
  margin-left: auto;
  border-radius: 999px;
  background: var(--color-border);
  transition: background 0.15s;
}

.prj-toggle span {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.prj-toggle.is-on {
  background: var(--color-brand);
}

.prj-toggle.is-on span {
  transform: translateX(1.05rem);
}

.prj-ws-eu.is-on {
  border-color: var(--color-brand);
}

/* "How this workspace works" in the panel: the steps and the two columns, stacked when the
   panel is narrow. */
.ws-guide-module {
  font-size: 0.88rem;
  line-height: 1.5;
}

.ws-guide-module .ws-guide-full {
  margin-top: 1.5rem;
}

@container wspanel (max-width: 700px) {
  .ws-guide-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.prj-section {
  margin-top: 1.75rem;
}

.prj-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: 0.8rem;
}

.prj-section-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.prj-section-head .admin-filter-input {
  margin-left: auto;
}

.prj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.9rem;
}

/* A tile is a link or a button; the [hidden] rule is needed because the class sets display. */
.prj-tile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  min-height: 8.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.prj-tile[hidden] {
  display: none;
}

.prj-tile:hover,
.prj-tile:focus-visible {
  border-color: var(--color-brand);
  transform: translateY(-1px);
}

.prj-tile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem 0.5rem;
}

/* A long name or a long status pill ("Live in this workspace", longer translated) wraps
   inside the tile: the pill drops under the name rather than running past the border. */
.prj-tile-head > .prj-tile-title {
  flex: 1 1 8rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.prj-tile-head > .prj-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prj-tile-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
}

.prj-tile-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

.prj-tile-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  margin-top: auto;
  font-size: 0.78rem;
}

.prj-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.4rem;
}

.prj-counts span + span::before {
  content: "\00b7";
  margin-right: 0.4rem;
  color: var(--color-text-muted);
}

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

.prj-warn {
  color: var(--color-accent-dark);
}

.prj-new-tile {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  box-shadow: none;
  background: transparent;
  color: var(--color-brand);
}

.prj-new-plus {
  font-size: 2rem;
  line-height: 1;
  font-weight: 300;
}

.prj-retired {
  margin-top: 1rem;
}

.prj-library-grid {
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}

.prj-library-tile {
  flex-direction: row;
  align-items: center;
  min-height: 0;
  gap: 0.75rem;
}

.prj-library-icon {
  font-size: 1.3rem;
  color: var(--color-brand);
}

.prj-library-count {
  margin-left: auto;
  font-weight: 700;
  color: var(--color-text-muted);
}

/* Status pills: a draft, live here, live for everyone, retired. */
.prj-pill {
  flex-shrink: 0;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
}

.prj-pill-live {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.prj-pill-everyone {
  background: rgba(42, 120, 214, 0.14);
  color: #1f5fae;
}

.prj-pill-draft {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
}

@media (prefers-color-scheme: dark) {
  .prj-pill-live { color: #4ade80; }
  .prj-pill-everyone { color: #7cb4f2; }
  .prj-pill-draft { color: #fbbf24; }
}

/* --- the project page --- */

.prj-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.prj-topline .ws-crumbs {
  margin-bottom: 0;
}

.prj-head-wrap {
  margin: 1rem 0 1.25rem;
}

.prj-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

.prj-head-titles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  min-width: 0;
}

.admin-page .prj-head h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

.prj-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prj-head-desc {
  margin: 0.45rem 0 0.2rem;
  max-width: 75ch;
  line-height: 1.5;
}

/* The ⋯ menu: a <details> with its list floating below. */
.prj-menu {
  position: relative;
}

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

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

.prj-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 20;
  min-width: 12rem;
  padding: 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lift);
}

.prj-menu-list a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
}

.prj-menu-list a:hover {
  background: var(--color-bg-subtle);
}

/* As many columns as fit at ~38rem each: two on an ordinary screen, three or four on a wide
   one, one beside an open panel or on a phone. */
.prj-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 38rem), 1fr));
  gap: 1rem;
  /* The cards of a row share its height. */
  align-items: stretch;
}

.prj-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-soft);
}

/* The documents after "Show all": the whole row. */
.prj-card.is-wide {
  grid-column: 1 / -1;
}

.prj-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem 0;
}

.prj-card-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.prj-card-head .prj-filter {
  margin-left: auto;
  max-width: 15rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}

.prj-card-body {
  padding: 0.75rem 1.1rem 1rem;
  font-size: 0.9rem;
}

/* Whatever the shortened lists hide, whatever its class's display says. */
.prj-card-body [hidden] {
  display: none !important;
}

.prj-card-body > :first-child {
  margin-top: 0;
}

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

.prj-card-foot {
  margin-top: auto;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.prj-lead {
  line-height: 1.5;
}

.prj-warn-line {
  color: var(--color-accent-dark);
}

.prj-facts {
  margin: 0.5rem 0;
  padding-left: 1.1rem;
  line-height: 1.6;
}

.prj-subhead {
  margin: 0.9rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* A card inside a tile, opening the drawer. */
.prj-item {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  min-width: 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

.prj-item[hidden] {
  display: none;
}

.prj-item:hover,
.prj-item:focus-visible {
  border-color: var(--color-brand);
}

.prj-item.is-off {
  opacity: 0.65;
}

.prj-item-more {
  color: var(--color-brand);
  font-size: 0.82rem;
  font-weight: 600;
}

.prj-prompt-preview {
  flex-direction: column;
  margin-top: 0.6rem;
}

.prj-prompt-text {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.prj-doc-grid,
.prj-form-grid,
.prj-formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.5rem;
}

.prj-doc-kind {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.8rem;
  border-radius: 6px;
  background: var(--color-bg-subtle);
  color: var(--color-brand);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.prj-doc-main {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.prj-doc-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.prj-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
}

.prj-doc-meta .admin-status {
  text-transform: none;
}

.prj-badge {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.prj-show-all {
  margin-top: 0.6rem;
}

.prj-tags {
  margin: 0 0 0.4rem;
}

.prj-formula,
.prj-form,
.prj-sets {
  flex-direction: column;
  gap: 0.35rem;
}

.prj-formula-name {
  font-weight: 600;
  line-height: 1.3;
}

.prj-formula-eq {
  overflow-x: auto;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.prj-sets {
  margin-top: 0.75rem;
}

.prj-sets-names,
.prj-form-meta {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.prj-ability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.prj-ability {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.prj-ability.is-on {
  border-color: var(--color-brand);
}

.prj-ability-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.prj-ability-name {
  font-weight: 600;
}

.prj-ability-text {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* An on/off state drawn like a switch; read-only until step 2 makes it one. */
.prj-switch {
  flex-shrink: 0;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.prj-switch.is-on {
  background: var(--color-brand);
  color: var(--color-bg-elevated);
}

.prj-drawer-section {
  margin-bottom: 1.1rem;
}

.prj-drawer-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.prj-drawer-section p {
  margin: 0.3rem 0;
  line-height: 1.5;
}

.prj-drawer-card + .prj-drawer-card {
  margin-top: 0.75rem;
}

.prj-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.prj-text {
  margin: 0;
  padding: 0.75rem 0.85rem;
  max-height: 24rem;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prj-headings {
  margin: 0;
  padding-left: 1.4rem;
  line-height: 1.6;
}

.prj-form-preview {
  margin: 0;
  padding: 0.75rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  min-width: 0;
}


@media (max-width: 720px) {
  .prj-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .prj-tile {
    min-height: 0;
  }

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

  .prj-card-head .prj-filter {
    max-width: none;
    width: 100%;
  }

}

/* --- the working panel (plan-assistant-builder §2.5) --- */

.prj-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.prj-main {
  flex: 1;
  min-width: 0;
}

.prj-panel {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.prj-panel[hidden] {
  display: none;
}

.prj-panel:focus {
  outline: none;
}

.prj-panel-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem 0.75rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
}

.prj-panel-titles {
  flex: 1;
  min-width: 0;
}

.prj-panel-kind {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.prj-panel-bar h2 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.prj-panel-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.prj-panel-btn:hover,
.prj-panel-btn[aria-pressed="true"] {
  border-color: var(--color-border);
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.prj-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem 1.5rem;
  font-size: 0.9rem;
}

.prj-panel-resize {
  display: none;
}

/* Full width: the panel takes the page, the tiles step aside until it is put back. */
.prj-layout.is-full .prj-main {
  display: none;
}

.prj-layout.is-full .prj-panel {
  flex: 1;
  width: auto;
  max-width: none;
}

/* Docked: a column of its own, the tiles narrowing beside it - as in the chat. */
@media (min-width: 1100px) {
  .prj-panel {
    position: sticky;
    top: 1rem;
    flex-shrink: 0;
    width: var(--prj-panel-width, clamp(420px, 40vw, 760px));
    max-width: 70vw;
    max-height: calc(100vh - 2rem);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
  }

  .prj-panel-resize {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: -6px;
    width: 10px;
    z-index: 2;
    cursor: col-resize;
    touch-action: none;
    border-radius: 6px;
  }

  .prj-panel-resize:hover,
  .prj-panel-resize:focus-visible,
  .prj-resizing .prj-panel-resize {
    background: color-mix(in srgb, var(--color-brand) 35%, transparent);
    outline: none;
  }

  .prj-layout.is-full .prj-panel-resize {
    display: none;
  }

  .prj-resizing {
    cursor: col-resize;
    user-select: none;
  }
}

/* A tablet: a drawer over the right of the page. */
@media (min-width: 721px) and (max-width: 1099px) {
  .prj-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: min(600px, 90vw);
    border-width: 0 0 0 1px;
    box-shadow: var(--shadow-lift);
  }
}

/* A phone: a sheet over everything. */
@media (max-width: 720px) {
  .prj-panel {
    position: fixed;
    inset: 0;
    z-index: 45;
    border: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .prj-panel-body {
    padding: 0.85rem 0.85rem 1.5rem;
  }

  #prj-panel-full {
    display: none;
  }
}

/* What is open in the panel is marked where it was opened from. */
.prj-card.is-open,
.prj-item.is-open {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px var(--color-brand);
}

.prj-head-btn {
  margin-left: auto;
}

.prj-foot-btn {
  margin-left: 1rem;
}

.prj-menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.prj-menu-item:hover:not(:disabled) {
  background: var(--color-bg-subtle);
}

.prj-menu-item:disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.prj-menu-item.is-danger:not(:disabled) {
  color: #c2410c;
}

button.prj-ability {
  width: 100%;
  font: inherit;
  text-align: left;
  color: var(--color-text);
  cursor: pointer;
}

button.prj-ability:hover:not(:disabled) {
  border-color: var(--color-brand);
}

/* --- modules (plan-assistant-builder §2.6) --- */

.mod-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-top: 0.75rem;
}

.mod-status-error {
  color: #dc2626;
}

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

.mod-section h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.mod-group-docs {
  margin-top: 0.5rem;
}

.mod-group-docs summary {
  cursor: pointer;
  font-size: 0.85rem;
}

.mod-group-doc-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
}

/* In the panel a module takes the panel's width. */
.prj-panel-body .assistant-form-wide {
  max-width: none;
}

.prj-panel-body .doc-groups {
  grid-template-columns: minmax(0, 1fr);
}

/* A fieldset is as wide as its widest content by default - a long <option> pushed the panel
   sideways on a phone. */
.prj-panel-body fieldset {
  min-width: 0;
}

.prj-panel-body select,
.prj-panel-body input:not([type=checkbox]):not([type=radio]) {
  max-width: 100%;
}

/* --- documents on the project page (plan-assistant-builder §3) --- */

.prj-doc-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.prj-upload-btn {
  cursor: pointer;
}

.prj-drop-hint {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.prj-upload-notes {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.prj-uploading {
  margin: 0 0 0.75rem;
  color: var(--color-brand);
  font-weight: 600;
}

/* Over the whole page while files are dragged over it; pointer-events off, or the overlay
   itself would be what the drag enters and leaves. */
.prj-dropzone {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--color-brand);
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  pointer-events: none;
}

.prj-dropzone[hidden] {
  display: none;
}

.prj-dropzone p {
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lift);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-brand);
}

/* Above a module in the panel: what concerns this assistant ("Remove from assistant"). */
.prj-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--color-border);
}

/* A page's cards, inside the panel: sections divided by a rule rather than boxed again. */
.prj-panel-body .usage-card {
  margin: 0 0 1.25rem;
  padding: 0 0 1.25rem;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.prj-picker-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.prj-picker-tools .admin-filter-input {
  flex: 1;
  min-width: 12rem;
}

.prj-picker-tools select,
.prj-doing-bar select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
}

.prj-picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.5rem;
}

.prj-pick {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  cursor: pointer;
  font-size: 0.86rem;
}

.prj-pick[hidden] {
  display: none;
}

.prj-pick:has(input:checked) {
  border-color: var(--color-brand);
}

.prj-pick.is-off {
  opacity: 0.6;
  cursor: default;
}

.prj-pick input {
  margin-top: 0.2rem;
}

.prj-pick-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.prj-picker-bar {
  position: sticky;
  bottom: -1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.9rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

/* --- formulas on the project page (plan-assistant-builder §7.1) --- */

/* A formula reached through a tag rather than attached: said quietly under its name. */
.prj-formula-via {
  color: var(--color-text-muted);
  font-size: 0.72rem;
}

/* The formula page's two columns (the form, "Try it") stack in the panel until it has the
   whole page. */
.prj-layout:not(.is-full) .prj-panel-body .formula-layout {
  grid-template-columns: minmax(0, 1fr);
}

/* The formula picker (templates/_module_assistant_formulas.html). Prefix `fpk-`. */
.fpk-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.75rem 0 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

.fpk-tab {
  padding: 0.45rem 0.8rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.fpk-tab.is-active {
  border-bottom-color: var(--color-brand);
  color: var(--color-text);
}

.fpk-group[hidden] {
  display: none;
}

.fpk-group .prj-subhead {
  margin-top: 0.75rem;
}

.fpk-eq {
  display: block;
  overflow-x: auto;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.fpk-eq code {
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.fpk-card .prj-doc-meta {
  flex-wrap: wrap;
}

.fpk-domain,
.fpk-symbols,
.fpk-via {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.fpk-symbols {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.fpk-fits {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.prj-badge-warn {
  border-color: #ea700b;
  color: #ea700b;
}

@media (prefers-color-scheme: dark) {
  .prj-badge-warn {
    border-color: #fb923c;
    color: #fb923c;
  }
}

/* After formulas were added: the materials and sections that fill them, offered once. */
.fpk-suggest {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  font-size: 0.9rem;
}

.fpk-suggest[hidden] {
  display: none;
}

.fpk-suggest p {
  margin: 0 0 0.6rem;
}

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

.fpk-tags {
  margin-top: 1.25rem;
}

/* A module's collapsible boxes (Tags, Build with AI) keep their distance in the panel, where
   the cards around them lose their borders. */
.prj-panel-body .mod > .doc-expander {
  margin-bottom: 1rem;
}

/* The workspace's lists in the working panel (plan-assistant-builder step 6): while the panel
   is narrow, every `.ws-table` becomes the phone's stack of cards - the same rules as in the
   phone block above, scoped to the panel's own width rather than the screen's. */
.prj-panel-body {
  container: wspanel / inline-size;
}

@container wspanel (max-width: 820px) {
  .ws-table-wrap {
    overflow: visible;
    border: none;
    border-radius: 0;
    background: none;
    cursor: auto;
  }

  .ws-table,
  .ws-table tbody,
  .ws-table tfoot {
    display: block;
  }

  .ws-table thead {
    display: none;
  }

  .ws-table tr {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg-elevated);
  }

  .ws-table tfoot tr {
    background: var(--color-bg-subtle);
  }

  .ws-table td,
  .ws-table td.admin-cell-prose,
  .ws-table tfoot td {
    display: block;
    position: relative;
    min-width: 0;
    max-width: none;
    padding: 0 0 0 7.25rem;
    border: none;
    background: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .ws-table td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 6.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .ws-table td.ws-cell-main,
  .ws-table td:not([data-label]) {
    padding-left: 0;
  }

  .ws-table td.ws-cell-main {
    font-size: 0.95rem;
  }

  .ws-table td.ws-cell-empty {
    display: none;
  }

  .ws-table td.ws-cell-equation {
    overflow-x: auto;
  }

  .ws-table td.ws-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.3rem;
    text-align: left;
  }

  .ws-table .ws-row-actions .btn + .btn {
    margin-left: 0;
  }

  .ws-table .ws-row-actions .btn {
    padding: 0.55rem 1.2rem;
  }

  .ws-table.tag-table td.tag-table-wide {
    width: auto;
  }

  .ws-table.tag-table input,
  .ws-table.tag-table select,
  .ws-table.tag-table td.tag-table-wide input {
    width: 100%;
    min-width: 0;
  }

  .ws-table .admin-inline-form select {
    width: 100%;
  }

}

/* ---- The builder (plan-assistant-builder §4.3, D12, D20): its bar above an assistant's
   tiles, and its tab in the working panel - the shared log, the cards, the composer. ---- */
.bld-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 1.25rem;
  padding: 0.75rem 0.75rem 0.75rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--color-brand) 45%, var(--color-border));
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-brand) 9%, var(--color-bg-elevated)), var(--color-bg-elevated) 60%);
  box-shadow: var(--shadow-lift);
}

.bld-bar-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--color-brand);
  color: #fff;
}

.bld-bar-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.bld-bar-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.bld-bar-label strong {
  color: var(--color-brand);
  font-size: 0.9rem;
  margin-right: 0.2rem;
}

.bld-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 1.02rem;
  padding: 0.3rem 0;
}

.bld-bar input:focus {
  outline: none;
}

.bld-bar:focus-within {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 30%, transparent);
}

@media (max-width: 720px) {
  .bld-bar [data-builder-open],
  .bld-bar-label span {
    display: none;
  }
}

.prj-panel-view-titles,
.prj-panel[data-view]:not([data-view="item"]) .prj-panel-titles:not(.prj-panel-view-titles) {
  display: none;
}

.prj-panel[data-view="builder"] [data-panel-view-titles="builder"],
.prj-panel[data-view="try"] [data-panel-view-titles="try"] {
  display: block;
}

.prj-panel-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 0.9rem;
  border-bottom: 1px solid var(--color-border);
}

.prj-panel-tabs[hidden] {
  display: none;
}

.prj-panel-tab {
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.prj-panel-tab[aria-selected="true"] {
  border-bottom-color: var(--color-brand);
  color: var(--color-text);
  font-weight: 600;
}

.prj-builder-box {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.prj-builder-box[hidden],
.prj-panel-body[hidden],
.prj-panel-tab[hidden] {
  display: none;
}

/* Try it: the chat page in a frame (app.chat.trying), filling the box. */
.prj-try-box {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

/* The help button would sit on the test chat's Send button. */
body:has(.prj-panel[data-view="try"]:not([hidden])) .ws-help-launcher {
  display: none;
}

/* Docked, the panel sizes to its content - a chat wants the window's height. */
@media (min-width: 1100px) {
  .prj-panel[data-view="try"] {
    height: calc(100vh - 2rem);
  }
}

.prj-try-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--color-bg);
}

.bld {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.bld-log {
  flex: 1;
  min-height: 12rem;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.bld-empty p {
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}

.bld-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.bld-starter {
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
}

.bld-msg-head {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.bld-who {
  font-weight: 700;
  color: var(--color-text);
}

.bld-builder .bld-who {
  color: var(--color-brand);
}

.bld-text {
  overflow-wrap: anywhere;
}

.bld-user .bld-text {
  white-space: pre-wrap;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}

.bld-text > :first-child {
  margin-top: 0;
}

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

.bld-msg.is-pending {
  opacity: 0.85;
}

.bld-change {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  border-left: 2px solid var(--color-border);
  padding-left: 0.6rem;
}

.bld-when {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.bld-card {
  margin-top: 0.6rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-brand);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.bld-card-applied {
  border-left-color: #16a34a;
}

.bld-card-dismissed,
.bld-card-undone {
  border-left-color: var(--color-border);
  opacity: 0.75;
}

.bld-card-title {
  font-weight: 700;
}

.bld-card-why {
  margin: 0.25rem 0 0.4rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.bld-card-line {
  margin: 0.3rem 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.bld-link {
  color: var(--color-brand);
  overflow-wrap: anywhere;
}

.bld-card-code {
  display: block;
  margin: 0.25rem 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* A module's Build with AI panel, replaced by the builder on an assistant's page. */
.bld-instead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.75rem 0;
}

.bld-card-list {
  margin: 0.3rem 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

.bld-card-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-top: 0.6rem;
}

/* A card of a turn still running: Apply and Dismiss wait for its end. */
.bld-card-bar button:disabled {
  opacity: 0.5;
  cursor: progress;
}

.bld-apply-all {
  margin-top: 0.6rem;
}

.bld-composer {
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 1.1rem 1rem;
  background: var(--color-bg-elevated);
}

.bld-input {
  width: 100%;
  resize: vertical;
  min-height: 3rem;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
}

.bld-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.bld-new {
  margin-right: auto;
}

/* Files for the builder's conversation: chips above the box, and on the message they went with. */
.bld-files {
  margin: 0 0 0.5rem;
}

.bld-msg-files {
  margin-top: 0.4rem;
}

.bld-composer.is-dropping {
  outline: 2px dashed var(--color-brand);
  outline-offset: -4px;
}

/* Where a new conversation with the builder starts, and the earlier ones folded away. */
.bld-start-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  border-top: 1px dashed var(--color-border);
  padding-top: 0.4rem;
}

.bld-earlier {
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.6rem;
}

.bld-earlier > summary {
  cursor: pointer;
  color: var(--color-text-muted);
}

.bld-earlier-one {
  margin: 0.5rem 0 0 0.5rem;
}

.bld-earlier-one > summary {
  cursor: pointer;
  overflow-wrap: anywhere;
}

.bld-earlier-one > summary .bld-when {
  margin-right: 0.6rem;
}

.bld-earlier-one > .bld-msg,
.bld-earlier-one > .bld-change {
  margin-top: 0.6rem;
}

.bld-status {
  flex: 1;
  margin: 0;
  min-height: 1.2em;
}

/* Docked or as a sheet, the panel reaches the bottom of the window, where "Ask for help"
   floats. */
.bld-composer {
  padding-bottom: 4.5rem;
}

.bld-composer [hidden] {
  display: none;
}

/* The Instructions tile: first and across the whole row (plan-feedback-task-1 §10, I). The
   prompt and "How it behaves" sit side by side once the tile has the room - measured on the
   tile, not the window, since an open panel narrows it. */
.prj-card-instructions {
  grid-column: 1 / -1;
  container-type: inline-size;
}

.prj-instr-main > :first-child {
  margin-top: 0;
}

@container (min-width: 52rem) {
  .prj-instr.has-side {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 1.75rem;
  }

  .prj-instr.has-side .prj-summary {
    margin: 0;
    padding-left: 1.5rem;
    border-left: 1px solid var(--color-border);
  }

  .prj-instr.has-side .prj-summary > .prj-subhead:first-child {
    margin-top: 0;
  }

  .prj-card-instructions .prj-prompt-text {
    -webkit-line-clamp: 8;
  }
}

/* The builder's "How it behaves" on the Instructions tile. */
.prj-summary {
  margin: 0.6rem 0;
}

.prj-summary .btn {
  margin-top: 0.4rem;
}

/* The instructions module: which of its texts is the prompt. */
/* "sent to the model" beside the two texts the chat model reads (the instructions module). */
.prj-to-model {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-brand) 12%, transparent);
  color: var(--color-brand);
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
}

/* A hint right under its heading or control. */
.prj-tight {
  margin: 0 0 0.4rem;
}

.prj-card-abilities .prj-ability-grid {
  grid-template-columns: minmax(0, 1fr);
}

/* "Model and abilities": a setting as a name and its control on one line. */
.prj-setting {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0 0.25rem;
}

/* The names in one column, so "Model" and "Look-ups per reply" line up. */
.prj-setting-name {
  flex: 0 0 9.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.prj-setting-input {
  min-width: 0;
  flex: 1;
  max-width: 24rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select.prj-setting-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.2rem;
  cursor: pointer;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}

.prj-setting-input:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--color-brand) 40%, var(--color-border));
}

.prj-setting-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 18%, transparent);
}

.prj-setting-input:disabled {
  opacity: 0.6;
  cursor: wait;
}

.prj-setting-number {
  flex: 0 0 5.5rem;
}

@media (max-width: 520px) {
  .prj-setting {
    flex-wrap: wrap;
  }

  .prj-setting-name {
    flex-basis: 100%;
  }
}

.prj-summary-title {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.prj-summary ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* The builder's setup cards (plan-assistant-builder §5): questions, the plan, test questions. */
.bld-q {
  margin: 0.6rem 0 0;
  padding: 0;
  border: none;
}

.bld-q legend {
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.bld-q-option {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.3rem 0;
  cursor: pointer;
}

.bld-q-option input[type=radio],
.bld-q-option input[type=checkbox] {
  margin-top: 0.2rem;
}

.bld-q-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.4rem;
  flex: 1;
  min-width: 0;
}

.bld-q-desc {
  flex-basis: 100%;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.bld-q-other {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
}

.bld-recommended {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.bld-plan-name {
  margin: 0.4rem 0 0;
  font-size: 1rem;
}

.bld-plan-head {
  margin: 0.7rem 0 0.2rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.bld-plan-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
}

.bld-plan-list li {
  position: relative;
  margin: 0.2rem 0;
  padding-right: 1.6rem;
}

.bld-plan-list li > strong + .prj-badge {
  margin-left: 0.4rem;
}

.bld-plan-list li.is-removed > :not(.bld-plan-x) {
  text-decoration: line-through;
  opacity: 0.5;
}

.bld-plan-list .bld-q-desc {
  display: block;
}

.bld-plan-x {
  position: absolute;
  top: 0;
  right: 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.bld-plan-x:hover {
  color: var(--color-text);
}

.bld-tests .bld-plan-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.bld-card-stamp {
  margin: 0.5rem 0 0;
}

@media (prefers-color-scheme: dark) {
  .bld-recommended { color: #4ade80; }
}

/* The start page: what the new assistant should do. */
.bld-start-page {
  max-width: 820px;
}

.bld-start h1 {
  margin: 0.5rem 0 1rem;
}

.bld-start-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.bld-start textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

.bld-start .bld-starters {
  margin: 0.6rem 0 1rem;
}

.bld-drop {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
}

.bld-drop.is-over {
  border-color: var(--color-brand);
  background: var(--color-bg-subtle);
}

.bld-drop-title {
  font-weight: 700;
}

.bld-drop-files {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.bld-start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 0.5rem;
}

.bld-start-manual {
  margin-top: 2rem;
}

/* The document module's review card, collapsed (templates/_module_document.html). */
.doc-review > summary [data-el="review-badge"] {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
}

.doc-review-line {
  margin: 0 0 0.75rem;
}

/* Delete at the foot of the document module: a button, its explanation behind a "?". */
.doc-delete-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

/* "Process as batch" leaves the document module for a model without the Batch API. */
.assistant-form-checkbox[hidden] {
  display: none;
}

/* Suggestions under the builder's bar (assistant-project.js renderChips): a chip drafts its
   request into the bar, its × hides it. */
.bld-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: -0.6rem 0 1rem;
  padding-left: 0.5rem;
}

.bld-chips[hidden] {
  display: none;
}

.bld-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-elevated);
  font-size: 0.82rem;
  overflow: hidden;
}

.bld-chip button {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: var(--color-text);
  cursor: pointer;
}

.bld-chip-use {
  padding: 0.3rem 0.4rem 0.3rem 0.75rem;
}

.bld-chip-use::before {
  content: "✦ ";
  color: var(--color-brand);
}

.bld-chip-x {
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  color: var(--color-text-muted) !important;
}

.bld-chip button:hover {
  background: var(--color-bg-subtle);
}

.bld-chip button:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: -2px;
}

/* A question the builder tried through the real chat (builder.js trialCard). */
.bld-trial-answer {
  max-height: 14rem;
  overflow: auto;
  margin: 0.4rem 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--color-border);
  background: var(--color-bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.85rem;
}

.bld-trial-answer > :first-child {
  margin-top: 0;
}

.bld-trial-answer > :last-child {
  margin-bottom: 0;
}

.bld-trial-sources {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.bld-trial-sources summary {
  cursor: pointer;
}

.bld-trial-sources ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}

/* ---------- "How it's doing" on the assistant's page (app.feedback.doing) ---------- */

.prj-doing-thumbs .prj-thumb,
.prj-doing-thumbs span {
  white-space: nowrap;
  margin-right: 0.9rem;
}

.prj-doing-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.prj-exchanges {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.prj-exchange {
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  background: var(--color-bg-elevated);
}

.prj-exchange.is-down { border-left-color: #c2410c; }
.prj-exchange.is-up { border-left-color: #15803d; }

.prj-exchange-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.prj-exchange-question {
  margin: 0.35rem 0;
  font-weight: 600;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prj-exchange-comment {
  margin: 0.35rem 0;
  overflow-wrap: anywhere;
}

.prj-exchange-more summary {
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.prj-exchange-reply {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  max-height: 20rem;
  overflow-y: auto;
}

.prj-exchange-sources {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.prj-doing-h {
  margin: 1.25rem 0 0.25rem;
  font-size: 1rem;
}

/* A team's tile and panel: a row per writer (plans/plan-sub-assistants.md §5). */
.prj-doing-team {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.9rem;
}

.prj-doing-team li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.2rem;
}

.prj-doing-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0 0.25rem;
}

.prj-doing-table {
  border-collapse: collapse;
  font-size: 0.875rem;
  width: 100%;
}

.prj-doing-table th,
.prj-doing-table td {
  text-align: right;
  padding: 0.3rem 0.45rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.prj-doing-table th:first-child,
.prj-doing-table td:first-child {
  text-align: left;
  white-space: normal;
}

.prj-doing-table th {
  color: var(--color-text-muted);
  font-weight: 600;
}

.prj-doing-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--color-brand);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.prj-doing-pick:hover,
.prj-doing-pick:focus-visible {
  text-decoration: underline;
}

.prj-exchange-writer {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.bld-trial-who {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0.2rem 0 0.4rem;
}

.prj-uncovered {
  padding-left: 1.1rem;
  line-height: 1.5;
}

.prj-uncovered li {
  overflow-wrap: anywhere;
  margin-bottom: 0.35rem;
}

/* An assistant based on a standard one (app.assistants.variants), on its Instructions tile. */
.prj-based-on {
  margin: 0.25rem 0 0.5rem;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--color-brand);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

/* A team: a lead with specialists (plans/plan-sub-assistants.md §6) - the team bar's tabs,
   the specialists' coloured initials, the Team tile, "Used by" and the team overview. */
.prj-team-c1 { --team: var(--team-1); }
.prj-team-c2 { --team: var(--team-2); }
.prj-team-c3 { --team: var(--team-3); }
.prj-team-c4 { --team: var(--team-4); }
.prj-team-c5 { --team: var(--team-5); }
.prj-team-c6 { --team: var(--team-6); }
.prj-team-c7 { --team: var(--team-7); }
.prj-team-c8 { --team: var(--team-8); }

.prj-team-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.4rem;
  border-radius: 999px;
  background: var(--team, var(--color-brand));
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.prj-team-field {
  color: var(--color-text-muted);
  font-weight: 600;
}

.prj-team-bar {
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--color-border);
}

.prj-team-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.prj-team-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.8rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.prj-team-tab .prj-team-dot {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.6rem;
}

.prj-team-tab:hover {
  color: var(--color-text);
}

.prj-team-tab.is-current {
  border-bottom-color: var(--color-brand);
  color: var(--color-text);
}

.prj-team-add {
  font-size: 1.1rem;
}

.prj-team-notready {
  flex: none;
  white-space: nowrap;
  margin-left: 0.4rem;
  padding: 0.02rem 0.4rem;
  border: 1px dashed var(--color-accent);
  border-radius: 999px;
  color: var(--color-accent-dark);
  font-size: 0.68rem;
  font-weight: 600;
}

.prj-team-select {
  display: none;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
}

@media (max-width: 640px) {
  .prj-team-tabs { display: none; }
  .prj-team-select { display: block; }
  .prj-team-bar { border-bottom: 0; }
}

.prj-team-addline {
  margin: 1rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.prj-team-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
}

.prj-team-row-head {
  display: flex;
  align-items: center;
  margin: 0;
  font-weight: 600;
}

.prj-team-row p,
.prj-team-person p {
  margin: 0.2rem 0 0;
}

.prj-team-covers {
  font-size: 0.88rem;
}

.prj-used-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.prj-used {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.prj-used-label {
  margin-right: 0.15rem;
  color: var(--color-text-muted);
  font-size: 0.72rem;
}

.prj-used-toggle {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--team, var(--color-border));
  border-radius: 999px;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.prj-used-toggle.is-on {
  background: var(--team, var(--color-brand));
  color: #fff;
}

.prj-used-toggle:disabled {
  cursor: default;
  opacity: 0.7;
}

.prj-used-all {
  border-style: dashed;
  color: var(--color-text-muted);
}

.prj-panel-actions .prj-used {
  flex-basis: 100%;
}

.prj-team-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.prj-team-person {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.prj-team-kinds {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

.prj-team-kind {
  padding: 0.4rem 0.75rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.prj-team-kind.is-current {
  border-bottom-color: var(--color-brand);
  color: var(--color-text);
}

.prj-team-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.prj-team-bulk select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
}

.prj-team-table .prj-team-col {
  text-align: center;
  white-space: nowrap;
}

.prj-team-table th.prj-team-col .prj-team-dot {
  margin-right: 0.25rem;
}

.prj-team-choices {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.prj-team-choices select {
  margin: 0 0.2rem;
  padding: 0.2rem 0.4rem;
  font: inherit;
}

/* The home's tile of a lead: its specialists under its name. */
.ws-team-members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.ws-team-members li {
  display: inline-flex;
  align-items: center;
}

.ws-team-members .prj-team-dot {
  width: 1.2rem;
  height: 1.2rem;
  margin-right: 0.25rem;
  font-size: 0.55rem;
}

/* A team in the chat (app/ai/team.py): the chip naming who worked on a reply, the bar above
   the composer picking who answers, the line at the start. The sidebar lists a team as one row. */
.message-team-chip .prj-team-dot,
.team-pin-bar .prj-team-dot,
.team-intro .prj-team-dot,
.thinking-line .prj-team-dot,
.message-sources-via .prj-team-dot,
.message-team-answers .prj-team-dot {
  width: 1.15rem;
  height: 1.15rem;
  margin-right: 0.3rem;
  font-size: 0.52rem;
}

.message-team-chip {
  display: inline-flex;
  align-items: center;
}

/* A merged reply (several specialists): its dots overlap a little, like a group of avatars. */
.message-team-chip .prj-team-dot + .prj-team-dot {
  margin-left: -0.45rem;
  box-shadow: 0 0 0 2px var(--color-bg);
}

.message-sources-via {
  display: flex;
  align-items: center;
  margin-top: 0.4rem;
  font-weight: 600;
  list-style: none;
}

.message-team-answers summary {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.message-team-answer {
  margin: 0.3rem 0 0.6rem 1.45rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--color-border);
  font-size: 0.85rem;
}

.team-pin-bar {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.4rem;
  padding: 0.1rem 0.2rem 0.1rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.team-pin-bar.is-pinned {
  color: var(--color-text);
  font-weight: 600;
}

.team-pin-select {
  min-width: 0;
  max-width: 100%;
  padding: 0.15rem 0.2rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-overflow: ellipsis;
  cursor: pointer;
}

.team-pin-select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-radius: var(--radius-md);
}

.team-intro {
  max-width: 46rem;
  margin: 1.5rem auto;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.8;
  text-align: center;
}

.team-intro-member {
  display: inline-flex;
  align-items: center;
  padding: 0 0.3rem 0 0.1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}

.team-intro-member:hover {
  border-color: var(--color-border);
  background: var(--color-bg-elevated);
}

.prj-team-who {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.prj-team-who-out p {
  margin: 0.35rem 0 0;
}

/* --- Teams in the builder (plans/plan-sub-assistants.md §7) ---------------------------------- */

/* "Who has what" card: per specialist what it gets (+) and gives up (−). */
.bld-assign-who {
  margin-top: 0.5rem;
  font-weight: 600;
}

.bld-assign-take {
  color: var(--color-text-muted);
}

/* The restructure card: the shape, the parts, and who has what - editable until applied. */
.bld-rs-shapes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 1rem;
  margin: 0.4rem 0;
}

.bld-rs-parts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.bld-rs-part {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.bld-rs-part-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bld-rs-part-head .bld-plan-x {
  margin-left: auto;
}

.bld-rs-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.bld-rs-field input,
.bld-rs-field textarea {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
}

.bld-rs-extra summary,
.bld-rs-table summary {
  cursor: pointer;
  font-size: 0.85rem;
}

.bld-rs-table {
  margin: 0.4rem 0;
}

.bld-rs-table summary .prj-badge {
  margin-left: 0.4rem;
}

.bld-rs-table .admin-table-wrap {
  max-height: 22rem;
  overflow: auto;
  margin-top: 0.35rem;
}

.bld-rs-table .admin-cell-prose .prj-badge {
  margin-left: 0.35rem;
}

/* The team overview's "Check the routing". */
.prj-team-check {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.prj-team-check-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.prj-team-check-head h3 {
  margin: 0;
}

.prj-team-check-list {
  margin: 0.4rem 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.prj-team-check-list li {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0;
}

.prj-team-check-questions summary {
  cursor: pointer;
  font-size: 0.88rem;
}

.prj-team-check-questions ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.prj-team-check-questions li {
  padding: 0.2rem 0;
}

.prj-team-check-wrong > span:first-child {
  text-decoration: underline wavy var(--color-accent);
  text-underline-offset: 3px;
}

/* A specialist's "Write it from the documents", under What it covers. */
.mod-covers-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: -0.4rem 0 0.75rem;
}

/* The model advisor on /admin/models' Active tab (static/model-advisor.js). */
.mad-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  align-items: flex-start;
}
.mad-head > div:first-child {
  flex: 1 1 28rem;
}
.mad-head h2 {
  margin-top: 0;
}
.mad-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.mad-model {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.mad-log {
  max-height: 70vh;
  overflow-y: auto;
  margin-top: 0.75rem;
}
.mad-log:empty {
  display: none;
}
.mad-msg {
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 0;
}
.mad-msg-head {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.mad-msg-user .mad-msg-body {
  white-space: pre-wrap;
  color: var(--color-text-muted);
}
.mad-msg-body > :first-child {
  margin-top: 0;
}
.mad-msg-body > :last-child {
  margin-bottom: 0;
}
.mad-msg-start {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.mad-pending .mad-msg-body:empty::before {
  content: "…";
  color: var(--color-text-muted);
}
.mad-sync {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0.35rem 0 0;
}
.mad-status {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0;
}
.mad-earlier > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 0.4rem 0;
}
.mad-card {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-brand);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  padding: 0.75rem 1rem;
  margin-top: 0.6rem;
}
.mad-card-add {
  border-left-color: #22c55e;
}
.mad-card-retire {
  border-left-color: var(--color-accent);
}
.mad-card-default {
  border-left-color: #8b5cf6;
}
.mad-credit {
  margin: 0.5rem 0 0;
}
.mad-last {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.mad-last.mad-late {
  color: #ea700b;
  font-weight: 600;
}
.mad-changes {
  margin-top: 0.4rem;
  font-size: 0.85rem;
}
.mad-changes > summary {
  cursor: pointer;
  color: var(--color-text-muted);
}
.mad-changes ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}
.mad-compare {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--color-border);
}
.mad-card-dismissed,
.mad-card-undone {
  opacity: 0.6;
}
.mad-card-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.mad-card-type {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mad-swap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}
.mad-arrow {
  font-size: 1.3rem;
  color: var(--color-text-muted);
}
.mad-twin {
  margin-top: 0.4rem;
}
.mad-card-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
.mad-card-label::after {
  content: ":";
}
.mad-card-list {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}
.mad-why {
  margin: 0.5rem 0 0;
}
.mad-done {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}
.mad-card-actions {
  margin-top: 0.6rem;
}
.mad-card-note {
  margin: 0.4rem 0 0;
}
.mad-ask {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  margin-top: 0.75rem;
}
.mad-ask textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
  font: inherit;
}
/* A class selector (.btn) outranks the UA stylesheet's [hidden]. */
.mad [hidden] {
  display: none;
}
@media (max-width: 720px) {
  .mad-ask {
    flex-wrap: wrap;
  }
  .mad-ask textarea {
    flex-basis: 100%;
  }
}

/* A card that folds (details.fold): the model advisor and the benchmarks on /admin/models. The
   summary is the card's heading; the marker sits before it. */
.fold > .fold-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  cursor: pointer;
  list-style: none;
}
.fold > .fold-summary::-webkit-details-marker {
  display: none;
}
.fold > .fold-summary::before {
  content: "▸";
  color: var(--color-text-muted);
  transition: transform 0.15s;
}
.fold[open] > .fold-summary::before {
  transform: rotate(90deg);
}
.fold > .fold-summary h2 {
  margin: 0;
}
.fold > .fold-summary .mad-last {
  margin: 0;
}
.fold[open] > .fold-summary {
  margin-bottom: 0.75rem;
}

/* The benchmarks card (static/model-benchmarks.js). */
.bmk-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.bmk-segment {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.bmk-segment label {
  position: relative;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.bmk-segment label + label {
  border-left: 1px solid var(--color-border);
}
.bmk-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.bmk-segment label:has(input:checked) {
  background: var(--color-brand);
  color: #fff;
}
.bmk-segment label:has(input:focus-visible) {
  outline: 2px solid var(--color-brand);
  outline-offset: -4px;
}
.bmk-chips {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.bmk-chips > [data-el="metric"] {
  display: contents;
}
.bmk-chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.bmk-chip-label {
  min-width: 3.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.bmk-chip-group label {
  position: relative;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.bmk-chip-group label:hover {
  border-color: var(--color-brand);
}
.bmk-chip-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.bmk-chip-group label:has(input:checked) {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}
.bmk-chip-group label:has(input:focus-visible) {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}
.bmk-controls .usage-legend {
  flex-direction: row;
  margin: 0 0 0 auto;
  gap: 0.35rem 1rem;
}
.bmk-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr));
  gap: 1rem 2rem;
}
.bmk-figure {
  margin: 0;
  min-width: 0;
}
.bmk-figure figcaption {
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.bmk-scatter {
  height: 26rem;
}
.bmk [hidden] {
  display: none !important;
}


/* --- Long conversations (app/chat/compaction.py) --------------------------------------------
   The gauge beside Send, its menu, the divider where earlier messages were summarised (the
   messages above it greyed slightly), and the limit card in place of a reply. */
.chat-gauge {
  position: relative;
  flex-shrink: 0;
}

.chat-gauge[hidden] { display: none; }

.chat-gauge-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 2.25rem;
  padding: 0 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.chat-gauge-btn:hover,
.chat-gauge-btn[aria-expanded="true"] {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.chat-gauge-btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}

.chat-gauge-ring {
  width: 1.15rem;
  height: 1.15rem;
}

.chat-gauge-ring circle {
  fill: none;
  stroke-width: 3;
}

.chat-gauge-track { stroke: var(--color-border); }

.chat-gauge-fill {
  stroke: var(--gauge-ok);
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.3s ease;
}

.chat-gauge.is-amber .chat-gauge-fill { stroke: var(--gauge-amber); }
.chat-gauge.is-red .chat-gauge-fill { stroke: var(--gauge-red); }
.chat-gauge.is-red .chat-gauge-figure { color: var(--gauge-red); }

.chat-gauge-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.4rem);
  z-index: 30;
  width: min(20rem, calc(100vw - 2rem));
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lift);
  font-size: 0.82rem;
}

.chat-gauge-menu[hidden] { display: none; }

.chat-gauge-text {
  margin: 0 0 0.6rem;
  color: var(--color-text);
}

.chat-gauge-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.chat-gauge-menu button:hover:not(:disabled),
.chat-gauge-menu button:focus-visible {
  border-color: var(--color-brand);
  outline: none;
}

.chat-gauge-menu button:focus-visible {
  box-shadow: inset 0 0 0 1px var(--color-brand);
}

.chat-gauge-menu button:disabled {
  cursor: default;
  opacity: 0.55;
}

.chat-gauge-hint {
  margin: 0.55rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.message.is-summarised {
  opacity: 0.72;
}

.chat-summary {
  margin: 1.1rem 0 0.9rem;
}

.chat-summary-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-brand);
  cursor: pointer;
}

.chat-summary-head::-webkit-details-marker { display: none; }

.chat-summary-head::before,
.chat-summary-head::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--color-border);
}

.chat-summary-head span::after {
  content: " ▾";
  font-weight: 400;
}

.chat-summary[open] .chat-summary-head span::after { content: " ▴"; }

.chat-summary-head:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
  border-radius: 4px;
}

.chat-summary-body {
  margin-top: 0.6rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  font-size: 0.88rem;
}

.chat-summary-note {
  margin: 0 0 0.45rem;
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.chat-summary-content > :last-child { margin-bottom: 0; }

.thread-divider-summary-pending {
  color: var(--color-brand);
}

.thread-divider-summary-pending span {
  animation: chat-summary-pulse 1.4s ease-in-out infinite;
}

@keyframes chat-summary-pulse {
  50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .thread-divider-summary-pending span { animation: none; }
  .chat-gauge-fill { transition: none; }
}

.chat-limit-card {
  padding: 0.85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--gauge-red) 45%, var(--color-border));
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
}

.chat-limit-card p { margin: 0 0 0.5rem; }

.chat-limit-title { font-weight: 700; }

.chat-limit-files {
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.chat-limit-files li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--color-border);
}

.chat-limit-file-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.chat-limit-file-size {
  flex-shrink: 0;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.chat-limit-hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.chat-limit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 600px) {
  .chat-gauge-figure { display: none; }
}

.best-match-item[hidden] {
  display: none;
}

/* ---------- Running a plan (plans/plan-big-requests.md §6): the card's progress, the step dividers,
   the sidebar's marks, the question card. Colours are the gauge's tokens (light and dark). ---------- */
.plan-card.is-active { border-color: color-mix(in srgb, var(--color-brand) 55%, var(--color-border)); }
.plan-step-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
}
.plan-step.is-done .plan-step-mark { color: var(--gauge-ok); }
.plan-step.is-running .plan-step-mark { color: var(--color-brand); animation: plan-pulse 1.4s ease-in-out infinite; }
.plan-step.is-paused .plan-step-mark, .plan-step.is-stopped .plan-step-mark { color: var(--gauge-amber); }
.plan-step.is-done .plan-step-title { font-weight: 500; }
.plan-step.is-todo { color: var(--color-text-muted); }
.plan-step-live { margin: 0.15rem 0 0 1.25rem; font-size: 0.85rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.plan-step-live:empty { display: none; }
.plan-progress, .plan-note-asked { margin: 0; font-size: 0.85rem; color: var(--color-text-muted); }
.plan-note-asked { color: var(--gauge-amber); font-weight: 600; }
@keyframes plan-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .plan-step.is-running .plan-step-mark { animation: none; } }

.thread-divider-plan-step { color: var(--color-brand); }
.thread-divider-plan-step span { text-align: center; }

/* A finished step's reply folded under its divider (foldStepReply in app.js): its first lines,
   fading out, then "Show the step" and the document. */
.message.is-step-folded > .message-content {
  max-height: 4.8em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
}
.message.is-step-folded > :not(.message-content):not(.step-fold-bar) { display: none; }
/* Its own heading repeats the divider's title: the first lines of text show instead. */
.message.is-step-folded > .message-content > :is(h1, h2, h3, h4):first-child { display: none; }
.message.is-step-folded > .message-content > :first-child + * { margin-top: 0; }
.step-fold-bar { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.25rem; font-size: 0.85rem; }
.step-fold-bar .btn-quiet { font-size: 0.85rem; padding: 0.1rem 0; }

.conversation-plan-mark {
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.conversation-plan-working { color: var(--color-brand); }
.conversation-plan-needs { color: var(--gauge-amber); }
.conversation-plan-done { color: var(--gauge-ok); }

.plan-question-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--gauge-amber);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}
.plan-question-card .plan-label { flex-basis: 100%; margin: 0; }
.plan-question-form { display: flex; gap: 0.4rem; flex: 1 1 14rem; }
.plan-question-form input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: inherit;
  font: inherit;
}

/* ---------- The plan's result (plans/plan-big-requests.md §8, app/chat/plan_result.py): a step's
   tools on the card (go to it, redo), the read-through's edits under its reply, the closing
   reply's links. The document itself is a form output card (.form-output-card). ---------- */
.plan-step-tools { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; margin-top: 0.15rem; font-size: 0.85rem; }
.plan-step-tools .btn-quiet { font-size: 0.85rem; padding: 0.1rem 0; }
.plan-redo { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.4rem; }
.plan-redo[hidden] { display: none; }
.plan-redo textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
}
.plan-edits {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--color-brand) 35%, var(--color-border));
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}
.plan-edits .plan-step-does { margin: 0; color: var(--color-text-muted); }
.plan-fix-list { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.85rem; }
.plan-fix { display: flex; flex-direction: column; gap: 0.35rem; }
.plan-fix-why { margin: 0; font-size: 0.92rem; }
.plan-fix-diff { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.88rem; }
.plan-fix-was, .plan-fix-new {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-md);
  border-left: 3px solid;
}
.plan-fix-was {
  max-height: 14rem;
  overflow-y: auto;
  border-color: var(--gauge-red);
  background: color-mix(in srgb, var(--gauge-red) 9%, transparent);
  color: var(--color-text-muted);
}
.plan-fix-new {
  text-decoration: none;
  border-color: var(--gauge-ok);
  background: color-mix(in srgb, var(--gauge-ok) 10%, transparent);
  color: var(--color-text);
}
.plan-fix.is-applied .plan-fix-was, .plan-fix.is-dismissed .plan-fix-new { display: none; }
.plan-fix.is-dismissed { color: var(--color-text-muted); }
.plan-fix-state { font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); }
.plan-fix.is-applied .plan-fix-state { color: var(--gauge-ok); }
.plan-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

/* ---------- A started plan beside the conversation (plans/plan-big-requests.md, the plan tab): the
   card in the side panel's Plan tab, one line under its reply, and the bar above the composer that
   says where it stands and what it waits for. ---------- */
.plan-card.is-slim { gap: 0.4rem; padding: 0.7rem 0.9rem; }
.plan-card.is-slim .plan-goal { font-size: 0.95rem; }
.plan-card-panel { margin-top: 0; }
.items-tab-needs::after,
.items-panel-btn-needs::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.15rem;
  border-radius: 50%;
  background: var(--gauge-amber);
}
.items-panel-btn-needs { position: relative; }

.plan-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin: 0 0 0.5rem;
  padding: 0.45rem 0.6rem 0.45rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  font-size: 0.85rem;
}
.plan-bar[hidden] { display: none; }
.plan-bar-mark { font-weight: 700; font-size: 0.8rem; color: var(--color-brand); }
.plan-bar-working .plan-bar-mark { animation: plan-pulse 1.4s ease-in-out infinite; }
.plan-bar-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  flex: 1 1 14rem;
  min-width: 0;
}
.plan-bar-text { color: var(--color-text); }
.plan-bar-working .plan-bar-text { color: var(--color-text-muted); }
.plan-bar-live { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.plan-bar-live:empty { display: none; }
.plan-bar-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.plan-bar-open, .plan-bar-stop { white-space: nowrap; }
/* On a phone a working plan takes two lines, not three: the step, then its clock beside the
   buttons - the keyboard leaves little room above the message box. */
@media (max-width: 720px) {
  .plan-bar-working .plan-bar-body { display: contents; }
  .plan-bar-working .plan-bar-text { flex: 1 1 calc(100% - 1.5rem); min-width: 0; }
  .plan-bar-working .plan-bar-live { flex: 0 1 auto; padding-left: 1.2rem; }
  .plan-bar-working .plan-bar-stage { display: none; }
}
.plan-bar-needs {
  border-color: var(--gauge-amber);
  background: color-mix(in srgb, var(--gauge-amber) 12%, var(--color-bg-elevated));
}
.plan-bar-needs .plan-bar-mark { color: var(--gauge-amber); }
.plan-bar-needs .plan-bar-text { font-weight: 600; }
.plan-bar-done { border-color: color-mix(in srgb, var(--gauge-ok) 55%, var(--color-border)); }
.plan-bar-done .plan-bar-mark { color: var(--gauge-ok); }
.plan-bar-close {
  display: inline-flex;
  padding: 0.2rem;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.plan-bar-close:hover { color: var(--color-text); background: var(--color-bg-subtle); }
.plan-bar-close .icon { width: 1rem; height: 1rem; }
@media (prefers-reduced-motion: reduce) { .plan-bar-working .plan-bar-mark { animation: none; } }

/* Who pays (plans/plan-organizations.md step 4): the Billing card's usage, credits, requests. */
.ws-billing-alerts p {
  margin: 0 0 0.6rem;
}

.ws-billing-meter {
  display: inline-block;
  width: 4.5rem;
  height: 0.45rem;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.ws-billing-meter > span {
  display: block;
  height: 100%;
  background: var(--color-brand);
}

.ws-limit-form {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: center;
}

.ws-table .ws-limit-form input {
  width: 6.5rem;
  flex: none;
}

.ws-billing-packs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0.2rem;
}

.ws-billing-sub {
  margin: 1.2rem 0 0.4rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.ws-billing-requests {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ws-billing-requests li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}

.ws-billing-requests li:last-child {
  border-bottom: 0;
}

/* "Ask your manager" under a seat holder's 429 (static/app.js offerAskManager). */
.ask-manager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
}

/* "Latoda support" (plans/plan-organizations.md §6.6): the Manager's switch and the visits. */
.ws-support-form {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-border);
  display: grid;
  gap: 0.6rem;
  justify-items: start;
}

.ws-support-form h3 {
  margin: 0;
  font-size: 0.95rem;
}

.ws-support-choices {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}

.ws-support-choices legend {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
  padding: 0;
}

.ws-support-on {
  margin: 0 0 0.6rem;
}

/* The cancel and withdraw pages (app/legal/contracts.py) - "ctr-". */
.ctr-form {
  display: grid;
  gap: 1.1rem;
  margin-top: 1.25rem;
  max-width: 36rem;
}
.ctr-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
.ctr-choice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.ctr-date {
  width: auto;
}
/* The cancel page's recommendation to signed-out visitors: sign in, cancel on the Plans page. */
.ctr-advice {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  max-width: 36rem;
}
.ctr-advice p {
  margin: 0 0 0.5rem 0;
}
.ctr-advice p:last-child {
  margin-bottom: 0;
}
.ctr-receipt {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 1.25rem 0;
}
.ctr-receipt dt {
  font-weight: 600;
}
.ctr-receipt dd {
  margin: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 520px) {
  .ctr-receipt {
    grid-template-columns: 1fr;
  }
  .ctr-receipt dd {
    margin-bottom: 0.5rem;
  }
}
@media print {
  .site-header, .site-footer, .legal-nav, .legal-back, .ctr-receipt ~ button {
    display: none;
  }
}

/* /admin/contracts (templates/admin_contracts.html) - prefix adc- */
.adc-notice {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 0 0 12px 0;
  background: var(--color-bg-elevated);
}
.adc-notice.adc-handled { opacity: 0.75; }
.adc-notice.adc-focus { outline: 2px solid var(--color-accent); }
.adc-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.adc-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; color: var(--color-text-muted); }
.adc-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 8px 0; }
.adc-facts dt { font-weight: 600; }
.adc-facts dd { margin: 0; overflow-wrap: anywhere; }
.adc-reason { white-space: pre-wrap; }
.adc-log { margin: 4px 0 0 0; padding-left: 18px; }
.adc-pick { margin: 8px 0; }
.adc-pick select { max-width: 100%; }
.adc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.adc-actions form { margin: 0; }
.adc-refund { margin: 8px 0; }
.adc-calc { margin: 6px 0 10px 0; padding-left: 20px; }
.adc-error { max-width: 28em; overflow-wrap: anywhere; font-size: 0.85em; }
@media (max-width: 640px) {
  .adc-facts { grid-template-columns: 1fr; }
}
