/* lib-web base layer + theme.
 *
 * Loaded automatically by pawlytics.lib-web.interface.render/page from
 * <assets-path>/web.css. This is plain CSS — not a Tailwind file, no
 * build step.
 *
 * THEME CONTRACT: the --web-* custom properties below are lib-web's
 * theme. The defaults are the Pawlytics light palette (from the
 * pawlytics.pen design system); override any of them in :root from the
 * host application's own stylesheet to re-theme every lib-web component
 * at once (render, chrome, forms). lib-web's markup references these via
 * Tailwind arbitrary values — e.g. bg-[var(--web-surface)] — so no
 * Tailwind colour config is required.
 *
 * Open Sans (the Pawlytics brand font) is linked from Google Fonts by
 * render/page (:web-fonts?, default true) rather than @imported here, so a
 * page can opt out — the public /w pages use the system font stack. */

:root {
  --web-font:           "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --web-radius:         4px;

  --web-canvas:         #f5f7fa;  /* page background         */
  --web-surface:        #ffffff;  /* cards, inputs, top bars */
  --web-surface-raised: #f5f7fa;  /* hover / inset surfaces  */
  --web-border:         #e2e2e2;  /* hairlines               */
  --web-fg:             #333333;  /* primary text            */
  --web-fg-muted:       #666666;  /* secondary text          */

  --web-accent:         #2ea3f2;  /* buttons, focus, active  */
  --web-accent-hover:   #1a8cd8;
  --web-accent-fg:      #ffffff;  /* text on an accent fill  */
  --web-ring:           rgba(46, 163, 242, 0.30);
  --web-link:           var(--web-accent); /* text links (a theme may set its own) */

  --web-sidebar:        #3f2a78;  /* Pawlytics purple rail   */
  --web-sidebar-fg:     #e9e3f8;
  --web-sidebar-muted:  #a89bd0;
  --web-sidebar-hover:  #5b3fb0;  /* active / hover row      */
  --web-sidebar-border: #33215f;

  --web-danger:         #c62828;  /* 5.6:1 with white, AA as text and as a fill */
  --web-danger-fg:      #ffffff;  /* text on a danger fill    */
  --web-ok:             #4caf50;
  --web-warning:        #ff9800;  /* available to host components */
  --web-info:           #2ea3f2;

  /* row dividers + tinted pill/tile backgrounds + faint text. These flip
     in dark so host views can reference them instead of hardcoding hexes. */
  --web-divider:        #f0f0f0;
  --web-fg-faint:       #999999;
  --web-accent-bg:      #e8f4fd;
  --web-ok-bg:          #e8f5e9;
  --web-danger-bg:      #ffebee;
  --web-warning-bg:     #fff3e0;
  --web-cat-purple-bg:  #f3e5f5;
  --web-cat-purple-fg:  #7b1fa2;

  --web-icon-stroke:    1.5;      /* Lucide icon stroke weight */

  color-scheme: light;
}

/* --- Apex dark theme ------------------------------------------------
 * "Apex Predator": near-obsidian indigo canvas with an electric-violet
 * accent. Applied when <html data-theme="dark"> (set by the opt-in
 * no-FOUC head script + web.js). The Pawlytics purple sidebar rail is
 * shared with light mode — only the content surfaces, text, accent and
 * semantic colours flip, so the rail pops against the obsidian canvas. */
html[data-theme="dark"] {
  color-scheme: dark;

  --web-canvas:         #0b0913;  /* obsidian page background */
  --web-surface:        #15121e;  /* cards, inputs, top bars  */
  --web-surface-raised: #1e1a2b;  /* hover / inset surfaces   */
  --web-border:         #2a2540;  /* hairlines                */
  --web-fg:             #f6f4ff;  /* primary text             */
  --web-fg-muted:       #a79fc8;  /* secondary text           */

  --web-accent:         #a35bff;  /* electric violet          */
  --web-accent-hover:   #b985ff;
  --web-accent-fg:      #14081f;  /* dark text on the violet  */
  --web-ring:           rgba(163, 91, 255, 0.40);

  --web-danger:         #ff5c6b;
  --web-danger-fg:      #14081f;  /* dark text on the bright red */
  --web-ok:             #4fe38a;
  --web-warning:        #ffb74d;
  --web-info:           #5bb8f5;

  --web-divider:        #262236;                    /* subtle on-surface line  */
  --web-fg-faint:       #8a82a8;
  --web-accent-bg:      rgba(163, 91, 255, 0.16);   /* violet tint             */
  --web-ok-bg:          rgba(79, 227, 138, 0.15);
  --web-danger-bg:      rgba(255, 92, 107, 0.15);
  --web-warning-bg:     rgba(255, 183, 77, 0.15);
  --web-cat-purple-bg:  rgba(163, 91, 255, 0.16);
  --web-cat-purple-fg:  #c79bff;

  /* Deeper rail in dark — the bright Pawlytics purple reads as a glare
     on the obsidian canvas, so dark drops it to a low, premium indigo. */
  --web-sidebar:        #1b1538;
  --web-sidebar-fg:     #ddd3f5;
  --web-sidebar-muted:  #847aa8;
  --web-sidebar-hover:  #372a6b;  /* active / hover row */
  --web-sidebar-border: #2a2150;
}

html { background: var(--web-canvas); }

body {
  background: var(--web-canvas);
  color: var(--web-fg);
  font-family: var(--web-font);
}

/* Inline Lucide icons: stroke weight is theme-driven (CSS wins over the
   stroke-width presentation attribute, which stays as a no-CSS
   fallback). Host apps re-weight all icons by overriding the var. */
.lucide {
  stroke-width: var(--web-icon-stroke, 1.5);
}

/* Self-hosted emoji glyphs render inline at 1em by default; a caller's
   width/height utilities still win over this fallback sizing. */
