/* =============================================================================
 * Design system — tokens + primitives.
 *
 * Loaded on every page after style.css so it overrides legacy. The intent is
 * that this file is the SAAS THEME PRIMITIVE: every visible color, spacing,
 * type, radius, shadow comes from a CSS custom property, so a future
 * per-workspace theme can swap the token block at runtime via inline <style>
 * (or by setting them on a parent element from server-rendered template) and
 * the entire UI rebrands without further work.
 *
 * Sections:
 *   1. Tokens (colors / spacing / type / radius / shadows / motion)
 *   2. Reset + base
 *   3. Topbar / nav
 *   4. Buttons / inputs / selects / textarea / chip
 *   5. Card / surface / kpi / badge / table
 *   6. Toast + modal
 *   7. Flash bridge (legacy `.flash` -> toast styling)
 *   8. Page shell + breadcrumb + hero
 *   9. Utilities
 * ============================================================================= */

/* ---------- 1. Tokens ----------------------------------------------------- */
:root {
  /* Surface (LIGHT default — photographer/editorial palette).
   * Switch to dark via [data-theme="dark"] on <html>. */
  --bg:        #fafaf7;
  --bg-elev-1: #ffffff;
  --bg-elev-2: #f5f4ef;
  --bg-elev-3: #ecebe5;
  --line:        rgba(0,0,0,.08);
  --line-strong: rgba(0,0,0,.16);
  --line-faint:  rgba(0,0,0,.04);

  /* Foreground */
  --fg:        #1a1a18;
  --fg-soft:   #585853;
  --fg-dim:    #8a8a85;
  --fg-faint:  #c2c2bc;

  /* Accent (workspace-themable; default = grails gold) */
  --accent:        #B98E2A;
  --accent-on:     #0a0d10;
  --accent-glow:   color-mix(in oklab, var(--accent) 22%, transparent);
  --accent-soft:   color-mix(in oklab, var(--accent) 14%, transparent);
  --accent-bright: color-mix(in oklab, var(--accent) 92%, white);

  /* Status */
  --green:  #4caf7a;
  --green-soft: rgba(76,175,122,.16);
  --red:    #ff7a7a;
  --red-soft: rgba(255,122,122,.13);
  --amber:  #f0b030;
  --amber-soft: rgba(240,176,48,.14);
  --blue:   #6aa9ff;
  --blue-soft: rgba(106,169,255,.14);

  /* Type scale — Geist + Instrument Serif. Geist is Vercel's UI font (free,
   * very current); Instrument Serif is a contemporary editorial serif that
   * reads less wedding-photography-2018 than Playfair Display. Both on
   * Google Fonts; no proprietary licensing. */
  --font-sans: 'Geist', 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Instrument Serif', 'Playfair Display', Georgia, serif;
  --font-mono: 'Geist Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --fs-15: 15px; --fs-16: 16px; --fs-18: 18px; --fs-22: 22px;
  --fs-28: 28px; --fs-36: 36px; --fs-48: 48px;

  /* Spacing */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Radius */
  --r-2: 4px; --r-3: 6px; --r-4: 8px; --r-5: 10px; --r-6: 12px; --r-pill: 999px;

  /* Shadow */
  --shadow-1: 0 1px 0 rgba(255,255,255,.04) inset, 0 2px 8px rgba(0,0,0,.25);
  --shadow-2: 0 1px 0 rgba(255,255,255,.05) inset, 0 8px 24px rgba(0,0,0,.4);
  --shadow-3: 0 1px 0 rgba(255,255,255,.06) inset, 0 18px 50px rgba(0,0,0,.55);

  /* Motion */
  --t-fast: .12s ease;
  --t: .18s ease;
  --t-slow: .28s cubic-bezier(.2,.9,.3,1.2);

  /* Layout */
  --topbar-h: 56px;
  --container-max: 1920px;     /* near-full-width on big screens, sensible cap on 4K */
  --sidebar-w: 280px;          /* fixed-left filter panel width on desktop */
}

/* Dark theme override. Toggled via the account-menu theme button which sets
 * `data-theme="dark"` on <html>. Default (no attribute) = light. */
[data-theme="dark"] {
  --bg:        #0a0d10;
  --bg-elev-1: #11161b;
  --bg-elev-2: #161d24;
  --bg-elev-3: #1c252e;
  --line:        rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.16);
  --line-faint:  rgba(255,255,255,.04);
  --fg:        #ecebe6;
  --fg-soft:   #b9b6ac;
  --fg-dim:    #7a7a72;
  --fg-faint:  #4d4d48;
}

/* ---------- 2. Reset + base ---------------------------------------------- */
*, ::before, ::after { box-sizing: border-box }
html, body { margin: 0; padding: 0 }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility }
body.app {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11", "tnum" 0;
  min-height: 100vh;
}
/* Generic anchor color (gold) — but EXCLUDE anchors that are styled as
 * buttons. Without the :not(.btn) guard, the gold accent color wins on
 * specificity against .btn's accent-on rule, making anchor-buttons
 * render as gold-on-gold (invisible text). All the CTA links on /try
 * and the minimal-topnav Sign-in button were affected before this fix. */
body.app a:not(.btn) { color: var(--accent); text-decoration: none }
body.app a:not(.btn):hover { text-decoration: underline; text-underline-offset: 2px }
body.app code { font-family: var(--font-mono); font-size: var(--fs-12);
                 background: var(--bg-elev-2); padding: 1px 5px;
                 border-radius: var(--r-2); color: var(--fg-soft) }
body.app h1, body.app h2, body.app h3, body.app h4 { margin: 0; font-weight: 600 }
body.app .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em }
body.app ::selection { background: var(--accent); color: var(--accent-on) }
body.app :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-2) }
@media (prefers-reduced-motion: reduce) {
  body.app *, body.app ::before, body.app ::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}

/* ---------- 3. Topbar / nav ---------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  /* Theme-aware surface: dark in dark mode, light in light mode. Earlier
   * this was hardcoded rgba(10,13,16,.86), which left the topbar dark
   * after a theme flip on mobile. */
  background: var(--bg-elev-1);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
}
.topbar-inner {
  max-width: var(--container-max);
  margin: 0 auto; padding: 0 var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-6);
  width: 100%;
}
.brand-mark {
  display: flex; align-items: center; gap: var(--sp-2);
  text-decoration: none !important; color: var(--fg);
  font-weight: 700; letter-spacing: -0.01em; font-size: var(--fs-15);
}
.brand-mark .brand-dot {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 60%, white));
  display: grid; place-items: center;
  color: var(--accent-on); font-family: var(--font-display);
  font-size: 14px; line-height: 1; font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 2px 8px rgba(0,0,0,.4);
}
.nav-primary { display: flex; gap: 2px; flex: 1 }
.nav-link {
  padding: 8px 12px; border-radius: var(--r-3);
  color: var(--fg-soft); font-size: var(--fs-13); font-weight: 500;
  text-decoration: none !important; line-height: 1;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  transition: color var(--t), background var(--t);
}
.nav-link:hover { color: var(--fg); background: rgba(255,255,255,.04) }
.nav-link.active { color: var(--fg); background: rgba(255,255,255,.06) }
.nav-link svg { width: 14px; height: 14px; opacity: .8 }
.nav-link.active svg { opacity: 1; color: var(--accent) }

.topbar-search {
  flex: 0 1 360px;
  position: relative;
}
.topbar-search input {
  width: 100%; height: 34px; border-radius: var(--r-3);
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--fg); font-size: var(--fs-13); font-family: inherit;
  padding: 0 12px 0 32px; transition: border-color var(--t), background var(--t);
}
.topbar-search input::placeholder { color: var(--fg-dim) }
.topbar-search input:focus { border-color: var(--accent); background: var(--bg-elev-1); outline: none }
.topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
                     width: 14px; height: 14px; color: var(--fg-dim); pointer-events: none }

.topbar-right { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-3);
  background: transparent; border: 1px solid transparent;
  color: var(--fg-soft); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.icon-btn:hover { background: rgba(255,255,255,.05); color: var(--fg); border-color: var(--line) }
.icon-btn svg { width: 16px; height: 16px }

