/* ═══════════════════════════════════════════════════════════════════════════
   CMS COMPONENTS — built only from semantic tokens (tokens.css).
   Flat colour only: no gradients, no glow. Icons sit bare — never in a tinted box.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui); font-size: var(--text-md); line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--leading-tight); }
p { margin: 0; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: color-mix(in srgb, var(--brand) 18%, transparent); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.i { flex: none; display: inline-block; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.display { font-family: var(--font-display); letter-spacing: -.01em; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* Headings scale */
.h-page { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: var(--weight-black); letter-spacing: -.015em; }
.h-section { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.h-card { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.eyebrow { font-size: var(--text-sm); font-weight: var(--weight-regular); color: var(--text-subtle); -webkit-text-stroke: var(--small-stroke) currentColor; }
/* Small regular text reads a touch heavier (Lato has no 500/600): a hairline stroke in the text colour. */
.hint, .counter, .label .opt, .menu-item .menu-desc, .kv dt, .breadcrumbs a, .breadcrumbs button, .segmented button, .tab, .table th, .small { -webkit-text-stroke: var(--small-stroke) currentColor; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  --btn-h: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--btn-h); padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid transparent; background: transparent; color: var(--text);
  font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; text-decoration: none !important;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-sm { --btn-h: 30px; padding: 0 10px; font-size: var(--text-sm); border-radius: var(--radius-sm); gap: 6px; }
.btn-lg { --btn-h: 44px; padding: 0 20px; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--sand-300); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-ghost[aria-pressed="true"], .btn-ghost[aria-expanded="true"] { background: var(--surface-active); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover:not(:disabled) { background: var(--primary-soft-hover); }
/* Text button — navy text, no fill. Use it instead of .btn-soft on warm paper
   surfaces (#F9F4EB / --bg-subtle), where a navy tint clashes with the warm tone. */
.btn-link { height: auto; padding: 0; border: 0; background: none; color: var(--primary-text); font-weight: var(--weight-bold); text-decoration: underline !important; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent) !important; text-underline-offset: 3px; }
.btn-link:hover:not(:disabled) { text-decoration-color: currentColor !important; }
.btn-link:active:not(:disabled) { transform: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-danger-ghost { color: var(--danger-text); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn .kbd { margin-left: 2px; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--on-primary) var(--on-primary) transparent transparent; animation: spin .7s linear infinite; }
.btn-secondary[aria-busy="true"]::after, .btn-ghost[aria-busy="true"]::after { border-color: var(--text) var(--text) transparent transparent; }
.btn-split { display: inline-flex; }
.btn-split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split > .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 9px; border-left: 1px solid color-mix(in srgb, var(--on-primary) 28%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form controls ────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field + .field, .field + .field-row, .field-row + .field, .field-row + .field-row { margin-top: var(--space-5); }
/* Fields side by side share one top edge: labels on one line, boxes on the next. */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-items: start; }
.field-row > .field { margin-top: 0; }
.label { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 20px; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text); }
.label .opt { font-weight: var(--weight-regular); color: var(--text-subtle); }
.hint { font-size: var(--text-xs); color: var(--text-subtle); line-height: var(--leading-snug); }
/* An icon in a footnote is as tall as one line of text, so its centre sits on the text's centre line
   (and on the first line when the note wraps). */
.hint > .i { vertical-align: top; height: 1lh; margin-right: 2px; }
.error-text { font-size: var(--text-xs); color: var(--danger-text); display: flex; gap: 6px; align-items: center; }
.counter { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.counter[data-state="warn"] { color: var(--warning-text); }
.counter[data-state="over"] { color: var(--danger-text); }
.counter[data-state="good"] { color: var(--success-text); }

.input, .textarea, .select {
  width: 100%; min-width: 0; height: 38px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font: inherit; font-size: var(--text-md); outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-disabled); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--sand-300); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--border-focus); box-shadow: var(--focus-ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.input:disabled, .textarea:disabled, .select:disabled { background: var(--surface-sunken); color: var(--text-subtle); cursor: not-allowed; }
.input-sm { height: 32px; font-size: var(--text-sm); padding: 0 10px; border-radius: var(--radius-sm); }
.textarea { height: auto; min-height: 88px; padding: 10px 12px; line-height: var(--leading-normal); resize: vertical; }
.textarea.mono, .input.mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.select { appearance: none; padding-right: 34px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A7068' stroke-width='2' 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 10px center; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .i:first-child { position: absolute; left: 11px; color: var(--text-subtle); pointer-events: none; }
.input-wrap > .i:first-child + .input { padding-left: 34px; }
.input-wrap > .input-suffix { position: absolute; right: 6px; display: flex; gap: 4px; align-items: center; }
.input-prefix-text { display: flex; align-items: stretch; }
.input-prefix-text > span { display: flex; align-items: center; padding: 0 10px; background: var(--surface-sunken); border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); color: var(--text-subtle); font-size: var(--text-sm); white-space: nowrap; }
.input-prefix-text > .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Checkbox & radio */
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--text-md); }
/* Animated: the box fills, the mark springs in (and shrinks away on uncheck),
   and the control dips slightly while pressed. Durations collapse to 0 under reduced motion. */