.emoji {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

/* Buttons are interactive — Tailwind v4's preflight resets the cursor to the
   browser default, so opt every <button> back into a pointer. The busy and
   :disabled rules below are more specific and still win. */
button {
  cursor: pointer;
}

/* Instant button feedback. htmx adds .htmx-request to the in-flight request's
   element (a form or button) synchronously on click, and hx-disabled-elt
   disables the control — so a click reads as busy immediately, before the
   response. Covers both a busy form (button inside) and a busy button. */
.htmx-request button,
button.htmx-request,
[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
  pointer-events: none;
}

button:disabled,
button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Small inline spinner — hidden until an ancestor element is mid-request (htmx
   adds .htmx-request). Drop a <span class="web-spinner"> in a button so the
   control visibly spins while its update is in flight. */
.web-spinner { display: none; }

.htmx-request .web-spinner,
.web-spinner.htmx-request,
.web-busy-table:has(.htmx-request) .web-spinner,
.web-busy-section.htmx-request .web-spinner,
.web-busy-section:has(.htmx-request:not(a)) .web-spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: web-spin 0.6s linear infinite;
  vertical-align: -0.1em;
}

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

@media (prefers-reduced-motion: reduce) {
  .htmx-request .web-spinner,
  .web-busy-table:has(.htmx-request) .web-spinner,
  .web-busy-section.htmx-request .web-spinner,
  .web-busy-section:has(.htmx-request:not(a)) .web-spinner { animation: none; }
}

/* Segmented filter pills (e.g. the Pets tab's All/Incoming/Current/Past).
   The selected look is driven by aria-pressed (set by the server) so it can
   flip the instant a pill is clicked: while the request is in flight, the
   clicked pill (htmx adds .htmx-request synchronously) shows selected and the
   others reset — then the swap settles it. Mirrors .web-subtab below. */
.web-seg { color: var(--web-fg-muted); }
.web-seg:hover { color: var(--web-fg); }
.web-seg[aria-pressed="true"] {
  background: var(--web-accent);
  color: var(--web-accent-fg);
}
.web-segs:has(.htmx-request) .web-seg {
  background: transparent;
  color: var(--web-fg-muted);
}
.web-segs:has(.htmx-request) .web-seg.htmx-request {
  background: var(--web-accent);
  color: var(--web-accent-fg);
}

/* Optimistic pick groups (controls/pick-group + webPick in web.js): a hidden
   input carries the group's value for hx-include, and a click flips
   aria-pressed + the input instantly via JS. Deliberately NOT .web-segs:
   pick-group buttons usually route .htmx-request elsewhere via hx-indicator,
   so the .web-segs :has(.htmx-request) flip rules would never match here —
   the instant flip is webPick's job. */
.web-pick-pill {
  border: 1px solid var(--web-border);
  background: var(--web-surface);
  color: var(--web-fg);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.web-pick-pill:hover { border-color: var(--web-accent); }
.web-pick-pill[aria-pressed="true"] {
  background: var(--web-accent);
  border-color: var(--web-accent);
  color: var(--web-accent-fg);
}
.web-pick-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--web-surface-raised);
  border: 1px solid var(--web-border);
  border-radius: 999px;
  padding: 2px;
}
.web-pick-seg button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--web-fg-muted);
  cursor: pointer;
}
.web-pick-seg button[aria-pressed="true"] {
  background: var(--web-surface);
  color: var(--web-accent);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(58, 38, 84, 0.18);
}

/* Busy table section: while ANY of its controls is mid-request (search, sort,
   page, a filter — htmx puts .htmx-request on the trigger), dim the rows and
   reveal the section's .web-spinner (rule above).

   .web-busy-section is the non-table generalization (e.g. a card grid): mark
   the section, put .web-busy-rows on the content to dim. It also matches
   .htmx-request on the section ITSELF, for surfaces whose controls route the
   indicator there via hx-indicator (a control OUTSIDE the section — like a
   hero search box — can then still drive the section's busy state). The
   :has() variant excludes anchors: an in-flight boosted <a> inside the
   section (a card link) is a page NAVIGATION — the universal overlay below
   owns that; matching it here would double the feedback. */
.web-busy-rows { transition: opacity 0.15s; } /* fade the un-dim too */

/* .web-pager (controls/table-footer): the Prev/Next buttons carry an inline
   chevron for a brick's compact pager variant (the tenant app floats the
   footer as a ‹ 1 / 5 › pill on mobile). Hidden here; the text label shows. */
.web-pager__icon { display: none; }
.web-busy-table:has(.htmx-request) tbody,
.web-busy-section.htmx-request .web-busy-rows,
.web-busy-section:has(.htmx-request:not(a)) .web-busy-rows {
  opacity: 0.45;
  transition: opacity 0.15s;
}

/* Universal navigation busy state — the house rule: ANY async load shows a
   spinner. Covers everything without scoped treatment: in-flight boosted
   links (sidebar + bottom nav, table row links, back links) and full-page
   form submits (PRG saves, report range forms) dim <main> and overlay a
   centered spinner until the swap lands. Excluded because they have their
   own loaders: .web-subtab tabs (#org-tab / .web-tabbed) and forms with a
   pinned hx-target (in-place toggles and section swaps). */
/* NOTE: never `position: relative` on <main> itself — a positioned <main>
   paints over the fixed sidebar (it spans the full width; the sidebar sits
   under its left padding) and silently swallows the nav's clicks. The
   spinner is viewport-fixed on body::after instead, so no element gains a
   position. */
/* Universal navigation overlay — driven SOLELY by body.web-nav-pending, which
   web.js sets on a real navigation CLICK (or a form PRG submit) and clears on
   afterSwap. It deliberately does NOT also key off :has(a.htmx-request): the
   nav links preload on hover (htmx preload ext), which puts .htmx-request on
   the link too, so a CSS-only trigger would flash the overlay on mouseover.
   Only a genuine click/submit clears the view.
   The outgoing view is CLEARED (display:none), not just dimmed — a section nav
   reads as clear -> spinner -> new content (same as .web-tabbed's tab-body
   below). <main> keeps a min-height during the load so the content panel
   doesn't collapse and the viewport-fixed spinner stays framed by it.
   web-nav-pending is held until afterSwap, so a View-Transition swap hands off
   spinner -> new view with no flash of the old content. */