.account-menu { position: relative }
.account-menu-trigger {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-elev-3); color: var(--fg);
  border: 1px solid var(--line); cursor: pointer; padding: 0;
  display: grid; place-items: center; font-size: var(--fs-12); font-weight: 600;
}
.account-menu-trigger:hover { border-color: var(--line-strong) }
.account-menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 220px; padding: 6px;
  background: var(--bg-elev-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-4); box-shadow: var(--shadow-2);
  display: none;
}
.account-menu.open .account-menu-pop { display: block }
.account-menu-pop a, .account-menu-pop button {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 10px; border-radius: var(--r-3);
  font-size: var(--fs-13); color: var(--fg) !important;
  text-decoration: none !important; line-height: 1;
  background: transparent; border: 0; width: 100%;
  cursor: pointer; font-family: inherit;
}
.account-menu-pop a:hover, .account-menu-pop button:hover { background: rgba(255,255,255,.06) }
.account-menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0 }
.account-menu-pop .meta { padding: 8px 10px; color: var(--fg-dim); font-size: var(--fs-11) }

/* ---------- Workspace switcher (top-left) -------------------------------- */
.brand-switcher { position: relative; display: flex; align-items: center; gap: 2px; }
.brand-mark .brand-logo {
  width: 22px; height: 22px; border-radius: 6px; object-fit: cover;
  box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 2px 8px rgba(0,0,0,.4);
}
.ws-switch-btn {
  width: 22px; height: 28px; border-radius: var(--r-2);
  background: transparent; border: 0; cursor: pointer; padding: 0;
  color: var(--fg-dim); display: grid; place-items: center;
  transition: background var(--t), color var(--t), transform var(--t);
}
.ws-switch-btn:hover { background: rgba(255,255,255,.05); color: var(--fg) }
.ws-switch-btn svg { width: 12px; height: 12px; transition: transform var(--t) }
.brand-switcher.open .ws-switch-btn { color: var(--fg); background: rgba(255,255,255,.05) }
.brand-switcher.open .ws-switch-btn svg { transform: rotate(180deg) }

.ws-switch-pop {
  position: absolute; left: -8px; top: calc(100% + 8px);
  min-width: 280px; padding: 6px;
  background: var(--bg-elev-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-4); box-shadow: var(--shadow-2);
  z-index: 50;
  animation: ws-pop-in 140ms ease-out;
}
.ws-switch-pop[hidden] { display: none }
@keyframes ws-pop-in {
  from { opacity: 0; transform: translateY(-4px) }
  to   { opacity: 1; transform: translateY(0) }
}
.ws-switch-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 8px; color: var(--fg-dim);
  font-size: var(--fs-11); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.ws-switch-loading { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .7 }
.ws-switch-list { display: flex; flex-direction: column; gap: 1px }

.ws-item {
  display: grid; grid-template-columns: 28px 1fr 16px;
  align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-3);
  background: transparent; border: 0; width: 100%;
  cursor: pointer; font-family: inherit; text-align: left;
  color: var(--fg);
  transition: background var(--t);
}
.ws-item:hover { background: rgba(255,255,255,.06) }
.ws-item.active { background: rgba(255,255,255,.04) }
.ws-item-dot {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 60%, white));
  display: grid; place-items: center;
  color: var(--accent-on); font-family: var(--font-display);
  font-size: var(--fs-13); line-height: 1; font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 2px 6px rgba(0,0,0,.35);
}
.ws-item-logo { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; }
.ws-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-item-name {
  font-size: var(--fs-13); font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-item-meta {
  font-size: var(--fs-11); color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-item-check { width: 14px; height: 14px; color: var(--accent); opacity: 0 }
.ws-item.active .ws-item-check { opacity: 1 }

.ws-switch-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0 }
.ws-switch-link, .ws-switch-create {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-3);
  font-size: var(--fs-13); color: var(--fg) !important;
  text-decoration: none !important; line-height: 1;
  background: transparent; border: 0; width: 100%;
  cursor: pointer; font-family: inherit; text-align: left;
  transition: background var(--t);
}
.ws-switch-link:hover { background: rgba(255,255,255,.06) }
.ws-switch-link svg, .ws-switch-create svg { width: 14px; height: 14px; opacity: .7 }
.ws-switch-create {
  color: var(--fg-dim) !important; cursor: not-allowed;
  position: relative;
}
.ws-switch-create:hover { background: transparent }
.ws-switch-soon {
  margin-left: auto;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--fg-soft);
}

/* ---------- Quick views (auto-suggested saved views on /) -------------- */
/* Strip of clickable view-pills sitting between hero-search and the
 * filter-trigger-bar. Visually subordinate to hero-search (no big borders)
 * but distinct from the filter sheet. Each pill: monoline icon · name ·
 * count. Hover lifts to accent. Empty views go .is-empty (greyed but still
 * clickable so users see the dimension exists in their catalog). */
.quick-views {
  max-width: var(--container-max);
  margin: var(--sp-3) auto 0;
  padding: 0 var(--sp-5);
}
/* Same sidebar-aware shift the .shell uses (line 731). Without this,
   .quick-views centers on the full viewport and the fixed left filter
   sidebar overlaps the leading edge of the row, hiding the "Quick views"
   label and the first few chips. */
body.app:has(aside.filters) .quick-views {
  padding-left: calc(var(--sidebar-w) + var(--sp-5));
}
html.sidebar-collapsed body.app:has(aside.filters) .quick-views {
  padding-left: var(--sp-5);
}
.quick-views-inner {
  display: flex; align-items: center; gap: var(--sp-3);
}
.quick-views-label {
  font-size: var(--fs-11); color: var(--fg-dim);
  font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; flex: 0 0 auto;
}
.quick-views-row {
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 0;  /* room for hover transform */
  scrollbar-width: none;  /* firefox */
}
.quick-views-row::-webkit-scrollbar { display: none; }

.quick-view-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 8px; border-radius: 999px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--fg-soft);
  font-size: var(--fs-12); font-weight: 500; line-height: 1;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background var(--t), color var(--t),
              border-color var(--t), transform var(--t);
}
.quick-view-chip:hover {
  background: var(--bg-elev-3);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--line));
  color: var(--fg);
  transform: translateY(-1px);
}
.quick-view-chip:active { transform: translateY(0); }
.quick-view-chip .qv-icon {
  width: 13px; height: 13px;
  color: var(--accent); opacity: .85;
  flex: 0 0 auto;
}
.quick-view-chip:hover .qv-icon { opacity: 1; }
.quick-view-chip .qv-name {
  font-weight: 500;
}
.quick-view-chip .qv-count {
  font-family: var(--font-mono); font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  padding: 1px 5px; border-radius: 999px;
  background: rgba(255,255,255,.05);
  margin-left: 2px;
}
.quick-view-chip:hover .qv-count {
  color: var(--fg-soft);
  background: rgba(255,255,255,.08);
}

.quick-view-chip.is-empty {
  opacity: .45;
}
.quick-view-chip.is-empty:hover {
  opacity: .7;
  transform: none;
}

/* Mobile: keep the whole strip visible, allow horizontal scroll. */
@media (max-width: 720px) {
  .quick-views { padding: 0 var(--sp-3); }
  .quick-views-inner { gap: var(--sp-2); }
}

/* ---------- Branding form (Settings → Branding) ----------------------- */
/* Two-pane layout: editable fields on the left, live preview card on the
 * right. Preview re-renders on every keystroke. Color picker swatch is
 * native <input type="color"> wired to the hex text input bidirectionally.
 *
 * --preview-accent is the per-preview CSS variable the JS sets — keeps
 * the preview swatching local to the card without leaking into the rest
 * of the page. */
.branding-form {
  /* surface card padding from the existing system */
  padding: var(--sp-5);
}
.branding-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: var(--sp-5);
  align-items: start;
}
.branding-fields { display: grid; gap: var(--sp-4); }
.branding-actions {
  margin-top: var(--sp-4);
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: var(--sp-4);
}

/* Color picker + hex text combined into one row. The native <input
 * type="color"> renders as a small swatch in most browsers; we style it
 * to look intentional, not browser-default. */
.brand-color-input {
  display: flex; align-items: center; gap: var(--sp-2);
}
.brand-color-swatch {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-3);
  background: var(--bg-elev-2); cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.brand-color-swatch::-webkit-color-swatch-wrapper { padding: 4px; }
