/* Rich content: highlighted code (config/code_highlight.py), code blocks with tabs, side-by-side
   examples, callouts, steps, heading anchors, HTTP method and status pills.
   First user: the Developer API wiki (developer_api/templates/developer_api/docs/).
   Colours are THEME TOKENS only (--color-*), defined once per theme below: dark is the default
   (the app's default), light applies under [data-theme="light"] and, with no theme chosen, a
   light OS preference -- the same three-way switch as static/css/input.css.
   Loaded as its own stylesheet: no Tailwind build. */

:root {
  --tok-key: var(--color-tg);
  --tok-string: var(--color-brand-600);
  --tok-number: var(--color-mon-orange);
  --tok-bool: var(--color-warning);
  --tok-null: var(--color-warning);
  --tok-punct: var(--color-foreground-lighter);
  --tok-comment: var(--color-foreground-muted);
  --tok-keyword: var(--color-destructive);
  --tok-func: var(--color-tg);
  --tok-var: var(--color-warning);
  --tok-flag: var(--color-mon-orange);
  --tok-url: var(--color-brand-600);
  --tok-method: var(--color-success);
  --tok-header: var(--color-tg);
  --md-get: var(--color-success);
  --md-post: var(--color-tg);
  --md-put: var(--color-warning);
  --md-patch: var(--color-warning);
  --md-delete: var(--color-destructive);
  --md-note: var(--color-tg);
  --md-tip: var(--color-success);
  --md-warning: var(--color-warning);
  --md-danger: var(--color-destructive);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --tok-key: var(--color-secondary);
    --tok-string: var(--color-success);
    --tok-number: var(--color-warning-500);
    --tok-bool: var(--color-warning-500);
    --tok-null: var(--color-warning-500);
    --tok-keyword: var(--color-primary);
    --tok-func: var(--color-secondary);
    --tok-var: var(--color-warning-500);
    --tok-flag: var(--color-warning-500);
    --tok-url: var(--color-success);
    --tok-header: var(--color-secondary);
    --md-post: var(--color-secondary);
    --md-put: var(--color-warning-500);
    --md-patch: var(--color-warning-500);
    --md-note: var(--color-secondary);
    --md-warning: var(--color-warning-500);
  }
}

:root[data-theme="light"] {
  --tok-key: var(--color-secondary);
  --tok-string: var(--color-success);
  --tok-number: var(--color-warning-500);
  --tok-bool: var(--color-warning-500);
  --tok-null: var(--color-warning-500);
  --tok-keyword: var(--color-primary);
  --tok-func: var(--color-secondary);
  --tok-var: var(--color-warning-500);
  --tok-flag: var(--color-warning-500);
  --tok-url: var(--color-success);
  --tok-header: var(--color-secondary);
  --md-post: var(--color-secondary);
  --md-put: var(--color-warning-500);
  --md-patch: var(--color-warning-500);
  --md-note: var(--color-secondary);
  --md-warning: var(--color-warning-500);
}

/* ── tokens ─────────────────────────────────────────────────────────────── */
.tok-key { color: var(--tok-key); }
.tok-string { color: var(--tok-string); }
.tok-number { color: var(--tok-number); }
.tok-bool { color: var(--tok-bool); font-weight: 500; }
.tok-null { color: var(--tok-null); font-style: italic; }
.tok-punct { color: var(--tok-punct); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-keyword { color: var(--tok-keyword); font-weight: 500; }
.tok-func { color: var(--tok-func); }
.tok-var { color: var(--tok-var); }
.tok-flag { color: var(--tok-flag); }
.tok-url { color: var(--tok-url); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--tok-url) 35%, transparent); text-underline-offset: 2px; }
.tok-method { color: var(--tok-method); font-weight: 600; }
.tok-header { color: var(--tok-header); }

/* ── code blocks ────────────────────────────────────────────────────────── */
.md-code {
  margin: 0.75rem 0;
  border: 1px solid var(--color-border-default);
  border-radius: 8px;
  background: var(--color-surface-200);
  overflow: hidden;
}
.md-code.hidden { display: none; }
.md-tabs .md-code { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.25rem 0 0.75rem;
  border-bottom: 1px solid var(--color-border-default);
  background: var(--color-surface-100);
}
.md-code-lang { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-foreground-lighter); }
.md-code-copy { color: var(--color-foreground-lighter); transition: background-color 0.15s, color 0.15s; }
.md-code-copy:hover { color: var(--color-foreground); background: var(--color-surface-300); }
.md-code-pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-foreground);
}

/* tabs (one example in several languages) */
.md-tabs { margin: 0.75rem 0; }
.md-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--color-border-default);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--color-surface-100);
}
.md-tab { color: var(--color-foreground-lighter); transition: background-color 0.15s, color 0.15s; }
.md-tab:hover { color: var(--color-foreground); background: var(--color-surface-200); }
.md-tab[aria-selected="true"] { color: var(--color-foreground); background: var(--color-surface-300); }