/* /app (main#app-main) owns its own loading transition — the chrome cross-fades
   an opaque shimmer overlay in over the still-visible previous page (app-css).
   So does any surface on /app's shell (a <main> in the floating .app-panel,
   e.g. Pawthority): its content fades out in place, so the panel keeps its
   height until the new page lands and then resizes once. Other surfaces keep
   the clear-then-spinner behaviour. */
body.web-nav-pending main:not(#app-main, .app-panel main) {
  min-height: 55vh;
}
body.web-nav-pending main:not(#app-main, .app-panel main) > * {
  display: none;
}
body.web-nav-pending::after {
  content: "";
  position: fixed; /* viewport-anchored: always in view regardless of page height */
  top: 40%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid var(--web-border);
  border-top-color: var(--web-accent);
  border-radius: 50%;
  animation: web-spin 0.6s linear infinite;
  z-index: 40;
  pointer-events: none;
}

/* center within the CONTENT area on desktop when the chrome has the fixed
   240px sidebar (the .web-sidebar marker on chrome's <aside>); sidebar-less
   top-nav surfaces (e.g. Adoptables) keep the spinner at true 50%. */
@media (min-width: 768px) {
  body:has(.web-sidebar).web-nav-pending::after {
    left: calc(50% + 120px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.web-nav-pending::after {
    animation: none;
  }
}

/* Generic tabbed region (used by the org-detail tabs, Reports, Experimental):
   wrap a .web-subtabs bar + a .web-tab-body in .web-tabbed and a tab click
   instantly clears the body and shows a centered spinner until the next page
   (or fragment) lands. */
.web-tab-body { position: relative; }
.web-tabbed:has(.web-subtab.htmx-request) .web-tab-body { min-height: 160px; }
.web-tabbed:has(.web-subtab.htmx-request) .web-tab-body > * { display: none; }
.web-tabbed:has(.web-subtab.htmx-request) .web-tab-body::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid var(--web-border);
  border-top-color: var(--web-accent);
  border-radius: 50%;
  animation: web-spin 0.6s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .web-tabbed:has(.web-subtab.htmx-request) .web-tab-body::after { animation: none; }
}

/* Sub-nav tabs. The selected look is driven by aria-selected (set by the server)
   so it can flip the instant a tab is clicked: while a tab request is in flight,
   the clicked tab (htmx adds .htmx-request synchronously) shows selected and the
   others reset — before the new content loads — then the swap settles it. */
/* More tabs than the width holds (a phone) scroll sideways, rather than
   widening the page and pushing fixed elements off-centre. */
.web-subtabs { overflow-x: auto; scrollbar-width: none; }
.web-subtabs::-webkit-scrollbar { display: none; }
.web-subtab {
  flex-shrink: 0;
  white-space: nowrap;
  border-bottom-color: transparent;
  color: var(--web-fg-muted);
}
.web-subtab:hover { color: var(--web-fg); }
.web-subtab[aria-selected="true"] {
  border-bottom-color: var(--web-accent);
  color: var(--web-fg);
}
.web-subtabs:has(.htmx-request) .web-subtab {
  border-bottom-color: transparent;
  color: var(--web-fg-muted);
}
.web-subtabs:has(.htmx-request) .web-subtab.htmx-request {
  border-bottom-color: var(--web-accent);
  color: var(--web-fg);
}

/* Request-failure toast (web.js htmx:sendError/timeout/responseError).
   Click to dismiss; auto-dismisses after 6s. */
.web-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 90vw;
  padding: 10px 18px;
  border-radius: var(--web-radius);
  background: var(--web-danger);
  color: var(--web-danger-fg);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  animation: web-toast-in 0.18s ease-out;
}

@keyframes web-toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Skeleton shimmer for lazy-loaded content (htmx/lazy-load-attrs). A slow page
   renders its shell immediately with shimmer placeholders, which stream in real
   content as it arrives — rather than blocking the previous page on a spinner. */
.web-shimmer {
  background: linear-gradient(
    90deg,
    var(--web-surface-raised) 25%,
    var(--web-border) 37%,
    var(--web-surface-raised) 63%
  );
  background-size: 400% 100%;
  animation: web-shimmer 1.4s ease infinite;
  border-radius: var(--web-radius);
}

@keyframes web-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* View Transitions - keep the cross-fade short; the 500ms default feels
   sluggish for in-app navigation. web.js opts a swap in by adding
   `transition:true` to hx-swap only when the pathname changes. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 180ms;
}

@media (prefers-reduced-motion: reduce) {
  .web-shimmer,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    transition: none;
    animation: none;
  }
}

/* Schema editor — web.js enhances a JSON <textarea data-schema-source> into this
   list of drag-to-reorder question fields. The textarea stays the submitted
   source of truth; invalid JSON gets .is-invalid + a visible error. */
textarea.is-invalid { border-color: var(--web-danger); }
.schema-editor__error {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  color: var(--web-danger);
}
.schema-editor__error.is-visible { display: block; }
.schema-editor__fields {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.schema-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--web-border);
  border-radius: var(--web-radius);
  background: var(--web-surface);
}
.schema-row.is-dragging { opacity: 0.5; }
.schema-row__handle {
  cursor: grab;
  color: var(--web-fg-muted);
  user-select: none;
  font-size: 14px;
  line-height: 1;
}
.schema-row__num {
  width: 1.6em;
  text-align: right;
  font-size: 12px;
  color: var(--web-fg-muted);
  font-variant-numeric: tabular-nums;
}
.schema-row__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--web-fg);
  padding: 2px 0;
}
.schema-row__input:focus { outline: none; }
.schema-row__remove {
  border: 0;
  background: transparent;
  color: var(--web-fg-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}
.schema-row__remove:hover { color: var(--web-danger); }
.schema-add {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--web-link);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 2px 0;
}