.brand-color-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }
.brand-color-swatch::-moz-color-swatch    { border: none; border-radius: 4px; }
.brand-color-swatch:hover { border-color: var(--line-strong); }
.brand-color-hex {
  flex: 1 1 auto;
  font-family: var(--font-mono); font-size: var(--fs-13);
}

/* Live preview card — mimics the look of a share-gallery header so the
 * user understands "this is what your client will see." */
.branding-preview-label {
  font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--fg-dim);
  margin-bottom: var(--sp-2);
}
.branding-preview-card {
  --preview-accent: var(--accent);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--r-5);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  position: sticky; top: calc(var(--topbar-h) + var(--sp-3));
}
.branding-preview-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--preview-accent) 8%, transparent),
    transparent 90%
  );
}
.branding-preview-glyph {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg,
    var(--preview-accent),
    color-mix(in oklab, var(--preview-accent) 60%, white));
  background-size: cover; background-position: center;
  display: grid; place-items: center;
  color: var(--accent-on); font-family: var(--font-display);
  font-weight: 700; font-size: var(--fs-18); line-height: 1;
  box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 2px 8px rgba(0,0,0,.4);
  flex: 0 0 auto;
}
.branding-preview-glyph.has-logo {
  /* When a logo URL is set, the background image takes over and we
   * suppress the gradient so the logo isn't tinted. */
  background-color: var(--bg-elev-3);
  background-image: var(--logo-url) !important;
  /* JS sets background-image directly via inline style */
}
.branding-preview-glyph.has-logo:not([style*="background-image"]) {
  background: var(--bg-elev-3);
}
.branding-preview-name {
  font-weight: 600; font-size: var(--fs-15); color: var(--fg);
  letter-spacing: -0.01em;
}
.branding-preview-body {
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  align-items: flex-start;
}
.branding-preview-headline {
  font-family: var(--font-display);
  font-size: var(--fs-18); color: var(--fg);
  letter-spacing: -0.01em; line-height: 1.2;
}
.branding-preview-cta {
  background: var(--preview-accent);
  color: var(--accent-on);
  border: 0; cursor: default;
  padding: 8px 14px; border-radius: var(--r-3);
  font-weight: 600; font-size: var(--fs-13);
  font-family: inherit; line-height: 1;
  box-shadow: 0 2px 8px color-mix(in oklab, var(--preview-accent) 35%, transparent);
}

/* Mobile: stack preview below fields */
@media (max-width: 720px) {
  .branding-grid {
    grid-template-columns: 1fr;
  }
  .branding-preview-card { position: static; }
}

/* ---------- 4. Buttons / inputs / chips ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: var(--r-3);
  background: var(--accent); color: var(--accent-on);
  border: 0; font-size: var(--fs-13); font-weight: 600; line-height: 1;
  cursor: pointer; font-family: inherit;
  text-decoration: none !important;
  transition: filter var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08) }
.btn:active { transform: translateY(1px) }
.btn:disabled { opacity: .4; cursor: not-allowed }
.btn svg { width: 14px; height: 14px }
.btn.btn-ghost {
  background: transparent; color: var(--fg);
  border: 1px solid var(--line-strong);
}
.btn.btn-ghost:hover { background: rgba(255,255,255,.05); filter: none }
.btn.btn-soft {
  background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--line);
}
.btn.btn-soft:hover { background: var(--bg-elev-3); filter: none }
.btn.btn-danger { background: var(--red); color: var(--accent-on) }
.btn.btn-tiny { padding: 5px 10px; font-size: var(--fs-12); font-weight: 500 }
.btn.btn-icon { padding: 8px; width: 34px; justify-content: center }

input.field, select.field, textarea.field {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: var(--r-3); color: var(--fg);
  font-size: var(--fs-14); font-family: inherit;
  transition: border-color var(--t), background var(--t);
}
textarea.field { padding: 10px 12px; height: auto; min-height: 80px; resize: vertical; line-height: 1.5 }
input.field:focus, select.field:focus, textarea.field:focus {
  border-color: var(--accent); background: var(--bg-elev-1); outline: none;
}
input.field::placeholder, textarea.field::placeholder { color: var(--fg-dim) }
.field-label {
  display: block; font-size: var(--fs-11); color: var(--fg-soft);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  margin: 0 0 6px;
}
.field-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-3) }
.field-help { font-size: var(--fs-12); color: var(--fg-dim); margin-top: 2px; line-height: 1.4 }

/* Chips / filter pills */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--r-pill);
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--fg-soft); font-size: var(--fs-12); font-weight: 500;
  cursor: pointer; text-decoration: none !important; line-height: 1;
  transition: border-color var(--t), color var(--t), background var(--t);
}
.chip:hover { border-color: var(--line-strong); color: var(--fg) }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--fg) }
.chip svg { width: 12px; height: 12px }

/* ---------- 5. Card / surface / KPI / badge / table ---------------------- */
.surface {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-5);
  padding: var(--sp-5);
}
.surface-2 { background: var(--bg-elev-2) }

.kpi-row {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.kpi {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  padding: var(--sp-3) var(--sp-4);
  position: relative; overflow: hidden;
}
.kpi-num {
  font-family: var(--font-display); font-size: 28px; font-weight: 600;
  color: var(--fg); line-height: 1.1; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.kpi-num.accent { color: var(--accent) }
.kpi-label {
  font-size: var(--fs-11); color: var(--fg-soft);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 600;
  margin-top: 4px;
}
.kpi-sublabel { font-size: var(--fs-12); color: var(--fg-dim); margin-top: 2px }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--bg-elev-3); color: var(--fg-soft);
  font-size: var(--fs-11); font-weight: 600; line-height: 1.5;
  letter-spacing: .03em;
}
.badge.ok    { background: var(--green-soft); color: var(--green) }
.badge.warn  { background: var(--amber-soft); color: var(--amber) }
.badge.error { background: var(--red-soft); color: var(--red) }
.badge.info  { background: var(--blue-soft); color: var(--blue) }
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: currentColor;
}

table.refined {
  width: 100%; border-collapse: collapse; font-size: var(--fs-13);
}
table.refined th {
  text-align: left; padding: 10px 12px;
  color: var(--fg-soft); font-size: var(--fs-11);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
table.refined td {
  padding: 12px; border-bottom: 1px solid var(--line-faint);
  color: var(--fg); vertical-align: top;
}
table.refined tr:hover td { background: rgba(255,255,255,.02) }
table.refined .num { text-align: right; font-variant-numeric: tabular-nums }
table.refined .actions {
  /* Legacy style.css declares .actions as a column-flex container (used by
   * the search sidebar). Inside refined tables the same class conflicts and
   * stretches the first <a> button to the full cell width. Reset to inline
   * row layout. */
  text-align: right; white-space: nowrap;
  display: table-cell; flex-direction: row; gap: 6px;
}
table.refined .actions > * { vertical-align: middle }

/* ---------- 6. Toast + modal --------------------------------------------- */
#toastRoot {
  position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 80;
  pointer-events: none; max-width: 380px;
}
.toast {
  background: var(--bg-elev-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-4); padding: 12px 14px;
  box-shadow: var(--shadow-2);
  display: flex; gap: 10px; align-items: flex-start;
  font-size: var(--fs-13); color: var(--fg);
  pointer-events: auto;
  transform: translateX(20px); opacity: 0;
  transition: transform var(--t-slow), opacity var(--t);
  max-width: 380px;
}
.toast.show { transform: translateX(0); opacity: 1 }
.toast-icon { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px }
.toast.ok    .toast-icon { background: var(--green-soft); color: var(--green) }
.toast.warn  .toast-icon { background: var(--amber-soft); color: var(--amber) }
.toast.error .toast-icon { background: var(--red-soft); color: var(--red) }
.toast.info  .toast-icon { background: var(--blue-soft); color: var(--blue) }
.toast-body { flex: 1 }
.toast-close { background: transparent; border: 0; color: var(--fg-dim); cursor: pointer; padding: 0; font-size: 16px; line-height: 1 }