/* request | response, side by side on wide screens, stacked below */
.md-example { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; }
@media (min-width: 1280px) {
  .md-example { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.md-example-col { min-width: 0; }

/* ── callouts, steps, headings ──────────────────────────────────────────── */
.md-callout {
  display: flex;
  gap: 0.625rem;
  margin: 0.75rem 0;
  padding: 0.625rem 0.75rem;
  border-left: 3px solid var(--md-callout);
  border-radius: 6px;
  background: color-mix(in srgb, var(--md-callout) 9%, transparent);
  color: var(--color-foreground-light);
}
.md-callout strong:first-child { color: var(--md-callout); }
.md-callout-icon { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--md-callout); }
.md-callout-note { --md-callout: var(--md-note); }
.md-callout-tip { --md-callout: var(--md-tip); }
.md-callout-warning { --md-callout: var(--md-warning); }
.md-callout-danger { --md-callout: var(--md-danger); }

.md-steps { list-style: none; counter-reset: md-step; margin: 0.75rem 0; padding: 0; }
.md-steps > li {
  counter-increment: md-step;
  position: relative;
  padding: 0.125rem 0 0.5rem 2.25rem;
  min-height: 1.75rem;
}
.md-steps > li::before {
  content: counter(md-step);
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface-200);
  color: var(--color-foreground);
  font-size: 12px;
  font-weight: 600;
}
.md-steps > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 1.625rem;
  bottom: 0.125rem;
  width: 1px;
  background: var(--color-border-default);
}

.md-content h2.md-heading { padding-top: 0.5rem; margin-top: 1.5rem; border-top: 1px solid var(--color-border-default); }
.md-heading { scroll-margin-top: 1rem; }
.md-anchor {
  display: inline-flex;
  margin-left: 0.375rem;
  vertical-align: middle;
  color: var(--color-foreground-lighter);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.md-heading:hover .md-anchor, .md-anchor:focus-visible { opacity: 1; }
.md-anchor:hover { color: var(--color-foreground); }
@media (hover: none) { .md-anchor { opacity: 0.6; } }

.md-content code { color: var(--color-foreground); }
.md-content table { font-size: 12px; }

/* ── HTTP method and status pills ──────────────────────────────────────── */
.md-method, .md-status {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 20px;
  padding: 0 0.5rem;
  border-radius: 9999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--md-pill);
  background: color-mix(in srgb, var(--md-pill) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-pill) 35%, transparent);
}
.md-method-sm { height: 16px; padding: 0 0.3125rem; font-size: 9px; min-width: 2.5rem; justify-content: center; }
.md-method-get { --md-pill: var(--md-get); }
.md-method-post { --md-pill: var(--md-post); }
.md-method-put { --md-pill: var(--md-put); }
.md-method-patch { --md-pill: var(--md-patch); }
.md-method-delete { --md-pill: var(--md-delete); }
.md-status-1xx, .md-status-3xx, .md-status-xxx { --md-pill: var(--color-foreground-lighter); }
.md-status-2xx { --md-pill: var(--md-get); }
.md-status-4xx { --md-pill: var(--md-warning); }
.md-status-5xx { --md-pill: var(--md-danger); }
.md-content h3 .md-status { margin-left: 0.375rem; vertical-align: middle; }

/* ── live-highlighted textarea (static/js/components/code-overlay.js) ──────
   A transparent-text <textarea> with a highlighted <pre> stacked ABOVE it
   (pointer-events: none, transparent background, so the textarea's caret and
   selection show through and every click/drag reaches the textarea). Above,
   not below: Chrome stops painting a layer UNDER a transparent textarea whose
   content is millions of pixels wide (a minified one-line file), measured
   2026-11-01; on top, nothing the textarea paints can hide it. The JS copies the
   textarea's font metrics and padding onto the <pre>'s <code>; this file only
   makes the two layers stack and keeps ligatures/kerning OFF in both, so a
   column is the same width above and below. First user: the Drive editor for
   .html / .htm sources. */