/* Modal dialog — native <dialog> opened via [data-dialog-open] (web.js).
   Reliably centered (don't lean on the UA default). This rule is just the
   static box. web.js ("Modal dialogs", "Height animation") animates it with
   the Web Animations API: in as it opens, out after it has closed, and to
   its new height when its content changes. */
.web-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(92vw, 640px);
  height: fit-content;
  max-height: 88vh;
  overflow: auto;
  padding: 0;
  border: 1px solid var(--web-border);
  border-radius: var(--web-radius);
  background: var(--web-surface);
  color: var(--web-fg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
/* Backdrop fades in on open and out on close. The Web Animations API can't
   target ::backdrop, so the open fade is a keyframe that runs when the backdrop
   is created. For the close, web.js shows the dialog it has just closed as a
   popover (data-closing) while its exit plays. The dimming is then the box's
   own shadow, spread over the whole window, so it fades with the box, on the
   box's clock; and nothing in the leaving dialog takes a click. */
.web-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  animation: web-backdrop-in 0.2s ease;
}
.web-dialog[data-closing] {
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 0 0 200vmax rgba(0, 0, 0, 0.45);
}
.web-dialog[data-closing]::backdrop { background: transparent; animation: none; }
@keyframes web-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .web-dialog::backdrop { animation: none; }
}
/* An element web.js is moving to a new height ("Height animation"): what
   doesn't fit yet is cut off, not scrolled. Clipped where the browser can
   (hidden would make the element the box its sticky parts stick to, and a
   pinned tab bar inside it would let go for the length of the animation). */
[data-height-animating] { overflow: hidden !important; overflow: clip !important; }
/* No default focus outline (renders red on some systems) on the box itself or
   its auto-focused close control; keyboard users still get an accent ring. */
.web-dialog:focus { outline: none; }
.web-dialog [data-dialog-close] { outline: none; }
.web-dialog [data-dialog-close]:focus-visible {
  outline: 2px solid var(--web-accent);
  outline-offset: 2px;
}
.web-dialog pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Modal page (widgets/modal-page) — a large .web-dialog that shows whole
   pages over the page behind. A title bar that stays put (the title and
   Close), and a body that scrolls. Its size doesn't follow its content, so
   it stays still as pages of different lengths come and go. web.js sets
   data-busy on the dialog while a page or a save is on its way. */
.web-dialog--page {
  width: min(calc(100vw - 16px), 960px);
  max-width: none;
  height: 90vh;
  height: min(90vh, calc(100dvh - 16px));
  max-height: none;
  overflow: hidden;
}
/* only while open: display here would show a closed dialog */
.web-dialog--page[open] { display: flex; flex-direction: column; }
/* and while it leaves, shown as a popover (its own rule: a browser that
   doesn't know the selector drops only this) */
.web-dialog--page:popover-open { display: flex; flex-direction: column; }
.web-dialog__bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 24px;
  border-bottom: 1px solid var(--web-border);
}
.web-dialog__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--web-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.web-dialog__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--web-radius);
  background: transparent;
  color: var(--web-fg-muted);
  cursor: pointer;
}
.web-dialog__close:hover { background: var(--web-surface-raised); color: var(--web-fg); }
.web-dialog__close-icon { width: 20px; height: 20px; }
.web-dialog__page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 24px 24px;
}
.web-dialog__page > :first-child { margin-top: 20px; }
/* a place a link or a redirect lands on clears a bar pinned to the top */
.web-dialog__page [id] { scroll-margin-top: 76px; }
/* The busy states. An empty body (just opened) shows a centered spinner. A
   page or a save on its way dims what is there and spins in the title bar;
   a tab switch already clears the tab's body for its own spinner
   (.web-tabbed), so it gets neither. */