#modalRoot { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px) }
#modalRoot.open { display: flex }
.modal {
  background: var(--bg-elev-1); border: 1px solid var(--line-strong);
  border-radius: var(--r-5); box-shadow: var(--shadow-3);
  padding: var(--sp-6); max-width: 520px; width: 100%;
  max-height: 90vh; overflow: auto;
}
.modal h3 { font-family: var(--font-display); font-size: 22px; margin: 0 0 8px; font-weight: 600; letter-spacing: -.01em }
.modal-msg { color: var(--fg-soft); font-size: var(--fs-14); line-height: 1.55; margin: 0 0 var(--sp-5) }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end }

/* ---------- 7. Flash bridge ---------------------------------------------- */
/* Old templates render server-side flash; we hide them and fire toasts instead */
.flash { display: none !important }

/* ---------- 8. Page shell + breadcrumb + hero ---------------------------- */
.shell {
  max-width: var(--container-max); margin: 0 auto;
  padding: var(--sp-8) var(--sp-5) var(--sp-12);
}
/* On pages that ALSO have the fixed-left filter sidebar (Collection detail
 * has a .shell header above the .layout block), push the shell content past
 * the sidebar so the heading/KPIs don't render behind it. */
body.app:has(aside.filters) .shell {
  padding-left: calc(var(--sidebar-w) + var(--sp-5));
}
html.sidebar-collapsed body.app:has(aside.filters) .shell {
  padding-left: var(--sp-5);
}
@media (max-width: 920px) {
  body.app:has(aside.filters) .shell { padding-left: var(--sp-5) }
}
@media (max-width: 720px) { .shell { padding: var(--sp-5) var(--sp-3) var(--sp-8) } }

.crumbs { font-size: var(--fs-12); color: var(--fg-dim); margin-bottom: var(--sp-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap }
.crumbs a { color: var(--fg-soft) !important }
.crumbs .sep { opacity: .5 }

.page-hero { margin-bottom: var(--sp-6) }
.page-hero h1 { font-family: var(--font-display); font-size: var(--fs-36); font-weight: 600; letter-spacing: -.015em; line-height: 1.1; margin-bottom: 6px }
.page-hero .subtitle { color: var(--fg-soft); font-size: var(--fs-15); max-width: 640px }
.page-hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap }

.section { margin: var(--sp-8) 0 }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: var(--sp-3); gap: var(--sp-3) }
.section-head h2 { font-size: var(--fs-18); font-weight: 600; letter-spacing: -.005em }
.section-head .section-sub { font-size: var(--fs-12); color: var(--fg-dim) }

/* Empty state */
.empty-state { padding: var(--sp-12) var(--sp-5); text-align: center; border: 1px dashed var(--line); border-radius: var(--r-5); background: var(--bg-elev-1) }
.empty-state .empty-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-elev-3); display: grid; place-items: center; margin: 0 auto var(--sp-3); color: var(--fg-soft) }
.empty-state h3 { font-family: var(--font-display); font-size: 22px; font-weight: 500; margin-bottom: 6px }
.empty-state p { color: var(--fg-soft); margin: 0 0 var(--sp-4) }

/* ---------- 8b. Photo cards (admin search results) ----------------------- */
/* Override style.css cards with a dark-theme version that's also usable from
 * collection_detail.html. Existing app.js depends on .grid / .card / .picker /
 * .selected / .info / .name / .tags / .tag classes — we keep them all. */
/* Constant card min size across all viewports — wider screens get MORE
 * cards, not bigger ones. (Earlier breakpoints bumped min size up which
 * froze the column count at ~5; that fought the user's instinct that a
 * wider window should show more photos.) */
body.app .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
}
body.app .card {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
/* Hover-to-enlarge: the card scales 1.85× after a 220ms dwell so casual
 * mouse passes don't snap every card, but pausing actually pops the photo.
 * transition-delay only applies entering :hover — exit snaps back instantly.
 * .card has overflow:hidden + flex column (image + info section), so the
 * thumb itself ends up close to 2× the original — finally feels like a
 * preview, not a 3-pixel nudge. */
body.app .card { transition: transform .22s cubic-bezier(.2,.9,.3,1.05), box-shadow .22s, border-color .15s }
body.app .card:hover {
  transform: scale(1.85) translateZ(0);
  transition-delay: 220ms, 220ms, 0s;
  box-shadow: 0 32px 80px rgba(20,16,4,.32);
  border-color: var(--accent);
  z-index: 20;
}
@media (prefers-reduced-motion: reduce) {
  /* Still scale meaningfully — the user wants the preview, just not a
   * springy animation. Drop the transition-delay so it feels instant. */
  body.app .card:hover { transform: scale(1.5); transition-delay: 0s }
}
@media (hover: none) {
  /* No hover on touch devices — kill the scale entirely to avoid sticky
   * "stuck on last tap" enlargement on iOS. */
  body.app .card:hover { transform: none; box-shadow: none; z-index: auto }
}

/* Hide the legacy floating preview panel entirely (the old hover-preview
 * approach). The element stays in the DOM for app.js's queries to be safe
 * against null refs, but it never shows. */
body.app #hoverPreview { display: none !important }
body.app .card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-2) }
body.app .card .pick {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px);
  border-radius: var(--r-2); padding: 4px 5px;
  border: 1px solid rgba(255,255,255,.12);
  cursor: pointer;
  transition: background .15s, transform .12s, border-color .15s;
}
body.app .card .pick:hover { background: rgba(0,0,0,.75); border-color: var(--accent); transform: scale(1.06) }
body.app .card .pick input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px; height: 14px;
  cursor: pointer;
  display: block;
}
body.app .card.selected .pick { background: var(--accent); border-color: var(--accent) }
body.app .card img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  background: var(--bg-elev-2); display: block;
}
body.app .card .info {
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--line-faint);
}
body.app .card .name { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); }
body.app .card .tags { display: flex; flex-wrap: wrap; gap: 4px; }
body.app .card .tag {
  font-size: var(--fs-11); padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--bg-elev-3); color: var(--fg-soft); text-decoration: none !important;
  line-height: 1.5;
}
body.app .card .tag:hover { background: var(--accent-soft); color: var(--fg) }
body.app .card .tag.scene  { background: rgba(106,169,255,.13); color: #a5c8ff }
body.app .card .tag.mood   { background: rgba(255,122,168,.13); color: #ff9eb6 }
body.app .card .tag.team   { background: rgba(240,200,90,.14); color: #f5d378 }
body.app .card .tag.tv     { background: rgba(126,209,156,.14); color: #9adfb6 }
body.app .card .tag.hosted { background: var(--accent-soft); color: var(--accent-bright) }
body.app .card .tag.focal  { background: var(--accent); color: var(--accent-on) }
body.app .card .tag.shot   { background: var(--accent-soft); color: var(--fg) }
body.app .card .tag.negspace { background: rgba(170,140,255,.14); color: #c7b1ff }
body.app .card .tag.src-dropbox { background: rgba(170,140,255,.14); color: #c7b1ff }
body.app .focal-line { font-size: var(--fs-12); color: var(--fg-soft) }
body.app .focal-line strong { color: var(--fg-dim); font-size: 10px; text-transform: uppercase; letter-spacing: .06em }
body.app .focal-line.user strong { color: var(--accent) }
body.app .user-tags { display: flex; flex-wrap: wrap; gap: 4px }
body.app .user-tag {
  background: var(--accent-soft); color: var(--accent-bright);
  font-size: 11px; padding: 1px 8px; border-radius: var(--r-pill);
  text-decoration: none !important;
}
body.app .upload-date { font-size: 11px; color: var(--fg-dim) }
body.app .preview { font-size: var(--fs-12); color: var(--fg-soft); line-height: 1.5;
                    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden }
body.app .actions-row {
  display: flex; gap: var(--sp-3); padding-top: 4px;
  font-size: var(--fs-12); color: var(--fg-dim);
  border-top: 1px solid var(--line-faint); margin-top: 4px; padding-top: 8px;
}
body.app .actions-row a { color: var(--fg-soft) !important }
body.app .actions-row a:hover { color: var(--accent) !important }
body.app .actions-row button.detailbtn {
  background: transparent; border: 0; color: var(--fg-soft);
  cursor: pointer; padding: 0; font-family: inherit; font-size: inherit;
  margin-left: auto;
}
body.app .actions-row button.detailbtn:hover { color: var(--accent) }

/* hoverPreview floating panel (existing app.js feature) */
body.app #hoverPreview {
  position: fixed; pointer-events: none; opacity: 0; z-index: 60;
  transition: opacity .18s; padding: 0;
  border-radius: var(--r-4); overflow: hidden; box-shadow: var(--shadow-3);
  border: 1px solid var(--line-strong); background: var(--bg-elev-2);
}
body.app #hoverPreview.show { opacity: 1 }
body.app #hoverPreview img { display: block; max-width: 480px; max-height: 360px }

/* Detail modal (legacy <dialog> usage) — restyle for dark theme */
body.app dialog#detailModal {
  background: var(--bg-elev-1); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--r-5);
  padding: 0; box-shadow: var(--shadow-3);
  max-width: min(960px, 92vw); max-height: 90vh; overflow: auto;
}
body.app dialog#detailModal::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(6px) }
body.app dialog#detailModal #detailContent { padding: var(--sp-5) }
body.app dialog#detailModal img { max-width: 100%; height: auto; border-radius: var(--r-3) }
body.app dialog#detailModal .modal-prev,
body.app dialog#detailModal .modal-next {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--fg); padding: 6px 10px; border-radius: var(--r-3);
  cursor: pointer;
}
body.app dialog#detailModal button {
  background: var(--accent); color: var(--accent-on); border: 0;
  padding: 9px 14px; border-radius: var(--r-3); font-weight: 600;
  cursor: pointer; font-family: inherit;
}
/* The Hide / Restore button in the detail modal — pinned top-right
 * next to the photo's title. Sized down so it doesn't dominate. */
body.app dialog#detailModal #modalHideBtn {
  background: transparent; color: var(--fg-soft);
  border: 1px solid var(--line);
  padding: 7px 12px; font-size: var(--fs-13); font-weight: 600;
  border-radius: 100px; flex: 0 0 auto;
}
body.app dialog#detailModal #modalHideBtn.danger:hover {
  color: var(--red); border-color: var(--red); background: rgba(255,80,80,.06);
}
body.app dialog#detailModal #modalHideBtn:not(.danger):hover {
  color: var(--accent); border-color: var(--accent);
}
body.app dialog#detailModal .modal-hidden-banner {
  margin: 8px 0; padding: 10px 14px; border-radius: var(--r-3);
  background: rgba(255,80,80,.08); color: var(--fg-soft);
  border: 1px solid rgba(255,80,80,.25);
  font-size: var(--fs-13);
}