.code-overlay {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  background: var(--color-background);
}
.code-overlay-input,
.code-overlay-pre code {
  font-variant-ligatures: none;
  font-kerning: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.code-overlay-input {
  position: relative;
  z-index: 1;
  background: var(--color-background);
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--color-foreground);
}
.code-overlay-input::placeholder {
  color: var(--color-foreground-muted);
  -webkit-text-fill-color: var(--color-foreground-muted);
}
.code-overlay-input::selection {
  background: color-mix(in srgb, var(--color-primary) 32%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.code-overlay-pre {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  color: var(--color-foreground);
  background: transparent;
}
.code-overlay-pre code {
  display: block;
  width: max-content;
  min-width: 100%;
  white-space: pre;
}
/* Colour only: a token must never change a glyph's advance, so the weight /
   italics the docs blocks use (.tok-keyword 500, .tok-comment italic, ...) are
   dropped here — the caret above is laid out in the textarea's plain face. */
.code-overlay-pre code span { font-weight: inherit; font-style: inherit; }
.code-overlay-skip { display: inline-block; height: 0; }

/* Content (publishing) entry editor: the body is ONE document (static/js/publishing/doc-editor.js). Theme tokens
   only. (Tiptap injects the ProseMirror base rules itself.) The Placeholder extension marks the empty line the
   caret is on and puts the hint in `data-placeholder`; a ::before has to draw it. */
[data-pub-doc] p.is-empty::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
  color: var(--color-foreground-muted);
}
.pub-doc-shell { border: 1px solid var(--color-border-default); border-radius: 8px; background: var(--color-surface-100); }
.pub-doc-toolbar { position: sticky; top: 0; z-index: 20; background: var(--color-surface-100); border-bottom: 1px solid var(--color-border-default); border-radius: 8px 8px 0 0; }
.pub-doc-errors { margin: 0; padding: 8px 12px 8px 28px; list-style: disc; font-size: 12px; color: var(--color-destructive); border-bottom: 1px solid var(--color-border-default); }
.pub-doc-wrap { position: relative; padding: 16px 16px 24px 44px; }
@media (min-width: 640px) { .pub-doc-wrap { padding-left: 74px; } }   /* room for the drag handle and the "+" */
.pub-plus { position: absolute; left: 8px; top: 0; z-index: 5; display: flex; align-items: center; gap: 2px; }
.pub-plus.hidden { display: none; }
.pub-handle { cursor: grab; }
@media (max-width: 639px) { .pub-plus .pub-handle { display: none; } }   /* a finger has no drag: Move up / down is in the options */
.pub-doc .ProseMirror { outline: none; min-height: 320px; font-size: 14px; line-height: 1.65; color: var(--color-foreground); }
.pub-doc .ProseMirror > * + *, .pub-col > * + * { margin-top: 0.6em; }
.pub-doc p { margin: 0; }
.pub-doc h2 { font-size: 22px; font-weight: 500; margin-top: 1.2em; }
.pub-doc h3 { font-size: 18px; font-weight: 500; margin-top: 1.1em; }
.pub-doc h4 { font-size: 16px; font-weight: 500; margin-top: 1em; }
.pub-doc h5 { font-size: 14px; font-weight: 500; margin-top: 1em; }
.pub-doc h6 { font-size: 13px; font-weight: 500; margin-top: 1em; }
.pub-doc a { color: var(--color-secondary); text-decoration: underline; }
[data-theme="dark"] .pub-doc a { color: color-mix(in srgb, var(--color-secondary) 45%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pub-doc a { color: color-mix(in srgb, var(--color-secondary) 45%, white); } }
.pub-doc ul { list-style: disc; padding-left: 1.4em; }
.pub-doc ol { list-style: decimal; padding-left: 1.4em; }
.pub-doc li > p { margin: 0; }
.pub-doc blockquote { border-left: 2px solid var(--color-border-stronger); padding-left: 12px; color: var(--color-foreground-light); }
.pub-doc code { background: var(--color-surface-300); padding: 1px 4px; border-radius: 4px; font-size: 0.9em; }
.pub-doc sup { vertical-align: super; font-size: 0.75em; }
.pub-doc cite { font-style: italic; }
.pub-doc hr { border: 0; border-top: 1px solid var(--color-border-stronger); margin: 1.2em 0; cursor: pointer; }
.pub-doc hr.ProseMirror-selectednode { border-top-color: var(--color-foreground-light); border-top-width: 2px; }
.pub-doc table.pub-table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.pub-doc table.pub-table td, .pub-doc table.pub-table th { border: 1px solid var(--color-border-stronger); padding: 6px 10px; vertical-align: top; min-width: 60px; overflow-wrap: anywhere; }
.pub-doc table.pub-table th { background: var(--color-surface-200); font-weight: 600; text-align: left; }   /* a header cell reads as a header, as on the published page */
.pub-doc table.pub-table .selectedCell { background: var(--color-surface-300); }
.pub-doc .tableWrapper, .pub-doc table.pub-table { margin-top: 0.6em; }
/* A table sits in its own scroll box (doc-editor.js renders it): on a phone a wide table (an 8-column price table) keeps
   readable columns and scrolls sideways inside the page, never the page itself. Desktop keeps the fixed full-width layout. */
.pub-doc .pub-table-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.pub-doc .pub-table-scroll > table.pub-table { margin-top: 0; }
@media (max-width: 639px) {
  .pub-doc table.pub-table { table-layout: auto; width: auto; min-width: 100%; }
  .pub-doc table.pub-table td, .pub-doc table.pub-table th { min-width: 5.5em; overflow-wrap: break-word; }
}
.pub-card { position: relative; border: 1px solid transparent; border-radius: 8px; margin: 12px 0; cursor: pointer; user-select: none; }
/* A side picture is a float. Any other card (and a set of columns) is a box of its own, never text that flows around it: it starts
   BELOW a float. Without this the next card's box began at the float's top and ran under it, so its outline and its floating bar
   were drawn around the side picture instead of the picked card. The page itself contains its floats (a float at the end stays inside). */
.pub-doc .ProseMirror { display: flow-root; }
.pub-card:not([data-align]), .pub-columns-wrap { clear: both; }
.pub-card:not([data-kind="image"]):not([data-kind="gallery"]) { border-color: var(--color-border-default); background: var(--color-surface-200); }
.pub-card.ProseMirror-selectednode, .pub-card.is-selected { outline: 2px solid var(--color-foreground-light); outline-offset: 1px; }   /* selection is NEUTRAL: red means an error and nothing else */
.pub-card.has-error { border-color: var(--color-destructive); }
.pub-card-pill { display: inline-flex; align-items: center; height: 18px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 500; color: var(--color-destructive); border: 1px solid var(--color-destructive); background: transparent; flex-shrink: 0; }
.pub-card-pill[hidden] { display: none; }
.pub-flash { outline: 2px solid var(--color-foreground-light); outline-offset: 2px; }
/* The item's name and its trash can are an overlay shown on hover, focus and selection: nothing in the page moves when they appear. */
.pub-card-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 2px 8px; font-size: 12px; font-weight: 500; color: var(--color-foreground-light); }
.pub-card > .pub-card-head, .pub-columns-wrap > .pub-card-head { position: absolute; top: 6px; right: 6px; z-index: 3; max-width: calc(100% - 12px); border-radius: 6px; background: var(--color-surface-100); border: 1px solid var(--color-border-default); opacity: 0; pointer-events: none; transition: opacity 0.12s; }
.pub-card:hover > .pub-card-head, .pub-card:focus-within > .pub-card-head, .pub-card.ProseMirror-selectednode > .pub-card-head, .pub-card.has-error > .pub-card-head,
.pub-columns-wrap:hover > .pub-card-head, .pub-columns-wrap:focus-within > .pub-card-head, .pub-columns-wrap.ProseMirror-selectednode > .pub-card-head { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { .pub-card.ProseMirror-selectednode > .pub-card-head:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; } }   /* the floating bar carries the tools there */
.pub-card.has-error > .pub-card-head { opacity: 1; pointer-events: auto; }
.pub-card-head .pub-card-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-card-body { padding: 10px; font-size: 13px; color: var(--color-foreground); }
.pub-card[data-kind="image"] > .pub-card-body, .pub-card[data-kind="gallery"] > .pub-card-body { padding: 0; }
.pub-card-caption { display: block; width: 100%; margin-top: 4px; padding: 2px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; text-align: center; font-size: 12px; color: var(--color-foreground-lighter); outline: none; }
.pub-card-caption:hover { border-color: var(--color-border-default); }
.pub-card-caption:focus { border-color: var(--color-border-stronger); color: var(--color-foreground); }
.pub-card-play { display: flex; align-items: center; gap: 12px; padding: 14px 12px; color: var(--color-foreground-light); }
.pub-card-sub { color: var(--color-foreground-lighter); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.pub-card-errors { margin: 0; padding: 6px 10px 8px 26px; list-style: disc; font-size: 12px; color: var(--color-destructive); }
.pub-card-image img { display: block; max-width: 100%; max-height: 280px; border-radius: 6px; margin: 0 auto; }
/* A Normal centred picture keeps its own size, so its card shrinks to the picture: the outline and the floating bar wrap what is
   seen, with no empty band beside it. The caption never widens the card (it takes the card's width, not its own). */
.pub-card[data-kind="image"]:not([data-align]):not([data-size="wide"]):not([data-size="full"]) { width: fit-content; max-width: 100%; margin-left: auto; margin-right: auto; }
.pub-card-caption { width: 0; min-width: 100%; }
/* Size: Normal keeps the picture's own size (up to 280px tall); Wide fills the text column at the picture's own proportions; Full width goes a little past it, square. */
.pub-card[data-kind="image"][data-size="wide"] .pub-card-image img,
.pub-card[data-kind="image"][data-size="full"] .pub-card-image img { width: 100%; max-height: none; height: auto; }
.pub-card[data-kind="image"][data-size="full"] { margin-left: -16px; margin-right: -16px; }
/* A Wide / Full width picture is never taller than 80% of the window: a tall (portrait) one is drawn narrower, centred, at
   its own proportions (no crop, no bands), and its card shrinks with it. --ar is the picture's width / height, set by
   doc-editor.js once the picture has loaded; without it the card keeps the full width. */
.pub-card[data-kind="image"][data-size="wide"]:not([data-align]) { --w: min(100%, calc(80vh * var(--ar, 1000))); }
.pub-card[data-kind="image"][data-size="full"]:not([data-align]) { --w: min(calc(100% + 32px), calc(80vh * var(--ar, 1000))); }
.pub-card[data-kind="image"][data-size]:not([data-align]):is([data-size="wide"], [data-size="full"]) { width: var(--w); margin-left: calc((100% - var(--w)) / 2); margin-right: 0; }
.pub-card[data-kind="image"][data-size="full"] .pub-card-image img { border-radius: 0; }
/* Position: Left / Right floats the picture and the text runs around it (the Size is then the side picture's own width). A phone stacks it. */
.pub-card[data-kind="image"][data-align="left"], .pub-card[data-kind="image"][data-align="right"] { width: 45%; margin-top: 4px; }
.pub-card[data-kind="image"][data-align="left"] { float: left; clear: left; margin-right: 16px; margin-bottom: 8px; margin-left: 0; }   /* two side pictures on the same side stack, never squeeze the text into a strip */
.pub-card[data-kind="image"][data-align="right"] { float: right; clear: right; margin-left: 16px; margin-bottom: 8px; margin-right: 0; }
.pub-card[data-kind="image"][data-align] .pub-card-image img { width: 100%; max-height: none; }
/* Size of a side picture: Small about 30% of the text, Medium (none) 45%, Large 60%. */
.pub-card[data-kind="image"][data-align][data-size="small"] { width: 30%; }
.pub-card[data-kind="image"][data-align][data-size="large"] { width: 60%; }
@media (max-width: 639px) {
  .pub-card[data-kind="image"][data-align="left"], .pub-card[data-kind="image"][data-align="right"] { float: none; width: auto; margin: 12px 0; }
  .pub-card[data-kind="image"][data-size="full"] { margin-left: -12px; margin-right: -12px; }
  .pub-card[data-kind="image"][data-size="full"]:not([data-align]) { --w: min(calc(100% + 24px), calc(80vh * var(--ar, 1000))); }
  .pub-card[data-kind="image"][data-align][data-size="small"], .pub-card[data-kind="image"][data-align][data-size="large"] { float: none; width: auto; }
}
.pub-card-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.pub-card-thumbs img { display: block; width: 100%; height: 64px; object-fit: cover; border-radius: 4px; }
.pub-card-empty { display: flex; align-items: center; gap: 8px; color: var(--color-foreground-lighter); font-size: 12px; }
.pub-card-cta { display: inline-block; padding: 4px 14px; border-radius: 6px; font-size: 13px; background: var(--color-primary); color: #fff; }
.pub-card-cta.is-secondary { background: var(--color-surface-300); color: var(--color-foreground); }
.pub-card-cta.is-link { background: transparent; color: var(--color-primary); text-decoration: underline; padding-left: 0; }
.pub-columns-wrap { position: relative; margin: 12px 0; border: 1px dashed var(--color-border-stronger); border-radius: 8px; }
.pub-columns-wrap.ProseMirror-selectednode { outline: 2px solid var(--color-foreground-light); outline-offset: 1px; }
.pub-columns { display: flex; gap: 12px; padding: 36px 8px 8px; }   /* the room at the top is the "Columns" chip's: it never covers the first line of a column */
.pub-col { flex: 1 1 0; min-width: 0; border: 1px dashed var(--color-border-default); border-radius: 6px; padding: 6px 10px; }
@media (max-width: 639px) {
  .pub-doc-wrap { padding: 12px 12px 20px 36px; }
  .pub-columns { flex-direction: column; }
}
.pub-options { z-index: 10; }
/* The side column (Options, Status, History) is ONE sticky box with its own scroll, so the cards never lie on top of each other.
   Its height leaves out the app header (h-12, 48px) above the page's scroller as well as its own 16px top and bottom: with
   100vh - 32px a tall column (an image's Layout picker + a validation report) ran 32px below the window, History's end unreachable. */
@media (min-width: 1024px) {
  .pub-side-col { position: sticky; top: 16px; max-height: calc(100vh - 80px); overflow-y: auto; overscroll-behavior: contain; padding: 2px; margin: -2px; }
}

/* ── the toolbar: one row, scrolling sideways on a phone ── */
.pub-toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px; }
@media (max-width: 1100px) { .pub-toolbar-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; } }
.pub-tb-sep { flex: none; width: 1px; height: 16px; margin: 0 4px; background: var(--color-border-default); }
.pub-tb-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; color: var(--color-foreground-lighter); cursor: pointer; transition: background-color 0.1s, color 0.1s; }
.pub-tb-btn:hover { background: var(--color-surface-200); color: var(--color-foreground); }
.pub-tb-btn[aria-pressed="true"] { background: var(--color-surface-200); color: var(--color-foreground); }
.pub-tb-style { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; min-width: 128px; justify-content: space-between; padding: 0 8px; border-radius: 6px; border: 1px solid var(--color-border-default); font-size: 12px; color: var(--color-foreground); cursor: pointer; }
.pub-tb-style:hover { border-color: var(--color-border-stronger); }