.web-dialog__page:empty::after,
.web-dialog__busy {
  width: 28px;
  height: 28px;
  border: 3px solid var(--web-border);
  border-top-color: var(--web-accent);
  border-radius: 50%;
  animation: web-spin 0.6s linear infinite;
}
.web-dialog__page:empty::after { content: ""; display: block; margin: 120px auto 0; }
.web-dialog__busy { display: none; flex: none; width: 18px; height: 18px; border-width: 2px; }
.web-dialog--page[data-busy]:not(:has(.web-subtab.htmx-request, .web-dialog__page:empty)) .web-dialog__busy {
  display: block;
}
.web-dialog--page[data-busy]:not(:has(.web-subtab.htmx-request)) .web-dialog__page > * {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
@media (max-width: 640px) {
  .web-dialog--page { height: 90vh; height: calc(100dvh - 16px); }
  .web-dialog__bar { padding-left: 16px; }
  .web-dialog__page { padding: 0 16px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .web-dialog__page:empty::after,
  .web-dialog__busy { animation: none; }
}

/* Confirm dialog (widgets/confirm-dialog) — web.js asks hx-confirm questions
   here instead of the browser's confirm(). A .web-dialog box; semantic
   classes rather than Tailwind utilities, so it looks the same on every
   surface, a CSP-strict one included. data-danger turns the confirm button
   red; data-alert (a notice) hides Cancel. */
.web-confirm { width: min(calc(100vw - 32px), 440px); }
.web-confirm__panel { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.web-confirm__title {
  margin: 0; font-size: 18px; font-weight: 800; line-height: 1.35;
  color: var(--web-fg); overflow-wrap: anywhere;
}
.web-confirm__message {
  margin: 0; font-size: 14px; line-height: 1.5; color: var(--web-fg); overflow-wrap: anywhere;
}
.web-confirm__message:empty { display: none; }
.web-confirm__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.web-confirm__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 8px 16px; border: 1px solid transparent;
  border-radius: var(--web-radius); font: inherit; font-size: 14px; font-weight: 600;
  line-height: 1.2; text-align: center;
}
.web-confirm__btn:focus-visible { outline: 2px solid var(--web-accent); outline-offset: 2px; }
.web-confirm__btn--cancel {
  border-color: var(--web-border); background: var(--web-surface); color: var(--web-fg);
}
.web-confirm__btn--cancel:hover { background: var(--web-surface-raised); }
.web-confirm__btn--ok { background: var(--web-accent); color: var(--web-accent-fg); }
.web-confirm__btn--ok:hover { background: var(--web-accent-hover); }
.web-confirm[data-danger] .web-confirm__btn--ok { background: var(--web-danger); color: var(--web-danger-fg); }
.web-confirm[data-danger] .web-confirm__btn--ok:hover { filter: brightness(0.92); }
.web-confirm[data-danger] .web-confirm__btn--ok:focus-visible { outline-color: var(--web-danger); }
.web-confirm[data-alert] .web-confirm__btn--cancel { display: none; }
/* phones: two equal buttons across the dialog, 44px tall */
@media (max-width: 480px) {
  .web-confirm__panel { padding: 20px; }
  .web-confirm__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .web-confirm[data-alert] .web-confirm__actions { grid-template-columns: 1fr; }
  .web-confirm__btn { min-height: 44px; }
}

/* Theme switch — a Light / Dark / Auto segmented control in the account
   panel (chrome). web.js sets aria-pressed on the active preference and
   flips <html data-theme>. Lives on the purple sidebar in both modes, so
   it uses translucent-white surfaces that read on the rail. */
.web-theme-switch {
  position: relative;
  display: flex;
  padding: 3px;
  border-radius: var(--web-radius);
  background: rgba(255, 255, 255, 0.10);
}
/* Sliding highlight. Sits behind the three equal segments and slides to
   the active one. Hidden until web.js sets data-active (so it never flashes
   at the wrong spot on load); the slide animates only once .is-animated is
   added, after the initial position is placed. */
.web-theme-switch__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border-radius: calc(var(--web-radius) - 1px);
  background: rgba(255, 255, 255, 0.18);
  opacity: 0;
  pointer-events: none;
}
.web-theme-switch[data-active] .web-theme-switch__thumb { opacity: 1; }
.web-theme-switch[data-active="dark"] .web-theme-switch__thumb { transform: translateX(100%); }
.web-theme-switch[data-active="auto"] .web-theme-switch__thumb { transform: translateX(200%); }
.web-theme-switch.is-animated .web-theme-switch__thumb {
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .web-theme-switch.is-animated .web-theme-switch__thumb { transition: none; }
}
.web-theme-switch__btn {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  border-radius: calc(var(--web-radius) - 1px);
  padding: 6px;
  color: var(--web-sidebar-muted);
  background: transparent;
  transition: color 0.15s;
}
.web-theme-switch__btn:hover { color: var(--web-sidebar-fg); }
.web-theme-switch__btn[aria-pressed="true"] { color: var(--web-sidebar-fg); }

/* --- Wizard components (interface.wizard; the public /w pages) -------------
   Semantic classes rather than Tailwind utilities: the /w shell is CSP-strict
   and small, and these must look the same wherever they are dropped in.
   Touch rules: 44px minimum targets, 16px form text (iOS zooms on focus below
   16px), the sticky CTA clears the iOS home indicator. */

.web-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;
}

/* Opt-in touch safety for any surface: wrap it in .web-touch. */
@media (pointer: coarse) {
  .web-touch input, .web-touch select, .web-touch textarea { font-size: 16px; }
  .web-touch { touch-action: manipulation; }
}

.web-money-input { font-size: 16px; }

/* Stepper — numbered circles on a line, every step named under its circle.
   When the row is too narrow for that (five or more steps in under 480px),
   the names alternate below and above the line, so each has two columns of
   room and none is cut short. */
.web-stepper { container-type: inline-size; }
.web-stepper__list {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  margin: 0; padding: 0; list-style: none;
}
.web-stepper__step { position: relative; min-width: 0; }
.web-stepper__step + .web-stepper__step::before {
  content: ""; position: absolute; top: 13px; left: -50%; right: 50%; height: 2px;
  background: var(--web-border);
}
.web-stepper__step--done::before, .web-stepper__step--current::before { background: var(--web-accent); }
.web-stepper__link {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: 4px;
  min-height: 44px; color: var(--web-fg-muted); text-decoration: none;
  font-size: 13px; line-height: 16px;
}
.web-stepper__num {
  position: relative; z-index: 1; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 2px solid var(--web-border); border-radius: 9999px;
  font-size: 13px; font-weight: 700; background: var(--web-surface);
}
.web-stepper__label { justify-self: unsafe center; white-space: nowrap; }
.web-stepper__step--done .web-stepper__num { border-color: var(--web-accent); color: var(--web-accent); }
.web-stepper__step--current .web-stepper__num {
  border-color: var(--web-accent); background: var(--web-accent); color: var(--web-accent-fg);
}
.web-stepper__step--current .web-stepper__link { color: var(--web-fg); font-weight: 600; }
a.web-stepper__link:hover .web-stepper__label { text-decoration: underline; }
@container (max-width: 480px) {
  .web-stepper__list:has(> :nth-child(5)) { padding: 0 8px; }
  .web-stepper__list:has(> :nth-child(5)) .web-stepper__link { grid-template-rows: 16px 28px 16px; }
  .web-stepper__list:has(> :nth-child(5)) .web-stepper__num { grid-row: 2; }
  .web-stepper__list:has(> :nth-child(5)) .web-stepper__label { grid-row: 3; }
  .web-stepper__list:has(> :nth-child(5)) .web-stepper__step:nth-child(even) .web-stepper__label { grid-row: 1; }
  .web-stepper__list:has(> :nth-child(5)) .web-stepper__step::before { top: 33px; }
}