.check input { appearance: none; flex: none; margin: 2px 0 0; width: 18px; height: 18px; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: background var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out), box-shadow var(--duration-fast), transform var(--duration-fast) var(--ease-out); }
.check input::after { content: ''; width: 10px; height: 10px; background: var(--on-primary); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); transform: scale(0); opacity: 0; transition: transform var(--duration-base) var(--ease-out), opacity var(--duration-fast); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]::after { clip-path: circle(35%); }
.check input:hover:not(:disabled) { border-color: var(--primary); }
.check input:active:not(:disabled) { transform: scale(.88); }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { transform: scale(1); opacity: 1; transition: transform var(--duration-slow) var(--ease-spring), opacity var(--duration-fast); }
.check input:focus-visible { box-shadow: var(--focus-ring); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--text-md); }
.switch input { appearance: none; position: relative; flex: none; margin: 0; width: 36px; height: 21px; border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background var(--duration-base); }
.switch input::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--duration-base) var(--ease-spring); }
.switch input:checked { background: var(--success); }
.switch input:checked::after { transform: translateX(15px); }
.switch input:focus-visible { box-shadow: var(--focus-ring); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-sunken); border-radius: var(--radius-md); border: 1px solid var(--border); }
.segmented button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--duration-fast); white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented.full { display: flex; }
.segmented.full button { flex: 1; justify-content: center; }
.segmented .count, .tab .count { font-size: var(--text-2xs); font-weight: var(--weight-bold); padding: 1px 6px; border-radius: 999px; background: var(--chip-neutral); color: var(--chip-neutral-text); font-variant-numeric: tabular-nums; }

/* Color input */
.color-input { display: flex; align-items: center; gap: 8px; }
.color-input input[type="color"] { appearance: none; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: none; cursor: pointer; }
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-input input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }

/* ── Badges & status ──────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); background: var(--chip-neutral); color: var(--chip-neutral-text); white-space: nowrap; line-height: 1; font-variant-numeric: tabular-nums; }
.badge-sm { height: 18px; padding: 0 6px; font-size: var(--text-2xs); }
.badge .i { width: 12px; height: 12px; }
.badge-success { background: var(--chip-success); color: var(--success-text); }
.badge-warning { background: var(--chip-warning); color: var(--warning-text); }
.badge-danger { background: var(--chip-danger); color: var(--danger-text); }
.badge-info { background: var(--chip-info); color: var(--info-text); }
.badge-violet { background: var(--chip-violet); color: var(--violet-text); }
.badge-primary { background: var(--chip-primary); color: var(--primary-text); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }
.status { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px 0 8px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; background: var(--chip-neutral); color: var(--chip-neutral-text); }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--status-draft); }
.status[data-status="published"] { background: var(--chip-success); color: var(--success-text); }
.status[data-status="published"]::before { background: var(--status-published); }
.status[data-status="changed"] { background: var(--chip-warning); color: var(--warning-text); }
.status[data-status="changed"]::before { background: var(--status-changed); }
.status[data-status="scheduled"] { background: var(--chip-violet); color: var(--violet-text); }
.status[data-status="scheduled"]::before { background: var(--status-scheduled); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--status-draft); flex: none; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); min-width: 0; }
.card-pad { padding: var(--space-6); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-6) 0; }
.card-header + .card-body { padding-top: var(--space-4); }
.card-body { padding: var(--space-6); }
.card-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); background: var(--bg-subtle); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.card-hover { transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base), border-color var(--duration-base); cursor: pointer; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card-accent { background: var(--surface); border-color: var(--border-strong); }

/* ── Icons (bare — no tinted squares or circles) ──────────────────────────────
   `.tile` is the one wrapper for a standalone icon. It only reserves an
   aligned slot; colour comes from meaning: neutral by default, navy for
   primary things, status colours only when the icon *is* a status. */