/* Filter sidebar — fixed to the left edge of the viewport on desktop, with
 * a collapse toggle that slides it off-screen. State is persisted to
 * localStorage and restored synchronously in <head> so layout doesn't shift. */
body.app aside.filters {
  position: fixed;
  left: 0; top: var(--topbar-h);
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  max-height: none;
  background: var(--bg-elev-1);
  border: 0; border-right: 1px solid var(--line);
  border-radius: 0;
  padding: var(--sp-4);
  overflow-y: auto;
  z-index: 25;
  transition: transform var(--t-slow);
}

/* Collapsed state — driven by html.sidebar-collapsed (set synchronously) */
html.sidebar-collapsed body.app aside.filters { transform: translateX(-100%) }
html.sidebar-collapsed body.app .layout { padding-left: var(--sp-5) !important }

/* Collapse handle — small chevron pinned to the right edge of the sidebar
 * when expanded, and pinned to the left edge of viewport when collapsed. */
.sidebar-handle {
  position: fixed; left: var(--sidebar-w); top: calc(var(--topbar-h) + var(--sp-3));
  z-index: 26;
  width: 24px; height: 28px;
  background: var(--bg-elev-1); border: 1px solid var(--line);
  border-left: 0; border-radius: 0 var(--r-3) var(--r-3) 0;
  cursor: pointer; padding: 0;
  display: grid; place-items: center;
  color: var(--fg-soft);
  transition: background var(--t), color var(--t), left var(--t-slow);
}
.sidebar-handle:hover { background: var(--bg-elev-2); color: var(--fg) }
.sidebar-handle svg { width: 12px; height: 12px; transition: transform var(--t) }
html.sidebar-collapsed .sidebar-handle { left: 0 }
html.sidebar-collapsed .sidebar-handle svg { transform: rotate(180deg) }
@media (max-width: 920px) { .sidebar-handle { display: none } }
/* Only show the handle on pages that actually have a filter sidebar
 * (Library + Collection detail). Sources / Collections / Settings don't. */
body.app:not(:has(aside.filters)) .sidebar-handle { display: none }
body.app aside.filters h3 {
  font-size: var(--fs-11); color: var(--fg-soft); text-transform: uppercase;
  letter-spacing: .08em; margin: 0 0 var(--sp-3); font-weight: 600;
}
body.app aside.filters h4 {
  font-size: var(--fs-11); color: var(--fg-soft); text-transform: uppercase;
  letter-spacing: .08em; margin: var(--sp-4) 0 var(--sp-2); font-weight: 600;
}
body.app aside.filters label {
  display: block; font-size: var(--fs-11); color: var(--fg-soft);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
  margin: var(--sp-3) 0 4px;
}
body.app aside.filters select, body.app aside.filters input {
  width: 100%; padding: 7px 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: var(--r-3); color: var(--fg);
  font-size: var(--fs-13); font-family: inherit;
}
body.app aside.filters select:focus, body.app aside.filters input:focus {
  border-color: var(--accent); outline: none;
}
body.app aside.filters .actions {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
body.app aside.filters .actions button {
  padding: 8px 12px; background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-3);
  cursor: pointer; font-size: var(--fs-12); font-family: inherit; text-align: left;
  transition: background var(--t), border-color var(--t);
}
body.app aside.filters .actions button:hover:not(:disabled) {
  background: var(--bg-elev-3); border-color: var(--line-strong);
}
body.app aside.filters .actions button:disabled { opacity: .35; cursor: not-allowed }
body.app aside.filters .actions button#copyUrls:not(:disabled),
body.app aside.filters .actions button#downloadZip:not(:disabled),
body.app aside.filters .actions button#addToCollection:not(:disabled) {
  background: var(--accent); color: var(--accent-on); border-color: var(--accent);
}
body.app aside.filters .collections-block { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line) }
/* Legacy style.css uses `display: flex; justify-content: space-between` on
 * these h4s — that's the right behavior for "Title | action-link" pairs
 * (e.g. "Collections   manage"). For h4s that are an icon+label lockup
 * (e.g. the Share block), the template adds an inline
 * `justify-content: flex-start` to override per-instance. */
body.app aside.filters .coll-list { list-style: none; padding: 0; margin: 0; font-size: var(--fs-12) }
body.app aside.filters .coll-list li { padding: 4px 0 }
body.app aside.filters .coll-list .count { color: var(--fg-dim) }
body.app aside.filters .coll-list .active a { color: var(--accent) !important; font-weight: 600 }
body.app aside.filters .tips ul { padding-left: 16px; margin: 4px 0 0; color: var(--fg-soft); font-size: var(--fs-11); line-height: 1.7 }
body.app aside.filters .tips code { background: var(--bg-elev-2); padding: 1px 5px; border-radius: var(--r-2); font-size: 10px }
body.app aside.filters .tiny-link {
  font-size: 11px; color: var(--fg-soft) !important;
  text-decoration: none !important;
  text-transform: none; letter-spacing: 0;
  font-weight: 500;
  padding: 2px 8px; border-radius: var(--r-2);
  transition: color var(--t), background var(--t);
}
body.app aside.filters .tiny-link:hover { color: var(--accent) !important; background: var(--accent-soft) }

/* Search header — the sidebar is position:fixed so it's out of flow.
 * `.layout` becomes a normal block and main fills its content box. We trim
 * the side padding to a tight 12px so card thumbnails extend almost to the
 * viewport edges (the user's request: "less padding or margin to the L/R of
 * the main container"). Legacy style.css set display:grid + main padding;
 * we reset both. */