/* Buttons — 44px targets; a .web-spinner inside shows while aria-busy. */
.web-btn {
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border: 1px solid transparent;
  border-radius: var(--web-radius); font: inherit; font-size: 16px; font-weight: 600;
  line-height: 1.2; text-decoration: none; cursor: pointer;
}
.web-btn--primary { background: var(--web-accent); color: var(--web-accent-fg); }
.web-btn--primary:hover { background: var(--web-accent-hover); }
.web-btn--secondary { background: var(--web-surface); color: var(--web-fg); border-color: var(--web-border); }
.web-btn:focus-visible { outline: 2px solid var(--web-accent); outline-offset: 2px; }
.web-btn[disabled], .web-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.web-btn[aria-busy="true"] .web-spinner {
  display: inline-block; width: 0.85em; height: 0.85em; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%;
  animation: web-spin 0.6s linear infinite; vertical-align: -0.1em;
}

/* Sticky CTA — pinned to the bottom of the viewport, in flow at the end. */
.web-sticky-cta {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--web-surface); border-top: 1px solid var(--web-border);
}
.web-sticky-cta > .web-btn { flex: 1 1 auto; }

/* Field — label, optional hint, control, per-field error. */
.web-field { display: flex; flex-direction: column; gap: 6px; }
.web-field__label { font-size: 14px; font-weight: 600; color: var(--web-fg); }
.web-field__req { color: var(--web-danger); }
.web-field__hint { margin: 0; font-size: 13px; color: var(--web-fg-muted); }
.web-field__error { margin: 0; font-size: 13px; font-weight: 600; color: var(--web-danger); }
.web-field input:not([type="checkbox"]):not([type="radio"]),
.web-field select, .web-field textarea {
  box-sizing: border-box; min-height: 44px; padding: 10px 12px; border: 1px solid var(--web-border);
  border-radius: var(--web-radius); background: var(--web-surface); color: var(--web-fg);
  font: inherit; font-size: 16px;
}
.web-field input:focus-visible, .web-field select:focus-visible, .web-field textarea:focus-visible {
  outline: 2px solid var(--web-accent); outline-offset: 1px;
}
.web-field--error input, .web-field--error select, .web-field--error textarea {
  border-color: var(--web-danger);
}

/* --- Widgets (interface.widgets; behaviour in web.js and show-when.js) ----- */

/* Popover — a details[data-menu] dropdown: web.js closes it on an outside
   click, on Escape (focus returns to the trigger) and when another opens. */
.web-popover { position: relative; display: inline-block; }
.web-popover > summary { list-style: none; cursor: pointer; }
.web-popover > summary::-webkit-details-marker { display: none; }
.web-popover__trigger {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface); color: var(--web-fg);
  font-size: 13px; font-weight: 600; user-select: none; -webkit-user-select: none;
}
.web-popover__trigger:hover { background: var(--web-surface-raised); }
.web-popover > summary:focus-visible { outline: 2px solid var(--web-accent); outline-offset: 2px; }
.web-popover[open] > .web-popover__trigger { border-color: var(--web-accent); }
.web-popover__chevron { transition: transform 0.15s; }
.web-popover[open] .web-popover__chevron { transform: rotate(180deg); }
.web-popover__panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  box-sizing: border-box; min-width: 12rem; max-width: min(22rem, calc(100vw - 32px));
  padding: 8px; border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface); color: var(--web-fg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}
.web-popover__panel--end { left: auto; right: 0; }
@media (prefers-reduced-motion: reduce) {
  .web-popover__chevron { transition: none; }
}

/* Sortable — [data-sortable] lists reordered by pointer or Alt+Arrow. */
[data-sortable-handle] {
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
/* without a handle the whole item is the grip: a long press must not open the
   image/link callout on iOS */
[data-sortable-item]:not(:has([data-sortable-handle])) { -webkit-touch-callout: none; }
[data-sortable-active], [data-sortable-active] * {
  cursor: grabbing; user-select: none; -webkit-user-select: none;
}
[data-sortable-item][data-sortable-dragging] { opacity: 0.45; }
[data-sortable-item]:focus { outline: none; }
[data-sortable-item]:focus-visible { outline: 2px solid var(--web-accent); outline-offset: 2px; }
.web-sortable { display: flex; flex-direction: column; gap: 6px; }
.web-sortable--x { flex-direction: row; flex-wrap: wrap; }
.web-sortable--list > .web-sortable__item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface); color: var(--web-fg);
}
.web-sortable--list > .web-sortable__item[data-sortable-dragging] { border-style: dashed; }
.web-sortable__handle {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; min-height: 24px; color: var(--web-fg-muted); font-size: 14px; line-height: 1;
}

/* Dirty guard — form[data-dirty-guard]; web.js shows the indicator while the
   form differs from what was last saved. */
.web-dirty-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--web-warning);
}
.web-dirty-indicator::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}
.web-dirty-indicator[hidden] { display: none; }
/* Controls that change with the form's state: inside a guarded form,
   .web-if-dirty shows only while it has unsaved changes and .web-if-clean only
   while it hasn't (the form builder's Publish / Save & publish). */
form[data-dirty-guard]:not([data-dirty]) .web-if-dirty,
form[data-dirty-guard][data-dirty] .web-if-clean { display: none !important; }

/* show-when.js hides a target with the hidden attribute; a class that sets
   display (.web-field is flex) must not bring it back. */
[data-show-when][hidden] { display: none !important; }