.tile { --tile: var(--text-muted); display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; color: var(--tile); }
.tile-sm { width: 16px; height: 16px; }
.tile-lg { width: 26px; height: 26px; }
.tile[data-color="primary"] { --tile: var(--primary-text); }
.tile[data-color="green"] { --tile: var(--success-text); }
.tile[data-color="amber"] { --tile: var(--warning-text); }
.tile[data-color="red"] { --tile: var(--danger-text); }

/* ── Avatars ──────────────────────────────────────────────────────────────── */
.avatar { --av: 28px; --av-c: var(--navy-500); flex: none; display: inline-grid; place-items: center; width: var(--av); height: var(--av); border-radius: 50%; font-size: calc(var(--av) * .38); font-weight: var(--weight-bold); color: #fff; background: var(--av-c); user-select: none; }
.avatar[data-color="ember"] { --av-c: var(--ember-700); }
.avatar-xs { --av: 20px; } .avatar-sm { --av: 24px; } .avatar-lg { --av: 40px; } .avatar-xl { --av: 56px; }
.avatar[data-color="violet"] { --av-c: var(--violet-600); } .avatar[data-color="blue"] { --av-c: var(--blue-600); }
.avatar[data-color="teal"] { --av-c: var(--teal-700); } .avatar[data-color="green"] { --av-c: var(--green-600); }
.avatar[data-color="amber"] { --av-c: var(--amber-600); } .avatar[data-color="rose"] { --av-c: var(--rose-500); }
.avatar[data-color="neutral"] { --av-c: var(--sand-500); }
.avatar[data-pending] { background: var(--surface-active); color: var(--text-subtle); border: 1.5px dashed var(--border-strong); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -7px; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; border: 0; background: none; color: var(--text-muted); font-size: var(--text-md); font-weight: var(--weight-medium); cursor: pointer; white-space: nowrap; text-decoration: none !important; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: var(--weight-semibold); }
.tab[aria-selected="true"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-md); }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--text-subtle); padding: 10px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child { border-top-left-radius: var(--radius-xl); }
.table th:last-child { border-top-right-radius: var(--radius-xl); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--duration-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr[data-href] { cursor: pointer; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .row-actions { opacity: 0; transition: opacity var(--duration-fast); }
.table tr:hover .row-actions, .table tr:focus-within .row-actions { opacity: 1; }

/* ── Menu / dropdown ──────────────────────────────────────────────────────── */
.menu { position: fixed; z-index: calc(var(--z-modal) + 8); /* above sheets and popovers it can open from */ min-width: 200px; max-width: 320px; padding: 6px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop var(--duration-base) var(--ease-out); transform-origin: top; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--radius-sm); font-size: var(--text-md); text-align: left; color: var(--text); cursor: pointer; text-decoration: none !important; }
.menu-item .i { color: var(--text-subtle); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); box-shadow: none; }
.menu-item[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.menu-item.danger { color: var(--danger-text); }
.menu-item.danger .i { color: currentColor; }
.menu-item .kbd, .menu-item .menu-meta { margin-left: auto; }
.menu-item .menu-desc { display: block; font-size: var(--text-xs); color: var(--text-subtle); font-weight: var(--weight-regular); margin-top: 1px; }
.menu-item[aria-checked="true"]::after { content: ''; margin-left: auto; width: 14px; height: 14px; background: var(--primary); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.menu-sep { height: 1px; margin: 6px -6px; background: var(--border); }
.menu-label { padding: 8px 10px 4px; font-size: var(--text-xs); color: var(--text-subtle); -webkit-text-stroke: var(--small-stroke) currentColor; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ── Overlays ────────────────────────────────────────────────────────────────
   Two kinds, nothing else:
   • Sheet  — a floating panel that slides in from the right over a darkened page.
              For real tasks: element library, version history, invites, asset details.
   • Popover — a small box anchored to the button that opened it, no backdrop.
              For quick actions: publish, new page, confirmations, rename. */
.backdrop { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--overlay); animation: fade var(--duration-base) var(--ease-out); }
.sheet { position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: calc(var(--z-modal) + 1); width: min(var(--sheet-w, 520px), calc(100vw - 24px)); display: flex; flex-direction: column; background: var(--surface-raised); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); overflow: hidden; animation: sheetIn var(--duration-slow) var(--ease-out); }
.sheet-sm { --sheet-w: 420px; } .sheet-md { --sheet-w: 520px; } .sheet-lg { --sheet-w: 680px; } .sheet-xl { --sheet-w: 960px; }
.sheet.leaving { animation: sheetOut var(--duration-base) var(--ease-out) forwards; }
.modal-header { display: flex; align-items: flex-start; gap: var(--space-4); padding: var(--space-6) var(--space-6) 0; }
.modal-header .h-modal { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-black); letter-spacing: -.01em; }
.modal-header p { color: var(--text-muted); margin-top: 4px; }
.modal-header .close { margin-left: auto; margin-top: -4px; margin-right: -8px; }
.modal-body { padding: var(--space-6); overflow-y: auto; flex: 1; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); }
.modal-footer .left { margin-right: auto; }
.popover { position: fixed; z-index: calc(var(--z-modal) + 5); width: min(var(--pop-w, 380px), calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: pop var(--duration-base) var(--ease-out); }
.popover.leaving { animation: fade var(--duration-fast) reverse forwards; }
.popover-head { display: flex; align-items: center; gap: var(--space-2); padding: 18px 20px 0; }
.popover-head h2 { font-size: var(--text-xl); font-weight: var(--weight-bold); flex: 1; min-width: 0; }
.popover-head .close { margin: -6px -10px -6px 0; }
.popover-desc { padding: 6px 20px 0; color: var(--text-muted); }
.popover-body { padding: 16px 20px; }
.popover-foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: 0 20px 18px; }
.popover-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetIn { from { opacity: 0; transform: translateX(32px); } }
@keyframes sheetOut { to { opacity: 0; transform: translateX(32px); } }
@media (max-width: 700px) { .sheet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: calc(100vh - 48px); } }