body.app .layout {
  display: block;
  grid-template-columns: none;
  /* No container cap on the grid layout — wider screens get more columns,
   * not wasted side gutters. Text-heavy pages still use `.shell` which
   * keeps `--container-max` for readability. */
  max-width: 100%;
  margin: 0;
  padding: var(--sp-3) var(--sp-3) var(--sp-5) calc(var(--sidebar-w) + var(--sp-3));
}
html.sidebar-collapsed body.app .layout { padding-left: var(--sp-3) !important }
body.app .layout > main { width: 100%; min-width: 0; padding: 0 }
@media (max-width: 920px) {
  body.app .layout { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  /* On mobile/tablet the sidebar is the slide-in sheet handled elsewhere */
}
body.app .resultbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0 var(--sp-4); color: var(--fg-soft); font-size: var(--fs-13);
  flex-wrap: wrap; gap: var(--sp-3);
}
body.app .resultbar em { color: var(--fg); font-style: normal; font-weight: 600 }

/* Load more bar */
body.app .load-more-bar { text-align: center; padding: var(--sp-8) 0 }
body.app .load-more-bar button {
  padding: 10px 18px; background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  cursor: pointer; font-size: var(--fs-13); font-weight: 600; font-family: inherit;
}
body.app .load-more-bar button:hover { background: var(--bg-elev-3) }

/* Empty inside grid */
body.app .grid > .empty {
  grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: var(--fg-dim);
}

/* Hero search bar (top of /). The fixed-left sidebar floats over the page,
 * so we clear it with padding-left equal to its width — and pull padding-left
 * back when collapsed via the same html.sidebar-collapsed cascade.
 * `position: relative; z-index: 10` gives the hero its own stacking context
 * so the help-tip bubble inside the form renders ABOVE the result cards
 * below (cards use `isolation: isolate` and would otherwise paint over). */
body.app .hero-search {
  position: relative;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-elev-1) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-8) var(--sp-5) var(--sp-8) calc(var(--sidebar-w) + var(--sp-5));
  transition: padding-left var(--t-slow);
}
html.sidebar-collapsed body.app .hero-search { padding-left: var(--sp-5) }
@media (max-width: 920px) {
  body.app .hero-search { padding-left: var(--sp-5); padding-right: var(--sp-5) }
}
body.app .hero-search-inner { max-width: var(--container-max); margin: 0 auto }
body.app .hero-search h1.display { font-size: var(--fs-36); margin-bottom: 4px }
body.app .hero-search .subtitle { color: var(--fg-soft); margin-bottom: var(--sp-5) }
/* Hero search form — matches the share-page search row: a clean pill input
 * with a × clear button, a separate "Main subject only" pill toggle, and
 * a "?" help icon that opens an inline banner below the row. Same look on
 * admin as on the partner share so users learn one pattern. */
body.app .hero-search-form {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  max-width: 1080px; background: transparent; border: 0;
  padding: 0; border-radius: 0;
}
body.app .hero-search-form .search-box {
  position: relative; flex: 1 1 320px; min-width: 0;
}
body.app .hero-search-form .search-box svg.glass {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--fg-dim); pointer-events: none;
}
body.app .hero-search-form input[type=search] {
  width: 100%; height: 44px;
  background: var(--bg-elev-1); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  padding: 0 44px 0 40px; font-size: var(--fs-15); font-family: inherit;
  outline: none;
  transition: border-color var(--t), background var(--t);
  text-overflow: ellipsis;
}
body.app .hero-search-form input[type=search]:focus { border-color: var(--accent); background: var(--bg-elev-1) }
body.app .hero-search-form input[type=search]::placeholder { color: var(--fg-dim) }
body.app .hero-search-form .q-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-elev-3); border: 0;
  color: var(--fg-soft); cursor: pointer; padding: 0;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
body.app .hero-search-form .q-clear:hover { background: var(--bg-elev-3); color: var(--fg) }
body.app .hero-search-form .q-clear svg { width: 12px; height: 12px }
/* Main-subject-only pill toggle — visually matches the share viewer. */
body.app .hero-search-form .focal-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  flex: 0 0 auto; padding: 6px 14px; height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--bg-elev-1);
  color: var(--fg-soft); font-size: var(--fs-13); font-weight: 600;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
body.app .hero-search-form .focal-toggle:hover { border-color: var(--fg-soft); color: var(--fg) }
body.app .hero-search-form .focal-toggle input { display: none }
body.app .hero-search-form .focal-toggle .chip-toggle-track {
  width: 26px; height: 14px; background: var(--line-strong);
  border-radius: var(--r-pill); position: relative; flex: 0 0 auto;
  transition: background .15s;
}
body.app .hero-search-form .focal-toggle .chip-toggle-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px; border-radius: 50%; background: #fff;
  transition: transform .25s cubic-bezier(.2,.9,.3,1.2);
}
body.app .hero-search-form .focal-toggle.active { background: var(--accent-soft); border-color: var(--accent); color: var(--fg) }
body.app .hero-search-form .focal-toggle.active .chip-toggle-track { background: var(--accent) }
body.app .hero-search-form .focal-toggle.active .chip-toggle-track::after { transform: translateX(12px) }
/* "?" help icon — opens an inline banner below; never clipped by viewport. */
body.app .hero-search-form .focal-help {
  color: var(--fg-dim); font-size: 11px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 50%;
  width: 22px; height: 22px; display: inline-grid; place-items: center;
  line-height: 1; font-weight: 700; background: var(--bg-elev-1);
  padding: 0; flex: 0 0 auto;
}
body.app .hero-search-form .focal-help:hover { color: var(--fg); border-color: var(--fg-soft) }
body.app .focal-help-banner {
  max-width: 1080px; margin: 8px 0 0;
  padding: 10px 14px; border-radius: var(--r-3);
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--fg-soft); font-size: var(--fs-13); line-height: 1.45;
}
body.app .focal-help-banner[hidden] { display: none }
body.app .hero-search-form > button[type="submit"] {
  padding: 0 22px; height: 36px;
  background: var(--accent); color: var(--accent-on); border: 0;
  border-radius: var(--r-pill); font-weight: 600; cursor: pointer;
  font-family: inherit; font-size: var(--fs-13);
}
body.app .hero-search-form .reset { color: var(--fg-dim); font-size: var(--fs-12); padding: 0 8px; text-decoration: none !important }
body.app .hero-search-form .reset:hover { color: var(--fg) }

/* ---------- 8b-1. iOS: prevent zoom on form focus ------------------------ */
/* Mobile Safari + Chrome iOS auto-zoom into inputs whose font-size is < 16px.
 * Override every form field to 16px on touch devices so the page never
 * jumps when the user taps a field. We use the touch media query (hover/none
 * + pointer/coarse) so desktop preserves its tighter 13–14px form density. */
@media (hover: none) and (pointer: coarse) {
  body.app input,
  body.app select,
  body.app textarea,
  body.app .field,
  body.app aside.filters select,
  body.app aside.filters input {
    font-size: 16px !important;
  }
}

/* Display (h1) on display-class elements should pull from --font-display */
body.app h1.display, body.app .display { font-family: var(--font-display); font-weight: 500 }

/* ---------- 8c. Mobile filter sheet -------------------------------------- */
/* On screens narrower than 920px the filter sidebar becomes a slide-up sheet
 * triggered by a sticky bar at the top of main. The sheet animates in from
 * the bottom on phones, and from the right on tablets. */