/* Column picker — a popover of column checkboxes with All / None / Apply. */
.web-colpick { display: flex; flex-direction: column; gap: 8px; }
.web-colpick__list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 50vh; overflow: auto; margin: 0; padding: 0; list-style: none;
}
.web-colpick__opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  border-radius: var(--web-radius); font-size: 13px; color: var(--web-fg); cursor: pointer;
}
.web-colpick__opt:hover { background: var(--web-surface-raised); }
.web-colpick__opt input { width: 16px; height: 16px; margin: 0; accent-color: var(--web-accent); }
.web-colpick__opt input:disabled + span { color: var(--web-fg-muted); }
.web-colpick__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--web-divider);
}
.web-colpick__links { display: inline-flex; gap: 4px; }
.web-colpick__links button {
  border: 0; background: transparent; padding: 4px 6px;
  font-size: 12px; font-weight: 600; color: var(--web-accent);
}
.web-colpick__apply {
  border: 0; border-radius: var(--web-radius); padding: 6px 14px;
  background: var(--web-accent); color: var(--web-accent-fg); font-size: 13px; font-weight: 600;
}
.web-colpick__apply:hover { background: var(--web-accent-hover); }

/* Textarea character counter (forms/textarea :maxlength; web.js updates it). */
[data-char-count-for] { margin: 0; font-size: 12px; color: var(--web-fg-muted); text-align: right; }
[data-char-count-for][data-near-limit] { color: var(--web-warning); font-weight: 600; }

/* --- Dropdowns (interface.dropdown; behaviour in web.js) ---------------------
   One trigger and one menu: select-menu chooses one value, check-menu several,
   add-menu builds a list. Each is a details[data-menu][data-dd], so the menu
   code above closes it; the controls inside are real inputs. */
.web-dd { position: relative; display: block; }
.web-dd--filter, .web-dd--add { display: inline-block; }
.web-dd > summary { list-style: none; cursor: pointer; }
.web-dd > summary::-webkit-details-marker { display: none; }
.web-dd [hidden] { display: none !important; }
.web-dd__trigger {
  display: flex; align-items: center; gap: 8px; box-sizing: border-box;
  min-height: 40px; padding: 7px 12px;
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface); color: var(--web-fg);
  font-size: 14px; user-select: none; -webkit-user-select: none;
  transition: border-color 0.12s, background 0.12s;
}
.web-dd__trigger:hover { border-color: var(--web-fg-faint); }
.web-dd > summary:focus-visible { outline: 2px solid var(--web-accent); outline-offset: 2px; }
.web-dd[open] > .web-dd__trigger {
  border-color: var(--web-accent); box-shadow: 0 0 0 1px var(--web-accent);
}
.web-dd[data-dd-invalid] > .web-dd__trigger { border-color: var(--web-danger); }
.web-dd[data-dd-disabled] > .web-dd__trigger {
  pointer-events: none; background: var(--web-surface-raised); color: var(--web-fg-muted);
}
.web-dd__value {
  flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.web-dd__value > [data-dd-text] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-dd__placeholder { color: var(--web-fg-muted); font-weight: 400; }
.web-dd__chevron { flex: none; color: var(--web-fg-muted); transition: transform 0.15s; }
.web-dd[open] > summary .web-dd__chevron { transform: rotate(180deg); color: var(--web-accent); }
.web-dd__label { flex: none; font-weight: 600; }

/* a filter row's compact trigger: its name, then a count or the choice */
.web-dd--filter > .web-dd__trigger {
  display: inline-flex; min-height: 36px; padding: 6px 12px; font-size: 13px;
}
.web-dd--filter[data-dd="one"] .web-dd__label { color: var(--web-fg-muted); }
.web-dd--filter .web-dd__value { flex: none; font-weight: 700; }
.web-dd--filter[data-dd-active] > .web-dd__trigger {
  background: var(--web-accent-bg); border-color: var(--web-accent); color: var(--web-accent);
}
.web-dd--filter[data-dd-active] .web-dd__label,
.web-dd--filter[data-dd-active] .web-dd__chevron { color: var(--web-accent); }
.web-dd__count {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--web-accent); color: var(--web-accent-fg); font-size: 12px; font-weight: 700;
}

.web-dd__panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; box-sizing: border-box;
  width: 100%; min-width: 14rem; max-width: calc(100vw - 32px); padding: 6px;
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface); color: var(--web-fg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}
/* In a dialog a floating menu would be cut off at the dialog's edge (the
   dialog scrolls its overflow), so there a form dropdown's menu opens in the
   flow: the dialog grows to hold it, and scrolls when it has to. */
.web-dialog .web-dd--field > .web-dd__panel, .web-dialog .web-dd--chips > .web-dd__panel {
  position: static; margin-top: 4px; box-shadow: none;
}
.web-dd--filter > .web-dd__panel, .web-dd--add > .web-dd__panel {
  width: max-content; min-width: 15rem; max-width: min(22rem, calc(100vw - 32px));
}
.web-dd--end > .web-dd__panel { left: auto; right: 0; }
.web-dd__list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: min(18rem, 50vh); overflow-y: auto; margin: 0; padding: 0; list-style: none;
}
.web-dd__opt {
  display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--web-radius);
  background: transparent; color: var(--web-fg);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.web-dd__opt:hover, .web-dd__opt:focus-visible, .web-dd__opt:focus-within {
  background: var(--web-surface-raised); outline: none;
}
.web-dd__opt[aria-selected="true"] {
  background: var(--web-accent-bg); color: var(--web-accent); font-weight: 700;
}
.web-dd__opt-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.web-dd__opt:has(input:checked) .web-dd__opt-label { font-weight: 700; }
.web-dd__opt input[type="checkbox"] {
  flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--web-accent);
}
.web-dd__hint { display: block; font-size: 12px; font-weight: 400; color: var(--web-fg-muted); }
.web-dd__opt-count { flex: none; font-size: 12px; color: var(--web-fg-muted); }
.web-dd__tick { flex: none; visibility: hidden; }
.web-dd__opt[aria-selected="true"] .web-dd__tick { visibility: visible; }
.web-dd__dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--web-fg-faint);
}
.web-dd__dot[data-dd-dot="ok"] { background: var(--web-ok); }
.web-dd__dot[data-dd-dot="info"] { background: var(--web-info); }
.web-dd__dot[data-dd-dot="warning"] { background: var(--web-warning); }
.web-dd__dot[data-dd-dot="danger"] { background: var(--web-danger); }
.web-dd__dot[data-dd-dot="accent"] { background: var(--web-accent); }
.web-dd__dot[data-dd-dot="purple"] { background: var(--web-cat-purple-fg); }
.web-dd__search {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px; padding: 7px 10px;
  border: 1px solid var(--web-border); border-radius: var(--web-radius); color: var(--web-fg-muted);
}
.web-dd__search:focus-within { border-color: var(--web-accent); color: var(--web-accent); }
.web-dd__search input {
  flex: 1 1 auto; min-width: 0; border: 0; outline: 0; padding: 0;
  background: transparent; color: var(--web-fg); font: inherit; font-size: 14px;
}
.web-dd__search-icon { flex: none; }
.web-dd__note { margin: 0; padding: 6px 10px; font-size: 12px; color: var(--web-fg-muted); }
.web-dd__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--web-divider);
}
.web-dd__clear {
  border: 0; background: transparent; padding: 6px 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--web-link);
}
.web-dd__done {
  border: 0; border-radius: var(--web-radius); padding: 6px 14px; cursor: pointer;
  background: var(--web-accent); color: var(--web-accent-fg); font-size: 13px; font-weight: 600;
}
.web-dd__done:hover { background: var(--web-accent-hover); }