/* ── the floating bar on the picked item ── */
.pub-float { position: absolute; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px; border: 1px solid var(--color-border-default); background: var(--color-surface-100); box-shadow: 0 4px 14px rgb(0 0 0 / 0.18); }
.pub-float[hidden] { display: none; }
.pub-float-btn { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: 6px; font-size: 12px; color: var(--color-foreground-light); cursor: pointer; }
.pub-float-btn[hidden] { display: none; }
.pub-float-icon { width: 26px; padding: 0; justify-content: center; }
.pub-float-btn:hover { background: var(--color-surface-200); color: var(--color-foreground); }
.pub-float-danger:hover { color: var(--color-destructive); }
.pub-float.is-compact .pub-float-btn > span { display: none; }   /* a narrow picture: icons only (each button keeps its aria-label) */
.pub-float.is-compact .pub-float-btn { width: 26px; padding: 0; justify-content: center; }

/* ── the options panel: column layout picker, gallery rows ── */
.pub-options[hidden] { display: none; }
.pub-col-layout { display: inline-flex; gap: 2px; width: 44px; height: 26px; padding: 4px; border-radius: 6px; border: 1px solid var(--color-border-strong); background: var(--color-surface-200); cursor: pointer; }
.pub-col-layout[hidden] { display: none; }
.pub-col-layout > span { flex-basis: 0; min-width: 0; border-radius: 2px; background: var(--color-foreground-muted); }
.pub-col-layout:hover { border-color: var(--color-border-stronger); }
.pub-col-layout[aria-pressed="true"] { border-color: var(--color-foreground-light); }
.pub-col-layout[aria-pressed="true"] > span { background: var(--color-foreground-light); }
.pub-gallery-row { display: flex; align-items: flex-start; gap: 6px; padding: 6px; border-radius: 8px; border: 1px solid var(--color-border-default); }
.pub-gallery-row.is-dragging { opacity: 0.45; }
.pub-gallery-thumb { flex: none; display: flex; align-items: center; justify-content: center; width: 72px; height: 54px; overflow: hidden; border-radius: 6px; background: var(--color-surface-200); }
.pub-gallery-fields { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pub-gallery-side { flex: none; display: flex; flex-direction: column; gap: 2px; }
.pub-gallery-handle, .pub-gallery-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; color: var(--color-foreground-lighter); cursor: pointer; }
.pub-gallery-handle { cursor: grab; }
.pub-gallery-handle:hover, .pub-gallery-btn:hover { background: var(--color-surface-200); color: var(--color-foreground); }