/* ── Toasts ──────────────────────────────────────────────────────────────────
   One stack at the bottom centre. The newest toast is in front; up to two older
   ones peek out behind it (smaller, fainter). Hovering the stack fans it out. */
.toasts { position: fixed; z-index: var(--z-toast); bottom: 20px; left: 50%; width: min(440px, calc(100vw - 32px)); transform: translateX(-50%); }
.toast { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 8px 8px 14px; background: var(--surface-inverse); color: var(--text-inverse); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-size: var(--text-md); transform-origin: 50% 100%;
  transform: translateY(calc(var(--i, 0) * -10px)) scale(calc(1 - var(--i, 0) * .05)); opacity: calc(1 - var(--i, 0) * .25);
  transition: transform var(--duration-slow) var(--ease-out), opacity var(--duration-slow) var(--ease-out); animation: toastIn var(--duration-slow) var(--ease-spring); }
.toast[data-hidden] { opacity: 0; pointer-events: none; }
.toasts.expanded .toast { transform: translateY(calc(var(--y, 0) * -1px)); opacity: 1; }
.toasts.expanded .toast[data-hidden] { opacity: 0; }
.toast.leaving { opacity: 0 !important; translate: 0 8px; transition: opacity var(--duration-base), translate var(--duration-base); }
.toast > .i { color: var(--navy-200); flex: none; }
.toast[data-tone="success"] > .i { color: #4ADE80; }
.toast[data-tone="danger"] > .i { color: #FF8A8E; }
.toast .toast-msg { flex: 1; min-width: 0; padding-right: 6px; }
.toast .btn { color: var(--text-inverse); height: 30px; }
.toast .btn:hover:not(:disabled) { background: rgba(255,255,255,.12); color: #fff; }
.toast .toast-action { color: var(--navy-200); }
@keyframes toastIn { from { opacity: 0; translate: 0 16px; } }

/* ── Tooltip ──────────────────────────────────────────────────────────────────
   One element positioned by ui.js: fixed to the viewport (always on top) and kept
   8px inside its edges, so labels near the far left/right are never cut off. */
.tooltip { position: fixed; z-index: var(--z-tooltip); max-width: 260px; padding: 6px 9px; border-radius: var(--radius-sm); background: var(--surface-inverse); color: var(--text-inverse); font-size: var(--text-xs); line-height: 1.3; pointer-events: none; box-shadow: var(--shadow-md); animation: fade var(--duration-fast) var(--ease-out); }

/* ── In-place steps (a confirm or rename inside an open sheet/popover) ── */
.inplace { display: grid; gap: 10px; padding: 16px 20px 18px; align-content: start; }
.sheet > .inplace { padding: 20px 24px; }
.inplace-back { justify-self: start; margin-left: -10px; }
.inplace-title { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.inplace-foot { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: 6px; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.kbd { display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-subtle); font-family: var(--font-ui); font-size: var(--text-2xs); font-weight: var(--weight-semibold); line-height: 1; }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-6) 0; }
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--info-soft); color: var(--text); font-size: var(--text-md); line-height: var(--leading-snug); }
.callout > .i { margin-top: 1px; color: var(--info-text); }
.callout-warning { background: var(--warning-soft); } .callout-warning > .i { color: var(--warning-text); }
.callout-danger { background: var(--danger-soft); } .callout-danger > .i { color: var(--danger-text); }
.callout-success { background: var(--success-soft); } .callout-success > .i { color: var(--success-text); }
.callout-brand { background: var(--primary-soft); } .callout-brand > .i { color: var(--primary-text); }
.callout strong { font-weight: var(--weight-semibold); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-active); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width var(--duration-slow) var(--ease-out); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin .7s linear infinite; }
.skeleton { background: var(--surface-active); animation: breathe 1.4s ease-in-out infinite; border-radius: var(--radius-sm); }
@keyframes breathe { 50% { opacity: .55; } }
.breadcrumbs { display: flex; align-items: center; gap: 4px; font-size: var(--text-md); color: var(--text-subtle); min-width: 0; }
.breadcrumbs a, .breadcrumbs button { color: var(--text-muted); background: none; border: 0; padding: 4px 6px; border-radius: var(--radius-xs); cursor: pointer; font-weight: var(--weight-medium); }
.breadcrumbs a:hover, .breadcrumbs button:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.breadcrumbs [aria-current] { color: var(--text); font-weight: var(--weight-semibold); padding: 4px 6px; }