/* chips: a chosen value with its own remove */
.web-dd--chips > .web-dd__trigger { padding: 5px 12px 5px 6px; }
.web-dd__chips {
  flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.web-dd__chips > .web-dd__placeholder { padding-left: 6px; }
.web-dd-chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  padding: 2px 4px 2px 10px; border-radius: 999px;
  background: var(--web-accent-bg); color: var(--web-accent);
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.web-dd-chip__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-dd-chip__x {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: inherit; font-size: 13px; cursor: pointer;
}
.web-dd-chip__x:hover, .web-dd-chip--link:hover .web-dd-chip__x { background: var(--web-surface); }
.web-dd-chip--more {
  padding: 4px 10px; background: var(--web-surface-raised); color: var(--web-fg-muted);
}
.web-dd-add { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.web-dd-add__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.web-dd-add__chips[hidden], .web-dd-add__empty[hidden] { display: none; }
.web-dd-add__empty { margin: 0; font-size: 13px; color: var(--web-fg-muted); }
.web-dd--add > .web-dd__trigger { display: inline-flex; font-weight: 600; }
.web-dd--add .web-dd__value { flex: none; }
.web-dd__plus { flex: none; color: var(--web-accent); }

/* the row that repeats a list's filters in use */
.web-dd-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.web-dd-active__summary { font-size: 13px; font-weight: 600; color: var(--web-fg-muted); }
.web-dd-active__clear { font-size: 13px; font-weight: 700; color: var(--web-link); }
@media (prefers-reduced-motion: reduce) {
  .web-dd__chevron, .web-dd__trigger { transition: none; }
}

/* On/off switch (forms/switch): a checkbox with role="switch", drawn as a
   track and thumb. The real input lies invisible over the track, so a click,
   the Space key, focus and a screen reader all meet a checkbox; nothing here
   needs script. --web-switch-on / --web-switch-off re-colour it. */
:root { --web-switch-off: #8c8c8c; }
html[data-theme="dark"] { --web-switch-off: #6b6488; }
.web-switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; color: var(--web-fg);
}
.web-switch__control {
  position: relative; display: inline-flex; flex: none; width: 44px; height: 24px;
}
.web-switch__input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: inherit; appearance: none; -webkit-appearance: none;
}
.web-switch__track {
  width: 100%; height: 100%; border-radius: 999px;
  background: var(--web-switch-off);
  transition: background-color 0.15s ease;
  pointer-events: none;
}
.web-switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #ffffff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.web-switch__input:checked + .web-switch__track { background: var(--web-switch-on, var(--web-accent)); }
.web-switch__input:checked + .web-switch__track::after { transform: translateX(20px); }
.web-switch__input:focus-visible + .web-switch__track {
  outline: 2px solid var(--web-accent); outline-offset: 2px;
}
.web-switch--disabled, .web-switch:has(.web-switch__input:disabled) { cursor: not-allowed; }
.web-switch__input:disabled + .web-switch__track { opacity: 0.45; }
.web-switch__state { font-size: 14px; font-weight: 700; min-width: 1.75em; }
.web-switch__on { display: none; }
.web-switch:has(.web-switch__input:checked) .web-switch__on { display: inline; }
.web-switch:has(.web-switch__input:checked) .web-switch__off { display: none; }
.web-switch:has(.web-switch__input:disabled) .web-switch__state { color: var(--web-fg-muted); }
.web-switch__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.web-switch__label { font-size: 14px; font-weight: 600; }
.web-switch__description { font-size: 12px; color: var(--web-fg-muted); }
@media (prefers-reduced-motion: reduce) {
  .web-switch__track, .web-switch__track::after { transition: none; }
}
/* Windows high contrast drops backgrounds: draw the track and thumb as borders */
@media (forced-colors: active) {
  .web-switch__track { border: 1px solid CanvasText; background: Canvas; }
  .web-switch__track::after { top: 1px; left: 1px; background: CanvasText; box-shadow: none; }
  .web-switch__input:checked + .web-switch__track { background: Highlight; }
  .web-switch__input:checked + .web-switch__track::after { background: HighlightText; }
  .web-switch__input:disabled + .web-switch__track { border-color: GrayText; }
  .web-switch__input:focus-visible + .web-switch__track { outline-color: Highlight; }
}

/* A wider .web-dialog, for one that lays columns side by side. */
.web-dialog--wide { width: min(94vw, 1040px); }