.filter-trigger-bar {
  display: none;
  position: sticky; top: var(--topbar-h); z-index: 25;
  /* Use theme-aware surface so light mode gets a light bar and dark mode
   * gets a dark bar. Earlier this was hardcoded rgba(10,13,16,.92) which
   * stayed dark even after the user flipped the theme on mobile. */
  background: var(--bg-elev-1);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px var(--sp-3);
  align-items: center; gap: 8px;
}
.filter-trigger-bar .ft-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--bg-elev-2); border: 1px solid var(--line-strong);
  color: var(--fg); font-size: var(--fs-13); font-weight: 600;
  cursor: pointer; font-family: inherit; line-height: 1;
}
.filter-trigger-bar .ft-btn:hover { background: var(--bg-elev-3) }
.filter-trigger-bar .ft-btn .ft-count {
  display: inline-block; min-width: 18px; padding: 0 6px;
  background: var(--accent); color: var(--accent-on);
  border-radius: var(--r-pill); font-size: var(--fs-11);
  font-variant-numeric: tabular-nums; line-height: 1.5; text-align: center;
}
.filter-trigger-bar .ft-btn svg { width: 14px; height: 14px }
.filter-trigger-bar .ft-summary {
  flex: 1; color: var(--fg-soft); font-size: var(--fs-12);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 920px) {
  body.app .filter-trigger-bar { display: flex }
  body.app .layout { grid-template-columns: 1fr; padding: 0 }
  body.app aside.filters {
    position: fixed; top: 0; bottom: 0; right: 0;
    width: min(420px, 100vw); max-width: 100vw; max-height: 100vh;
    border-radius: 0; border: 0; border-left: 1px solid var(--line-strong);
    z-index: 95; transform: translateX(100%);
    transition: transform var(--t-slow);
    box-shadow: -20px 0 60px rgba(0,0,0,.5);
    padding: var(--sp-5) var(--sp-4);
    overflow-y: auto;
  }
  body.app.filters-open aside.filters { transform: translateX(0) }
  body.app .filter-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px); z-index: 94;
    opacity: 0; pointer-events: none;
    transition: opacity var(--t);
  }
  body.app.filters-open .filter-scrim { opacity: 1; pointer-events: auto }
  body.app.filters-open { overflow: hidden }
  /* On mobile, drop the dev-y FTS tips and the in-sidebar collections list
     since both have better homes (help modal + topnav) */
  body.app aside.filters .tips,
  body.app aside.filters .collections-block { display: none }
  body.app main { padding: var(--sp-4) var(--sp-3) var(--sp-12) }
}
@media (max-width: 720px) {
  body.app aside.filters {
    /* Full-screen drawer on phones — using dvh so iOS Chrome's collapsing URL
     * bar never eats the bottom or hides the sticky Done button at the top. */
    width: 100vw; max-width: 100vw;
    border: 0; border-radius: 0;
    top: 0; bottom: 0; left: 0; right: 0;
    height: 100dvh; max-height: 100dvh;
    transform: translateY(100%);
    box-shadow: 0 -20px 60px rgba(0,0,0,.55);
    /* Inner padding: head supplies its own top spacing (safe-area aware).
     * Bottom needs generous clearance — iOS Safari & Chrome's bottom URL
     * bar (~50-90px) can cover the last action even with 100dvh because
     * the bar fades in/out without firing a viewport resize. 100px of
     * scroll-overflow guarantees the last button is reachable. */
    padding: 0 var(--sp-4);
    padding-bottom: calc(max(env(safe-area-inset-bottom, 0px), 16px) + 100px);
  }
  body.app.filters-open aside.filters { transform: translateY(0) }
}

/* "Done" button + sheet head: sticks to the visible top of the sheet so it's
 * never trapped behind the iOS Chrome URL bar — and gets safe-area-inset
 * padding on devices with a notch. */
body.app .filter-sheet-head {
  display: none;
  position: sticky; top: 0; z-index: 5;
  margin: 0 calc(-1 * var(--sp-4));
  padding: max(env(safe-area-inset-top, 0px), 12px) var(--sp-4) 12px;
  background: var(--bg-elev-1);
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-3);
}
body.app .filter-sheet-head h3 { margin: 0; font-size: var(--fs-15); color: var(--fg); font-weight: 600 }
@media (max-width: 920px) { body.app .filter-sheet-head { display: flex } }

/* ---------- 8d. Responsive table wrapper --------------------------------- */
/* Pages with .refined tables: wrap each in <div class="table-wrap"> so the
 * table scrolls horizontally rather than blowing out the viewport. */
.table-wrap {
  width: 100%; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-5);
}
.table-wrap > table.refined { min-width: 720px }
@media (max-width: 720px) {
  .table-wrap > table.refined { font-size: var(--fs-12) }
  .table-wrap > table.refined th,
  .table-wrap > table.refined td { padding: 10px 10px }
}

/* ---------- 8e. Topbar mobile reflow ------------------------------------- */
@media (max-width: 720px) {
  body.app .topbar-inner { gap: var(--sp-3); padding: 0 var(--sp-3) }
  body.app .nav-link { padding: 8px 6px; font-size: var(--fs-12) }
  body.app .nav-link svg { display: none }
  body.app .topbar-right .icon-btn:not(.account-menu-trigger) { display: none }
  body.app .brand-mark .brand-dot { width: 28px; height: 28px; font-size: 16px }
  body.app .ws-switch-pop { min-width: min(320px, calc(100vw - 16px)) }
}
@media (max-width: 460px) {
  body.app .nav-primary { display: none }
  body.app .topbar-inner { justify-content: space-between }
}

/* ---------- 8f. Page hero compaction on mobile --------------------------- */
@media (max-width: 720px) {
  body.app .page-hero { margin-bottom: var(--sp-4) }
  body.app .page-hero h1 { font-size: var(--fs-28) }
  body.app .page-hero .subtitle { font-size: var(--fs-14) }
  body.app .hero-search { padding: var(--sp-5) var(--sp-3) }
  body.app .hero-search h1.display { font-size: var(--fs-28) }
  body.app .hero-search .subtitle { font-size: var(--fs-13) }
  /* Mobile reflow: search-box gets full width, controls below */
  body.app .hero-search-form .search-box { flex: 1 1 100% }
  body.app .hero-search-form .focal-toggle { flex: 1 1 auto; justify-content: center }
  body.app .hero-search-form > button[type="submit"] { flex: 1 1 100%; height: 44px }
  body.app .kpi-row { grid-template-columns: repeat(2, 1fr) }
  body.app .kpi-num { font-size: var(--fs-22) }
}

/* ---------- 8g. Status pill + library cards (Sources page) -------------- */
/* A high-status communication strip that puts Update Catalog one click away.
 * Ranks the day's most relevant info — synced state and last update — over
 * the technical chrome (pid, model, workers) which moves to disclosure. */
.status-strip {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-elev-1); border: 1px solid var(--line);
  border-radius: var(--r-5);
  flex-wrap: wrap;
}
.status-strip .status-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  border: 1px solid var(--line);
}
.status-strip.is-ok      .status-icon { background: var(--green-soft); color: var(--green); border-color: color-mix(in oklab, var(--green) 30%, transparent) }
.status-strip.is-running .status-icon { background: var(--blue-soft);  color: var(--blue);  border-color: color-mix(in oklab, var(--blue) 30%, transparent) }
.status-strip.is-stale   .status-icon { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in oklab, var(--amber) 30%, transparent) }
.status-strip.is-error   .status-icon { background: var(--red-soft);   color: var(--red);   border-color: color-mix(in oklab, var(--red) 30%, transparent) }
.status-strip .status-text { flex: 1; min-width: 0 }
.status-strip .status-headline { font-size: var(--fs-16); font-weight: 600; color: var(--fg) }
.status-strip .status-sub      { font-size: var(--fs-13); color: var(--fg-soft); margin-top: 2px }
.status-strip .status-actions  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap }
.status-strip.is-running .status-icon svg { animation: spin 5s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }

/* Library cards — replace the dense table on Sources page */
.lib-grid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.lib-card {
  background: var(--bg-elev-1); border: 1px solid var(--line);
  border-radius: var(--r-5); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  transition: border-color var(--t), background var(--t);
}
.lib-card:hover { border-color: var(--line-strong); background: var(--bg-elev-2) }
.lib-card.is-disabled { opacity: .55 }
.lib-card-head { display: flex; gap: var(--sp-3); align-items: flex-start }
.lib-icon {
  width: 40px; height: 40px; border-radius: var(--r-3);
  background: var(--bg-elev-2); display: grid; place-items: center;
  flex: 0 0 auto; color: var(--fg-soft); border: 1px solid var(--line);
}
.lib-icon.drive   { background: rgba(106,169,255,.10); color: #6aa9ff; border-color: rgba(106,169,255,.20) }
.lib-icon.dropbox { background: rgba(170,140,255,.10); color: #b39bff; border-color: rgba(170,140,255,.20) }
.lib-card .lib-name {
  font-size: var(--fs-15); font-weight: 600; color: var(--fg);
  display: block; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none !important;
}
.lib-card .lib-name:hover { color: var(--accent) }
.lib-card .lib-meta { font-size: var(--fs-12); color: var(--fg-dim); margin-top: 2px }
.lib-card .lib-stats { display: flex; gap: var(--sp-4); font-size: var(--fs-12); color: var(--fg-soft) }
.lib-card .lib-stats strong { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums }
.lib-progress {
  height: 4px; background: var(--bg-elev-3); border-radius: var(--r-pill); overflow: hidden;
}
.lib-progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in oklab, var(--accent) 60%, white));
  transition: width var(--t-slow);
}
.lib-card .lib-actions {
  display: flex; gap: 6px; padding-top: var(--sp-2);
  border-top: 1px solid var(--line-faint);
}
.lib-card .lib-actions a, .lib-card .lib-actions button { flex: 1; justify-content: center }