/* ── the preview, full screen ── */
[data-pub-preview-mount] iframe { height: calc(100vh - 210px); min-height: 360px; }


/* The language tabs of the entry editor: the picked language is NEUTRAL (red is for errors). */
[data-pub-locale-tabs] a[aria-current="page"] { border-color: var(--color-border-stronger); background: var(--color-surface-300); color: var(--color-foreground); }

/* ── the entry's "Search appearance" previews (publishing/partials/search_appearance.html): how the page looks in Google and
   when its link is shared, with the author's framing of the picture (share-framer.js). Theme tokens only. ── */
.pub-sa { font-size: 13px; line-height: 1.45; color: var(--color-foreground); }
.pub-sa-label { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-foreground-lighter); }
.pub-sa-label:first-child { margin-top: 0; }
.pub-sa-serp { display: flex; gap: 12px; align-items: flex-start; max-width: 640px; padding: 12px; border: 1px solid var(--color-border-default); border-radius: 8px; background: var(--color-surface-100); }
.pub-sa-serp.is-hidden-page { opacity: 0.6; }
.pub-sa-serp-main { flex: 1; min-width: 0; }
.pub-sa-site { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pub-sa-badge { flex: none; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--color-border-default); color: var(--color-foreground-lighter); }
.pub-sa-who { min-width: 0; }
.pub-sa-name, .pub-sa-url { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-sa-name { font-size: 12px; }
.pub-sa-url { font-size: 11px; color: var(--color-foreground-lighter); }
.pub-sa-title { margin: 6px 0 0; font-size: 18px; line-height: 1.3; color: var(--color-secondary); overflow-wrap: anywhere; }
[data-theme="dark"] .pub-sa-title { color: color-mix(in srgb, var(--color-secondary) 45%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pub-sa-title { color: color-mix(in srgb, var(--color-secondary) 45%, white); } }
.pub-sa-rich, .pub-sa-desc { margin: 2px 0 0; font-size: 13px; color: var(--color-foreground-light); overflow-wrap: anywhere; }
.pub-sa-date { color: var(--color-foreground-lighter); }
/* A picture is shown through a box of the shape the result uses; framed (`is-framed`), the picture is scaled and shifted
   inside it by an inline style (share_image.styles / share-framer.js), else it covers the box from its centre. */
.pub-sa-thumb, .pub-sa-share-frame { position: relative; display: block; overflow: hidden; background: var(--color-surface-300); }
.pub-sa-thumb { flex: none; width: 80px; height: 80px; border-radius: 6px; border: 1px solid var(--color-border-default); }
.pub-sa-thumb img, .pub-sa-share-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; max-width: none; }
.pub-sa-thumb img.is-framed, .pub-sa-share-frame img.is-framed { inset: auto; height: auto; object-fit: fill; }
.pub-sa-share { max-width: 500px; border: 1px solid var(--color-border-default); border-radius: 8px; overflow: hidden; background: var(--color-surface-100); }
.pub-sa-share-frame, .pub-sa-share-empty { width: 100%; aspect-ratio: 1.91 / 1; }
.pub-sa-share-empty { display: flex; align-items: center; justify-content: center; color: var(--color-foreground-lighter); background: var(--color-surface-300); }
.pub-sa-share-text { padding: 8px 12px 10px; }
.pub-sa-share-host { font-size: 11px; letter-spacing: 0.02em; color: var(--color-foreground-lighter); }
.pub-sa-share-title { margin: 2px 0 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.pub-sa-share-desc { margin: 2px 0 0; font-size: 12px; color: var(--color-foreground-lighter); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pub-sa-share-desc:empty { display: none; }
.pub-sa-frame-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.pub-sa-frame-state { font-size: 12px; color: var(--color-foreground-lighter); }
.pub-sa-hints { margin: 12px 0 0; padding-left: 18px; list-style: disc; font-size: 12px; color: var(--color-foreground-lighter); }
.pub-framer { margin-top: 12px; padding: 12px; border: 1px solid var(--color-border-default); border-radius: 8px; background: var(--color-surface-100); }
.pub-framer[hidden] { display: none; }
.pub-framer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pub-framer-help { margin: 6px 0 10px; font-size: 12px; color: var(--color-foreground-lighter); }
.pub-framer-stage { position: relative; width: 100%; max-width: 520px; overflow: hidden; border-radius: 6px; background: var(--color-surface-300); touch-action: none; cursor: crosshair; user-select: none; }
.pub-framer-stage img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
/* Everything outside the frame is dimmed (the shadow), the frame itself is clear and carries a white edge that reads on any picture. */
.pub-framer-box { position: absolute; box-sizing: border-box; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(0 0 0 / 0.6); cursor: move; outline: none; }
.pub-framer-box:focus-visible { border-color: var(--color-primary); }
.pub-framer-handle { position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px; border-radius: 4px; border: 2px solid #fff; background: rgb(0 0 0 / 0.6); cursor: nwse-resize; }
@media (pointer: coarse) { .pub-framer-handle { width: 28px; height: 28px; right: -14px; bottom: -14px; } }
.pub-framer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ── the image Layout picker (publishing/blocks/forms/image.html): each way a picture sits against the text, drawn ── */
.pub-lay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.pub-lay { display: flex; align-items: center; justify-content: center; height: 52px; padding: 6px; border-radius: 6px; border: 1px solid var(--color-border-default); background: var(--color-surface-100); color: var(--color-foreground-lighter); cursor: pointer; transition: border-color 0.1s, background-color 0.1s; }
.pub-lay:hover { border-color: var(--color-border-stronger); }
.pub-lay[aria-checked="true"] { border-color: var(--color-foreground-light); background: var(--color-surface-300); color: var(--color-foreground); }
.pub-lay:disabled { cursor: default; opacity: 0.6; }
.pub-lay-art { position: relative; display: block; width: 44px; height: 36px; }
.pub-lay-pic { position: absolute; top: 0; width: 18px; height: 16px; border-radius: 2px; background: currentColor; opacity: 0.55; }
.pub-lay-l { position: absolute; left: 0; right: 0; height: 2px; border-radius: 1px; background: currentColor; }
.pub-lay-l:nth-of-type(2) { top: 1px; } .pub-lay-l:nth-of-type(3) { top: 8px; } .pub-lay-l:nth-of-type(4) { top: 15px; }
.pub-lay-l:nth-of-type(5) { top: 22px; } .pub-lay-l:nth-of-type(6) { top: 29px; }
/* centred: the picture on top, the text under it */
[data-art="centre"] .pub-lay-pic { left: 13px; }
[data-art="centre"] .pub-lay-l:nth-of-type(2), [data-art="centre"] .pub-lay-l:nth-of-type(3), [data-art="centre"] .pub-lay-l:nth-of-type(4) { display: none; }
/* left / right, wrap around: lines beside the picture, then full width under it */
[data-art^="left"] .pub-lay-pic { left: 0; } [data-art^="right"] .pub-lay-pic { right: 0; }
[data-art="left"] .pub-lay-l:nth-of-type(-n+4), [data-art="left-beside"] .pub-lay-l { left: 22px; }
[data-art="right"] .pub-lay-l:nth-of-type(-n+4), [data-art="right-beside"] .pub-lay-l { right: 22px; }
/* beside only: every line stays in the column */
/* below: nothing beside the picture */
[data-art$="-below"] .pub-lay-l:nth-of-type(2), [data-art$="-below"] .pub-lay-l:nth-of-type(3), [data-art$="-below"] .pub-lay-l:nth-of-type(4) { display: none; }

/* ── how the text treats a side picture in the editor (the same rule as the preview and the sites) ── */
.pub-card[data-kind="image"][data-wrap="below"] { float: none; clear: both; margin-top: 12px; }
.pub-card[data-kind="image"][data-align="right"][data-wrap="below"] { margin-left: auto; }
.pub-card[data-kind="image"][data-width] { max-width: 100%; }
@media (max-width: 639px) { .pub-card[data-kind="image"][data-align][data-width] { width: auto !important; } }
/* The corner a picture is resized from (its width as a % of the text): shown on the picked picture. */
.pub-card-resize { position: absolute; right: -6px; bottom: -6px; z-index: 4; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--color-surface-100); background: var(--color-foreground-light); cursor: nwse-resize; touch-action: none; display: none; }
.pub-card.ProseMirror-selectednode > .pub-card-resize, .pub-card:hover > .pub-card-resize { display: block; }
@media (pointer: coarse) { .pub-card-resize { width: 24px; height: 24px; right: -10px; bottom: -10px; } }
/* "+ here": the line that appears between two blocks (and after the last) on hover / focus, to add text exactly there. */
.pub-gap { position: absolute; z-index: 5; left: 0; right: 0; height: 0; display: flex; align-items: center; pointer-events: none; }
.pub-gap.hidden { display: none; }
.pub-gap::before { content: ""; position: absolute; left: 30px; right: 8px; top: 0; border-top: 1px dashed var(--color-border-stronger); }
.pub-gap-btn { position: relative; pointer-events: auto; margin-left: 8px; display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; transform: translateY(0); border-radius: 999px; border: 1px solid var(--color-border-strong); background: var(--color-surface-100); font-size: 11px; color: var(--color-foreground-light); cursor: pointer; }
.pub-gap-btn:hover, .pub-gap-btn:focus-visible { color: var(--color-foreground); border-color: var(--color-border-stronger); }
.pub-card[data-align="right"] > .pub-card-resize { right: auto; left: -6px; cursor: nesw-resize; }

/* Content entry editor: the body's Visual / HTML switch and the HTML view (static/js/publishing/body-html.js). The HTML
   view IS the docs code block (.md-code, its head and the tok-* colours, light and dark) with the live-highlighted
   textarea of components/code-overlay.js inside, plus a line-number gutter and a find bar. */
.pub-mode-switch { display: inline-flex; padding: 0; gap: 0; border-radius: 6px; border: 1px solid var(--color-border-default); background: var(--color-surface-200); }
.pub-mode-btn { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 5px; font-size: 12px; color: var(--color-foreground-lighter); cursor: pointer; }
.pub-mode-btn:hover { color: var(--color-foreground); }
.pub-mode-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.pub-mode-btn[aria-pressed="true"] { background: var(--color-surface-100); color: var(--color-foreground); box-shadow: 0 0 0 1px var(--color-border-strong); }
.pub-html-shell { margin: 0; }
.pub-html-shell[hidden], .pub-html-find[hidden], .pub-html-removed[hidden] { display: none; }
.pub-html-find { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--color-border-default); background: var(--color-surface-100); }
.pub-html-find-input { flex: 1 1 auto; min-width: 0; max-width: 320px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--color-border-input); background: var(--color-background); font-size: 12px; color: var(--color-foreground); outline: none; }
.pub-html-find-input:focus { border-color: var(--color-primary); }
.pub-html-removed { padding: 8px 12px; border-bottom: 1px solid var(--color-border-default); background: color-mix(in srgb, var(--color-mon-orange) 10%, transparent); }
.pub-html-removed-list { margin: 6px 0 0; padding-left: 18px; list-style: disc; font-size: 12px; color: var(--color-foreground-light); overflow-wrap: anywhere; }
.pub-html-removed-list li + li { margin-top: 2px; }
.pub-html-body { position: relative; display: flex; height: min(70vh, 640px); min-height: 280px; background: var(--color-background); }
.pub-html-gutter { flex: 0 0 auto; margin: 0; overflow: hidden; min-width: 44px; padding: 12px 8px 12px 0; text-align: right; user-select: none; border-right: 1px solid var(--color-border-default); background: var(--color-surface-100); color: var(--color-foreground-muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6; }
.pub-html-gutter code { display: block; white-space: pre; padding-left: 8px; }
.pub-html-overlay { flex: 1 1 0%; }
.pub-html-input { flex: 1 1 0%; width: 100%; min-height: 0; resize: none; padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6; tab-size: 2; outline: none; border: 0; }
.pub-html-help { margin: 0; padding: 8px 12px; border-top: 1px solid var(--color-border-default); font-size: 11px; line-height: 1.5; color: var(--color-foreground-lighter); background: var(--color-surface-100); }
.pub-html-help code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
@media (max-width: 639px) { .pub-html-body { height: 60vh; } .pub-html-gutter { min-width: 34px; } .pub-html-input { padding: 10px; } }
[data-pub-doc-shell][hidden] { display: none; }
.pub-gap-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
