/* Generated from apps/web/app/styles.css and its ordered modules. */

/* Tomebound: foundations. Cascade order is declared in ../styles.css. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
/* iOS: stop landscape text auto-inflating and the grey tap flash on every
   touch. Buttons keep their own :active feedback (e.g. vellum's
   .btn:active), so this doesn't leave taps feeling dead. */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
/* Scrollbar rails are hidden for now (Benson, 2026-09-14): the themed thumb
   clashed with the page. The rule covers every scroller, not only the panels
   scrollbarVisibility.js tags at runtime, so Storybook fixtures and scrollers
   mounted before that pass match production. The .themed-scrollbar hook, the
   --scrollbar-* tokens, and the show-on-scroll helper stay so a future
   position indicator can reuse them; `.is-scrolling` currently paints nothing. */
*,
.themed-scrollbar {
  scrollbar-width: none;
}
*::-webkit-scrollbar,
.themed-scrollbar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
/* BEN-759: self-hosted Noto Color Emoji (COLRv1 vector woff2, same-origin) so
   emoji render in the flat Google style on Windows/Chromium/Firefox instead of
   the glossy OS glyphs. It sits last in the app font stacks, so only emoji
   codepoints fall through to it; text stays in the existing fonts. Loads lazily
   (font-display: swap) and caches after first paint. Safari lacks COLRv1 and
   falls back to Apple emoji — fine, not fought. */
@font-face {
  font-family: 'Noto Color Emoji';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./NotoColorEmoji-COLRv1-cc1ca9eace.woff2') format('woff2');
}
/* BEN-759: vellum's `body.vui-app` sets the body font from --vui-font-body and
   outspecifies the base `body` rule, so anything that inherits the body font
   (emoji picker cells/tabs, the container-editor emoji button, history rows,
   staged-import) would miss the Noto fallback. Re-point it at tomebound's
   --font-body, which is the same vellum stack with 'Noto Color Emoji' appended. */
body.vui-app {
  font-family: var(--font-body);
}
:root {
  /* Structural (non-themable) values */
  --edge-margin: var(--vui-edge-margin, 12px);
  --z-flyout: var(--vui-z-flyout, 50);
  --z-modal: var(--vui-z-modal, 110);
  --control-height-compact: var(--vui-control-height-compact, 28px);
  --control-pad-y: var(--vui-control-pad-y, 5px);
  --control-pad-x: var(--vui-control-pad-x, 10px);
  --focus-ring: var(--vui-focus-ring, 2px solid var(--color-text-strong));
  --focus-ring-offset: var(--vui-focus-ring-offset, 2px);
  --scrollbar-thumb: var(--vui-scrollbar-thumb, var(--color-text-muted));
  --scrollbar-thumb-hover: var(--vui-scrollbar-thumb-hover, var(--color-text-strong));
  --scrollbar-track: var(--vui-scrollbar-track, transparent);

  /* ---- Arcane-ledger design tokens (typography, color, shape, shadow, motion, space).
     tomebound has one visual language; no theme switching. Adjust here to retune. ---- */

  /* Typography. BEN-759: 'Noto Color Emoji' is appended after the resolved text
     fonts so emoji codepoints fall through to the self-hosted Google emoji face
     while text keeps rendering in the sans/mono fonts. */
  --font-body:
    var(
      --vui-font-body,
      system-ui,
      -apple-system,
      'Segoe UI',
      Roboto,
      Helvetica,
      Arial,
      sans-serif
    ),
    'Noto Color Emoji';
  --font-heading: var(--vui-font-heading, 'Cormorant Unicase', Georgia, 'Times New Roman', serif);
  --font-display: var(--vui-font-display, 'Cormorant Unicase', Georgia, 'Times New Roman', serif);
  --font-mono: var(--vui-font-mono, 'Courier New', Courier, monospace), 'Noto Color Emoji';
  --font-size-xxxs: var(--vui-font-size-xxxs, 0.55rem);
  --font-size-xxs: var(--vui-font-size-xxs, 0.68rem);
  --font-size-xs: var(--vui-font-size-xs, 0.72rem);
  --font-size-sm: var(--vui-font-size-sm, 0.78rem);
  --font-size-md: var(--vui-font-size-md, 0.85rem);
  --font-size-base: var(--vui-font-size-base, 0.9rem);
  --font-size-lg: var(--vui-font-size-lg, 0.95rem);
  --font-size-xl: var(--vui-font-size-xl, 1.02rem);
  --font-size-heading: var(--vui-font-size-heading, 1.3rem);
  --font-size-display: var(--vui-font-size-display, 1.7rem);
  /* BEN-477 size long-tail: steps minted to retire one-off font-sizes.
     -xs-plus/-sm-plus sit between the t-shirt steps; -jumbo is above display. */
  --font-size-xs-plus: 0.75rem;
  --font-size-sm-plus: 0.82rem;
  --font-size-jumbo: var(--vui-font-size-jumbo, 2rem);
  --font-weight-body: var(--vui-font-weight-body, 900);
  --font-weight-title: var(--vui-font-weight-title, 900);
  --line-height-body: var(--vui-line-height-body, 1.4);
  --letter-spacing-ui: var(--vui-letter-spacing-ui, 0);
  --title-size: var(--vui-title-size, clamp(36px, 5.6vw, 68px));
  --title-tracking: var(--vui-title-tracking, -0.06em);
  --title-transform: var(--vui-title-transform, none);
  --title-shadow: var(--vui-title-shadow, 3px 3px 0 var(--color-text-strong));
  --label-tracking: var(--vui-label-tracking, 0.06em);
  --label-transform: none;

  /* Color */
  /* BEN-420: cooler canvas — surfaces shifted off the warm yellow toward a
     cool lilac-grey so the app reads less beige; purple accent carries
     interactive emphasis (active states, labels). */
  --color-bg: var(--vui-color-bg, #f1eef6);
  --color-surface: var(--vui-color-surface, #e7e2ee);
  --color-surface-sunken: var(--vui-color-surface-sunken, #cec4dd);
  --color-surface-raised: var(--vui-color-surface-raised, #faf8fd);
  --color-surface-hover: var(--vui-color-surface-hover, #ece7f3);
  --color-surface-placeholder: var(--vui-color-surface-placeholder, #e8d8ad);
  --color-text: var(--vui-color-text, #15100d);
  --color-text-muted: var(--vui-color-text-muted, #5b3b25);
  --color-text-faint: var(--vui-color-text-muted, #5b3b25);
  --color-text-strong: var(--vui-color-text-strong, #15100d);
  --color-text-inverse: var(--vui-color-text-inverse, #fff5d2);
  --color-line: var(--vui-color-line, rgba(21, 16, 13, 0.4));
  --color-line-subtle: var(--vui-color-line-faint, #eee);
  --color-line-strong: var(--vui-color-line-strong, #15100d);
  /* BEN-411: focus/hover indicator uses the arcane purple accent, not the wax
     red (which is reserved for destructive actions). */
  --color-line-focus: var(--vui-color-line-focus, var(--color-accent));
  --color-accent: var(--vui-color-accent, #6c3aa4);
  --color-accent-strong: var(--vui-color-accent-strong, #452451);
  /* Card hover/selection outline. Violet is the one hue no Magic card frame
     uses, so it stays distinct on every card; keep it opaque and full strength
     (a mixed hover read as faint over the art). Selection is thicker. */
  --color-card-outline: #8b3fd9;
  --color-card-hover-outline: var(--color-card-outline);
  --color-accent-soft: var(--vui-color-accent-soft, #e7d8f5);
  /* BEN-445: translucent accent washes for column hover / drag highlight.
     Translucent so they layer over the existing row-hover / selected
     backgrounds instead of replacing them. */
  --color-column-hl: rgba(108, 58, 164, 0.1);
  --color-column-dragging: rgba(108, 58, 164, 0.2);
  --color-success: var(--vui-color-success, #7f9461);
  --color-warn: var(--vui-color-warn, #f2c452);
  --color-danger: var(--vui-color-danger, #a73528);
  --color-danger-strong: var(--vui-color-danger-strong, #a73528);
  --color-danger-hover: var(--vui-color-danger-hover, #7a2820);
  --color-info: var(--vui-color-info, #68447d);
  --color-success-soft: var(--vui-color-success-soft, rgba(127, 148, 97, 0.18));
  --color-warn-soft: var(--vui-color-warn-soft, #ead07a);
  --color-warn-soft-pale: var(--vui-color-warn-soft-pale, #fff8e0);
  --color-danger-soft: var(--vui-color-danger-soft, rgba(167, 53, 40, 0.14));
  /* Vellum's info-soft is still blue; derive the wash from its plum info hue.
     A neutral status base preserves that hue even on the book theme's paper. */
  --color-info-soft: color-mix(
    in srgb,
    var(--vui-color-info, #68447d) 12%,
    var(--color-status-neutral-bg)
  );
  --color-success-line: var(--vui-color-success-line, #7f9461);
  --color-warn-line: var(--vui-color-warn-line, #d4a830);
  --color-warn-line-soft: #e6c878;
  --color-danger-line: var(--vui-color-danger-line, #a73528);
  --color-info-line: var(--vui-color-info-line, #68447d);
  --color-state-queued: #8756a0;
  /* Status chips (legality / share) — pale bg + border + readable text per
     status. Exact prior literals, now named for zero-drift token adoption. */
  --color-success-bg: var(--vui-status-success-bg, #effaef);
  --color-success-border: var(--vui-status-success-border, #c4e5c4);
  --color-success-text: var(--vui-status-success-text, #2c6b2c);
  --color-status-success-text: var(--vui-status-success-text, #2c6b2c);
  --color-warn-bg: var(--vui-status-warn-bg, #fff5dc);
  --color-warn-border: var(--vui-status-warn-border, #e8d49a);
  --color-warn-text: var(--vui-status-warn-text, #7a5a10);
  --color-status-warning-text: var(--vui-status-warn-text, #7a5a10);
  --color-warn-bg-cream: #fff8e6;
  --color-danger-bg: var(--vui-status-danger-bg, #fbecec);
  --color-danger-border: var(--vui-status-danger-border, #e6bebe);
  --color-danger-text: var(--vui-status-danger-text, #8a2828);
  --color-status-neutral-bg: var(--vui-status-neutral-bg, #f4f4f4);
  --color-status-neutral-border: var(--vui-status-neutral-border, #ddd);
  --color-status-neutral-text: var(--vui-status-neutral-text, #777);
  /* Faint neutral line — lighter than --color-line; used for empty-state SVG
     ring strokes and the neutral (not-legal) status chip border. */
  --color-line-faint: var(--vui-color-line-faint, #eee);
  --color-surface-warm: #fbfaf7;
  --color-loc-deck-bg: #eee6f1;
  --color-loc-deck-text: var(--vui-color-accent, #6c3aa4);
  --color-loc-deck-line: #a795af;
  --color-loc-container-bg: #ece8e0;
  --color-loc-container-text: #6b5730;
  --color-loc-container-line: #c2bdb0;
  /* Meaning-bearing hues: attention (ember), provenance (cobalt), passive
     state (sage), and the Archivist's curated voice (plum). */
  --color-attention-text: #794c3b;
  --color-attention-bg: #f2e5df;
  --color-attention-line: #b48b78;
  --color-provenance-text: #465d7c;
  --color-provenance-bg: #e6ecf4;
  --color-provenance-line: #8a9eb9;
  --color-passive-text: #545d4d;
  --color-archivist: var(--vui-color-accent, #6c3aa4);
  --color-board-main-bg: var(--color-surface);
  --color-board-main-text: var(--color-text);
  --color-board-main-line: var(--color-line);
  --color-board-side-bg: #e3ebe7;
  --color-board-side-text: #405c53;
  --color-board-side-line: #4d6861;
  --color-board-maybe-bg: #e8ebe4;
  --color-board-maybe-text: var(--color-passive-text);
  --color-board-maybe-line: #949b8b;
  --color-input-bg: var(--vui-color-input-bg, rgba(255, 255, 255, 0.36));
  --color-input-bg-focus: var(--vui-color-input-bg-focus, rgba(255, 255, 255, 0.52));
  --color-overlay-strong: var(--vui-color-overlay-strong, rgba(0, 0, 0, 0.8));
  --color-overlay-soft: var(--vui-color-overlay-soft, rgba(0, 0, 0, 0.4));
  /* Aliased to vellum so they theme-flip: in dark mode the "ink" surfaces go
     light, so on-dark content must go dark (these were literal-white before —
     invisible on the flipped band). */
  --color-on-dark-line: var(--vui-color-on-dark-line, rgba(255, 255, 255, 0.4));
  --color-on-dark-text-soft: var(--vui-color-on-dark-text-soft, rgba(255, 255, 255, 0.82));
  /* Pastel card-pip discs. Keep these six values identical to MANA_COLORS
     in ui/colorTokens.js, which also supplies the multicolor stats fill. */
  --color-mana-w: #efe6c0;
  --color-mana-u: #9cc4dd;
  --color-mana-b: #8f8580;
  --color-mana-r: #e39a80;
  --color-mana-g: #93bf9d;
  --color-mana-c: #c9c1ba;
  --color-btn-primary-hover: var(--vui-color-btn-primary-hover, #5b3b25);
  --color-shadow: var(--vui-color-shadow, #3d2b22);
  /* History controls and MCP badges share the provenance family. */
  --color-mcp-bg: var(--color-provenance-bg);
  --color-mcp-border: var(--color-provenance-line);
  --color-mcp-text: var(--color-provenance-text);
  --color-mcp-mark-bg: var(--color-provenance-bg);
  --color-chat-bg: #f1ecdf;
  --color-chat-border: rgba(120, 90, 30, 0.32);
  --color-chat-text: #6a4f1a;
  --color-deck-hover-bg: rgba(107, 82, 36, 0.16);
  --color-deck-hover-text: #3f2f0e;
  --color-undo-link: var(--color-provenance-text);
  --color-redo-link: var(--color-provenance-text);
  /* Neutral greys — cool achromatic scale used by settings panels, share /
     import modals and the inspector chrome. Distinct from the warm canvas
     tokens above (which are lilac/brown); these stay neutral by design.
     Exact prior literals, named for zero-drift adoption. */
  --color-neutral-black: var(--vui-color-neutral-black, #000);
  --color-neutral-white: var(--vui-color-neutral-white, #fff);
  --color-neutral-900: var(--vui-color-neutral-900, #111);
  --color-neutral-700: var(--vui-color-neutral-700, #333);
  --color-neutral-600: var(--vui-color-neutral-600, #444);
  --color-neutral-550: var(--vui-color-neutral-550, #555);
  --color-neutral-500: var(--vui-color-neutral-500, #666);
  --color-neutral-400: var(--vui-color-neutral-400, #888);
  --color-neutral-350: var(--vui-color-neutral-350, #999);
  --color-neutral-250: var(--vui-color-neutral-250, #bbb);
  --color-neutral-200: var(--vui-color-neutral-200, #ccc);
  /* Neutral surface/border off-whites for the same chrome. */
  --color-neutral-surface-warm: var(--vui-color-neutral-surface-warm, #fffefb);
  --color-neutral-surface-faint: var(--vui-color-neutral-surface-faint, #fafafa);
  --color-neutral-border-warm: var(--vui-color-neutral-border-warm, #ddd6ca);
  /* Plain reds used by destructive text/borders in the settings chrome. */
  --color-danger-text-plain: #9f0000;
  --color-danger-text-deep: #900;
  /* Warm chrome long-tail — beige surfaces, hairlines and muted text used by
     detail/printing meta, mcp-chat cards, tag manager and deck rows. Exact
     prior literals. */
  --color-surface-beige: #f0ece0;
  --color-surface-beige-soft: #f4f4f0;
  --color-surface-beige-pale: #f8f7f4;
  --color-surface-parchment: #f7f3eb;
  --color-line-beige: #e2ded6;
  --color-line-beige-soft: #eee7dc;
  --color-line-beige-faint: #f3eee2;
  --color-line-parchment: #e4ddd0;
  --color-line-warm-mid: #d6d0c5;
  --color-line-warm-dim: #d6d0c2;
  --color-line-warm-divider: #cfc7b8;
  --color-line-warm-divider-strong: #d3cbbc;
  --color-bullet-warm: #b9aa96;
  --color-text-warm-muted: #5e5548;
  --color-text-warm-faint: #8f8576;
  --color-text-warm-label: #84796a;
  --color-text-warm-strong: #2f2a23;
  --color-detail-note-bg: #f8f3e7;
  --color-detail-note-line: #e1d5ba;
  --color-detail-note-text: #5b4b2e;
  /* Status / accent long-tail — feedback toasts, badges and inline warnings. */
  --color-warn-bg-soft: #fff7e0;
  --color-warn-text-amber: #b58a00;
  --color-warn-text-gold: #b08020;
  --color-warn-text-deep: #9a6a00;
  --color-tag-amber-bg: #fff8d9;
  --color-tag-amber-text: #7a5f00;
  --color-tag-amber-line: #e3cf84;
  --color-tag-blue-bg: #f1f7ff;
  --color-tag-blue-text: #0a477a;
  --color-tag-blue-line: #bdd4ea;
  --color-danger-text-warm: #8b3636;
  --color-danger-line-warm: #d8b8b8;
  --color-danger-bg-warm: #fbf2f2;
  --color-danger-text-soft: #9d1c1c;
  --color-danger-text-rose: #b04848;
  /* Price sparkline + empty-state card-back illustration. */
  --color-sparkline-line: #5f86b0;
  --color-cardback-navy: #323e59;
  --color-cardback-rust: #9a592a;
  --color-cardback-parchment: #efe3c5;
  --color-surface-stripe: #e8e4dd;

  /* Shape */
  --radius-sharp: var(--vui-radius-sharp, 4px);
  --radius-soft: var(--vui-radius-soft, 7px);
  --radius-square: var(--vui-radius-square, 0px);
  --radius-pill: var(--vui-radius-pill, 999px);
  --radius-card: var(--vui-radius-card, 4%);
  --radius-tight: var(--vui-radius-tight, 2px); /* below sharp; retires one-off 2px corners */
  --radius-round: var(--vui-radius-round, 10px); /* between soft and pill */
  --border-width: var(--vui-border-width, 3px);

  /* Shadow */
  --shadow-subtle: var(--vui-shadow-subtle, 0 0 0 var(--color-shadow));
  --shadow-soft: var(--vui-shadow-soft, 3px 3px 0 var(--color-shadow));
  --shadow-firm: var(--vui-shadow-firm, 4px 4px 0 var(--color-shadow));
  --shadow-lift: var(--vui-shadow-lift, 0 3px 0 var(--color-shadow));
  --shadow-popover: var(--vui-shadow-popover, 4px 4px 0 var(--color-shadow));
  --shadow-overlay: var(--vui-shadow-overlay, 8px 8px 0 var(--color-shadow));
  --shadow-hard: var(--vui-shadow-hard, 6px 6px 0 var(--color-shadow));
  --shadow-hard-small: var(--vui-shadow-hard-sm, 3px 3px 0 var(--color-text-strong));
  --press-shift: var(--vui-press-shift, 2px);
  --press-shadow: var(--vui-press-shadow, 2px 2px 0 var(--color-shadow));
  --input-bevel: var(
    --vui-input-bevel,
    inset 3px 3px 0 rgba(0, 0, 0, 0.18),
    inset -2px -2px 0 rgba(255, 255, 255, 0.32)
  );

  /* Soft elevation — blurred ambient panel-edge shadows (vs hard ledger family above) */
  --shadow-panel-right: 4px 0 10px -6px rgba(0, 0, 0, 0.18);
  --shadow-panel-left: -3px 0 8px -3px rgba(0, 0, 0, 0.08);
  --shadow-panel-top: 0 -3px 8px -3px rgba(0, 0, 0, 0.08);
  --shadow-strip-top: 0 -3px 8px -6px rgba(0, 0, 0, 0.24);
  --shadow-sticky-column: 10px 0 18px -8px rgba(0, 0, 0, 0.28);
  --shadow-drawer-side: -2px 0 12px rgba(0, 0, 0, 0.15);
  --shadow-drawer-side-right: 2px 0 12px rgba(0, 0, 0, 0.15);
  --shadow-drawer-top: 0 -10px 22px -22px rgba(0, 0, 0, 0.65);

  /* Translucent surface veils */
  --surface-veil: rgba(255, 255, 255, 0.88);
  --surface-veil-soft: rgba(255, 255, 255, 0.34);
  --surface-veil-warm: rgba(248, 247, 244, 0.72);
  --surface-veil-warm-soft: rgba(240, 236, 224, 0.42);

  /* Motion */
  --motion-fast: var(--vui-motion-fast, 120ms);
  --motion-snap: var(--vui-motion-snap);
  --motion-base: var(--vui-motion-base, 180ms);
  --motion-slow: var(--vui-motion-slow, 260ms);

  /* Space */
  --space-1: var(--vui-space-1, 4px);
  --space-2: var(--vui-space-2, 8px);
  --space-3: var(--vui-space-3, 12px);
  --space-4: var(--vui-space-4, 16px);
  --space-5: var(--vui-space-5, 20px);

  /* Gradients (specialty card foils) */
  --gradient-card-foil: linear-gradient(
    110deg,
    transparent 18%,
    rgba(255, 90, 180, 0.42) 38%,
    rgba(120, 200, 255, 0.42) 50%,
    rgba(140, 255, 110, 0.42) 62%,
    transparent 82%
  );
  --gradient-card-etched: linear-gradient(
    110deg,
    transparent 25%,
    rgba(180, 80, 220, 0.45) 50%,
    transparent 75%
  );
}

/* M-29: 12px is the smallest comfortable text on a touchscreen — bump the two
   sub-12px steps everywhere they're used (location pills, sidebar counts,
   history chips, …) rather than patching each selector. Vellum components
   (e.g. .ui-chip, which loc-pill and tag-chip both ride) read --vui-font-
   size-xxs/xs directly rather than the app's --font-size-* alias, so both
   layers need the override. */
@media (pointer: coarse) {
  :root {
    --font-size-xxs: 12px;
    --font-size-xs: 12px;
    --vui-font-size-xxs: 12px;
    --vui-font-size-xs: 12px;
  }
}

/* Dark theme — tomebound-local palette. Vellum's [data-theme='dark'] layer
   flips the shared tokens (the attribute lives on <html>); this block flips
   the app-local warm/parchment families layered on top. First pass: large
   surfaces, lines, text, veils, and tinted panels. The loc/board/tag pill
   palettes deliberately keep their light "sticker" look on dark — their ink is
   pinned to the palettes' fixed dark text tokens (BEN-562), never the
   theme-flipping text tokens. */
[data-theme='dark'] {
  --color-card-outline: #a979f2;
  --color-text-faint: var(--vui-color-text-muted, #b0a3ad);
  --color-line-subtle: var(--vui-color-line-faint, #343039);
  --color-accent-strong: var(--vui-color-accent-strong, #ead0f2);
  --color-status-success-text: var(--vui-status-success-text, #a8d8a8);
  --color-status-warning-text: var(--vui-status-warn-text, #e8cc7a);
  --color-column-hl: rgba(168, 120, 224, 0.14);
  --color-column-dragging: rgba(168, 120, 224, 0.26);
  --color-warn-line-soft: #6a5a28;
  --color-warn-bg-cream: #2e2614;
  --color-surface-warm: #261f2e;
  /* Lighter, quieter versions of the book hues for dark surfaces. */
  --color-attention-text: #dfb29d;
  --color-attention-bg: #392b28;
  --color-attention-line: #a17e6e;
  --color-provenance-text: #b3c6e0;
  --color-provenance-bg: #252f3e;
  --color-provenance-line: #8098b6;
  --color-passive-text: #b9c2af;
  --color-archivist: var(--vui-color-accent, #c6a0d5);
  --color-loc-deck-bg: #33283b;
  --color-loc-deck-text: var(--vui-color-accent, #c6a0d5);
  --color-loc-deck-line: #a795af;
  --color-loc-container-bg: #342e23;
  --color-loc-container-text: #dcc391;
  --color-loc-container-line: #a58b55;
  --color-board-main-bg: var(--color-surface);
  --color-board-main-text: var(--color-text);
  --color-board-main-line: var(--color-line);
  --color-board-side-bg: #25332f;
  --color-board-side-text: #a9c7bc;
  --color-board-side-line: #86a79b;
  --color-board-maybe-bg: #2d322a;
  --color-board-maybe-text: var(--color-passive-text);
  --color-board-maybe-line: #949b8b;
  --color-chat-bg: #2b2517;
  --color-chat-border: rgba(200, 160, 80, 0.35);
  --color-chat-text: #d8b86a;
  --color-deck-hover-bg: rgba(216, 184, 106, 0.18);
  --color-deck-hover-text: #e8cc7a;
  --color-danger-text-plain: #e89090;
  --color-danger-text-deep: #e07b7b;
  --color-surface-beige: #28222f;
  --color-surface-beige-soft: #251f2c;
  --color-surface-beige-pale: #221c29;
  --color-surface-parchment: #262030;
  --color-line-beige: #3e3648;
  --color-line-beige-soft: #383140;
  --color-line-beige-faint: #322b3b;
  --color-line-parchment: #3e3648;
  --color-line-warm-mid: #46404f;
  --color-line-warm-dim: #443d4d;
  --color-line-warm-divider: #4a4254;
  --color-line-warm-divider-strong: #524a5e;
  --color-bullet-warm: #776e82;
  --color-text-warm-muted: #b8aec5;
  --color-text-warm-faint: #8d8398;
  --color-text-warm-label: #a298ad;
  --color-text-warm-strong: #e9e2f2;
  --color-detail-note-bg: #2a2433;
  --color-detail-note-line: #4a4254;
  --color-detail-note-text: #cdbf9d;
  --color-warn-bg-soft: #2e2614;
  --color-warn-text-amber: #e8cc7a;
  --color-warn-text-gold: #dfc26a;
  --color-warn-text-deep: #e8cc7a;
  --color-danger-text-warm: #d89090;
  --color-danger-line-warm: #6a3434;
  --color-danger-bg-warm: #2e1818;
  --color-danger-text-soft: #e08585;
  --color-danger-text-rose: #d88f8f;
  --color-surface-stripe: #2e2738;
  --shadow-panel-right: 4px 0 10px -6px rgba(0, 0, 0, 0.55);
  --shadow-panel-left: -3px 0 8px -3px rgba(0, 0, 0, 0.25);
  --shadow-panel-top: 0 -3px 8px -3px rgba(0, 0, 0, 0.25);
  --shadow-strip-top: 0 -3px 8px -6px rgba(0, 0, 0, 0.72);
  --shadow-drawer-side: -2px 0 12px rgba(0, 0, 0, 0.46);
  --shadow-drawer-side-right: 2px 0 12px rgba(0, 0, 0, 0.46);
  --shadow-drawer-top: 0 -10px 22px -22px rgba(0, 0, 0, 0.9);
  --surface-veil: rgba(28, 23, 34, 0.88);
  --surface-veil-soft: rgba(28, 23, 34, 0.34);
  --surface-veil-warm: rgba(36, 30, 44, 0.72);
  --surface-veil-warm-soft: rgba(36, 30, 44, 0.42);
}
/* BEN-563: these add-drawer panels are deliberately whiter-than-surface in
   light mode; in dark they get a real dark surface instead of staying white
   under dark-theme (light) text. (The drawer shells themselves ride
   --color-bg and flip on their own — BEN-609.) */
[data-theme='dark'] details.add-details,
[data-theme='dark'] .add-actions {
  background: var(--color-surface);
}
[data-theme='dark'] .autocomplete-list,
[data-theme='dark'] .printing-list,
[data-theme='dark'] .printing-filter-input {
  background: var(--color-surface-raised);
}
/* BEN-570: Scryfall set-symbol SVGs are black glyph art in an <img> — flip
   them light on dark rows. */
[data-theme='dark'] .set-icon {
  filter: invert(1);
}
/* BEN-608: the chat widget and its grey-family inputs are pinned to
   --color-neutral-white, which never flips; give them real dark surfaces
   (border/text already flip via the neutral-200/900 tokens). */
[data-theme='dark'] .mcp-chat-card-move select,
[data-theme='dark'] .mcp-chat-card-move input,
[data-theme='dark'] .mcp-chat-draft-field input,
[data-theme='dark'] .mcp-chat-draft-field select {
  background: var(--color-surface-raised);
}
body {
  --app-footer-h: 38px;
  --sidebar-collapsed-w: 52px;
  --sidebar-width: 248px;
  --sidebar-width-min: 200px;
  --sidebar-width-max: 420px;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text-strong);
  text-transform: none;
  font-size: var(--font-size-base);
  overflow: hidden;
}
html.text-size-compact {
  font-size: 15px;
}
html.text-size-large {
  font-size: 18px;
}
body.text-size-compact {
  --app-footer-h: 34px;
}
body.text-size-large {
  --app-footer-h: 44px;
}
body.app-booting .app-shell,
body.app-boot-settling .app-shell,
body.app-booting .app-left,
body.app-boot-settling .app-left,
body.app-booting .app-right,
body.app-boot-settling .app-right,
body.app-booting .app-footer,
body.app-boot-settling .app-footer,
body.app-booting .app-totals-strip,
body.app-boot-settling .app-totals-strip,
body.app-booting .fab-cluster,
body.app-boot-settling .fab-cluster,
body.app-booting .mcp-chat-widget,
body.app-boot-settling .mcp-chat-widget {
  transition: none !important;
}

/* Tomebound: app shell. Cascade order is declared in ../styles.css. */

/* A-shell border-frame layout */
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) var(--app-footer-h);
  grid-template-columns: var(--sidebar-width) 1fr 360px;
  grid-template-areas:
    'header header header'
    'left   main   right'
    'left   footer right';
  transition: grid-template-columns var(--motion-base) ease;
}
body.suppress-layout-transition .app-shell,
body.suppress-layout-transition .app-left {
  transition: none;
}
/* While dragging, track the pointer instantly instead of easing behind it. */
body.sidebar-resizing .app-shell,
body.sidebar-resizing .app-left {
  transition: none;
}

.app-header {
  grid-area: header;
  border-bottom: var(--border-width) solid var(--color-line);
  box-shadow: var(--shadow-lift);
  background: var(--color-surface-raised);
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 0 var(--space-5);
  gap: 18px;
}
.app-primary-nav.mobile-bottom-nav {
  align-items: center;
  backdrop-filter: none;
  background: transparent;
  border: 0;
  bottom: auto;
  box-shadow: none;
  display: flex;
  gap: 18px;
  left: auto;
  min-height: 0;
  padding: 0;
  position: static;
  right: auto;
  z-index: auto;
}
.app-primary-nav .mobile-bottom-nav-item {
  flex-direction: row;
  min-height: var(--vui-control-height-compact);
  min-width: 0;
}
.app-primary-nav .app-header-views {
  align-items: center;
  display: flex;
  gap: 4px;
}
.app-primary-nav .app-header-views .mobile-bottom-nav-item {
  background: transparent;
  border: 0;
  border-radius: var(--radius-tight);
  box-shadow: none;
  color: var(--color-text-muted);
  margin: 0;
  padding: 7px 9px;
  transition:
    background-color var(--motion-fast) ease,
    color var(--motion-fast) ease,
    transform var(--motion-snap) cubic-bezier(0.23, 1, 0.32, 1);
}
.app-primary-nav .mobile-bottom-nav-icon {
  height: 14px;
  width: 14px;
}
.app-primary-nav .mobile-bottom-nav-item.active,
.app-primary-nav .mobile-bottom-nav-item[aria-current='page'] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 700;
}
@media (hover: hover) and (pointer: fine) {
  .app-primary-nav .mobile-bottom-nav-item:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-strong);
  }
}
.mobile-filter-sheet-head,
.mobile-collection-toolbar,
.mobile-utility-trigger,
.mobile-history-action,
.mobile-about-action {
  display: none;
}
.fab-cluster > .mobile-utility-menu {
  display: flex;
  flex-direction: column;
}
.fab-cluster > .mobile-utility-menu > summary {
  display: none;
}
/* Narrow viewports keep the utility menu as a popover stack (responsive.css
   adds the trigger and the open/closed display rules). */
@media (max-width: 900px) {
  .fab-cluster > .mobile-utility-menu > .mobile-utility-menu-panel,
  .fab-cluster > .mobile-utility-menu:not([open]) > .mobile-utility-menu-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    padding: 0;
    border: var(--border-width) solid var(--color-line);
    border-radius: var(--radius-soft);
    background: var(--color-surface);
    box-shadow: var(--shadow-popover);
  }
  .fab-cluster > .mobile-utility-menu .mobile-utility-menu-item {
    min-height: var(--control-height-compact);
    border: 0;
    border-bottom: var(--border-width) solid var(--color-line);
    border-radius: 0;
    box-shadow: none;
  }
  .fab-cluster > .mobile-utility-menu .mobile-utility-menu-item:last-child {
    border-bottom: 0;
  }
}
/* Floating actions (Ellie #7, corner treatment, 2026-09-16): free pills in the
   bottom-right corner. ui/floatingActions.js sets data-fab-state on .fab-cluster
   (full on view load and scope switch, collapsed once the collection scrolls,
   full again on hover or focus) and --fab-width to the widest pill so all four
   match without padding. The class panel reset scores (0,4,1), outranking
   the book frame's class surfaces (0,3,1) without an id or a root theme
   attribute (light appearance removes it). The mobile-utility hooks remain
   responsible for the narrow-viewport menu. */
@media (min-width: 901px) {
  .fab-cluster > details.mobile-utility-menu > .fab-actions.mobile-utility-menu-panel,
  .fab-cluster > details.mobile-utility-menu:not([open]) > .fab-actions.mobile-utility-menu-panel {
    position: static;
    inset: auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    background-image: none;
    box-shadow: none;
  }
  .fab-cluster > details .fab-action {
    box-sizing: border-box;
    width: var(--fab-width, auto);
    height: 36px;
    min-height: 36px;
    padding: 0 9px;
    gap: 8px;
    overflow: hidden;
    border: var(--border-width) solid var(--color-line);
    border-radius: var(--radius-soft);
    background: var(--color-surface-raised);
    box-shadow: none;
    transform: none;
    /* Like the scroll control: rows show through until the cluster is in use. */
    opacity: 0.8;
    transition:
      width var(--motion-base) var(--vui-ease-out, ease-out),
      background-color var(--motion-fast) ease,
      border-color var(--motion-fast) ease,
      opacity var(--motion-fast) ease;
  }
  .fab-cluster:is(:hover, :focus-within) .fab-action {
    opacity: 1;
  }
  .fab-cluster .fab-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
  }
  .fab-cluster :is(.fab-label, .fab-shortcut) {
    transition: opacity var(--motion-base) var(--vui-ease-out, ease-out);
  }
  .fab-cluster[data-fab-state='collapsed']:not([data-fab-measuring]) .fab-action {
    width: 36px;
    gap: 0;
  }
  .fab-cluster[data-fab-state='collapsed']:not([data-fab-measuring])
    :is(.fab-label, .fab-shortcut) {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
  }
  /* ui/floatingActions.js reads natural widths under this attribute. */
  .fab-cluster[data-fab-measuring] .fab-action,
  .fab-cluster[data-fab-measuring] :is(.fab-label, .fab-shortcut) {
    transition: none;
  }
}
/* Each pill hovers on its own. Mix ink into its own surface so the tint also
   survives legacy themes where the shared hover and rest fills coincide. */
@media (hover: hover) and (pointer: fine) {
  .fab-cluster .fab-actions .fab-action:hover {
    background: color-mix(in srgb, var(--color-text-strong) 9%, var(--color-surface-raised));
    border-color: var(--color-text-muted);
    color: var(--color-text-strong);
  }
}
@media (prefers-reduced-motion: reduce) {
  .fab-cluster .fab-action,
  .fab-cluster :is(.fab-label, .fab-shortcut) {
    transition: none;
  }
}
/* Multi-key hints such as "ctrl k" stay on one line. */
.fab-cluster .fab-shortcut {
  flex: none;
  white-space: nowrap;
}
.fab-cluster .fab-actions .fab-action > .fab-glyph {
  align-items: center;
  display: inline-flex;
  flex: 0 0 16px;
  justify-content: center;
  width: 16px;
}
.fab-glyph-svg svg {
  display: block;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}
.app-header h1 {
  font-size: var(--font-size-heading);
  font-weight: 400;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.app-title-row {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  min-width: 0;
}
/* The "Tomebound" wordmark — an intentional named component, not a control.
   It is a <button> only so clicking the title resets the view. Deliberately
   bespoke (inherits the title's font/letter-spacing/color); do not fold into
   the .btn family. */
.title-reset-btn {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: none;
  cursor: pointer;
  letter-spacing: inherit;
}
.title-reset-btn:hover {
  color: var(--color-neutral-600);
}
.title-reset-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
/* Collapsed rail condenses the wordmark to its first letter. Still click-to-home
   — expanding lives on the toggle at the rail's bottom, not here. */
.btn-shortcut {
  color: currentColor;
  /* Keep shortcut hints beside their labels so shared buttons remain compact. */
  display: inline-grid;
  flex: 0 0 auto;
  font-size: 0.68em;
  margin-left: 0;
  opacity: 0.72;
  white-space: nowrap;
}
.quick-jump-panel {
  background: var(--surface-veil-warm);
  inset: 0;
  padding-top: 76px;
  position: fixed;
  z-index: 120;
}
.quick-jump-shell {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-text-strong);
  box-shadow: var(--shadow-overlay);
  margin: 0 auto;
  max-width: calc(100vw - 28px);
  padding: 10px;
  width: min(560px, calc(100vw - 28px));
}
.quick-jump-input {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-square);
  color: var(--color-text-strong);
  font: inherit;
  min-height: 34px;
  padding: 7px 9px 7px 12px;
  text-transform: none;
  width: 100%;
}
.quick-jump-input:focus {
  border-color: var(--color-text-strong);
  outline: none;
}
.quick-jump-results {
  display: grid;
  gap: 1px;
  margin-top: 8px;
  overflow: visible;
}
.quick-jump-result,
a.quick-jump-result {
  align-items: baseline;
  background: transparent;
  border: none;
  border-bottom: var(--border-width) solid var(--color-line);
  color: var(--color-text-strong);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 2px 10px;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  padding: 8px 6px;
  text-align: left;
  text-decoration: none;
  text-transform: none;
}
/* BEN-992: shortcut hint for the utility actions (help/feedback/chat) that
   have a real single-key global shortcut — auto-placed into the row's third
   column, empty for every other result (cards, containers, command verbs
   with no dedicated key). */
.quick-jump-result .btn-shortcut {
  align-self: center;
}
.quick-jump-result:hover,
.quick-jump-result.active,
a.quick-jump-result:hover,
a.quick-jump-result.active {
  background: var(--color-surface-sunken);
}
.quick-jump-result-kind {
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.04em;
}
.quick-jump-result-label {
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-jump-result-meta {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  grid-column: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-jump-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  padding: 12px 6px 4px;
}
/* BEN-406: the top-view tabs consume the shared .segmented / .segment-btn
   component (container carries `segmented`, buttons carry `segment-btn`).
   Only layout lives here — frame, vellum segments, and green active state all
   come from the shared component. */
.app-header-views {
  justify-self: end;
}
.app-header-views .toggle-view {
  gap: 5px;
}
.app-header-views .view-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  line-height: 1;
}

.sync-account-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  justify-self: end;
  min-width: 84px;
}
.desktop-sidebar-shell .sidebar-account-slot {
  min-width: 0;
  position: relative;
}
.desktop-sidebar-shell .sidebar-account-slot .sync-account-slot,
.desktop-sidebar-shell .sidebar-account-slot .sync-chip {
  width: 100%;
}
.desktop-sidebar-shell .sidebar-account-slot .sync-chip {
  justify-content: flex-start;
}
.desktop-sidebar-shell .sidebar-account-slot .sync-menu {
  left: calc(100% + 8px);
  right: auto;
  /* Anchored to the sidebar's bottom, so the menu opens upward.
     positionSyncMenu() overrides these with fixed coordinates once measured. */
  bottom: 0;
  top: auto;
}
/* The sidebar's bottom rail: account chip + collapse toggle. Sticky so it stays
   reachable while the nav above it scrolls. */
.sidebar-footer {
  align-items: center;
  background: var(--color-surface-sunken);
  border-top: var(--border-width) solid var(--color-line);
  bottom: -16px;
  display: flex;
  gap: 6px;
  margin: auto -14px -16px;
  padding: 10px 14px 16px;
  position: sticky;
  z-index: 7;
}
.sidebar-footer .sidebar-account-slot {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}
/* The account row is a person, not a control: icon + name in plain text,
   with the button chrome appearing only on hover (it opens the menu). */
.sidebar-footer .sync-chip {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.sidebar-footer .sync-chip:hover,
.sidebar-footer .sync-chip:focus-visible,
.sidebar-footer .sync-chip[aria-expanded='true'] {
  background: var(--color-surface-hover);
  border-color: transparent;
}
/* Quiet toggle: no chrome until hover — the glyph is the affordance, the
   button shouldn't read as a control inset into the panel. */
.sidebar-footer .sidebar-toggle {
  background: transparent;
  border-color: transparent;
  border-radius: var(--radius-sharp);
  color: var(--color-text-muted);
  flex: 0 0 auto;
}
.sidebar-footer .sidebar-toggle:hover,
.sidebar-footer .sidebar-toggle:focus-visible {
  background: var(--color-surface-hover);
  border-color: transparent;
  color: var(--color-text-strong);
}
/* One button, two glyphs — which arrow shows follows the collapsed state. */
.sidebar-toggle .sidebar-toggle-expand-glyph,
body.left-sidebar-collapsed .sidebar-toggle .sidebar-toggle-collapse-glyph {
  display: none;
}
body.left-sidebar-collapsed .sidebar-toggle .sidebar-toggle-expand-glyph {
  display: inline;
}
.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* BEN-473: match the segmented control (same line-height + vertical
     padding + border recipe) so the chip lines up with the top-nav tabs. */
  padding: 7px 10px;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-bg);
  color: var(--color-text-strong);
  font-family: inherit;
  font-size: var(--font-size-sm);
  text-transform: none;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  line-height: 1;
}
.sync-chip:hover {
  background: var(--color-surface-hover);
}
/* Signed out, the chip is the one obvious next step: the primary-button
   recipe at chip size, one click into Clerk. */
.sync-chip-cta {
  padding: 9px 12px;
  min-height: 36px;
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
  font-weight: 600;
}
.sync-chip-cta:hover,
.sync-chip-cta:focus-visible {
  background: var(--color-btn-primary-hover);
  border-color: var(--color-btn-primary-hover);
}
.sync-chip-cta .sync-dot {
  color: inherit;
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex: 0 0 auto;
}
.sync-chip-synced .sync-dot {
  color: var(--color-text);
  background: var(--color-text);
}
.sync-chip-syncing .sync-dot,
.sync-chip-signing-in .sync-dot {
  color: var(--color-provenance-text);
  background: var(--color-provenance-text);
}
.sync-chip-queued .sync-dot {
  color: var(--color-provenance-text);
  background: var(--color-provenance-text);
}
.sync-chip-error .sync-dot {
  color: var(--color-danger);
  background: var(--color-danger);
}
/* BEN-987: offline/sync-delayed (will resolve itself once you reconnect) vs
   rejected (the change itself couldn't be saved, needs your attention) used
   to look identical — both just "sync error", red dot. `kind-offline` tints
   the dot back to provenance cobalt, shared with syncing/queued states;
   `kind-rejected` is the default danger red above, kept explicit here so the
   two are never accidentally reunified. */
.sync-chip-kind-offline .sync-dot {
  color: var(--color-provenance-text);
  background: var(--color-provenance-text);
}
.sync-chip-kind-rejected .sync-dot {
  color: var(--color-danger);
  background: var(--color-danger);
}
.sync-chip-account .sync-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-square);
  background: transparent;
  display: grid;
  place-items: center;
}
.sync-chip-account.sync-chip-synced .sync-dot,
.sync-chip:is(:hover, :focus-visible, [aria-expanded='true']) .sync-dot {
  color: inherit;
}
/* BEN-732: quiet chip-level stand-in for the old demo banner — a signed-out
   ephemeral demo (try demo / welcome tour) gets a dot color nod, not a band. */
.sync-chip-demo .sync-dot {
  background: var(--color-warn);
}
.sync-dot svg {
  display: block;
  height: 14px;
  width: 14px;
}
.sync-chip:not(.sync-chip-account) .sync-dot {
  background: transparent;
  border-radius: var(--radius-square);
  display: grid;
  height: 14px;
  place-items: center;
  width: 14px;
}
.sync-chip-demo:not(.sync-chip-account) .sync-dot {
  background: transparent;
  color: var(--color-warn);
}
.sync-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  width: 210px;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  padding: 8px 0;
}
.sync-menu-meta {
  display: grid;
  gap: 2px;
  padding: 2px 12px 8px;
  border-bottom: var(--border-width) solid var(--color-line);
  margin-bottom: 6px;
  font-size: var(--font-size-sm);
}
.sync-menu-meta span {
  color: var(--color-text-muted);
}
.sync-menu-session-actions:not(:empty) {
  border-top: var(--border-width) solid var(--color-line);
  margin-top: 8px;
  padding-top: 6px;
}
.sync-menu button {
  align-items: center;
  display: flex;
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  line-height: var(--line-height-body);
  min-height: 32px;
  padding: 6px 12px;
  text-align: left;
  font: inherit;
  font-size: var(--font-size-sm);
  /* BEN-570: explicit ink — the UA's default button color read as disabled
     grey on the dark surface while the settings item stayed white. */
  color: var(--color-text-strong);
  text-transform: none;
  cursor: pointer;
}
.sync-menu button:hover,
.sync-menu button:focus-visible {
  background: var(--color-surface-hover);
}
.sync-menu button:focus-visible {
  outline: 2px solid var(--color-line-focus);
  outline-offset: -2px;
}

/* BEN-610: the export modal rides the shared .ui-modal chrome; only content
   layout lives here. */
.export-modal-card {
  width: min(360px, calc(100vw - 32px));
}
.export-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.export-choice-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.export-choice-label {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  text-transform: none;
  letter-spacing: var(--label-tracking);
  color: var(--color-text-muted);
}
.export-choice-select {
  min-width: 0;
}

/* BEN-988: scope picker — always visible, never implicit, so a stale filter
   can't quietly ship a partial file as if it were a full backup. */
.export-scope-field {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.export-scope-field legend {
  padding: 0;
}
.export-scope-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.export-scope-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
}
.export-scope-option.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.export-scope-option-label {
  flex: 1;
  font-size: var(--font-size-sm-plus);
}
.export-scope-option-count {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

/* BEN-448: the "how sync works" explainer now uses the shared modal chrome
   (.ui-modal / .ui-modal-card / .ui-modal-head / .ui-modal-body / .rune-close).
   Only the explainer's content layout is styled here. */
.sync-details-modal-card {
  width: min(440px, calc(100vw - 24px));
}
.sync-details-modal-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}
.sync-details-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.sync-details-modal-body p {
  color: var(--color-btn-primary-hover);
  font-size: var(--font-size-sm-plus);
  line-height: 1.42;
  margin: 0;
}
.sync-details-intro {
  color: var(--color-text);
  font-size: var(--font-size-md);
}
.sync-details-section {
  border-top: var(--border-width) solid var(--color-line);
  padding-top: 10px;
}
.sync-details-section h3 {
  font-size: var(--font-size-xs);
  font-weight: 600;
  margin: 0 0 4px;
  text-transform: none;
}
.sync-details-list {
  color: var(--color-btn-primary-hover);
  display: grid;
  font-size: var(--font-size-sm);
  gap: 5px;
  line-height: 1.35;
  list-style: none;
  margin: 0;
  padding: 0;
}
.sync-details-list li {
  padding-left: 12px;
  position: relative;
}
.sync-details-list li::before {
  content: '';
  background: var(--color-bullet-warm);
  height: 3px;
  left: 0;
  position: absolute;
  top: 0.58em;
  width: 3px;
}
.sync-details-faq {
  display: grid;
  gap: 9px;
}
.sync-details-modal-body strong {
  color: var(--color-text);
  font-weight: 600;
}

/* Personal access tokens manager — reuses the shared modal chrome
   (.ui-modal / .ui-modal-card / .ui-modal-head / .ui-modal-body). Only the
   token list + create form layout is styled here. */
.pat-modal-card {
  width: min(480px, calc(100vw - 24px));
}
.pat-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pat-modal-intro {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.42;
  margin: 0;
}
.pat-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pat-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: var(--label-tracking);
  margin: 0;
  text-transform: none;
}
.pat-reveal {
  border: var(--border-width) solid var(--color-text-muted);
  background: var(--color-surface-alt, var(--color-surface));
  gap: 6px;
  padding: 10px;
}
.pat-reveal-note {
  color: var(--color-text);
  font-size: var(--font-size-sm);
  margin: 0;
}
.pat-reveal-row {
  align-items: center;
  display: flex;
  gap: 8px;
}
.pat-reveal-token {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.pat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pat-list-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin: 0;
}
.pat-row {
  align-items: center;
  border: var(--border-width) solid var(--color-line);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 10px;
}
.pat-row-revoked {
  opacity: 0.6;
}
.pat-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pat-row-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.pat-row-state {
  color: var(--color-text-muted);
  font-weight: 400;
}
.pat-row-meta {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}
.pat-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pat-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pat-field-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  letter-spacing: var(--label-tracking);
  text-transform: none;
}
.pat-field-input {
  border: var(--border-width) solid var(--color-text-muted);
  background: var(--color-surface);
  font: inherit;
  min-width: 0;
  padding: 8px;
}
.pat-create-actions {
  display: flex;
  justify-content: flex-end;
}

.app-left {
  grid-area: left;
  position: relative;
  border-right: var(--border-width) solid var(--color-line);
  box-shadow: var(--shadow-panel-right);
  padding: 16px 14px;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width-min);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--color-surface-sunken);
  opacity: 1;
  transform: translateX(0);
  transition:
    transform var(--motion-base) ease,
    opacity var(--motion-fast) ease,
    box-shadow var(--motion-base) ease,
    --scrollbar-visible-thumb 160ms ease-out;
  will-change: transform;
}
.sidebar-toggle svg {
  height: 16px;
  width: 16px;
}
/* Drag handle pinned to the sidebar's right edge (vellum .vui-resize-divider
   provides position/cursor/hairline). Sits inside the scroll container but
   stays put because the sidebar doesn't scroll wider than itself.
   BEN-565: 16px hit area (the sidebar clips overflow, so it widens inward) —
   near-miss presses land on the handle, whose pointerdown preventDefault stops
   page text selection. The hairline stays pinned to the panel edge. */
.sidebar-resize-handle {
  right: 0;
  width: 16px;
}
.sidebar-resize-handle::after {
  margin-right: 0;
}
.sidebar-resize-handle .sidebar-strip-grip {
  display: none;
}
/* Hovering or dragging the handle highlights the whole panel edge in accent. */
body:has(.sidebar-resize-handle:hover) .app-left,
body.sidebar-resizing .app-left {
  border-right-color: var(--color-line-focus);
}
/* Collapsed: the handle becomes the visible strip — full collapsed width,
   clickable above the pointer-events-none sidebar, drag-or-click to reopen.
   The grip dots are the "drag me back open" affordance. */
body.left-sidebar-collapsed .sidebar-resize-handle {
  cursor: e-resize;
  display: grid;
  pointer-events: auto;
  place-items: center;
  right: 0;
  width: var(--sidebar-collapsed-w);
  transition: background var(--motion-fast) ease;
}
/* BEN-565: hover invitation on the collapsed strip — a subtle accent tint
   (the grip dots light via vellum's divider hover rule). */
body.left-sidebar-collapsed .sidebar-resize-handle:hover,
body.left-sidebar-collapsed .sidebar-resize-handle:focus-visible {
  background: var(--color-accent-soft);
}
body.left-sidebar-collapsed .sidebar-resize-handle::after {
  display: none;
}
body.left-sidebar-collapsed .sidebar-resize-handle .sidebar-strip-grip {
  display: inline-block;
  height: 28px;
}
body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}
.sidebar-label {
  font-size: var(--font-size-xs);
  letter-spacing: 0.06em;
  color: var(--color-accent); /* BEN-420: purple section labels */
  margin-bottom: 6px;
  text-transform: none;
}
.sidebar-section .search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  max-width: none;
  width: 100%;
}
.sidebar-section .search-wrap .search-input {
  width: 100%;
  flex: 1;
  background: var(--color-surface-raised);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  padding: 6px var(--search-trailing-space) 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-text-strong);
  outline: none;
  text-transform: none;
  box-shadow: var(--input-bevel);
  max-width: none;
  min-width: 0;
}
.sidebar-section .search-wrap .search-input:focus {
  border-color: var(--color-line-focus);
}
/* BEN-416: search-syntax help is an underlined quiet link below the field;
   hovering it reveals the syntax popover (deltas live with the BEN-613
   quiet-link family). */
.sidebar-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
@media (max-width: 900px) {
  .sidebar-filters .collection-filter-group {
    grid-template-columns: minmax(0, 1fr);
  }
}
.advanced-filter-field {
  color: var(--color-text-muted);
  display: grid;
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  gap: 4px;
  letter-spacing: 0.05em;
  min-width: 0;
  text-transform: none;
}
.advanced-filter-field input,
.advanced-filter-field select {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sharp);
  box-shadow: var(--input-bevel);
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-sm);
  letter-spacing: normal;
  min-height: 32px;
  min-width: 0;
  padding: 6px 8px;
  text-transform: none;
  width: 100%;
}
.advanced-filter-number-controls {
  display: grid;
  gap: 5px;
  grid-template-columns: minmax(92px, 1.25fr) minmax(54px, 0.75fr) minmax(54px, 0.75fr);
}
.advanced-filter-number-controls > [hidden] {
  display: none;
}
.advanced-filter-number-controls:has(> [data-range-maximum][hidden]) {
  grid-template-columns: minmax(92px, 1.25fr) minmax(64px, 1fr);
}

/* BEN-959 review preview: three honest toolbar organizations share the live
   search/filter/view controls. The floating preview switcher is intentionally
   outside the proposed UI; it lets the reviewer compare alternatives at the
   same browser width. Below 901px the nodes return to the mobile sheet. */
.collection-controls-toolbar {
  background: color-mix(in srgb, var(--color-surface) 82%, var(--color-surface-raised));
  border-bottom: 1px solid var(--color-line-faint);
  box-shadow: none;
  display: none;
  min-width: 0;
  position: relative;
  z-index: 18;
}
body.view-list .collection-controls-toolbar.is-active:not([hidden]) {
  display: grid;
}
.collection-controls-toolbar > .sidebar-section {
  border: 0;
  margin: 0;
  min-width: 0;
}
.collection-controls-toolbar .sidebar-label {
  display: none;
}
.collection-toolbar-search {
  align-items: center;
  display: flex;
  gap: 7px;
}
.collection-toolbar-search .search-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.collection-toolbar-search .search-input {
  min-height: 32px;
  width: 100%;
}
.collection-toolbar-search .search-syntax-link {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px;
  white-space: nowrap;
}
.collection-toolbar-search .search-help-popover {
  position: relative;
}
.collection-controls-toolbar > .collection-toolbar-filter-trigger {
  align-items: center;
  display: none;
  gap: 6px;
  min-height: 32px;
  padding-inline: 10px;
  white-space: nowrap;
}
.collection-toolbar-filter-trigger svg {
  height: 14px;
  width: 14px;
}
.collection-toolbar-filters .sidebar-filters {
  align-items: center;
  flex-direction: row;
  gap: 7px;
  min-width: 0;
  overflow-x: auto;
}
.collection-toolbar-filters .sidebar-filters > div:not([hidden]) {
  flex: 1 0 116px;
  max-width: 154px;
  min-width: 104px;
}
.collection-toolbar-filters .sidebar-filters .deck-sidebar-filter.hidden {
  display: none;
}
.collection-toolbar-filters .sidebar-filters .clear-filters-btn {
  flex: 0 0 auto;
  font-size: var(--font-size-xxs);
  margin: 0;
  min-height: 30px;
  padding-inline: 8px;
  width: auto;
}
.collection-controls-toolbar .clear-filters-label-long {
  display: none;
}
.collection-controls-toolbar .clear-filters-label-short {
  display: inline;
}
.collection-controls-toolbar > .sidebar-view-settings {
  align-items: center;
  display: flex;
  gap: 8px;
  width: auto;
}
.collection-controls-toolbar .collection-display-controls {
  flex: 0 0 154px;
  min-width: 0;
}
.collection-controls-toolbar .collection-display-mode.segmented {
  width: 100%;
}
.collection-controls-toolbar .collection-display-controls .segment-btn {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  justify-content: center;
}
.collection-controls-toolbar .collection-display-controls .view-icon-svg {
  flex: 0 0 auto;
  height: 14px;
  width: 14px;
}
.collection-controls-toolbar .collection-column-settings-panel {
  flex: 0 1 auto;
  margin: 0;
  min-width: 136px;
  width: auto;
}
.collection-controls-toolbar .collection-column-settings-dropdown .ms-trigger {
  min-height: 32px;
}
.collection-controls-toolbar > .sidebar-view-settings.is-visual-mode .collection-visual-settings {
  align-items: center;
  flex-direction: row;
  gap: 8px;
}
.collection-controls-toolbar
  > .sidebar-view-settings.is-visual-mode
  .collection-column-settings-dropdown {
  flex: 1 1 136px;
  min-width: 132px;
}
.collection-controls-toolbar
  > .sidebar-view-settings.is-visual-mode
  .collection-price-style-control {
  flex: 0 0 auto;
  gap: 6px;
  grid-template-columns: auto auto;
}
.collection-controls-toolbar
  > .sidebar-view-settings.is-visual-mode
  .collection-price-style-segments
  .segment-btn {
  padding-inline: 7px;
}

/* A — Asana-like search-led command bar. Filters open in one predictable
   panel; search, view, visible fields, and price presentation stay persistent. */
.toolbar-variant--search-led {
  align-items: center;
  gap: 8px;
  grid-template-columns: minmax(210px, 1fr) auto auto;
  padding: 8px 12px;
}
.toolbar-variant--search-led > .collection-toolbar-filter-trigger {
  display: inline-flex;
}
.toolbar-variant--search-led .collection-toolbar-search {
  padding: 0;
}
.toolbar-variant--search-led .collection-toolbar-filters {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  box-shadow: var(--shadow-menu);
  display: none;
  left: 12px;
  padding: 12px;
  position: absolute;
  top: calc(100% + 6px);
  width: min(760px, calc(100% - 24px));
  z-index: 30;
}
.toolbar-variant--search-led.filters-open .collection-toolbar-filters {
  display: block;
}
.toolbar-variant--search-led > .sidebar-view-settings {
  justify-self: end;
}

/* B — two-tier workbench. Primary navigation stays calm on row one while the
   concrete filters get a dedicated, horizontally scrollable row beneath it. */
.toolbar-variant--two-tier {
  grid-template-areas:
    'search view'
    'filters filters';
  grid-template-columns: minmax(250px, 1fr) auto;
}
.toolbar-variant--two-tier .collection-toolbar-search {
  grid-area: search;
  padding: 8px 12px;
}
.toolbar-variant--two-tier .collection-toolbar-filters {
  border-top: 1px solid var(--color-line-faint);
  grid-area: filters;
  padding: 8px 12px 9px;
}
.toolbar-variant--two-tier > .sidebar-view-settings {
  border-left: 1px solid var(--color-line-faint);
  grid-area: view;
  padding: 8px 12px;
}

/* C — adaptive rail. Wide screens expose everything in one sweep; laptop
   widths collapse only the filter row into a summary button and popover. */
.toolbar-variant--adaptive {
  align-items: center;
  gap: 8px;
  grid-template-columns: minmax(190px, 0.7fr) minmax(430px, 1.3fr) auto;
  padding: 8px 12px;
}
.toolbar-variant--adaptive .collection-toolbar-search,
.toolbar-variant--adaptive .collection-toolbar-filters {
  padding: 0;
}
.toolbar-variant--adaptive > .sidebar-view-settings {
  justify-self: end;
}

.collection-toolbar-preview-switcher {
  align-items: center;
  background: color-mix(in srgb, var(--color-surface-raised) 94%, transparent);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  bottom: 14px;
  box-shadow: var(--shadow-menu);
  display: flex;
  gap: 8px;
  left: 50%;
  padding: 6px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 120;
}
.collection-toolbar-preview-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  padding-inline: 4px;
  white-space: nowrap;
}
.collection-toolbar-preview-switcher .segment-btn {
  min-height: 28px;
  padding-inline: 9px;
}

@media (max-width: 1320px) and (min-width: 901px) {
  .toolbar-variant--adaptive {
    grid-template-columns: minmax(210px, 1fr) auto auto;
  }
  .toolbar-variant--adaptive > .collection-toolbar-filter-trigger {
    display: inline-flex;
  }
  .toolbar-variant--adaptive .collection-toolbar-filters {
    background: var(--color-bg);
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-soft);
    box-shadow: var(--shadow-menu);
    display: none;
    left: 12px;
    padding: 12px;
    position: absolute;
    top: calc(100% + 6px);
    width: min(760px, calc(100% - 24px));
    z-index: 30;
  }
  .toolbar-variant--adaptive.filters-open .collection-toolbar-filters {
    display: block;
  }
}
@media (max-width: 1080px) and (min-width: 901px) {
  .toolbar-variant--search-led,
  .toolbar-variant--adaptive {
    grid-template-columns: minmax(180px, 1fr) auto auto;
  }
  .collection-controls-toolbar .search-syntax-link {
    display: none;
  }
  .collection-controls-toolbar > .sidebar-view-settings {
    gap: 6px;
  }
  .collection-controls-toolbar .collection-display-controls {
    flex-basis: 140px;
  }
  .collection-controls-toolbar > .sidebar-view-settings.is-visual-mode .collection-visual-settings {
    gap: 5px;
  }
}
@media (max-width: 900px) {
  .collection-toolbar-preview-switcher {
    display: none;
  }
}
/* BEN-757: the scope selector is flat sidebar nav (Linear/Asana pattern), not
   bordered input-looking boxes — no border, no field background, no bevel. Rows
   read categorically differently from the search/filter inputs around them.
   Hover = quiet wash; selected = subtle filled bg + stronger weight. */
.scope-selector {
  display: flex;
  flex-direction: column;
}
.scope-option-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.scope-option-group + .scope-option-group {
  border-top: 1px solid var(--color-line-faint);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
}
.scope-option-group-heading {
  /* Width the chevron toggle occupies — the flat "collection" heading pads by
     this much so all three top-level labels line up. */
  --scope-group-chevron-w: calc(var(--space-2) * 2 + 5px + 6px);
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 26px;
}
.scope-option-group-toggle,
.scope-option-group-add {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.06em;
  padding: 3px var(--space-2);
  text-transform: none;
}
.scope-option-group-toggle {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}
.scope-option-group-add {
  opacity: 0.72;
}
.scope-option-group-toggle:hover,
.scope-option-group-toggle:focus-visible,
.scope-option-group-add:hover,
.scope-option-group-add:focus-visible {
  color: var(--color-text-strong);
}
.scope-option-group-chevron {
  display: inline-block;
  font-size: 15px;
  transform: rotate(90deg);
  transition: transform var(--motion-fast) ease;
}
.scope-option-group-toggle[aria-expanded='false'] .scope-option-group-chevron {
  transform: rotate(0);
}
.scope-option-group-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.scope-option-group-body[hidden] {
  display: none;
}
.scope-option {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding: 4px var(--space-2);
  border: 0;
  border-radius: var(--radius-soft);
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.35;
  text-align: left;
  text-transform: none;
  cursor: pointer;
}
.scope-option:hover {
  background: var(--color-surface-hover);
}
/* M-11 sizing for .scope-option and its group +/... controls lives in
   control-surfaces.css: that file's `html:root #scopeSelector ...` rules are
   the ID-specific control-surface normalization that actually wins the
   cascade for these selectors (it overrides plain-class rules here). */
.scope-option:focus-visible {
  outline: var(--focus-ring);
  outline-offset: calc(-1 * var(--focus-ring-offset));
}
.scope-option.is-selected {
  background: var(--color-accent-soft);
  color: var(--color-text-strong);
  font-weight: 700;
}
.scope-option-icon {
  flex: 0 0 auto;
  font-size: var(--font-size-md);
  line-height: 1;
}
.scope-option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* "collection" is a destination with no children, so its heading has no
   chevron. Sit it flush left (its icon lines up with the group chevrons)
   rather than indenting it to the group labels — an indent with nothing to
   its left reads as floating. */
/* The trailing "unfiled · N" row: present but visibly secondary to real
   containers, because it is a filter state rather than a place. */
.scope-option-muted {
  color: var(--color-text-muted);
}
.scope-option-count {
  color: var(--color-text-muted);
  flex: 0 0 auto;
  font-size: var(--font-size-xxs);
  margin-left: auto;
  padding-left: 8px;
}
.scope-option-count::before {
  content: '· ';
}
/* BEN-1005: sidebar drop target while a card-row drag is over it -- flat
   wash + dashed outline, same idiom as the column-header drag highlight
   (box-shadow inset) but on a plain nav row. */
.scope-option-drop-target {
  background: var(--color-accent-soft);
  outline: var(--border-width) dashed var(--color-accent);
  outline-offset: -1px;
}
.sidebar-filters select {
  background-color: var(--color-surface-raised);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  /* BEN-467: extra right padding + arrow inset so the chevron clears the border. */
  padding: 6px 30px 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-text-strong);
  width: 100%;
  outline: none;
  text-transform: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: var(--input-bevel);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%2315100d' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  min-width: 0;
}
.sidebar-filters select:hover {
  border-color: var(--color-line-focus);
}
.sidebar-view-settings {
  display: none;
}
body.view-list .sidebar-view-settings {
  display: grid;
  gap: 6px;
}

.app-center {
  /* Only the shell, sidebar and book header consume this dimension. Stop it
     inheriting through thousands of table cells on every pointer movement. */
  --sidebar-width: initial;
  grid-area: main;
  background: var(--color-surface-raised);
  overflow-y: auto;
  padding: 18px 20px;
  min-width: 0;
  --app-center-pad-top: 18px;
}
body.view-list .app-center {
  padding: 0;
  --app-center-pad-top: 0px;
}
/* Keep the moving collection on its own paint layer for the gesture. The
   table still lays out at the live width; release drops the temporary layer. */
body.sidebar-resizing.view-list .app-center {
  will-change: transform;
}
/* The wide collection table used to scroll .app-center itself, dragging the
   identity strip and the filter toolbar sideways with it. Give the scrollport
   to #listView instead. A horizontal scroller is always a vertical one too
   (overflow-x: auto forces overflow-y off visible), so #listView has to be
   height-bounded — otherwise `thead th { position: sticky; top: 0 }` re-anchors
   to a scrollport that never scrolls and the header stops sticking. Narrow
   layouts use the same bounded list scrollport in responsive.css, keeping the
   footer visible while the rows scroll. */
@media (min-width: 901px) {
  body.view-list .app-center {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  body.view-list #collectionSection {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }
  body.view-list #collectionSection.hidden {
    display: none;
  }
  body.view-list .list-view.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }
}
/* Shared/read-only pages use the same edge-to-edge frame as the main
   collection. Individual toolbar and table controls own their breathing room. */
body.share-mode.view-list .app-center,
body.share-mode.view-grid .app-center {
  padding-left: 0;
  padding-right: 0;
}
@media (min-width: 901px) {
  /* A closed sidebar leaves no permanent rail. The page owns the full width,
     while hovering the header affordance reveals the complete sidebar as a
     temporary overlay below the sticky page header. */
  body.left-sidebar-collapsed .app-left {
    border-radius: 0 var(--radius-round) var(--radius-round) 0;
    bottom: 8px;
    box-shadow: var(--shadow-overlay);
    height: auto;
    left: 0;
    min-width: var(--sidebar-width-min);
    opacity: 0;
    padding: 10px 16px 16px;
    pointer-events: none;
    position: fixed;
    top: 52px;
    transform: translateX(calc(-100% - 18px));
    transition: none;
    width: var(--sidebar-width);
    z-index: 70;
  }
  body.left-sidebar-collapsed.left-sidebar-peeking .app-left {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }
  body.left-sidebar-collapsed .sidebar-resize-handle {
    display: none;
  }
  body.left-sidebar-collapsed .app-shell {
    grid-template-columns: 0 minmax(0, 1fr) 360px;
  }
  body.left-sidebar-collapsed.view-list .app-shell,
  body.left-sidebar-collapsed.view-grid .app-shell,
  body.left-sidebar-collapsed.view-locations .app-shell,
  body.left-sidebar-collapsed.view-deck .app-shell {
    grid-template-columns: 0 minmax(0, 1fr) 0;
  }
}
.app-totals-strip {
  flex: 1 1 auto;
  min-width: 0;
  position: static;
  z-index: auto;
  display: flex;
  align-items: center;
  /* Counts anchor the bar's left edge; the history ticker + about link own
     the right. */
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 36px;
  margin: 0;
  padding: 7px 20px 6px;
  border-bottom: var(--border-width) solid var(--color-line);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.3;
}
body.view-list .app-totals-strip {
  margin: 0;
  padding: 8px 20px;
  box-shadow: var(--shadow-strip-top);
}
.app-totals-strip strong {
  color: var(--color-text-strong);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.app-totals-strip .sep {
  color: var(--color-line-strong);
  margin-inline-end: 5px;
  display: none;
}
.app-totals-strip .total-part:not([hidden], .hidden) ~ .total-part:not([hidden], .hidden) .sep {
  display: inline;
}
.app-totals-strip .total-part {
  align-items: baseline;
  display: inline-flex;
  gap: 3px;
  white-space: nowrap;
}
.app-totals-strip .total-part[hidden] {
  display: none;
}
.app-totals-strip .total-part strong {
  display: inline-block;
  /* Reserve the common one-to-two-digit edit without blank space between a
     separator and its number. Every separator travels with the next part. */
  min-width: 2ch;
  text-align: left;
}
/* BEN-534: small muted "prices as of <date>" note next to the collection value. */
.app-totals-strip .total-part-asof {
  color: var(--color-text-muted);
  font-size: 0.85em;
  font-style: italic;
}
/* History ticker — the right end of the status bar. Sits beside the totals
   strip rather than inside it because setTotalsStrip() rewrites that node's
   innerHTML wholesale; matching background/padding keeps the bar reading as one
   continuous surface. */
.app-history-ticker {
  align-items: center;
  background: var(--color-surface-raised);
  border-bottom: var(--border-width) solid var(--color-line);
  color: var(--color-text-muted);
  display: flex;
  flex: 0 1 auto;
  font-size: var(--font-size-xs);
  gap: 6px;
  line-height: 1.3;
  min-width: 0;
  padding: 7px 20px 6px 0;
}
.app-history-ticker[hidden] {
  display: none;
}
.app-footer #appTotalsStrip {
  flex: 0 1 auto;
  padding-inline-end: 0;
}
.app-footer .app-history-ticker {
  margin-inline-start: auto;
}
.app-footer:has(.app-history-ticker:not([hidden])) .app-about-link {
  margin-inline-start: 0;
}
.app-history-ticker .ticker-label {
  color: var(--color-neutral-350);
  flex: 0 0 auto;
}
/* One flat line: the summary is exactly one line tall, and its inline chips
   are top-aligned boxes no taller than that line, so an icon never lifts the
   text or changes the footer height. */
.app-history-ticker .ticker-summary {
  height: 1.3em;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-history-ticker .ticker-summary.is-undone {
  text-decoration: line-through;
  color: var(--color-passive-text);
}
.app-history-ticker {
  position: relative;
}
.history-ticker-entity {
  color: var(--color-text-strong);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.history-ticker-entity:focus-visible {
  border-radius: var(--radius-tight);
  outline: var(--focus-ring);
  outline-offset: 1px;
}
.history-entity-ref {
  align-items: center;
  box-sizing: border-box;
  display: inline-flex;
  gap: 4px;
  max-width: none;
  min-width: 0;
  vertical-align: baseline;
}
.history-entity-ref-icon {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  font-family: 'Noto Color Emoji', sans-serif;
  font-size: 12px;
  height: 14px !important;
  justify-content: center;
  line-height: 1;
  max-height: 14px !important;
  max-width: 14px !important;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transform: none !important;
  width: 14px !important;
}
.history-entity-ref-icon:is(svg, img),
.history-entity-ref-icon svg,
.history-entity-ref-icon img {
  display: block;
  height: 14px !important;
  max-height: 14px !important;
  max-width: 14px !important;
  object-fit: contain;
  width: 14px !important;
}
.history-entity-ref-name {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}
.history-entity-ref--missing {
  border-style: dashed;
  color: var(--color-text-muted);
}
.history-entity-ref:hover,
.history-entity-ref:focus-visible {
  background: var(--color-accent-soft);
  color: var(--color-text-strong);
}
.history-entity-ref:focus-visible {
  outline: 2px solid var(--color-line-focus);
  outline-offset: 1px;
}
.app-history-ticker .history-entity-ref {
  background: transparent;
  border: 0;
  height: 1.3em;
  line-height: inherit;
  padding: 0;
  vertical-align: top;
  white-space: nowrap;
}
.app-history-ticker .history-entity-ref-name {
  white-space: nowrap;
}
.app-history-ticker .ticker-action {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font: inherit;
  line-height: 1.3;
  padding: 0;
  vertical-align: middle;
}
.app-history-ticker .ticker-action:hover,
.app-history-ticker .ticker-action:focus-visible {
  color: var(--color-text-strong);
}
.app-history-ticker .ticker-action[hidden] {
  display: none;
}
@media (pointer: coarse) {
  /* M-11: these are text-sized buttons (29x16 / 40x16) squeezed into a
     cramped footer row -- hit slop instead of growing the row. Undo is the
     only recovery from an unconfirmed detail Delete, so it wins the overlap
     with History's slop in the tight gap between them. `::after`, not
     `::before`: the separator dot's `.ticker-summary + .ticker-action::before`
     / `.ticker-action + .ticker-action::before` rules are more specific than
     a plain `.ticker-action::before` and force `content: none`, which kills
     any `::before` box on this element outright. */
  .app-history-ticker .ticker-action {
    position: relative;
  }
  .app-history-ticker .ticker-action::after {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: max(44px, 100%);
    height: max(44px, 100%);
    transform: translate(-50%, -50%);
  }
  .app-history-ticker .ticker-action[data-history-ticker-action='undo']::after {
    z-index: 1;
  }
}
.app-history-ticker .ticker-action + .ticker-action::before,
.app-history-ticker .ticker-summary + .ticker-action::before {
  color: var(--color-line-strong);
  content: '·';
  /* inline-block: an inline pseudo can't opt out of the parent link's
     propagated underline with text-decoration alone. */
  display: inline-block;
  margin-right: 6px;
  text-decoration: none;
}
.app-about-link {
  align-items: center;
  appearance: none;
  align-self: center;
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font: inherit;
  font-size: var(--font-size-xs);
  line-height: 1.3;
  margin-left: auto;
  /* Left padding keeps it from crowding the history ticker's trailing link. */
  padding: 7px 20px 6px 14px;
  text-decoration: none;
  vertical-align: middle;
}
.app-about-link:hover {
  background: transparent;
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.app-about-link:focus-visible {
  background: transparent;
  color: var(--color-text);
  outline: none;
  text-decoration-line: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.about-modal-card {
  width: min(480px, calc(100vw - 32px));
}
.about-modal-body {
  display: grid;
  gap: 12px;
  line-height: 1.5;
}
.about-modal-body p {
  margin: 0;
}
.about-modal-lede {
  color: var(--color-text-strong);
  font-size: var(--font-size-lg);
}
.about-modal-links {
  border-top: var(--border-width) solid var(--color-line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 4px;
  padding-top: 12px;
}
.about-modal-links a {
  color: var(--color-accent);
  text-underline-offset: 3px;
}
.about-modal-links a:hover,
.about-modal-links a:focus-visible {
  color: var(--color-text-strong);
}

body.view-grid .app-center {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}
body.view-grid #collectionSection {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}
body.view-grid #collectionSection.hidden {
  display: none !important;
}
.app-right {
  grid-area: right;
  border-left: var(--border-width) solid var(--color-line);
  box-shadow: var(--shadow-panel-left);
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--color-bg);
}
.app-right details.add-details,
.app-right details.import-details,
.app-right details.stats-panel {
  margin-bottom: 0;
}
.app-right-close {
  display: none;
}
.app-right-drawer-handle {
  display: none;
}

/* List-view + locations + container: hide right sidebar until the add drawer opens. */
body.view-list .app-shell,
body.view-grid .app-shell,
body.view-locations .app-shell {
  grid-template-columns: var(--sidebar-width) 1fr 0;
}
body.view-grid .app-shell {
  grid-template-rows: 60px minmax(0, 1fr) 0;
}
/* The status bar stays in grid view too — the history ticker is the always-on
   undo/trust surface and must not disappear with the view mode. */
body.view-grid .app-totals-strip {
  display: none;
}
body.view-list .app-right,
body.view-grid .app-right,
body.view-locations .app-right {
  display: none;
}
body.view-deck .app-shell {
  grid-template-columns: 0 minmax(0, 1fr) 0;
}
body.view-deck .app-left,
body.view-deck .app-right {
  display: none;
}

/* Drawer-open: float the sidebar in from the right for shapes that hide it. */
body.view-list.right-drawer-open .app-right,
body.view-grid.right-drawer-open .app-right,
body.view-deck.right-drawer-open .app-right {
  display: flex;
  position: fixed;
  top: 60px;
  right: 0;
  bottom: var(--app-footer-h);
  width: 440px;
  z-index: 50;
  box-shadow: var(--shadow-drawer-side);
  border-left: var(--border-width) solid var(--color-text-strong);
  background: var(--color-bg);
}
.app-right-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay-soft);
  z-index: 40;
  display: none;
}
body.view-list.right-drawer-open .app-right-backdrop,
body.view-grid.right-drawer-open .app-right-backdrop,
body.view-deck.right-drawer-open .app-right-backdrop {
  display: block;
}

/* Vellum owns the overlay lifecycle while this same aside remains an in-flow
   collection rail when it is restored to .app-shell. */
.app-right-layer {
  z-index: 170;
}
body .app-right-layer .app-right.ui-drawer {
  scrollbar-gutter: stable;
  bottom: 0;
  display: flex;
  height: 100dvh;
  max-width: min(92vw, 480px);
  position: fixed;
  right: 0;
  top: 0;
  width: 440px;
}
.app-right-layer.open .app-right-backdrop.ui-drawer-backdrop {
  display: block;
  z-index: 40;
}
.app-right-layer .app-right-drawer-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  flex: 0 0 auto;
  padding: 10px 16px;
  margin: -16px -14px 2px;
  position: sticky;
  top: -16px;
  z-index: 2;
}
.app-right-layer .app-right-close {
  display: inline-flex;
  position: static;
  margin: 0;
  background: transparent;
  border: 0;
}
.app-right-layer .ui-drawer-title {
  font-size: var(--font-size-xl);
  font-weight: 400;
}
.app-right-layer .app-right > .add-details > summary {
  display: none;
}

/* FAB cluster — always visible (even with an empty collection so the user
     can reach the add panel from list view, where the right sidebar is hidden) */
/* The .fab-* family is vellum's (vendor/vellum-ui/vellum-ui.css); tomebound
   only needs to sit above its footer, so it sets vellum's bottom-offset
   token instead of overriding the rule (BEN-656). */
.fab-cluster {
  --vui-fab-cluster-bottom: calc(var(--app-footer-h) + 12px);
  right: 16px;
  z-index: 30;
  transition:
    opacity var(--motion-fast) ease,
    visibility var(--motion-fast) ease;
}
/* BEN-564: the cluster competes with real content under every right-side
   drawer (detail drawer, add drawer) — fade it out whenever one is open.
   The keyboard shortcuts (h/f/c/a) still work. */
body.right-drawer-open .fab-cluster,
body:has(.detail-drawer.visible) .fab-cluster {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Card details share one mounted content tree. Desktop tables keep the
   non-modal side panel; visual collections frame the art in a shared modal.
   The add drawer still owns right-drawer-open and its FAB hiding rule. */
:root {
  --overlay-detail: var(--vui-overlay-detail, rgb(0 0 0 / 64%));
}
#cardDetailModal {
  --vui-modal-backdrop: var(--overlay-detail);
  background: var(--overlay-detail);
}
#detailDrawer[data-detail-host='panel'] .drawer-head > .rune-close {
  display: inline-flex;
}
#cardDetailModal #detailDrawer.ui-modal-card {
  position: relative;
  inset: auto;
  width: min(980px, calc(100vw - 48px));
  height: min(820px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  min-width: 0;
  min-height: 0;
  border: var(--vui-modal-card-border);
  border-radius: var(--vui-modal-card-radius);
  box-shadow: none;
  container-type: inline-size;
  z-index: auto;
}
#cardDetailModal .drawer-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  gap: 24px;
  padding: 24px;
}
/* The desktop panel lets the art participate directly in its body flow. */
.detail-art-column {
  display: contents;
}
#cardDetailModal .detail-art-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 34px;
  gap: 12px;
  min-height: 0;
}
#cardDetailModal .detail-art-column,
#cardDetailModal #detailImageWrap {
  min-width: 0;
  width: 100%;
}
#cardDetailModal .detail-nav {
  justify-content: center;
  margin-top: 0;
  padding: 0;
  border: none;
}
#cardDetailModal #detailForm {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#cardDetailModal .detail-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
#cardDetailModal #detailImageWrap {
  min-height: 0;
  display: flex;
  justify-content: center;
}
#cardDetailModal .drawer-image-frame,
#cardDetailModal .drawer-placeholder {
  height: 100%;
  width: auto;
  max-width: 100%;
  margin: 0;
  box-shadow: none;
  filter: none;
}
#cardDetailModal .detail-card-identity {
  padding-block: 0;
}
#cardDetailModal .drawer-actions {
  justify-content: flex-end;
  padding: 12px 24px;
  box-shadow: none;
  flex: 0 0 72px;
  display: flex;
}
#cardDetailModal .detail-drawer:not(.detail-advanced-open) .drawer-actions {
  visibility: hidden;
}
#cardDetailModal #detailDrawer .drawer-head > .rune-close {
  display: inline-flex;
}
#cardDetailModal .drawer-actions > .btn {
  flex: 0 1 auto;
  min-width: 128px;
}
/* A resized desktop dialog can be narrow even on a wide viewport. */
@container (max-width: 640px) {
  #cardDetailModal .drawer-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 286px minmax(280px, auto);
    align-content: start;
    overflow-y: auto;
    gap: 16px;
    padding: 16px;
  }
  #cardDetailModal .detail-art-column {
    grid-template-rows: 240px 34px;
    min-height: 286px;
  }
  #cardDetailModal #detailForm {
    min-height: 280px;
  }
}
/* All pills identical — stock vellum ink, glyph + label + shortcut on each
   (the BEN-568 gold-primary / icon-only hierarchy is retired). */
body.deck-details-modal-open .fab-cluster,
body.deck-create-modal-open .fab-cluster,
body.csv-import-modal-open .fab-cluster,
body.csv-header-mapper-modal-open .fab-cluster,
body.import-receipt-modal-open .fab-cluster,
body.export-receipt-modal-open .fab-cluster,
body.confirm-modal-open .fab-cluster {
  z-index: 120;
}
body.deck-details-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab),
body.deck-create-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab),
body.csv-import-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab),
body.csv-header-mapper-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab),
body.import-receipt-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab),
body.export-receipt-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab),
body.confirm-modal-open .fab-cluster .fab-btn:not(.feedback-capture-fab) {
  display: none;
}
/* BEN-1017: the csv-import flow's modals were lifted from the shared
   .ui-modal z-index (100) to 180 so they clear the add-cards drawer (see
   .csv-import-modal above) — restate the feedback-capture-fab's
   above-the-backdrop z-index for exactly those three body classes so it
   stays reachable instead of sinking below the raised modal. */
body.csv-import-modal-open .fab-cluster,
body.csv-header-mapper-modal-open .fab-cluster,
body.import-receipt-modal-open .fab-cluster {
  z-index: 185;
}
.fab-btn.mobile-filter-fab {
  display: none;
}

.app-footer {
  grid-area: footer;
  border-top: var(--border-width) solid var(--color-line);
  box-shadow: var(--shadow-panel-top);
  background: var(--color-bg);
  display: flex;
  align-items: stretch;
  min-height: var(--app-footer-h);
  padding: 0;
  font-size: var(--font-size-sm);
  color: var(--color-neutral-600);
}
/* Floating scroll control (desktop): up step, grip, down step. ui/listFolio.js
   places it on the list's right edge at a height that mirrors the scroll
   position. */
.scroll-control {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 25;
  width: 28px;
  will-change: transform;
}
.scroll-control[hidden] {
  display: none;
}
.scroll-control-thumb {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 28px;
  height: 96px;
  box-sizing: border-box;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  opacity: 0.8;
  overflow: hidden;
  transition: opacity var(--motion-fast) ease;
}
.scroll-control:is(:hover, :focus-within, .is-dragging, .is-scrolling) .scroll-control-thumb {
  opacity: 1;
}
.scroll-control-step {
  appearance: none;
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.scroll-control-thumb .app-icon {
  display: block;
  width: 16px;
  height: 16px;
}
.scroll-control-grip {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: grab;
  touch-action: none;
}
.scroll-control.is-dragging .scroll-control-grip {
  cursor: grabbing;
}
@media (hover: hover) and (pointer: fine) {
  .scroll-control-step:hover,
  .scroll-control-grip:hover {
    background: color-mix(in srgb, var(--color-text-strong) 7%, transparent);
    color: var(--color-text-strong);
  }
}
.scroll-control-grip:focus-visible {
  outline: 2px solid var(--color-line-focus);
  outline-offset: -2px;
}
@media (max-width: 900px), (pointer: coarse) {
  .scroll-control {
    display: none;
  }
}

body.view-grid.right-drawer-open .app-right {
  bottom: 0;
}
.footer-storage-nag {
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.02em;
}
.field-deck-only.hidden {
  display: none !important;
}
.add-ownership-readout {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: 4px;
}
.add-ownership-readout.placeholder-state {
  color: var(--color-warn);
}
.add-placeholder-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-neutral-550);
  font-size: var(--font-size-sm);
  cursor: pointer;
}
.add-placeholder-toggle input {
  margin: 0;
}
.settings-utility-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
/* BEN-613: dashed-add family — transparent dashed affordance, muted at rest,
   ink on hover. Per-instance geometry stays local. */
.settings-reset-action,
a.settings-reset-action,
.deck-companion-add,
.deck-home-add-card,
.location-pill-new {
  appearance: none;
  border: 1px dashed var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xs);
  text-decoration: none;
  text-transform: none;
}
.settings-reset-action:hover,
.settings-reset-action:focus-visible,
a.settings-reset-action:hover,
a.settings-reset-action:focus-visible,
.deck-companion-add:hover,
.deck-companion-add:focus-visible,
.deck-home-add-card:hover,
.deck-home-add-card:focus-visible,
.location-pill-new:hover,
.location-pill-new:focus-visible {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
  outline: none;
}
.settings-reset-action {
  min-height: 30px;
  padding: 6px 8px;
  width: 100%;
}
.settings-utility-actions .settings-reset-action {
  flex: 1 1 0;
  min-width: 92px;
  width: auto;
}
.settings-danger-action {
  border-color: var(--color-danger-line);
  color: var(--color-danger);
}
.settings-test-status {
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity var(--motion-base);
}
.settings-test-status.visible {
  opacity: 1;
}
.settings-diagnostics {
  border: var(--border-width) solid var(--color-line);
  color: var(--color-neutral-550);
  font-size: var(--font-size-xs);
  line-height: 1.35;
  padding: 8px;
}
.header-settings {
  display: block;
  position: static;
}
.settings-toggle {
  background: none;
  border: 0;
  border-radius: var(--radius-sharp);
  cursor: pointer;
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-sm);
  min-height: 28px;
  padding: 5px 4px;
  text-align: left;
  text-transform: none;
  width: 100%;
}
.settings-toggle:hover,
.settings-toggle:focus-visible,
.settings-toggle[aria-expanded='true'] {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
  outline: none;
}
.settings-popover {
  background: var(--color-surface);
  border: var(--vui-modal-card-border);
  border-radius: var(--vui-modal-card-radius);
  box-shadow: var(--vui-modal-card-shadow);
  color: var(--color-text-strong);
  display: grid;
  gap: 12px;
  left: var(--settings-left, calc(50vw - 160px));
  max-height: calc(100dvh - 24px);
  max-width: calc(100vw - 24px);
  min-height: 260px;
  min-width: 280px;
  overflow: auto;
  padding: 0 12px 12px;
  position: fixed;
  resize: both;
  top: var(--settings-top, 84px);
  width: min(340px, calc(100vw - 24px));
  z-index: 110;
}
.settings-group {
  display: grid;
  gap: 5px;
}
.settings-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
}
.settings-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
}
.settings-option {
  background: transparent;
  border: var(--border-width) solid var(--color-line-strong);
  border-right: none;
  color: var(--color-neutral-550);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xs);
  line-height: 1;
  min-height: 28px;
  padding: 6px 8px;
  text-transform: none;
  white-space: nowrap;
}
.settings-option:last-child {
  border-right: var(--border-width) solid var(--color-line-strong);
}
.settings-option:hover,
.settings-option:focus-visible {
  color: var(--color-text-strong);
  outline: none;
}
.settings-option.active {
  background: var(--color-text-strong);
  border-color: var(--color-text-strong);
  color: var(--color-text-inverse);
}
.settings-option.active + .settings-option {
  border-left-color: var(--color-text-strong);
}
.settings-utility-group {
  border-top: var(--border-width) solid var(--color-line);
  padding-top: 10px;
}

/* Multiselect filter control */
.multiselect {
  position: relative;
  width: 100%;
}
/* Vellum owns the field chrome and disclosure cue; Tomebound only owns the
   full-width filter layout and lowercase label treatment. */
.multiselect .ms-trigger {
  width: 100%;
  text-align: left;
  font-size: var(--font-size-sm);
  text-transform: none;
  min-width: 0;
}
.field-disclosure > .ms-trigger-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.multiselect.has-selection .ms-trigger {
  color: var(--color-text-strong);
  border-color: var(--color-line-strong);
}
.multiselect .ms-popover {
  display: none;
  position: absolute;
  z-index: 50;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-popover);
}
.multiselect .ms-popover.open {
  display: block;
}
.multiselect .ms-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-transform: none;
}
/* M-34: 29px rows are too tight to tap reliably in the Sets multiselect (and
   every other multiselect) on a phone. */
@media (pointer: coarse) {
  .multiselect .ms-option {
    min-height: var(--vui-touch-target);
  }
}
.multiselect .ms-option:hover {
  background: var(--color-surface-sunken);
}
.multiselect .ms-option input {
  margin: 0;
  cursor: pointer;
}
.multiselect .ms-option > span {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}
.multiselect .ms-option-icon {
  display: block;
  height: 15px;
  width: 15px;
}
.multiselect .ms-search {
  position: sticky;
  top: 0;
  z-index: 1;
  display: block;
  width: 100%;
  box-sizing: border-box;
  border-width: 0 0 var(--border-width);
  border-radius: 0;
  font-size: var(--font-size-sm);
}
.multiselect .ms-search::-webkit-search-cancel-button {
  display: none;
}
.multiselect .ms-option[hidden],
.multiselect .ms-group-header[hidden] {
  display: none;
}
.multiselect .ms-empty {
  padding: 6px 8px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.multiselect .ms-group-header {
  padding: 6px 8px 2px;
  font-size: var(--font-size-xs);
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-transform: none;
  border-top: var(--border-width) solid var(--color-line);
}
.multiselect .ms-group-header:first-child {
  border-top: none;
}
/* BEN-457: optional footer action inside a multiselect popover (the tags
   filter's "manage tags" link). Full-width row that matches the option list
   chrome and sits below the checkboxes. */
.multiselect .ms-action {
  display: block;
  width: 100%;
  appearance: none;
  background: none;
  border: none;
  border-top: var(--border-width) solid var(--color-line);
  padding: 6px 8px;
  font-family: inherit;
  font-size: var(--font-size-sm);
  color: var(--color-text-strong);
  text-align: left;
  text-transform: none;
  cursor: pointer;
}
.multiselect .ms-action:hover,
.multiselect .ms-action:focus-visible {
  background: var(--color-surface-sunken);
  outline: none;
}
.multiselect .ms-trigger-label.ms-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.multiselect .ms-pill {
  background: var(--color-surface-sunken);
  padding: 1px 6px;
  border-radius: var(--radius-sharp);
  font-size: var(--font-size-xxs);
  line-height: 1.4;
  color: var(--color-text-strong);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-filters-btn {
  display: flex;
  width: 100%;
  margin-top: 4px;
}
.clear-filters-label-short {
  display: none;
}
.clear-filters-label-long {
  display: inline;
}

/* BEN-613: the one quiet text-button — bare underlined link, muted at rest,
   ink on hover (danger variant flips to the danger color). */
.btn-link-danger,
.search-syntax-link,
.add-empty-example,
.mcp-chat-empty-example,
.bulk-hidden-review-link {
  appearance: none;
  display: inline-block;
  width: auto;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  font-size: var(--font-size-xs);
  text-align: left;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--color-text-muted);
  cursor: pointer;
}
.btn-link-danger:hover,
.btn-link-danger:focus-visible,
.search-syntax-link:hover,
.search-syntax-link:focus-visible,
.add-empty-example:hover,
.add-empty-example:focus-visible,
.mcp-chat-empty-example:hover,
.mcp-chat-empty-example:focus-visible,
.bulk-hidden-review-link:hover,
.bulk-hidden-review-link:focus-visible {
  background: transparent;
  color: var(--color-text-strong);
  outline: none;
}
.btn-link-danger:hover,
.btn-link-danger:focus-visible {
  color: var(--color-danger);
}
.search-syntax-link {
  margin-top: 5px;
  cursor: help;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--color-line-strong);
  border-radius: var(--radius-soft);
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--motion-base);
  margin-bottom: 16px;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
  background: var(--color-surface);
}
.drop-zone p {
  margin: 4px 0;
}
.drop-zone .small {
  font-size: var(--font-size-sm);
  color: var(--color-line-strong);
}

.paste-area {
  width: 100%;
  min-height: 120px;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  padding: 8px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  resize: vertical;
  background: var(--color-surface);
  color: var(--color-text-strong);
  text-transform: none;
  margin-bottom: 8px;
}
.paste-area:focus {
  border-color: var(--color-text-strong);
  outline: none;
}

.import-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.export-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: var(--border-width) solid var(--color-line);
}
.export-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Stats */
.stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-label {
  font-size: var(--font-size-xxs);
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 400;
}

.stats-panel {
  margin-bottom: 16px;
  border: var(--border-width) solid var(--color-line);
  background: var(--color-surface);
  padding: 10px 14px;
  border-radius: var(--radius-sharp);
}
.stats-panel > summary {
  cursor: pointer;
  font-size: var(--font-size-sm);
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  list-style: revert;
}
.stats-panel > summary::marker {
  color: var(--color-text-muted);
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 12px;
}
.stats-section-title {
  font-size: var(--font-size-xxs);
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 400;
  margin-bottom: 8px;
  text-transform: none;
}
.curve-row,
.breakdown-row {
  display: grid;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-neutral-600);
  margin-bottom: 3px;
  text-transform: none;
}
.curve-row {
  grid-template-columns: 24px 1fr 28px;
}
.breakdown-row {
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
}
.breakdown-row > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.curve-bucket {
  color: var(--color-text-muted);
}
.curve-bar-wrap {
  background: var(--color-surface-sunken);
  height: 10px;
  border-radius: var(--radius-tight);
  overflow: hidden;
}
.curve-bar {
  height: 100%;
  background: var(--color-text-muted);
}
.breakdown-count,
.curve-count {
  text-align: right;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.breakdown-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.color-legend {
  font-size: var(--font-size-xxs);
  color: var(--color-neutral-550);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 6px;
}
.color-legend-row {
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: none;
}
.color-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: var(--border-width) solid var(--color-line);
  flex-shrink: 0;
}

/* Shared controls: search, segmented buttons, and filters */
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: var(--border-width) solid var(--color-line);
}
.controls input,
.controls select {
  background: transparent;
  border: none;
  border-bottom: var(--border-width) solid var(--color-text-strong);
  color: var(--color-text-strong);
  padding: 4px 2px;
  font-size: var(--font-size-md);
  font-family: inherit;
  text-transform: none;
  outline: none;
  border-radius: var(--radius-square);
  -webkit-appearance: none;
}
.controls input:focus,
.controls select:focus {
  border-bottom-width: 2px;
}
.controls .search-input {
  width: 200px;
  flex: 1;
  max-width: 280px;
}
.search-wrap {
  --search-slot-size: 24px;
  --search-control-inset: 8px;
  --search-trailing-space: calc(var(--search-control-inset) * 2 + var(--search-slot-size));
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 280px;
}
.search-wrap .search-input {
  box-sizing: border-box;
  flex: 1;
  padding-right: var(--search-trailing-space);
  min-width: 0;
  max-width: none;
}
.search-wrap .search-actions {
  position: absolute;
  right: var(--search-control-inset);
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: var(--search-slot-size);
  height: var(--search-slot-size);
  pointer-events: none;
}
.search-wrap .search-actions > * {
  grid-area: 1 / 1;
}
.search-wrap .search-actions > kbd.btn-shortcut {
  pointer-events: none;
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: var(--search-slot-size);
  height: var(--search-slot-size);
  margin: 0;
  padding: 0;
  line-height: 1;
}
/* M-34: this rule's specificity beats the generic `.btn-shortcut { display:
   none }` touch rule, so the "/" chip kept showing on phones. Match its
   selector at the same media condition so it wins by source order instead. */
@media (pointer: coarse) {
  .search-wrap .search-actions > kbd.btn-shortcut {
    display: none;
  }
}
.search-wrap:has(.search-input:focus) .search-focus-hint {
  opacity: 0.4;
}
.search-wrap:has(.search-input:not(:placeholder-shown)) .search-focus-hint {
  visibility: hidden;
}
/* One fixed slot for either the shortcut or clear, including narrow toolbars. */
.search-wrap .search-clear-btn {
  position: static;
  box-sizing: border-box;
  pointer-events: auto;
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
  width: var(--search-slot-size);
  height: var(--search-slot-size);
  min-width: var(--search-slot-size);
  min-height: var(--search-slot-size);
  padding: 0;
  line-height: 1;
  align-items: center;
  justify-content: center;
  display: none;
}
.search-wrap:has(.search-input:not(:placeholder-shown)) .search-clear-btn {
  display: inline-flex;
}
.search-wrap .search-clear-btn:hover,
.search-wrap .search-clear-btn:focus-visible {
  color: var(--color-text-strong);
}
.search-help-popover {
  position: fixed;
  z-index: 1050;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  padding: 12px 14px;
  font-size: var(--font-size-xs);
  line-height: 1.7;
  box-shadow: var(--shadow-popover);
  width: 320px;
  max-width: calc(100vw - 40px);
  text-transform: none;
  display: none;
}
.search-help-popover.visible {
  display: block;
}
.search-help-popover .syntax-title {
  font-size: var(--font-size-xxs);
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.search-help-popover code {
  background: var(--color-surface-sunken);
  padding: 1px 5px;
  border-radius: var(--radius-sharp);
  font-family: var(--font-mono);
  font-size: 0.92em;
}
.controls .filter-select {
  min-width: 90px;
  padding-right: 16px;
}
/* Tag vocabulary manager — singleton modal portaled to body. */
/* BEN-462: the tag manager is a canonical .ui-modal (chrome inherited from the
   shared modal component). Only its card width + inner layout live here. */
.tag-manager-card {
  width: min(420px, calc(100vw - 32px));
}
.tag-manager-body {
  padding: 0;
}
.tag-manager-add-form {
  display: flex;
  gap: 6px;
  padding: 12px;
  border-bottom: var(--border-width) solid var(--color-line);
}
.tag-manager-add-input {
  flex: 1 1 auto;
  min-width: 0;
  border: var(--border-width) solid var(--color-line-strong);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-md);
  padding: 4px 6px;
  text-transform: none;
}
.tag-manager-add-input:focus {
  outline: none;
  border-color: var(--color-text-muted);
}
.tag-manager-add-input::placeholder {
  color: var(--color-text-muted);
}
.tag-manager-empty {
  padding: 16px 12px;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  font-style: italic;
  text-align: center;
}
.tag-manager-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.tag-manager-add {
  margin-bottom: 12px;
}
.tag-manager-list li {
  border-bottom: 1px solid var(--color-line-faint);
  list-style: none;
}
.tag-manager-identity-row {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--color-text-strong);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 10px;
  padding: 10px 2px;
  text-align: left;
  width: 100%;
}
.tag-manager-identity-row:hover,
.tag-manager-identity-row:focus-visible {
  background: var(--color-surface-hover);
  outline: none;
}
.tag-manager-identity-row .tag-manager-count {
  margin-left: auto;
}
.tag-manager-row-disclosure {
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
}
.tag-manager-editor {
  display: grid;
  gap: 14px;
}
.tag-manager-editor[hidden] {
  display: none;
}
.tag-manager-editor-heading {
  color: var(--color-text-strong);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
.tag-manager-editor-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}
.tag-manager-editor-spacer {
  flex: 1 1 auto;
}
.tag-manager-item {
  padding: 6px 12px;
  border-bottom: 1px solid var(--color-line-beige-faint);
}
.tag-manager-item:last-child {
  border-bottom: none;
}
.tag-manager-display {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tag-manager-count {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-left: 4px;
}
.tag-manager-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
}
.tag-manager-action {
  appearance: none;
  background: transparent;
  border: 1px solid var(--color-line-warm-dim);
  border-radius: var(--radius-sharp);
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-sm);
  padding: 2px 8px;
  text-transform: none;
}
.tag-manager-action:hover,
.tag-manager-action:focus-visible {
  border-color: var(--color-text-muted);
  color: var(--color-text-strong);
  outline: none;
}
.tag-manager-action-danger {
  color: var(--color-danger-text-warm);
  border-color: var(--color-danger-line-warm);
}
.tag-manager-action-danger:hover,
.tag-manager-action-danger:focus-visible {
  border-color: var(--color-danger-text-warm);
  color: var(--color-danger-text-warm);
  background: var(--color-danger-bg-warm);
}
.tag-manager-color-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.tag-manager-color-swatch-group {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.tag-manager-color-swatch {
  appearance: none;
  padding: 0;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  cursor: pointer;
  background: transparent;
  position: relative;
  overflow: hidden;
}
.tag-manager-color-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.tag-manager-color-swatch.active,
.tag-manager-color-swatch[aria-pressed='true'] {
  border-color: var(--color-text-strong);
  box-shadow: 0 0 0 1px var(--color-surface) inset;
}
.tag-manager-color-swatch:hover,
.tag-manager-color-swatch:focus-visible {
  border-color: var(--color-text-muted);
  outline: none;
}
/* Leftmost "no color" / default swatch. Distinguishes itself from the preset
   color buttons with a dashed border and a diagonal strikethrough line so the
   user reads it as "default" rather than as another color. */
.tag-manager-color-swatch-default {
  border-style: dashed;
  border-color: var(--color-line-strong);
  background: var(--color-surface);
}
.tag-manager-color-swatch-default span {
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.75px),
    var(--color-line-strong) calc(50% - 0.75px),
    var(--color-line-strong) calc(50% + 0.75px),
    transparent calc(50% + 0.75px)
  );
}
.tag-manager-color-swatch-default.active,
.tag-manager-color-swatch-default[aria-pressed='true'] {
  border-color: var(--color-text-strong);
  border-style: solid;
  box-shadow: none;
}
.tag-manager-color-swatch-default.active span,
.tag-manager-color-swatch-default[aria-pressed='true'] span {
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.75px),
    var(--color-text-strong) calc(50% - 0.75px),
    var(--color-text-strong) calc(50% + 0.75px),
    transparent calc(50% + 0.75px)
  );
}
.tag-manager-color-input {
  width: 22px;
  height: 22px;
  padding: 0;
  border: var(--border-width) solid var(--color-line-strong);
  background: transparent;
  cursor: pointer;
}
.tag-manager-emoji-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.tag-manager-emoji-swatch-group {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.tag-manager-emoji-swatch {
  appearance: none;
  padding: 2px;
  width: 24px;
  height: 24px;
  line-height: 1;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-sharp);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tag-manager-emoji-swatch.active,
.tag-manager-emoji-swatch[aria-pressed='true'] {
  background: var(--color-line-strong);
  outline: 2px solid var(--color-text-strong);
  outline-offset: -1px;
}
.tag-manager-emoji-swatch:hover {
  background: var(--color-line);
}
.tag-manager-emoji-swatch:focus-visible {
  background: var(--color-line);
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.tag-manager-emoji-input {
  width: 64px;
  padding: 2px 4px;
  border: var(--border-width) solid var(--color-line-strong);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font: inherit;
}
.tag-manager-rename-form {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}
.tag-manager-rename-input {
  flex: 1 1 auto;
  min-width: 0;
  border: var(--border-width) solid var(--color-line-strong);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-md);
  padding: 3px 6px;
  text-transform: none;
}
.tag-manager-rename-input:focus {
  outline: none;
  border-color: var(--color-text-muted);
}
/* Segmented controls come from vellum's quiet .segmented / .segment-btn
   (BEN-607) — one scale plus .segmented-compact. Only layout lives locally. */

.scope-option[data-loc-type='deck'] .entity-label-glyph {
  color: var(--color-loc-deck-text);
}
.scope-option[data-loc-type='container'] .entity-label-glyph {
  color: var(--color-loc-container-text);
}
.app-history-ticker .ticker-action[data-history-ticker-action] {
  color: var(--color-provenance-text);
}
.app-history-ticker .ticker-action-label {
  text-decoration: none;
}
.app-history-ticker .ticker-action[data-history-ticker-action]:is(:hover, :focus-visible),
.app-about-link:is(:hover, :focus-visible) {
  color: var(--color-text-strong);
}
.app-history-ticker .ticker-action:is(:hover, :focus-visible) .ticker-action-label,
.app-about-link:is(:hover, :focus-visible) {
  text-decoration-line: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.app-history-ticker .ticker-action[data-history-ticker-action]:focus-visible,
.app-about-link:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
.app-history-ticker .ticker-action:focus-visible .ticker-action-label,
.app-about-link:focus-visible {
  text-decoration-thickness: 2px;
}
.app-history-ticker .ticker-summary.is-undone .history-ticker-entity {
  color: inherit;
}
.mcp-chat-fab .fab-glyph {
  color: var(--color-archivist);
}
.quick-jump-trigger {
  min-height: 32px;
}
.quick-jump-trigger kbd {
  margin-left: auto;
}
.quick-jump-collapsed-trigger {
  display: none;
}
.quick-jump-empty {
  padding: 20px 12px;
  text-align: center;
}
.quick-jump-empty p {
  margin: 0 0 12px;
}
.shortcuts-modal > .ui-modal-card {
  width: min(660px, calc(100vw - 32px));
}
.shortcuts-modal .ui-modal-body {
  padding: 16px;
}
.shortcuts-modal h3 {
  font-size: var(--font-size-sm);
  margin: 20px 0 8px;
}
.shortcuts-list {
  margin: 0;
}
.shortcuts-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 2fr;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--color-line);
}
.shortcuts-row dd {
  margin: 0;
}
.shortcuts-row kbd {
  white-space: normal;
  font-size: var(--font-size-xs);
}
@media (min-width: 901px) {
  body.left-sidebar-collapsed .app-title-row > .quick-jump-collapsed-trigger {
    display: grid;
  }
}

/* Tomebound: collection cards. Cascade order is declared in ../styles.css. */

/* Collection grid and card tiles */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.grid.grid-small {
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 7px;
}
.grid.grid-medium {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.grid.grid-large {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.card-badges {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}
.deck-card.is-foil .deck-card-face::after,
.collection-visual-card.is-foil .collection-visual-card-art::after,
.deck-preview-frame.is-foil::after,
.drawer-image-frame.is-foil::after,
.grid-slot.is-foil::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: var(--gradient-card-foil);
  mix-blend-mode: screen;
}
.deck-card.is-etched .deck-card-face::after,
.collection-visual-card.is-etched .collection-visual-card-art::after,
.deck-preview-frame.is-etched::after,
.drawer-image-frame.is-etched::after,
.grid-slot.is-etched::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: var(--gradient-card-etched);
  mix-blend-mode: screen;
}
.grid-slot.is-foil::after,
.grid-slot.is-etched::after {
  opacity: 0.16;
}

.card-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--color-overlay-strong), transparent);
  color: var(--color-text-inverse);
  padding: 20px 6px 5px;
  font-size: var(--font-size-xs);
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity var(--motion-base);
  pointer-events: none;
}
.card-loc {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  pointer-events: auto;
}
.card-loc .loc-pill {
  box-shadow: var(--shadow-subtle);
  cursor: pointer;
}
.card-loc .loc-pill:hover {
  filter: brightness(0.95);
}
.card-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 18px 6px 5px;
  background: linear-gradient(to top, var(--color-overlay-strong), transparent);
  color: var(--color-text-inverse);
  opacity: 0;
  transition: opacity var(--motion-base);
  pointer-events: none;
}
.card-action-label,
.card-scryfall-link {
  color: var(--color-text-inverse);
  font-size: var(--font-size-xs);
  letter-spacing: 0.02em;
  text-decoration: none;
  text-transform: none;
}
.card-scryfall-link {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-on-dark-line);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.card-scryfall-link:hover,
.card-scryfall-link:focus-visible {
  border-color: var(--color-text-inverse);
  outline: none;
}

/* Tomebound: deck workspace. Cascade order is declared in ../styles.css. */

/* Deck workspace, cards, settings, and dashboard */
/* Deck view — moxfield-style stacked columns */
.deck-view {
  display: none;
}
.deck-view.active {
  display: block;
}
.deck-view-wrap {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.deck-side-column {
  display: flex;
  flex-direction: column;
  align-self: start;
  position: sticky;
  top: 14px;
  height: auto;
  min-height: 0;
  gap: 12px;
}
.deck-preview-panel {
  display: block;
  cursor: pointer;
  flex: 0 0 auto;
}
.deck-preview-panel.hidden {
  display: none;
}
.deck-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 488 / 680;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--color-surface-placeholder);
  box-shadow: none;
}
.deck-preview-card {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.deck-preview-card.hidden {
  display: none;
}
.deck-preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 8px;
  text-align: center;
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  text-transform: none;
}
.deck-preview-placeholder.hidden {
  display: none;
}
/* foil/etched overlay handled by the unified .is-foil / .is-etched ::after
     rule near the top of the stylesheet — no per-frame duplicate needed. */
.deck-preview-name {
  font-family: var(--font-heading);
  font-size: var(--font-size-md);
  color: var(--color-text-strong);
  text-transform: none;
  margin-top: 4px;
  line-height: 1.25;
}
.deck-preview-meta {
  display: inline;
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.deck-preview-details {
  display: inline;
  margin: 0;
  padding: 0;
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  line-height: 1.35;
}
.deck-preview-details.hidden {
  display: none;
}
.deck-preview-details dt {
  text-transform: none;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.deck-preview-details dd {
  display: inline;
  min-width: 0;
  margin: 0;
  color: inherit;
  overflow-wrap: anywhere;
  text-transform: none;
}
.deck-preview-details dd::before {
  content: ' · ';
}
.deck-view-wrap:has([data-deck-preview='hidden']) {
  grid-template-columns: minmax(0, 1fr);
}
.deck-view-wrap:has([data-deck-preview='hidden']) > .deck-side-column {
  display: none;
}
.deck-columns {
  display: grid;
  grid-template-columns: repeat(
    var(--deck-logical-columns, 1),
    var(--deck-column-w, var(--deck-card-w, 210px))
  );
  grid-auto-rows: 8px;
  grid-auto-flow: row;
  column-gap: 12px;
  row-gap: 0;
  justify-content: start;
  align-items: start;
}
.deck-col {
  min-width: 0;
  grid-row: span var(--deck-col-span, 48);
}
.deck-col-pack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  grid-row: span var(--deck-col-span, 48);
  min-width: 0;
}
.deck-col-pack .deck-col--packed {
  grid-row: auto;
}
.deck-col-header {
  font-size: var(--font-size-sm);
  color: var(--color-text-strong);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  border-bottom: var(--border-width) solid var(--color-line);
  padding-bottom: 4px;
  white-space: nowrap;
}
.deck-col-header .deck-col-count {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.deck-card-menu.is-context-positioned {
  position: fixed;
}
.deck-stack {
  position: relative;
  display: flex;
  flex-direction: column;
}
.deck-card {
  position: relative;
  width: 100%;
  aspect-ratio: 488 / 680;
  margin-top: calc(var(--deck-name-bar) - 100% * 680 / 488);
  border-radius: var(--radius-card);
}
.deck-card:first-child {
  margin-top: 0;
}
.deck-card:has(:focus-visible),
.deck-card.menu-open {
  z-index: 30;
}
/* Placeholder/missing-copy styling is only meaningful while building — in
   decklist mode the deck reads as a clean list with no ownership cues.
   BEN-392: opacity 0.65 reads as faded without the muddy greyscale tone.
   BEN-381: no "placeholder" text label — the visual fade alone is enough
   signal. */
body.deck-ownership-building .deck-card-placeholder .deck-card-face {
  opacity: 0.65;
}
body.deck-ownership-building .deck-text-row-placeholder {
  opacity: 0.65;
}
.deck-row-loc {
  display: inline-block;
  margin-left: 8px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
.deck-row-loc-placeholder {
  color: var(--color-warn-text-amber);
}
.deck-card-face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  overflow: hidden;
  background: var(--color-surface-placeholder);
  color: inherit;
  cursor: pointer;
  box-shadow: none;
  font: inherit;
  text-align: inherit;
  outline: 2px solid transparent;
  outline-offset: 4px;
}
.deck-card-face:focus-visible {
  outline: 2px solid var(--color-card-outline);
  outline-offset: 4px;
}
.deck-card-menu-btn:focus-visible,
.deck-card-menu button:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.deck-card-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@media (hover: hover) and (pointer: fine) {
  .deck-card:not(.deck-stack > .deck-card):hover .deck-card-face {
    outline-color: var(--color-card-hover-outline);
  }
}
.deck-card .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 8px;
  text-align: center;
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  text-transform: none;
}
/* .icon-btn--bordered + corner placement and reveal-on-hover (BEN-689). */
.deck-card-menu-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 4;
  width: 28px;
  height: 24px;
  font-size: var(--font-size-xl);
  opacity: 0;
  transition:
    opacity var(--motion-fast),
    background var(--motion-fast);
}
.deck-card:hover .deck-card-menu-btn,
.deck-card:focus-within .deck-card-menu-btn,
.deck-card.menu-open .deck-card-menu-btn {
  opacity: 1;
}
.deck-card-menu {
  position: absolute;
  left: 4px;
  top: 28px;
  z-index: 20;
  min-width: 148px;
  max-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface);
  padding: 4px;
  box-shadow: var(--shadow-popover);
}
.deck-card-menu button {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sharp);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xs);
  line-height: 1.2;
  padding: 5px 7px;
  text-align: left;
  text-transform: none;
}
.deck-card-menu button:hover,
.deck-card-menu button:focus-visible {
  background: var(--color-surface-hover);
}
.deck-card-menu button[disabled] {
  color: var(--color-text-muted);
  cursor: default;
}
.deck-card-menu button[disabled]:hover {
  background: transparent;
}
.deck-card-menu .deck-card-menu-danger {
  border-top: var(--border-width) solid var(--color-line);
  margin-top: 3px;
  padding-top: 8px;
  color: var(--color-danger-text-soft);
}
@media (hover: none) {
  .deck-card-menu-btn {
    opacity: 1;
  }
}
@media (pointer: coarse) {
  /* M-11: menu rows are ~24px tall (5px padding around one text line). The
     menu is already full-width, so growing row height is safe -- it just
     makes the popover taller, no sibling overlap. */
  .deck-card-menu button {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
}
.deck-workspace .deck-card .deck-card-quantity-pill {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 4;
  width: auto;
  min-width: 26px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-strong);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  opacity: 1;
  box-shadow: none;
}
.deck-card-quantity-pill .deck-card-menu-dots {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-width var(--motion-fast),
    opacity var(--motion-fast);
}
.deck-card:is(:hover, :focus-within, .menu-open) .deck-card-quantity-pill .deck-card-menu-dots {
  max-width: 20px;
  margin-left: 5px;
  opacity: 1;
}
.deck-card-quantity-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-bottom: var(--border-width) solid var(--color-line);
  font-size: var(--font-size-xs);
}
.deck-card-quantity-stepper > span {
  margin-right: auto;
}
.deck-card-quantity-stepper output {
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.deck-card-menu .deck-card-quantity-stepper button {
  width: 28px;
  height: 28px;
  padding: 0;
  text-align: center;
}
.deck-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.deck-group-control {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: none;
}
.deck-actions .deck-summary {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-left: auto;
}
.deck-actions .deck-summary .warn {
  color: var(--color-danger-text-rose);
}
.deck-actions.hidden {
  display: none;
}
.deck-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.deck-workspace.deck-card-size-small {
  --deck-card-w: 160px;
  --deck-name-bar: 28px;
}
.deck-workspace.deck-card-size-medium {
  --deck-card-w: 210px;
  --deck-name-bar: 32px;
}
.deck-workspace.deck-card-size-large {
  --deck-card-w: 250px;
  --deck-name-bar: 36px;
}
.deck-workspace .deck-hero {
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.deck-hero-main {
  min-width: 0;
}
.deck-hero.is-editing .deck-hero-read {
  display: none;
}
.deck-kicker {
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  text-transform: none;
}
.deck-hero h2 {
  margin: 0;
  font-size: var(--font-size-display);
  line-height: 1.1;
  text-transform: none;
  letter-spacing: 0;
}
.deck-description {
  margin: 5px 0 0;
  color: var(--color-text-muted);
  text-transform: none;
  max-width: none;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.45;
}
.deck-description.is-empty {
  color: var(--color-text-muted);
}
.deck-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  margin: 8px 0 0;
}
.deck-meta-strip div {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}
.deck-meta-strip dt {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
.deck-meta-strip dd {
  margin: 0;
  color: var(--color-text-strong);
  font-size: var(--font-size-sm-plus);
  line-height: 1.25;
  text-transform: none;
  overflow-wrap: anywhere;
}
.deck-meta-card-link {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--color-line);
  text-underline-offset: 2px;
}
.deck-meta-card-link:hover,
.deck-meta-card-link:focus-visible {
  color: var(--color-text-strong);
  text-decoration-color: var(--color-text-strong);
}
.deck-meta-strip .is-empty {
  color: var(--color-text-muted);
}
/* ---- Deck header: read-first layout ---- */
.deck-hero {
  align-items: stretch;
  grid-template-columns: minmax(190px, 240px) minmax(320px, 1fr) auto;
}
.deck-hero-title-row {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
}
/* BEN-614: rides the .ui-chip base; only behavioral deltas live here. */
.deck-format-chip {
  cursor: default;
  letter-spacing: 0.02em;
  text-transform: none;
}
.deck-hero-title {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.deck-hero-title-btn,
.deck-hero-title-text {
  align-items: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--font-size-display);
  line-height: 1.1;
  margin: 0;
  padding: 0;
  text-align: left;
  text-decoration-color: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.deck-hero-title-text {
  cursor: inherit;
  text-decoration: none;
}
.deck-hero-identity {
  font-size: inherit;
}
.deck-hero-identity > .entity-label-mark {
  height: 22px;
  width: 22px;
}
.deck-hero-title-btn:hover,
.deck-hero-title-btn:focus-visible {
  text-decoration-color: var(--color-line-strong);
}
@media (min-width: 901px) and (max-width: 1300px) {
  .deck-hero {
    grid-template-columns: minmax(220px, auto) minmax(0, 1fr);
  }
  .deck-hero-side {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
/* ---- Commander hero block ---- */
.deck-commander-hero {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  padding-right: 4px;
  width: 100%;
}
.deck-commander-hero-arts {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  min-height: 132px;
}
.deck-commander-hero-arts.is-paired {
  display: grid;
  min-width: 122px;
}
.deck-commander-hero-art {
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-soft);
  cursor: pointer;
  display: block;
  height: 132px;
  overflow: hidden;
  padding: 0;
  width: 96px;
}
.deck-commander-hero-arts.is-paired .deck-commander-hero-art {
  grid-area: 1 / 1;
}
.deck-commander-hero-arts.is-paired .deck-commander-hero-art:nth-child(1) {
  position: relative;
  z-index: 2;
}
.deck-commander-hero-arts.is-paired .deck-commander-hero-art:nth-child(2) {
  margin-left: 26px;
  margin-top: 12px;
  position: relative;
  z-index: 1;
}
.deck-commander-hero-art img {
  display: block;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  width: 100%;
}
.deck-commander-hero-art-empty {
  background: repeating-linear-gradient(
    135deg,
    var(--color-surface-sunken) 0,
    var(--color-surface-sunken) 6px,
    var(--color-surface-stripe) 6px,
    var(--color-surface-stripe) 12px
  );
  cursor: default;
}
.deck-commander-hero-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.deck-commander-hero-kicker {
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
.deck-commander-hero-names {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 130px;
  min-width: 0;
}
.deck-commander-hero-name {
  background: none;
  border: 0;
  color: var(--color-text-strong);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xl);
  line-height: 1.15;
  max-width: 100%;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--color-line);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.deck-commander-hero-name:hover,
.deck-commander-hero-name:focus-visible {
  text-decoration-color: var(--color-text-strong);
}
.deck-commander-hero-sep {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.deck-commander-hero-pips {
  display: inline-flex;
  gap: 4px;
  margin-top: 2px;
}
@media (max-width: 700px) {
  .deck-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .deck-commander-hero {
    grid-column: 1;
  }
  .deck-commander-hero-names {
    max-width: none;
  }
}
.deck-color-pip {
  /* Mana discs stay light in every theme. Use existing dark ink locally;
     book body ink misses 4.5:1 on the black disc. */
  --color-text-strong: var(--color-neutral-900);
  align-items: center;
  border: var(--border-width) solid var(--color-line);
  border-radius: 50%;
  box-shadow: var(--shadow-subtle);
  display: inline-flex;
  font-size: var(--font-size-sm);
  font-weight: 800;
  height: 24px;
  justify-content: center;
  letter-spacing: 0;
  overflow: hidden;
  position: relative;
  text-transform: none;
  width: 24px;
}
.deck-color-pip img {
  display: block;
  height: 100%;
  pointer-events: none;
  width: 100%;
}
.deck-color-pip-letter {
  opacity: 0;
  position: absolute;
}
.deck-color-pip-w {
  background: var(--color-mana-w);
  color: var(--color-text-strong);
}
.deck-color-pip-u {
  background: var(--color-mana-u);
  color: var(--color-text-strong);
}
.deck-color-pip-b {
  background: var(--color-mana-b);
  color: var(--color-text-strong);
}
.deck-color-pip-r {
  background: var(--color-mana-r);
  color: var(--color-text-strong);
}
.deck-color-pip-g {
  background: var(--color-mana-g);
  color: var(--color-text-strong);
}
.deck-color-pip-c {
  background: var(--color-mana-c);
  color: var(--color-text-strong);
}
html[data-theme='dark'] .deck-color-pip {
  --color-text-strong: var(--color-text-inverse);
}
/* When the commander hero is visible, drop the redundant commander/partner
   rows in the meta strip — keep only companion/format. */
.deck-hero .deck-commander-hero ~ .deck-hero-main .deck-meta-strip {
  /* No-op selector kept for spec; controlled via JS conditional render. */
}
/* ---- Deck health strip ---- */
.deck-health-strip {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}
.deck-format-status {
  align-items: baseline;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--font-size-sm);
  gap: 4px 6px;
  text-transform: none;
}
.deck-format-status::before {
  background: var(--color-text-muted);
  border-radius: 50%;
  content: '';
  height: 7px;
  position: relative;
  top: -1px;
  width: 7px;
}
.deck-format-status-title {
  color: var(--color-text-strong);
  font-weight: 600;
}
.deck-format-status-detail::before {
  content: '\00b7';
  margin-right: 6px;
}
.deck-format-status-legal::before {
  background: var(--color-status-success-text);
}
.deck-format-status-legal .deck-format-status-title {
  color: var(--color-status-success-text);
}
.deck-format-status-illegal::before {
  background: var(--color-danger);
}
.deck-format-status-illegal .deck-format-status-title {
  color: var(--color-danger);
}
.deck-format-status-pending::before {
  background: var(--color-warn);
}
.deck-format-status-action,
.deck-summary-ownership-button {
  background: none;
  border: 0;
  color: var(--color-accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.deck-format-status-action:hover,
.deck-summary-ownership-button:hover {
  color: var(--color-accent-strong);
}
.deck-format-status-action:focus-visible,
.deck-summary-ownership-button:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
.deck-summary-line {
  align-items: baseline;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--font-size-xs-plus);
  font-variant-numeric: tabular-nums;
  gap: 6px 20px;
}
.deck-summary-item strong {
  color: var(--color-text-strong);
  font-weight: 650;
}
.deck-summary-line {
  order: -1;
}
.deck-legality-details {
  flex-basis: auto;
}
.deck-legality-details summary {
  cursor: pointer;
}
.deck-legality-details p {
  margin: 8px 0 0;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.45;
  text-transform: none;
}
.deck-ownership-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
}
.deck-ownership-details {
  color: var(--color-text-muted);
}
.deck-ownership-details > summary {
  cursor: pointer;
}
.deck-ownership-detail-body {
  display: grid;
  gap: 4px;
  max-width: 440px;
  padding-top: 8px;
  line-height: 1.4;
}
.deck-ownership-explanation {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.4;
}
.deck-summary-item {
  white-space: nowrap;
}
.deck-summary-line [data-deck-health='count'] {
  color: var(--color-text-strong);
  font-weight: 600;
}
.deck-summary-ownership {
  display: inline-flex;
  position: relative;
}
body:has([data-deck-legality-trigger]:is(:hover, :focus, :focus-visible))
  .deck-workspace
  :is(.deck-card, .decklist-line, .deck-text-table tbody tr):not(
    .deck-card-invalid,
    .decklist-line-invalid,
    .deck-text-row-invalid
  ) {
  opacity: 0.6;
}
body:has([data-deck-legality-trigger]:is(:hover, :focus, :focus-visible))
  .deck-workspace
  :is(.deck-card-invalid, .decklist-line-invalid, .deck-text-row-invalid) {
  background: var(--color-danger-soft);
  outline: 3px solid var(--color-danger-strong);
  outline-offset: 2px;
}
.deck-workspace.deck-legality-reveal
  :is(.deck-card, .decklist-line, .deck-text-table tbody tr):not(
    .deck-card-invalid,
    .decklist-line-invalid,
    .deck-text-row-invalid
  ) {
  animation: deck-legality-reveal-dim min(var(--motion-slow), 600ms) ease-out;
}
@keyframes deck-legality-reveal-dim {
  0% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .deck-workspace.deck-legality-reveal
    :is(.deck-card, .decklist-line, .deck-text-table tbody tr):not(
      .deck-card-invalid,
      .decklist-line-invalid,
      .deck-text-row-invalid
    ) {
    animation: none;
  }
}
/* ---- Sticky deck top bar ---- */
/* Body-level fixed bar so the background spans the full viewport width while
   the inner .deck-topbar-bar stays bounded to the app-center content column. */
.deck-topbar-strip {
  background: var(--color-on-dark-text-soft);
  backdrop-filter: blur(4px);
  border-bottom: var(--border-width) solid var(--color-line);
  display: block;
  left: 0;
  opacity: 0;
  padding: 6px 0;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transition:
    opacity var(--motion-base) ease,
    transform var(--motion-base) ease;
  transform: translateY(-4px);
  visibility: hidden;
  width: 100%;
  z-index: 50;
}
.deck-topbar-strip.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}
.deck-topbar-strip.hidden {
  display: none;
}
/* The chip used to have a border + white background, which read as a text
   input rather than a clickable label. Strip that down to a plain text-like
   button so it sits flush with the rest of the topbar (BEN-382). */
.deck-topbar-chip {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--color-text-strong);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--font-size-md);
  font-weight: 600;
  gap: 6px;
  padding: 4px 0;
  text-transform: none;
}
.deck-topbar-chip:hover .deck-topbar-chip-name,
.deck-topbar-chip:focus-visible .deck-topbar-chip-name {
  text-decoration: underline;
  text-decoration-color: var(--color-text-muted);
  text-underline-offset: 2px;
}
.deck-topbar-chip:focus-visible {
  outline: none;
}
.deck-topbar-chip-title {
  padding: 4px 0;
}
.deck-topbar-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.deck-topbar-bar {
  align-items: center;
  display: flex;
  gap: 12px;
  min-height: 38px;
  /* BEN-393: anchor the deck name to the left edge of the screen so it scans
     as a header crumb. Right side still leaves room for the right rail. */
  padding-left: var(--space-5);
  padding-right: calc(360px + 20px);
  width: 100%;
}
body.left-sidebar-collapsed .deck-topbar-bar {
  padding-left: 56px;
}
body.view-list .deck-topbar-bar,
body.view-grid .deck-topbar-bar,
body.view-locations .deck-topbar-bar {
  /* These views hide the right rail. */
  padding-right: 20px;
}
@media (max-width: 900px) {
  /* BEN-mobile-audit M-06: the mobile book header is a real 56px toolbar
     (styles/responsive.css), not part of the sidebar column this strip was
     designed to clear — without this the strip paints over it at top:0 and
     the commander chip sits on the sidebar toggle underneath. */
  .deck-topbar-strip {
    top: 56px;
  }
  .deck-topbar-bar {
    padding-left: 12px;
    padding-right: 12px;
  }
  body.left-sidebar-collapsed .deck-topbar-bar {
    padding-left: 12px;
  }
  /* The tab row (List/Stats/Sample hand/Notes) ran off-screen with no way to
     reach it. Let it scroll horizontally in its own lane instead of pushing
     the rest of the bar off screen. */
  .deck-topbar-tabs {
    flex: 1 1 0%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
.deck-topbar-tabs {
  margin-left: 4px;
}
.deck-topbar-status {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--color-text-strong);
  cursor: default;
  display: inline-flex;
  font: inherit;
  font-size: var(--font-size-sm);
  gap: 6px;
  /* BEN-382: keep status left-aligned with the rest of the topbar instead of
     pushing it to the far right. */
  margin-left: 4px;
  padding: 4px 0;
  text-transform: none;
  white-space: nowrap;
}
.deck-topbar-status-sep {
  color: var(--color-text-muted);
}
.deck-topbar-status-legal .deck-topbar-status-legality {
  color: var(--color-success);
}
.deck-topbar-status-illegal .deck-topbar-status-legality {
  color: var(--color-danger);
}
.deck-topbar-status-count-under .deck-topbar-status-count {
  color: var(--color-warn);
}
.deck-topbar-status-count-over .deck-topbar-status-count {
  color: var(--color-danger);
}
.deck-topbar-status-count-ok .deck-topbar-status-count {
  color: var(--color-success);
}
/* ---- Shared modal shell ---- */
.ui-modal,
.deck-details-modal,
.confirm-modal {
  align-items: center;
  background: var(--color-overlay-soft);
  display: none;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 100;
}
.deck-details-modal {
  z-index: 100;
}
/* A confirm has to sit above whatever raised it, including the right-side
   drawers (1101) — the large-undo gate is reached from the history panel. The
   toast stack is lifted above it in turn (see .toast-stack below), so an error
   or progress toast raised while a confirm is open stays readable. */
.confirm-modal {
  z-index: 1350;
}
/* BEN-1017: same problem as .confirm-modal above, one link down the chain —
   the whole csv-import flow (staged preview, header mapper, receipt) is
   reached from the add-cards drawer (.app-right-layer, z-index 170) via
   paste/upload, and the drawer is never closed while the flow runs. Riding
   the shared .ui-modal z-index (100) let the still-open drawer paint over
   these modals' right-anchored actions: #csvImportConfirm existed in the DOM
   and was enabled, but sat visually and interactively behind the drawer
   panel, so it never became clickable. */
.csv-import-modal,
.csv-header-mapper-modal,
.import-receipt-modal {
  z-index: 180;
}
/* Above .confirm-modal — a failed save or a running resolve must not be dimmed
   out of existence behind a confirm scrim. */
.toast-stack {
  z-index: 1400;
}
.ui-modal.visible,
.deck-details-modal.visible,
.confirm-modal.visible {
  display: flex;
}
.ui-modal-card,
.deck-details-modal-card,
.confirm-modal-card {
  background: var(--color-surface);
  /* BEN-610: card border/shadow come from the vellum modal tokens. */
  border: var(--vui-modal-card-border);
  box-shadow: var(--vui-modal-card-shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  /* iOS: 100vh exceeds the visible area while Safari's bars are showing. */
  max-height: calc(100dvh - 32px);
  /* The card is the positioning context for the corner .rune-close;
     body-scroll clipping lives on the inner *-body (overflow-y: auto). */
  position: relative;
  overflow: visible;
}
.ui-modal-body,
.deck-details-modal-body,
.confirm-modal-body {
  /* BEN-451: inner scroll lives here now that the card no longer clips. */
  min-height: 0;
  overflow-y: auto;
}
.confirm-modal-card {
  width: min(420px, calc(100vw - 32px));
}
/* Vellum owns the modal head's visual chrome. Tomebound matches the feedback
   surface's canonical minimum height so every headed dialog keeps one rhythm. */
.ui-modal-head {
  align-items: center;
  min-height: 44px;
  padding: 0 14px 0 16px;
}
.ui-modal-title,
.drawer-title,
.ui-drawer-title {
  font-size: var(--font-size-md);
  font-weight: 650;
  line-height: 1.25;
  margin: 0;
  text-transform: none;
}
.ui-modal-head > .rune-close,
.ui-modal-head > :last-child .rune-close,
.drawer-head > .rune-close,
.ui-drawer-head > .rune-close {
  align-items: center;
  display: inline-flex;
  flex: 0 0 36px;
  height: 36px;
  justify-content: center;
  padding: 0;
  width: 36px;
}
.ui-modal-body,
.deck-details-modal-body,
.confirm-modal-body {
  padding: 14px 16px;
}
.confirm-modal-message {
  font-size: var(--font-size-md);
  line-height: 1.45;
  margin: 0;
  white-space: pre-line;
}
.ui-modal-actions,
.deck-details-modal-actions,
.confirm-modal-actions {
  border-top: var(--border-width) solid var(--color-line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
}
/* BEN-613: the one sanctioned prominent variant — buttons in modal action
   footers get extra padding. */
.ui-modal-actions .btn {
  padding: 7px 14px;
}
.confirm-modal .btn.confirm-modal-confirm-destructive {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
  color: var(--color-danger-text-plain);
}
.confirm-modal .btn.confirm-modal-confirm-destructive:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger-hover);
}
.deck-details-modal-card {
  width: min(640px, calc(100vw - 32px));
}
/* M-14: this modal is the only phone-reachable deck editor and previously had
   no way to delete the deck. Pinned to the opposite end of the footer from
   Cancel/Save, matching the danger-button convention used elsewhere. */
.deck-details-modal-actions .deck-details-delete {
  margin-right: auto;
}
.deck-details-modal-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}
.deck-details-modal-body {
  overflow-y: auto;
  padding-bottom: 18px;
}
.deck-create-modal .deck-details-modal-card {
  max-height: calc(100vh - 24px);
  /* iOS: 100vh exceeds the visible area while Safari's bars are showing. */
  max-height: calc(100dvh - 24px);
  overflow: visible;
}
.deck-create-modal .deck-details-modal-body {
  overflow-y: auto;
  padding-bottom: 12px;
}
.deck-create-modal .deck-meta-ac-wrap {
  z-index: 3;
}
.deck-create-modal .deck-meta-ac-list {
  max-height: min(52vh, 420px);
}
.csv-import-modal-card {
  width: min(900px, calc(100vw - 32px));
}
.csv-import-modal-body {
  display: grid;
  gap: 12px;
  overflow: auto;
}
.csv-import-summary {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
.csv-import-summary-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.csv-import-controls {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}
.csv-import-location-field,
.csv-import-new-location-field,
.csv-import-tags-field,
.csv-import-duplicate-field {
  display: grid;
  flex: 1 1 180px;
  gap: 5px;
  min-width: min(220px, 100%);
}
.csv-import-location-field {
  flex-basis: 260px;
}
/* BEN-1000: [icon | name] for the inline new-container field — same shared
   icon picker as every other destination picker. */
.csv-import-new-location-group {
  align-items: stretch;
}
.csv-import-new-location-input {
  flex: 1;
  min-width: 0;
}
.csv-import-tags-field {
  flex-basis: 220px;
}
.csv-import-duplicate-field {
  flex-basis: 240px;
}
.csv-import-field-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  letter-spacing: var(--label-tracking);
  text-transform: none;
}
.csv-import-preview-wrap {
  border: var(--border-width) solid var(--color-line);
  max-height: min(52vh, 420px);
  overflow: auto;
}
.csv-import-preview-table {
  min-width: 900px;
  table-layout: fixed;
}
.csv-import-preview-table tbody tr:hover {
  background: transparent;
  cursor: default;
}
.csv-import-cell {
  white-space: nowrap;
}
.csv-import-cell-name {
  width: 220px;
}
.csv-import-cell-setCode,
.csv-import-cell-cn,
.csv-import-cell-qty,
.csv-import-cell-language,
.csv-import-cell-finish {
  width: 88px;
}
.csv-import-cell-condition {
  width: 120px;
}
.csv-import-cell-status {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 190px;
  white-space: normal;
}
.csv-import-row-override {
  font-size: var(--font-size-xxs);
}

/* Header mapper modal (BEN-984 criterion 2) */
.csv-header-mapper-modal-card {
  width: min(560px, calc(100vw - 32px));
}
.csv-header-mapper-intro {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin: 0 0 10px;
}
.csv-header-mapper-fields {
  display: grid;
  gap: 10px;
  max-height: min(52vh, 420px);
  overflow: auto;
}
.csv-header-mapper-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.csv-header-mapper-field-label {
  display: grid;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.csv-header-mapper-select {
  font-family: var(--font-mono);
}
.csv-header-mapper-sample {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
}

/* Import receipt modal (BEN-984 criterion 3) */
.import-receipt-modal-card {
  width: min(440px, calc(100vw - 32px));
}
.import-receipt-counts {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
.import-receipt-destination {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.import-receipt-warning {
  margin-top: 6px;
}

/* Export receipt modal (BEN-988 criterion 4) */
.export-receipt-modal-card {
  width: min(400px, calc(100vw - 32px));
}
.export-receipt-summary {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
.export-receipt-detail {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.export-receipt-warning {
  margin-top: 6px;
}
.deck-details-modal-body .deck-metadata-form {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}
.deck-details-modal-body .deck-metadata-title,
.deck-details-modal-body .deck-metadata-description {
  grid-column: 1 / -1;
}
.deck-hero-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  min-width: 0;
  justify-content: flex-start;
}
.deck-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.deck-hero-actions .btn {
  white-space: nowrap;
}
.deck-workspace .deck-workspace-controls {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  overflow: visible;
}
.deck-workspace-nav-row {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
  padding: 8px 0;
  border-bottom: var(--border-width) solid var(--color-line);
}
.deck-workspace-nav {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}
.deck-mode-tabs-secondary .segment-btn:not(.active) {
  color: var(--color-text-muted);
}
.deck-build-mode-toggle {
  align-items: center;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--font-size-xs-plus);
  gap: 6px;
  margin-left: auto;
  white-space: nowrap;
}
.deck-build-mode-toggle input {
  margin: 0;
}
.deck-context-controls {
  align-items: flex-end;
  display: flex;
  gap: 10px;
  padding: 8px 0;
}
.deck-toolbar-field {
  align-items: center;
  color: var(--color-text-muted);
  display: inline-flex;
  font-size: var(--font-size-xs-plus);
  gap: 6px;
  white-space: nowrap;
}
.deck-toolbar-field > span {
  font-weight: 600;
  text-transform: none;
}
.deck-toolbar-field select {
  min-width: 136px;
}
.deck-display-menu > label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-height: 30px;
}
.deck-display-menu input[type='checkbox'] {
  margin: 0;
}
.deck-display-menu .deck-card-size-control {
  display: grid;
  gap: 8px;
  border: 0;
  margin: 0;
  padding: 0;
}
.deck-display-menu .deck-card-size-control legend {
  padding: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
}
.deck-view-settings-wrap {
  position: relative;
}
.deck-display-menu-trigger {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}
.deck-display-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}
.deck-display-menu .deck-card-size-row {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.deck-display-menu .deck-control-label {
  white-space: nowrap;
}
.deck-view-settings-fieldset {
  border: 0;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
}
/* BEN-459: deck mode tabs, ownership toggle, card size, and group-by all
   consume the shared .segmented / .segment-btn component — appearance lives
   there now. */
/* Decklist mode: drop the ownership/physical-location surface so the
     deck reads as a clean list (for sharing, tournament reports, etc.).
     Placeholder opacity is gated by .deck-ownership-building above, so
     here we only need to hide the location chips. */
body.deck-ownership-decklist .deck-row-loc {
  display: none;
}
.deck-gallery-mode,
.deck-gallery-groups {
  display: grid;
  gap: 18px;
}
.deck-gallery-board {
  padding: 14px;
}
.deck-gallery-group {
  min-width: 0;
}
.deck-gallery-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: var(--border-width) solid var(--color-line);
  margin-bottom: 9px;
  padding-bottom: 5px;
}
.deck-gallery-group-header h4 {
  margin: 0;
  color: var(--color-text-strong);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: none;
}
.deck-gallery-group-toggle {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 6px;
  padding: 0;
}
.deck-gallery-group-chevron {
  display: inline-flex;
  transform: rotate(90deg);
  transition: transform var(--motion-fast) ease;
}
.deck-gallery-group-toggle[aria-expanded='false'] .deck-gallery-group-chevron {
  transform: rotate(0);
}
.deck-gallery-group[data-collapsed] .deck-gallery-group-header {
  margin-bottom: 0;
}
.deck-gallery-grid[hidden] {
  display: none;
}
.deck-gallery-group-header span {
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  font-variant-numeric: tabular-nums;
}
.deck-gallery-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--deck-card-w)), var(--deck-card-w))
  );
  gap: 14px;
  align-items: start;
}
.deck-gallery-grid .deck-card {
  margin-top: 0;
}
.deck-visual-group-by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs-plus);
  text-transform: none;
}
.deck-export-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
.deck-visual-price-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-text-strong);
  font-size: var(--font-size-xs-plus);
  text-transform: none;
}
.deck-visual-price-toggle input {
  margin: 0;
}
.deck-details-editor {
  border: var(--border-width) solid var(--color-line);
  background: var(--color-surface-raised);
  margin-top: 0;
  padding: 12px;
}
.deck-metadata-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: start;
}
.deck-metadata-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
/* BEN-613: deck metadata fields ride the shared ledger field base; only
   layout lives here. */
.deck-metadata-form input,
.deck-metadata-form textarea,
.deck-metadata-form select {
  min-width: 0;
  text-transform: none;
}
.deck-metadata-form .deck-format-select {
  width: 100%;
}
.deck-create-collection-check {
  align-items: center;
  color: var(--color-text-strong);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--font-size-sm);
  gap: 7px;
  justify-self: start;
  text-transform: none;
}
.deck-create-collection-check input {
  margin: 0;
}
.deck-metadata-description {
  grid-column: 1 / -1;
}
.deck-format-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.deck-meta-ac-wrap {
  position: relative;
  display: block;
}
.deck-meta-ac-list {
  font-size: var(--font-size-sm);
}
.deck-meta-ac-row {
  align-items: center;
  display: flex;
  gap: 8px;
  padding: 4px 8px;
}
.deck-meta-ac-row-colors {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 32px;
  padding-left: 4px;
}
.deck-meta-ac-row-colors .deck-color-pip {
  font-size: var(--font-size-xs);
  height: 18px;
  margin-left: -4px;
  width: 18px;
}
.deck-meta-ac-row-colors .deck-color-pip:first-child {
  margin-left: 0;
}
.deck-meta-ac-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.deck-meta-ac-name {
  color: inherit;
  font-size: var(--font-size-md);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-meta-ac-type {
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-meta-ac-list li.highlight .deck-meta-ac-type,
.deck-meta-ac-list li:hover .deck-meta-ac-type {
  color: var(--color-line);
}
.deck-meta-ac-pill {
  align-items: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  display: inline-flex;
  gap: 8px;
  max-width: 100%;
  padding: 4px 4px 4px 4px;
}
.deck-meta-ac-pill-name {
  flex: 1;
  font-size: var(--font-size-md);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-meta-ac-pill-colors {
  display: inline-flex;
  flex: 0 0 auto;
  padding-left: 4px;
}
.deck-meta-ac-pill-colors .deck-color-pip {
  font-size: var(--font-size-xxxs);
  height: 16px;
  margin-left: -4px;
  width: 16px;
}
.deck-meta-ac-pill-colors .deck-color-pip:first-child {
  margin-left: 0;
}
.deck-metadata-form[data-format=''] .deck-metadata-commander,
.deck-metadata-form[data-format=''] .deck-metadata-partner,
.deck-metadata-form:not([data-format='commander']) .deck-metadata-commander,
.deck-metadata-form:not([data-format='commander']) .deck-metadata-partner {
  display: none;
}
.deck-metadata-form[data-format='commander'] .deck-metadata-cover {
  display: none;
}
.deck-companion-add {
  padding: 7px 8px;
  text-align: left;
}
.deck-card-size-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
.deck-visual-card-size {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.deck-control-label {
  color: inherit;
}
.deck-card-size-segmented {
  align-self: flex-start;
}
.deck-metadata-form textarea {
  min-height: 84px;
  resize: vertical;
}
.deck-metadata-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.deck-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}
.deck-stat-card,
.deck-surface {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  padding: 0;
}
.deck-stat-card h3,
.deck-board-header h3 {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: 600;
  text-transform: none;
}
.deck-stats-curve-footer {
  border-top: var(--border-width) solid var(--color-line);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs-plus);
  margin-top: 8px;
  padding-top: 6px;
  text-align: right;
}
.deck-stats-legality-illegal {
  border-color: var(--color-danger-line);
}
.deck-stats-legality-legal {
  border-color: var(--color-success-line);
}
.deck-stats-legality-issues {
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  margin: 6px 0 0;
  padding-left: 18px;
}
.deck-validation-summary {
  border: var(--border-width) solid var(--color-line);
  background: var(--color-surface-raised);
  padding: 8px;
  font-size: var(--font-size-sm);
}
.deck-validation-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.deck-validation-summary-illegal {
  border-color: var(--color-danger-line);
  background: var(--color-danger-soft);
}
.deck-validation-summary-pending {
  border-color: var(--color-warn-line-soft);
  background: var(--color-warn-soft-pale);
}
.deck-card-invalid .deck-card-face {
  outline: 2px solid var(--color-danger-strong);
  outline-offset: 2px;
}
.deck-card-validation,
.deck-row-validation {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  font-size: var(--font-size-xxs);
  color: var(--color-danger);
}
.deck-card-validation span,
.deck-row-validation span {
  border: 1px solid var(--color-danger-line);
  background: var(--color-danger-soft);
  padding: 1px 4px;
}
.deck-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.deck-content-grid-single {
  grid-template-columns: minmax(0, 1fr);
}
.deck-board-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.deck-board-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 18px;
  align-items: start;
}
.deck-board-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: var(--border-width) solid var(--color-line);
  margin-bottom: 12px;
  padding-bottom: 8px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs-plus);
}
.deck-board-header > .deck-section-heading,
.deck-board-header > .deck-section-actions {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.deck-board-header > .deck-section-heading {
  justify-content: flex-start;
}
.deck-board-header > .deck-section-actions {
  justify-content: flex-end;
}
.deck-section-summary {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.deck-side-stack {
  display: flex;
  flex-direction: column;
  position: relative;
  width: min(100%, var(--deck-card-w));
}
.deck-text-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 360px;
  overflow: auto;
  font-size: var(--font-size-xs-plus);
}
.deck-text-list-full {
  max-height: none;
}
.deck-text-mode {
  display: grid;
  gap: 12px;
}
.deck-text-mode .deck-text-table {
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  min-width: 960px;
  table-layout: auto;
  width: 100%;
}
.deck-text-table-scroll {
  overflow-x: auto;
}
.deck-text-table th,
.deck-text-table td {
  padding: 7px 8px;
  text-align: left;
  vertical-align: middle;
}
.deck-text-table th {
  white-space: nowrap;
}
.deck-text-table th button,
.deck-text-table .deck-text-name button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  padding: 0;
  text-align: left;
}
.deck-text-table th button:hover,
.deck-text-table .deck-text-name button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.deck-text-qty {
  font-variant-numeric: tabular-nums;
  text-align: right !important;
  width: 48px;
}
.deck-text-mana {
  min-width: 100px;
  white-space: nowrap;
}
.deck-text-tags {
  min-width: 150px;
}
.deck-text-table tbody tr:hover {
  cursor: pointer;
}
.deck-text-table .board-cell {
  width: 60px;
  white-space: nowrap;
}
.decklist-mode {
  display: grid;
  gap: 18px;
}
.decklist-options,
.decklist-totals {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.decklist-options {
  border-bottom: var(--border-width) solid var(--color-line);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs-plus);
  justify-content: flex-end;
  padding-bottom: 10px;
}
.decklist-totals {
  margin-left: auto;
}
.decklist-board {
  break-inside: avoid;
  min-width: 0;
}
.decklist-board-head,
.decklist-group-head {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
}
.decklist-board-head {
  border-bottom: var(--border-width) solid var(--color-line);
  margin-bottom: 10px;
  padding-bottom: 5px;
}
.decklist-board-head h3,
.decklist-group-head h3,
.decklist-group-head h4 {
  margin: 0;
  white-space: nowrap;
}
.decklist-board-head > span,
.decklist-group-head > span {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.decklist-board-columns {
  display: grid;
  gap: 18px 28px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  align-items: start;
}
.decklist-board-layout {
  align-items: start;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
}
.decklist-secondary-boards {
  display: grid;
  gap: 18px;
}
.decklist-column,
.decklist-lines {
  display: grid;
}
.decklist-column {
  align-content: start;
  gap: 16px;
}
.decklist-group-head {
  border-bottom: var(--border-width) solid var(--color-line);
  margin-bottom: 3px;
  padding-bottom: 2px;
}
.decklist-commander-group {
  width: 100%;
}
.decklist-group {
  min-width: 0;
}
.decklist-line {
  align-items: center;
  aspect-ratio: auto;
  border-bottom: var(--border-width) dotted var(--color-line);
  display: grid;
  gap: 8px;
  grid-template-columns:
    minmax(0, 1fr) minmax(0, var(--decklist-mana-width, 6em)) var(--decklist-value-width, 8ch)
    auto;
  margin: 0;
  min-height: 30px;
  position: relative;
}
.decklist-line-open {
  align-items: baseline;
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  font: inherit;
  gap: 8px;
  grid-template-columns: 2.2ch minmax(0, 1fr);
  min-width: 0;
  padding: 4px 0;
  text-align: left;
}
.decklist-line-open:hover .decklist-line-name,
.decklist-line-open:focus-visible .decklist-line-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.decklist-line-qty {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.decklist-line-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.decklist-line-mana,
.decklist-line-needed,
.decklist-line-price {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.decklist-line-mana {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 0;
  min-width: 0;
}
.decklist-line > .deck-card-menu {
  grid-column: 4;
}
.decklist-line > .deck-card-menu-btn {
  grid-column: 4;
  grid-row: 1;
}
.decklist-line-mana .mana-symbol {
  flex: 0 0 auto;
}
.deck-color-legend-row > span:first-child {
  display: flex;
  align-items: center;
  gap: 5px;
}
.mana-symbol {
  display: inline-block;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.2em;
  width: 1.15em;
}
.decklist-line-unowned .decklist-line-name {
  color: var(--color-text-muted);
}
.decklist-line > .deck-card-menu-btn {
  inset: auto;
  opacity: 0;
  position: relative;
}
.decklist-line:hover > .deck-card-menu-btn,
.decklist-line:focus-within > .deck-card-menu-btn {
  opacity: 1;
}
@media (max-width: 700px) {
  .decklist-board-columns,
  .decklist-board-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .decklist-options {
    justify-content: flex-start;
  }
  .decklist-totals {
    margin-left: 0;
    width: 100%;
  }
  .decklist-commander-group {
    max-width: none;
  }
}
@media print {
  .app-left,
  .app-right,
  .deck-hero-actions,
  .deck-workspace-controls,
  .decklist-options,
  .deck-card-menu-btn,
  .deck-card-menu,
  .fab-cluster {
    display: none !important;
  }
  .decklist-mode,
  .decklist-board {
    break-inside: avoid;
  }
  .decklist-board-columns,
  .decklist-board-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .decklist-line {
    min-height: 22px;
  }
}
.board-pill {
  display: inline-block;
  padding: 1px 6px;
  border: var(--border-width) solid var(--color-line);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  border-radius: var(--radius-sharp);
}
.board-pill-main {
  background: var(--color-board-main-bg);
  color: var(--color-board-main-text);
  border-color: var(--color-board-main-line);
}
.board-pill-sideboard {
  background: var(--color-board-side-bg);
  color: var(--color-board-side-text);
  border-color: var(--color-board-side-line);
}
.board-pill-maybe {
  background: var(--color-board-maybe-bg);
  color: var(--color-board-maybe-text);
  border-color: var(--color-board-maybe-line);
}
.deck-text-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
  border-bottom: var(--border-width) solid var(--color-line);
  text-transform: none;
}
.deck-text-row span:last-child {
  color: var(--color-text-muted);
  white-space: nowrap;
}
/* Sample hand row — same renderDeckCard articles as the visual deck view,
     just laid out left-to-right instead of stacked. Inherits card-size from
     the parent .deck-workspace.deck-card-size-{small|medium|large}. */
.deck-hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  --deck-hand-card-width: 160px;
}
.deck-hand-status {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--font-size-sm);
  gap: 8px 18px;
  margin-bottom: 14px;
}
.deck-hand-status strong {
  color: var(--color-text-strong);
}
.deck-missing-acquire-actions {
  border-bottom: var(--border-width) solid var(--color-line);
  display: flex;
  gap: 8px;
  padding: 10px 0 12px;
}
.deck-mobile-mode-control {
  display: none;
}
/* Matches the breakpoint that hides .deck-workspace-nav (styles/responsive.css,
   max-width: 900px) — these two used different cutoffs (700 vs 900), so a
   width in between (e.g. a phone in landscape, ~756px) showed neither the
   segmented tabs nor this select: no way to switch deck view at all. */
@media (max-width: 900px) {
  .deck-mobile-mode-control {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
  }
  .deck-mobile-mode-control select {
    flex: 1 1 auto;
    min-width: 0;
  }
}
.deck-hand-cards .deck-card {
  width: var(--deck-hand-card-width);
  flex: 0 0 auto;
  margin-top: 0;
}
.deck-card-size-small .deck-hand-cards {
  --deck-hand-card-width: 120px;
}
.deck-card-size-large .deck-hand-cards {
  --deck-hand-card-width: 200px;
}
/* .deck-empty-state layers onto the shared .empty-state (vellum dashed-mono)
   base — only the deck-workspace deltas (bigger gap/padding) live here
   (BEN-689, D3). Markup pairs the two classes: class="empty-state
   deck-empty-state". */
.deck-empty-state {
  gap: 16px;
  padding: 80px 20px;
}
.deck-empty-prompt {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: 0;
  max-width: 480px;
  line-height: 1.5;
  text-transform: none;
}
.deck-empty-prompt code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface-sunken);
  padding: 1px 6px;
  border-radius: var(--radius-sharp);
  color: var(--color-text-muted);
}
.deck-empty-chips {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  max-width: 600px;
}
.deck-empty-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.deck-empty-group-label {
  font-size: var(--font-size-xs);
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-transform: none;
}
.deck-empty-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
/* .deck-empty-chip is a plain click-target wrapper around a real .ui-chip
   (locationPillMarkup) — BEN-689. It carries no chrome of its own (the old
   version double-styled: pill-shaped button chrome around an already-styled
   chip); hover/focus forwards onto the nested chip instead. */
.deck-empty-chip {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.deck-empty-chip:hover .ui-chip,
.deck-empty-chip:focus-visible .ui-chip {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
}
.deck-empty-chip:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* BEN-987: geometry-matched loading skeletons — layout only. The shimmer +
   prefers-reduced-motion handling live on vellum's .skeleton/.skeleton-line;
   nothing here duplicates that. */
.skeleton-table {
  width: 100%;
  border-collapse: collapse;
}
.skeleton-table td {
  border: 0;
  padding: 10px 12px;
}
.skeleton-table .skeleton-line {
  width: 100%;
}
.skeleton-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.skeleton-card {
  width: 110px;
}
.skeleton-card-art {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 7;
}

/* Deck page chrome: title and actions share a baseline; boards are headings. */
.deck-hero-title-row > .deck-hero-title {
  min-width: 0;
}
.deck-hero-title-row > .deck-hero-actions {
  align-items: baseline;
  flex-wrap: wrap;
  margin-left: auto;
}
.deck-hero-title-row .deck-hero-actions .btn {
  flex: 0 0 auto;
}
.deck-hero-meta-row {
  display: flex;
  align-items: start;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-width: 0;
  margin-top: 6px;
}
.deck-hero-meta-row:empty {
  display: none;
}
.deck-hero-meta-row .deck-description {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow-wrap: anywhere;
  margin: 0;
  min-width: 0;
  line-height: 1.5;
}
.deck-description-caption {
  flex: 1 1 20rem;
  min-width: 0;
}
.deck-hero-meta-row .deck-description.is-expanded {
  display: block;
}
.deck-description-toggle {
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--font-size-xs);
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.deck-description-toggle:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
.deck-hero-meta-row .deck-commander-hero {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  gap: 8px;
  min-width: 0;
  width: auto;
}
.deck-hero-meta-row .deck-commander-hero-arts {
  display: none;
}
.deck-hero-meta-row .deck-commander-hero-art-empty {
  display: none;
}
.deck-hero-meta-row .deck-commander-hero-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  max-width: none;
}
.deck-hero-meta-row .deck-commander-hero-names {
  display: flex;
  flex-direction: row;
  max-width: none;
  gap: 8px;
}
.deck-hero-meta-row .deck-commander-hero-name {
  font-size: var(--font-size-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-hero-meta-row .deck-commander-hero-kicker,
.deck-hero-meta-row .deck-commander-hero-pips {
  flex-shrink: 0;
}
.deck-hero-meta-row .deck-description {
  flex: 1;
}
.deck-hero-meta-row .deck-commander-hero-pips {
  margin: 0;
}
.deck-hero-meta-row .deck-color-pip {
  width: 16px;
  height: 16px;
}
.deck-summary-line {
  gap: 4px 8px;
}
.deck-summary-line > span + span::before {
  content: '\00b7';
  margin-right: 8px;
  color: var(--color-text-muted);
}
.deck-legality-details,
.deck-ownership-details {
  position: relative;
}
.deck-legality-details > p,
.deck-ownership-detail-body {
  position: absolute;
  z-index: 40;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-soft);
  padding: 12px;
  margin-top: 6px;
  width: min(380px, 80vw);
  max-height: 220px;
  overflow: auto;
}
.deck-workspace .deck-surface > .deck-board-header {
  border-bottom: var(--border-width) solid var(--color-line);
  padding: 0 0 8px;
  margin-bottom: 12px;
}
[data-deck-board-section] {
  scroll-margin-top: 150px;
}
[data-deck-board-section]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 4px;
}
.deck-total-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.deck-total-link:is(:hover, :focus-visible) {
  color: var(--color-text-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.deck-total-link:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
.deck-text-table .deck-text-board-heading th {
  padding: 16px 8px 8px;
  text-align: left;
  border-bottom: var(--border-width) solid var(--color-line);
  font-weight: 600;
}
.deck-text-board-heading span {
  color: var(--color-text-muted);
  font-weight: 400;
  margin-left: 8px;
}
@media (max-width: 700px) {
  .deck-workspace .deck-card .deck-card-quantity-pill {
    min-width: 44px;
  }
  .deck-card:is(:hover, :focus-within, .menu-open) .deck-card-quantity-pill {
    padding-inline: 12px;
  }
  .deck-hero-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .deck-hero-title-row > .deck-hero-actions {
    margin-left: 0;
    gap: 4px;
    flex-wrap: nowrap;
  }
  .deck-hero-title-row .deck-hero-actions .btn {
    padding-inline: 7px;
  }
  .deck-hero-title-row .deck-share-btn .button-leading-icon {
    display: none;
  }
  .deck-hero-title-btn,
  .deck-hero-title-text,
  .deck-hero-identity {
    max-width: 100%;
    min-width: 0;
  }
  .deck-hero-identity .entity-label-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .deck-ownership-details > .deck-ownership-detail-body,
  .deck-legality-details > p {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
  }
}

.deck-summary-ownership-button.is-missing,
.decklist-line.is-missing .decklist-line-name,
.decklist-line.is-missing .decklist-line-needed,
.deck-text-table .is-missing .deck-text-name > .detail-trigger,
.deck-text-missing {
  color: var(--color-attention-text);
}
.deck-text-missing {
  margin-left: 8px;
  font-size: var(--font-size-xs);
}
.deck-summary-ownership-button.is-missing .deck-ownership-owned {
  color: var(--color-text);
}
.decklist-line.is-missing .decklist-line-name::before,
.deck-text-table .is-missing .deck-text-name > .detail-trigger::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--color-attention-text);
  vertical-align: middle;
}
.deck-card-missing-pill {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  padding: 1px 5px;
  border: 1px solid var(--color-attention-line);
  border-radius: var(--radius-pill);
  background: var(--color-attention-bg);
  color: var(--color-attention-text);
  font-size: var(--font-size-xs);
}
.deck-card-missing-count {
  top: 0;
  left: 0;
  right: auto;
  transform: translate(-45%, -45%);
  min-width: 1.5em;
  text-align: center;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  z-index: 4;
}
.deck-workspace .deck-stack .deck-card .deck-card-quantity-pill,
.deck-workspace .deck-side-stack .deck-card .deck-card-quantity-pill {
  top: 24px;
}
[data-deck-board-section] {
  --deck-board-rule: var(--color-board-main-line);
}
[data-deck-board-section='sideboard'] {
  --deck-board-rule: var(--color-board-side-line);
}
[data-deck-board-section='maybe'] {
  --deck-board-rule: var(--color-board-maybe-line);
}
.deck-workspace .deck-surface[data-deck-board-section] > .deck-board-header,
.decklist-board[data-deck-board-section] > .decklist-board-head,
.deck-text-table [data-deck-board-section] .deck-text-board-heading th {
  border-bottom-color: var(--deck-board-rule);
}

/* Deck-wide controls precede view-specific tabs. */
.deck-hero-title-row,
.deck-hero-title-row > .deck-hero-actions {
  align-items: center;
}
.deck-hero-title-btn,
.deck-hero-title-text {
  gap: 8px;
  text-decoration: none;
}
.deck-hero-actions .deck-build-mode-toggle {
  min-height: 32px;
  margin: 0 8px 0 0;
  font-size: var(--font-size-sm);
}
.deck-hero-meta-row {
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.deck-description-caption {
  flex: 0 1 auto;
  width: 100%;
}
.deck-hero-meta-row .deck-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.deck-hero-meta-row .deck-commander-hero-body {
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .deck-hero-title-row > .deck-hero-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 6px;
  }
  .deck-hero-actions .deck-build-mode-toggle {
    margin-right: auto;
  }
}

@media (max-width: 600px) {
  .deck-hero-title-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .deck-hero-title-row > .deck-hero-title {
    width: 100%;
  }
}

/* Tomebound: collection home. Cascade order is declared in ../styles.css. */

/* Grid, locations, home views, and list/table view */
/* Grid view — paginated card slots, IRL grid mental model */
.grid-view {
  display: none;
}
.grid-view.active {
  display: block;
}
body.view-grid .grid-view.active {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}
.grid-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: space-between;
  min-height: 18px;
  position: relative;
  z-index: 5;
}
.grid-actions-primary {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.grid-explore-controls {
  align-items: stretch;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  font-size: var(--font-size-sm);
  gap: 8px;
  min-width: 185px;
}
.grid-control-field {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}
.grid-control-label {
  color: var(--color-text-muted);
}
.grid-control-field select,
.grid-search-input {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-square);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  height: 34px;
  padding: 4px 10px;
}
.grid-control-field select:focus,
.grid-search-input:focus {
  border-color: var(--color-text-strong);
  outline: none;
}
.grid-search-input {
  min-width: 132px;
  width: 16vw;
  max-width: 190px;
}
.grid-filter-menu {
  position: relative;
}
.grid-filter-menu > summary {
  list-style: none;
}
.grid-filter-menu > summary::-webkit-details-marker {
  display: none;
}
.grid-filter-trigger {
  align-items: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--font-size-sm);
  gap: 6px;
  height: 34px;
  padding: 4px 10px;
  text-transform: none;
}
.grid-filter-trigger svg,
.grid-price-toggle svg {
  display: block;
  flex: 0 0 auto;
  height: 16px;
  width: 16px;
}
.grid-filter-trigger:hover,
.grid-filter-trigger:focus-visible,
.grid-filter-menu[open] .grid-filter-trigger {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
  outline: none;
}
.grid-filter-menu.has-active-filters .grid-filter-trigger::after {
  background: var(--color-text-strong);
  border-radius: var(--radius-pill);
  content: '';
  height: 5px;
  margin-left: 6px;
  width: 5px;
}
.grid-filter-menu[open] .grid-explore-controls {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  box-shadow: var(--shadow-popover);
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
}
.grid-filter-menu:not([open]) .grid-explore-controls {
  display: none;
}
.grid-filter-menu .grid-control-field {
  align-items: stretch;
  flex-direction: column;
  gap: 3px;
}
.grid-filter-menu .grid-control-field select {
  min-width: 160px;
}
.grid-lens-reset {
  height: 34px;
  padding-bottom: 3px;
  padding-top: 3px;
}
.grid-price-toggle {
  align-items: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-square);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--font-size-sm);
  gap: 6px;
  height: 34px;
  padding: 4px 10px;
  text-transform: none;
}
.grid-price-toggle:hover,
.grid-price-toggle:focus-within {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
}
.grid-price-toggle input {
  height: 14px;
  margin: 0;
  width: 14px;
}
.grid-summary {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}
.grid-pages {
  display: flex;
  justify-content: center;
  min-width: 0;
}
body.view-grid .grid-pages {
  align-items: flex-start;
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
  min-height: 0;
  overflow: visible;
  padding-top: 8px;
}
.grid-pages-list {
  background: transparent;
  border: 0;
  border-radius: var(--radius-square);
  box-shadow: none;
  overflow-x: auto;
  padding: 0;
}
body.view-grid .grid-pages-list {
  align-items: stretch;
  justify-content: flex-start;
  overflow: auto;
}
.grid-list-table {
  flex: 1 0 100%;
  width: 100%;
}
.grid-list-table .col-check {
  display: none;
}
.grid-surface {
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-soft);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05); /* TODO: inset shadow token */
  box-sizing: border-box;
  display: flex;
  max-width: 100%;
  padding: clamp(10px, 1.2vh, 16px);
  width: fit-content;
}
.grid-page {
  display: grid;
  gap: clamp(10px, 1.1vh, 14px);
  width: min(var(--grid-page-width, 860px), calc(100vw - 40px));
}
body.view-grid .grid-page {
  height: auto;
  max-height: none;
  max-width: 100%;
  min-height: 0;
  min-width: 0;
}
.grid-page-4x3 {
  --grid-page-width: min(860px, max(600px, calc(96vh - 185px)));
}
.grid-page-3x3 {
  --grid-page-width: min(720px, max(480px, calc(72vh - 55px)));
}
.grid-page-2x2 {
  --grid-page-width: min(590px, max(360px, calc(72vh - 65px)));
}
.grid-slot {
  position: relative;
  aspect-ratio: 488 / 680;
  /* Slots are card-aspect and clip card images, so they wear the card radius. */
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-surface-placeholder);
  outline: var(--border-width) solid transparent;
  outline-offset: calc(-1 * var(--border-width));
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.18),
    var(--shadow-subtle);
  transition: none;
}
body.view-grid .grid-slot {
  height: auto;
  min-height: 0;
  width: 100%;
}
.grid-slot:hover {
  outline-color: var(--color-line-focus);
}
.grid-slot:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.grid-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.grid-slot .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 8px;
  text-align: center;
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  text-transform: none;
}
.grid-slot.is-foil::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: var(--gradient-card-foil);
}
.grid-slot.is-etched::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: var(--gradient-card-etched);
}
.grid-slot-empty {
  cursor: default;
  background: color-mix(in srgb, var(--color-surface-placeholder) 28%, transparent);
  box-shadow: none;
  border: 1px dashed color-mix(in srgb, var(--color-line-strong) 62%, transparent);
}
.grid-slot-empty:hover {
  transform: none;
  box-shadow: none;
}
.grid-empty-slot-label {
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  left: 8px;
  line-height: 1;
  position: absolute;
  pointer-events: none;
  top: 8px;
}
.grid-qty {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-overlay-strong);
  color: var(--color-text-inverse);
  font-size: var(--font-size-xxs);
  padding: 2px 6px;
  border-radius: var(--radius-sharp);
  backdrop-filter: blur(4px);
  z-index: 3;
}
.grid-price-badge {
  position: absolute;
  right: 8%;
  top: 12%;
  z-index: 4;
  background: var(--color-overlay-strong);
  color: var(--color-text-inverse);
  border-radius: var(--radius-sharp);
  padding: 4px 7px;
  font-size: var(--font-size-sm);
  line-height: 1;
  backdrop-filter: blur(4px);
}
.grid-page-4x3 .grid-price-badge {
  font-size: var(--font-size-xs);
  padding: 4px 7px;
}
.grid-page-2x2 .grid-price-badge {
  font-size: var(--font-size-base);
  padding: 5px 8px;
}
.grid-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}
.grid-nav.hidden {
  display: none;
}
.grid-page-indicator {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  min-width: 110px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.locations-view {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
}
.locations-view.active {
  display: block;
}
.container-identity-strip {
  align-items: center;
  border-bottom: var(--border-width) solid var(--color-line);
  display: flex;
  gap: 12px;
  margin: 0 0 14px;
  padding: 0 0 10px;
}
.collection-scope-header {
  background: var(--color-surface-raised);
}
body.view-grid .container-identity-strip {
  gap: 7px;
  margin-bottom: 8px;
}
body.view-list .container-identity-strip {
  gap: 7px;
  margin: 0;
  min-height: 54px;
  padding: 11px 16px;
}
.container-identity-strip.hidden {
  display: none;
}
.container-identity-edit-btn {
  flex: 0 0 auto;
  font-size: var(--font-size-xs);
  min-height: 28px;
  padding: 4px 9px;
}
.container-identity-actions {
  flex: 0 0 auto;
  position: relative;
}
.container-identity-menu-trigger {
  color: var(--color-text-muted);
  height: 28px;
  min-height: 28px;
  width: 28px;
}
.container-identity-menu-trigger:hover,
.container-identity-menu-trigger[aria-expanded='true'] {
  color: var(--color-text-strong);
}
.container-identity-menu {
  min-width: 176px;
}
.container-identity-share {
  margin-left: auto;
}
.container-identity-name,
.container-identity-name-static {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-xl);
  padding: 0 0 1px;
  text-align: left;
  text-transform: none;
}
.container-identity-name {
  border-bottom: 1px dotted var(--color-line);
  cursor: text;
}
.container-identity-name-static {
  border-bottom: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.container-identity {
  align-items: center;
  display: inline-flex;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
}

/* Shared icon-title geometry for page headers, sidebar rows, cards, chips and
   compact cells. Only the label is allowed to shrink; marks/counts/actions keep
   their alignment as names grow. */
.entity-label {
  --entity-icon-optical-size: 14px;
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-width: 0;
}
.entity-label-mark {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  height: 18px;
  justify-content: center;
  overflow: hidden;
  line-height: 0;
  width: 18px;
}
.entity-label-glyph {
  display: block;
  flex: 0 0 auto;
  height: 100%;
  line-height: 1;
  max-height: 100%;
  max-width: 100%;
  width: 100%;
}
.entity-label-text {
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entity-label-count,
.entity-label-action {
  flex: 0 0 auto;
}
.entity-label-count {
  margin-left: auto;
}
.entity-label--header {
  --entity-icon-optical-size: 18px;
  font-size: var(--font-size-xl);
  font-weight: 600;
  gap: 9px;
}
.entity-label--header > .entity-label-mark {
  height: 24px;
  width: 24px;
}
.entity-label--scope {
  --entity-icon-optical-size: 16px;
  font-size: var(--font-size-lg);
  font-weight: 600;
}
.entity-label--scope > .entity-label-mark {
  height: 20px;
  width: 20px;
}
.entity-label--card > .entity-label-mark {
  height: 32px;
  width: 32px;
}
.entity-label--card {
  --entity-icon-optical-size: 20px;
}
.entity-label--chip {
  --entity-icon-optical-size: 11px;
  gap: 4px;
}
.entity-label--chip > .entity-label-mark,
.entity-label-mark--chip {
  height: 14px;
  width: 14px;
}
.entity-label--compact-table > .entity-label-mark {
  height: 16px;
  width: 16px;
}
.entity-label--compact-table {
  --entity-icon-optical-size: 12px;
}
.scope-option-identity,
.scope-option-group-identity {
  width: 100%;
}
.container-identity-edit-cue {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  margin-left: 7px;
  opacity: 0.7;
  transition:
    color var(--motion-fast),
    opacity var(--motion-fast);
}
.container-identity-name:hover,
.container-identity-name:focus-visible {
  border-bottom-color: var(--color-text-strong);
  outline: none;
  text-decoration: none;
}
.container-identity-name:hover .container-identity-edit-cue,
.container-identity-name:focus-visible .container-identity-edit-cue {
  color: var(--color-text-strong);
  opacity: 1;
}
.container-identity-spacer {
  flex: 1 1 auto;
  min-width: 16px;
}
.container-identity-edit {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-width: 0;
}
/* BEN-514: container edit modal — the shared container editor lives here, stacked. */
.container-edit-modal-card {
  width: min(420px, calc(100vw - 32px));
}
/* M-14: Delete has no path on a phone otherwise (no right-click, no sidebar
   Edit/Delete menu reachable via touch) -- pinned to the opposite end of the
   footer from Cancel/Save, matching the danger-button convention used
   elsewhere (e.g. detail's own delete button). */
.container-edit-modal-card .container-edit-delete {
  margin-right: auto;
}
.container-edit-modal-body .container-identity-edit {
  display: block;
  min-width: 0;
}

/* BEN-633: shared container editor — the one compact field set every container
   create/edit surface renders ([emoji|name] group, default-view segmented,
   label-color swatches). Markup lives in ui/containerEditor.js. */
.container-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
/* [emoji | name] uses Vellum's field-group frame. Only the emoji typography
   and compact input spacing are domain-specific. */
.container-editor-emoji-btn {
  /* BEN-759: <button>s don't inherit the app font — pin it so a chosen emoji
     renders in the Noto face. */
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  line-height: 1;
  padding: 0;
  width: 36px;
}
.container-editor-icon,
.container-identity-emoji,
.scope-option-icon,
.location-card-emoji,
.ui-chip-emoji {
  display: inline-block;
  height: 1em;
  object-fit: contain;
  width: 1em;
}
.container-editor-icon {
  height: 17px;
  width: 17px;
}
.container-editor-icon-mark {
  height: 18px;
  overflow: visible;
  width: 18px;
}
.container-icon-glyph {
  fill: none;
  overflow: visible;
}
.container-icon-emoji {
  font-family: var(--font-mono);
  line-height: 1;
}
.entity-label-glyph.container-icon-emoji {
  align-items: center;
  display: flex;
  font-family: 'Noto Color Emoji', sans-serif;
  font-size: var(--entity-icon-optical-size);
  font-variant-emoji: emoji;
  justify-content: center;
  line-height: 1;
  text-align: center;
  transform: translateY(-1px);
}
.container-editor-icon-mark > .entity-label-glyph.container-editor-icon {
  transform: none;
}
.container-editor-emoji-btn.is-empty {
  color: var(--color-line);
}
/* Vellum removes the inner input chrome; this is domain-specific spacing. */
.container-editor-name-group .container-editor-name-input {
  padding: 7px 10px;
  text-transform: none;
}
.container-editor-field {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.container-editor-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: none;
}
.container-editor-view-toggle {
  display: inline-flex;
  width: fit-content;
}
.segment-btn-with-icon {
  gap: 6px;
}
.container-editor-view-option input[type='radio'] {
  height: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 0;
}
.container-editor-view-option input:focus-visible + span {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
.container-editor-view-icon {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  justify-content: center;
  height: 15px;
  width: 15px;
}
.container-editor-view-icon svg {
  fill: none;
  height: 15px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.25;
  width: 15px;
}

.container-icon-picker {
  background: var(--color-surface-raised);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  max-height: min(480px, calc(100vh - 32px));
  /* iOS: 100vh exceeds the visible area while Safari's bars are showing. */
  max-height: min(480px, calc(100dvh - 32px));
  padding: 10px;
  width: min(380px, calc(100vw - 24px));
  z-index: 1300;
}
.container-icon-picker[hidden] {
  display: none;
}
.container-icon-picker-head {
  align-items: center;
  display: flex;
  gap: 6px;
}
.container-icon-picker-search {
  min-width: 0;
  width: 100%;
}
.container-icon-picker-clear {
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
}
.container-icon-picker-tabs {
  border-bottom: var(--border-width) solid var(--color-line);
  display: flex;
  gap: 14px;
  margin-top: 6px;
}
.container-icon-picker-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 7px 1px 6px;
}
.container-icon-picker-tab.active {
  border-bottom-color: var(--color-accent);
  color: var(--color-text-strong);
  font-weight: 700;
}
.container-icon-picker-grid {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: auto;
  padding: 8px 0 4px;
}
.container-icon-picker-item {
  align-items: center;
  background: transparent;
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font: inherit;
  gap: 4px;
  justify-content: center;
  min-height: 58px;
  padding: 6px 3px;
}
.container-icon-picker-item:hover,
.container-icon-picker-item:focus-visible {
  background: var(--color-surface-sunken);
  border-color: var(--color-line);
  outline: none;
}
.container-icon-picker-icon {
  display: block;
  height: 24px;
  object-fit: contain;
  width: 24px;
}
.container-icon-picker-item > span:not(.container-icon-picker-icon):not(.sr-only) {
  font-size: var(--font-size-xxs);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.container-icon-picker-item > .sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
.container-icon-custom-emoji {
  display: flex;
  flex-direction: column;
  gap: 5px;
  grid-column: 1 / -1;
  margin-bottom: 5px;
}
.container-icon-custom-emoji label,
.container-icon-picker-credit,
.container-icon-picker-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.container-icon-picker-credit {
  border-top: var(--border-width) solid var(--color-line);
  margin: 5px 0 0;
  padding-top: 8px;
}
.container-editor-swatch-row {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}
.container-editor-swatch {
  align-items: center;
  appearance: none;
  background: var(--container-editor-swatch-color);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: 2px;
  display: inline-flex;
  height: 24px;
  justify-content: center;
  margin: 0;
  padding: 0;
  width: 24px;
}
.container-editor-swatch:hover,
.container-editor-swatch:focus-visible {
  border-color: var(--color-text-muted);
  outline: none;
}
/* Keep selection visible without changing the square's geometry or obscuring
   the color. */
.container-editor-swatch.active {
  border-color: var(--color-accent);
  outline: 1px solid var(--color-accent);
  outline-offset: 1px;
}
.ds-container-editor-frame {
  max-width: 340px;
}

/* BEN-431: the storage "new container" trigger bar (the form moved into a
   modal that mirrors the deck-create flow). */
.locations-create-bar {
  display: flex;
  padding: 10px 0 18px;
  border-bottom: var(--border-width) solid var(--color-line);
  margin-bottom: 18px;
}
.locations-create-trigger-plus {
  font-size: 1.1em;
  line-height: 1;
}
.locations-group {
  margin-bottom: 28px;
}
.locations-group-title {
  font-size: var(--font-size-sm);
  text-transform: none;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.locations-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}
.location-index {
  margin: 0 auto;
  max-width: 1100px;
  width: 100%;
}
.location-index-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 0 12px;
  min-height: 36px;
}
.location-index-identity {
  color: var(--color-text-strong);
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: none;
}
.location-index-grid {
  align-items: stretch;
}
.location-index-create-card {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 1px dashed var(--color-line-strong);
  border-radius: var(--radius-soft);
  color: var(--color-text-muted);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 12px;
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 132px;
  padding: 16px;
  text-align: left;
  text-transform: none;
}
.location-index-create-card:hover,
.location-index-create-card:focus-visible {
  background: color-mix(in srgb, var(--color-surface-raised) 92%, var(--color-accent-soft));
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
  outline: none;
}
.location-index-create-card:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.location-index-create-icon {
  align-items: center;
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sharp);
  display: inline-flex;
  height: 48px;
  justify-content: center;
  position: relative;
  width: 48px;
}
.location-index-create-glyph {
  height: 24px;
  width: 24px;
}
.location-index-create-plus {
  align-items: center;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line-strong);
  border-radius: 50%;
  bottom: -5px;
  display: inline-flex;
  font-size: var(--font-size-md);
  height: 20px;
  justify-content: center;
  position: absolute;
  right: -5px;
  width: 20px;
}
.location-index-create-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.location-index-create-copy strong {
  color: var(--color-text-strong);
  font-size: var(--font-size-lg);
  font-weight: 600;
}
.location-index-create-copy > span {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.location-index-empty {
  color: var(--color-text-muted);
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 2px;
}
/* BEN-1001: sort + compact-list toolbar, shown once a home has grown past
   LOCATION_HOME_TOOLBAR_THRESHOLD items. Control chrome (.grid-control-field,
   .segmented/.segment-btn) is reused from the grid lens / deck-create toggles
   rather than styled fresh. */
.location-index-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
}
.locations-list.is-compact {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.locations-list.is-compact .location-index-create-card {
  min-height: auto;
  grid-template-columns: 32px minmax(0, 1fr);
  padding: 10px 14px;
  gap: 10px;
}
.locations-list.is-compact .location-index-create-icon {
  height: 32px;
  width: 32px;
}
.locations-list.is-compact .location-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: auto;
  padding: 8px 12px;
}
.locations-list.is-compact .location-card.deck-home-card {
  padding: 8px 12px;
}
.locations-list.is-compact .location-card-head {
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
}
.locations-list.is-compact .location-card-identity-mark {
  flex: 0 0 24px;
  height: 24px;
  width: 24px;
}
.locations-list.is-compact .storage-card-emoji-tile {
  flex: 0 0 28px;
  height: 28px;
  font-size: var(--font-size-md);
  width: 28px;
}
.locations-list.is-compact .location-card-name {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: var(--font-size-md);
  padding: 0;
}
.locations-list.is-compact .location-card-name-text {
  order: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.locations-list.is-compact .location-card-name-meta {
  order: 1;
  min-height: auto;
  flex: 0 0 auto;
}
.locations-list.is-compact .location-card:not(.deck-home-card) .location-card-menu-btn {
  opacity: 1;
}
.locations-list.is-compact .location-card-stats {
  display: flex;
  flex: 0 0 auto;
  gap: 14px;
  margin: 0;
  padding: 0;
  border-top: 0;
}
.locations-list.is-compact .location-card-stats > div {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.locations-list.is-compact .location-card-stats dd {
  margin: 0;
}

.sealed-lot-collapsible {
  border: var(--border-width) solid var(--color-line);
  background: var(--color-surface);
  border-radius: var(--radius-soft);
  padding: 8px;
}
.sealed-lot-summary {
  cursor: pointer;
  font-size: var(--font-size-sm-plus);
  color: var(--color-text-muted);
  list-style: none;
}
.sealed-lot-summary::-webkit-details-marker {
  display: none;
}
.sealed-lot-summary::before {
  content: '+';
  display: inline-block;
  margin-right: 6px;
}
.sealed-lot-collapsible[open] .sealed-lot-summary::before {
  content: '-';
}
.sealed-lot-create-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 90px auto;
  gap: 8px;
  margin: 10px 0 12px;
}
.sealed-lot-create-form input {
  width: 100%;
}
body.view-decks-home .locations-list {
  align-items: stretch;
}
.location-card {
  position: relative;
  border: var(--border-width) solid var(--color-line);
  background: var(--color-surface-raised);
  border-radius: var(--radius-soft);
  padding: 16px;
  min-height: 132px;
  cursor: pointer;
  transition:
    border-color var(--motion-fast),
    background-color var(--motion-fast),
    box-shadow var(--motion-fast);
}
.location-card:hover {
  border-color: var(--color-line-strong);
  background: color-mix(in srgb, var(--color-surface-raised) 94%, var(--color-accent-soft));
  box-shadow: 0 2px 8px rgba(43, 31, 23, 0.08);
}
.location-card:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.location-card:has(.location-card-open-btn:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.location-card-open-btn {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
.location-card.editing {
  cursor: default;
}
.location-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.location-card-identity {
  width: 100%;
}
.location-card-identity > .entity-label-text {
  flex: 1 1 auto;
}
.location-card-identity > .entity-label-action {
  align-self: center;
  margin-left: auto;
}
.location-card-identity-mark {
  font-size: var(--font-size-xl);
}
.storage-card-emoji-tile {
  align-items: center;
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-soft);
  display: inline-flex;
  flex: 0 0 42px;
  font-size: var(--font-size-xl);
  height: 42px;
  justify-content: center;
}
.location-card-name {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: var(--font-size-xl);
  margin: 0;
}
.location-card-name-meta {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-height: 24px;
}
.location-card-name-meta:has(> .location-card-actions:only-child) {
  justify-content: flex-end;
  min-height: 14px;
}
.scope-option-group-destination.is-selected {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.location-card-kicker {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.05em;
  text-transform: none;
}
.location-card-emoji {
  flex: 0 0 auto;
  line-height: 1;
}
.location-card-name-text {
  flex: 1;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: anywhere;
}
/* BEN-955: storage names own the full identity row. Actions live with the
   quiet kicker above, so a long name can wrap instead of being sacrificed to
   edit/delete controls. */
:not(.deck-home-card) .location-card-name .location-card-name-text {
  white-space: normal;
}
/* .icon-btn sized down to fit the card name row, with a muted glyph and a
   sunken hover backplate. */
.location-card-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  margin: -3px -4px -3px 0;
}
.location-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: var(--border-width) solid var(--color-line);
  font-variant-numeric: tabular-nums;
}
.location-card-stats > div {
  min-width: 0;
}
.location-card-stats dt {
  color: var(--color-text-muted);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.03em;
  text-transform: none;
}
.location-card-stats dd {
  color: var(--color-text-strong);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* BEN-613: location-card edit/menu buttons ride base .icon-btn chrome. */
.location-card-menu-btn {
  flex: 0 0 auto;
}
.location-card:not(.deck-home-card) .location-card-menu-btn {
  opacity: 0;
  transition: opacity var(--motion-fast);
}
.location-card:not(.deck-home-card):hover .location-card-menu-btn,
.location-card:not(.deck-home-card):focus-within .location-card-menu-btn,
.location-card:not(.deck-home-card).menu-open .location-card-menu-btn {
  opacity: 1;
}
.location-card-menu {
  position: absolute;
  top: 48px;
  right: 12px;
  z-index: 5;
  min-width: 100px;
  display: none;
}
.location-card.menu-open .location-card-menu {
  display: block;
}
.location-card-menu-item {
  color: var(--color-text-strong);
}
.location-card-menu-item:hover:not(:disabled) {
  background: var(--color-surface-sunken);
}
.location-card-menu-item.location-delete {
  color: var(--color-danger);
}
.location-card-menu-item.location-delete:hover:not(:disabled) {
  background: var(--color-danger-soft);
}
.location-card-menu-item:disabled {
  color: var(--color-line);
  cursor: not-allowed;
}
.location-card-edit-row {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: var(--border-width) solid var(--color-line);
}
.location-card.editing .location-card-edit-row {
  display: flex;
}
.location-card-edit-actions {
  display: flex;
  gap: 6px;
}
@media (hover: none) {
  .location-card:not(.deck-home-card) .location-card-menu-btn {
    opacity: 1;
  }
}

/* Decks home — commander art + format badge */
.deck-home-card {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}
.deck-home-art {
  width: 100%;
  height: 132px;
  overflow: hidden;
  border-radius: calc(var(--radius-soft) - var(--border-width))
    calc(var(--radius-soft) - var(--border-width)) 0 0;
  background: var(--color-surface-sunken);
  margin-bottom: 8px;
  position: relative;
}
.deck-home-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
}
.deck-home-art-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-line);
}
.deck-home-art-empty .card-sleeve,
.deck-home-add-art .card-sleeve {
  --card-sleeve-width: 76px;
  display: block;
}
.deck-home-card .location-card-name {
  align-items: center;
  flex-direction: row;
  gap: 6px;
  padding: 0 10px;
}
/* BEN-458: the deck title gets its own full-width row so long names
   (e.g. "Breya, Etherium Shaper - Bracket 4 Benson's Way") fill the chip
   and wrap there, instead of being squeezed into a column beside the format
   badge and the edit/menu controls. */
.deck-home-card-head {
  margin-bottom: 4px;
}
.deck-home-card-head-spacer {
  flex: 1;
  min-width: 0;
}
.deck-home-card .deck-home-card-title {
  padding: 0 10px;
  margin-bottom: 6px;
  font-size: var(--font-size-xl);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.deck-home-card .location-card-stats {
  border-top: 0;
  color: var(--color-text-muted);
  display: block;
  font-size: var(--font-size-sm);
  margin: 0;
  padding: 0 10px 4px;
}
.deck-home-card .location-card-edit-row {
  margin: 0 10px;
}
.deck-home-add-card {
  display: block;
  min-height: 206px;
  padding: 0 0 10px;
  text-align: left;
  transition:
    border-color var(--motion-fast),
    box-shadow var(--motion-fast),
    color var(--motion-fast);
  width: 100%;
}
.deck-home-add-card:hover,
.deck-home-add-card:focus-visible {
  box-shadow: var(--shadow-soft);
}
.deck-home-add-art {
  align-items: center;
  background: var(--surface-veil-warm-soft);
  border-bottom: 1px dashed var(--color-line-strong);
  display: flex;
  height: 132px;
  justify-content: center;
  margin-bottom: 8px;
  position: relative;
  width: 100%;
}
.deck-home-add-art .card-sleeve {
  opacity: 0.7;
}
.deck-home-add-plus {
  align-items: center;
  background: var(--color-bg);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-pill);
  display: inline-flex;
  font-size: var(--font-size-xl);
  height: 24px;
  justify-content: center;
  left: calc(50% + 12px);
  line-height: 1;
  position: absolute;
  top: calc(50% + 4px);
  width: 24px;
}
.deck-home-add-body {
  display: grid;
  gap: 5px;
  padding: 0 10px;
}
.deck-home-add-title {
  font-size: var(--font-size-xl);
  color: inherit;
}
.deck-home-add-stats {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}
/* .ui-chip base (BEN-689) — only the muted ink + placement deltas live here. */
.deck-home-badge {
  --ui-chip-ink: var(--color-text-muted);
  padding: 1px 6px;
  margin-left: 4px;
}
.deck-create-modal-card {
  width: min(520px, calc(100vw - 32px));
}
.deck-create-form {
  grid-template-columns: minmax(0, 1.3fr) minmax(128px, 0.7fr);
}
.deck-create-form .deck-metadata-title,
.deck-create-commander {
  grid-column: 1 / -1;
}
.deck-create-import-fields {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}
.deck-create-target-toggle {
  margin-top: 2px;
}

/* Deck-import dry run (BEN-1002) — same grammar as .csv-import-* (BEN-984):
   muted mono summary line, wrapping count chips, a scrollable line list. */
.deck-import-review {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}
.deck-import-review-detected {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
.deck-import-review-row {
  display: flex;
  gap: 6px;
}
.deck-import-review-row span:first-child {
  text-transform: none;
  font-size: var(--font-size-xxs);
  letter-spacing: var(--label-tracking);
}
.deck-import-review-boards,
.deck-import-review-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.deck-import-review-lines {
  border: var(--border-width) solid var(--color-line);
  max-height: min(40vh, 320px);
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.deck-import-review-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: var(--border-width) solid var(--color-line);
  font-size: var(--font-size-sm);
}
.deck-import-review-line:last-child {
  border-bottom: none;
}
.deck-import-review-line-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-import-review-line-board {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  text-transform: none;
}

/* Hide right sidebar on the new home shapes (alias of view-locations) */
body.view-decks-home .app-right,
body.view-storage-home .app-right {
  display: none;
}
/* Keep global utility FABs on home shapes; primary create actions live in-page. */
body.view-decks-home .fab-cluster,
body.view-storage-home .fab-cluster {
  display: flex;
}
body.view-decks-home .fab-btn[data-fab-target],
body.view-storage-home .fab-btn[data-fab-target] {
  display: none;
}
@media (min-width: 901px) {
  /* Keep utilities beside long home lists, including while scrolling. */
  body:is(.view-decks-home, .view-storage-home) .locations-view {
    box-sizing: border-box;
    width: calc(100% - 152px);
    margin-left: 0;
    margin-right: 152px;
  }
}

.location-card-reorder {
  cursor: grab;
  touch-action: none;
}
.location-card.is-drop-target {
  background: var(--color-surface-hover);
  outline: var(--focus-ring);
  outline-offset: -2px;
}
.location-card:hover {
  box-shadow: none;
}

.container-title-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-width: 0;
}
.title-edit-cue {
  opacity: 0;
  font: 16px/1 var(--font-body);
  flex: none;
}
:is(.container-title-edit, .deck-hero-title-btn):is(:hover, :focus-visible) .title-edit-cue {
  opacity: 0.65;
}
:is(.container-title-edit, .deck-hero-title-btn):focus-visible {
  outline: var(--focus-ring);
  outline-offset: 4px;
}

/* Tomebound: collection table. Cascade order is declared in ../styles.css. */

/* Only the table consumes this width. Inheriting each drag update through
   every card cell needlessly invalidates styles throughout a large collection. */
@property --collection-table-real-width {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 0px;
}

/* Table view (compact) */
.list-view {
  display: none;
}
/* Overscroll at the top must not bounce the fixed app shell behind it or
   trigger Safari's pull-to-refresh — #listView is the scroller in every
   view mode this table participates in. */
#listView {
  overscroll-behavior-y: contain;
}
.list-view.active {
  display: block;
}
/* BEN-638: zero-result filters show the vellum .empty-state inside the table. */
.collection-zero-results td {
  padding: 24px 12px;
}
.collection-zero-results .empty-state {
  max-width: 340px;
  margin: 0 auto;
}
/* BEN-666: the zero-results placeholder is a <tr> for layout purposes only —
   it isn't a data row, so it shouldn't carry the row border or hover affordance. */
.collection-zero-results {
  border-bottom: none;
}
.collection-zero-results:hover {
  background: none;
  cursor: default;
}
/* BEN-758: the filter/scope zero state reuses the vellum .card-sleeve (+
   .card-sleeve-tilt) — the exact tape-sealed, hover-tilt, flat treatment the
   empty collection-history drawer uses (see .history-empty-sleeve) — holding
   "One with Nothing" (the joke is the point), centered in the empty table
   region. */
.collection-zero-results-sleeve td {
  padding: 0;
}
.zero-sleeve-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 46vh;
  padding: var(--space-5) var(--space-3);
}
.collection-zero-sleeve {
  --card-sleeve-width: 146px;
}
.zero-sleeve-msg {
  margin: 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  text-transform: none;
  text-align: center;
}
/* BEN-999: zero-results filter debugger — the note about still-loading
   legality metadata, and the remove-this-filter / clear-all action row. */
.zero-sleeve-note {
  margin: 0;
  max-width: 340px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}
.zero-sleeve-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  max-width: 420px;
}
.zero-sleeve-filter-btn,
.zero-sleeve-clear-all {
  text-transform: none;
}
.grid.hidden {
  display: none;
}
table {
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  width: 100%;
}
#listView > table,
.grid-list-table,
.deck-text-table {
  min-width: max(100%, var(--collection-table-real-width, 100%));
  table-layout: fixed;
  width: 100%;
}
thead th {
  box-sizing: border-box;
  text-align: left;
  padding: 6px 8px;
  box-shadow: inset 0 -1px 0 var(--color-text-strong);
  font-size: var(--font-size-xxs);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  position: sticky;
  overflow: hidden;
  text-overflow: ellipsis;
  top: 0;
  background: color-mix(in srgb, var(--color-surface-raised) 86%, var(--color-surface));
  z-index: 10;
}
thead th[data-sort] {
  cursor: pointer;
  padding-inline: 10px;
  text-align: center;
  user-select: none;
  white-space: nowrap;
}
thead th[data-collection-column-reorder] {
  cursor: pointer;
  user-select: none;
}
thead th[data-sort]:hover {
  color: var(--color-text-strong);
}
thead th.sort-active {
  color: var(--color-text-strong);
  background: color-mix(in srgb, var(--color-accent-soft) 58%, var(--color-surface-raised));
}
.collection-header-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.collection-sort-icon {
  display: none;
  height: 14px;
  flex: 0 0 14px;
  width: 14px;
}
.collection-sort-icon svg {
  display: block;
  height: 100%;
  width: 100%;
}
thead th.sort-active .collection-sort-icon {
  display: inline-flex;
}
.collection-sort-icon [data-ink-icon='arrow-down'],
thead th[data-sort-direction='desc'] .collection-sort-icon [data-ink-icon='arrow-up'] {
  display: none;
}
thead th[data-sort-direction='desc'] .collection-sort-icon [data-ink-icon='arrow-down'] {
  display: block;
}
.button-with-icon {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}
.button-leading-icon {
  display: block;
  flex: 0 0 auto;
  height: 15px;
  width: 15px;
}
/* BEN-443: responsive header label. Both spans are rendered; JS measures the
   full label against the usable header width and toggles `hidden` to collapse
   to the short form. */
thead th .col-label-full,
thead th .col-label-short {
  display: inline;
}
thead th .col-label-full[hidden],
thead th .col-label-short[hidden] {
  display: none;
}
tbody tr {
  border-bottom: var(--border-width) solid var(--color-line);
}
tbody tr:hover {
  background: color-mix(in srgb, var(--color-accent-soft) 28%, var(--color-surface-raised));
  cursor: pointer;
}
/* iOS polish: rows have no :hover on touch, and -webkit-tap-highlight-color is
   now transparent (foundations.css) — give a tap its own brief feedback
   instead of leaving it feeling dead. */
@media (pointer: coarse) {
  tbody tr:active {
    background: color-mix(in srgb, var(--color-accent-soft) 28%, var(--color-surface-raised));
  }
}
tbody tr.row-selected,
tbody tr.row-selected:hover {
  background: var(--color-warn-soft);
}
tbody tr.row-selected .muted {
  color: var(--color-text-strong);
}
/* BEN-992: marks the row currently open in the detail drawer (prev/next
   stepping updates this live) — an inset accent bar rather than a background
   swap so it composes cleanly with .row-selected instead of fighting it. */
tbody tr.detail-active-row {
  box-shadow: inset 3px 0 0 var(--color-accent);
}
tbody tr.row-added-flash {
  animation: row-added-flash 900ms ease-out 1;
}
@keyframes row-added-flash {
  0% {
    background: var(--color-success-soft);
  }
  100% {
    background: transparent;
  }
}
td {
  box-sizing: border-box;
  overflow: hidden;
  padding: 6px 8px;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.price-provenance {
  cursor: help;
  outline: none;
}
.price-provenance:focus-visible {
  border-radius: var(--radius-sharp);
  box-shadow: 0 0 0 2px var(--color-focus-ring);
}
/* `table-cells-wrap` opts text-heavy collection cells out of truncation so
   they can grow vertically and show full content. Affects name, location,
   tags, and (future) notes cells; structural columns (cn / set / rarity /
   finish / qty / price) stay compact even in wrap mode so the grid still
   scans. The default mode (no body class) keeps the original td truncation. */
body.table-cells-wrap td.card-name-cell,
body.table-cells-wrap td.location-cell,
body.table-cells-wrap td.tags-cell {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}
/* BEN-529: out-specify the truncation rule
   `body.view-list .list-view.active .card-name-cell .card-name-button` (0,5,1),
   which otherwise wins and keeps names ellipsized even in wrap mode. */
body.table-cells-wrap.view-list .list-view.active .card-name-cell .card-name-button,
body.table-cells-wrap.view-grid .grid-list-table .card-name-cell .card-name-button,
body.table-cells-wrap .deck-text-table .card-name-cell .card-name-button,
body.table-cells-wrap td.location-cell .loc-pill {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  max-width: none;
}
body.table-cells-wrap .tags-cell {
  display: table-cell;
}
body.table-cells-wrap .tags-cell .tag-cell-content {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  inset: auto;
  overflow: visible;
  position: static;
  white-space: normal;
}
body.table-cells-wrap .tags-cell .tag-chip {
  margin-right: 0;
}
body.view-list .list-view.active tbody td:not(.col-check),
body.view-grid .grid-list-table tbody td:not(.col-check),
.deck-text-table tbody td:not(.col-check) {
  /* Use one resolved line box even when book names and numeric metadata have
     different font sizes. Table baseline alignment handles their font metrics. */
  line-height: calc(var(--font-size-base) * var(--line-height-body));
  padding-top: 6px;
  padding-bottom: 6px;
  vertical-align: baseline;
}
body.collection-table-density-compact.view-list .list-view.active tbody td:not(.col-check),
body.collection-table-density-compact.view-grid .grid-list-table tbody td:not(.col-check),
body.collection-table-density-compact .deck-text-table tbody td:not(.col-check) {
  padding-top: 3px;
  padding-bottom: 3px;
}
@media (min-width: 901px) {
  #listView > table th[data-column-id='check'],
  #listView > table td[data-column-id='check'],
  .grid-list-table th[data-column-id='check'],
  .grid-list-table td[data-column-id='check'] {
    left: 0;
    position: sticky;
  }
  #listView > table th[data-column-id='name'],
  #listView > table td[data-column-id='name'],
  .grid-list-table th[data-column-id='name'],
  .grid-list-table td[data-column-id='name'] {
    left: var(--collection-table-name-left, 36px);
    position: sticky;
  }
  #listView > table th[data-column-id='check'],
  #listView > table th[data-column-id='name'],
  .grid-list-table th[data-column-id='check'],
  .grid-list-table th[data-column-id='name'] {
    z-index: 12;
  }
  #listView > table td[data-column-id='check'],
  #listView > table td[data-column-id='name'],
  .grid-list-table td[data-column-id='check'],
  .grid-list-table td[data-column-id='name'] {
    background: var(--color-bg);
    z-index: 2;
  }
  #listView.collection-table-has-horizontal-offset > table th[data-column-id='name'],
  #gridPages.collection-table-has-horizontal-offset .grid-list-table th[data-column-id='name'] {
    box-shadow:
      inset 0 -1px 0 var(--color-text-strong),
      var(--shadow-sticky-column);
  }
  #listView.collection-table-has-horizontal-offset > table td[data-column-id='name'],
  #gridPages.collection-table-has-horizontal-offset .grid-list-table td[data-column-id='name'] {
    box-shadow:
      inset -1px 0 0 var(--color-shell-divider),
      var(--shadow-sticky-column);
  }
  #listView > table tbody tr:hover > td,
  .grid-list-table tbody tr:hover > td {
    background: color-mix(in srgb, var(--color-accent-soft) 28%, var(--color-surface-raised));
  }
  #listView > table tbody tr.row-selected td[data-column-id='check'],
  #listView > table tbody tr.row-selected td[data-column-id='name'],
  .grid-list-table tbody tr.row-selected td[data-column-id='check'],
  .grid-list-table tbody tr.row-selected td[data-column-id='name'] {
    background: var(--color-warn-soft);
  }
}
body.view-list .list-view.active .card-name-cell .card-name-button,
body.view-grid .grid-list-table .card-name-cell .card-name-button,
.deck-text-table .card-name-cell .card-name-button {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-check {
  overflow: visible;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  text-overflow: clip;
}
.collection-select-control {
  align-items: center;
  display: grid;
  inline-size: 100%;
  justify-items: center;
  min-block-size: 100%;
}
.row-check,
.header-check {
  display: block;
  margin: 0;
}
.set-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
th[data-sort='set'],
.set-cell {
  width: 70px;
}
th[data-sort='cn'],
.cn-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 56px;
}
th[data-sort='finish'],
.finish-cell {
  width: 60px;
}
th[data-sort='rarity'],
.rarity-cell {
  width: 44px;
}
th[data-sort='condition'],
.condition-cell {
  width: 56px;
}
th[data-sort='qty'],
.qty-cell {
  width: 44px;
}
th[data-sort='price'],
.price-cell {
  width: 70px;
  white-space: nowrap;
}
.location-cell {
  width: 190px;
}
th.tags-header,
.tags-cell {
  width: 220px;
}
thead th[data-column-id][style*='--collection-column-width'],
tbody td[data-column-id][style*='--collection-column-width'] {
  width: var(--collection-column-width);
}
.collection-table-filler {
  padding-left: 0;
  padding-right: 0;
  width: auto;
}
.collection-table-filler-col {
  width: auto;
}
.collection-column-resize-handle {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  bottom: 0;
  cursor: col-resize;
  position: absolute;
  right: 0;
  top: 0;
  width: 10px;
  z-index: 11;
}
/* No rule between headers at rest: the centered headings already separate the
   columns. The resize rule appears on the header you hover or focus. */
.collection-column-resize-handle::after {
  background: transparent;
  content: '';
  display: block;
  position: absolute;
  top: 18%;
  bottom: 18%;
  right: 0;
  width: 1px;
}
thead th:hover .collection-column-resize-handle::after,
.collection-column-resize-handle:focus-visible::after,
body.collection-column-resizing .collection-column-resize-handle:active::after {
  background: var(--color-line-strong);
}
.collection-column-resize-handle:focus-visible {
  outline: var(--border-width) solid var(--color-text-muted);
  outline-offset: -1px;
}
/* Ink mixed with paper stays visible even when a theme aliases its hover
   surface to its resting surface. A handle is a control, not an accent rail. */
html[data-theme] table thead th[data-sort]:hover,
html[data-theme] table thead th[data-column-id]:focus-visible {
  background: color-mix(in srgb, var(--color-text-strong) 14%, var(--color-surface));
  color: var(--color-text-strong);
}
html[data-theme] table thead th[data-column-id]:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}
html[data-theme] .collection-column-resize-handle:hover,
html[data-theme] .collection-column-resize-handle:focus-visible {
  background: transparent;
}
html[data-theme] .collection-column-resize-handle:hover::after,
html[data-theme] th:focus-visible .collection-column-resize-handle::after {
  background: var(--color-text-strong);
}
/* During a drag the controller reserves offscreen rows' exact height, so only
   the visible rows participate in each column-width layout. */
.collection-column-resize-spacer,
.collection-column-resize-spacer:hover,
.collection-column-resize-spacer > td {
  border: 0;
  padding: 0;
  background: none;
  pointer-events: none;
}
.collection-skeleton-row > td,
tr.detail-trigger[data-key] > td {
  height: 38px;
}
.collection-table-density-compact :is(.collection-skeleton-row, tr.detail-trigger[data-key]) > td,
html[data-compact='true'] :is(.collection-skeleton-row, tr.detail-trigger[data-key]) > td {
  height: 32px;
  padding-top: 3px;
  padding-bottom: 3px;
}
.collection-skeleton-row .skeleton-line {
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
}
.collection-skeleton-row:hover {
  background: transparent;
  cursor: default;
}
.finish-cell .finish-badge--table {
  max-width: none;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.set-icon-placeholder {
  display: inline-block;
  text-align: center;
  color: var(--color-text-muted);
  filter: none;
}
body.collection-column-resizing {
  cursor: col-resize;
  user-select: none;
}
body.collection-column-dragging {
  cursor: grabbing;
  user-select: none;
}
/* BEN-1005: dragging a card row (or the current selection) onto a sidebar
   container/deck -- same dimmed-source idiom as the column-reorder drag. */
body.collection-row-dragging {
  cursor: grabbing;
  user-select: none;
}
tr.detail-trigger.row-dragging {
  opacity: 0.48;
}
body.collection-column-dragging thead th[data-collection-column-reorder] {
  cursor: grabbing;
}
thead th.collection-column-drag-source {
  opacity: 0.48;
}
/* BEN-445: highlight a whole column (header + body cells sharing data-column-id)
   on header hover, and a stronger wash while the column is dragged to reorder.
   Applied as an inset box-shadow wash so it layers over the row-hover and
   row-selected backgrounds instead of replacing them. */
thead th.column-hl,
tbody td.column-hl {
  box-shadow: inset 0 0 0 9999px var(--color-column-hl);
}
thead th.column-dragging,
tbody td.column-dragging {
  box-shadow: inset 0 0 0 9999px var(--color-column-dragging);
}
/* Keep the header's bottom rule visible under the wash. */
thead th.column-hl {
  box-shadow:
    inset 0 -1px 0 var(--color-text-strong),
    inset 0 0 0 9999px var(--color-column-hl);
}
thead th.column-dragging {
  box-shadow:
    inset 0 -1px 0 var(--color-text-strong),
    inset 0 0 0 9999px var(--color-column-dragging);
}
thead th.collection-column-drop-before::before,
thead th.collection-column-drop-after::after {
  background: var(--color-text);
  bottom: 4px;
  content: '';
  pointer-events: none;
  position: absolute;
  top: 4px;
  width: 2px;
  z-index: 12;
}
thead th.collection-column-drop-before::before {
  left: 0;
}
thead th.collection-column-drop-after::after {
  right: 0;
}
body.collection-column-resizing {
  cursor: col-resize;
}
.tags-cell {
  position: relative;
  text-overflow: clip;
  white-space: nowrap;
  cursor: pointer;
}
.tags-cell[data-row-tag-trigger] {
  /* BEN-454: no cell-level background/hover — the tags cell stays transparent so
     it inherits the standard `tbody tr:hover` (and row-selected) background like
     every other td, instead of painting its own color on cell hover. */
  background: transparent;
}
.tag-cell-content {
  align-items: center;
  display: flex;
  inset-block: 0;
  inset-inline: 8px;
  overflow: hidden;
  position: absolute;
  text-overflow: clip;
  white-space: nowrap;
}
.tags-cell .tag-chip {
  flex: 0 0 auto;
  margin-right: 3px;
  white-space: nowrap;
}
.tag-overflow-indicator {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sharp);
  color: var(--color-text-muted);
  font: 500 var(--font-size-xxs) / 18px var(--font-mono);
  inset-inline-end: 28px;
  padding-inline: 4px;
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 1;
}
/* BEN-430: arcane chip-style mini-button family (solid border, vellum, mono,
   hard 1px shadow + press). BEN-611: the chat "new chat" and deck-meta pill
   clear ride the same family. The empty location cell's ghost + does too. */
.row-tag-add,
.row-loc-add,
.deck-meta-ac-pill-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: var(--font-weight-title);
  font-size: var(--font-size-sm);
  line-height: 1;
  vertical-align: middle;
  box-shadow: 1px 1px 0 var(--color-text-strong);
  transition:
    transform var(--motion-fast) steps(2, end),
    box-shadow var(--motion-fast) steps(2, end);
}
.row-tag-add {
  block-size: 18px;
  inline-size: 18px;
  inset-inline-end: 6px;
  margin: 0;
  position: absolute;
  top: calc(50% - 9px);
  transform: none;
  z-index: 2;
  box-shadow: none;
  transition:
    background-color var(--motion-fast),
    border-color var(--motion-fast),
    color var(--motion-fast),
    outline-color var(--motion-fast);
}
.row-loc-add {
  width: 18px;
  height: 18px;
}
.deck-meta-ac-pill-clear {
  width: 22px;
  height: 22px;
}
.row-loc-add:hover,
.row-loc-add:focus-visible,
.deck-meta-ac-pill-clear:hover,
.deck-meta-ac-pill-clear:focus-visible {
  color: var(--color-text-strong);
  transform: translate(1px, 1px);
  box-shadow: 0 0 0 var(--color-text-strong);
  outline: none;
}
.row-tag-add:hover,
.row-tag-add:focus-visible {
  background: color-mix(in srgb, var(--color-accent-soft) 64%, var(--color-surface-raised));
  border-color: var(--color-accent);
  box-shadow: none;
  color: var(--color-accent);
  outline: 2px solid color-mix(in srgb, var(--color-accent) 38%, transparent);
  outline-offset: 1px;
  transform: none;
}
.row-tag-add:active {
  box-shadow: none;
  transform: none;
}
/* BEN-569: an affordance repeated on every row stops being an affordance — the
   ghost "+" surfaces on row hover (or keyboard focus via focus-within) instead
   of sitting on every row at rest. Hover-capable pointers only; touch keeps it
   always-visible. (Table pills no longer render an inline × at all — its
   hidden-but-space-reserving segment read as dead chrome; remove/move live in
   the pill quick menus.) */
@media (hover: hover) {
  .list-view tbody tr .row-tag-add,
  .list-view tbody tr .row-loc-add {
    opacity: 0;
    transition: opacity var(--motion-fast) ease;
  }
  .list-view tbody tr:hover .row-tag-add,
  .list-view tbody tr:focus-within .row-tag-add,
  .list-view tbody tr:hover .row-loc-add,
  .list-view tbody tr:focus-within .row-loc-add {
    opacity: 1;
  }
}
.row-tag-popover {
  position: absolute;
  /* M-01: this singleton popover is reused from the detail drawer's tags row
     too, where the drawer itself is z-index 1101 — match .row-context-menu's
     tier (also a row-level popover that must clear the drawer) instead of
     losing to it. */
  z-index: 1250;
  min-width: 220px;
  max-width: 320px;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-popover);
  padding: 8px;
}
.row-tag-popover-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  min-height: 22px;
}
.row-tag-popover-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
  padding: 2px 0;
}
/* Available-tag picker: the user's existing tags rendered as clickable chips so
   a known tag can be applied without retyping. The text input only filters this
   list + creates a brand-new tag. */
.row-tag-popover-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  max-height: 132px;
  overflow-y: auto;
}
.row-tag-popover-choices:empty {
  margin-top: 0;
}
.row-tag-popover-choice {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
}
.row-tag-popover-choice:hover .tag-chip,
.row-tag-popover-choice:focus-visible .tag-chip {
  filter: brightness(0.95);
}
.row-tag-popover-choice:focus-visible {
  outline: none;
}
.row-tag-popover-choice:focus-visible .tag-chip {
  outline: var(--border-width) solid var(--color-line-focus);
  outline-offset: 1px;
}
.row-tag-popover-choices-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
  padding: 2px 0;
}
.row-tag-popover-foot {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}
.row-tag-manage-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--font-size-sm);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.row-tag-manage-link:hover,
.row-tag-manage-link:focus-visible {
  color: var(--color-text-strong);
}
.row-tag-popover-input-wrap {
  position: relative;
}
.row-tag-popover-input {
  width: 100%;
  box-sizing: border-box;
  border: var(--border-width) solid var(--color-line-strong);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-md);
  padding: 4px 6px;
  text-transform: none;
}
.row-tag-popover-input:focus {
  outline: none;
  border-color: var(--color-text-muted);
  background: var(--color-surface-hover);
}
.row-tag-popover-input::placeholder {
  color: var(--color-line);
}

/* Emoji picker (BEN-491): a `+`-style trigger sits next to every emoji input and
   opens the shared anchored popover below. */
.emoji-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.emoji-picker-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1;
  cursor: pointer;
}
.emoji-picker-trigger:hover,
.emoji-picker-trigger:focus-visible {
  color: var(--color-text-strong);
  border-color: var(--color-text-muted);
  background: var(--color-surface-hover);
  outline: none;
}
.emoji-picker-popover {
  position: absolute;
  /* Above every modal it can be triggered from and appended to <body> as a
     sibling of that overlay: the tag manager (.ui-modal, z-index 100) and,
     per BEN-1017, the csv-import modal's inline "new container" field
     (.csv-import-modal, z-index 180). */
  z-index: 190;
  width: 240px;
  box-sizing: border-box;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  box-shadow: var(--shadow-popover);
  padding: 8px;
}
.emoji-picker-search-row {
  align-items: stretch;
  display: flex;
  gap: 4px;
}
.emoji-picker-clear {
  appearance: none;
  background: none;
  border: var(--border-width) solid var(--color-line-strong);
  color: var(--color-text-muted);
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: var(--font-size-xs);
  padding: 0 6px;
  text-transform: none;
}
.emoji-picker-clear:hover,
.emoji-picker-clear:focus-visible {
  background: var(--color-surface-hover);
  color: var(--color-text-strong);
  outline: none;
}
.emoji-picker-search {
  width: 100%;
  box-sizing: border-box;
  border: var(--border-width) solid var(--color-line-strong);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-md);
  padding: 4px 6px;
  text-transform: none;
}
.emoji-picker-search:focus {
  outline: none;
  border-color: var(--color-text-muted);
  background: var(--color-surface-hover);
}
.emoji-picker-search::placeholder {
  color: var(--color-line);
}
.emoji-picker-tabs {
  display: flex;
  gap: 2px;
  margin: 6px 0;
}
.emoji-picker-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-soft);
  background: none;
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
}
.emoji-picker-tab:hover,
.emoji-picker-tab:focus-visible {
  opacity: 1;
  background: var(--color-surface-hover);
  outline: none;
}
.emoji-picker-tab.active {
  opacity: 1;
  border-color: var(--color-line-strong);
  background: var(--color-surface-hover);
}
.emoji-picker-grid {
  max-height: 176px;
  overflow-y: auto;
}
.emoji-picker-group-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin: 4px 0 2px;
  text-transform: none;
}
.emoji-picker-grid-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
}
.emoji-picker-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-soft);
  background: none;
  /* BEN-759: <button>s don't inherit the app font — pin the app stack so emoji
     fall through to Noto rather than the OS emoji font. */
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.emoji-picker-cell:hover,
.emoji-picker-cell:focus-visible {
  background: var(--color-surface-hover);
  border-color: var(--color-line-strong);
  outline: none;
}
.emoji-picker-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
  padding: 8px 2px;
}
.row-tag-input {
  /* `.row-tag-input` is still used by the MCP chat reference-row inputs
     (`mcp-chat-row-tag-input`). Keep the lightweight borderless inline form so
     that surface continues to render as before. The collection table no longer
     uses this class; it routes editing through the popover above. */
  width: 64px;
  border: none;
  background: transparent;
  color: var(--color-text-strong);
  font: inherit;
  font-size: var(--font-size-xxs);
  margin-left: 1px;
  padding: 1px 2px;
  text-transform: none;
}
.row-tag-input::placeholder {
  color: var(--color-line);
}
.row-tag-input:focus {
  outline: none;
  background: var(--color-surface-hover);
}
.row-tag-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 24;
  min-width: 116px;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-line-strong);
  background: var(--color-surface);
  box-shadow: var(--shadow-firm);
  padding: 2px;
}
.row-tag-suggestions:not(.active) {
  display: none;
}
.row-tag-suggestion {
  border: 0;
  background: transparent;
  color: var(--color-text-strong);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-sm);
  overflow: hidden;
  padding: 4px 6px;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}
.row-tag-suggestion:hover,
.row-tag-suggestion[aria-selected='true'] {
  background: var(--color-surface-beige);
}

/* Typed-location pills (list view + history + filter chips). Geometry,
   truncation, and the sticker identity come from the vellum .ui-chip base —
   only type colors + interactivity live here. */
.loc-pill {
  cursor: pointer;
}
.loc-pill:hover {
  filter: brightness(0.95);
}
/* BEN-562: the typed pill surfaces are light "stickers" in BOTH themes, so
   their ink is pinned to the palette's fixed dark text tokens — printed ink on
   a sticker doesn't invert with the page. (.loc-pill-colored is translucent
   over the page surface, so its ink keeps following the theme.) */
.loc-pill-deck {
  background: var(--color-loc-deck-bg);
  border-color: var(--color-loc-deck-line);
  color: var(--color-loc-deck-text);
}
.loc-pill-container {
  background: var(--color-loc-container-bg);
  border-color: var(--color-loc-container-line);
  color: var(--color-loc-container-text);
}
/* Custom-colored pills consume the shared --ui-chip-* hooks. The class (rather
   than the base's own var lookup) is still needed so the custom color beats the
   per-type rules above; ink returns to theme-following strong (BEN-562). */
.loc-pill-colored {
  background: var(--ui-chip-bg, inherit);
  border-color: var(--ui-chip-border, currentColor);
  color: var(--color-text-strong);
}
/* Clickable typed-location button used inside history summaries.
     Hover reveals the type via the title attr. */
.loc-link {
  cursor: pointer;
  text-decoration: none;
  text-transform: none;
}
.loc-link:hover {
  filter: brightness(0.95);
}
.loc-link-deck {
  background: var(--color-loc-deck-bg);
  border-color: var(--color-loc-deck-line);
  color: var(--color-loc-deck-text);
}
.loc-link-container {
  background: var(--color-loc-container-bg);
  border-color: var(--color-loc-container-line);
  color: var(--color-loc-container-text);
}
/* BEN-421: .loc-pill-remove + .tag-chip-remove now share the .ui-chip-remove base. */

/* (The inline empty-cell location picker select retired — the cell now shows
   a ghost .row-loc-add + that opens the location quick menu.) */

/* Drawer / bulk-bar / add-form location field — type select + name input */
.loc-field {
  display: flex;
  gap: 6px;
  align-items: stretch;
  border-bottom: var(--border-width) solid var(--color-line);
}
.loc-field:focus-within {
  border-bottom-color: var(--color-text-strong);
}
.loc-field .loc-type-select {
  border: none;
  background: transparent;
  font: inherit;
  color: var(--color-text-muted);
  text-transform: none;
  padding: 4px 0;
  cursor: pointer;
}
.loc-field .loc-type-select:focus {
  outline: none;
  color: var(--color-text-strong);
}
.loc-field .loc-name-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--color-text-strong);
  font: inherit;
  text-transform: none;
  padding: 4px 0;
}
/* Location picker in the add-card form: existing-container pills + inline new */
.location-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.location-pills {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
}
.location-pill-group {
  align-items: center;
  display: inline-grid;
  gap: 3px 5px;
  grid-template-columns: auto auto;
  width: auto;
}
.location-pill-group-items {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 4px;
  min-width: 0;
}
.location-pills .loc-group-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  /* BEN-572: lowercase group labels. */
  text-transform: none;
  letter-spacing: 0.06em;
  line-height: 1.7;
  margin: 0;
}
/* Pill-as-button: a bare <button> wrapper that makes a .loc-pill selectable.
   The chrome lives on the inner .loc-pill; the button only carries the hit
   target and selected/hover state (via opacity + inset ring). */
.location-pill-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.location-pill-btn .loc-pill {
  padding: 2px 6px;
  font-size: var(--font-size-xxs);
  opacity: 0.55;
  transition:
    opacity var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}
.location-pill-btn:hover .loc-pill,
.location-pill-btn:focus-visible .loc-pill {
  opacity: 1;
}
.location-pill-btn.is-selected .loc-pill {
  opacity: 1;
  box-shadow: 0 0 0 1px var(--color-text-strong) inset;
}
.location-pill-new {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 3px 8px;
  font-size: var(--font-size-xxs);
}
.location-pill-new.is-selected {
  background: var(--color-text-strong);
  color: var(--color-text-inverse);
  border-style: solid;
  border-color: var(--color-text-strong);
}
.location-new.hidden {
  display: none;
}
.field-full {
  grid-column: 1 / -1;
}

/* Typed-pill radio variant of .loc-field — used by the add-card form */
.loc-field-typed {
  border-bottom: none;
  align-items: center;
}
.loc-type-radios {
  display: inline-flex;
  gap: 4px;
}
.loc-type-radio {
  display: inline-flex;
  cursor: pointer;
}
.loc-type-radio input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.loc-type-radio .loc-pill {
  padding: 2px 6px;
  font-size: var(--font-size-xxs);
  opacity: 0.5;
  transition:
    opacity var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}
.loc-type-radio.is-selected .loc-pill {
  opacity: 1;
  box-shadow: 0 0 0 1px var(--color-text-strong) inset;
}
.loc-type-radio input:focus-visible + .loc-pill {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.loc-field-typed .loc-name-input {
  border-bottom: var(--border-width) solid var(--color-line);
  min-width: 0;
}
.loc-field-typed:focus-within .loc-name-input {
  border-bottom-color: var(--color-text-strong);
}
.loc-field .loc-name-input:focus {
  outline: none;
}
/* BEN-1000: inline "new container" icon picker + create button, shared by
   every destination picker (add drawer, bulk move, detail edit, import). */
.container-editor-icon-field {
  flex-shrink: 0;
}
.loc-new-create {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: var(--font-size-xxs);
}

.set-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 5px;
  opacity: 0.55;
}
.row-check,
.header-check {
  cursor: pointer;
}

.bulk-bar {
  display: none;
  align-items: center;
  box-sizing: border-box;
  flex-wrap: nowrap;
  gap: 8px;
  height: 52px;
  padding: 8px 14px;
  margin: 0;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-firm);
  font-size: var(--font-size-sm);
  /* BEN-463: float as a content-width bar centered at the bottom of the table
     view rather than docking full-width across the top. */
  bottom: calc(16px + var(--app-footer-h));
  left: 50%;
  max-width: calc(100vw - 32px);
  min-width: 0;
  overflow: visible;
  position: fixed;
  transform: translateX(-50%);
  width: max-content;
  z-index: 35;
}
.bulk-bar.active {
  display: flex;
}
.bulk-count {
  align-self: center;
  flex: 0 1 auto;
  font-weight: 400;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bulk-selection-stats {
  color: var(--color-text-muted);
  flex: 0 1 auto;
  font-size: var(--font-size-sm);
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bulk-hidden-actions {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
}
.bulk-hidden-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.bulk-edit-menu {
  flex: 0 0 auto;
  min-width: 0;
  position: relative;
}
.bulk-edit-menu > summary {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  list-style: none;
  user-select: none;
}
.bulk-bar > .btn,
.bulk-edit-trigger {
  flex: 0 0 auto;
  white-space: nowrap;
}
.bulk-edit-menu > summary::-webkit-details-marker {
  display: none;
}
.bulk-edit-menu[open] > .bulk-edit-trigger {
  background: var(--color-text-strong);
  border-color: var(--color-text-strong);
  color: var(--color-text-inverse);
}
.bulk-edit-panel {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-popover);
  box-sizing: border-box;
  display: grid;
  gap: 12px 14px;
  grid-template-columns: repeat(3, minmax(145px, 1fr));
  /* BEN-463: pop above the floating bottom toolbar, centered to match it, so
     the bar stays pinned and the action UI appears over it. */
  bottom: calc(16px + var(--app-footer-h) + 52px + 8px);
  left: 50%;
  transform: translateX(-50%);
  max-height: calc(100vh - 32px - var(--app-footer-h) - 52px - 8px);
  /* iOS: 100vh exceeds the visible area while Safari's bars are showing. */
  max-height: calc(100dvh - 32px - var(--app-footer-h) - 52px - 8px);
  overflow: auto;
  padding: 12px;
  position: fixed;
  width: min(720px, calc(100vw - 32px));
  z-index: 45;
}
.bulk-edit-panel-header {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
}
.bulk-action-group {
  align-content: start;
  border: var(--border-width) solid var(--color-line);
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
}
.bulk-action-group h3 {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1;
  margin: 0;
  text-transform: none;
}
.bulk-action-group-primary,
.bulk-action-group-corrections,
.bulk-action-group-danger {
  grid-column: 1 / -1;
}
.bulk-correction-fields {
  display: grid;
  gap: 12px 14px;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}
.bulk-action-group-danger {
  align-items: center;
  display: flex;
  justify-content: space-between;
}
.bulk-edit-panel .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.bulk-edit-panel .field label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
}
.bulk-edit-panel input,
.bulk-edit-panel select {
  background: transparent;
  border: none;
  border-bottom: var(--border-width) solid var(--color-text-strong);
  box-sizing: border-box;
  padding: 4px 2px;
  font-size: var(--font-size-md);
  font-family: inherit;
  text-transform: none;
  outline: none;
  border-radius: var(--radius-square);
  -webkit-appearance: none;
  min-width: 0;
  width: 100%;
}
.bulk-bar .bulk-spacer {
  flex: 1;
}
.row-context-menu {
  position: fixed;
  z-index: 1250;
  min-width: min(170px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
}
/* A scale, even scale(1), would trap fixed submenus inside the scrolling menu. */
.row-context-menu.ui-popover {
  scale: none;
  transform: none;
  transition: none;
}
.row-context-menu .row-context-menu-danger {
  color: var(--color-danger);
}
/* BEN-474: pill/chip quick menus + the location move-to submenu. */
.pill-context-submenu-wrap {
  position: relative;
  display: grid;
}
.pill-context-submenu-wrap > .pill-context-submenu {
  position: fixed;
  width: 240px;
  margin: 0;
  display: none;
  z-index: 1251;
}
.pill-context-submenu-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pill-context-submenu-direction::before {
  content: '▸';
}
.pill-context-submenu-trigger[data-submenu-side='left'] .pill-context-submenu-direction::before {
  content: '◂';
}
.pill-context-submenu .floating-menu-item {
  overflow-wrap: anywhere;
}
/* BEN-709: `.is-submenu-open` is toggled by vellum floatingMenu's safe-triangle
   hover-intent, which holds the fly-out open through a diagonal corner-clip;
   :hover/:focus-within stay for instant open + keyboard reveal. */
.pill-context-submenu-wrap:hover > .pill-context-submenu,
.pill-context-submenu-wrap:focus-within > .pill-context-submenu,
.pill-context-submenu-wrap.is-submenu-open > .pill-context-submenu {
  display: grid;
}
.pill-context-submenu .pill-context-new {
  border-top: 1px dashed var(--color-line);
  margin-top: 2px;
  padding-top: 9px;
}
/* BEN-1013: "move to > + new container" from the row/pill context menus opens
   this compact modal instead of window.prompt() -- same [icon|name] field +
   create button every other destination picker uses (BEN-1000). */
.move-new-container-card {
  width: min(320px, calc(100vw - 32px));
}
.move-new-container-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bulk-location-field,
.bulk-pending {
  grid-column: 1 / -1;
}
.bulk-location-picker {
  gap: 8px;
}
.bulk-location-picker .location-pills {
  max-height: 92px;
  overflow: auto;
  padding: 1px 0;
}
.bulk-location-picker .location-new {
  margin-top: 2px;
}
.bulk-location-meta {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  font-size: var(--font-size-xxs);
  gap: 8px;
  justify-content: space-between;
}
.bulk-location-meta .btn-link-danger {
  flex: 0 0 auto;
}
.bulk-loc-field {
  align-items: center;
  border-bottom: none;
  display: flex;
  gap: 8px;
}
.bulk-loc-field .loc-type-radios {
  flex: 0 0 auto;
}
.bulk-loc-field .loc-name-input {
  flex: 1 1 180px;
  width: auto;
}
.bulk-edit-panel .bulk-tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.bulk-edit-panel .bulk-tag-row input,
.bulk-edit-panel .bulk-tag-row select {
  flex: 1 1 auto;
}
.bulk-pending {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px dashed var(--color-line);
}
.bulk-pending.active {
  display: flex;
}
.pending-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
  text-transform: none;
  margin-right: 4px;
}
.pending-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-warn-soft);
  border: 1px solid var(--color-warn-line);
  padding: 2px 4px 2px 8px;
  border-radius: var(--radius-sharp);
  font-size: var(--font-size-sm);
  color: var(--color-text-strong);
}
.pending-pill-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  font-size: var(--font-size-lg);
  line-height: 1;
  color: var(--color-text-muted);
}
.pending-pill-remove:hover {
  color: var(--color-text-strong);
}
.save-pending-btn {
  padding: 4px 14px;
  font-size: var(--font-size-sm);
}
.cancel-pending-btn {
  padding: 4px 12px;
  font-size: var(--font-size-sm);
}

@media (max-width: 860px) {
  .bulk-edit-panel {
    width: calc(100vw - 216px);
  }
  .bulk-edit-panel-body {
    grid-template-columns: minmax(0, 1fr);
  }
  body.left-sidebar-collapsed .bulk-edit-panel {
    width: calc(100vw - 16px);
  }
}

.collection-display-controls {
  background: var(--surface-veil-soft);
  border: 0;
  border-radius: var(--radius-square);
  display: grid;
  gap: 8px;
  overflow: visible;
  width: 100%;
}
.collection-display-controls-main {
  align-items: stretch;
  display: flex;
  min-width: 0;
  width: 100%;
}
.collection-display-mode .segment-btn {
  flex: 1;
  min-width: 0;
}
.collection-display-mode {
  flex: 1;
}
/* BEN-447: the table/visual toggle is the same segmented control as the top
   view nav — it consumes the shared .segmented / .segment-btn component (frame,
   vellum segments, purple active state all come from the base rules). Only
   sidebar layout lives here: full width, equal segments, and 14px icons matching
   the top-nav view icons. */
.sidebar-view-settings .collection-display-controls {
  background: transparent;
}
.sidebar-view-settings .collection-display-controls.segmented,
.sidebar-view-settings .collection-display-mode.segmented {
  width: 100%;
}
.sidebar-view-settings .collection-display-controls .segment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.sidebar-view-settings .collection-display-controls .view-icon-svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}
/* BEN-538: grid display controls (table/visual toggle + grid sizes) live in the
   sidebar now, mirroring the collection's view settings. */
.sidebar-grid-view-settings {
  display: none;
}
body.view-grid .sidebar-grid-view-settings {
  display: grid;
  gap: 6px;
}
.sidebar-grid-view-settings .collection-display-controls {
  background: transparent;
}
.sidebar-grid-view-settings .collection-display-controls.segmented,
.sidebar-grid-view-settings .collection-display-mode.segmented {
  width: 100%;
}
.sidebar-grid-view-settings .collection-display-controls .segment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.sidebar-grid-view-settings .collection-display-controls .view-icon-svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}
.sidebar-grid-view-settings .grid-size-options {
  width: 100%;
  display: flex;
  margin-top: 6px;
}
.sidebar-grid-view-settings .grid-size-options .segment-btn {
  flex: 1;
}
.collection-column-settings-panel {
  background: transparent;
  /* BEN-423: no divider line between the table/visual toggle and the visible-
     columns control — just breathing room. BEN-425: the control is now a
     filter-style .multiselect dropdown (.collection-column-settings-dropdown). */
  margin-top: 12px;
  min-width: 0;
  overflow: visible;
  width: 100%;
}
.collection-column-settings-dropdown .ms-option.is-locked {
  cursor: default;
  opacity: 0.65;
}
.collection-visual-view {
  padding: 12px;
}
/* Desktop: a side margin at least as wide as the floating controls on the
   right (resting action icons 16 + 36 px, the scroll control 10 + 28 px), kept
   on both sides. The centered columns add whatever width is left over, so the
   visible margin varies with the window instead of being a fixed lane. */
@media (min-width: 901px) {
  .collection-visual-view {
    padding-inline: 64px;
  }
}
.collection-visual-grid {
  display: grid;
  grid-auto-rows: 1fr;
  gap: clamp(12px, 1.2vw, 18px);
  /* Center the fixed-width column group rather than stretching gaps. auto-fit,
     not auto-fill: auto-fill keeps empty trailing tracks alive, so centering
     would center the phantom tracks too and still read left-biased. (width:
     fit-content is not an option — repeat() resolves to a single repetition
     under indefinite sizing and collapses the grid to one column.) */
  grid-template-columns: repeat(
    auto-fit,
    minmax(var(--collection-visual-card-width, 180px), var(--collection-visual-card-width, 180px))
  );
  justify-content: center;
}
.collection-binder-pages {
  display: grid;
  gap: clamp(24px, 3vw, 40px);
  justify-items: center;
  padding: clamp(4px, 0.8vw, 10px) 0 clamp(18px, 2vw, 30px);
}
.collection-binder-nav {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.collection-binder-page-indicator {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  min-width: 96px;
  text-align: center;
}
.collection-binder-pages.is-turning-next .collection-binder-page {
  animation: binder-page-next 190ms cubic-bezier(0.2, 0.75, 0.25, 1);
  transform-origin: left center;
}
.collection-binder-pages.is-turning-prev .collection-binder-page {
  animation: binder-page-prev 190ms cubic-bezier(0.2, 0.75, 0.25, 1);
  transform-origin: right center;
}
@keyframes binder-page-next {
  from {
    opacity: 0.72;
    transform: perspective(900px) rotateY(3deg) translateX(8px);
  }
  to {
    opacity: 1;
    transform: perspective(900px) rotateY(0) translateX(0);
  }
}
@keyframes binder-page-prev {
  from {
    opacity: 0.72;
    transform: perspective(900px) rotateY(-3deg) translateX(-8px);
  }
  to {
    opacity: 1;
    transform: perspective(900px) rotateY(0) translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .collection-binder-pages.is-turning-next .collection-binder-page,
  .collection-binder-pages.is-turning-prev .collection-binder-page {
    animation: none;
  }
}
.collection-binder-page {
  background: color-mix(in srgb, var(--color-accent) 7%, var(--color-surface-raised));
  border: 1px solid color-mix(in srgb, var(--color-accent) 14%, var(--color-line));
  border-radius: clamp(12px, 1.2vw, 18px);
  box-shadow:
    0 9px 24px rgba(40, 31, 46, 0.1),
    inset 0 1px 0 color-mix(in srgb, white 58%, transparent);
  box-sizing: border-box;
  max-width: 100%;
  padding: clamp(10px, 1.35vw, 18px);
  position: relative;
  width: min(100%, var(--collection-binder-page-width, 720px));
}
.collection-binder-sheet {
  display: grid;
  gap: clamp(6px, 0.75vw, 12px);
  grid-template-columns: repeat(var(--collection-binder-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--collection-binder-rows), auto);
}
.collection-binder-pocket {
  aspect-ratio: 5 / 7;
  background: color-mix(in srgb, var(--color-text-strong) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-line-strong) 72%, transparent);
  border-radius: calc(var(--radius-card) + 3px);
  box-shadow:
    inset 0 1px 4px rgba(44, 35, 50, 0.12),
    inset 0 -1px 0 color-mix(in srgb, white 48%, transparent);
  min-width: 0;
  padding: clamp(3px, 0.38vw, 6px);
  position: relative;
}
.collection-binder-pocket::after {
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, white 26%, transparent);
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 5;
}
.collection-binder-pocket > .collection-visual-card-binder {
  height: 100%;
  width: 100%;
}
.collection-binder-pocket-empty {
  background: color-mix(in srgb, var(--color-surface-sunken) 44%, transparent);
  border-style: dashed;
  box-shadow: inset 0 1px 4px rgba(44, 35, 50, 0.06);
}
.collection-binder-page-number {
  background: color-mix(in srgb, var(--color-surface-raised) 86%, transparent);
  border: 1px solid var(--color-line-faint);
  border-radius: 999px;
  bottom: 5px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  line-height: 1;
  min-width: 18px;
  padding: 3px 5px;
  position: absolute;
  right: 6px;
  text-align: center;
}
.collection-visual-card {
  position: relative;
  background: transparent;
  border: none;
  border-radius: var(--radius-card);
  box-shadow: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: max-content 1fr;
  min-width: 0;
  overflow: visible;
  cursor: pointer;
}
.collection-visual-card-media {
  position: relative;
  min-width: 0;
  border-radius: inherit;
}
/* Selection is the card outline itself: cmd/ctrl-click or shift-click starts it. */
.collection-visual-card.row-selected .collection-visual-card-art {
  outline: 3px solid var(--color-card-outline);
  outline-offset: 3px;
}
.collection-visual-card:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
}
.collection-visual-card-art {
  appearance: none;
  aspect-ratio: 5 / 7;
  background: var(--color-surface-placeholder);
  border: none;
  border-radius: var(--radius-card);
  cursor: pointer;
  display: block;
  filter: none;
  overflow: hidden;
  padding: 0;
  position: relative;
  width: 100%;
  outline: 2px solid transparent;
  outline-offset: 4px;
  transition: none;
}
@media (hover: hover) and (pointer: fine) {
  .collection-visual-card:not(.collection-visual-card-binder):not(.row-selected):hover
    .collection-visual-card-art {
    outline-color: var(--color-card-hover-outline);
  }
}
.collection-visual-card-art:focus-visible {
  outline: 2px solid var(--color-card-outline);
  outline-offset: 4px;
}
.collection-visual-card-name:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.collection-visual-card-image {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}
.collection-visual-card-image-missing {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  font-size: var(--font-size-jumbo);
  justify-content: center;
}
.collection-visual-card-body {
  align-content: start;
  background: transparent;
  border: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 8px 3px 3px;
  position: relative;
  z-index: 1;
}
.collection-visual-card-name {
  align-items: flex-start;
  background: transparent;
  border: none;
  color: var(--color-text-strong);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: var(--font-size-md);
  font-weight: 540;
  line-height: 1.1;
  height: 2.2em;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  text-align: left;
}
.collection-visual-card-name-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  /* Reserve both name lines on the button; clamp only the text so its full
     focus outline remains visible. Long unbroken names can wrap too. */
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: normal;
}
.collection-visual-card-name:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.collection-visual-card-meta {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--font-size-xs);
  gap: 4px;
  line-height: 1.3;
  /* Reserve the swatch plus baseline descent even when labels are hidden. */
  min-height: max(1lh, calc(14px + 0.5lh));
}
.collection-visual-card-meta-item {
  align-items: center;
  display: inline-flex;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
}
.collection-visual-card-meta-item
  + .collection-visual-card-meta-item:not(.collection-visual-card-location)::before {
  color: var(--color-line-strong);
  content: '·';
  margin-right: 1px;
}
.collection-visual-card-qty,
.collection-visual-card-finish,
.collection-visual-card-price {
  color: var(--color-text-strong);
}
.collection-visual-card-finish {
  display: inline-flex;
  flex: none;
  height: 14px;
  width: 14px;
}
/* BEN-643: the visual card art isn't a vellum .card-sleeve, so define the
   --card-sleeve-width that the price sticker sizes and positions off — track the
   art's own width via a container query so the sticker scales per card. */
.collection-visual-card-art {
  container-type: inline-size;
  --card-sleeve-width: 100cqw;
}
.collection-visual-card-binder {
  background: var(--color-surface-placeholder);
  display: block;
  grid-template-rows: none;
}
.collection-visual-card-binder .collection-visual-card-media {
  height: 100%;
}
.collection-visual-card-binder .collection-visual-card-art {
  aspect-ratio: auto;
  cursor: inherit;
  filter: none;
  height: 100%;
  pointer-events: none;
}
.collection-visual-card-binder .collection-visual-card-image {
  object-fit: contain;
}
.collection-visual-card-binder.is-foil .collection-visual-card-art::after,
.collection-visual-card-binder.is-etched .collection-visual-card-art::after {
  content: none;
}
.collection-visual-settings {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.collection-view-settings-section {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}
.collection-table-density-control {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}
.collection-table-layout-settings .collection-column-settings-dropdown,
.collection-table-layout-settings > .btn {
  width: 100%;
}
.collection-view-settings-section:first-child {
  padding-top: 0;
}
.collection-view-settings-section + .collection-view-settings-section {
  border-top: 1px solid var(--color-line-faint);
}
.collection-view-settings-section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 24px;
}
.collection-view-settings-section-head strong {
  color: var(--color-text-strong);
  font-size: 13px;
  font-weight: 650;
  text-transform: none;
}
.collection-visible-field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
}
.collection-visible-field-list .ms-option {
  align-items: center;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  min-height: 30px;
  font-size: 13px;
  line-height: 1.35;
  border-radius: var(--radius-sharp);
  padding: 2px 0;
}
.collection-visible-field-list input {
  margin: 0;
}
.collection-price-visibility-toggle {
  align-items: center;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--font-size-xs);
  gap: 6px;
}
.collection-binder-mode-toggle {
  align-items: center;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--font-size-xs);
  gap: 6px;
}
.collection-binder-layout-control {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}
.collection-binder-layout-segments {
  flex: 0 0 auto;
}
.collection-binder-layout-segments .segment-btn {
  min-width: 42px;
  padding-inline: 7px;
}
.collection-price-style-control {
  align-items: center;
  display: flex;
  justify-content: space-between;
}
.collection-view-setting-label {
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1.2;
}
.collection-price-style-segments {
  flex: 0 0 auto;
}
.collection-card-size-setting output {
  color: var(--color-text-muted);
  font-size: 12px;
}
input.collection-card-size-slider[type='range'] {
  accent-color: var(--color-accent);
  cursor: pointer;
  display: block;
  margin: 0;
  position: relative;
  width: 100%;
  z-index: 1;
}
input.collection-card-size-slider[type='range']:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.collection-card-size-stops {
  align-items: center;
  display: flex;
  inset: 50% 7px auto;
  justify-content: space-between;
  pointer-events: none;
  position: absolute;
  transform: translateY(-50%);
  z-index: 0;
}
.collection-card-size-control {
  min-width: 0;
  padding: 2px 0;
  position: relative;
  width: 100%;
}
.collection-card-size-stops i {
  background: var(--color-line-strong);
  border-radius: var(--radius-pill);
  display: block;
  height: 6px;
  width: 2px;
}
.ds-thumbnail-quality-lab {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.ds-thumbnail-quality-item {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin: 0;
}
.ds-thumbnail-quality-item img,
.ds-thumbnail-quality-item canvas {
  border-radius: var(--radius-soft);
  box-shadow: var(--shadow-soft);
  display: block;
  height: auto;
  image-rendering: auto;
  max-width: 100%;
}
.ds-thumbnail-quality-item figcaption {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}
.collection-visual-card-location {
  display: flex;
  min-width: 0;
}
.collection-visual-card-location .loc-pill {
  max-width: 100%;
}
@media (prefers-reduced-motion: reduce) {
  .collection-visual-card-art,
  .deck-card-face,
  .grid-slot {
    transition: none;
  }
}
@media (hover: none), (pointer: coarse) {
  .collection-visual-card-art:active,
  .deck-card-face:active,
  .grid-slot:active {
    outline-color: var(--color-card-hover-outline);
  }
  /* A touch-and-hold opens our menus (ui/longPress.js) across the collection
     and sidebar, so iOS must not select text, show its callout, or lift a
     draggable row first. Fields stay selectable. */
  :is(#collectionSection, #scopeSelector),
  .loc-pill,
  .tag-chip {
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    user-select: none;
  }
  :is(#collectionSection, #scopeSelector) :is(input, textarea, [contenteditable='true']) {
    -webkit-user-select: text;
    user-select: text;
  }
}
.collection-variant-chip-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}
.collection-variant-chip {
  border-color: var(--color-line);
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.2;
  padding: 1px 6px;
}
.collection-variant-overflow {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.4;
}

/* Tomebound: interaction history. Cascade order is declared in ../styles.css. */

/* F19/F20 decision labs live in the design-system catalog so finish and
   motion choices can be compared without shipping experimental behavior. */
.ds-interaction-lab-row {
  align-items: start;
  display: grid;
  gap: 18px;
  perspective: 900px;
}
.ds-finish-lab {
  grid-template-columns: repeat(3, minmax(112px, 154px));
  width: 498px;
}
.ds-card-hover-lab {
  grid-template-columns: repeat(5, minmax(112px, 132px));
  width: 732px;
}
.ds-interaction-lab-item {
  display: grid;
  gap: 7px;
  justify-items: center;
  margin: 0;
  min-width: 0;
}
.ds-interaction-lab-item figcaption {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}
.ds-interaction-lab-card {
  appearance: none;
  aspect-ratio: 5 / 7;
  background: var(--color-surface-placeholder);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: 0 7px 14px rgba(38, 28, 20, 0.16);
  cursor: pointer;
  max-width: 154px;
  overflow: hidden;
  padding: 0;
  position: relative;
  transform: translateZ(0);
  transition:
    transform var(--lab-duration, 160ms) var(--lab-ease, ease-out),
    box-shadow var(--lab-duration, 160ms) var(--lab-ease, ease-out),
    outline-color var(--lab-duration, 160ms) var(--lab-ease, ease-out);
  width: 100%;
}
.ds-interaction-lab-card img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}
.ds-interaction-lab-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}
.ds-card-hover-lab.is-binder .ds-interaction-lab-card {
  max-width: 112px;
}
.ds-finish-card .finish-badge {
  bottom: 6px;
  position: absolute;
  right: 6px;
  z-index: 2;
}
.finish-badge {
  align-items: center;
  display: inline-flex;
  gap: 3px;
  background: color-mix(in srgb, var(--color-surface-raised) 88%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  border-radius: var(--radius-pill);
  color: var(--color-text-strong);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  font-weight: var(--font-weight-title);
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 4px 6px;
  text-transform: none;
}
.finish-badge--table {
  padding: 3px 5px;
}
.finish-badge--card {
  backdrop-filter: blur(4px);
  background: color-mix(in srgb, var(--color-neutral-white) 84%, var(--color-accent) 16%);
  border: 1px solid color-mix(in srgb, var(--color-accent) 46%, var(--color-line));
  border-radius: var(--radius-tight);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--color-neutral-black) 18%, transparent);
  color: var(--color-text-strong);
  font-size: var(--font-size-xxs);
  height: auto;
  opacity: 0.96;
  padding: 3px 5px;
  position: absolute;
  right: 7px;
  top: 7px;
  width: auto;
  z-index: 4;
}
.finish-badge--etched.finish-badge--card {
  background: color-mix(in srgb, var(--color-neutral-white) 82%, #8b78a8 18%);
}
.ds-finish-card.is-foil::after,
.ds-finish-card.is-etched::after {
  border-radius: inherit;
  content: '';
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0.22;
  pointer-events: none;
  position: absolute;
}
.ds-finish-card.is-foil::after {
  background: var(--gradient-card-foil);
}
.ds-finish-card.is-etched::after {
  background: var(--gradient-card-etched);
}
.ds-finish-lab--badge-only .ds-finish-card::after {
  display: none;
}
.ds-finish-lab--material-only .finish-badge {
  display: none;
}
.ds-hover-variant--sheen::after {
  background: linear-gradient(
    108deg,
    transparent 25%,
    rgba(255, 255, 255, 0.28) 48%,
    transparent 68%
  );
  content: '';
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: translateX(-55%);
  transition:
    opacity var(--lab-duration, 160ms) var(--lab-ease, ease-out),
    transform var(--lab-duration, 160ms) var(--lab-ease, ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .ds-hover-variant--lift:hover,
  .ds-hover-variant--sheen:hover {
    box-shadow: 0 12px var(--lab-shadow, 18px) rgba(38, 28, 20, 0.24);
    transform: translateY(calc(var(--lab-lift, 2px) * -1));
  }
  .ds-hover-variant--micro-scale:hover {
    transform: scale(var(--lab-scale, 1.01));
  }
  .ds-hover-variant--edge:hover {
    outline: 2px solid color-mix(in srgb, var(--color-accent) 48%, transparent);
    outline-offset: 2px;
  }
  .ds-hover-variant--tilt:hover {
    transform: rotateX(var(--lab-rotate-x, 0deg)) rotateY(var(--lab-rotate-y, 0deg));
  }
  .ds-hover-variant--sheen:hover::after {
    opacity: 0.65;
    transform: translateX(55%);
  }
}
.ds-card-hover-lab.is-reduced-motion .ds-interaction-lab-card {
  transition: none;
}
.ds-card-hover-lab.is-reduced-motion .ds-hover-variant:hover,
.ds-card-hover-lab.is-reduced-motion .ds-hover-variant:focus-visible {
  box-shadow: 0 7px 14px rgba(38, 28, 20, 0.16);
  outline: 2px solid color-mix(in srgb, var(--color-accent) 48%, transparent);
  outline-offset: 2px;
  transform: none;
}
.ds-card-hover-lab.is-reduced-motion .ds-hover-variant--sheen::after {
  display: none;
}
@media (hover: none), (pointer: coarse) {
  .ds-hover-variant:active {
    outline: 2px solid color-mix(in srgb, var(--color-accent) 48%, transparent);
    outline-offset: 2px;
  }
}
.collection-visual-variant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 5px;
}
.collection-visual-variant-chip {
  border-color: var(--color-line);
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.2;
  padding: 1px 6px;
}

.history-card-ref,
.history-card-name {
  appearance: none;
  background: none;
  border: 0;
  border-radius: 2px;
  color: inherit;
  display: inline;
  font: inherit;
  padding: 0;
  text-transform: none !important;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}
.history-card-ref:hover,
.history-card-ref:focus-visible,
.history-card-name:hover,
.history-card-name:focus-visible {
  color: var(--color-text-strong);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}
.history-card-ref:focus-visible,
.history-card-name:focus-visible {
  outline: 2px solid var(--color-line-focus);
  outline-offset: 2px;
}
.changelog-more-muted {
  color: var(--color-text-muted);
  text-transform: none;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  font-size: var(--font-size-sm);
}
.history-list li {
  background: var(--color-on-dark-line);
  box-shadow:
    inset 2px 0 0 var(--color-line),
    inset 0 -1px 0 rgba(0, 0, 0, 0.06);
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px 8px 10px;
  position: relative;
  word-break: break-word;
}
.history-list li + li {
  margin-top: 5px;
}
.history-list li:last-child {
  box-shadow: inset 2px 0 0 var(--color-line);
}
.history-list .history-row-meta {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
}
.history-list .history-row-meta .history-undo,
.history-list .history-row-meta .history-redo,
.history-list .history-row-meta .history-delete {
  margin-left: auto;
}
/* When an undo/redo button precedes the delete, the action's auto-margin
   already pushed the cluster right — keep delete snug against it. */
.history-list .history-row-meta .history-undo + .history-delete,
.history-list .history-row-meta .history-redo + .history-delete {
  margin-left: 2px;
}
.history-list time {
  color: var(--color-text-muted);
  flex: 0 0 auto;
  font-size: var(--font-size-xs);
  white-space: nowrap;
}
/* One chip: geometry/identity come from the .ui-chip base — only the
   font-size delta and the mcp/chat domain tints (via --ui-chip-* hooks)
   live here (BEN-689). */
.history-list .history-source-badge {
  font-size: var(--font-size-xxxs);
  letter-spacing: 0.04em;
}
.history-list .history-source-mcp {
  --ui-chip-bg: var(--color-mcp-bg);
  --ui-chip-border: var(--color-mcp-border);
  --ui-chip-ink: var(--color-mcp-text);
}
.history-list .history-source-mcp-client {
  padding-left: 4px;
}
.history-list .history-source-client-mark {
  align-items: center;
  background: var(--color-mcp-mark-bg);
  border-radius: var(--radius-pill);
  display: inline-flex;
  font-size: var(--font-size-xxxs);
  font-weight: 700;
  height: 12px;
  justify-content: center;
  letter-spacing: 0;
  text-transform: none;
  width: 12px;
}
.history-list .history-source-client-name {
  letter-spacing: 0.02em;
}
.history-list .history-source-chat {
  --ui-chip-bg: var(--color-chat-bg);
  --ui-chip-border: var(--color-chat-border);
  --ui-chip-ink: var(--color-chat-text);
}
.history-list li.history-undone .history-source-badge {
  opacity: 1;
}
/* One chip: geometry/identity come from the .ui-chip base + .loc-link deck
   tints — only history-layout deltas (flex sizing, width cap, hover) here. */
.history-list .history-deck-tag {
  flex: 1 1 auto;
  max-width: 130px;
}
.history-list .history-deck-tag:hover,
.history-list .history-deck-tag:focus-visible {
  background: var(--color-deck-hover-bg);
  color: var(--color-deck-hover-text);
  outline: none;
  text-decoration: none;
}
.history-list .history-deck-tag-name {
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* BEN-442: location chips embedded in a history summary must stay inside the
   section — cap their width and ellipsize the name rather than overflowing. */
.history-list .loc-link {
  max-width: 100%;
  min-width: 0;
}
.history-list .loc-link .loc-link-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.history-list li.history-undone .history-deck-tag {
  opacity: 0.55;
}
.history-list .history-undo,
.history-list .history-redo {
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-grid;
  font: inherit;
  font-size: var(--font-size-lg);
  height: 16px;
  line-height: 1;
  margin-right: -2px;
  padding: 0;
  place-items: center;
  width: 16px;
  color: var(--color-undo-link);
  text-decoration: none;
  text-transform: none;
}
.history-list .history-undo:focus-visible,
.history-list .history-redo:focus-visible {
  color: var(--color-text-strong);
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
/* BEN-492: per-entry delete — same compact glyph button as undo/redo, muted
   until hover where it reads as a destructive action. */
.history-list .history-delete {
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-grid;
  font: inherit;
  font-size: var(--font-size-lg);
  height: 16px;
  line-height: 1;
  margin-right: -2px;
  padding: 0;
  place-items: center;
  width: 16px;
  color: var(--color-text-muted);
  text-decoration: none;
  text-transform: none;
}
.history-list .history-delete:focus-visible {
  color: var(--color-danger);
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.history-list .history-summary-text {
  word-break: break-word;
}
.history-list li.history-undone {
  color: var(--color-text-muted);
}
.history-list li.history-undone time,
.history-list li.history-undone .history-summary-text {
  text-decoration: line-through;
}
.history-list li.history-undone .loc-link,
.history-list li.history-undone .history-card-name {
  text-decoration: line-through;
  color: var(--color-text-muted);
}
.history-list li.history-undone .history-redo {
  color: var(--color-redo-link);
  text-decoration: none;
}
/* BEN-673: undone entries recede past strikethrough — dimmed and collapsed to
   a single line, with an explicit "undone" label, so a live event standing
   among several undone ghosts (e.g. repeated identical imports) reads as
   unmistakably different at a glance. */
.history-list li.history-collapsed {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  opacity: 0.6;
  padding-top: 5px;
  padding-bottom: 5px;
}
.history-list li.history-collapsed .history-row-meta {
  flex: 0 0 auto;
  width: auto;
}
.history-list li.history-collapsed .history-summary-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-list li.history-collapsed .history-entity-ref-name {
  white-space: nowrap;
}

.history-list .history-undone-label {
  color: var(--color-text-muted);
  flex: 0 0 auto;
  font-size: var(--font-size-xxxs);
  letter-spacing: 0.04em;
  text-transform: none;
  white-space: nowrap;
}
.history-list li.history-dismissed {
  color: var(--color-text-muted);
}
.history-list li.history-empty {
  align-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--color-text-muted);
  display: grid;
  font-style: normal;
  gap: 7px;
  /* BEN-571: the polaroid scales to the space the drawer actually has instead
     of clipping mid-card at the drawer's bottom edge. Copy row is fixed, the
     card row absorbs (and bounds) the rest. */
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  justify-items: center;
  justify-self: center;
  max-width: 178px;
  padding: 0 0 8px;
  text-align: center;
  width: 100%;
}
.history-empty-card {
  display: grid;
  gap: 6px;
  height: 100%;
  justify-items: center;
  margin: 6px 0 0;
  min-height: 0;
  position: relative;
  width: auto;
  max-width: 174px;
}
/* BEN-637 → one sleeve: rides the vellum .card-sleeve. Only the height-fit
   sizing and the rest tilt live here. BEN-987: this is always the static
   card-back below now — the "has a real card image" branch (and its
   Scryfall-random-card fetch in changelog.js) was removed outright. */
.history-empty-sleeve {
  /* width-driven like every other sleeve: 154px wide ≈ the old 222px-tall fit */
  --card-sleeve-width: 154px;
  max-width: 100%;
  overflow: hidden;
  transform: rotate(-5deg);
}
.history-empty-card-back {
  aspect-ratio: 5 / 7;
  background:
    radial-gradient(circle at center, rgba(160, 92, 43, 0.65) 0 18%, transparent 19%),
    linear-gradient(
      135deg,
      var(--color-cardback-navy) 0 18%,
      var(--color-cardback-rust) 19% 34%,
      var(--color-cardback-parchment) 35% 66%,
      var(--color-cardback-rust) 67% 82%,
      var(--color-cardback-navy) 83%
    );
  display: block;
  width: 100%;
}
.history-empty-copy {
  display: grid;
  gap: 2px;
  justify-items: center;
  line-height: 1.25;
}
.history-empty-title {
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.history-empty-note {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  max-width: 130px;
}
.history-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}
.history-actions .btn {
  font-size: var(--font-size-xxs);
  padding: 4px 8px;
}
/* History is one compact activity surface, not a stack of beige cards. The
   stable row geometry stays still; only color and press feedback transition. */
.history-list {
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: hidden auto;
}
.history-list:has(.history-empty) {
  background: transparent;
  border-color: transparent;
}
.history-list li,
.history-list li:last-child {
  background: transparent;
  box-shadow: none;
}
.history-list li + li {
  border-top: var(--border-width) solid var(--color-line-faint);
  margin-top: 0;
}
.history-list .history-row-meta {
  align-items: center;
}
.history-list time {
  font-variant-numeric: tabular-nums;
}
.history-list .history-undo,
.history-list .history-redo,
.history-list .history-delete {
  border-radius: var(--radius-tight);
  height: 28px;
  opacity: var(--history-action-opacity, 1);
  margin-right: 0;
  transition:
    background-color var(--motion-fast) ease,
    color var(--motion-fast) ease,
    transform var(--motion-snap) cubic-bezier(0.23, 1, 0.32, 1);
  width: 28px;
}
@media (pointer: coarse) {
  /* M-11: undo/redo/delete sit 28x28 side by side per entry -- hit slop
     keeps that compact row instead of ballooning every icon to 44px. */
  .history-list .history-undo,
  .history-list .history-redo,
  .history-list .history-delete {
    position: relative;
  }
  .history-list .history-undo::before,
  .history-list .history-redo::before,
  .history-list .history-delete::before {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: max(44px, 100%);
    height: max(44px, 100%);
    transform: translate(-50%, -50%);
  }
}
.history-location-missing {
  color: var(--color-text-muted);
  cursor: default;
  opacity: 0.8;
}
.history-list .history-undo:active,
.history-list .history-redo:active,
.history-list .history-delete:active {
  transform: scale(0.94);
}
@media (hover: hover) and (pointer: fine) {
  .history-list li .history-undo,
  .history-list li .history-redo,
  .history-list li .history-delete {
    opacity: 0;
    pointer-events: none;
  }
  .history-list li:hover .history-undo,
  .history-list li:hover .history-redo,
  .history-list li:hover .history-delete,
  .history-list li:focus-within .history-undo,
  .history-list li:focus-within .history-redo,
  .history-list li:focus-within .history-delete {
    opacity: var(--history-action-opacity, 1);
    pointer-events: auto;
  }
  .history-list li:not(.history-empty):hover {
    background: var(--color-surface-hover);
  }
  .history-list .history-undo:hover,
  .history-list .history-redo:hover,
  .history-list .history-delete:hover {
    background: var(--color-surface-hover);
  }
}
.history-list li button[aria-disabled='true'],
.ticker-action[aria-disabled='true'] {
  --history-action-opacity: 0.4;
  cursor: default;
}
.history-list button[aria-disabled='true']:hover {
  background: transparent;
}
.card-name-cell {
  min-width: 128px;
  text-transform: none;
}
.card-name-cell.card-preview-link {
  cursor: default;
}
/* BEN-524: tiny card thumbnail in the row — capped to ~1.2em so it never grows
   the row height; object-position top biases the crop toward the card art. */
.card-name-thumb {
  /* BEN-524: mobile-only — hidden on desktop; sized in the mobile list-table below. */
  border: 1px solid var(--color-line);
  border-radius: 2px;
  display: none;
  flex: 0 0 auto;
  object-fit: cover;
  object-position: top;
  vertical-align: middle;
}
.card-name-button {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  display: block;
  font: inherit;
  padding: 0;
  text-align: left;
  text-transform: none;
  width: 100%;
}
body.view-list .list-view.active .card-name-cell .card-name-button {
  display: inline;
  width: auto;
}
.card-name-button:hover,
.card-name-button:focus-visible {
  text-decoration: underline;
}
.card-preview-link {
  cursor: pointer;
}
.muted {
  color: var(--color-text-muted);
}

/* BEN-406: removed the legacy bottom-border `.toggle-view` base style. The top
   view tabs are the only `.toggle-view` users and now take their appearance
   from the shared .segment-btn component. */

.history-list mark {
  color: var(--color-provenance-text);
  background: var(--color-provenance-bg);
}

.ticker-action[aria-disabled='true'] {
  opacity: 0.4;
}

/* Tomebound: sharing and detail. Cascade order is declared in ../styles.css. */

/* Share/read-only mode */
/* ---- Share: viewer banner ---- */
/* BEN-612: share + read-only banners ride the shared .banner family; only
   their deltas live here. */
.share-banner {
  flex-wrap: wrap;
}
/* F11 removed the share-mode sidebar, which held the only wordmark a shared
   page had — so a stranger opening a link saw no branding anywhere. A quiet
   serif mark, not a control: `exit` is already the way out. */
.share-banner-brand {
  color: var(--color-text-strong);
  flex: 0 0 auto;
  font-family: var(--vui-font-heading);
  font-size: var(--font-size-md);
  margin-right: 4px;
}
.share-banner.hidden {
  display: none;
}
/* BEN-517: the list/card toggle in the share banner. Only surfaced on mobile:
   the desktop shared view carries the real table/visual control in the
   collection toolbar, while the mobile toolbar and filter FAB are both hidden
   in share mode (F11 dropped the sidebar that used to hold it either way). */
.share-banner .share-banner-view-toggle {
  display: none;
}
@media (max-width: 768px) {
  .share-banner {
    flex-wrap: nowrap;
    gap: 6px;
    overflow: hidden;
  }
  .share-banner-brand {
    font-size: var(--font-size-sm);
    margin-right: 0;
  }
  .share-banner .banner-message {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .share-banner .banner-actions {
    margin-left: auto;
  }
  .share-banner .banner-actions .btn {
    min-height: 32px;
    padding: 3px 8px;
    width: auto;
  }
  .share-banner .share-banner-view-toggle {
    display: inline-flex;
  }
}

/* Read-only mode removes every WRITE affordance while leaving the full browsing
   app intact (nav, search, filters, sort, view toggles, history viewing, export).
   The commit chokepoint also no-ops writes; this keeps the UI honest so nothing
   invites an edit that won't persist. NOTE: this deliberately does NOT reuse
   `.write-only` — that class means "hidden in share view" and is also on the nav
   (.app-header-views), the whole sidebar (.app-left), and the mobile filter FAB,
   which a browsing user still needs. Write surfaces are targeted explicitly. */
body.read-only-mode .app-right, /* add-card rail */
body.read-only-mode .fab-btn[data-fab-target='addDetails'], /* add FAB (filter FAB stays) */
body.read-only-mode .bulk-bar, /* bulk edit bar */
/* NOTE: the list select column is NOT hidden here. The collection table is
   `table-layout: fixed` with an explicit <colgroup>, so `display: none` on a
   th/td leaves its <col> behind and shifts every later column's width by one
   track. Read-only mode drops `check` from the column model instead — see
   collectionTableForceHiddenColumnIds() in view.js. */
body.read-only-mode .detail-stack-panel, /* detail: +/- one, move, add copy */
body.read-only-mode .detail-advanced, /* detail: the whole edit form */
body.read-only-mode .drawer-actions, /* detail: save / delete */
body.read-only-mode .row-loc-add, /* list inline location set */
body.read-only-mode .row-tag-add, /* list/detail tag add */
body.read-only-mode .tag-chip-remove,
body.read-only-mode .loc-pill-remove,
body.read-only-mode .ui-chip-remove,
body.read-only-mode .location-pill-btn,
body.read-only-mode .location-card-edit-btn, /* decks/storage home: edit */
body.read-only-mode .location-card-menu-btn, /* decks/storage home: more (delete) */
body.read-only-mode [data-location-create-focus], /* decks/storage home: new */
body.read-only-mode .history-undo, /* history: undo / redo / delete-entry */
body.read-only-mode .history-redo,
body.read-only-mode .history-delete,
body.read-only-mode .app-history-ticker .ticker-action[data-history-ticker-action='undo'],
body.read-only-mode .app-history-ticker .ticker-action[data-history-ticker-action='redo'],
body.read-only-mode .deck-card-menu, /* deck: per-card write menu */
body.read-only-mode .deck-card-menu-btn,
body.read-only-mode .deck-share-btn, /* deck: share */
body.read-only-mode .container-identity-share, /* grid/container: share */
body.read-only-mode #deckDetailsEditor, /* deck: inline details editor */
body.read-only-mode [data-edit-deck-details]:not(.deck-hero-title-btn) {
  /* deck: edit/commander */
  display: none !important;
}

/* Editors that also display content — disabled, not hidden, so the value stays. */
body.read-only-mode [data-row-tag-trigger],
body.read-only-mode .location-picker,
body.read-only-mode .loc-link,
body.read-only-mode .deck-hero-title-btn {
  /* deck title stays visible, not editable */
  pointer-events: none;
}

/* ---- Welcome: modal (BEN-627) ---- */
/* Rides the canonical .ui-modal chrome; only the card width is specific. */
.welcome-modal-card {
  width: min(420px, calc(100vw - 32px));
}
.welcome-modal-body p {
  font-size: var(--font-size-md);
  line-height: 1.45;
  margin: 0;
}
.welcome-hype-link {
  color: var(--color-accent);
  display: inline-block;
  font-size: var(--font-size-sm);
  font-weight: 700;
  margin-top: 2px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.welcome-hype-link:hover,
.welcome-hype-link:focus-visible {
  color: var(--color-text-strong);
  text-decoration-thickness: 2px;
}

/* ---- Share: modal ---- */
/* Chrome (.ui-modal / -card / -head / -title / -body) is the canonical modal
   component; only the card width and body content layout are share-specific. */
.share-modal-card {
  width: min(440px, calc(100vw - 32px));
}
.share-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.share-modal-description {
  margin: 0;
  color: var(--color-status-neutral-text);
  font-size: var(--font-size-sm);
  line-height: 1.45;
  text-transform: none;
}
.share-modal-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.share-modal-checkbox {
  font-size: var(--font-size-md);
  color: var(--color-text-strong);
  cursor: pointer;
}
.share-modal-checkbox input {
  margin: 0;
}
.share-modal-label {
  font-size: var(--font-size-sm);
  color: var(--color-neutral-550);
  min-width: 64px;
}
.share-modal-url {
  flex: 1;
  border: 1px solid var(--color-neutral-200);
  padding: 6px 8px;
  font: inherit;
  font-size: var(--font-size-sm);
  background: var(--color-neutral-surface-faint);
  min-width: 0;
}
.share-modal-meta {
  font-size: var(--font-size-xs-plus);
  color: var(--color-status-neutral-text);
  line-height: 1.4;
}
.share-modal-actions {
  flex-wrap: wrap;
}

.collection-date-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.collection-date-unknown {
  color: var(--color-text-muted);
}

/* ---- Share: viewer mode hides write affordances ---- */
body.share-mode .write-only {
  display: none !important;
}
/* BEN-396: the list-view tag and location editors weren't tagged write-only,
   so shared viewers could still open the popover, add tags, or remove pills.
   Hide the affordances and block pointer events on the trigger cells. */
body.share-mode .row-tag-add,
body.share-mode .loc-pill-remove,
body.share-mode .ui-chip-remove,
body.share-mode .tag-chip-remove,
body.share-mode .location-pill-btn {
  display: none !important;
}
body.share-mode [data-row-tag-trigger],
body.share-mode .location-picker,
body.share-mode .loc-link {
  pointer-events: none;
}
/* F11: the shared view has no sidebar. BEN-397 kept a slim 200px rail because
   search + the visual/table toggle lived there and a viewer needed them; both
   now live in #collectionControlsToolbar inside .app-center (see
   collectionToolbarPreview.js), and the rest of the sidebar — scope nav, the
   collapse toggle, the viewer's OWN account chip — is either meaningless for
   someone else's snapshot or actively misleading about whose collection this
   is. So the rail is dropped entirely rather than collapsed: a 52px rail of
   nav buttons pointing at collections the viewer isn't looking at is worse
   than none, and the banner already owns the exit path.
   .app-left carries `write-only`, so it is hidden by the rule at the top of
   this block — no `display` override here, which also retires the equal-
   specificity `!important` standoff between the two (whoever came last won).
   Both side tracks collapse so the shared table gets the full window width. */
body.share-mode .app-shell {
  grid-template-columns: 0 minmax(0, 1fr) 0 !important;
}
/* F11: the shell is sized to the whole viewport, but the share banner is a
   sibling ABOVE it — so the shared page was always banner-tall taller than the
   window, pushing the footer and the last table rows below the fold behind a
   second scrollbar. Let the body own the viewport and hand the shell the rest. */
@media (min-width: 901px) {
  body.share-mode {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  body.share-mode .app-shell {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }
}
/* Mobile scrolls as one document, so the banner sticks to the top instead —
   "you are viewing a shared link" has to survive scrolling to the 400th row. */
@media (max-width: 900px) {
  body.share-mode .share-banner {
    position: sticky;
    top: 0;
  }
  /* The mobile footer pads itself by the bottom nav's height, and .app-center
     reserves 132px for the nav + the FAB row. Share mode hides that nav
     (below) and all but the utility FAB, so both were holding open a band of
     empty page above the totals. Reclaim it, keeping just enough clearance for
     the floating FAB, which now parks above the totals strip instead. */
  body.share-mode .app-footer {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.share-mode .fab-cluster {
    bottom: calc(var(--app-footer-h) + 34px + env(safe-area-inset-bottom, 0px));
  }
  body.share-mode.view-list .app-center,
  body.share-mode.view-grid .app-center {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
}
/* F11: the viewer's own account chip. In share mode initSyncEngine() never
   runs (app.js returns before it), so the chip renders its default local /
   "not signed in" state regardless of whether the viewer is actually signed
   in — a lie either way, and on top of that it frames someone else's snapshot
   as the viewer's own account surface. Desktop loses it with the sidebar; the
   mobile shell re-homes it into the bottom nav, whose only other content
   (.app-header-views) is already write-only, so drop the whole bar.
   The per-section `.app-left` hiding that used to live here went with it — the
   sidebar is hidden wholesale in share mode now, so those selectors were dead. */
body.share-mode .app-primary-nav,
body.share-mode .sync-account-slot {
  display: none !important;
}
/* BEN-397: hide tags column in viewer mode when the body class flag is set
   by the share viewer (no card in the share has any tags). */
body.share-mode.viewer-no-tags th.tags-cell,
body.share-mode.viewer-no-tags td.tags-cell,
body.share-mode.viewer-no-tags col.tags-cell {
  display: none;
}

#cardPreview {
  position: fixed;
  width: 300px;
  pointer-events: none;
  z-index: 1250;
  display: none;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
  transform: scale(var(--card-preview-scale, 1));
  transform-origin: top left;
  /* Border-radius matches the img inside so the .is-foil/.is-etched
       ::after overlay clips to card-shaped corners. */
  border-radius: var(--radius-card);
}
#cardPreview.visible {
  display: block;
}
#cardPreview.has-entry-info.visible {
  align-items: start;
  background: var(--color-neutral-surface-warm);
  border: 1px solid var(--color-neutral-border-warm);
  border-radius: var(--radius-soft);
  display: grid;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.28));
  gap: 10px;
  grid-template-columns: 300px 220px;
  padding: 8px;
  width: 538px;
}
#cardPreview img {
  width: 100%;
  border-radius: var(--radius-card);
  display: block;
}
#cardPreview.has-entry-info img {
  width: 300px;
}
#cardPreview.has-entry-info.is-foil::after,
#cardPreview.has-entry-info.is-etched::after {
  display: none;
}
.card-preview-info {
  color: var(--color-neutral-900);
  display: grid;
  font-size: var(--font-size-sm-plus);
  gap: 8px;
  line-height: 1.35;
  min-width: 0;
  padding: 2px 2px 0;
}
.card-preview-info-eyebrow {
  color: var(--color-status-neutral-text);
  font-size: var(--font-size-xxs);
  text-transform: none;
}
.card-preview-info-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
}
.card-preview-info-list {
  display: grid;
  gap: 5px 10px;
  grid-template-columns: minmax(62px, max-content) minmax(0, 1fr);
  margin: 0;
}
.card-preview-info-list dt {
  color: var(--color-status-neutral-text);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.card-preview-info-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay-soft);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--vui-motion-drawer) var(--vui-ease-drawer),
    visibility var(--vui-motion-drawer) allow-discrete;
}
.drawer-backdrop.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(390px, 100vw);
  height: 100vh;
  height: 100dvh;
  /* BEN-609: one drawer treatment — the add drawer's surface, border, and
     side shadow. */
  background: var(--color-bg);
  border-left: var(--border-width) solid var(--color-text-strong);
  box-shadow: var(--shadow-drawer-side);
  z-index: 1101;
  display: flex;
  flex-direction: column;
}
.detail-drawer:not(.ui-modal-card) {
  transform: translateX(100%);
  transition: transform var(--vui-motion-drawer) var(--vui-ease-drawer);
}
/* BEN-499: keep drawer scroll from rubber-banding the page body on iOS. */
.app-left,
.app-right,
.detail-drawer {
  overscroll-behavior: contain;
}
.detail-drawer.visible:not(.ui-modal-card) {
  transform: translateX(0);
}
/* History panel — same slide-over slot as card detail, sized for a log rather
   than a form. Full height, no resize handle: the old sidebar drawer's 120-640px
   dance is what made the audit log unusable. */
.history-panel {
  width: min(440px, 100vw);
}
.history-panel .drawer-head {
  align-items: flex-start;
}
.history-scope-toggle {
  margin-top: 8px;
}
.history-panel .drawer-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
}
/* Hug the entries instead of stretching the raised card to the panel's full
   height — one change should read as one row, not a giant mostly-empty sheet.
   Scrolling still kicks in once entries exceed the drawer body. */
.history-panel .history-list {
  flex: 0 1 auto;
  max-height: none;
  min-height: 0;
}
.history-panel.history-is-empty .history-list {
  flex: 1 1 auto;
}
.history-panel.history-is-empty .history-list {
  /* BEN-571: one stretched row so the empty-state sleeve can size itself to the
     panel's real height (see li.history-empty). */
  align-content: stretch;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-line-faint);
}
.drawer-title {
  font-size: var(--font-size-xl);
  font-weight: 400;
  text-transform: none;
}
.drawer-subtitle {
  margin-top: 2px;
  color: var(--color-neutral-350);
  font-size: var(--font-size-xs-plus);
}
.detail-card-identity {
  min-width: 0;
  flex: 1;
}
#detailDrawer .drawer-head > .rune-close {
  position: static;
  flex-shrink: 0;
  /* M-21: vellum's default neutral-350 (#999) is ~2.5:1 on paper — too faint
     to find. */
  color: var(--color-text-strong);
}
@media (min-width: 901px) {
  #detailDrawer .drawer-head > .rune-close {
    display: none;
  }

  #detailDrawer.detail-inspection .drawer-head > .rune-close {
    display: flex;
  }
}
.detail-card-title-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
}
/* Detail type scale: name = display; price = lg; body/headings/controls = sm;
   metadata/counts/secondary links = xs. Body uses 400, emphasis uses 600.
   The same rules govern the panel and modal, including asynchronous content. */
#detailDrawer {
  --detail-title-line-height: calc(var(--font-size-display) * 1.25);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 400;
}
#detailDrawer :where(*) {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
}
#detailDrawer
  :is(
    button,
    input,
    select,
    summary,
    h3,
    strong,
    a,
    label,
    .ui-chip,
    kbd,
    .detail-stack-summary,
    .detail-quantity-value,
    .detail-other-copy-quantity
  ) {
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}
#detailDrawer .detail-card-title-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  height: var(--detail-title-line-height);
  overflow: hidden;
}
#detailDrawer #detailTitle {
  font-family: var(--font-heading);
  font-size: var(--font-size-display);
  font-weight: 400;
  line-height: var(--detail-title-line-height);
  text-wrap: initial;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
#detailDrawer .detail-mana-cost {
  font-size: var(--font-size-lg);
  flex: 0 0 auto;
  line-height: 1;
  white-space: nowrap;
}
#detailDrawer .detail-mana-cost:empty {
  display: none;
}
#detailDrawer #detailSubtitle {
  font-size: var(--font-size-xs);
  line-height: 1.4;
  height: 1.4em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0;
  min-width: 0;
}
#detailDrawer .detail-card-metadata {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
}
#detailDrawer #detailLegality {
  height: 20px;
  font-size: var(--font-size-xs);
  margin: 0;
  flex: 0 0 auto;
  max-width: 60%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#detailDrawer
  :is(
    .detail-section-heading h3,
    .detail-advanced > summary,
    .detail-other-copy-identity strong,
    .detail-lifecycle strong
  ) {
  font-weight: 600;
}
#detailDrawer
  :is(
    .detail-section-heading > span,
    .detail-stack-meta,
    .detail-stack-location .loc-pill,
    .detail-card-deck,
    .detail-lifecycle,
    .detail-lifecycle strong,
    .detail-danger-zone span,
    .detail-nav-position,
    .btn-shortcut
  ) {
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  letter-spacing: normal;
}
#detailDrawer #detailPriceLink {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 400;
  text-decoration: underline;
  text-decoration-color: var(--color-line-strong);
  text-underline-offset: 3px;
}
#detailDrawer #detailPriceLink:is(:hover, :focus-visible) {
  color: var(--color-text-strong);
  text-decoration-color: currentColor;
}
#detailDrawer .detail-price-value {
  font-size: var(--font-size-lg);
  font-weight: 600;
}
#detailDrawer .detail-price-card {
  flex: 0 0 38px;
  height: 38px;
}
#detailDrawer .detail-stack-panel {
  flex: 0 0 auto;
}
#detailDrawer .detail-stack-summary {
  flex-wrap: nowrap;
  height: 28px;
  overflow: hidden;
}
#detailDrawer .detail-stack-location {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#detailDrawer #detailMove {
  height: 34px;
}
#detailImageWrap {
  position: relative;
}
#detailDrawer .drawer-flip-row {
  position: absolute;
  bottom: 24px;
  inset-inline: 0;
  margin: 0;
}
.detail-card-title-line .drawer-title {
  flex: 1 1 150px;
  font-family: var(--font-heading);
  font-size: 25px;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}
.detail-mana-cost {
  white-space: nowrap;
  font-size: 18px;
  line-height: 1;
}
.card-text-symbol {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-inline: 0.06em;
  vertical-align: -0.12em;
}
/* BEN-997: prev/next stepping bar — sits between the drawer head and body,
   same disabled-at-the-ends treatment as the collection-binder pager
   (.detail-nav-btn just narrows the shared .btn.btn-secondary). */
.detail-nav {
  align-items: center;
  border-bottom: 1px solid var(--color-line-faint);
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 16px;
}
.detail-nav-btn {
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
}
.detail-nav-position {
  color: var(--color-text-muted);
  flex: 0 0 16ch;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.legality-chip {
  /* Single-text chip, not a flex row — geometry and identity come from the
     .ui-chip base sticker; only the status tints below are local. */
  display: inline-block;
  margin-top: 6px;
  letter-spacing: 0.02em;
  text-transform: none;
}
.legality-chip.hidden {
  display: none;
}
.legality-chip.legal {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success-text);
}
.legality-chip.not_legal {
  background: var(--color-status-neutral-bg);
  border-color: var(--color-status-neutral-border);
  color: var(--color-status-neutral-text);
}
.legality-chip.banned {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger-text);
}
.legality-chip.restricted {
  background: var(--color-warn-bg);
  border-color: var(--color-warn-border);
  color: var(--color-warn-text);
}
/* .icon-btn itself is vellum's (28x28, transparent, neutral grey) — no local
   re-declaration (BEN-689; the byte-identical value-for-value duplicate that
   used to live here is deleted). Close-glyph rule still holds: .icon-btn
   close/dismiss buttons use × (U+00D7), .rune-close uses ✕ (U+2715), no
   literal ASCII "x" (BEN-455's flex-centering rationale for bare glyph
   buttons lives in vellum's own rule now).

   Two named modifiers cover the consumers that used to silently override
   .icon-btn's size/border per-instance:
   - .icon-btn--inline: auto width/height, for icon-btns sitting inline in a
     text/table-header context instead of the fixed 28x28 slot (search-clear,
     sort-clear, lightbox-close).
   - .icon-btn--bordered: adds the card-art contrast border + reveal-on-hover
     backplate (deck-card-menu-btn). */
.icon-btn--inline {
  width: auto;
  height: auto;
}
.icon-btn--bordered {
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sharp);
  background: var(--surface-veil);
  color: var(--color-text-strong);
}
.icon-btn--bordered:hover,
.icon-btn--bordered[aria-expanded='true'] {
  background: var(--color-surface);
  color: var(--color-text-strong);
}
.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}
#detailForm {
  margin: 0;
}
.detail-stack-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}
.detail-stack-summary {
  color: var(--color-neutral-700);
  font-size: var(--font-size-sm-plus);
  line-height: 1.35;
  text-transform: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}
.detail-quantity-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
}
.detail-control-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.detail-stack-meta {
  display: inline-flex;
  align-items: center;
}
.detail-quantity-control {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 36px minmax(42px, 1fr) 36px;
  min-height: 34px;
}
.detail-quantity-btn {
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sharp);
  height: 34px;
  min-width: 0;
  padding: 0;
}
.detail-quantity-value {
  align-items: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  display: flex;
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  font-variant-numeric: tabular-nums;
  height: 34px;
  justify-content: center;
  text-align: center;
}
.detail-stack-location .loc-pill {
  font-size: var(--font-size-xs);
  line-height: 1;
}
.detail-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
/* Compact .btn for the detail drawer quantity controls — only the size
   modifier lives here; disabled state inherits the canonical .btn:disabled. */
.detail-quick-btn {
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
}
.detail-advanced {
  border-top: 1px solid var(--color-line-faint);
  margin-top: 12px;
  padding-top: 8px;
}
.detail-section-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
}
.detail-section-heading h3 {
  font-size: var(--font-size-sm-plus);
  font-weight: 600;
  margin: 0;
  text-transform: none;
}
.detail-section-heading > span {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}
.detail-other-copies,
.detail-card-decks {
  border-top: var(--border-width) solid var(--color-line);
  margin-top: 14px;
  padding-top: 13px;
}
/* The price row already separates the first relationship section when the
   editing controls are hidden. Keep one divider at that boundary. */
body.read-only-mode .detail-scroll > .detail-other-copies:not(.hidden),
.detail-stack-panel[hidden] + .detail-scroll > .detail-other-copies:not(.hidden),
body.read-only-mode .detail-scroll > .detail-other-copies.hidden + .detail-card-decks,
.detail-stack-panel[hidden] + .detail-scroll > .detail-other-copies.hidden + .detail-card-decks {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}
.detail-other-copies-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}
.detail-other-copy {
  align-items: center;
  background: transparent;
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sm);
  color: inherit;
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 9px;
  text-align: left;
  width: 100%;
}
.detail-other-copy:hover,
.detail-other-copy:focus-visible {
  background: var(--color-surface-sunken);
  border-color: var(--color-line-strong);
  outline: none;
}
.detail-other-copy-identity {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 7px;
  min-width: 0;
}
.detail-other-copy-identity strong {
  font-size: var(--font-size-xs-plus);
  font-weight: 500;
}
.detail-other-copy-quantity {
  color: var(--color-text-muted);
  flex: 0 0 auto;
  font-family: var(--font-mono);
}
.detail-card-decks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.detail-lifecycle {
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--font-size-xs);
  gap: 6px 14px;
  margin-top: 12px;
}
.detail-lifecycle strong {
  color: var(--color-text);
  font-weight: 500;
}
.detail-danger-zone {
  align-items: center;
  border-top: var(--border-width) solid var(--color-line-faint);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
}
.detail-danger-zone span {
  color: var(--color-text-muted);
  line-height: 1.3;
}
.detail-advanced > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  list-style: none;
  min-height: 36px;
  padding: 4px 0;
  width: 100%;
}
.detail-advanced > summary:hover {
  background: var(--color-surface-sunken);
}
.detail-advanced > summary::-webkit-details-marker {
  display: none;
}
.detail-advanced > summary::before {
  content: '▸';
  color: var(--color-neutral-350);
  flex: 0 0 auto;
  margin-right: 2px;
}

@media (min-width: 601px) and (max-width: 1180px) {
  .collection-visual-grid {
    grid-template-columns: repeat(
      auto-fit,
      minmax(
        min(var(--collection-visual-card-width, 180px), 168px),
        min(var(--collection-visual-card-width, 180px), 168px)
      )
    );
  }
}
@media (max-width: 600px) {
  .collection-visual-grid {
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collection-visual-grid.is-large-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}
.detail-advanced[open] > summary::before {
  content: '▾';
}
.detail-advanced > summary:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.detail-advanced-subtitle {
  color: var(--color-neutral-350);
  flex: 1 1 auto;
  font-size: var(--font-size-xxs);
  line-height: 1.25;
  text-align: right;
}
.drawer-image-frame {
  position: relative;
  width: 100%;
  margin: 0 auto 16px;
  border-radius: var(--radius-card);
  overflow: hidden;
  aspect-ratio: 488 / 680;
}
.drawer-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: inherit;
}
.drawer-placeholder {
  width: 100%;
  aspect-ratio: 488 / 680;
  margin: 0 auto 16px;
  background: var(--color-line-faint);
  color: var(--color-neutral-350);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  border-radius: var(--radius-sharp);
}
.detail-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-field.full {
  grid-column: 1 / -1;
}
.detail-field label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
}
.detail-field input,
.detail-field select {
  border: none;
  border-bottom: var(--border-width) solid var(--color-line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--color-text-strong);
  font: inherit;
  padding: 5px 0;
  text-transform: none;
}
/* BEN-509/511/512: finish, condition, and language are real dropdowns. Keep the
   form's minimal underline aesthetic but carve in the design-system chevron so
   they read unmistakably as selects (the language select previously had no arrow). */
.detail-field .detail-form-select {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  block-size: 36px;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  inline-size: 100%;
  line-height: 1.25;
  min-block-size: 36px;
  padding: 0 26px 0 0;
  cursor: pointer;
  box-shadow: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%2315100d' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.detail-field input:focus,
.detail-field select:focus {
  border-bottom-color: var(--color-line-focus);
  outline: none;
}
#detailQty {
  max-width: 70px;
}
.condition-toggle {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  overflow: hidden;
}
.deck-export-menu-wrap {
  position: relative;
  display: inline-flex;
}
.deck-export-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  width: min(360px, calc(100vw - 32px));
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface);
  padding: 0;
  box-shadow: var(--shadow-popover);
}
/* BEN-mobile-audit M-08: right:0 anchors to the trigger button, which sits
   ~66px from the right edge on a phone, so the panel ran 24px off the left
   edge. The trigger can be anywhere along the deck actions row, so clamp to
   the viewport as a fixed sheet instead of trying to re-anchor it. The
   max-height query also catches phone landscape (~352px tall), where the
   panel opened below the trigger and ran off the bottom of the screen. */
@media (max-width: 600px), (max-height: 420px) {
  .deck-export-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    /* Clear the fixed footer ticker, matching .bulk-bar's offset below. */
    bottom: calc(12px + var(--app-footer-h));
    width: auto;
    max-height: calc(100vh - 24px - var(--app-footer-h));
    overflow-y: auto;
    /* Above the floating More button, which shares this corner. */
    z-index: 40;
  }
}
.deck-export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: var(--border-width) solid var(--color-line-subtle);
}
.deck-export-head strong {
  font-size: var(--font-size-md);
  white-space: nowrap;
}
.deck-export-panel .deck-export-form {
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
}
.deck-export-panel .deck-export-actions {
  justify-content: flex-end;
}
.deck-export-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.6fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: end;
}
.deck-export-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--color-neutral-black);
  font-size: var(--font-size-xs-plus);
}
.deck-export-checks label {
  flex-direction: row;
  align-items: center;
  color: inherit;
  font-size: inherit;
}
.deck-export-checks input {
  margin: 0;
}
.deck-export-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}
.deck-ownership-chip-wrap {
  position: relative;
  display: inline-flex;
}
.deck-missing-queue-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 30;
  width: min(420px, calc(100vw - 32px));
  max-height: min(480px, 70vh);
  overflow-y: auto;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface);
  padding: 0;
  box-shadow: var(--shadow-popover);
}
.deck-missing-queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: var(--border-width) solid var(--color-line-subtle);
}
.deck-missing-queue-head strong {
  font-size: var(--font-size-md);
  white-space: nowrap;
}
.deck-missing-queue-section {
  padding: 10px 12px;
  border-bottom: var(--border-width) solid var(--color-line-subtle);
}
.deck-missing-queue-section:last-child {
  border-bottom: none;
}
.deck-missing-queue-section h4 {
  margin: 0 0 8px;
  font-size: var(--font-size-xs-plus);
  color: var(--color-neutral-black);
}
.deck-missing-queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.deck-missing-queue-item-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.deck-missing-queue-name {
  font-weight: 600;
}
.deck-missing-queue-needed {
  color: var(--color-neutral-black);
  font-size: var(--font-size-xs-plus);
  white-space: nowrap;
}
.deck-missing-queue-explain {
  margin: 4px 0 8px;
  color: var(--color-neutral-black);
  font-size: var(--font-size-xs-plus);
}
.deck-missing-queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.deck-missing-queue-pick-label {
  font-size: var(--font-size-xs-plus);
  color: var(--color-neutral-black);
}
.deck-missing-queue-empty {
  padding: 16px 12px;
  color: var(--color-neutral-black);
  font-size: var(--font-size-sm);
}
.deck-notes-panel p {
  margin: 0;
  max-width: 780px;
  line-height: 1.5;
  text-transform: none;
  white-space: pre-wrap;
}
.language-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
  vertical-align: top;
}
.condition-toggle input,
.language-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.condition-toggle label,
.language-toggle label {
  cursor: pointer;
}
.condition-toggle span,
.language-toggle span {
  display: block;
  padding: 6px 4px;
  text-align: center;
  border-right: var(--border-width) solid var(--color-line-strong);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--font-size-xs-plus);
  line-height: 1;
}
.language-toggle span {
  min-width: 38px;
  padding-left: 8px;
  padding-right: 8px;
}
.condition-toggle label:last-child span {
  border-right: none;
}
.language-toggle label:last-child span {
  border-right: none;
}
.condition-toggle input:checked + span,
.language-toggle input:checked + span {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}
.condition-toggle input:focus-visible + span,
.language-toggle input:focus-visible + span {
  outline: var(--focus-ring);
  outline-offset: -2px;
}
.language-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.language-select-wrap {
  display: block;
  min-width: 132px;
}
/* The add-form language select (not inside .detail-field) keeps the carved
   design-system base look; add the chevron + appearance so it reads as a
   dropdown. The detail-drawer language select is handled by .detail-field
   select (underline + chevron) instead. */
.language-select {
  width: 100%;
}
.field-language .language-select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%2315100d' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.language-other {
  width: 54px;
  display: none;
}
.language-other.visible {
  display: inline-block;
}
.language-add {
  border: none;
  background: transparent;
  color: var(--color-neutral-350);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xl);
  line-height: 1;
  padding: 4px 6px;
}
.language-add:hover,
.language-add:focus-visible {
  color: var(--color-neutral-black);
  outline: none;
}
.tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--color-neutral-200);
  padding: 4px 0;
}
.detail-drawer .tags-row .row-tag-add {
  position: static;
  inset: auto;
}
@media (pointer: coarse) {
  /* M-11: the table's tag "+" is 18x18 too, but its whole cell is already a
     tap target (listRowActions.js openRowTagEditor trigger). In the detail
     drawer it's a lone control in the chip row, so it needs its own hit
     slop instead. */
  .detail-drawer .tags-row .row-tag-add {
    position: relative;
  }
  .detail-drawer .tags-row .row-tag-add::before {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: max(44px, 100%);
    height: max(44px, 100%);
    transform: translate(-50%, -50%);
  }
}
.tags-row:focus-within {
  border-bottom-color: var(--color-neutral-black);
}
.tag-chips {
  display: contents;
}
/* BEN-421 → one chip: .tag-chip geometry and identity come entirely from the
   vellum .ui-chip base now. Tag colors arrive via the inline --ui-chip-bg /
   --ui-chip-border hooks (set by ui/tagChipUi.js), no local variant rules. */
.tag-input {
  flex: 1 1 100px;
  min-width: 80px;
  /* Beats the local generic input:not([type]) field reset below, not vellum. */
  border: none !important;
  border-bottom: none !important;
  background: transparent;
  color: var(--color-neutral-black);
  font: inherit;
  padding: 2px 0 !important;
  text-transform: none;
}
.tag-input:focus {
  outline: none;
}
.checkbox-field {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-neutral-350);
  font-size: var(--font-size-xs-plus);
}
.drawer-actions {
  background: var(--color-bg);
  border-top: 1px solid var(--color-status-neutral-border);
  box-shadow: 0 -6px 14px rgba(0, 0, 0, 0.04);
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}
.detail-drawer:not(.detail-advanced-open) .drawer-actions {
  display: none;
}
.drawer-actions .btn {
  flex: 1 1 0;
  min-width: 0;
}
.detail-price-card {
  align-items: baseline;
  border-bottom: var(--border-width) solid var(--color-line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 0 1px 11px;
  text-transform: none;
}
.detail-price-value {
  font-family: var(--font-mono);
  font-size: var(--font-size-lg);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  min-width: 0;
}
.detail-price-card #detailPriceMark {
  color: var(--color-neutral-350);
  cursor: help;
}
.detail-price-card a {
  color: var(--color-neutral-350);
  font-size: var(--font-size-xs);
  margin-inline-start: auto;
  text-decoration-line: underline;
  text-decoration-color: var(--color-neutral-200);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.detail-price-card a:hover {
  color: var(--color-neutral-black);
  text-decoration-color: var(--color-neutral-black);
}
.drawer-actions .btn {
  flex-direction: column;
  gap: 4px;
}
.detail-drawer .btn-shortcut {
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: 3px;
  color: currentColor;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  font-weight: 400;
  line-height: 1;
  margin: 0;
  opacity: 0.72;
  padding: 2px 4px;
  white-space: nowrap;
}
/* M-20: `display` moved behind (hover: hover) — this selector's specificity
   otherwise beats the generic `.btn-shortcut { display: none }` touch rule,
   so the Shift Enter/Esc chips kept showing on touch. */
@media (hover: hover) {
  .detail-drawer .btn-shortcut {
    display: inline-flex;
  }
}
.detail-drawer .drawer-actions .btn:not(.btn-secondary) .btn-shortcut {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.42);
  opacity: 0.9;
}
.detail-price-sparkline {
  margin-top: 8px;
  width: min(100%, 220px);
}
.detail-price-sparkline.hidden {
  display: none;
}
.detail-price-sparkline-chart {
  display: block;
  width: 100%;
  height: 56px;
}
.detail-price-sparkline-line {
  fill: none;
  stroke: var(--color-sparkline-line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}
.detail-price-sparkline-area {
  fill: rgba(95, 134, 176, 0.16);
  stroke: none;
}
.detail-price-sparkline-baseline {
  fill: none;
  stroke: var(--color-line-warm-mid);
  stroke-dasharray: 2 3;
  stroke-width: 1;
}
.detail-price-sparkline-label {
  color: var(--color-text-warm-label);
  font-size: var(--font-size-xxs);
  margin-top: 4px;
}
.detail-printing-meta {
  border-top: 1px solid var(--color-line-parchment);
  margin-top: 10px;
  padding-top: 8px;
  display: grid;
  gap: 5px;
}
.detail-printing-meta.hidden {
  display: none;
}
.detail-printing-meta-row {
  align-items: baseline;
  color: var(--color-text-warm-muted);
  display: flex;
  gap: 8px;
  font-size: var(--font-size-xs);
  line-height: 1.35;
}
.detail-printing-meta-row.hidden {
  display: none;
}
.detail-printing-meta-label {
  color: var(--color-text-warm-faint);
  min-width: 72px;
  text-transform: none;
}
.detail-printing-meta-values {
  color: var(--color-text-warm-strong);
  text-transform: none;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  box-sizing: border-box;
  cursor: zoom-out;
}
.image-lightbox.visible {
  display: flex;
}
.image-lightbox img {
  max-width: min(100%, 900px);
  max-height: calc(100dvh - 128px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 3%;
  display: block;
  box-shadow: none;
  cursor: default;
}
.image-lightbox .lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: var(--radius-round);
  background: transparent;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}
.image-lightbox .lightbox-close:hover {
  background: rgb(255 255 255 / 12%);
}
.image-lightbox .lightbox-close:focus-visible,
.image-lightbox .lightbox-flip:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.image-lightbox .lightbox-flip {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-neutral-black);
  border: none;
  border-radius: var(--radius-tight);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-sm);
  text-transform: none;
  padding: 8px 16px;
}
.image-lightbox .lightbox-flip:hover {
  background: var(--color-neutral-white);
}
.image-lightbox .lightbox-flip.hidden {
  display: none;
}

/* Small-size modifier on .btn .btn-secondary — colors/border inherited from
   the secondary variant; only size lives here. */
.flip-btn {
  font-size: var(--font-size-xs);
  letter-spacing: 0.02em;
  min-height: 0;
  padding: 4px 10px;
}
.flip-btn.hidden {
  display: none;
}
.drawer-flip-row {
  display: flex;
  justify-content: center;
  margin: -8px 0 12px;
}

.add-preview-existing {
  display: inline-block;
  background: var(--color-warn-bg-soft);
  border: 1px solid var(--color-warn-border);
  color: var(--color-warn-text);
  padding: 2px 8px;
  border-radius: var(--radius-round);
  font-size: var(--font-size-xs);
  margin-bottom: 8px;
  text-transform: none;
  letter-spacing: 0.02em;
}
.add-preview-existing.hidden {
  display: none;
}

/* Feedback uses one quiet, neutral container. Tone belongs in the copy, not a
   colored outline/left rail that makes transient import progress look like an
   error state. This applies to every showFeedback() toast, not only imports. */
.toast.feedback-toast-info,
.toast.feedback-toast-success,
.toast.feedback-toast-warning,
.toast.feedback-toast-error,
.toast.feedback-toast-progress {
  border-color: var(--color-line);
}

/* Progress toast: spinner reads as part of the message, not a separate item. */
.toast.feedback-toast-progress {
  gap: 8px;
}

.status-state {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.status-state .loading-spinner {
  margin-right: 2px;
}
.status-state-message {
  font-weight: 500;
}
.status-state-detail {
  color: var(--color-text-muted);
}
.status-state-inline-error .status-state-message,
.status-state-blocking-error .status-state-message,
.status-state-retryable-error .status-state-message {
  color: var(--color-danger-text-deep);
}
.status-state-retry {
  margin-left: 6px;
  padding: 2px 8px;
  font-size: var(--font-size-xs);
}

/* .hidden { display:none !important } comes from vellum-ui.css (loads first,
   identical rule) — local duplicate deleted per BEN-686 audit. */
.price-fallback-mark {
  color: var(--color-neutral-350);
  cursor: help;
  margin-left: 1px;
}

/* Keep destructive sharing actions legible against the warm dialog surface. */
.share-modal-actions .btn.btn-danger,
.share-modal-actions .btn.btn-danger:hover:not(:disabled) {
  color: color-mix(in srgb, var(--color-danger) 60%, var(--color-text-strong));
}

/* In-app help reader. Shared modal chrome and independent content scroll. */
.help-modal > .ui-modal-card {
  container-type: inline-size;
  width: min(1060px, calc(100vw - 32px));
  height: calc(100dvh - 48px);
  max-height: calc(100dvh - 32px);
  box-shadow: none;
}
.help-modal .ui-modal-head {
  flex-shrink: 0;
}
.help-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  font-size: var(--font-size-base);
  line-height: 1.55;
  color: var(--color-text);
}
.help-modal-search {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-line);
}
.help-modal-search input {
  width: 100%;
  min-height: 36px;
}
.help-modal-search-status {
  grid-column: 2;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.help-modal-search-status:empty {
  display: none;
}
.help-modal-layout {
  display: grid;
  grid-template-columns: minmax(120px, 22%) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}
.help-modal-contents {
  padding: var(--space-4);
  overflow-y: auto;
  border-right: 1px solid var(--color-line);
}
.help-modal-contents > summary {
  display: none;
}
.help-modal-contents nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.help-modal-contents a {
  display: block;
  padding: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--font-size-md);
}
.help-modal-contents a:hover,
.help-modal-contents a[aria-current] {
  background: var(--color-surface-sunken);
  color: var(--color-text-strong);
  text-decoration: underline;
}
.help-modal-reader {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-4) var(--space-5) var(--space-5);
  overflow-wrap: anywhere;
  scroll-padding-top: var(--space-4);
}
.help-modal-reader p {
  margin: 0 0 var(--space-4);
}
.help-modal-section + .help-modal-section {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-line);
}
.help-modal-section h3 {
  font-family: var(--font-heading);
  font-size: var(--font-size-heading);
  margin: 0 0 var(--space-2);
}
.help-modal-topic h4 {
  font-size: var(--font-size-lg);
  margin: var(--space-5) 0 var(--space-2);
}
.help-modal-topic ul {
  margin: 0;
  padding-left: var(--space-5);
}
.help-modal-topic li + li {
  margin-top: var(--space-2);
}
.help-modal mark {
  background: var(--color-text);
  color: var(--color-surface);
}
.help-modal-status {
  padding: var(--space-4);
}
.help-modal-status a {
  margin-left: var(--space-4);
}
@media (max-width: 700px) {
  .help-modal > .ui-modal-card {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .help-modal-search {
    grid-template-columns: minmax(0, 1fr);
  }
  .help-modal-search-status {
    grid-column: 1;
  }
  .help-modal-layout {
    display: flex;
    flex-direction: column;
  }
  .help-modal-contents {
    flex-shrink: 0;
    max-height: 38%;
    padding: var(--space-2) var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--color-line);
  }
  .help-modal-contents > summary {
    display: list-item;
    cursor: pointer;
    padding: var(--space-2) 0;
  }
  .help-modal-reader {
    flex: 1;
    padding: var(--space-4);
  }
}

/* Tomebound: onboarding. First-account setup chooser and capability handoff. */
.onboarding-modal {
  z-index: 190;
}

.onboarding-modal-card {
  width: min(620px, calc(100vw - 32px));
}

.onboarding-modal-head {
  min-height: 68px;
  padding-bottom: 10px;
  padding-top: 10px;
}

.onboarding-modal-head > div {
  min-width: 0;
}

.onboarding-step {
  color: var(--color-text-muted);
  display: block;
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  margin-bottom: 3px;
  text-transform: none;
}

.onboarding-title {
  font-size: var(--font-size-lg);
}

.onboarding-modal-body {
  padding: 18px;
}

.onboarding-guide-description {
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  line-height: 1.5;
  margin: 0 0 16px;
}

.onboarding-paths {
  display: grid;
  gap: 10px;
}

.onboarding-path {
  align-items: center;
  background: var(--color-surface-raised, var(--color-surface));
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 12px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  padding: 14px;
  text-align: left;
  text-transform: none;
  width: 100%;
}

.onboarding-path:hover,
.onboarding-path:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
  outline: none;
}

.onboarding-path-icon {
  align-items: center;
  background: var(--color-accent-soft);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
  display: flex;
  font-size: 18px;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.onboarding-path strong,
.onboarding-path small {
  display: block;
}

.onboarding-path strong {
  font-size: var(--font-size-md);
  line-height: 1.3;
}

.onboarding-path small {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  margin-top: 3px;
}

.onboarding-path-arrow {
  color: var(--color-text-muted);
  font-size: 18px;
}

.onboarding-modal-actions {
  justify-content: space-between;
}

.onboarding-guide-actions .btn:last-child {
  margin-left: auto;
}

@media (max-width: 560px) {
  .onboarding-modal-card {
    max-height: calc(100dvh - 16px);
    width: calc(100vw - 16px);
  }

  .onboarding-modal-body {
    padding: 14px;
  }

  .onboarding-path {
    gap: 10px;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    padding: 12px;
  }

  .onboarding-path-icon {
    height: 32px;
    width: 32px;
  }
}

/* Tomebound: import and add card. Cascade order is declared in ../styles.css. */

/* Import and add-card panels */
details.import-details,
details.add-details {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--color-neutral-white);
  border: 1px solid var(--color-line-faint);
  border-radius: var(--radius-tight);
}
details.import-details summary,
details.add-details summary {
  cursor: pointer;
  font-size: var(--font-size-sm);
  letter-spacing: 0;
}
details.import-details summary::marker,
details.add-details summary::marker {
  color: var(--color-neutral-350);
}
details.import-details .details-body,
details.add-details .details-body {
  margin-top: 12px;
}
/* BEN-535: the add panel is no longer a collapsible disclosure — hide the
   summary so the scan / lookup / import tabs sit across the top of the add
   drawer, always visible. (Kept as <details> so the .open machinery + toggle
   focus still drive the drawer; it just never collapses.) */
#addDetails > summary {
  display: none;
}
#addDetails > .details-body {
  margin-top: 0;
}
.mcp-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mcp-chat-widget {
  position: fixed;
  right: 16px;
  bottom: 148px;
  z-index: 75;
  display: flex;
  flex-direction: column;
  width: min(var(--mcp-chat-width, 420px), calc(100vw - 24px));
  height: min(var(--mcp-chat-height, 430px), calc(100dvh - 24px));
  min-width: min(340px, calc(100vw - 24px));
  min-height: min(320px, calc(100dvh - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  /* one floating-panel frame: the modal-card tokens (BEN-634) */
  background: var(--color-surface);
  border: var(--vui-modal-card-border);
  border-radius: var(--vui-modal-card-radius);
  box-shadow: var(--vui-modal-card-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  visibility: hidden;
  /* Corner rounding follows vellum's technique (.feedback-capture-body):
     overflow: visible on the frame + inner-radius clipping on the head/body
     children, not overflow: hidden on the frame itself (BEN-689) — that
     would clip outside-edge decorations like the resize grip. */
  overflow: visible;
  resize: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    visibility 120ms ease;
}
.mcp-chat-widget.is-positioned {
  left: var(--mcp-chat-left);
  top: var(--mcp-chat-top);
  right: auto;
  bottom: auto;
}
.mcp-chat-widget.is-dragging,
.mcp-chat-widget.is-resizing {
  transition: none;
  user-select: none;
}
.mcp-chat-resize-handle {
  position: absolute;
  z-index: 3;
  touch-action: none;
}
.mcp-chat-resize-left {
  bottom: 12px;
  cursor: ew-resize;
  left: 0;
  top: 42px;
  width: 8px;
}
.mcp-chat-resize-right {
  bottom: 12px;
  cursor: ew-resize;
  right: 0;
  top: 42px;
  width: 8px;
}
.mcp-chat-resize-bottom {
  bottom: 0;
  cursor: ns-resize;
  height: 8px;
  left: 12px;
  right: 12px;
}
.mcp-chat-resize-bottom-left {
  bottom: 0;
  cursor: nesw-resize;
  height: 16px;
  left: 0;
  width: 16px;
}
.mcp-chat-resize-bottom-right {
  bottom: 0;
  cursor: nwse-resize;
  height: 16px;
  right: 0;
  width: 16px;
}
body.mcp-chat-open .mcp-chat-widget {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}
.mcp-chat-head {
  cursor: grab;
  gap: 12px;
  touch-action: none;
  border-radius: calc(var(--vui-modal-card-radius) - var(--vui-border-width))
    calc(var(--vui-modal-card-radius) - var(--vui-border-width)) 0 0;
}
.mcp-chat-widget.is-dragging .mcp-chat-head {
  cursor: grabbing;
}
.mcp-chat-head-actions {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}
.mcp-chat-head .ui-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.mcp-chat-seal {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mcp-chat-quill {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#mcpChatSend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-left: auto;
}
.mcp-chat-consulting {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-muted);
}
.mcp-chat-stars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  font-size: 12px;
}
.mcp-chat-stars > span {
  opacity: 0.3;
  animation: chat-star-light 1200ms cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.mcp-chat-stars > span:nth-child(2) {
  animation-delay: 160ms;
}
.mcp-chat-stars > span:nth-child(3) {
  animation-delay: 320ms;
}
@keyframes chat-star-light {
  0%,
  65%,
  100% {
    opacity: 0.3;
  }
  25%,
  40% {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mcp-chat-stars > span {
    animation: none;
    opacity: 0.7;
  }
}
.mcp-chat-widget .mcp-chat {
  flex: 1 1 auto;
  min-height: 0;
  /* Own scroll clipping (independent of the frame's overflow: visible above)
     plus the bottom-corner radius the frame used to provide for free. */
  overflow: hidden;
  border-radius: 0 0 calc(var(--vui-modal-card-radius) - var(--vui-border-width))
    calc(var(--vui-modal-card-radius) - var(--vui-border-width));
  padding: 10px;
}
/* BEN-608: layout only — the visual comes from the BEN-403 arcane-ledger
   field base (themed surface/border/mono), which also flips in dark. */
.mcp-chat textarea {
  width: 100%;
  min-width: 0;
}
.mcp-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--color-line-beige);
  background: var(--color-surface-raised);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mcp-chat-empty {
  align-self: stretch;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  line-height: 1.35;
  margin: auto 0;
  padding: 10px;
}
.mcp-chat-empty-title {
  color: var(--color-neutral-900);
  font-size: var(--font-size-base);
  margin-bottom: 4px;
}
.mcp-chat-empty-copy {
  margin-bottom: 10px;
}
.mcp-chat-empty-examples {
  display: grid;
  gap: 4px;
  list-style: none;
}
.mcp-chat-empty-examples li {
  min-width: 0;
}
.mcp-chat-message {
  display: grid;
  gap: 3px;
}
.mcp-chat-role {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.mcp-chat-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--font-size-base);
  line-height: 1.35;
}
.mcp-chat-inline-card.card-name-button {
  display: inline;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  width: auto;
}
.mcp-chat-inline-card.card-name-button:hover,
.mcp-chat-inline-card.card-name-button:focus-visible {
  text-decoration-style: solid;
}
.mcp-chat-inline-location {
  display: inline-flex;
  margin: 0 2px;
  vertical-align: text-bottom;
  white-space: nowrap;
}
.mcp-chat-inline-location .loc-pill {
  cursor: default;
}
.mcp-chat-card-results {
  border: 1px solid var(--color-neutral-border-warm);
  background: var(--color-neutral-surface-warm);
  display: grid;
  gap: 4px;
  margin-top: 8px;
  overflow: hidden;
  padding: 6px;
}
.mcp-chat-card-results-head {
  align-items: center;
  color: var(--color-neutral-500);
  display: flex;
  font-size: var(--font-size-xs);
  gap: 8px;
  justify-content: space-between;
  text-transform: none;
}
.mcp-chat-card-results-actions {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}
.mcp-chat-card-results-copy {
  background: transparent;
  border: none;
  color: var(--color-neutral-550);
  cursor: pointer;
  font-size: var(--font-size-xs);
  padding: 0;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.mcp-chat-card-results-copy:hover,
.mcp-chat-card-results-copy:focus-visible {
  color: var(--color-neutral-black);
  outline: none;
}
.mcp-chat-card-summary {
  display: grid;
  gap: 4px;
}
.mcp-chat-card-summary-item {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
  padding: 2px 0;
}
.mcp-chat-card-summary-meta {
  font-size: var(--font-size-sm-plus);
}
.mcp-chat-card-summary-location {
  display: inline-flex;
}
.mcp-chat-card-details {
  border-top: 1px solid var(--color-line-beige-soft);
  margin-top: 2px;
  padding-top: 4px;
}
.mcp-chat-card-details > summary {
  color: var(--color-neutral-500);
  cursor: pointer;
  font-size: var(--font-size-xs);
  line-height: 1.2;
  width: max-content;
}
.mcp-chat-card-details[open] {
  display: grid;
  gap: 4px;
}
.mcp-chat-card-list {
  display: grid;
  overflow-x: auto;
}
.mcp-chat-card-row {
  border-top: 1px solid var(--color-line-beige-soft);
  display: grid;
  grid-template-columns:
    minmax(180px, 1.6fr) 64px 48px 72px 58px 76px minmax(140px, 1fr) minmax(130px, 1fr)
    44px 72px 44px;
  min-width: 970px;
}
.mcp-chat-card-header {
  background: var(--color-surface-parchment);
  border-top: 0;
  color: var(--color-neutral-500);
  font-size: var(--font-size-xxs);
  line-height: 1;
  text-transform: none;
}
.mcp-chat-card-header-cell {
  align-items: center;
  display: flex;
  min-width: 0;
  padding: 4px 8px;
  white-space: nowrap;
}
.mcp-chat-reference-row > *:not(.mcp-chat-card-move) {
  align-items: center;
  display: flex;
  min-width: 0;
  padding: 6px 8px;
}
.mcp-chat-reference-row .card-name-button {
  white-space: normal;
}
.mcp-chat-reference-row .tags-cell {
  padding-top: 4px;
  padding-bottom: 4px;
}
.mcp-chat-card-edit-cell {
  justify-content: flex-end;
}
.mcp-chat-card-edit {
  background: transparent;
  border: none;
  color: var(--color-status-neutral-text);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xs);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.mcp-chat-card-edit:hover,
.mcp-chat-card-edit:focus-visible {
  color: var(--color-neutral-black);
  outline: none;
}
.mcp-chat-card-move {
  border-left: 2px solid var(--color-line-warm-divider-strong);
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
  padding-left: 8px;
}
.mcp-chat-card-move-field {
  display: grid;
  gap: 3px;
}
.mcp-chat-card-move-field span {
  color: var(--color-neutral-500);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.mcp-chat-card-move select,
.mcp-chat-card-move input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-white);
  border-radius: var(--radius-tight);
  color: var(--color-neutral-900);
  font: inherit;
  min-height: 30px;
  padding: 4px 6px;
}
.mcp-chat-card-move-new {
  display: grid;
  gap: 6px;
  grid-template-columns: 92px minmax(0, 1fr);
}
.mcp-chat-card-move-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.mcp-chat-card-move-error {
  color: var(--color-danger-text-plain);
  flex: 1;
  font-size: var(--font-size-xs);
  line-height: 1.2;
}
.mcp-chat-preview-panel,
.mcp-chat-draft-panel {
  border: 1px solid var(--color-neutral-900);
  background: var(--color-neutral-surface-warm);
  display: grid;
  gap: 8px;
  margin: 8px 0;
  max-height: min(26vh, 220px);
  overflow: auto;
  padding: 8px;
}
.mcp-chat-draft-panel {
  max-height: min(38vh, 340px);
}
.mcp-chat-preview-panel,
.mcp-chat-draft-panel,
.mcp-chat-preview-list,
.mcp-chat-preview-group,
.mcp-chat-draft-row,
.mcp-chat-draft-controls {
  grid-template-columns: minmax(0, 1fr);
}
.mcp-chat-signedout {
  border: 1px solid var(--color-neutral-900);
  background: var(--color-neutral-surface-warm);
  display: grid;
  gap: 8px;
  justify-items: start;
  margin: 8px 0;
  padding: 10px;
}
.mcp-chat-signedout-copy {
  color: var(--color-neutral-700);
  font-size: var(--font-size-sm-plus);
  line-height: 1.3;
}
.mcp-chat-preview-head,
.mcp-chat-preview-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}
.mcp-chat-preview-title {
  font-size: var(--font-size-xs);
  text-transform: none;
  color: var(--color-neutral-550);
}
.mcp-chat-preview-list {
  display: grid;
  gap: 8px;
}
.mcp-chat-preview-group {
  display: grid;
  gap: 6px;
}
.mcp-chat-preview-group-title {
  color: var(--color-status-neutral-text);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.03em;
  text-transform: none;
}
.mcp-chat-preview-row {
  border-top: 1px solid var(--color-line-beige);
  padding-top: 8px;
}
.mcp-chat-preview-row.has-error .mcp-chat-preview-meta {
  color: var(--color-danger-text-plain);
}
.mcp-chat-draft-row {
  border-top: 1px solid var(--color-line-beige);
  display: grid;
  gap: 6px;
  padding-top: 6px;
}
.mcp-chat-draft-row.has-error .mcp-chat-preview-meta {
  color: var(--color-danger-text-plain);
}
.mcp-chat-draft-controls {
  display: grid;
  gap: 6px;
}
.mcp-chat-draft-add-preview {
  align-items: center;
  flex-direction: row;
  gap: 10px;
  margin-top: 0;
  min-height: 0;
  padding-top: 0;
  border-top: 0;
}
.mcp-chat-draft-add-preview .add-preview-img-wrap {
  gap: 0;
}
.mcp-chat-draft-add-preview .add-preview-img {
  width: 74px;
}
.mcp-chat-draft-add-preview .add-preview-name {
  font-size: var(--font-size-lg);
  line-height: 1.1;
  margin-bottom: 1px;
}
.mcp-chat-draft-add-preview .add-preview-meta {
  font-size: var(--font-size-xs);
  line-height: 1.25;
  margin-bottom: 0;
}
.mcp-chat-draft-printing-picker {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.mcp-chat-draft-printing-picker .printing-list {
  max-height: 112px;
}
.mcp-chat-draft-printing-picker .printing-row {
  padding-top: 4px;
  padding-bottom: 4px;
}
.mcp-chat-draft-option-bar {
  display: grid;
  gap: 7px;
  grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr);
}
.mcp-chat-draft-field {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.mcp-chat-draft-field-wide,
.mcp-chat-draft-printing {
  grid-column: 1 / -1;
}
.mcp-chat-draft-field span {
  color: var(--color-neutral-500);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.mcp-chat-draft-field input,
.mcp-chat-draft-field select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-white);
  border-radius: var(--radius-tight);
  color: var(--color-neutral-900);
  font: inherit;
  min-height: 30px;
  padding: 4px 6px;
}
.mcp-chat-draft-printing {
  color: var(--color-neutral-700);
  font-size: var(--font-size-sm-plus);
  line-height: 1.25;
}
.mcp-chat-preview-summary {
  font-size: var(--font-size-base);
  line-height: 1.25;
}
.mcp-chat-preview-meta {
  color: var(--color-neutral-500);
  font-size: var(--font-size-xs);
  line-height: 1.25;
  margin-top: 2px;
}
.mcp-chat-preview-actions,
.mcp-chat-preview-row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.mcp-chat-preview-action {
  min-height: 28px;
  min-width: 0;
  padding: 0 8px;
}
.mcp-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 0 0 auto;
  gap: 8px;
  align-items: end;
}
.mcp-chat-form textarea {
  min-height: 70px;
  resize: none;
}
.mcp-chat-form .btn {
  min-height: 32px;
  min-width: 56px;
}
@media (hover: none) {
  .mcp-chat-head {
    cursor: auto;
    touch-action: auto;
  }
}
.mcp-chat-apply {
  justify-self: start;
  margin-top: 4px;
}
body.share-mode .mcp-chat-widget,
body.share-mode .sync-details-modal,
body.share-mode .mcp-chat-fab {
  display: none;
}

/* Add-cards panel */
/* .tab-row/.tab-btn (vellum) — first consumer (BEN-689). Only the
   icon+label layout delta lives here; chrome/active-state/focus all come
   from vellum. */
.add-tabs {
  margin-bottom: 12px;
}
.add-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.add-tab-icon,
.add-tab-icon-svg {
  display: inline-flex;
  flex: 0 0 auto;
}

.add-mode {
  display: none;
}
.add-mode.active {
  display: block;
}
/* A paired phone only sends scans to its computer, including the shared editor. */
.scan-standalone-page .add-tabs,
.scan-standalone-page .add-mode:not(#addModeScan),
.scan-standalone-page #cardScanManual,
.scan-standalone-page .card-scan-handoff,
.scan-standalone-page .card-scan-queue,
.scan-standalone-page #addPreviewExisting,
.scan-standalone-page .field:has(#addTagsRow),
.scan-standalone-page .add-fields .field-location,
.scan-standalone-page #addDeckOptions {
  display: none;
}
/* The paired link owns the document, outside the collection and drawer layers.
   Feedback and card art remain available to the shared confirmation editor. */
body.scan-standalone > :not(#scanStandalone, #feedback, .image-lightbox) {
  display: none !important;
}
body.scan-standalone {
  height: auto;
  min-height: 100dvh;
  overflow-y: auto;
}
.scan-standalone-page:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.scan-standalone-header h1 {
  font-size: var(--font-size-xl);
  margin: 0 0 6px;
}
.scan-standalone-header p {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin: 0;
}
.scan-standalone-page #addDetails {
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
}
.scan-standalone-page #addDetails,
.scan-standalone-page #addDetails > .details-body,
.scan-standalone-page #addModeScan.active {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.scan-standalone-page #addModeScan.active {
  gap: 12px;
  min-height: calc(100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.scan-standalone-page .card-scan-stage {
  aspect-ratio: 4 / 5;
  flex: none;
  min-height: 0;
  max-height: 65dvh;
  width: 100%;
}
.scan-standalone-page #addModeScan:has(.card-scan-candidates:not([hidden])) .card-scan-stage {
  flex: none;
  height: 25dvh;
  min-height: 0;
}
.scan-standalone-page .card-scan-status,
.scan-standalone-page .card-scan-privacy {
  margin: 0;
}
.scan-standalone-page .card-scan.is-paired-phone .card-scan-privacy::before {
  content: none;
}
.scan-standalone-page .card-scan-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.scan-standalone-page .card-scan-actions .btn {
  flex: 1;
  min-height: 48px;
}
.scan-standalone-page .add-preview {
  scroll-margin-top: 16px;
}
.scan-standalone-page #addEditor .add-actions {
  background: var(--color-bg);
}
.add-printing-toggle {
  margin-top: 8px;
}
#addDetails[data-add-mode='scan'] .printing-picker.scan-collapsed {
  display: none;
}

.card-scan {
  --scan-card-ratio: 0.716;
}
.card-scan-handoff {
  display: grid;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}
.card-scan-handoff.has-qr {
  grid-template-columns: minmax(0, 1fr);
}
.card-scan-handoff-copy,
.card-scan-handoff-copy > div:first-child {
  display: grid;
  gap: 8px;
}
.card-scan-handoff-copy > div:first-child {
  gap: 3px;
}
.card-scan-handoff span,
.card-scan-privacy {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm-plus);
  line-height: 1.35;
}
.card-scan-handoff span[data-connected='true'] {
  color: var(--color-status-success-text);
}
.card-scan-qr {
  background: var(--color-neutral-white);
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-tight);
  display: none;
}
.card-scan-handoff.has-qr .card-scan-qr {
  display: block;
}
.add-preview {
  scroll-margin-top: 72px;
}
.card-scan-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}
.card-scan-link-row input {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-size-sm);
  min-width: 0;
  width: 100%;
}
.card-scan-stage {
  align-items: center;
  aspect-ratio: 4 / 5;
  /* M-27: aspect-ratio + max-height already shrink this narrower than its
     container; without this it sits at the left edge instead of centered. */
  margin-inline: auto;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--color-neutral-black) 92%, var(--color-surface)),
    color-mix(in srgb, var(--color-neutral-black) 76%, var(--color-surface))
  );
  border: 1px solid var(--color-neutral-700);
  border-radius: var(--radius-tight);
  display: grid;
  justify-items: center;
  max-height: 54dvh;
  overflow: hidden;
  position: relative;
}
.card-scan-stage video {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: none;
  display: none;
  height: 100%;
  object-fit: cover;
  object-position: center;
  width: 100%;
}
.card-scan-stage.is-live video {
  display: block;
}
.card-scan-frame {
  aspect-ratio: var(--scan-card-ratio);
  border: 2px solid color-mix(in srgb, var(--color-neutral-white) 78%, transparent);
  border-radius: 9px;
  display: none;
  height: min(80%, 440px);
  max-width: 92%;
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.card-scan-stage.is-live .card-scan-frame {
  display: block;
}
.card-scan-stage[data-quality='captured'] .card-scan-frame {
  border-color: color-mix(in srgb, var(--color-status-success-text) 82%, white);
}
.card-scan-idle {
  align-items: center;
  color: color-mix(in srgb, var(--color-text-inverse) 72%, transparent);
  display: grid;
  gap: 10px;
  justify-items: center;
}
.card-scan-idle svg {
  fill: none;
  height: 52px;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.25;
  width: 52px;
}
.card-scan-stage.is-live .card-scan-idle,
.card-scan-working {
  display: none;
}
.card-scan:not(.is-paired-phone).is-analyzing .card-scan-working {
  align-items: center;
  background: color-mix(in srgb, var(--color-neutral-black) 68%, transparent);
  color: var(--color-text-inverse);
  display: flex;
  gap: 8px;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: var(--radius-tight);
  padding: 8px 12px;
  justify-content: center;
  position: absolute;
  z-index: 2;
}
.card-scan.is-pair-host > .card-scan-stage,
.card-scan.is-pair-host > .card-scan-status,
.card-scan.is-pair-host > .card-scan-candidates,
.card-scan.is-pair-host > .card-scan-actions,
.card-scan.is-pair-host > .card-scan-privacy,
.card-scan:not(.is-pair-host) > .card-scan-handoff,
.card-scan.is-paired-phone ~ #addPrintingToggle,
.card-scan.is-paired-phone ~ #addPrintingPicker,
.card-scan.is-paired-phone ~ #addPreview,
.card-scan.is-paired-phone ~ #addEditor {
  display: none;
}
.card-scan.has-connected-phone:not(.show-phone-link) .card-scan-qr-slot,
.card-scan.has-connected-phone:not(.show-phone-link) .card-scan-link-row {
  display: none;
}
.card-scan.has-connected-phone:not(.show-phone-link) .card-scan-handoff.has-qr {
  grid-template-columns: minmax(0, 1fr);
}
.card-scan-status {
  display: grid;
  gap: 4px;
  line-height: 1.35;
  margin: 10px 0 8px;
  min-height: 19px;
}
.card-scan-processing {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.card-scan-reconnect {
  justify-self: start;
}
.card-scan-status[data-kind='error'] {
  color: var(--color-danger-text-deep);
}
.card-scan-status[data-kind='success'] {
  color: var(--color-status-success-text);
}
.card-scan-status[data-kind='uncertain'] {
  color: var(--color-status-warning-text);
}
.card-scan-candidates {
  border-top: 1px solid var(--color-line-faint);
  margin: 8px 0 10px;
  padding-top: 10px;
}
.card-scan-candidate-list {
  display: grid;
  gap: 5px;
}
.card-scan-candidate {
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-tight);
  color: var(--color-text);
  cursor: pointer;
  display: grid;
  font: inherit;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  padding: 6px;
  text-align: left;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    transform 140ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
}
.card-scan-candidate:active {
  transform: scale(0.98);
}
.card-scan-candidate img {
  border-radius: 3px;
  display: block;
  width: 34px;
}
.card-scan-candidate span {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.card-scan-candidate strong,
.card-scan-candidate small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-scan-candidate small {
  color: var(--color-text-muted);
}
@media (hover: hover) and (pointer: fine) {
  .card-scan-candidate:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-line-strong);
  }
}
/* Desktop review queue. Each row keeps the printing and physical details together. */
.card-scan-queue {
  margin: 16px 0;
}
.card-scan.is-paired-phone .card-scan-queue {
  display: none;
}
.card-scan-queue:not(:has(.scan-queue-row)) {
  display: none;
}
.card-scan-queue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-scan-queue-totals {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.card-scan-queue-list {
  display: grid;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: none;
  overflow: visible;
}
ul.card-scan-queue-list > li.scan-queue-row {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
ul.card-scan-queue-list > li.scan-queue-row + li.scan-queue-row {
  border-top: 1px solid var(--color-line-subtle);
}
.scan-queue-card {
  display: grid;
  grid-template-columns: minmax(100px, 36%) minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
  min-width: 0;
}
.scan-queue-card:not(:has(.scan-queue-thumb)) {
  grid-template-columns: minmax(0, 1fr);
}
.scan-queue-summary {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.scan-queue-heading {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.scan-queue-heading > input {
  margin-top: 5px;
  flex: none;
}
.scan-queue-thumb {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 150px;
  aspect-ratio: 0.716;
  object-fit: contain;
  object-position: top;
  border-radius: 6px;
}
.scan-queue-card-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.scan-queue-card-copy strong {
  font-size: var(--font-size-sm-plus);
  line-height: 1.35;
}
.scan-queue-properties {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}
.scan-queue-state {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.scan-queue-row-confirmed .scan-queue-state,
.scan-queue-row-corrected .scan-queue-state {
  color: var(--color-status-success-text);
}
.scan-queue-row-actions,
.scan-queue-bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.scan-queue-row-actions {
  flex-wrap: nowrap;
  gap: 6px;
}
.scan-queue-row-actions .btn {
  min-height: 34px;
  padding-inline: 8px;
  white-space: nowrap;
}
@media (max-width: 420px) {
  .scan-queue-card {
    gap: 10px;
  }
}
.scan-queue-toolbar:not(:empty) {
  display: grid;
  gap: 10px;
  padding: 0 0 12px;
}
.scan-queue-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
}
.scan-queue-error {
  color: var(--color-danger-text-deep);
  font-size: var(--font-size-sm);
}
.scan-queue-correct {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: none;
}
.scan-queue-correct input {
  width: 100%;
  min-width: 0;
}
.scan-queue-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.scan-queue-fields label {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: var(--font-size-sm);
}
.scan-queue-fields select {
  width: 100%;
  min-width: 0;
}
.scan-queue-printing-review {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.scan-queue-printing-picker {
  margin: 8px 0;
}
.scan-queue-printing-picker summary {
  cursor: pointer;
  font-size: var(--font-size-sm);
  padding: 4px 0 8px;
}
.scan-queue-printing-picker .printing-list {
  max-height: 220px;
  overflow: auto;
}
.scan-queue-printing-review li.printing-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  box-shadow: none;
}
.scan-queue-selection {
  margin: 10px 0;
  font-size: var(--font-size-sm);
}
.card-scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.card-scan-privacy {
  border-top: 1px solid var(--color-line-faint);
  margin-top: 12px;
  padding-top: 10px;
}
.card-scan-gate-card {
  max-width: 430px;
}

.name-search {
  position: relative;
  max-width: 360px;
}
.app-right .name-search {
  max-width: none;
}
/* BEN-571: step-1 empty state — example searches with the chat panel's
   quote-bar treatment. Hidden once a printing list or preview is up. */
.add-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  line-height: 1.35;
  margin-top: 14px;
  padding: 2px;
}
.add-empty-copy {
  margin-bottom: 10px;
}
.add-empty-examples {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.add-empty-examples li {
  padding: 0;
}
/* Quiet-link chrome comes from the shared family (BEN-613). */
.add-details .details-body:has(.printing-picker.active) .add-empty,
.add-details .details-body:has(.add-preview.active) .add-empty {
  display: none;
}
.name-search input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-neutral-black);
  padding: 6px 2px;
  font-size: var(--font-size-lg);
  font-family: inherit;
  text-transform: none;
  outline: none;
}
.name-search input:focus {
  border-bottom-width: 2px;
}
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-neutral-white);
  border: 1px solid var(--color-neutral-200);
  border-top: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
}
.autocomplete-list.active {
  display: block;
}
.autocomplete-list li {
  padding: 6px 10px;
  font-size: var(--font-size-md);
  cursor: pointer;
  text-transform: none;
}
.autocomplete-list li.highlight,
.autocomplete-list li:hover {
  background: color-mix(in srgb, var(--color-accent-soft) 54%, var(--color-surface-raised));
  color: var(--color-text-strong);
}
.ac-suggestion-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.ac-suggestion-name {
  flex: 1;
  min-width: 0;
}
.suggestion-recent-badge {
  font-size: var(--font-size-xxs);
  padding: 0;
  color: var(--color-text-muted);
  border: 0;
  background: transparent;
  white-space: nowrap;
  text-transform: none;
}

.mic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.mic-btn {
  align-items: center;
  background-color: var(--color-text-strong);
  background-image:
    radial-gradient(rgba(21, 16, 13, 0.1) 1px, transparent 1px),
    linear-gradient(rgba(255, 245, 210, 0.08), rgba(0, 0, 0, 0.05));
  background-size:
    6px 6px,
    auto;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-firm);
  color: var(--color-text-inverse);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-title);
  justify-content: center;
  letter-spacing: 0.04em;
  line-height: 1;
  min-height: var(--control-height-compact);
  padding: 4px 10px;
  text-transform: none;
  transition:
    transform var(--motion-fast) steps(2, end),
    box-shadow var(--motion-fast) steps(2, end),
    background-color var(--motion-fast),
    filter var(--motion-fast);
}
.mic-btn:hover {
  box-shadow: var(--press-shadow);
  filter: brightness(1.05);
  transform: translate(var(--press-shift), var(--press-shift));
}
.mic-btn:active {
  box-shadow: 0 0 0 var(--color-shadow);
  filter: brightness(0.94);
  transform: translate(4px, 4px);
}
.mic-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.mic-btn.on {
  background-color: var(--color-danger);
  border-color: var(--color-text-strong);
  color: var(--color-text-inverse);
}
.mic-status {
  font-size: var(--font-size-xs-plus);
  color: var(--color-neutral-350);
}
.mic-status strong {
  color: var(--color-neutral-black);
}
.autoadd-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs-plus);
  color: var(--color-neutral-350);
  cursor: pointer;
  text-transform: none;
}
.autoadd-toggle input {
  accent-color: var(--color-neutral-black);
  cursor: pointer;
}
.vocab-hint {
  font-size: var(--font-size-xxs);
  color: var(--color-neutral-250);
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}
.vocab-hint strong {
  color: var(--color-neutral-400);
  font-weight: 400;
}

.add-preview {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-line-faint);
}
.add-preview.active {
  display: flex;
}

.add-editor {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-line-faint);
}
.add-editor.active {
  display: flex;
}

.printing-picker {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-line-faint);
}
.printing-picker.active {
  display: flex;
}
.detail-printing-picker {
  display: flex;
  margin-top: 12px;
  padding-top: 12px;
}
.printing-filter-input {
  width: 100%;
  border: 1px solid var(--color-status-neutral-border);
  background: var(--color-neutral-white);
  padding: 6px 8px;
  font: inherit;
  font-size: var(--font-size-sm);
  text-transform: none;
  outline: none;
}
.printing-filter-input:focus {
  border-color: var(--color-neutral-black);
}
.printing-list-caption {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  /* Clear the filter input's focus ring. */
  margin: 10px 0 4px;
  text-transform: none;
}
.printing-list-caption .truncate-hint {
  color: var(--color-warn-text-gold);
}
.printing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--color-line-faint);
  border-radius: var(--radius-tight);
  background: var(--color-neutral-white);
}
.printing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-line-faint);
  cursor: pointer;
  font-size: var(--font-size-sm);
  line-height: 1.2;
}
.printing-row:last-child {
  border-bottom: none;
}
.printing-row:hover {
  background: var(--color-surface-beige-soft);
}
.printing-row:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.printing-row.selected {
  background: var(--color-surface-hover);
  font-weight: 600;
}
.printing-row .set-icon {
  flex-shrink: 0;
  margin-right: 0;
}
.printing-set-code {
  font-weight: 500;
  text-transform: uppercase;
  min-width: 38px;
}
.printing-set-name {
  color: var(--color-text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
}
.printing-cn {
  color: var(--color-text-muted);
  min-width: 38px;
  text-align: right;
}
.printing-owned-badge {
  font-size: var(--font-size-xxs);
  padding: 1px 5px;
  border-radius: var(--radius-tight);
  background: var(--color-tag-amber-bg);
  color: var(--color-tag-amber-text);
  border: 1px solid var(--color-tag-amber-line);
  white-space: nowrap;
  text-transform: none;
}
.printing-price-badge {
  font-size: var(--font-size-xxs);
  padding: 1px 5px;
  border-radius: var(--radius-tight);
  background: var(--color-tag-blue-bg);
  color: var(--color-tag-blue-text);
  border: 1px solid var(--color-tag-blue-line);
  white-space: nowrap;
  text-transform: none;
}
.printing-year {
  color: var(--color-text-muted);
  min-width: 36px;
  text-align: right;
}
.field-hint {
  margin-top: 4px;
  font-size: var(--font-size-xxs);
  color: var(--color-warn-text-deep);
  line-height: 1.25;
  text-transform: none;
}
.field-hint.hidden {
  display: none;
}
.add-preview-img-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}
.add-preview-img {
  width: 140px;
  aspect-ratio: 488 / 680;
  object-fit: contain;
  max-width: 100%;
  border-radius: var(--radius-card);
  align-self: center;
}
.add-preview-img.is-loading {
  opacity: 0.35;
}
.add-preview-img-wrap.loading::after {
  animation: vui-spin 0.5s linear infinite;
  border: 2px solid var(--color-neutral-200);
  border-radius: 50%;
  border-top-color: var(--color-neutral-black);
  content: '';
  height: 18px;
  left: 50%;
  margin-left: -9px;
  margin-top: -9px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  width: 18px;
}
.add-preview-info {
  flex: 1;
  min-width: 0;
}
#addPreview .add-preview-info {
  min-height: 100px;
}
.add-preview-name {
  font-size: var(--font-size-xl);
  margin-bottom: 2px;
  text-align: left;
  text-transform: none;
}
.add-preview-meta {
  font-size: var(--font-size-xs-plus);
  color: var(--color-text-muted);
  margin-bottom: 10px;
  text-transform: none;
}
.add-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 10px;
}
.add-fields .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.add-fields .field-finish,
.add-fields .field-condition,
.add-fields .field-language,
.add-fields .field-qty {
  grid-column: span 1;
}
.add-fields .field-qty {
  max-width: 80px;
}
.add-fields .field-location {
  grid-column: 1 / -1;
}
.add-fields label {
  font-size: var(--font-size-xs);
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}
.add-fields input,
.add-fields select {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-neutral-black);
  padding: 4px 2px;
  font-size: var(--font-size-base);
  font-family: inherit;
  text-transform: none;
  outline: none;
  border-radius: var(--radius-square);
  -webkit-appearance: none;
}
.add-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Reserve the action geometry while artwork, finishes and prices resolve. */
#addEditor .add-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
#addCardBtn {
  width: 100%;
  min-height: 44px;
  height: 44px;
  white-space: nowrap;
}
#addCardCancel {
  justify-self: end;
  width: auto;
}
#addFinish {
  min-height: 32px;
}
.location-combobox {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.location-combobox input.field-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 8px 2px;
  color: var(--color-text);
}
.location-field-icon:empty {
  display: none;
}
.location-field-hint {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.tag-combobox {
  flex: 1;
  min-width: 100px;
}
.tag-combobox input {
  width: 100%;
}
.editor-suggestions {
  position: fixed;
  margin: 0;
  min-width: 0;
  box-sizing: border-box;
  box-shadow: none;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  color: var(--color-text);
}
.editor-suggestions .combobox-option {
  align-items: center;
  padding: 6px 8px;
  min-height: 36px;
  white-space: normal;
}
.editor-suggestions .combobox-option-label {
  flex: 1;
  overflow-wrap: anywhere;
}
.editor-suggestions .combobox-option.is-selected {
  font-weight: 600;
}
.editor-suggestions .combobox-option.is-active,
.editor-suggestions .combobox-option:hover {
  background: var(--color-surface-hover);
}
.location-option-icon,
.location-field-icon {
  display: inline-flex;
  flex: 0 0 20px;
}

.danger-zone {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-line-faint);
  text-align: right;
}

/* Import source choices (BEN-984 criterion 4) — lead with what the user has,
   not parser vocabulary; format detail only shows once a source is picked. */
.import-source-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.import-surface-fields {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.import-source-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  color: var(--color-text-strong);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: all var(--motion-base);
}
.import-source-btn:hover {
  border-color: var(--color-text-strong);
}
.import-source-btn.active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.import-source-btn-title {
  font-weight: 600;
}
.import-source-btn-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.import-source-panel {
  margin-bottom: 8px;
}
.import-provider-url {
  width: 100%;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  padding: 8px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background: var(--color-surface);
  color: var(--color-text-strong);
  margin-bottom: 8px;
}
.import-provider-url:focus {
  border-color: var(--color-text-strong);
  outline: none;
}

/* "what can I import?" disclosure (BEN-984 criterion 5) */
.import-disclosure {
  border-top: var(--border-width) solid var(--color-line);
  padding-top: 8px;
  margin-top: 4px;
}
.import-disclosure summary {
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.import-disclosure-body {
  margin-top: 8px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.import-disclosure-body p {
  margin: 0 0 6px;
}
.import-disclosure-example {
  background: var(--color-line-faint);
  border-radius: var(--radius-tight);
  padding: 6px 8px;
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.95em;
  white-space: pre-wrap;
  text-transform: none;
}
.archive-restore-dialog {
  margin: auto;
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  box-sizing: border-box;
  overflow-y: auto;
}
.archive-restore-date {
  color: var(--color-text-muted);
}
.archive-restore-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.archive-restore-counts dt {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.archive-restore-counts dd {
  margin: 0.25rem 0 0;
  font-size: 1.5rem;
  font-weight: 600;
}
.archive-restore-confirmation {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-top: 1.5rem;
}
.archive-restore-confirmation input {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}
.archive-restore-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.archive-restore-error {
  color: var(--color-error-text, #9b2424);
}
.archive-restore-status {
  min-height: 1.5em;
  font-size: 0.85rem;
}
/* The Archivist's voice is text, never an accent rail on a message. */
.mcp-chat-head .ui-modal-title,
.mcp-chat-assistant .mcp-chat-body {
  color: var(--color-archivist);
}

/* Pairing has stable geometry before the QR response arrives. */
.card-scan-qr-slot {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--color-surface-hover);
}
.card-scan-qr-slot .card-scan-qr {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.card-scan-qr-slot .card-scan-qr[hidden] {
  display: none;
}
.card-scan.has-connected-phone:not(.show-phone-link) .card-scan-handoff-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-scan-last-sent {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.card-scan-last-sent img {
  width: 42px;
  height: 58px;
  object-fit: cover;
}
.card-scan.is-reporting .card-scan-stage,
.card-scan.is-reporting .card-scan-status,
.card-scan.is-reporting .card-scan-actions > button {
  display: none;
}
.scan-report {
  flex: 1 0 100%;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-tight);
  background: var(--color-surface);
  text-align: left;
}
.scan-report-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.scan-report-preview img {
  width: 54px;
  height: 76px;
  object-fit: contain;
}
.scan-report-preview p {
  margin: 4px 0 0;
  color: var(--color-text-muted);
}
.scan-report fieldset {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.scan-report legend {
  margin-bottom: 12px;
  font-weight: 600;
}
.scan-report label,
.scan-report-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.scan-report input:not([type='checkbox']),
.scan-report textarea,
.scan-report select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}
.scan-report-printing {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.scan-report label.scan-report-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}
.scan-report-consent input {
  flex: 0 0 auto;
  margin-top: 3px;
}
.scan-report-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.scan-queue-expand {
  justify-self: end;
}
.scan-queue-row:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
@media (min-width: 901px) {
  .app-right.scan-review-expanded:has(#addModeScan.active) {
    width: calc(100vw - 48px) !important;
    max-width: none;
  }
  .scan-review-expanded .card-scan-handoff {
    max-width: 360px;
  }
  .scan-review-expanded .has-connected-phone:not(.show-phone-link) .card-scan-handoff {
    max-width: none;
  }
  .scan-review-expanded .card-scan-queue-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    align-items: start;
  }
  .scan-review-expanded ul.card-scan-queue-list > li.scan-queue-row {
    padding: 0;
    border: 0;
  }
  .scan-review-expanded .scan-queue-card {
    grid-template-columns: minmax(0, 1fr);
  }
  .scan-review-expanded .scan-queue-thumb {
    max-height: 390px;
  }
  .scan-review-expanded .scan-queue-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
  }
  .scan-review-expanded .scan-queue-expand {
    margin-left: auto;
    order: 2;
  }
}

.scan-review-expanded .card-scan-queue:not(:has(.scan-queue-row)) {
  display: block;
}

@media (max-width: 900px) {
  .scan-queue-expand {
    display: none;
  }
}

/* Camera guidance stays separate from photos already captured for processing. */
.card-scan.is-paired-phone .card-scan-unpaired-copy,
.card-scan.is-batch-scan .card-scan-single-copy,
.card-scan:not(.is-batch-scan) .card-scan-batch-copy {
  display: none;
}
/* M-27: nothing previously hid the "paired" copy when this device is doing
   its own scanning (not relaying to a paired desktop) — it showed alongside
   the unpaired copy above, reading as one run-on paragraph. */
.card-scan:not(.is-paired-phone) .card-scan-paired-copy {
  display: none;
}
/* An unpaired phone scanning a stack reviews it here, including the ?scan page. */
.scan-standalone-page .card-scan.is-batch-scan .card-scan-queue:has(.scan-queue-row) {
  display: block;
}
.card-scan-captures {
  border-top: 1px solid var(--color-line-faint);
  padding-top: 12px;
  font-size: var(--font-size-sm);
}
.card-scan-captures ul {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 8px 0 0;
  list-style: none;
}
.card-scan-capture {
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-scan-capture img {
  width: 56px;
  aspect-ratio: 0.716;
  object-fit: cover;
  flex: none;
  border-radius: var(--radius-tight);
}
.card-scan-capture > div {
  display: grid;
  gap: 3px;
}
.card-scan-capture small,
.card-scan-capture span {
  color: var(--color-text-muted);
}
.scan-queue-save-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.scan-queue-quantity {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scan-queue-quantity output {
  min-width: 2ch;
  text-align: center;
}

/* Tomebound: responsive. Cascade order is declared in ../styles.css. */

/* Responsive overrides */
@media (max-width: 768px) {
  .deck-view-wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .deck-preview-panel {
    display: none !important;
  }
}

/* M-10: iOS Safari zooms the page on focus when a field's computed font-size
   is under 16px. This used to be a hand-maintained list of "known offender"
   selectors (needed to out-specify their own font-size rules) that still
   missed ~60 fields; a coarse-pointer rule with !important reaches every
   text-entry control regardless of what else sets its font-size, present or
   future. Non-text input types are excluded since a checkbox/radio/range/
   color/file field never triggers the zoom and doesn't need this override. */
@media (pointer: coarse) {
  input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color']):not(
      [type='file']
    ):not([type='hidden']),
  select,
  textarea,
  [contenteditable='true'] {
    font-size: max(16px, 1em) !important;
  }
}

/* Below ~900px: collapse the border-frame to a single column */
@media (max-width: 900px) {
  .sidebar-collapsed-trigger {
    display: none !important;
  }
  .sidebar-footer {
    display: none !important;
  }
  html,
  body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body {
    overflow-x: hidden;
    overflow-y: visible;
  }
  .app-shell,
  body.view-list .app-shell,
  body.view-grid .app-shell,
  body.view-locations .app-shell,
  body.view-deck .app-shell,
  body.left-sidebar-collapsed .app-shell,
  body.view-collection .app-shell,
  body.view-list .app-shell,
  body.view-grid .app-shell,
  body.view-locations .app-shell,
  body.view-deck .app-shell {
    height: 100dvh;
    min-height: 0;
    /* The footer is a content-sized grid row. Only a displayed bottom bar
       reserves space outside it; floatingActions measures both boxes. */
    padding-bottom: var(--app-bottom-nav-h, 0px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    /* Single full-width column for main at mobile — sidebar + right detail pane
       overlay (off-canvas), they must not reserve grid columns. Was gated on
       left-sidebar-collapsed, so the non-collapsed state kept the desktop 3-col
       grid (areas said 1 col, columns said 3) and squished main into ~140px.
       !important because desktop var()-based column rules win on source order. */
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      'header'
      'main'
      'footer';
  }
  /* The side rails use grid-area: left / right, which the single-column area
     template above no longer defines — so as in-flow grid items they spawned
     phantom implicit columns and crushed main. At mobile they become off-canvas
     drawers (fixed, out of grid flow), driven by the drawer-open classes the JS
     toggles at narrow widths — independent of the desktop collapse preference,
     which is what the agent's rules were (wrongly) gated on. */
  body:is(.view-collection, .view-list, .view-grid, .view-locations, .view-deck) #appLeft,
  body:is(.view-collection, .view-list, .view-grid, .view-locations, .view-deck) .app-right {
    position: fixed;
    top: 0;
    height: 100dvh;
    z-index: 170;
  }
  body:is(.view-collection, .view-list, .view-grid, .view-locations, .view-deck) #appLeft {
    left: 0;
    transform: translateX(-100%);
  }
  body:is(.view-collection, .view-list, .view-grid, .view-locations, .view-deck) .app-right {
    right: 0;
    transform: translateX(100%);
  }
  body.left-drawer-open #appLeft {
    transform: translateX(0) !important;
  }
  body.right-drawer-open .app-right {
    transform: translateX(0);
  }
  body.view-grid .app-shell,
  body.left-sidebar-collapsed.view-grid .app-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .app-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 8px 14px;
    height: auto;
    min-height: 50px;
  }
  .app-header h1 {
    font-size: var(--font-size-xl);
  }
  /* The collection toolbar is sticky at 50. Its reserved left gutter must
     expose the navigation control, while drawers/backdrops remain above it. */
  body.view-list #book-stage .book-sidebar-workbench > .book-header {
    z-index: 51;
  }
  /* Deck identity and actions start below a real navigation row, so the
     floating book controls cannot cover the title, build mode, or export. */
  body.view-deck #book-stage .book-sidebar-workbench > .book-header {
    align-items: center;
    background: var(--color-surface);
    border-right: 0;
    border-bottom: 1px solid var(--color-line);
    flex: 0 0 56px;
    height: 56px;
    justify-content: space-between;
    padding: 6px 8px;
    position: relative;
    width: 100%;
  }
  body.view-deck
    #book-stage
    .book-header
    > :is(.book-sidebar-toggle, .quick-jump-collapsed-trigger) {
    height: 44px;
    inset: auto;
    margin: 0;
    min-height: 44px;
    position: relative;
    width: 44px;
  }
  body.view-deck .deck-hero-actions :is(.deck-build-mode-toggle, .btn) {
    min-height: 44px;
  }
  body.view-deck:not(.left-drawer-open) #book-stage .book-sidebar-workbench .app-left,
  body.view-deck #book-stage .book-sidebar-mobile-open .book-sidebar-backdrop {
    top: 56px;
  }
  /* BEN-520: on mobile the filters FAB opens the sidebar drawer (backdrop tap /
     Escape close it) — no edge resizing, hide the strip. */
  .sidebar-resize-handle {
    display: none;
  }
  .app-primary-nav.mobile-bottom-nav {
    /* Unframed shells show primary navigation here for every account state.
       The book navigation frame hides its header and uses the sidebar. */
    align-items: stretch;
    backdrop-filter: blur(16px) saturate(140%);
    background: color-mix(in srgb, var(--color-bg) 96%, transparent);
    border-top: var(--border-width) solid var(--color-line);
    bottom: 0;
    box-shadow: 0 -8px 24px rgba(45, 34, 27, 0.06);
    display: grid;
    gap: 4px;
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    left: 0;
    min-height: calc(var(--vui-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    position: fixed;
    right: 0;
    z-index: var(--vui-z-fab);
  }
  .app-header-views {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-self: stretch;
    width: 100%;
  }
  .app-header-views .toggle-view,
  .app-primary-nav .sync-chip {
    border: 0;
    border-radius: var(--radius-soft);
    box-shadow: none;
    flex-direction: column;
    font-size: var(--font-size-xs);
    gap: 3px;
    min-height: var(--vui-touch-target);
    padding: 5px 6px;
  }
  .app-header-views .toggle-view + .toggle-view {
    margin-left: 0;
  }
  .app-header-views .view-icon,
  .app-primary-nav .sync-dot {
    height: 18px;
    margin: 0;
    width: 18px;
  }
  .app-header-views .toggle-view.active,
  .app-header-views .toggle-view[aria-pressed='true'] {
    background: var(--color-accent-soft);
    border-color: transparent;
    color: var(--color-accent);
  }
  .sync-account-slot {
    align-items: stretch;
    justify-content: stretch;
    justify-self: stretch;
    min-width: 0;
  }
  .sync-account-slot .sync-chip {
    justify-content: center;
    width: 100%;
  }
  .sync-account-slot .sync-label {
    display: block;
    font-size: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sync-account-slot .sync-label::after {
    content: 'account';
    font-size: var(--font-size-xs);
  }
  .sync-account-slot .sync-chip-cta .sync-label {
    font-size: var(--font-size-xs);
    white-space: normal;
  }
  .sync-account-slot .sync-chip-cta .sync-label::after {
    content: none;
  }
  .sync-menu {
    bottom: calc(100% + 8px);
    left: auto;
    right: 0;
    top: auto;
  }
  .app-left {
    border-bottom: 0;
    border-right: 1px solid var(--color-line);
    box-shadow: var(--shadow-drawer-side-right);
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    left: 0;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
    pointer-events: none;
    position: fixed;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition:
      transform var(--vui-motion-drawer) var(--vui-ease-drawer),
      opacity var(--vui-motion-exit) var(--vui-ease-out),
      box-shadow var(--vui-motion-base) ease;
    width: min(420px, 100vw);
    z-index: 50;
  }
  body.left-sidebar-collapsed .app-left {
    min-width: 0;
    opacity: 1;
    padding: 0;
    pointer-events: none;
    transform: translateX(-100%);
    width: min(420px, 100vw);
  }
  body.left-drawer-open .app-left {
    pointer-events: auto;
    transform: translateX(0);
  }
  .mobile-filter-sheet-head {
    display: flex;
    flex: 0 0 auto;
    min-height: 56px;
    padding-left: 16px;
    padding-right: 12px;
    top: 0;
    z-index: 8;
    /* M-05: sticky with no background lets scrolled fields slide up under it. */
    background: var(--color-surface);
    border-bottom: var(--border-width) solid var(--color-line);
  }
  .mobile-filter-sheet-close {
    min-height: var(--vui-touch-target);
    padding-left: 14px;
    padding-right: 14px;
  }
  .mobile-sidebar-tabs {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 10px 16px 0;
    position: sticky;
    top: 56px;
    width: auto;
    z-index: 7;
    /* M-05: same transparent-sticky problem as the head above. */
    background: var(--color-surface);
  }
  .mobile-sidebar-tabs .segment-btn,
  html[data-theme] .app-left .mobile-sidebar-tabs .segment-btn {
    color: var(--color-text-strong);
    min-height: var(--vui-touch-target);
  }
  .app-left[data-mobile-tab='browse'] #collectionFiltersSection,
  .app-left[data-mobile-tab='browse'] .sidebar-view-settings,
  .app-left[data-mobile-tab='browse'] .sidebar-grid-view-settings,
  .app-left[data-mobile-tab='filters'] #collectionSearchSection,
  .app-left[data-mobile-tab='filters'] #collectionScopeSection,
  .app-left[data-mobile-tab='filters'] .sidebar-view-settings,
  .app-left[data-mobile-tab='filters'] .sidebar-grid-view-settings,
  .app-left[data-mobile-tab='view'] #collectionSearchSection,
  .app-left[data-mobile-tab='view'] #collectionScopeSection,
  .app-left[data-mobile-tab='view'] #collectionFiltersSection {
    display: none;
  }
  .app-left .sidebar-section {
    flex: 0 0 auto;
    min-width: 0;
    padding: 14px 16px 0;
    width: 100%;
    /* M-35: the drawer runs edge to edge — clear the notch/rounded-corner
       inset in landscape (additive to the existing 16px). */
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .app-left .sidebar-section:last-of-type {
    padding-bottom: 16px;
  }
  .app-left .search-input,
  .app-left .ms-trigger,
  .app-left .clear-filters-btn,
  .app-left .scope-option,
  .app-left .collection-display-controls .segment-btn,
  .app-left .collection-column-settings-panel button {
    min-height: var(--vui-touch-target);
  }
  .app-left .search-syntax-link {
    align-items: center;
    display: inline-flex;
    min-height: var(--vui-touch-target);
    /* M-34: the 44px hit area is taller than the single line of text, which
       pushed "All Cards" well below it — pull the surrounding sections back
       in without shrinking the tap target. */
    margin-block: -13px;
  }
  .app-left .history-actions button,
  .app-left .history-list .icon-btn {
    min-height: var(--vui-touch-target);
    min-width: var(--vui-touch-target);
  }
  .app-center {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 14px 14px var(--app-floating-clearance, 68px);
    width: 100%;
  }
  /* Keep the toolbar and footer still; #listView owns scrolling and clearance
     for the floating actions, without extending the page itself. */
  body.view-list .app-center {
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  body.view-list #collectionSection {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }
  body.view-list #collectionSection.hidden {
    display: none;
  }
  .mobile-collection-toolbar {
    display: none;
  }
  body.view-list:not(.share-mode) .mobile-collection-toolbar {
    display: flex;
    justify-content: flex-end;
  }
  /* M-35: the sticky header (and the Browse & filters sheet head, which
     shares this class) sits at the physical top edge — clear the Dynamic
     Island/notch inset instead of sliding under it now that the viewport
     covers that area. Additive to vellum's own padding, not a replacement. */
  .mobile-toolbar {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }
  .mobile-filter-trigger {
    gap: 6px;
    min-height: var(--vui-touch-target);
  }
  .mobile-filter-trigger svg {
    height: 16px;
    width: 16px;
  }
  .bulk-bar {
    bottom: calc(12px + var(--app-footer-h));
    max-width: calc(100vw - 16px);
  }
  .bulk-bar .bulk-count {
    flex-shrink: 0;
  }
  .bulk-edit-panel {
    bottom: calc(12px + var(--app-footer-h) + 52px + 8px);
    max-height: calc(100vh - 24px - var(--app-footer-h) - 52px - 8px);
    /* iOS: 100vh exceeds the visible area while Safari's bars are showing. */
    max-height: calc(100dvh - 24px - var(--app-footer-h) - 52px - 8px);
    width: calc(100vw - 16px);
  }
  body.view-grid .app-center,
  body.view-grid #collectionSection {
    min-height: 0;
  }
  body.view-grid .app-center {
    overflow: auto;
  }
  .app-right {
    border-left: none;
    border-top: 1px solid var(--color-neutral-black);
    bottom: 0;
    box-shadow: var(--shadow-drawer-side);
    display: none;
    max-width: 100vw;
    overflow-y: auto;
    padding: 14px;
    position: fixed;
    right: 0;
    top: 0;
    width: min(480px, 100vw);
    z-index: 50;
  }
  .app-right-close {
    align-items: center;
    align-self: flex-end;
    background: transparent;
    border: 1px solid var(--color-neutral-200);
    color: var(--color-neutral-500);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    height: var(--vui-touch-target);
    justify-content: center;
    margin-bottom: 8px;
    min-width: var(--vui-touch-target);
    padding: 0 10px;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .app-right-close:hover,
  .app-right-close:focus-visible {
    border-color: var(--color-neutral-black);
    color: var(--color-neutral-black);
    outline: none;
  }
  .app-right details.add-details,
  .app-right details.import-details {
    background: transparent;
    border: 0;
    margin: 0;
    padding: 0;
  }
  .app-right details.add-details summary,
  .app-right details.import-details summary {
    border-bottom: 1px solid var(--color-status-neutral-border);
    font-size: var(--font-size-xl);
    padding: 0 0 10px;
  }
  .app-right details.add-details .details-body,
  .app-right details.import-details .details-body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
  .add-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }
  .add-tab {
    min-height: var(--vui-touch-target);
    padding: 8px 6px;
  }
  .add-tab span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .card-scan-stage {
    max-height: 52dvh;
  }
  .card-scan-actions .btn {
    min-height: var(--vui-touch-target);
  }
  .card-scan.is-paired-phone .card-scan-privacy::before {
    color: var(--color-status-success-text);
    content: 'connected to your computer · ';
    font-weight: 600;
  }
  .name-search input,
  .printing-filter-input {
    min-height: var(--vui-touch-target);
    padding: 9px 4px;
  }
  .add-empty-examples {
    gap: 0;
  }
  .add-empty-examples li {
    border-left: 0;
    padding-left: 0;
  }
  .add-empty-example {
    align-items: center;
    display: inline-flex;
    min-height: var(--vui-touch-target);
    padding: 0 8px;
  }
  .autocomplete-list li,
  .printing-row {
    min-height: 42px;
    padding: 10px 9px;
  }
  .add-preview.active {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
  }
  .add-preview-img {
    width: 112px;
  }
  .add-preview-meta {
    margin-bottom: 4px;
  }
  .printing-list {
    max-height: min(38vh, 320px);
  }
  .add-fields,
  .detail-form {
    grid-template-columns: 1fr;
  }
  .add-fields .field-finish,
  .add-fields .field-condition,
  .add-fields .field-language,
  .add-fields .field-qty,
  .add-fields .field-location,
  .add-fields .field-full {
    grid-column: 1;
  }
  .add-fields .field-qty,
  #detailQty {
    max-width: 96px;
  }
  .condition-toggle span,
  .language-toggle span {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 44px;
  }
  /* BEN-500: 44x44 minimum touch targets on mobile (Apple HIG / WCAG 2.5.5). */
  .icon-btn {
    min-height: 44px;
    min-width: 44px;
  }
  .segment-btn {
    min-height: 44px;
  }
  .settings-toggle {
    min-height: 44px;
  }
  .add-actions {
    background: var(--color-neutral-white);
    border-top: 1px solid var(--color-status-neutral-border);
    bottom: 0;
    margin-top: 14px;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    position: sticky;
    z-index: 3;
  }
  .add-actions .btn,
  .drawer-actions .btn {
    flex: 1 1 0;
    min-height: 42px;
  }
  /* M-28: #addEditor .add-actions is a single-column grid on desktop (Add
     full width, Cancel a small right-aligned link below it) — on a phone
     that grid stacks the two buttons and the wrap alone runs the sticky
     footer to 117px. Go side by side, matching .drawer-actions above. */
  #addEditor .add-actions {
    display: flex;
    flex-wrap: nowrap;
    /* Cover #addDetails' 16px bottom padding, which sticky bottom: 0 leaves
       open for scrolled fields to show through. */
    bottom: -16px;
    margin-bottom: -16px;
    padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  }
  #addCardBtn,
  #addCardCancel {
    justify-self: auto;
    width: auto;
    flex: 1 1 0;
    min-width: 0;
  }
  .detail-drawer {
    height: 100dvh;
    width: 100vw;
  }
  /* M-35: the drawer is full-bleed only at this width — clear the
     notch/rounded-corner inset in landscape (desktop's fixed-width side
     panel doesn't need this). */
  .drawer-actions {
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  /* History opens as a bottom sheet on mobile rather than a full-screen slide-in
     — it is a glance surface, not a form. */
  .history-panel {
    border-left: 0;
    border-top: var(--border-width) solid var(--color-text-strong);
    border-radius: var(--radius-soft) var(--radius-soft) 0 0;
    height: 72dvh;
    top: auto;
    bottom: 0;
    transform: translateY(100%);
    width: 100vw;
    /* M-19: vellum's .ui-drawer caps width at min(92vw, 480px), leaving a 32px
       strip uncovered — this sheet is meant to run full width on phones. */
    max-width: none;
    /* M-35: full-width bottom sheet — clear the notch/rounded-corner in landscape. */
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .history-panel.visible {
    transform: translateY(0);
  }
  .history-panel .drawer-body {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .drawer-head {
    align-items: center;
    padding: 12px 14px;
  }
  .drawer-head .rune-close {
    min-height: var(--vui-touch-target);
    min-width: var(--vui-touch-target);
  }
  .drawer-body {
    display: flex;
    flex-direction: column;
    padding: 12px 14px 0;
  }
  /* The header stays outside the single mobile scrollport. Art and navigation
     lead; the form follows in the same reading order as the desktop modal. */
  #detailDrawer .drawer-body {
    display: block;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  #detailDrawer #detailForm,
  #detailDrawer .detail-scroll {
    display: block;
  }
  #detailDrawer .detail-art-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }
  #detailDrawer #detailImageWrap {
    width: 100%;
  }
  #detailDrawer :is(.drawer-image-frame, .drawer-placeholder) {
    /* Header = title line + metadata + padding/border. Leave another 76px for
       body padding, the art/nav gap, and the 44px navigation targets. */
    --detail-mobile-header-height: calc(var(--detail-title-line-height) + 26px + 25px);
    /* M-31: capping only at the available height let the art fill the whole
       first screen, pushing price/quantity/Move below the fold on every
       open. Also cap at ~55% of the viewport height so that row is always
       visible without scrolling. */
    width: min(
      100%,
      calc((100dvh - var(--detail-mobile-header-height) - 76px) * 488 / 680),
      calc(55dvh * 488 / 680)
    );
    max-width: none;
    margin: 0 auto;
  }
  #detailDrawer .detail-nav {
    justify-content: center;
    border: 0;
    padding: 0;
  }
  #detailDrawer :is(.rune-close, .detail-nav-btn, .detail-quantity-btn, #detailMove) {
    min-width: 44px;
    min-height: 44px;
  }
  #detailDrawer .detail-quantity-control {
    grid-template-columns: 44px minmax(42px, 1fr) 44px;
  }
  #detailDrawer .detail-quantity-value {
    height: 44px;
  }
  .detail-quick-btn,
  .detail-nav-btn {
    min-height: var(--vui-touch-target);
  }
  .detail-nav {
    padding: 8px 14px;
  }
  .detail-price a,
  .detail-advanced > summary {
    align-items: center;
    display: inline-flex;
    min-height: var(--vui-touch-target);
  }
  .drawer-actions {
    padding-left: 14px;
    padding-right: 14px;
  }
  .drawer-image-frame,
  .drawer-placeholder {
    max-width: 220px;
  }
  body.view-list .app-right,
  body.view-grid .app-right,
  body.view-locations .app-right,
  body.view-deck .app-right {
    display: none;
  }
  body.view-list.right-drawer-open .app-right,
  body.view-grid.right-drawer-open .app-right,
  body.view-deck.right-drawer-open .app-right {
    display: flex;
    border-left: 1px solid var(--color-neutral-black);
    border-top: 0;
    bottom: 0;
    height: 100dvh;
    top: 0;
    width: 100vw;
  }
  body .app-right-layer .app-right.ui-drawer {
    bottom: 0;
    height: 100dvh;
    max-width: 100vw;
    top: 0;
    width: 100vw;
  }
  .app-right-layer .app-right-drawer-handle {
    margin: -14px -14px 2px;
    top: -14px;
  }
  body.view-deck .app-left,
  body.view-deck:not(.right-drawer-open) .app-right {
    display: none;
  }
  .deck-view-wrap,
  .deck-hero,
  .deck-content-grid,
  .deck-dashboard,
  .deck-metadata-form,
  .deck-export-form,
  .deck-meta-strip {
    grid-template-columns: 1fr;
  }
  /* BEN-mobile-audit M-06: was position:sticky with a transparent background
     (deck-workspace.css ".deck-workspace .deck-workspace-controls" beat this
     on specificity, so the bg never painted) and it ate ~160px permanently
     once scrolled. Scroll away with the content instead — the fixed topbar
     strip already covers quick nav/mode switching once scrolled. */
  .deck-workspace .deck-workspace-controls {
    position: static;
  }
  .deck-workspace-root {
    min-width: 0;
    order: 1;
  }
  .deck-side-column {
    height: auto;
    margin-top: 18px;
    order: 2;
    position: static;
  }
  .deck-workspace-nav-row {
    align-items: center;
    padding: 8px;
  }
  .deck-workspace-nav {
    display: none;
  }
  .deck-mobile-mode-control {
    min-width: 0;
    width: auto;
  }
  .deck-mobile-mode-control select {
    min-width: 0;
  }
  .deck-build-mode-toggle {
    margin-left: auto;
  }
  .deck-context-controls {
    align-items: stretch;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }
  .deck-toolbar-field {
    align-items: stretch;
    display: grid;
    gap: 4px;
  }
  .deck-toolbar-field select {
    min-width: 0;
    width: 100%;
  }
  .deck-view-settings-wrap {
    grid-column: 1 / -1;
  }
  .deck-view-settings-trigger {
    justify-content: center;
    width: 100%;
  }
  .deck-display-menu {
    left: 0;
    min-width: 0;
    right: 0;
    width: auto;
  }
  .deck-hero-side {
    min-width: 0;
  }
  .deck-hero-actions {
    justify-content: flex-start;
  }
  .deck-hero-actions .btn {
    flex: 1 1 130px;
  }
  .deck-metadata-description {
    grid-column: 1;
  }
  .deck-metadata-actions {
    justify-content: stretch;
  }
  .deck-metadata-actions .btn {
    flex: 1 1 auto;
  }
  .deck-export-actions {
    justify-content: stretch;
  }
  .deck-export-actions .btn {
    flex: 1 1 auto;
  }
  .deck-preview-panel {
    display: none;
  }
  .deck-columns {
    --deck-card-w: minmax(130px, 1fr);
    grid-template-columns: repeat(var(--deck-logical-columns, 1), minmax(130px, 1fr));
  }
  .list-view.active {
    max-width: 100%;
    overflow-x: auto;
  }
  body.view-list .list-view.active,
  body.view-grid .grid-pages-list {
    overflow: auto;
    min-height: 0;
    padding-bottom: var(--app-floating-clearance, 68px);
  }
  body.view-list .list-view.active table,
  body.view-list .list-view.active thead,
  body.view-list .list-view.active tbody,
  body.view-grid .grid-list-table,
  body.view-grid .grid-list-table thead,
  body.view-grid .grid-list-table tbody {
    display: block;
    min-width: 0;
    width: 100%;
  }
  /* Neutralize the JS-set inline --collection-table-real-width (desktop column
     sum) so the reflowed list table fills the viewport instead of overflowing.
     #listView > table is an ID rule; match its specificity to win on source order. */
  #listView > table {
    min-width: 0;
  }
  body.view-list .list-view.active thead,
  body.view-grid .grid-list-table thead {
    display: none;
  }
  /* BEN-523: condensed mobile list rows for ALL list views (not just shares) —
     tighter gaps/padding so many rows fit. (Location stays visible here; only
     share mode hides it, since a share is scoped to one container.) */
  body.view-list .list-view.active tbody,
  body.view-grid .grid-list-table tbody {
    display: grid;
    gap: 4px;
  }
  body.view-list .list-view.active tbody tr,
  body.view-grid .grid-list-table tbody tr {
    align-items: center;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-status-neutral-border);
    display: flex;
    flex-wrap: wrap;
    gap: 3px 8px;
    min-height: 58px;
    padding: 6px 8px;
  }
  body.view-list .list-view.active tbody tr:hover,
  body.view-grid .grid-list-table tbody tr:hover {
    background: var(--color-surface-raised);
  }
  /* BEN-666: the zero-results placeholder isn't a data row — don't give it the
     card-style row border used by the mobile condensed layout. */
  body.view-list .list-view.active tbody tr.collection-zero-results,
  body.view-grid .grid-list-table tbody tr.collection-zero-results {
    border: 0;
  }
  body.view-list .list-view.active td,
  body.view-grid .grid-list-table td {
    display: block;
    padding: 0;
  }
  body.view-list .list-view.active td[data-column-id],
  body.view-grid .grid-list-table td[data-column-id] {
    min-width: 0;
    width: auto;
  }
  body.view-list .list-view.active .col-check {
    align-self: center;
    flex: 0 0 auto;
    order: 0;
    width: auto;
  }
  body.view-grid .grid-list-table .col-check {
    display: none;
  }
  body.view-list .list-view.active .card-name-cell,
  body.view-grid .grid-list-table .card-name-cell {
    align-items: center;
    display: flex;
    flex: 1 1 calc(100% - 96px);
    gap: 8px;
    min-width: 0;
    order: 1;
  }
  body.view-list .list-view.active .card-name-thumb,
  body.view-grid .grid-list-table .card-name-thumb {
    display: block;
    flex: 0 0 auto;
    height: 42px;
    margin: 0;
    width: 30px;
  }
  body.view-list .list-view.active .card-name-button,
  body.view-grid .grid-list-table .card-name-button {
    align-items: center;
    display: flex;
    font-size: var(--font-size-md);
    min-height: var(--vui-touch-target);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    text-align: left;
    white-space: nowrap;
  }
  body.view-list .list-view.active .price-cell,
  body.view-grid .grid-list-table .price-cell {
    color: var(--color-neutral-black);
    font-size: var(--font-size-md);
    font-weight: 600;
    margin-left: auto;
    order: 2;
  }
  body.view-list .list-view.active .set-cell,
  body.view-list .list-view.active .cn-cell,
  body.view-list .list-view.active .finish-cell,
  body.view-list .list-view.active .rarity-cell,
  body.view-list .list-view.active .condition-cell,
  body.view-list .list-view.active .qty-cell,
  body.view-grid .grid-list-table .set-cell,
  body.view-grid .grid-list-table .cn-cell,
  body.view-grid .grid-list-table .finish-cell,
  body.view-grid .grid-list-table .rarity-cell,
  body.view-grid .grid-list-table .condition-cell,
  body.view-grid .grid-list-table .qty-cell {
    flex: 0 1 auto;
    font-size: var(--font-size-xs);
    order: 3;
  }
  body.view-list .list-view.active .location-cell,
  body.view-grid .grid-list-table .location-cell {
    flex: 0 1 auto;
    margin-top: 3px;
    order: 4;
  }
  body.view-list .list-view.active .tags-cell,
  body.view-grid .grid-list-table .tags-cell {
    flex: 1 1 auto;
    order: 5;
  }
  body.view-list .list-view.active .col-check {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: var(--vui-touch-target);
    min-width: 28px;
  }
  body.view-list .list-view.active .row-check {
    height: 20px;
    margin: 0;
    width: 20px;
  }
  body.view-list .list-view.active .row-tag-input,
  body.view-grid .grid-list-table .row-tag-input {
    min-height: 30px;
  }
  /* BEN-516/BEN-523: the condensed mobile row density now applies to all list
     views (above). Share mode additionally drops the per-row location, since a
     share is scoped to one container and the location repeats on every row. */
  body.share-mode.view-list .list-view.active .location-cell,
  body.share-mode.view-grid .grid-list-table .location-cell {
    display: none;
  }
  .grid-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .grid-actions-primary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
  }
  .grid-actions .segment-btn {
    flex: 1 1 0;
    min-height: 44px;
  }
  .grid-price-toggle {
    height: var(--vui-touch-target);
    min-height: var(--vui-touch-target);
  }
  .grid-sort-field {
    min-width: 0;
  }
  .grid-sort-field select,
  .grid-search-input,
  .grid-filter-trigger {
    height: var(--vui-touch-target);
  }
  .grid-sort-field select {
    min-width: 0;
    width: 100%;
  }
  .grid-search-input {
    grid-column: 1 / -1;
    max-width: none;
    width: 100%;
  }
  .grid-summary {
    flex: 1 1 100%;
    margin-left: 0;
    text-align: right;
  }
  .grid-filter-menu[open] .grid-explore-controls {
    left: 0;
    right: auto;
    width: min(220px, calc(100vw - 44px));
  }
  .grid-surface {
    padding: 12px;
  }
  .grid-page {
    gap: 10px;
    width: min(var(--grid-page-width, 760px), calc(100vw - 48px));
  }
  .grid-nav {
    gap: 8px;
  }
  .grid-nav .btn {
    flex: 1 1 96px;
    min-height: 40px;
  }
  .location-card {
    min-height: 92px;
  }
  body.view-list.right-drawer-open .app-right-backdrop,
  body.view-grid.right-drawer-open .app-right-backdrop,
  body.view-deck.right-drawer-open .app-right-backdrop,
  body.left-drawer-open .app-right-backdrop {
    display: block;
    z-index: 130;
  }
  .app-right-layer.open .app-right-backdrop.ui-drawer-backdrop {
    z-index: 40;
  }
  .fab-cluster {
    align-items: center;
    bottom: calc(
      var(--app-footer-measured-h, var(--app-footer-h)) + var(--app-bottom-nav-h, 0px) + 12px
    );
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    max-width: calc(100vw - 32px);
  }
  .fab-cluster > .mobile-utility-menu {
    display: block;
  }
  .fab-cluster > .mobile-utility-menu > summary {
    display: inline-flex;
  }
  .fab-cluster > .mobile-utility-menu > .mobile-utility-menu-panel {
    bottom: calc(100% + 8px);
    display: grid;
    max-width: calc(100vw - 32px);
    max-height: calc(
      100dvh - var(--app-footer-measured-h, var(--app-footer-h)) - var(--app-bottom-nav-h, 0px) -
        var(--app-more-h, 44px) - 32px
    );
    overflow-y: auto;
  }
  .fab-cluster > .mobile-utility-menu:not([open]) > .mobile-utility-menu-panel {
    display: none;
  }
  .mobile-utility-trigger,
  .fab-actions .fab-action[data-fab-target='addDetails'] {
    min-height: var(--vui-touch-target);
  }
  /* M-26: icon-only 44px on phones — the trigger already carries
     aria-label="More actions", so hiding the visible label doesn't touch the
     accessible name. The panel it opens keeps full labels. */
  .mobile-utility-trigger {
    width: var(--vui-touch-target);
    padding: 0;
    gap: 0;
    justify-content: center;
  }
  .mobile-utility-trigger .fab-label {
    display: none;
  }
  .mobile-history-action,
  .mobile-about-action {
    display: flex;
  }
  .mobile-utility-menu-panel .fab-btn {
    border: 0;
    border-bottom: var(--border-width) solid var(--color-line);
    border-radius: 0;
    box-shadow: none;
    min-height: var(--vui-touch-target);
    width: 100%;
  }
  .fab-cluster > .mobile-utility-menu .mobile-utility-menu-item {
    min-height: var(--vui-touch-target);
  }
  /* M-33: a floating card over a still-scrollable list read as broken on a
     phone. A full-height sheet needs no separate backdrop — it IS the whole
     screen. .mcp-chat already lays out log (flex: 1 1 auto, scrolls) above
     form (flex: 0 0 auto) in a column, so the composer stays pinned to the
     bottom for free; only the widget's own geometry needs to go edge-to-edge.
     top/bottom (not an explicit height) so --mcp-chat-keyboard-inset can
     shrink the sheet from the bottom without fighting a fixed height. */
  .mcp-chat-widget,
  .mcp-chat-widget.is-positioned {
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--mcp-chat-keyboard-inset, 0px);
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    border: 0;
    border-radius: 0;
    resize: none;
  }
  .mcp-chat-head,
  .mcp-chat-widget .mcp-chat {
    border-radius: 0;
  }
  .mcp-chat-resize-handle {
    display: none;
  }
  .mcp-chat-form {
    grid-template-columns: 1fr;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mcp-chat-form .btn {
    min-height: var(--vui-touch-target);
  }
  /* Coarse-pointer composer: 16px+ so iOS doesn't zoom the page on focus. */
  #mcpChatInput {
    font-size: max(16px, 1em);
  }
  body.left-drawer-open .fab-cluster {
    display: none;
  }
  /* M-03/M-26: the bulk bar spans nearly the full width of this same corner,
     and More sits right on top of its Clear button. Hide More (not the whole
     cluster — other FAB buttons already hide per-view) while a selection is
     active; nothing else needs the corner then. */
  body:has(#bulkBar.active) .fab-cluster > .mobile-utility-menu {
    display: none;
  }
  /* BEN-568: keyboard-shortcut chips mean nothing on narrow viewports (the
     hover:none block covers wide touch screens). */
  .fab-shortcut,
  .btn-shortcut {
    display: none;
  }
  .fab-btn.mobile-filter-fab {
    display: none;
  }
  body.view-deck .fab-btn.mobile-filter-fab,
  body.share-mode .fab-btn.mobile-filter-fab {
    display: none;
  }
  body.view-decks-home .fab-cluster,
  body.view-storage-home .fab-cluster {
    display: flex;
  }
  body.view-decks-home .fab-btn[data-fab-target],
  body.view-storage-home .fab-btn[data-fab-target] {
    display: none;
  }
  .toast-stack {
    bottom: calc(
      var(--app-footer-measured-h, var(--app-footer-h)) + var(--app-bottom-nav-h, 0px) +
        var(--app-floating-clearance, 68px)
    );
    max-width: calc(100vw - 24px);
  }
  /* At most two single-line rows: totals, then the latest change with its
     undo/history actions. About moves to the more menu. Spacing separates
     totals at this width: no dot can be stranded at a line edge. */
  .app-footer {
    min-height: 0;
    /* M-35: left/right clear the notch/rounded-corner inset in landscape. */
    padding: 6px calc(14px + env(safe-area-inset-right, 0px))
      calc(6px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 12px;
  }
  html[data-mobile-nav-visible] .app-footer {
    /* The navigation already owns the safe area while displayed. */
    padding-bottom: 6px;
  }
  .app-footer #appTotalsStrip {
    flex: 1 1 100%;
    min-width: 0;
    min-height: 0;
    justify-content: flex-start;
    /* Whole totals wrap on the narrowest phones rather than clipping. */
    flex-wrap: wrap;
    padding: 0;
    gap: 2px 12px;
  }
  .app-footer #appTotalsStrip .total-part {
    flex: none;
    white-space: nowrap;
  }
  .app-footer #appTotalsStrip .sep {
    display: none;
  }
  .app-footer .app-history-ticker {
    border-bottom: 0;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: 0;
    margin: 0;
    padding: 0;
  }
  .app-footer .app-history-ticker :is(.ticker-label, .ticker-action) {
    flex: none;
  }
  .app-footer .app-history-ticker .ticker-summary {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-footer .app-history-ticker :is(.history-entity-ref, .history-entity-ref-name) {
    white-space: nowrap;
  }
  .app-history-ticker .ticker-action + .ticker-action::before,
  .app-history-ticker .ticker-summary + .ticker-action::before {
    content: none;
    margin-right: 0;
  }
  .app-footer .app-about-link {
    display: none;
  }
  .settings-popover {
    left: var(--settings-left, 12px);
    right: auto;
    width: min(280px, calc(100vw - 28px));
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
  }
}
/* M-23: in a short landscape viewport, the More menu's single-column list
   (Portal, Help, Feedback, Chat, Add, History, About) scrolls internally with
   several items hidden below the fold. Two columns halves the row count. */
@media (max-width: 900px) and (max-height: 420px) {
  .fab-cluster > .mobile-utility-menu > .mobile-utility-menu-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* Phone collection rows keep the printing together below the name. Explicit
   cell sizing prevents desktop table density and borders leaking into the
   two-line layout. Binder pages and deck tables keep their own presentation. */
@media (max-width: 599px) {
  body.view-list .list-view.active tbody {
    gap: 0;
  }
  body.view-list .list-view.active tbody tr.detail-trigger {
    --mobile-row-leading: 48px;
    border: 0;
    border-bottom: 1px solid var(--color-line);
    column-gap: 4px;
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr) max-content;
    grid-template-rows: 22px 20px;
    min-height: 60px;
    padding: 8px 10px 8px var(--mobile-row-leading);
    position: relative;
    row-gap: 1px;
  }
  body.view-list .list-view.active tbody tr.detail-trigger:has(.col-check) {
    --mobile-row-leading: 76px;
  }
  body.view-list #listView.active tbody tr.detail-trigger td {
    border: 0;
    height: auto;
    line-height: 20px;
    margin: 0;
    min-height: 0;
    padding: 0;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .card-name-cell {
    display: block;
    grid-column: 1 / 4;
    grid-row: 1;
    min-width: 0;
    overflow: visible;
  }
  body.view-list .list-view.active .card-name-cell .card-name-thumb {
    height: 42px;
    left: calc(var(--mobile-row-leading) - 40px);
    position: absolute;
    top: 8px;
    width: 30px;
  }
  body.view-list .list-view.active .card-name-cell .card-name-button {
    display: block;
    font-size: var(--font-size-md);
    line-height: 22px;
    min-height: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .price-cell {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .set-cell {
    grid-column: 1;
    grid-row: 2;
    white-space: nowrap;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .cn-cell {
    grid-column: 2;
    grid-row: 2;
    white-space: nowrap;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .location-cell {
    grid-column: 3;
    grid-row: 2;
    min-width: 0;
    overflow: hidden;
    padding-left: 4px;
  }
  body.view-list .list-view.active .location-cell .location-pill {
    max-width: 100%;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .qty-cell {
    grid-column: 4;
    grid-row: 2;
    justify-self: end;
  }
  body.view-list .list-view.active tbody tr.detail-trigger .col-check {
    height: 44px;
    left: 6px;
    position: absolute;
    top: 8px;
    width: 28px;
  }
  body.view-list
    .list-view.active
    tbody
    tr.detail-trigger
    :is(
      .finish-cell,
      .rarity-cell,
      .condition-cell,
      .tags-cell,
      .collection-date-cell,
      .collection-table-filler
    ) {
    display: none;
  }
}
@media (max-width: 599px) and (pointer: coarse) {
  /* M-12: the checkbox's own hit box is 20x20 inside a 28x44 cell, so a
     near miss falls through to the row and opens detail instead of
     selecting. A `::before` hit-slop sized to the whole leading column at
     full row height covers the miss (listRowActions.js's onClick routes any
     tap landing on `.col-check` to a selection toggle); the checkbox glyph
     itself is untouched, so nothing moves on screen. Sized in pixels, not
     percent -- percentage height on this absolutely positioned box resolves
     to 0 against a min-height-only row. */
  body.view-list .list-view.active tbody tr.detail-trigger .col-check::before {
    content: '';
    position: absolute;
    left: -6px;
    top: -8px;
    width: var(--mobile-row-leading);
    height: 60px;
  }
}
/* BEN-986: 600-900px compact table tier. Below 900px the block above flips
   the collection table straight to phone card rows — fine at phone widths,
   but at 760px those rows stretch edge-to-edge with big dead space and no
   real tabular scan. Here the table stays a table: same column model
   (`views/collectionTableColumnConfig.js` ids via `data-column-id`, colgroup
   from `views/listRowView.js`), just a smaller column subset chosen by task
   priority (name / set / price / container). Everything else stays reachable
   via the existing row-tap detail drawer. Percentage <col> widths (not px)
   guarantee the visible columns can never exceed the table's own width, so
   there's no horizontal scroll to fight. Selectors intentionally mirror the
   ones above at matching specificity — later in the cascade wins the tie, so
   each override lands only in this width band. */
@media (min-width: 600px) and (max-width: 900px) {
  body.view-list .list-view.active table,
  body.view-grid .grid-list-table {
    display: table;
  }
  body.view-list .list-view.active thead,
  body.view-grid .grid-list-table thead {
    display: table-header-group;
  }
  body.view-list .list-view.active thead th,
  body.view-grid .grid-list-table thead th {
    /* Contain the book sort glyph in its column, not at the viewport edge. */
    position: relative;
  }
  .list-view .collection-column-resize-handle {
    /* This tier uses percentage columns rather than desktop drag widths. */
    display: none;
  }
  body.view-list .list-view.active tbody,
  body.view-grid .grid-list-table tbody {
    display: table-row-group;
  }
  body.view-list .list-view.active tbody tr,
  body.view-grid .grid-list-table tbody tr {
    align-items: unset;
    background: transparent;
    border: 0;
    border-bottom: var(--border-width) solid var(--color-line);
    display: table-row;
    flex-wrap: unset;
    gap: 0;
    min-height: 0;
    padding: 0;
  }
  body.view-list .list-view.active tbody tr:hover,
  body.view-grid .grid-list-table tbody tr:hover {
    background: color-mix(in srgb, var(--color-accent-soft) 28%, var(--color-surface-raised));
  }
  body.view-list .list-view.active tbody tr.row-selected,
  body.view-grid .grid-list-table tbody tr.row-selected,
  body.view-list .list-view.active tbody tr.row-selected:hover,
  body.view-grid .grid-list-table tbody tr.row-selected:hover {
    background: var(--color-warn-soft);
  }
  body.view-list .list-view.active td,
  body.view-grid .grid-list-table td {
    display: table-cell;
    padding: 6px 8px;
  }
  body.view-list .list-view.active tbody td:not(.col-check):not(.collection-table-filler),
  body.view-grid .grid-list-table tbody td:not(.col-check):not(.collection-table-filler) {
    padding-top: 7px;
    padding-bottom: 5px;
  }
  body.view-list .list-view.active td.collection-table-filler,
  body.view-grid .grid-list-table td.collection-table-filler,
  body.view-list .list-view.active th.collection-table-filler,
  body.view-grid .grid-list-table th.collection-table-filler {
    padding: 0;
    width: 0;
  }
  body.view-list .list-view.active .col-check {
    align-items: unset;
    display: table-cell;
    justify-content: unset;
    min-height: 0;
    min-width: 0;
    text-align: center;
    vertical-align: middle;
  }
  body.view-list .list-view.active .card-name-cell,
  body.view-grid .grid-list-table .card-name-cell {
    align-items: unset;
    display: table-cell;
    flex: unset;
    gap: 0;
    min-width: 128px;
    order: unset;
  }
  body.view-list .list-view.active .card-name-thumb,
  body.view-grid .grid-list-table .card-name-thumb {
    /* Thumbnails are the phone-card affordance (BEN-524) — a compact table
       row uses the plain desktop-style truncated name instead. */
    display: none;
  }
  /* Task-priority column subset: name, set, price, container (+ the always-
     present select checkbox). Everything else — cn, finish, rarity,
     condition, tags, added, modified, qty — is one tap away in the detail
     drawer, not deleted from the data model. One rule hides the <col>, <th>,
     and <td> together since all three share `data-column-id`. */
  body.view-list .list-view.active [data-column-id='cn'],
  body.view-list .list-view.active [data-column-id='finish'],
  body.view-list .list-view.active [data-column-id='rarity'],
  body.view-list .list-view.active [data-column-id='condition'],
  body.view-list .list-view.active [data-column-id='tags'],
  body.view-list .list-view.active [data-column-id='added'],
  body.view-list .list-view.active [data-column-id='modified'],
  body.view-list .list-view.active [data-column-id='qty'],
  body.view-grid .grid-list-table [data-column-id='cn'],
  body.view-grid .grid-list-table [data-column-id='finish'],
  body.view-grid .grid-list-table [data-column-id='rarity'],
  body.view-grid .grid-list-table [data-column-id='condition'],
  body.view-grid .grid-list-table [data-column-id='tags'],
  body.view-grid .grid-list-table [data-column-id='added'],
  body.view-grid .grid-list-table [data-column-id='modified'],
  body.view-grid .grid-list-table [data-column-id='qty'] {
    display: none !important;
  }
  /* Share mode already drops the location column at phone widths (a share is
     scoped to one container, so it repeats on every row) — same call here. */
  body.share-mode.view-list .list-view.active [data-column-id='location'],
  body.share-mode.view-grid .grid-list-table [data-column-id='location'] {
    display: none;
  }
  /* Percentage <col> widths sum to 100% of the table's own width, so the
     visible columns can never add up to more than the viewport — no
     horizontal scroll regardless of any desktop drag-resized column widths
     (those are px and live in the inline `style` attribute, which these
     `!important` rules intentionally out-rank). */
  body.view-list
    .list-view.active
    colgroup[data-collection-table-columns]
    col[data-column-id='check'] {
    width: 8% !important;
  }
  /* The grid-mode reference table hides the select checkbox td entirely
     (rule above this tier) — collapse its column too, instead of leaving a
     blank 8%-wide gap; name/set/price/location fall a little short of 100%
     without it and the filler column silently absorbs the remainder. */
  body.view-grid
    .grid-list-table
    colgroup[data-collection-table-columns]
    col[data-column-id='check'] {
    display: none;
  }
  body.view-list
    .list-view.active
    colgroup[data-collection-table-columns]
    col[data-column-id='name'],
  body.view-grid
    .grid-list-table
    colgroup[data-collection-table-columns]
    col[data-column-id='name'] {
    width: 38% !important;
  }
  body.view-list
    .list-view.active
    colgroup[data-collection-table-columns]
    col[data-column-id='set'],
  body.view-grid
    .grid-list-table
    colgroup[data-collection-table-columns]
    col[data-column-id='set'] {
    width: 15% !important;
  }
  body.view-list
    .list-view.active
    colgroup[data-collection-table-columns]
    col[data-column-id='price'],
  body.view-grid
    .grid-list-table
    colgroup[data-collection-table-columns]
    col[data-column-id='price'] {
    width: 15% !important;
  }
  body.view-list
    .list-view.active
    colgroup[data-collection-table-columns]
    col[data-column-id='location'],
  body.view-grid
    .grid-list-table
    colgroup[data-collection-table-columns]
    col[data-column-id='location'] {
    width: 24% !important;
  }
}
/* Landscape phones (iPhone-class devices in landscape sit around 350-430px
   tall): the chrome above/below #listView leaves so little height that a
   portrait-tuned layout barely shows any content. Scoped by height, not
   orientation — the max-width above already keeps this off desktop. Placed
   after the compact-table tier above so the sticky restore here wins the
   cascade against that tier's `position: relative`. */
@media (max-width: 900px) and (max-height: 500px) {
  /* M-31: art sits beside the form instead of above it, so the
     price/quantity row never needs a scroll to reach. */
  #detailDrawer .drawer-body {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    align-items: start;
    gap: 14px;
  }
  #detailDrawer .detail-art-column {
    margin-bottom: 0;
  }
  #detailDrawer :is(.drawer-image-frame, .drawer-placeholder) {
    width: min(42vw, calc((100dvh - var(--detail-mobile-header-height) - 76px) * 488 / 680));
  }
  /* The narrow art column has no room for .detail-nav-position's fixed
     16ch flex-basis alongside both 44px buttons (it doesn't shrink) —
     drop the "N of M" label here and pin the buttons to the column's own
     edges instead of centering a row wider than its container. */
  #detailDrawer .detail-nav {
    justify-content: space-between;
  }
  #detailDrawer .detail-nav-position {
    display: none;
  }
  #detailDrawer #detailForm,
  #detailDrawer .detail-scroll {
    display: block;
  }
  /* M-18: the compact-table tier's `thead th { position: relative }` (above)
     keeps a book decoration glyph inside its column but also stops the
     header sticking, so a landscape phone's ~3 visible rows lose their
     column labels on the first scroll. Restore sticky for the real table
     (not the grid-mode reference table, which still needs the glyph fix). */
  body.view-list .list-view.active thead th {
    position: sticky;
  }
  /* The header row's own compact height/font live in book.css, next to the
     60px/22px-blackletter rule this overrides. */
  /* Collapse the footer to just the totals line so the list keeps its rows. */
  .app-footer .app-history-ticker {
    display: none;
  }
}
.mcp-chat-form-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

@media (max-width: 600px) {
  .app-header {
    gap: 6px;
    padding: 8px 10px;
  }
  .app-header h1 {
    font-size: var(--font-size-xl);
  }
  .quick-jump-panel {
    /* --header-h is measured + set by the quick-jump open() handler so the
       panel clears a header that may grow (e.g. a sync banner). */
    padding-top: calc(var(--header-h, 50px) + 12px);
  }
  .quick-jump-result {
    grid-template-columns: 54px minmax(0, 1fr);
  }
  .app-header-views .toggle-view {
    padding-left: 8px;
    padding-right: 8px;
  }
  .sync-chip {
    padding-left: 8px;
    padding-right: 8px;
  }
  .app-center {
    padding: 10px 12px var(--app-floating-clearance, 68px);
    --app-center-pad-top: 10px;
  }
  .app-left {
    padding: 0;
  }
  .app-right {
    padding: 10px 12px;
  }
  .grid,
  .grid.grid-small,
  .grid.grid-medium {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
  }
  .grid.grid-large {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 8px;
  }
  .locations-list {
    grid-template-columns: 1fr;
  }
  .location-card-name {
    align-items: flex-start;
  }
  .location-card-edit-btn,
  .location-card-menu-btn {
    min-height: 32px;
    min-width: 32px;
  }
  .grid-surface {
    padding: 10px;
  }
  .container-identity-strip {
    flex-wrap: wrap;
  }
  .container-identity-spacer {
    display: none;
  }
  .container-identity-strip .grid-summary {
    flex: 1 1 100%;
    text-align: left;
  }
  .grid-page {
    gap: 8px;
    width: min(var(--grid-page-width, 760px), calc(100vw - 44px));
  }
  .grid-page-indicator {
    min-width: 82px;
  }
  .deck-columns {
    --deck-card-w: 150px;
    gap: 16px 8px;
  }
  /* BEN-mobile-audit M-06: the sticky "View/Group/Sort" strip's status text
     is the widest part of the fixed topbar and the first thing to overflow;
     the card count/legality is still visible in the deck header above. */
  .deck-topbar-status {
    display: none;
  }
  /* BEN-mobile-audit M-07: --deck-name-bar was a fixed 26-36px tuned for a
     ~160-250px desktop card. On a phone a stacked column collapses to one
     ~378px-wide card (deckColumnLayoutForWidth has no room for a second),
     so a 26px strip only bares the border, not the printed name. Measured
     against real card art, the name plate sits at roughly 5%-10% of card
     height (680/488 aspect) regardless of card size, so reveal to 11% of
     that height (a hair past the plate) plus 48px of clearance below it for
     the menu/quantity pill, so the pill has somewhere to live that isn't on
     top of the name (see the pill rules below). Applies to every card size
     since the rendered width on a phone is governed by viewport, not the
     desktop small/medium/large preference. */
  .deck-workspace.deck-card-size-small,
  .deck-workspace.deck-card-size-medium,
  .deck-workspace.deck-card-size-large {
    --deck-name-bar: calc(100% * 680 / 488 * 0.11 + 48px);
  }
  /* Move the menu/quantity pill down into that clearance, off the name, and
     shrink its visible size back down — the mobile 44px touch-target floor
     (.icon-btn) otherwise inflates it to a solid 44px square. The hit area
     stays 44px via the invisible ::after slop instead. */
  .deck-workspace .deck-stack .deck-card .deck-card-menu-btn,
  .deck-workspace .deck-side-stack .deck-card .deck-card-menu-btn,
  .deck-workspace .deck-stack .deck-card .deck-card-quantity-pill,
  .deck-workspace .deck-side-stack .deck-card .deck-card-quantity-pill {
    top: 11%;
    height: 22px;
    min-height: 0;
  }
  .deck-workspace .deck-stack .deck-card .deck-card-menu-btn::after,
  .deck-workspace .deck-side-stack .deck-card .deck-card-menu-btn::after {
    content: '';
    position: absolute;
    inset: -11px 0;
  }
  /* M-24: Gallery was one left-aligned column (the desktop card width never
     fit twice in a phone-width row). Two narrower columns fill the width. */
  .deck-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-left: 8px;
    padding-right: 8px;
  }
  .app-header h1 {
    font-size: var(--font-size-lg);
  }
  .app-header-views .toggle-view {
    font-size: var(--font-size-xs);
    min-width: var(--vui-touch-target);
    padding: 5px 4px;
  }
  .app-header-views .view-icon {
    margin-right: 0;
  }
  .sync-account-slot {
    min-width: 0;
  }
  .sync-chip {
    gap: 3px;
    justify-content: center;
    min-width: var(--vui-touch-target);
    padding-left: 4px;
    padding-right: 4px;
  }
  .sync-chip .sync-label {
    display: block;
  }
  .settings-toggle {
    padding-left: 7px;
    padding-right: 7px;
  }
}

@media (hover: none) {
  .card-actions {
    opacity: 1;
    pointer-events: auto;
  }
  .card-caption {
    display: none;
  }
  /* BEN-496/BEN-521: no physical keyboard on touch devices — hide the keyboard
     shortcut hints (FAB letter badges and inline ctrl/shift/esc badges). */
  .fab-shortcut,
  .btn-shortcut {
    display: none;
  }
  /* M-25: .title-edit-cue is opacity: 0 until :hover/:focus-visible, so it
     never actually shows on touch — but it still reserves layout width in
     the title button's flex row, truncating short container/deck names
     sooner than necessary. Drop it; tapping the title already opens the
     same edit dialog. */
  .title-edit-cue {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .app-left,
  .detail-drawer {
    transition: none;
  }
}

/* Tomebound: theme tools. Cascade order is declared in ../styles.css. */

/* Theme editor — design tool, mounted on demand. */
.theme-editor {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  box-shadow: var(--shadow-overlay);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  font: inherit;
  font-size: var(--font-size-sm);
  max-height: 80vh;
  position: fixed;
  right: calc(24px + env(safe-area-inset-right, 0px));
  top: 80px;
  width: 380px;
  z-index: 200;
}
.theme-editor.is-dragging {
  user-select: none;
}
.theme-editor-head {
  align-items: center;
  background: var(--color-text);
  color: var(--color-text-inverse);
  cursor: grab;
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2);
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
}
.theme-editor.is-dragging .theme-editor-head {
  cursor: grabbing;
}
.theme-editor-head h2 {
  font-size: var(--font-size-md);
  font-weight: 400;
  margin: 0;
}
.theme-editor-head-actions {
  align-items: center;
  display: flex;
  gap: var(--space-1);
}
.theme-editor-btn {
  background: transparent;
  border: 1px solid var(--color-on-dark-line);
  color: var(--color-text-inverse);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-sm);
  padding: 2px 8px;
}
.theme-editor-btn:hover {
  border-color: var(--color-text-inverse);
}
.theme-editor-btn-primary {
  background: var(--color-text-inverse);
  color: var(--color-text);
}
.theme-editor-close {
  background: transparent;
  border: 1px solid var(--color-on-dark-line);
  color: var(--color-text-inverse);
  cursor: pointer;
  font: inherit;
  height: 22px;
  width: 22px;
  padding: 0;
}
.theme-editor-preset-bar {
  align-items: center;
  background: var(--color-surface-sunken);
  border-bottom: var(--border-width) solid var(--color-line);
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}
.theme-editor-preset-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.theme-editor-preset-select {
  flex: 1 1 auto;
}
.theme-editor-dirty {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.theme-editor-dirty.is-dirty {
  color: var(--color-warn);
}
.theme-editor-dirty.is-saved {
  color: var(--color-success);
}
.theme-editor-body {
  overflow-y: auto;
  padding: var(--space-2) var(--space-3);
}
.theme-editor-section {
  border-bottom: var(--border-width) solid var(--color-line);
  padding: var(--space-2) 0;
}
.theme-editor-section:last-child {
  border-bottom: none;
}
.theme-editor-section > summary {
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  list-style: none;
  margin-bottom: var(--space-1);
  text-transform: none;
}
.theme-editor-section > summary::-webkit-details-marker {
  display: none;
}
.theme-editor-grid {
  display: grid;
  gap: var(--space-1);
}
.theme-editor-row {
  align-items: center;
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 130px 1fr;
}
.theme-editor-row-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-editor-control {
  align-items: center;
  display: flex;
  gap: var(--space-1);
  min-width: 0;
}
.theme-editor-color-picker {
  background: none;
  border: var(--border-width) solid var(--color-line-strong);
  cursor: pointer;
  flex-shrink: 0;
  height: 22px;
  padding: 0;
  width: 30px;
}
.theme-editor-text-input,
.theme-editor-select,
.theme-editor-number-input {
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-line);
  color: var(--color-text);
  font: inherit;
  font-size: var(--font-size-xs);
  min-width: 0;
  padding: 2px 6px;
}
.theme-editor-text-input {
  flex: 1 1 auto;
}
.theme-editor-text-input-wide {
  width: 100%;
}
.theme-editor-number-input {
  width: 64px;
}
.theme-editor-unit-suffix {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.theme-editor-export-area {
  background: var(--color-surface-sunken);
  border: none;
  border-top: var(--border-width) solid var(--color-line);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  height: 140px;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  width: 100%;
}

/* Theme gallery — full-screen swatch grid for browsing presets. */
.theme-gallery-overlay {
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  inset: 0;
  position: fixed;
  z-index: 220;
}
.theme-gallery-head {
  align-items: center;
  background: var(--color-text);
  color: var(--color-text-inverse);
  display: flex;
  flex-shrink: 0;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.theme-gallery-head h2 {
  font-size: var(--font-size-base);
  font-weight: 400;
  margin: 0;
}
.theme-gallery-hint {
  color: var(--color-on-dark-text-soft);
  font-size: var(--font-size-xs);
  margin-left: auto;
}
.theme-gallery-close {
  background: transparent;
  border: 1px solid var(--color-on-dark-line);
  color: var(--color-text-inverse);
  cursor: pointer;
  font: inherit;
  height: 24px;
  padding: 0;
  width: 24px;
}
.theme-gallery-close:hover {
  border-color: var(--color-text-inverse);
}
.theme-gallery-grid {
  display: grid;
  flex: 1 1 auto;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  overflow-y: auto;
  padding: var(--space-4);
}

/* Each swatch tile establishes its OWN token scope via inline style.
   Every selector inside .theme-swatch-body therefore renders with that
   tile theme rather than the global theme. */
.theme-swatch {
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-line-strong);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  overflow: hidden;
  padding: 0;
  text-align: left;
  text-transform: none;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}
.theme-swatch:hover {
  box-shadow: var(--shadow-overlay);
  transform: translateY(-2px);
}
.theme-swatch-label {
  align-items: baseline;
  background: var(--color-surface-sunken);
  border-bottom: var(--border-width) solid var(--color-line);
  display: flex;
  gap: var(--space-2);
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
}
.theme-swatch-label-name {
  color: var(--color-text-strong);
  font-family: var(--font-heading);
  font-size: var(--font-size-md);
}
.theme-swatch-label-mode {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.theme-swatch-body {
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
}
.theme-swatch-header {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
}
.theme-swatch-title {
  color: var(--color-text-strong);
  font-family: var(--font-heading);
  font-size: var(--font-size-md);
}
.theme-swatch-meta {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.theme-swatch-card-strip {
  display: flex;
  gap: 6px;
}
.theme-swatch-card-pip {
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-subtle);
  height: 18px;
  width: 18px;
}
.theme-swatch-card-pip[data-pip='w'] {
  background: var(--color-mana-w);
}
.theme-swatch-card-pip[data-pip='u'] {
  background: var(--color-mana-u);
}
.theme-swatch-card-pip[data-pip='b'] {
  background: var(--color-mana-b);
}
.theme-swatch-card-pip[data-pip='r'] {
  background: var(--color-mana-r);
}
.theme-swatch-card-pip[data-pip='g'] {
  background: var(--color-mana-g);
}
.theme-swatch-card-pip[data-pip='c'] {
  background: var(--color-mana-c);
}
.theme-swatch-row {
  border-bottom: var(--border-width) solid var(--color-line);
  display: grid;
  font-size: var(--font-size-sm);
  gap: var(--space-2);
  grid-template-columns: 1fr 36px 18px 30px;
  padding: 4px 0;
}
.theme-swatch-row-alt {
  background: var(--color-surface-sunken);
  margin: 0 calc(-1 * var(--space-3));
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.theme-swatch-cell-name {
  color: var(--color-text-strong);
}
.theme-swatch-cell-set,
.theme-swatch-cell-rarity,
.theme-swatch-cell-qty {
  color: var(--color-text-muted);
}
.theme-swatch-input-row {
  display: flex;
}
.theme-swatch-input {
  background: var(--color-input-bg);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  color: var(--color-text);
  flex: 1 1 auto;
  font: inherit;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  padding: 4px 8px;
}
.theme-swatch-btn-row {
  display: flex;
  gap: var(--space-1);
}
.theme-swatch-btn {
  background: transparent;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  color: var(--color-text-strong);
  cursor: pointer;
  font: inherit;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  padding: 4px 10px;
  text-transform: none;
}
.theme-swatch-btn-primary {
  background: var(--color-text-strong);
  border-color: var(--color-text-strong);
  color: var(--color-text-inverse);
}
.theme-swatch-btn-danger {
  color: var(--color-danger);
  border-color: var(--color-danger-line);
}
.theme-swatch-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.theme-swatch-chip {
  border: 1px solid;
  border-radius: var(--radius-sharp);
  font-size: var(--font-size-xxs);
  padding: 2px 8px;
}
.theme-swatch-chip-success {
  background: var(--color-success-soft);
  border-color: var(--color-success-line);
  color: var(--color-success);
}
.theme-swatch-chip-warn {
  background: var(--color-warn-soft);
  border-color: var(--color-warn-line);
  color: var(--color-warn);
}
.theme-swatch-chip-danger {
  background: var(--color-danger-soft);
  border-color: var(--color-danger-line);
  color: var(--color-danger);
}
.theme-swatch-chip-info {
  background: var(--color-info-soft);
  border-color: var(--color-info-line);
  color: var(--color-info);
}

/* Tomebound: design library. Cascade order is declared in ../styles.css. */

/* Design system library — single-home overlay for components + patterns. */
.lib-overlay {
  background: var(--color-bg);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  inset: 0;
  position: fixed;
  z-index: 230;
}
.lib-head {
  align-items: center;
  background: var(--color-text);
  color: var(--color-text-inverse);
  display: flex;
  flex-shrink: 0;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.lib-head h2 {
  font-family: var(--font-heading);
  font-size: var(--font-size-base);
  font-weight: 400;
  margin: 0;
}
.lib-head-hint {
  color: var(--color-on-dark-text-soft);
  font-size: var(--font-size-xs);
  margin-left: var(--space-2);
}
.lib-head-theme {
  align-items: center;
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}
.lib-head-theme > span {
  color: var(--color-on-dark-text-soft);
  font-size: var(--font-size-xs);
  text-transform: none;
}
.lib-head-theme-select {
  background: transparent;
  border: 1px solid var(--color-on-dark-line);
  color: var(--color-text-inverse);
  font: inherit;
  font-size: var(--font-size-sm);
  padding: 2px 6px;
}
.lib-close {
  background: transparent;
  border: 1px solid var(--color-on-dark-line);
  color: var(--color-text-inverse);
  cursor: pointer;
  font: inherit;
  height: 24px;
  padding: 0;
  width: 24px;
}
.lib-close:hover {
  border-color: var(--color-text-inverse);
}
.lib-shell {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: 240px 1fr;
  min-height: 0;
}
.lib-nav {
  background: var(--color-surface-sunken);
  border-right: var(--border-width) solid var(--color-line);
  overflow-y: auto;
  padding: var(--space-3);
}
.lib-nav-group + .lib-nav-group {
  margin-top: var(--space-4);
}
.lib-nav-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
  text-transform: none;
}
.lib-nav-list {
  display: flex;
  flex-direction: column;
}
.lib-nav-item {
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  padding: 4px 8px;
  text-align: left;
  text-transform: none;
  transition:
    color var(--motion-fast) ease,
    border-color var(--motion-fast) ease;
}
.lib-nav-item:hover {
  color: var(--color-text);
}
.lib-nav-item.is-active {
  border-left-color: var(--color-text-strong);
  color: var(--color-text-strong);
}
.lib-main {
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}
.lib-entry-head {
  margin-bottom: var(--space-4);
}
.lib-entry-kicker {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: none;
}
.lib-entry-title {
  color: var(--color-text-strong);
  font-family: var(--font-heading);
  font-size: var(--font-size-heading);
  font-weight: 400;
  margin: 0 0 var(--space-2);
}
.lib-entry-rule {
  color: var(--color-text);
  font-size: var(--font-size-md);
  margin: 0 0 var(--space-2);
  max-width: 70ch;
}
.lib-entry-tokens {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.lib-entry-tokens code {
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-line);
  font-family: var(--font-mono);
  margin-right: 4px;
  padding: 1px 4px;
}
.lib-entry-demo {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  padding: var(--space-4);
}

/* shared scaffolds used by entry builders */
.lib-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.lib-stack-row {
  align-items: center;
  display: flex;
  gap: var(--space-3);
}
.lib-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.lib-subhead {
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-size: var(--font-size-sm);
  font-weight: 400;
  margin: var(--space-3) 0 var(--space-1);
  text-transform: none;
}
.lib-subhead:first-child {
  margin-top: 0;
}
.lib-note {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-2);
  max-width: 70ch;
}
.lib-field-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  min-width: 120px;
  text-transform: none;
}

/* color swatches */
.lib-swatches {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.lib-swatch {
  align-items: center;
  border: var(--border-width) solid var(--color-line);
  display: flex;
  gap: var(--space-2);
  padding: var(--space-1);
}
.lib-swatch-chip {
  border: var(--border-width) solid var(--color-line);
  flex-shrink: 0;
  height: 28px;
  width: 28px;
}
.lib-swatch-name {
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

/* spacing */
.lib-spacing-row {
  align-items: center;
  display: flex;
  gap: var(--space-3);
}
.lib-spacing-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  min-width: 80px;
}
.lib-spacing-bar {
  background: var(--color-text-strong);
  display: inline-block;
  height: 8px;
}

/* radii */
.lib-radii {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.lib-radius-cell {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.lib-radius-shape {
  background: var(--color-text-strong);
  height: 48px;
  width: 48px;
}
.lib-radius-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

/* shadows */
.lib-shadows {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.lib-shadow-card {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  padding: var(--space-3);
  text-align: center;
}

/* motion */
.lib-motion {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.lib-motion-card {
  align-items: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line-strong);
  color: var(--color-text);
  cursor: default;
  display: flex;
  flex-direction: column;
  font-size: var(--font-size-sm);
  height: 96px;
  justify-content: center;
  text-align: center;
  width: 140px;
}
.lib-motion-card[data-speed='fast']:hover {
  background: var(--color-text-strong);
  color: var(--color-text-inverse);
  transition: all var(--motion-fast) ease;
}
.lib-motion-card[data-speed='base']:hover {
  background: var(--color-text-strong);
  color: var(--color-text-inverse);
  transition: all var(--motion-base) ease;
}
.lib-motion-card[data-speed='slow']:hover {
  background: var(--color-text-strong);
  color: var(--color-text-inverse);
  transition: all var(--motion-slow) ease;
}

/* truncation */
.lib-trunc-demo {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  max-width: 520px;
}
.lib-trunc {
  display: inline-block;
  flex: 1 1 auto;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-trunc-multi {
  display: -webkit-box;
  flex: 1 1 auto;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 360px;
  overflow: hidden;
}

/* hover */
.lib-hover-row {
  align-items: center;
  display: flex;
  gap: var(--space-3);
}
.lib-hover-card {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-line);
  cursor: default;
  font-size: var(--font-size-sm);
  padding: var(--space-3);
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
  width: 220px;
}
.lib-hover-card:hover {
  box-shadow: var(--shadow-firm);
  transform: translateY(-2px);
}

/* Settings popover additions for theme picker */
.settings-options-stack {
  display: flex;
  flex-direction: column;
}
.settings-theme-select {
  background: transparent;
  border: var(--border-width) solid var(--color-line-strong);
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-sm);
  min-height: 28px;
  padding: 4px 8px;
  text-transform: none;
}
.settings-theme-select:hover,
.settings-theme-select:focus-visible {
  border-color: var(--color-text-strong);
  color: var(--color-text-strong);
  outline: none;
}

/* Tomebound: patterns. Cascade order is declared in ../styles.css. */

/* Banner (BEN-449) is vellum-ui's canonical .banner component
   (components.css) — tomebound no longer carries a local copy (BEN-704
   dedup). [hidden] is handled by vellum's global guard in base.css. */

/* Site-stale banner (BEN-386) — shown when a newer deploy is live on the
   server than the one this tab loaded. Soft affordance only; no auto-reload.
   BEN-449: adopts the shared .banner pattern; only its hidden state is set
   here. */
.site-stale-banner.hidden {
  display: none;
}

/* BEN-862 / ADR 0013: sync alert banner — the single surface for every sync
   problem (it replaced a second bottom-right notice that used to show at the same
   time). Rides the shared .banner family; only its tint + hidden state live here.
   Two tones: danger when a change was actually lost, warn when the collection is
   intact but read-only (offline, can't reach sync). Status tokens carry their own
   light/dark values. */
.sync-alert-banner {
  background: var(--vui-status-danger-bg);
  border-bottom-color: var(--vui-status-danger-border);
  color: var(--vui-status-danger-text);
}
.sync-alert-banner-warning {
  background: var(--vui-status-warn-bg);
  border-bottom-color: var(--vui-status-warn-border);
  color: var(--vui-status-warn-text);
}
.sync-alert-banner.hidden {
  display: none;
}

/* BEN-876: auth-loss banner — the "fails loudly" surface for an unexpected
   sign-out (a 401 that survived refresh+retry, or Clerk invalidating the
   session out from under the user). Rides the shared .banner family; only its
   danger tint + hidden state live here. Never shown for a deliberate sign-out
   (see syncEngine.js deliberateSignOutInFlight). */
.auth-loss-banner {
  background: var(--vui-status-danger-bg);
  border-bottom-color: var(--vui-status-danger-border);
  color: var(--vui-status-danger-text);
}
.auth-loss-banner.hidden {
  display: none;
}

/* ---- Container tiers (ported from arcane-ledger). Token-driven so they
   render heavy chrome under arcane (default) and dial back via
   DIAL_BACK_FROM_ARCANE under every other theme. ---- */

.tome,
.branch,
.scroll,
.panel {
  position: relative;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  box-shadow: var(--shadow-hard);
  padding: var(--space-5);
}
.tome {
  background: var(--color-surface-raised);
}
.branch {
  background: var(--color-surface);
}
.scroll {
  border-style: double;
  border-width: calc(var(--border-width) + 1px);
  background: var(--color-surface-raised);
}
.panel {
  border-width: max(1px, calc(var(--border-width) - 1px));
  background: var(--color-surface);
  padding: var(--space-4);
}
/* Section heading typography that pairs with the container tiers. */
.tome > .heading,
.branch > .heading,
.scroll > .heading,
.panel > .heading {
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: var(--border-width) solid var(--color-text-strong);
  color: var(--color-text-strong);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-title);
  letter-spacing: var(--label-tracking);
  text-transform: var(--label-transform);
}

/* ---- Pattern library (ported from arcane-ledger). All token-driven so
   they auto-theme. Generic class names, usable anywhere in tomebound. ---- */

/* Spreadsheet sheet — chunky bordered table with row/col heads, formula cells,
   sum totals, and a "selected" cell outline. */
.sheet-wrap {
  overflow: auto;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-hard);
}
.sheet-wrap table {
  width: 100%;
  border-collapse: collapse;
}
.sheet-wrap th,
.sheet-wrap td {
  border: 1px solid var(--color-line);
  padding: 6px 9px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
.sheet-wrap .row-head,
.sheet-wrap .col-head,
.sheet-wrap .corner {
  background: var(--color-surface-sunken);
  font-weight: var(--font-weight-title);
  text-align: center;
  width: 44px;
}
.sheet-wrap .cell-formula {
  background: var(--color-accent-soft);
  font-weight: var(--font-weight-title);
}
.sheet-wrap .cell-sum {
  background: var(--color-warn-soft);
  font-weight: var(--font-weight-title);
}
.sheet-wrap .cell-selected {
  outline: 3px solid var(--color-accent);
  outline-offset: -3px;
  background: var(--color-info-soft);
}
.sheet-wrap .num {
  text-align: right;
}

/* Formula bar — one-line fx token + monospace input + optional status pill. */
.formula-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface-raised);
  padding: 8px 10px;
  box-shadow: var(--shadow-hard-small);
  font-family: var(--font-mono);
}
.formula-token {
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  padding: 6px 8px;
  line-height: 1;
  font-weight: var(--font-weight-title);
}
.formula-input {
  flex: 1;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface);
  padding: 8px 10px;
  font-family: var(--font-mono);
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.formula-status {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  padding: 4px 8px;
  border-radius: var(--radius-sharp);
  font-size: var(--font-size-xs);
  text-transform: none;
  font-family: var(--font-mono);
}

/* Toolbar — wrapping row of monospace "tool" pills for view controls. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
}
.tool {
  padding: 6px 8px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-title);
  text-transform: none;
  box-shadow: var(--shadow-hard-small);
  cursor: pointer;
}

/* Range slider — minimal styled input[type=range]. */
.range {
  width: 100%;
  appearance: none;
  height: 8px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: var(--shadow-hard-small);
  cursor: grab;
}
.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: var(--shadow-hard-small);
  cursor: grab;
}

/* Switch toggle comes from vellum (.switch / .switch-input / .switch-track);
   the legacy local block collided with it (BEN-613). */

/* Pagination — page-number chips with active and muted states. */
.page-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 4px 8px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-hard-small);
  font-family: var(--font-mono);
  font-weight: var(--font-weight-title);
  cursor: pointer;
  user-select: none;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}
.page-chip:not(.muted):hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--color-text-strong);
}
.page-chip.active {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}
.page-chip.muted {
  cursor: default;
  opacity: 0.65;
}

/* Dropdown via details/summary — declarative open/close, popover menu. */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown > summary {
  position: relative;
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  font-family: var(--font-mono);
  font-weight: var(--font-weight-title);
  cursor: pointer;
  box-shadow: var(--shadow-hard-small);
  list-style: none;
  user-select: none;
}
.dropdown > summary::-webkit-details-marker {
  display: none;
}
.dropdown > summary::after {
  content: '▾';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}
.dropdown-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  padding: 4px;
  box-shadow: var(--shadow-popover);
  z-index: 20;
}
.dropdown-item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-weight: var(--font-weight-title);
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover {
  background: var(--color-surface-hover);
}

/* Tooltips come from vellum's .tooltip-host + data-tooltip (BEN-606). */

/* Metric grid — fluid-column tile grid of labeled values. */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-2);
}
.metric {
  display: grid;
  gap: 5px;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface-raised);
  padding: 10px;
  box-shadow: var(--shadow-hard-small);
  font-family: var(--font-mono);
}
.metric > span {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: none;
  letter-spacing: var(--label-tracking);
}
.metric > strong {
  font-family: var(--font-body);
  font-size: 1.4rem;
  line-height: 1;
  font-weight: var(--font-weight-title);
}

/* Notice — emphatic info block on accent surface. */
.notice {
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  padding: 12px 14px;
  box-shadow: var(--shadow-hard-small);
  font-family: var(--font-mono);
  font-weight: var(--font-weight-title);
}

/* Tomebound: decoration. Cascade order is declared in ../styles.css. */

/* ============================================================
 * Arcane-ledger foundation decoration
 *
 * Applies the arcane-ledger visual language to tomebound's actual
 * component classes. Layered last in the cascade so it wins at equal
 * specificity over earlier component rules.
 *
 * Locked to the arcane aesthetic (no dial-back). The 12 other themes
 * are intentionally parked while we iterate on this one.
 * ============================================================ */

/* --- Body dust overlay: subtle parchment grain over the whole app --- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.18;
  background:
    radial-gradient(rgba(255, 245, 210, 0.22) 1px, transparent 1px),
    radial-gradient(rgba(21, 16, 13, 0.16) 1px, transparent 1px);
  background-size:
    17px 19px,
    29px 31px;
  background-position:
    0 0,
    7px 11px;
  mix-blend-mode: soft-light;
}

/* --- BEN-399: removed the gilded top stripe on .app-header — it read as a
       broken dashed line rather than a skeuomorphic gilt edge. position:
       relative kept (harmless, other decorations may anchor to it). --- */
.app-header {
  position: relative;
}

/* --- Bark rail decoration on sidebars (the "branch" panels) --- */
.app-left,
.app-right {
  position: relative;
}
.app-left::after,
.app-right::after {
  /* BEN-405: hidden for now — the bark rail adds clutter where it's placed.
     CSS kept intact so it can be revived later. */
  display: none;
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 7px;
  border: 2px solid var(--color-text-strong);
  border-radius: var(--radius-soft);
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.18),
      rgba(0, 0, 0, 0.18) 5px,
      transparent 5px,
      transparent 12px
    ),
    var(--color-text-muted);
  box-shadow: var(--shadow-hard-small);
  pointer-events: none;
  z-index: 1;
}
.app-left::after {
  right: -4px;
}
.app-right::after {
  left: -4px;
}

/* Compatibility mirror of Vellum's button primitive. Tomebound still has
   app-specific button selectors below, so the shared base values remain here
   until that legacy cascade is fully retired. */
.btn {
  align-content: center;
  align-items: center;
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sharp);
  position: relative;
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  /* Button labels and icon/shortcut adornments are a single unbreakable unit. */
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: center;
  min-height: var(--control-height-compact);
  padding: calc(var(--control-pad-y) - 1px) var(--control-pad-x) calc(var(--control-pad-y) + 1px);
  text-align: center;
  text-wrap: nowrap;
  white-space: nowrap;
  font-size: var(--font-size-sm);
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.2;
  cursor: pointer;
  text-transform: none;
  background-image: none;
  transition:
    transform var(--motion-fast) cubic-bezier(0.23, 1, 0.32, 1),
    border-color var(--motion-fast) ease,
    background-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}
.btn > svg,
.segment-btn > svg {
  align-self: center;
  display: block;
  flex: 0 0 auto;
}
.btn:hover:not(:disabled),
.ds-force-hover .btn:not(:disabled) {
  /* BEN-470: :not(:disabled) keeps disabled controls visually still while
     preserving their explanatory title tooltip. */
  background-color: var(--color-surface-hover);
  border-color: var(--color-line-strong);
  color: var(--color-text-strong);
  transform: none;
  box-shadow: var(--shadow-soft);
  filter: none;
}
.btn:active:not(:disabled),
.ds-force-active .btn:not(:disabled) {
  transform: scale(0.98);
  box-shadow: var(--shadow-subtle);
  filter: none;
}
.btn:disabled {
  box-shadow: none;
  filter: none;
  opacity: 0.62;
}
.btn:focus-visible,
.ds-force-focus .btn {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
/* Variants mirror Vellum's accent primary, quiet secondary, and soft danger. */
.btn:not(.btn-secondary):not(.btn-danger) {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
  font-weight: 500;
}
.btn:not(.btn-secondary):not(.btn-danger):hover:not(:disabled),
.ds-force-hover .btn:not(.btn-secondary):not(.btn-danger):not(:disabled) {
  background-color: var(--color-btn-primary-hover);
  border-color: var(--color-btn-primary-hover);
  color: var(--color-text-inverse);
}
.btn.btn-secondary {
  background-color: var(--color-surface-raised);
  color: var(--color-text-strong);
  border-color: var(--color-line);
}
.btn.btn-secondary:hover:not(:disabled),
.ds-force-hover .btn.btn-secondary:not(:disabled) {
  background-color: var(--color-surface-hover);
}
.btn.btn-danger {
  background-color: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger-line);
}
.btn.btn-danger:hover:not(:disabled) {
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.ds-force-hover .btn.btn-danger:not(:disabled) {
  color: var(--color-danger);
  border-color: var(--color-danger);
}
/* BEN-470: every disabled variant reads as a flat, muted surface with no
   raise or hover response. */
.btn:not(.btn-secondary):not(.btn-danger):disabled,
.btn.btn-secondary:disabled,
.btn.btn-danger:disabled {
  background-color: var(--color-surface-sunken);
  color: var(--color-text-muted);
  border-color: var(--color-line);
  box-shadow: none;
  filter: none;
  transform: none;
  cursor: default;
}

/* --- BEN-403: default arcane-ledger field. A real bordered vellum field with a
       carved-in inset shadow and mono type — the documented input style. App
       inputs with their own higher-specificity treatment (compact sidebar
       underlines, inline editors) keep theirs; everything else gets this. --- */
input[type='text'],
input[type='search'],
input[type='number'],
input[type='email'],
input[type='url'],
input[type='tel'],
input[type='password'],
input:not([type]),
textarea,
select {
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  color: var(--color-text-strong);
  /* BEN-467: extra right padding so the native dropdown arrow has breathing
     room from the border instead of crowding it. */
  padding: 8px 32px 8px 10px;
  font-family: var(--font-mono);
  /* BEN-613: token base size — fields without an explicit size used to fall
     back to the UA default. */
  font-size: var(--font-size-sm);
  text-overflow: ellipsis;
  box-shadow: var(--input-bevel);
}
input[type='text']:focus,
input[type='search']:focus,
input[type='number']:focus,
input[type='email']:focus,
input[type='url']:focus,
input[type='tel']:focus,
input[type='password']:focus,
input:not([type]):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-line-focus);
}

/* (The hard-shadow + mono chip identity that used to be layered here moved
   into the vellum .ui-chip base — one chip fleet-wide.) */

/* --- Press transitions on page chips --- */
.page-chip:not(.muted) {
  transition:
    transform var(--motion-fast) steps(2, end),
    box-shadow var(--motion-fast) steps(2, end),
    background-color var(--motion-fast);
}
.page-chip:not(.muted):hover {
  transform: translate(1px, 1px);
  background: var(--color-surface);
}
.page-chip:not(.muted):active {
  transform: translate(var(--press-shift), var(--press-shift));
  box-shadow: 0 0 0 var(--color-shadow);
}

/* (BEN-532/610's sunken head band retired — every head wears vellum's ink
   band, no local fill.) */

/* BEN-655 (2026-07-02): heads go flat — the BEN-532 drop shadow is retired. */

/* --- Table headers: hatched parchment background --- */
table thead th {
  /* BEN-420: cool sunken token instead of the hardcoded gold so the hatched
     header matches the cooler canvas. */
  background-image:
    linear-gradient(var(--color-surface-sunken), var(--color-surface-sunken)),
    repeating-linear-gradient(90deg, rgba(21, 16, 13, 0.08) 0 4px, transparent 4px 9px),
    radial-gradient(rgba(0, 0, 0, 0.14) 1px, transparent 1px);
  background-size:
    auto,
    auto,
    5px 5px;
}

/* (BEN-400's generic .modal* family retired — the chat panel and the design
   system demo both compose the real chat-head classes now: the vellum drag
   band + .mcp-chat-head vocabulary.) */

/* BEN-604: the close affordance is vellum's quiet grey × (.rune-close in
   vendored vellum-ui.css) — no local override. Glyph rule still holds:
   .rune-close uses ✕ (U+2715); .icon-btn close/dismiss use × (U+00D7). */

/* Drag-band chrome comes from vellum (.ui-modal-head-drag /
   .feedback-capture-head). Settings-popover-specific: bleed the band to the
   popover edges. */
.settings-modal-head {
  margin: 0 -12px 2px;
}

/* Reset belongs to an existing conversation and stays visually quiet beside Ask. */
.mcp-chat-form .mcp-chat-clear {
  appearance: none;
  min-height: 32px;
  padding: 4px 6px;
  margin-left: -6px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 11px;
  text-transform: none;
  cursor: pointer;
  box-shadow: none;
}
.mcp-chat-form .mcp-chat-clear:hover {
  color: var(--color-text-strong);
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}
.mcp-chat-form .mcp-chat-clear:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
@media (max-width: 600px) {
  .mcp-chat-form .mcp-chat-clear {
    min-height: 44px;
  }
}
/* Resize hit targets stay available without a decorative corner grip. */
.vui-modal-resize-handle::before,
.vui-modal-resize-handle::after,
.feedback-capture-resize-bottom-left::before {
  content: none;
}
@media (max-width: 900px) {
  .ui-modal-card > .vui-modal-resize-handle {
    display: none;
  }
}

/* Tomebound: design system reference. Cascade order is declared in ../styles.css. */

/* ============================================================
 * Design system reference standalone page
 *
 * Served at /design-system.html. Linked from the settings popover.
 * ============================================================ */
body.design-system-page {
  overflow: auto;
  background: var(--color-bg);
}
body.design-system-page::before,
body.design-system-page::after {
  /* The body dust overlay and any pseudo-elements meant for the app shell
     don't apply on the design system page — keep it clean. */
  content: none;
}
.ds-page-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.ds-page-head {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 24px;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-soft);
  background-image: linear-gradient(var(--color-surface-sunken), var(--color-surface-sunken));
  box-shadow: var(--shadow-hard);
}
.ds-page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--font-size-jumbo);
  font-weight: var(--font-weight-title);
  letter-spacing: -0.02em;
}
.ds-page-sub {
  margin: 0;
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
  /* keep clear of the absolutely-positioned .ds-page-links column */
  max-width: 64ch;
}
.ds-page-links {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.ds-page-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.ds-page-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.ds-toc {
  position: sticky;
  top: 16px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding-right: 4px;
}
.ds-toc-title {
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  text-transform: none;
  letter-spacing: var(--label-tracking);
  color: var(--color-text-muted);
  margin: 10px 0 4px;
}
.ds-toc-link {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  text-transform: none;
  padding: 4px 8px;
  border-radius: var(--radius-sharp);
  border-left: 2px solid transparent;
}
.ds-toc-link:hover {
  color: var(--color-text-strong);
  background: var(--color-surface-hover);
}
.ds-toc-link.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: var(--color-surface-hover);
}
.ds-toc-states {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-line);
}
@media (max-width: 900px) {
  .ds-page-layout {
    grid-template-columns: 1fr;
  }
  .ds-toc {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .ds-toc-states {
    flex-basis: 100%;
    border-bottom: none;
  }
}
.ds-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 16px;
}
.ds-group-title {
  margin: 0;
  padding-bottom: 6px;
  border-bottom: var(--border-width) solid var(--color-text-strong);
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-title);
  text-transform: none;
  letter-spacing: var(--label-tracking);
}
.ds-entry {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
  padding: 12px;
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface-raised);
}
.ds-entry-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-entry-name {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-title);
}
.ds-entry-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ds-entry-selectors code {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  padding: 2px 5px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-tight);
  background: var(--color-surface);
}
.ds-entry-desc {
  grid-column: 1 / 2;
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.45;
}
.ds-entry-demo {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  padding: 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto; /* zoomed demos can scroll within the panel instead of spilling */
}
/* Per-demo zoom controls — a vellum compact segmented pinned to the demo edge */
.ds-zoom-bar {
  align-self: flex-end;
}
.ds-zoom-stage {
  width: fit-content;
}
.ds-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.ds-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ds-history-frame {
  background: var(--color-surface-sunken);
  border-radius: var(--radius-soft);
  padding: 10px;
}
.ds-knobs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 10px;
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-sunken);
}
.ds-knob {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  text-transform: none;
  color: var(--color-text-muted);
}
.ds-knob input[type='text'],
.ds-knob select {
  font-size: var(--font-size-xxs);
  padding: 2px 4px;
}
.ds-knob input[type='text'] {
  width: 120px;
}
.ds-knob-canvas {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ds-substate {
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  text-transform: none;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.ds-static-popover {
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-soft);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
  width: 280px;
}
.ds-static-popover-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* BEN-479: render the position:fixed feedback-capture widget statically in the
   catalog. position:relative (not static) so the rune-close stays anchored to
   the widget corner; size to content instead of the fixed viewport frame. */
.ds-static-feedback {
  position: relative;
  inset: auto;
  width: min(360px, 100%);
  height: auto;
  min-height: 0;
  max-height: none;
}
.ds-table-wrap {
  width: 100%;
  /* BEN-466: as a flex item inside .ds-entry-demo, min-width:auto would let the
     wide demo table stretch the card past its grid cell. min-width:0 lets the
     wrap shrink so overflow-x scrolls the table instead of breaking layout. */
  min-width: 0;
  overflow-x: auto;
  border: var(--border-width) solid var(--color-text-strong);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-hard-small);
}
.ds-table-wrap table {
  font-size: var(--font-size-xs);
}
/* DS demo of the chat panel — a static stand-in for the floating
   .mcp-chat-widget frame (which is fixed-position + hidden until opened). */
.ds-chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  background: var(--color-neutral-white);
  border: 1px solid var(--color-neutral-900);
  border-radius: var(--radius-soft);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.ds-chat-panel-body {
  padding: 16px;
}
.ds-modal-log {
  border: 2px solid var(--color-line);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  padding: 14px;
  margin-bottom: 10px;
}
.ds-modal-empty-title {
  margin: 4px 0;
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-title);
}
.ds-modal-hint {
  margin: 0 0 12px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.ds-modal-prompts {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-modal-prompts li {
  padding-left: 10px;
  border-left: 2px solid var(--color-warn-line-soft);
  font-size: var(--font-size-sm);
}
.ds-modal-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}
.ds-modal-compose textarea {
  margin: 0;
  resize: vertical;
}
@media (max-width: 720px) {
  .ds-entry {
    grid-template-columns: 1fr;
  }
  .ds-entry-demo {
    grid-column: 1 / 2;
    grid-row: auto;
  }
  .ds-page-links {
    position: static;
    flex-direction: row;
    align-items: flex-start;
    align-self: flex-start;
    margin-top: 6px;
  }
}

/* BEN-477: adherence backlog checklist — priority-tagged rows of known DS drift */
.ds-backlog-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-backlog-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: var(--font-size-sm);
  line-height: 1.4;
}
.ds-backlog-prio {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  font-weight: var(--font-weight-title);
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 1px 6px;
  border-radius: var(--radius-sharp);
  border: 1px solid var(--color-line);
  min-width: 3.2em;
  text-align: center;
}
.ds-backlog-prio-high {
  background: var(--color-danger-soft);
  border-color: var(--color-danger-line);
  color: var(--color-danger);
}
.ds-backlog-prio-med {
  background: var(--color-warn-soft-pale);
  border-color: var(--color-warn-line);
  color: var(--color-text-muted);
}
.ds-backlog-prio-low {
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
}
.ds-backlog-text {
  color: var(--color-text);
}

/* BEN-987: state treatments + stress gallery catalog entries. */
.ds-empty-state-holder {
  width: 100%;
}
.ds-stress-width-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 4px;
  width: 100%;
}
.ds-stress-frame {
  flex: 0 0 auto;
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-sharp);
  overflow: hidden;
}
.ds-stress-frame-label {
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
  text-transform: none;
}
.ds-stress-frame-body {
  padding: 8px;
  overflow: auto;
}
.ds-stress-long-names {
  max-width: 480px;
}
/* Forces the reduced-motion end state for visual review without touching OS
   settings — vellum's .skeleton already gates its own animation on
   prefers-reduced-motion; this just reproduces that end state on demand. */
.ds-force-reduced-motion .skeleton {
  animation: none;
}

/* Tomebound: collection toolbar. Cascade order is declared in ../styles.css. */

/* BEN-959 revised preview: keep search and the three most common filters in a
   compact workbench. Less frequent filters and growing display preferences use
   focused popovers. Live controls return to the mobile sheet below 901px. */
.collection-controls-toolbar {
  --collection-toolbar-control-size: 32px;
  align-items: center;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) max-content;
  padding: 9px 12px;
}
body.view-list .collection-controls-toolbar.is-active:not([hidden]) {
  display: grid;
}
.collection-controls-toolbar .collection-toolbar-search {
  border: 0;
  margin: 0;
  min-width: 0;
  padding: 0;
}
.collection-toolbar-search > .sidebar-label,
.collection-toolbar-search > .search-syntax-link,
.collection-toolbar-view > .sidebar-label {
  display: none;
}
.collection-toolbar-search .search-wrap {
  max-width: none;
  width: 100%;
}
.collection-toolbar-search .search-input {
  block-size: var(--collection-toolbar-control-size);
  box-sizing: border-box;
}
/* Deliberately nowrap in the three-column layout: keeping it a single line is
   what gives the grid track a truthful min-content floor (see the toolbar's
   grid-template-columns). Wrapping is enabled only in the two-row layout below,
   where the row spans the full width and has somewhere to wrap to. */
.collection-toolbar-primary-filters {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  position: relative;
}
.collection-toolbar-primary-filter {
  flex: 0 0 auto;
  min-width: 0;
}
.collection-toolbar-filter--set {
  width: clamp(88px, 8vw, 108px);
}
.collection-toolbar-filter--tags {
  width: clamp(116px, 11vw, 148px);
}
.collection-toolbar-filter--format {
  width: clamp(112px, 10vw, 138px);
}
.collection-toolbar-filter--format .ms-trigger-label,
.collection-toolbar-filter--format .ms-pill {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.collection-toolbar-primary-filter .multiselect .ms-trigger {
  block-size: var(--collection-toolbar-control-size);
  box-sizing: border-box;
  white-space: nowrap;
}
.collection-toolbar-popover-trigger {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  block-size: var(--collection-toolbar-control-size, 32px);
  box-sizing: border-box;
  white-space: nowrap;
}
.collection-toolbar-popover-trigger svg {
  height: 15px;
  width: 15px;
}
.collection-toolbar-more-control {
  align-items: stretch;
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 0;
}
.collection-toolbar-more-control .collection-toolbar-more-trigger.is-active {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
  color: var(--color-text-strong);
}
.collection-toolbar-more-clear {
  align-items: center;
  appearance: none;
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent);
  border-left: 0;
  border-radius: 0 var(--radius-md, 5px) var(--radius-md, 5px) 0;
  color: var(--color-text-strong);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-variant-numeric: tabular-nums;
  justify-content: center;
  block-size: var(--collection-toolbar-control-size);
  box-sizing: border-box;
  min-width: var(--collection-toolbar-control-size);
  padding: 0 8px;
  white-space: nowrap;
}
.collection-toolbar-more-clear:hover,
.collection-toolbar-more-clear:focus-visible {
  background: color-mix(in srgb, var(--color-accent-soft) 72%, var(--color-surface-raised));
}
.collection-toolbar-more-clear:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.collection-toolbar-more-clear[hidden] {
  display: none;
}
.collection-controls-toolbar > .collection-toolbar-view {
  align-items: center;
  border: 0;
  display: flex;
  gap: 6px;
  justify-self: end;
  margin: 0;
  min-width: 108px;
  padding: 0;
  position: relative;
  width: auto;
}
body.view-list .collection-controls-toolbar > .collection-toolbar-view {
  display: flex;
}
.collection-toolbar-view .collection-display-controls {
  background: transparent;
  display: block;
  flex: 0 0 68px;
  min-width: 0;
  width: 68px;
}
.collection-toolbar-view .collection-display-controls-main,
.collection-toolbar-view .collection-display-mode {
  flex: 0 0 68px;
  width: 68px;
}
.collection-toolbar-view .collection-display-mode .segment-btn {
  align-items: center;
  display: inline-flex;
  flex: 0 0 34px;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 34px;
}
.collection-toolbar-view .collection-display-mode .view-icon-svg {
  height: 15px;
  width: 15px;
}
.collection-toolbar-settings-trigger {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 10px;
}
.sidebar-view-settings:not(.collection-toolbar-view) > .collection-toolbar-settings-trigger,
.sidebar-view-settings:not(.collection-toolbar-view) > .collection-toolbar-settings-popover {
  display: none;
}
.collection-toolbar-popover[hidden] {
  display: none !important;
}
.collection-toolbar-popover {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-soft);
  box-shadow: var(--shadow-popover);
  color: var(--color-text);
  padding: 12px;
  position: absolute;
  top: calc(100% + 8px);
  z-index: 80;
}
.collection-toolbar-more-popover {
  right: 0;
  max-height: min(720px, calc(100vh - 112px));
  /* iOS: 100vh exceeds the visible area while Safari's bars are showing. */
  max-height: min(720px, calc(100dvh - 112px));
  overflow: hidden;
  padding: 0;
  width: min(640px, calc(100vw - 32px));
}
.collection-toolbar-settings-popover {
  right: 0;
  width: min(336px, calc(100vw - 32px));
}
.collection-toolbar-settings-popover.is-top-layer {
  max-width: calc(100vw - 24px);
  overflow-y: auto;
  position: fixed;
  z-index: 2000;
}
.collection-toolbar-more-popover.is-top-layer {
  max-width: calc(100vw - 24px);
  overflow: hidden;
  position: fixed;
  z-index: 2000;
}
.collection-toolbar-popover-head {
  border-bottom: 1px solid var(--color-line-faint);
  display: grid;
  gap: 2px;
  margin: 0 0 11px;
  padding: 0 0 10px;
}
.collection-toolbar-more-popover .collection-toolbar-popover-head {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  margin: 0;
  padding: 12px 14px;
}
.collection-toolbar-more-popover .collection-toolbar-popover-head > div {
  display: grid;
  gap: 2px;
}
.collection-toolbar-popover-body {
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
}
.collection-toolbar-popover-actions {
  align-items: center;
  background: var(--color-surface-raised);
  border-top: 1px solid var(--color-line-faint);
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 14px;
}
.collection-toolbar-popover-count {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}
.collection-toolbar-more-popover:not([hidden]) {
  display: flex;
  flex-direction: column;
}
.collection-toolbar-popover-head strong {
  color: var(--color-text-strong);
  font-size: var(--font-size-sm);
  text-transform: none;
}
.collection-toolbar-popover-head span {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.35;
}
.collection-toolbar-more-popover .collection-toolbar-popover-body > .sidebar-section {
  border: 0;
  margin: 0;
  padding: 0;
}
.collection-toolbar-more-popover
  .collection-toolbar-popover-body
  > .sidebar-section
  > .sidebar-label {
  display: none;
}
.collection-toolbar-more-popover .sidebar-filters {
  display: block;
}
/* Three levels: section titles (strong, body face) head a group of fields;
   field labels stay small and muted; values read at control size. Sections are
   separated by a full-width rule above each title. */
.collection-filter-hierarchy {
  display: grid;
  gap: 0;
}
.collection-filter-group {
  display: grid;
  gap: 10px 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px 0 18px;
}
.collection-filter-group:first-child {
  padding-top: 2px;
}
.collection-filter-group + .collection-filter-group {
  border-top: 1px solid var(--color-line);
}
.collection-filter-group-title {
  color: var(--color-text-strong);
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  font-weight: 600;
  grid-column: 1 / -1;
  letter-spacing: -0.005em;
  margin: 0 0 2px;
  text-transform: none;
  white-space: nowrap;
}
.collection-filter-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.collection-filter-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.05em;
  text-transform: none;
}
.collection-filter-hierarchy .is-filter-active {
  background: var(--color-accent-soft);
  border-radius: var(--radius-sharp);
  box-shadow: 0 0 0 5px var(--color-accent-soft);
  color: var(--color-text-strong);
}
.collection-filter-hierarchy .is-filter-active > :is(span, .collection-filter-label),
.collection-filter-hierarchy label.is-filter-active {
  color: var(--color-text-strong);
  font-weight: 600;
}
.collection-filter-hierarchy .is-filter-active :is(input, select, .ms-trigger) {
  border-color: var(--color-accent);
  font-weight: 400;
}
.collection-filter-range {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.collection-toolbar-more-popover
  :is(
    input:not([type]),
    input[type='text'],
    input[type='number'],
    input[type='search'],
    input[type='url'],
    input[type='email'],
    select,
    .ms-trigger
  ) {
  min-height: var(--control-height, 36px);
  width: 100%;
}
.collection-toolbar-more-popover .advanced-filter-wide {
  grid-column: 1 / -1;
}
.collection-toolbar-more-popover .sidebar-filters > [data-toolbar-filter-label]:not([hidden]) {
  display: grid;
  gap: 4px;
}
.collection-toolbar-more-popover
  .sidebar-filters
  > [data-toolbar-filter-label]:not([hidden])::before {
  color: var(--color-text-muted);
  content: attr(data-toolbar-filter-label);
  font-family: var(--font-mono);
  font-size: var(--font-size-xxs);
  letter-spacing: 0.05em;
  text-transform: none;
}
.collection-toolbar-more-popover .sidebar-filters .clear-filters-btn:not([hidden]) {
  display: none;
}
.collection-toolbar-more-popover .clear-filters-label-short {
  display: none;
}
.collection-toolbar-more-popover .clear-filters-label-long {
  display: inline;
}
.collection-toolbar-settings-popover .collection-column-settings-panel {
  margin: 0;
  min-width: 0;
  overflow: visible;
  width: 100%;
}
.collection-toolbar-settings-popover .collection-column-settings-dropdown > .ms-trigger {
  display: none;
}
.collection-toolbar-settings-popover .collection-column-settings-dropdown > .ms-popover {
  opacity: 1;
  scale: 1;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: block;
  left: auto;
  margin: 0;
  max-height: 330px;
  overflow-y: auto;
  position: static;
  right: auto;
}
.collection-toolbar-settings-popover .collection-column-settings-dropdown .ms-option {
  align-items: center;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  font-size: 13px;
  line-height: 1.35;
  border-radius: var(--radius-sharp);
  padding: 5px 4px;
}
.collection-toolbar-settings-popover .collection-column-settings-dropdown .ms-popover {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 10px;
}
#filterMinPrice,
#filterMaxPrice {
  appearance: textfield;
  -moz-appearance: textfield;
  font-variant-numeric: tabular-nums;
}
#filterMinPrice::-webkit-inner-spin-button,
#filterMinPrice::-webkit-outer-spin-button,
#filterMaxPrice::-webkit-inner-spin-button,
#filterMaxPrice::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.collection-controls-toolbar
  > .sidebar-view-settings.is-visual-mode
  .collection-toolbar-settings-popover
  .collection-visual-settings {
  align-items: stretch;
  flex-direction: column;
  gap: 0;
  width: 100%;
}
.collection-toolbar-settings-popover .collection-price-style-control {
  padding: 0;
}
/* A separate row between the collection toolbar and the table or gallery. */
.collection-toolbar-filter-chips {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-line-faint);
}
.collection-toolbar-filter-chips.hidden,
body:not(.view-list) .app-center > .collection-toolbar-filter-chips {
  display: none;
}
.collection-toolbar-filter-chips .filter-chip {
  font-size: var(--font-size-sm);
  min-height: 26px;
}
.filter-chip-wrap {
  position: relative;
}
.filter-chip.ui-chip .ui-chip-label {
  cursor: pointer;
}
.filter-chip.ui-chip .ui-chip-label:focus-visible {
  border-radius: var(--radius-sharp);
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.filter-chip-editor {
  display: grid;
  gap: 8px;
  left: 0;
  min-width: 220px;
  padding: 10px;
  right: auto;
}
.filter-chip-editor-options {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.filter-chip-editor-option {
  align-items: center;
  display: flex;
  gap: 6px;
  font-size: var(--font-size-sm);
}
.filter-chip-editor-input {
  min-height: var(--control-height, 36px);
  width: 100%;
}
.filter-chip-editor-actions {
  display: flex;
  justify-content: flex-end;
}
.filter-chip-editor-apply {
  min-height: 30px;
  padding-inline: 12px;
}

@media (max-width: 1100px) and (min-width: 901px) {
  .collection-controls-toolbar {
    grid-template-columns: minmax(0, 1fr) max-content;
  }
  .collection-toolbar-filter-chips {
    grid-row: 2;
  }
  .collection-toolbar-search {
    grid-column: 1;
    grid-row: 1;
  }
  .collection-controls-toolbar > .collection-toolbar-view {
    grid-column: 2;
    grid-row: 1;
  }
  .collection-toolbar-primary-filter {
    width: auto;
  }
  .collection-toolbar-filter--set {
    flex: 1 1 122px;
    min-width: 118px;
  }
  .collection-toolbar-filter--tags {
    flex: 1 1 164px;
    min-width: 148px;
  }
  .collection-toolbar-filter--format {
    flex: 1 1 190px;
    min-width: 176px;
  }
  .collection-toolbar-more-control {
    flex: 0 0 auto;
  }
  .collection-toolbar-more-popover {
    left: 12px;
    right: auto;
  }
}

/* Match Vellum's popover motion without changing layout or anchored transforms. */
:is(
  .ms-popover,
  .search-help-popover,
  .settings-popover,
  .sync-menu,
  .autocomplete-list,
  .deck-meta-ac-list,
  .container-icon-picker,
  .collection-toolbar-popover
) {
  opacity: 1;
  scale: 1;
  transform-origin: var(--vui-popover-origin-x) var(--vui-popover-origin-y);
  transition:
    opacity var(--vui-motion-enter) var(--vui-ease-out),
    scale var(--vui-motion-enter) var(--vui-ease-out),
    display var(--vui-motion-enter) allow-discrete;
}
:is(
  .ms-popover,
  .search-help-popover,
  .settings-popover,
  .sync-menu,
  .autocomplete-list,
  .deck-meta-ac-list,
  .container-icon-picker,
  .collection-toolbar-popover
)[hidden],
:is(
  .ms-popover,
  .search-help-popover,
  .settings-popover,
  .sync-menu,
  .collection-toolbar-popover
)[data-vui-state='closed'],
.search-help-popover:not(.visible),
.autocomplete-list:not(.active),
.deck-meta-ac-list:not(.active),
.multiselect:not(.collection-column-settings-dropdown) > .ms-popover:not(.open) {
  opacity: 0;
  scale: 0.97;
  transition-duration: var(--vui-motion-exit);
}
@starting-style {
  :is(
    .ms-popover,
    .search-help-popover,
    .settings-popover,
    .sync-menu,
    .autocomplete-list,
    .deck-meta-ac-list,
    .container-icon-picker,
    .collection-toolbar-popover
  ) {
    opacity: 0;
    scale: 0.97;
  }
}
.collection-toolbar-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.collection-view-settings-section[aria-label='sort'] label,
#collectionSettingsSort {
  text-transform: none;
}
.autocomplete-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  color: var(--color-text-muted);
  cursor: default;
}
.history-drawer-layer {
  z-index: 1101;
}
.mobile-filter-layer {
  z-index: 170;
}
.mobile-filter-sheet-footer,
.mobile-utility-menu-head {
  display: none;
}
.confirm-modal-body .field-label {
  display: grid;
  gap: 8px;
}
@media (max-width: 900px) {
  .mobile-filter-sheet-footer {
    display: flex;
    margin-top: auto;
    /* M-35: last thing in the sheet, sitting at the physical bottom edge. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-utility-menu-head {
    display: flex;
  }
  body .app-right-layer .app-right.ui-drawer {
    display: flex;
    transition: transform var(--vui-motion-drawer) var(--vui-ease-drawer);
  }
  .app-right-layer:not(.open) .app-right.ui-drawer {
    transform: translateX(100%);
  }
  .app-right-layer.open .app-right.ui-drawer {
    transform: translateX(0);
  }
  .mobile-filter-layer #appLeft.ui-drawer {
    display: flex;
    flex-direction: column;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-snap: 0s;
    --motion-fast: 0s;
    --motion-base: 0s;
    --motion-slow: 0s;
  }
  :is(
    .ms-popover,
    .search-help-popover,
    .settings-popover,
    .sync-menu,
    .autocomplete-list,
    .deck-meta-ac-list,
    .container-icon-picker,
    .collection-toolbar-popover,
    .drawer-backdrop
  ),
  body .app-right-layer .app-right.ui-drawer {
    transition: none;
    scale: 1;
  }
}