/* "+ Add library" tile */
.lib-add {
  background: transparent; border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-5); padding: var(--sp-4);
  color: var(--fg-soft); cursor: pointer;
  display: grid; place-items: center; min-height: 200px;
  font-family: inherit; font-size: var(--fs-14); font-weight: 500;
  text-align: center; line-height: 1.5;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.lib-add:hover { border-color: var(--accent); color: var(--fg); background: var(--accent-soft) }
.lib-add svg { width: 28px; height: 28px; opacity: .8; margin-bottom: 6px }

/* Quiet log tail (collapsed by default) */
.quiet-log {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: var(--r-3); padding: 10px 12px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-soft); overflow-x: auto;
  max-height: 220px; overflow-y: auto;
  white-space: pre; line-height: 1.5;
}

/* ---------- 8g-bis. Filter customize (hide/show per-filter) --------------
 * Filters are tagged with `data-filter-key`; visibility is toggled
 * exclusively from the "Edit filters" modal. State persists in localStorage. */
body.app aside.filters label[data-filter-key].is-hidden { display: none }

.filter-customize-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: var(--sp-3);
  font-size: var(--fs-12); color: var(--fg-soft);
  background: transparent; border: 0; padding: 4px 0;
  cursor: pointer; font-family: inherit;
}
.filter-customize-link:hover { color: var(--accent) }
.filter-customize-link svg { width: 12px; height: 12px }

/* ---------- 8h-pre. Toggle switch -----------------------------------------
 * iOS-style toggle that visually replaces a checkbox without losing form
 * semantics. Markup pattern:
 *   <label class="toggle"><input type="checkbox" name="..."><span class="toggle-track"></span> Label text</label>
 * The checkbox is visually hidden (still keyboard-focusable + form-submitted);
 * the .toggle-track is the visible pill + sliding knob. */
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  font-size: var(--fs-13); color: var(--fg-soft);
  font-weight: 500; line-height: 1;
}
.toggle input[type="checkbox"] {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: 0; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.toggle-track {
  position: relative; display: inline-block; flex: 0 0 auto;
  width: 32px; height: 18px;
  background: color-mix(in oklab, var(--fg-dim) 35%, transparent);
  border-radius: 100px;
  transition: background var(--t);
}
.toggle-track::after {
  content: ""; position: absolute;
  top: 2px; left: 2px; width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform var(--t-slow);
}
.toggle input:checked + .toggle-track { background: var(--accent) }
.toggle input:checked + .toggle-track::after { transform: translateX(14px) }
.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.toggle:hover .toggle-track { filter: brightness(1.04) }

/* ---------- 8h. Help tip (?) — works on hover AND mobile tap ------------ */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: transparent; color: var(--fg-dim);
  border: 1.25px solid color-mix(in oklab, var(--fg-dim) 35%, transparent);
  padding: 0; margin-left: 6px;
  cursor: pointer; line-height: 1; font-family: inherit;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t-fast);
  vertical-align: middle;
  position: relative;
}
.help-tip svg { width: 10px; height: 10px; display: block }
.help-tip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); transform: scale(1.08) }
.help-tip[aria-expanded="true"] { background: var(--accent); color: var(--accent-on); border-color: var(--accent) }
.help-tip-bubble {
  position: absolute;
  top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-1); color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  padding: 8px 12px;
  font-size: var(--fs-12); font-weight: 400; line-height: 1.45;
  text-align: left; text-transform: none; letter-spacing: 0;
  width: max-content; max-width: 240px;
  box-shadow: var(--shadow-2);
  z-index: 50;
  display: none;
  white-space: normal;
}
.help-tip-bubble::before {
  content: ""; position: absolute;
  top: -5px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 9px; height: 9px;
  background: var(--bg-elev-1);
  border-left: 1px solid var(--line-strong); border-top: 1px solid var(--line-strong);
}
.help-tip[aria-expanded="true"] .help-tip-bubble,
.help-tip:hover .help-tip-bubble { display: block }
@media (hover: none) and (pointer: coarse) {
  .help-tip:hover .help-tip-bubble { display: none }
  .help-tip[aria-expanded="true"] .help-tip-bubble { display: block }
}

/* ---------- 8i. Bulk actions sticky bar (admin Library) ------------------
 * Floats at the bottom of the viewport when ≥1 card is selected. Pulls every
 * existing sidebar action button into a horizontal pill. Mobile-friendly:
 * scrolls horizontally if buttons don't fit, respects safe-area-inset-bottom
 * on iOS, doesn't fight the filter sheet. */
.bulkbar {
  position: fixed;
  left: 50%; bottom: -160px;
  transform: translateX(-50%);
  background: var(--bg-elev-1);
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  padding: 10px 10px 10px 22px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 28px 70px rgba(20,16,4,.32), 0 6px 18px rgba(20,16,4,.16);
  transition: bottom .35s cubic-bezier(.2,.9,.3,1.2), opacity .25s;
  z-index: 40;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.bulkbar::-webkit-scrollbar { display: none }
.bulkbar.show { bottom: max(24px, env(safe-area-inset-bottom, 0px)) }
.bulkbar.dismissed { bottom: -160px }
.bulkbar-count {
  font-weight: 600; font-size: var(--fs-15); color: var(--fg);
  display: inline-flex; align-items: baseline; gap: 6px;
  flex: 0 0 auto;
}
.bulkbar-count strong { color: var(--accent); font-size: 22px; font-variant-numeric: tabular-nums }
.bulkbar .bulkbar-actions { display: inline-flex; gap: 8px; align-items: center }
.bulkbar button {
  background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 100px;
  padding: 11px 18px; font-size: var(--fs-14); font-weight: 600;
  cursor: pointer; font-family: inherit; line-height: 1;
  white-space: nowrap; flex: 0 0 auto;
  transition: background .15s, border-color .15s, color .15s;
}
.bulkbar button:hover { background: var(--bg-elev-3); border-color: var(--line-strong) }
.bulkbar button.primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent) }
.bulkbar button.danger:hover { color: var(--red); border-color: var(--red) }
.bulkbar button:disabled { opacity: .4; cursor: not-allowed }
.bulkbar .bulkbar-close {
  width: 36px; height: 36px; padding: 0; font-size: 22px;
  display: inline-grid; place-items: center;
  color: var(--fg-soft); border-radius: 50%;
}
.bulkbar .bulkbar-close:hover { color: var(--fg); border-color: var(--line-strong) }
@media (max-width: 720px) {
  .bulkbar {
    left: 8px; right: 8px; transform: none;
    width: auto; max-width: none;
    border-radius: var(--r-5);
    padding: 12px 10px 12px 16px;
  }
  .bulkbar.show { bottom: max(12px, env(safe-area-inset-bottom, 0px)) }
  .bulkbar button { padding: 12px 16px; font-size: var(--fs-14) }
  .bulkbar-count strong { font-size: 19px }
}

/* ---------- 9. Utilities ------------------------------------------------- */
.muted { color: var(--fg-soft) }
.dim   { color: var(--fg-dim) }
.tiny  { font-size: var(--fs-12) }
.mono  { font-family: var(--font-mono); font-size: var(--fs-12) }
.row   { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap }
.row-tight { display: flex; gap: 4px; align-items: center }
.col   { display: flex; flex-direction: column; gap: var(--sp-2) }
.spacer { flex: 1 }
.hide  { display: none !important }
.show-mobile { display: none }
@media (max-width: 720px) {
  .hide-mobile { display: none !important }
  .show-mobile { display: initial }
}