/* Empty state */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--space-3); padding: var(--space-16) var(--space-6); }
.empty-art { display: grid; place-items: center; margin-bottom: var(--space-1); color: var(--primary-text); }
.empty h3 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-black); }
.empty p { color: var(--text-muted); max-width: 42ch; }
.empty .btn { margin-top: var(--space-2); }

/* Score ring */
.score { position: relative; display: inline-grid; place-items: center; flex: none; }
.score svg { transform: rotate(-90deg); }
.score .track { stroke: var(--surface-active); }
.score .value { transition: stroke-dashoffset 800ms var(--ease-out); }
.score b { position: absolute; font-family: var(--font-display); font-weight: var(--weight-black); font-variant-numeric: tabular-nums; }
.score[data-tone="success"] .value { stroke: var(--green-500); }
.score[data-tone="warning"] .value { stroke: var(--amber-500); }
.score[data-tone="danger"] .value { stroke: var(--red-500); }

/* Dropzone */
.dropzone { position: relative; display: grid; place-items: center; gap: 8px; padding: var(--space-8); text-align: center; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-xl); background: var(--bg-subtle); color: var(--text-muted); transition: all var(--duration-base); }
.dropzone.over { border-color: var(--brand); background: var(--surface); color: var(--primary-text); transform: scale(1.005); }

/* Check list (SEO) */
.checks { display: grid; gap: 2px; }
.check-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 10px; border-radius: var(--radius-md); }
.check-row:hover { background: var(--surface-hover); }
.check-row .ico { display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; }
.check-row[data-status="pass"] .ico { color: var(--success-text); }
.check-row[data-status="warn"] .ico { color: var(--warning-text); }
.check-row[data-status="fail"] .ico { color: var(--danger-text); }
.check-row .t { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.check-row .d { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; line-height: var(--leading-snug); }

/* Stack helpers */
.row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.row-3 { gap: var(--space-3); } .row-4 { gap: var(--space-4); }
.stack { display: grid; gap: var(--space-2); } .stack-4 { display: grid; gap: var(--space-4); } .stack-6 { display: grid; gap: var(--space-6); }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4, .field-row { grid-template-columns: 1fr; } }

/* Success mark — the one celebratory moment (publishing). The navy disc just fades in (barely growing,
   from its own centre); the tick is the part that animates: it draws itself. */
.success-mark circle { fill: var(--primary); transform-box: fill-box; transform-origin: center; animation: markFade 220ms var(--ease-out) both; }
.success-mark path { fill: none; stroke: var(--on-primary); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: markDraw 420ms 160ms var(--ease-out) forwards; }
@keyframes markFade { from { opacity: 0; transform: scale(.94); } }
@keyframes markDraw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .success-mark circle { animation: none; } .success-mark path { animation: none; stroke-dashoffset: 0; } }

[hidden] { display: none !important; }
