/* ── Fonts (self-hosted, slot-based) ──────────────────────────────────────
   Fonts are served from /static/fonts/ (NOT Google Fonts — the CSP blocks
   fonts.googleapis.com / fonts.gstatic.com).

   The @font-face families are named by ROLE (bo-display / bo-body / bo-mono),
   not by typeface. The FILENAME is the swappable slot: to reskin a font sitewide,
   just drop a different .woff2 in with the same name — no CSS edit needed.
     display.woff2  → headings, logo, titles   (default: Archivo Black)
     body.woff2     → body text, buttons        (default: Archivo)
     mono.woff2     → numbers, IDs, code        (default: JetBrains Mono)
   Missing file → the system fallback in --font-* is used, so nothing breaks. */
@font-face {
  font-family: "bo-display";
  src: url("/static/fonts/display.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "bo-body";
  src: url("/static/fonts/body.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "bo-mono";
  src: url("/static/fonts/mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}
/* Optional extra slots for per-theme fonts. Create the file + a theme that sets
   e.g. --font-body: "bo-body-alt", ...  (leave unused ones out; a missing file
   just falls through to the fallback stack).
@font-face { font-family: "bo-display-alt"; src: url("/static/fonts/display-alt.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "bo-body-alt";    src: url("/static/fonts/body-alt.woff2")    format("woff2"); font-display: swap; }
*/

/* ── BrickOSINT — Main Stylesheet ─────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg: #0b0d13;
  --bg-card: #181b25;
  --bg-sidebar: #10121a;
  --bg-hover: #232839;
  --bg-input: #0d0f17;
  --bg-deep: #05060a;

  /* Text */
  --text: #f2f3f7;
  --text-muted: #8388a0;
  --text-dim: #5a5e73;

  /* LEGO primaries */
  --lego-yellow: #f8b708;
  --lego-yellow-hi: #ffcf3e;
  --lego-yellow-lo: #8a5f00;
  --lego-red: #d01012;
  --lego-red-hi: #ed3336;
  --lego-red-lo: #7e0608;
  --lego-blue: #0057a6;
  --lego-blue-hi: #1e82d4;
  --lego-blue-lo: #003c73;
  --lego-green: #00a03a;
  --lego-green-hi: #1bc557;
  --lego-green-lo: #005e22;
  --lego-orange: #f57c20;
  --lego-orange-lo: #98410a;
  --lego-black: #0a0b0f;
  --lego-white: #ffffff;

  /* Semantic tokens mapped to LEGO palette */
  --accent: var(--lego-yellow);
  --accent-hover: var(--lego-yellow-hi);
  --accent-shadow: var(--lego-yellow-lo);
  --green: var(--lego-green-hi);
  --green-shadow: var(--lego-green-lo);
  --red: var(--lego-red-hi);
  --red-shadow: var(--lego-red-lo);
  --orange: var(--lego-orange);
  --orange-shadow: var(--lego-orange-lo);
  --blue: var(--lego-blue-hi);
  --blue-shadow: var(--lego-blue-lo);
  --muted: var(--text-muted);

  /* Card surface alias (used by public pages) */
  --surface: var(--bg-card);
  /* Accent-derived translucents — themeable focus ring + faint accent wash.
     Override these per-theme alongside --accent so glows/tints follow suit. */
  --accent-ring: rgba(248, 183, 8, 0.18);
  --accent-tint: rgba(248, 183, 8, 0.07);

  --border: #2b2f42;
  --border-strong: #434a68;

  /* Geometry */
  --radius: 4px;
  --radius-lg: 8px;
  --radius-pill: 999px;
  --sidebar-w: 260px;

  /* Hard-offset "brick" shadows (no blur) */
  --brick-sm: 0 2px 0 rgba(0, 0, 0, 0.55);
  --brick-md: 0 4px 0 rgba(0, 0, 0, 0.6);
  --brick-lg: 0 6px 0 rgba(0, 0, 0, 0.6);
  --brick-yellow: 0 4px 0 var(--accent-shadow);
  --brick-red: 0 4px 0 var(--red-shadow);
  --brick-green: 0 4px 0 var(--green-shadow);
  --brick-blue: 0 4px 0 var(--blue-shadow);
  --brick-orange: 0 4px 0 var(--orange-shadow);
  --overlay-shadow:
    0 18px 0 rgba(0, 0, 0, 0.35), 0 24px 60px rgba(0, 0, 0, 0.6);

  /* Typography — first name is the swappable role slot (see @font-face above);
     the rest are graceful fallbacks if the woff2 file isn't present. */
  --font-display:
    "bo-display", "Archivo Black", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:
    "bo-body", "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono:
    "bo-mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, "Courier New",
    monospace;

  /* Stud pattern */
  --stud-pattern: radial-gradient(
    circle at 4px 4px,
    rgba(255, 255, 255, 0.11) 0 2px,
    transparent 2.5px
  );
  --stud-size: 10px 10px;

  /* Snappy timings */
  --t-fast: 90ms;
  --t-base: 130ms;
  --t-slow: 220ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Themes ────────────────────────────────────────────────────────────────
   :root above is the default "lego" theme. Each block below overrides only the
   palette/font tokens; anything it doesn't set inherits from :root. Switch by
   setting  <html data-theme="midnight">  (handled by the dashboard control +
   the no-FOUC script in the base templates). Add a new theme by copying a
   block, renaming it, and adding it to THEMES in index.html. */

[data-theme="midnight"] {
  --bg: #0a0e1a;
  --bg-card: #141b2e;
  --bg-sidebar: #0d1322;
  --bg-hover: #1e2740;
  --bg-input: #0b1020;
  --bg-deep: #05070f;

  --text: #eef1f8;
  --text-muted: #8a93b2;
  --text-dim: #565f7e;

  --accent: #4c8bf5;
  --accent-hover: #6fa4ff;
  --accent-shadow: #1b3f7a;
  --accent-ring: rgba(76, 139, 245, 0.2);
  --accent-tint: rgba(76, 139, 245, 0.08);

  --border: #232c44;
  --border-strong: #3a466a;
  --surface: var(--bg-card);
}

[data-theme="terminal"] {
  --bg: #0a0f0a;
  --bg-card: #0f1710;
  --bg-sidebar: #0b120b;
  --bg-hover: #16241a;
  --bg-input: #08110a;
  --bg-deep: #050805;

  --text: #d7f5db;
  --text-muted: #6f9a76;
  --text-dim: #47624c;

  --accent: #22c55e;
  --accent-hover: #4ade80;
  --accent-shadow: #12602f;
  --accent-ring: rgba(34, 197, 94, 0.22);
  --accent-tint: rgba(34, 197, 94, 0.09);

  --border: #1c3322;
  --border-strong: #2f5238;
  --surface: var(--bg-card);

  /* Sharper corners + monospace display for a terminal feel */
  --radius: 2px;
  --radius-lg: 3px;
  --font-display: "bo-mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-body: "bo-mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Chunky scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

body {
  font-family: var(--font-body);
  font-weight: 500;
  font-feature-settings: "ss01", "cv11";
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5 {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover {
  color: var(--accent-hover);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 2px solid var(--border);
  padding: 24px 0 60px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--t-slow) var(--ease);
}

/* ── Sidebar collapse toggle ─────────────────────────────────────────────── */

/* A small handle centered on the sidebar's right edge. Clicking it slides the
   sidebar off-screen and lets .content expand to full width. */
.sidebar-toggle {
  position: fixed;
  top: 50%;
  left: var(--sidebar-w);
  transform: translateY(-50%);
  z-index: 101;
  width: 22px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--bg-sidebar);
  border: 2px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    left var(--t-slow) var(--ease),
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Chevron drawn from two borders — points left (‹) to collapse. */
.sidebar-toggle-arrow {
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 3px;
  transition: transform var(--t-base) var(--ease);
}

html.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}
html.sidebar-collapsed .content {
  margin-left: 0;
  max-width: none;
}
html.sidebar-collapsed .sidebar-toggle {
  left: 0;
}
/* Flip the chevron to point right (›) to expand. */
html.sidebar-collapsed .sidebar-toggle-arrow {
  transform: rotate(-135deg);
  margin-left: -3px;
}

.sidebar-header {
  position: relative;
  padding: 22px 20px 18px;
  background:
    var(--stud-pattern), linear-gradient(180deg, #14172100 0, #0a0c12 100%);
  background-size: var(--stud-size), cover;
  border-bottom: 2px solid var(--border);
}
.sidebar-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 2px 0 var(--accent-shadow);
}

.logo {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  color: var(--lego-black);
  background: var(--accent);
  padding: 4px 12px 5px;
  border-radius: 3px;
  box-shadow: var(--brick-yellow);
  text-transform: uppercase;
}
.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
}
.nav-links li a {
  display: block;
  padding: 10px 20px;
  padding-left: 24px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.02em;
  transition:
    color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    padding-left var(--t-fast) var(--ease);
}
.nav-links li a:hover,
.nav-links li a.active {
  color: var(--text);
  background: var(--bg-hover);
  padding-left: 28px;
}
.nav-links li a.active {
  color: var(--accent);
  box-shadow: inset 5px 0 0 var(--accent);
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  border-top: 2px solid var(--border);
  background: var(--bg-sidebar);
}
.sidebar-public-link {
  display: block;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  text-align: center;
  box-shadow: var(--brick-sm);
  transition:
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.sidebar-public-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.sidebar-public-link:active {
  transform: translateY(2px);
  box-shadow: none;
}

.filter-section {
}
.filter-section h3 {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.filter-group {
  margin-bottom: 12px;
}
.filter-group label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
/* Native <select> is kept in the DOM (for form submission) but visually hidden */
.filter-group select,
.cs-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ── Year range slider (dual-handle) ──────────────────────────────────── */
.filter-group.year-range {
  margin-bottom: 18px;
}
.year-range-values {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.year-range-values input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--bg-input, var(--bg-card, #1c1c1c));
  color: var(--text, #e6e6e6);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  -moz-appearance: textfield;
}
.year-range-values input[type="number"]::-webkit-outer-spin-button,
.year-range-values input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.year-range-sep {
  color: var(--text-muted, #888);
  font-size: 0.85rem;
}
/* Min–max number-input pairs (piece count, minifig count browse filters). */
.range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.range-inputs input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--bg-input, var(--bg-card, #1c1c1c));
  color: var(--text, #e6e6e6);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
}
.range-sep {
  color: var(--text-muted, #888);
  font-size: 0.85rem;
}
/* Visual break separating the Sort-by control from the filter inputs/buttons. */
.filter-divider {
  border-top: 1px solid var(--border, #333);
  margin: 16px 0 4px;
}
.year-range-slider {
  position: relative;
  height: 24px;
  margin: 0 6px;
}
.year-range-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  margin-top: -2px;
  background: var(--border, #333);
  border-radius: 2px;
}
.year-range-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: var(--accent, #ffb800);
  border-radius: 2px;
  pointer-events: none;
}
.year-range-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.year-range-handle::-webkit-slider-runnable-track {
  background: transparent;
  height: 24px;
  border: 0;
}
.year-range-handle::-moz-range-track {
  background: transparent;
  height: 24px;
  border: 0;
}
.year-range-handle::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent, #ffb800);
  border: 2px solid var(--bg-card, #1c1c1c);
  cursor: grab;
  pointer-events: auto;
  margin-top: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.year-range-handle::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent, #ffb800);
  border: 2px solid var(--bg-card, #1c1c1c);
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.year-range-handle:active::-webkit-slider-thumb {
  cursor: grabbing;
}
.year-range-handle:active::-moz-range-thumb {
  cursor: grabbing;
}

/* ── Custom searchable select widget ──────────────────────────────────── */

.cs-wrapper {
  position: relative;
}
.cs-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  gap: 6px;
}
.cs-btn:hover,
.cs-btn:focus {
  border-color: var(--accent);
  outline: none;
}
.cs-btn-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-btn.cs-placeholder .cs-btn-text {
  color: var(--text-muted);
}
.cs-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform var(--t-fast) var(--ease);
  line-height: 1;
}
.cs-btn.cs-open .cs-arrow {
  transform: rotate(180deg);
}
.cs-panel {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  z-index: 500;
  box-shadow: var(--overlay-shadow);
}
.cs-search {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.83rem;
  outline: none;
  box-sizing: border-box;
}
.cs-search::placeholder {
  color: var(--text-muted);
}
.cs-list {
  max-height: 210px;
  overflow-y: auto;
}
.cs-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-item:hover {
  background: var(--bg-hover);
}
.cs-item.cs-selected {
  color: var(--accent);
  background: var(--bg-hover);
}
.cs-item.cs-item-placeholder {
  color: var(--text-muted);
  font-style: italic;
}
.cs-no-results {
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Content ─────────────────────────────────────────────────────────────── */

.content {
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  flex: 1;
  max-width: 1400px;
  transition: margin-left var(--t-slow) var(--ease);
}

.page-header {
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 1.6rem;
  font-weight: 900;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-simple-search {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.85rem;
  padding: 8px 14px;
}

.back-link {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: 8px;
}
.back-link:hover {
  color: var(--accent);
}

.set-num-lg {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Stats cards ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px 22px;
  text-align: center;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--brick-md);
  border-color: var(--border-strong);
}
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
}
.stat-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.stat-completed .stat-value {
  color: var(--green);
}
.stat-completed::before {
  background: var(--green);
}
.stat-pending .stat-value {
  color: var(--orange);
}
.stat-pending::before {
  background: var(--orange);
}
.stat-failed .stat-value {
  color: var(--red);
}
.stat-failed::before {
  background: var(--red);
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */

.progress-section {
  margin-bottom: 32px;
}
.progress-section h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}
.progress-bar {
  height: 14px;
  background: var(--bg-deep);
  border-radius: 3px;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4);
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  background-image:
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 14px,
      rgba(0, 0, 0, 0.18) 15px,
      rgba(0, 0, 0, 0.18) 16px,
      transparent 16px
    ),
    linear-gradient(
      180deg,
      var(--accent-hover) 0,
      var(--accent) 50%,
      var(--accent-shadow) 100%
    );
  background-size:
    16px 100%,
    100% 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  transition: width 0.5s;
}
.progress-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: inline-block;
}

/* ── Section ──────────────────────────────────────────────────────────────── */

.section {
  margin-bottom: 32px;
}
.section h3 {
  font-size: 1rem;
  margin-bottom: 14px;
}
.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.badge {
  display: inline-block;
  background: var(--lego-black);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1.5px solid var(--accent);
  margin-left: 8px;
}

/* ── Theme grid ───────────────────────────────────────────────────────────── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.theme-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.theme-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.theme-card:active {
  transform: translateY(2px);
  box-shadow: none;
}
.theme-name {
  font-size: 0.85rem;
  color: var(--text);
}
.theme-count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Year chart ───────────────────────────────────────────────────────────── */

.year-chart-outer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-nav-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--brick-sm);
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
  user-select: none;
  padding: 0;
}
.year-nav-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.year-nav-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
}
.year-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.year-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 360px;
  /* Bottom padding leaves room for the set-count labels that now sit below
     the baseline; the year labels live above each bar inside the chart. */
  padding: 0 4px 30px;
  overflow-x: hidden;
  scroll-behavior: smooth;
  flex: 1;
  min-width: 0;
}

.year-bar-link {
  display: flex;
  flex-direction: column;
  /* Pin the year label + bar to the bottom so every bar stems from a shared
     baseline and grows upward; the year label rides above the bar's top. */
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
  min-width: 48px;
  height: 100%;
}
.year-bar {
  width: 100%;
  background: var(--accent);
  background-image: linear-gradient(
    180deg,
    var(--accent-hover) 0,
    var(--accent) 40%,
    var(--accent-shadow) 100%
  );
  border-radius: 2px 2px 0 0;
  height: var(--bar-height);
  min-height: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset -2px 0 0 rgba(0, 0, 0, 0.2);
  transition:
    filter var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
  position: relative;
}
.year-bar:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}
.year-bar-link:nth-child(10n + 3) .year-bar {
  background-image: linear-gradient(
    180deg,
    var(--lego-red-hi),
    var(--lego-red) 50%,
    var(--lego-red-lo)
  );
}
.year-bar-link:nth-child(10n + 7) .year-bar {
  background-image: linear-gradient(
    180deg,
    var(--lego-blue-hi),
    var(--lego-blue) 50%,
    var(--lego-blue-lo)
  );
}
.year-bar-count {
  display: block;
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}
.year-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  writing-mode: vertical-rl;
  font-weight: 500;
}

/* ── Set grid (browse page) ───────────────────────────────────────────────── */

.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.set-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
  display: flex;
  flex-direction: column;
}
.set-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--brick-yellow);
}
.set-card:hover .set-card-img img {
  transform: scale(1.05);
}
.set-card-img {
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid var(--border);
}
.set-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--t-slow) var(--ease);
}
.no-image {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.set-card-info {
  padding: 12px 14px;
}
.set-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}
.set-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 2px;
  color: var(--text);
}
.set-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 32px;
}
.pagination-inline {
  margin-top: 6px;
  justify-content: flex-start;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
  text-decoration: none;
  user-select: none;
}
a.page-btn:hover,
button.page-btn:not(.active):not(.disabled):hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
a.page-btn:active,
button.page-btn:not(.active):not(.disabled):active {
  transform: translateY(2px);
  box-shadow: none;
}
.page-btn.active {
  background: var(--accent);
  color: var(--lego-black);
  border-color: var(--accent);
  font-weight: 700;
  cursor: default;
  box-shadow: var(--brick-yellow);
}
.page-btn.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  border-color: var(--border);
  box-shadow: none;
}
.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 34px;
  font-size: 0.82rem;
  color: var(--text-muted);
  user-select: none;
}
.page-info {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.btn {
  display: inline-block;
  padding: 8px 18px;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.btn:active {
  transform: translateY(2px);
  box-shadow: none;
}
.btn-secondary {
  font-size: 0.8rem;
  margin-top: 8px;
}

/* ── Detail page ──────────────────────────────────────────────────────────── */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

/* Hero + color picker strip side-by-side */
.detail-hero-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.detail-hero-wrap .detail-hero {
  flex: 1 1 auto;
  min-width: 0;
}

/* Color picker strip — two-column swatch grid to the right of the part image */
.color-picker-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 84px;
  flex-shrink: 0;
}
.color-picker-swatches {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 430px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.color-picker-swatches::-webkit-scrollbar {
  width: 4px;
}
.color-picker-swatches::-webkit-scrollbar-track {
  background: transparent;
}
.color-picker-swatches::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
.color-swatch-btn {
  width: 100%;
  height: 32px;
  border-radius: 3px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition:
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
  padding: 0;
  background-clip: padding-box;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.color-swatch-btn:hover {
  border-color: var(--accent);
  transform: scale(1.14);
  z-index: 2;
}
.color-swatch-btn.active {
  transform: scale(1.08);
  box-shadow:
    0 0 0 2px var(--accent),
    inset 0 2px 0 rgba(255, 255, 255, 0.15);
}
.color-swatch-reset {
  background: var(--bg-card) !important;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: var(--border);
  opacity: 1;
  box-shadow: var(--brick-sm);
}
.color-swatch-reset:hover {
  border-color: var(--red);
  color: var(--red);
}

.hero-img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--bg-deep);
  border: 2px solid var(--border);
}
.hero-no-image {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 2px solid var(--border);
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
}
.meta-table th,
.meta-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.meta-table th {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  width: 35%;
}

.subsection {
  margin-top: 20px;
}
.subsection h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

/* ── Set appearances dropdown (minifig detail) ───────────────────────────── */

.set-appearances summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  padding: 8px 0;
  list-style: none;
  user-select: none;
}
.set-appearances summary::before {
  content: "▸ ";
  font-size: 0.8rem;
}
.set-appearances[open] summary::before {
  content: "▾ ";
}
.set-appearances-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.set-appearances-list li {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.set-appearances-list li:last-child {
  border-bottom: none;
}
.set-appearances-list li a {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}
.set-appearances-name {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.set-appearances-year {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ── Color-grouped appearances (part detail) ─────────────────────────────── */

.part-appearances-colors {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.part-color-group {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.part-color-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-card);
  user-select: none;
}
.part-color-group > summary::before {
  content: "▸";
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.part-color-group[open] > summary::before {
  content: "▾";
}
.part-color-group .set-appearances-list {
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.color-inline-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  display: inline-block;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.15),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  background: var(--bg-hover);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1.5px solid var(--border);
}

.status-badge {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1.5px solid currentColor;
}
.status-completed {
  background: rgba(27, 197, 87, 0.12);
  color: var(--green);
}
.status-pending {
  background: rgba(245, 124, 32, 0.12);
  color: var(--orange);
}
.status-in_progress {
  background: rgba(30, 130, 212, 0.12);
  color: var(--blue);
}
.status-failed {
  background: rgba(237, 51, 54, 0.12);
  color: var(--red);
}

/* ── Gallery ──────────────────────────────────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.gallery-item {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  cursor: pointer;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.gallery-item:active {
  transform: translateY(2px);
  box-shadow: none;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

/* Lock page scroll while the lightbox is open (padding-right compensates for
   the removed scrollbar so the layout doesn't shift). */
html.lb-open,
html.lb-open body {
  overflow: hidden;
  touch-action: none;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.lightbox.active {
  display: flex;
}
.lightbox .lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  border: 3px solid var(--accent);
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  cursor: zoom-out;
  will-change: transform;
  -webkit-user-drag: none;
}

/* Floating zoom controls */
.lightbox-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 1001;
}
.lightbox-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--accent);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: var(--radius);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
}
.lightbox-btn:hover {
  background: var(--accent);
}
.lightbox-btn:active {
  transform: scale(0.92);
}

/* Affordance: expandable images show a zoom cursor */
.gallery-item,
.pub-gallery-item,
.hero-img {
  cursor: zoom-in;
}

/* ── Parts table ──────────────────────────────────────────────────────────── */

.parts-summary {
  max-height: 400px;
  overflow-y: auto;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
.parts-table {
  width: 100%;
  border-collapse: collapse;
}
.parts-table thead th {
  background: var(--bg-card);
  position: sticky;
  top: 0;
  font-family: var(--font-display);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 2px solid var(--border-strong);
}
.parts-table th,
.parts-table td {
  padding: 6px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.parts-table td {
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state h2 {
  margin-bottom: 8px;
}
.empty-state p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 2px solid var(--border);
  }
  .content {
    margin-left: 0;
    padding: 20px;
  }
  body {
    flex-direction: column;
  }
  /* Sidebar is a top bar here — collapse/handle don't apply. */
  .sidebar-toggle {
    display: none;
  }
  html.sidebar-collapsed .sidebar {
    transform: none;
  }
  html.sidebar-collapsed .content {
    margin-left: 0;
  }
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: flex;
    padding: 8px 12px;
  }
  .nav-links li a {
    padding: 8px 14px;
  }
  .nav-links li a.active {
    box-shadow: inset 0 -3px 0 var(--accent);
  }
  .filter-section {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
  }
  .filter-group {
    margin-bottom: 0;
  }
}

/* ── Job control panel ───────────────────────────────────────────────────── */

.job-panel {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.job-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.job-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.dot-running {
  background: var(--green);
  box-shadow:
    0 0 8px var(--green),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: blink 1.2s ease-in-out infinite;
}
.dot-ok {
  background: var(--green);
}
.dot-error {
  background: var(--red);
}
.dot-warn {
  background: var(--orange);
}
.dot-unknown {
  background: var(--text-muted);
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.job-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-start {
  border-color: var(--green);
  color: var(--green);
}
.btn-start:hover {
  background: var(--green);
  color: var(--lego-black);
  border-color: var(--green);
  box-shadow: var(--brick-green);
}
.btn-stop {
  border-color: var(--red);
  color: var(--red);
}
.btn-stop:hover {
  background: var(--red);
  color: var(--lego-black);
  border-color: var(--red);
  box-shadow: var(--brick-red);
}
.btn-reset {
  border-color: var(--orange);
  color: var(--orange);
}
.btn-reset:hover {
  background: var(--orange);
  color: var(--lego-black);
  border-color: var(--orange);
  box-shadow: var(--brick-orange);
}

/* ── In-progress stat card ───────────────────────────────────────────────── */

.stat-in-progress .stat-value {
  color: var(--blue);
}
.stat-in-progress::before {
  background: var(--blue);
}

/* ── Pulse dot ───────────────────────────────────────────────────────────── */

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.pulse-active {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(27, 197, 87, 0.7);
  animation: pulse-ring 1.5s ease-out infinite;
}
@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(27, 197, 87, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(27, 197, 87, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(27, 197, 87, 0);
  }
}

/* ── Live feed ───────────────────────────────────────────────────────────── */

.live-feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 4px;
}

.feed-col {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--brick-sm);
}

.feed-title {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feed-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.badge-error {
  background: rgba(237, 51, 54, 0.15);
  color: var(--red);
}

.feed-list {
  overflow-y: auto;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed-empty {
  font-size: 0.82rem;
  padding: 8px 0;
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-left-width: 4px;
  transition: border-color var(--t-fast) var(--ease);
}
.feed-row:hover {
  border-color: var(--border);
}
.row-ok {
  border-left: 4px solid var(--green);
}
.row-err {
  border-left: 4px solid var(--red);
}
.row-active {
  border-left: 4px solid var(--blue);
}

.feed-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.row-ok .feed-badge {
  color: var(--green);
}
.row-err .feed-badge {
  color: var(--red);
}
.row-active .feed-badge {
  color: var(--blue);
}

.feed-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.feed-set-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}
.feed-set-name {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Compact stats strip ─────────────────────────────────────────────────── */

.stats-compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin-bottom: 20px;
}
.stats-compact .stat-value {
  font-size: 1.5rem;
}

/* ── Catalog grid (parts & minifigs browse pages) ────────────────────────── */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.catalog-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
  display: flex;
  flex-direction: column;
}
.catalog-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--brick-yellow);
}
.catalog-card:hover .catalog-card-img img {
  transform: scale(1.05);
}
.catalog-card-img {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid var(--border);
}
.catalog-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--t-slow) var(--ease);
}
.catalog-card-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.catalog-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}
.catalog-name {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.catalog-meta-line {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Filter input ────────────────────────────────────────────────────────── */

.filter-input {
  width: 100%;
  padding: 8px;
  background: var(--bg-input);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
}
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ── Filter checkboxes ───────────────────────────────────────────────────── */

.filter-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}
.filter-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.filter-checkbox span {
  user-select: none;
}
.filter-checkbox.is-disabled,
.filter-checkbox.is-disabled input[type="checkbox"] {
  cursor: not-allowed;
}
.filter-checkbox.is-disabled {
  opacity: 0.45;
}
.filter-checkbox-hint {
  font-style: italic;
  opacity: 0.85;
}

.btn-search {
  width: 100%;
  margin-top: 4px;
  text-align: center;
  background: var(--accent);
  color: var(--lego-black);
  border-color: var(--accent);
  box-shadow: var(--brick-yellow);
}
.btn-search:hover {
  background: var(--accent-hover);
  color: var(--lego-black);
  border-color: var(--accent-hover);
  box-shadow: 0 6px 0 var(--accent-shadow);
}

/* ── Color swatch circles (parts browse / detail pages) ──────────────────── */

.color-circle {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  vertical-align: middle;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.15),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.color-swatches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.color-swatch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
}
.color-swatch-name {
  color: var(--text);
  font-size: 0.78rem;
}

/* ── Color groups on set detail page ─────────────────────────────────────── */

.color-group {
  margin-bottom: 24px;
}
.color-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}
.color-group-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.color-group-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.parts-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.part-visual-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.part-visual-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.part-visual-img {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.part-visual-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.part-visual-info {
  padding: 5px 6px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.part-visual-num {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.part-visual-qty {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Minifig grid on set detail page ─────────────────────────────────────── */

.minifig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.minifig-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
  display: flex;
  flex-direction: column;
}
.minifig-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--brick-yellow);
}
.minifig-card-img {
  aspect-ratio: 3/4;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 2px solid var(--border);
}
.minifig-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.minifig-card-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.qty-badge {
  position: absolute;
  top: -14px;
  right: 8px;
  background: var(--accent);
  color: var(--lego-black);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 3px;
  box-shadow: var(--brick-yellow);
}

/* ── Minifig hero image (taller aspect ratio) ────────────────────────────── */

.minifig-hero-img {
  max-height: 400px;
  object-position: center top;
}

/* ── Public landing page ─────────────────────────────────────────────────── */

.public-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 24px 48px;
  text-align: center;
}
.public-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--stud-pattern);
  background-size: 28px 28px;
  opacity: 0.07;
  pointer-events: none;
}
.public-title {
  position: relative;
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 12px;
}
.public-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 6px;
  background: var(--accent);
  margin: 10px auto 0;
}
.public-title--plain::after {
  display: none;
}
.public-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 36px;
  max-width: 460px;
  line-height: 1.6;
}

/* ── Legal page ──────────────────────────────────────────────────────────── */
.legal-page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 56px;
  box-sizing: border-box;
}
.legal-page h1 {
  font-size: 2rem;
  color: var(--text);
  margin: 0 0 12px;
}
.legal-page h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin: 32px 0 8px;
}
.legal-page p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 12px;
}
.legal-page .legal-lede {
  font-size: 1.05rem;
  color: var(--text);
}
.legal-page .legal-foot {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-dim);
}
.legal-page h3 {
  font-size: 0.95rem;
  color: var(--text);
  margin: 20px 0 6px;
}
.legal-page ul {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}
.legal-page li {
  margin-bottom: 4px;
}
.legal-page strong {
  color: var(--text);
}
.legal-page .legal-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ── Landing page nav cards ──────────────────────────────────────────────── */
.pub-nav-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}
.pub-nav-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 48px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  min-width: 210px;
  box-shadow: var(--brick-md);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.pub-nav-card:hover {
  border-color: var(--accent);
  box-shadow: var(--brick-yellow);
  transform: translateY(-4px);
}
.pub-nav-card:active {
  transform: translateY(2px);
  box-shadow: none;
}
.pub-nav-card-icon {
  font-size: 2.8rem;
  line-height: 1;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.4));
}
.pub-nav-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pub-nav-card-desc {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  max-width: 180px;
  line-height: 1.5;
}

/* ── Public browse layout ────────────────────────────────────────────────── */
/* Title and toolbar span the top; the filter sidebar sits left of the
   results. .filters-hidden drops the sidebar column and data-view="list"
   turns the results into rows. browse-ui.js toggles both, they're remembered
   per browser, and _browse_toolbar.html applies them before first paint. */
.pub-browse-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-areas:
    "head head"
    "bar bar"
    "side main";
  gap: 0 24px;
  padding: 24px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}
.pub-browse-layout.filters-hidden {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "bar"
    "main";
}
.browse-head {
  grid-area: head;
  margin-bottom: 14px;
}
.pub-browse-sidebar {
  grid-area: side;
  min-width: 0;
}
.filters-hidden .pub-browse-sidebar {
  display: none;
}
.pub-browse-main {
  grid-area: main;
  min-width: 0;
  container-type: inline-size;
}
@media (max-width: 768px) {
  .pub-browse-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "bar"
      "side"
      "main";
  }
  .pub-browse-sidebar {
    margin-bottom: 18px;
  }
}

/* Sidebar stays a stacked column at every width (the ≤900px admin rule turns
   .filter-section into a row and zeroes .filter-group margins). */
.pub-browse-sidebar .filter-section {
  display: block;
}
.pub-browse-sidebar .filter-group {
  margin-bottom: 12px;
}
.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.pub-browse-sidebar .filter-head h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0;
}
.browse-reset {
  padding: 4px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
}
.browse-reset.is-idle {
  opacity: 0.5;
  pointer-events: none;
}
/* Year From/To: two custom selects sharing the row. */
.year-selects .cs-wrapper {
  flex: 1;
  min-width: 0;
}

/* ── Browse toolbar: filter toggle · count · sort · view ─────────────────── */
.browse-toolbar {
  grid-area: bar;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 10px 0;
  margin-bottom: 20px;
  border-top: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
}
.browse-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.browse-filter-toggle:hover,
.browse-filter-toggle:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.browse-filter-toggle .label-show,
.filters-hidden .browse-filter-toggle .label-hide {
  display: none;
}
.filters-hidden .browse-filter-toggle .label-show {
  display: inline;
}
.browse-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--lego-black);
  font-size: 0.72rem;
  font-weight: 800;
}
.browse-count {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}
/* Active-filter chips: each × link is the current URL minus that filter. */
.browse-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.browse-chip {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  padding: 3px 10px;
  background: var(--accent);
  color: var(--lego-black);
  border: 2px solid var(--accent-shadow);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    padding var(--t-fast) var(--ease);
}
.browse-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The × stays collapsed (zero width, keeps the chip's height) until hover /
   keyboard focus, then slides open as the chip turns red. */
.browse-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 0;
  height: 18px;
  margin-left: 0;
  overflow: hidden;
  opacity: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  color: var(--lego-black);
  font-size: 0.9rem;
  line-height: 1;
  transition:
    width var(--t-fast) var(--ease),
    margin-left var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease);
}
/* Hover / keyboard focus previews the delete: the chip turns red. */
.browse-chip:hover,
.browse-chip:focus-visible {
  padding-right: 5px;
  background: var(--red);
  border-color: var(--red-shadow);
  color: var(--lego-white);
  outline: none;
}
.browse-chip:hover .browse-chip-x,
.browse-chip:focus-visible .browse-chip-x {
  width: 18px;
  margin-left: 6px;
  opacity: 1;
  background: rgba(0, 0, 0, 0.25);
  color: var(--lego-white);
}
/* Touch screens have no hover, so the × would never show — keep it visible. */
@media (hover: none) {
  .browse-chip {
    padding-right: 5px;
  }
  .browse-chip-x {
    width: 18px;
    margin-left: 6px;
    opacity: 1;
  }
}
.browse-chip-clear {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: underline;
}
.browse-chip-clear:hover {
  color: var(--text);
}
.browse-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.browse-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}
.browse-sort label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
/* app.js swaps the native select for its custom widget; hide the native one
   up front (as .filter-group does) so it never flashes before JS runs. */
.browse-sort select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.browse-sort .cs-wrapper {
  width: 230px;
}
.browse-view-toggle {
  display: inline-flex;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.browse-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 34px;
  padding: 0;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 0;
  font-size: 1rem;
  cursor: pointer;
}
.browse-view-btn + .browse-view-btn {
  border-left: 2px solid var(--border);
}
.browse-view-btn:hover,
.browse-view-btn:focus-visible {
  color: var(--text);
  outline: none;
}
.pub-browse-layout:not([data-view="list"]) .browse-view-btn[data-view="grid"],
.pub-browse-layout[data-view="list"] .browse-view-btn[data-view="list"] {
  background: var(--accent);
  color: var(--lego-black);
}
@media (max-width: 480px) {
  .browse-toolbar-right {
    width: 100%;
    margin-left: 0;
  }
  .browse-sort {
    flex: 1;
    min-width: 0;
  }
  .browse-sort .cs-wrapper {
    flex: 1;
    width: auto;
    min-width: 0;
  }
}

/* ── Browse list view ────────────────────────────────────────────────────── */
/* Same card markup as the grid, laid out as rows: thumbnail · number · name ·
   theme/category · meta. .list-only bits appear only here. */
.list-only {
  display: none;
}
.set-theme {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-browse-layout[data-view="list"] .list-only {
  display: revert;
}
.pub-browse-layout[data-view="list"] .set-grid,
.pub-browse-layout[data-view="list"] .catalog-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.pub-browse-layout[data-view="list"] .set-card,
.pub-browse-layout[data-view="list"] .catalog-card {
  flex-direction: row;
  align-items: center;
  box-shadow: none;
}
.pub-browse-layout[data-view="list"] .set-card:hover,
.pub-browse-layout[data-view="list"] .catalog-card:hover {
  transform: none;
  box-shadow: var(--brick-sm);
}
.pub-browse-layout[data-view="list"] .set-card:hover .set-card-img img,
.pub-browse-layout[data-view="list"] .catalog-card:hover .catalog-card-img img {
  transform: none;
}
.pub-browse-layout[data-view="list"] .set-card-img,
.pub-browse-layout[data-view="list"] .catalog-card-img {
  flex: 0 0 96px;
  width: 96px;
  border-bottom: 0;
  border-right: 2px solid var(--border);
}
.pub-browse-layout[data-view="list"] .catalog-card-img {
  flex-basis: 72px;
  width: 72px;
}
.pub-browse-layout[data-view="list"] .set-card-info,
.pub-browse-layout[data-view="list"] .catalog-card-info {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(0, 200px) 180px;
  align-items: center;
  gap: 4px 16px;
  padding: 10px 16px;
}
.pub-browse-layout[data-view="list"] .set-num,
.pub-browse-layout[data-view="list"] .catalog-num {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-browse-layout[data-view="list"] .set-name,
.pub-browse-layout[data-view="list"] .catalog-name {
  grid-column: 2;
  grid-row: 1;
  margin-top: 0;
  font-size: 0.9rem;
}
.pub-browse-layout[data-view="list"] .set-theme,
.pub-browse-layout[data-view="list"] .catalog-meta-line {
  grid-column: 3;
  grid-row: 1;
  font-size: 0.78rem;
}
/* Meta values sit in fixed-width, right-aligned slots so the columns line up
   row to row even when a value is missing (templates always render every slot,
   empty when there's no value). Card view hides the empty ones. */
.pub-browse-layout .set-meta > span:empty {
  display: none;
}
.pub-browse-layout[data-view="list"] .set-meta {
  grid-column: 4;
  grid-row: 1;
  margin-top: 0;
  display: grid;
  grid-template-columns: 4ch 9ch 8ch; /* sets: year · pcs · figs */
  justify-content: end;
  justify-items: end;
  column-gap: 12px;
  white-space: nowrap;
}
.pub-browse-layout[data-view="list"] .catalog-grid .set-meta {
  grid-template-columns: 10ch 9ch; /* minifigs: years · parts | parts: sets · figs */
}
.pub-browse-layout[data-view="list"] .set-meta > span:empty {
  display: block;
}
/* Narrow results column (phones, or filters open on a small laptop): stack the
   text beside the thumbnail instead of columns. */
@container (max-width: 720px) {
  .pub-browse-layout[data-view="list"] .set-card-info,
  .pub-browse-layout[data-view="list"] .catalog-card-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .pub-browse-layout[data-view="list"] .set-meta {
    display: flex;
    margin-top: 4px;
    justify-content: flex-start;
  }
  .pub-browse-layout[data-view="list"] .set-meta > span:empty {
    display: none;
  }
  .pub-browse-layout[data-view="list"] .set-name,
  .pub-browse-layout[data-view="list"] .catalog-name {
    font-size: 0.85rem;
  }
}

/* ── Public catalog search theme row ─────────────────────────────────────── */
.pub-theme-row {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.pub-theme-select {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  min-width: 220px;
  max-width: 400px;
  width: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238388a0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.pub-theme-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ── Public search box ───────────────────────────────────────────────────── */

/* ── Brick loader (shown while search index primes on first load) ─────────── */

.pub-search-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 760px;
}
.brick-loader {
  background: var(--accent);
  border-radius: 4px;
  padding: 10px 12px 13px;
  box-shadow:
    var(--brick-yellow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.brick-row {
  display: flex;
  gap: 5px;
}
.brick-stud {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  box-shadow:
    0 2px 0 var(--accent-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: studPulse 1.6s ease-in-out infinite;
  animation-delay: calc(var(--d, 0) * 0.14s);
}
@keyframes studPulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}
.pub-loader-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}
.pub-search-loader.loader-exit {
  animation: loaderFadeOut 0.25s ease forwards;
}
.pub-search-wrap.search-enter {
  animation: searchFadeIn 0.3s ease forwards;
}
@keyframes loaderFadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@keyframes searchFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pub-search-wrap {
  position: relative;
  width: 100%;
  max-width: 760px;
}
.pub-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 18px;
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.pub-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.pub-search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* ── Admin loading overlay (full-page, shown while indexes prime) ─────── */
.admin-loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.25s ease;
}
.admin-loading-overlay.loader-exit {
  opacity: 0;
  pointer-events: none;
}

/* ── Autocomplete dropdown ───────────────────────────────────────────────── */

.pub-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--overlay-shadow);
  z-index: 200;
  overflow: hidden;
  max-height: 520px;
  overflow-y: auto;
}
.pub-search-dropdown.open {
  display: block;
}
.pub-search-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  transition: background var(--t-fast) var(--ease);
}
.pub-search-result:last-child {
  border-bottom: none;
}
.pub-search-result:hover,
.pub-search-result.focused {
  background: var(--bg-hover);
  box-shadow: inset 4px 0 0 var(--accent);
}
.pub-search-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg-deep);
}
.pub-search-thumb-placeholder {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: var(--bg-deep);
  border-radius: 4px;
  border: 1px solid var(--border);
}
.pub-search-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.pub-search-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-search-setnum {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
}
.pub-search-name {
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-search-name strong,
.pub-search-setnum strong,
.pub-search-meta strong {
  color: var(--accent);
  font-weight: 700;
}
.pub-search-sep {
  color: var(--border);
  user-select: none;
}
.pub-search-msg {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* ── Filter loading overlay (shown while page reloads on filter submit) ───── */

.filter-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.65);
  z-index: 9998;
  align-items: center;
  justify-content: center;
}
.filter-loading-overlay.active {
  display: flex;
}
.filter-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: filterSpin 0.7s linear infinite;
}
@keyframes filterSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Inline set detail embed ─────────────────────────────────────────────── */

.pub-set-embed {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 60px;
  box-sizing: border-box;
  animation: embedSlideIn 0.2s ease;
}
@keyframes embedSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.pub-embed-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0 14px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.pub-embed-close {
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  box-shadow: var(--brick-sm);
  transition:
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.pub-embed-close:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: var(--brick-md);
}
.pub-embed-close:active {
  transform: translateY(1px);
  box-shadow: none;
}
.pub-embed-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.pub-embed-setnum {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
  flex-shrink: 0;
}
.pub-embed-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.pub-embed-top {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 700px) {
  .pub-embed-top {
    grid-template-columns: 1fr;
  }
}
.pub-embed-hero {
  background: var(--bg-deep);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.pub-embed-hero img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform var(--t-slow) var(--ease);
}
.pub-embed-hero:hover img {
  transform: scale(1.04);
}
.pub-embed-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 14px;
}
.pub-embed-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Game System ─────────────────────────────────────────────────────────── */

/* Lobby */
.game-lobby {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.game-lobby-hero {
  text-align: center;
  margin-bottom: 32px;
}
.game-lobby-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
}
.game-lobby-sub {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
}
.game-player-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}
.player-badge {
  font-size: 0.9rem;
  padding: 5px 14px;
  border-radius: 3px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--brick-sm);
}
.player-badge--user {
  border-color: var(--accent);
  color: var(--accent);
}
.player-badge--guest {
  color: var(--text-muted);
}
.game-link-btn {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: none;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  text-decoration: none;
  transition:
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}
.game-link-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Mode cards */
.game-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.game-mode-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--brick-md);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.game-mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--brick-yellow);
}
.game-mode-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.4));
}
.game-mode-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.game-mode-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
  line-height: 1.5;
}
.game-mode-note {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.game-mode-btn {
  display: inline-block;
  padding: 9px 20px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--lego-black);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--brick-yellow);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.game-mode-btn:hover {
  background: var(--accent-hover);
  color: var(--lego-black);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--accent-shadow);
}
.game-mode-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}
.game-mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.game-mode-btn--sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}
.game-mode-btn--secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  box-shadow: var(--brick-sm);
  margin-left: 8px;
}
.game-mode-btn--secondary:hover {
  background: var(--bg-hover);
  color: var(--text);
  box-shadow: var(--brick-md);
}
.game-room-join {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.game-room-input {
  width: 120px;
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  outline: none;
}
.game-room-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.game-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

/* Leaderboard */
.game-leaderboard-preview {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--brick-sm);
}
.game-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 16px;
}
.game-lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.game-lb-table th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
}
.game-lb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

/* Game play page */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.game-header-left,
.game-header-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.game-header-right {
  text-align: right;
}
.game-header-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.game-header-set {
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-header-set--target {
  color: var(--accent);
}
.game-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.game-timer {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}
.game-move-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.game-target-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--accent-tint);
  border-bottom: 2px solid var(--border);
  border-left: 4px solid var(--accent);
}
.game-target-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-deep);
  flex-shrink: 0;
}
.game-target-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.game-target-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.game-target-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.game-target-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Path breadcrumb */
.game-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  font-size: 0.8rem;
  overflow-x: auto;
}
.game-path-step {
  padding: 3px 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.game-path-step--current {
  background: var(--accent);
  color: var(--lego-black);
  font-weight: 700;
  border-color: var(--accent);
}
.game-path-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Current set */
.game-current {
  padding: 20px 24px;
}
.game-current-card {
  display: flex;
  gap: 20px;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--brick-sm);
}
.game-current-img {
  width: 120px;
  height: 100px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-deep);
  flex-shrink: 0;
}
.game-current-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.game-current-info h2 {
  font-size: 1.1rem;
  margin: 0 0 4px;
}
.game-current-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 2px;
}

/* Neighbor grid */
.game-neighbors {
  padding: 0 24px 20px;
}
.game-neighbor-section {
  margin-bottom: 24px;
}
.game-neighbor-heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.game-neighbor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.game-neighbor-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition:
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.game-neighbor-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--brick-yellow);
}
.game-neighbor-card:active {
  transform: translateY(2px);
  box-shadow: none;
}
.game-neighbor-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  object-fit: contain;
  background: var(--bg-deep);
  flex-shrink: 0;
}
.game-neighbor-img--empty {
  border: 1px dashed var(--border);
}
.game-neighbor-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.game-neighbor-name {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-neighbor-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-neighbor-link {
  font-size: 0.72rem;
  color: var(--blue);
}
.game-no-neighbors {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
}

/* Game actions */
.game-actions {
  display: flex;
  justify-content: center;
  padding: 16px 24px;
  gap: 12px;
}
.game-btn {
  padding: 8px 20px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}
.game-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--brick-md);
}
.game-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}
.game-btn--danger {
  background: rgba(237, 51, 54, 0.1);
  color: var(--red);
  border-color: var(--red);
}
.game-btn--danger:hover {
  background: var(--red);
  color: var(--lego-black);
  box-shadow: var(--brick-red);
}

/* Win modal */
.game-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
  animation: modalFade var(--t-base) var(--ease) both;
}
.game-modal-box {
  background: var(--bg-card);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--brick-yellow), var(--overlay-shadow);
  animation: modalPop var(--t-slow) var(--ease) both;
}
.game-modal-title {
  font-size: 1.5rem;
  margin: 0 0 16px;
}
.game-modal-time,
.game-modal-moves {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 4px 0;
}
.game-modal-time strong,
.game-modal-moves strong {
  color: var(--text);
}

/* Result page */
.game-result {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.game-result-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--brick-md);
}
.game-result-title {
  font-size: 1.5rem;
  text-align: center;
  margin: 0 0 24px;
}
.game-result-title--win {
  color: var(--green);
}
.game-result-title--loss {
  color: var(--red);
}
.game-result-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
}
.game-result-stat {
  text-align: center;
}
.game-result-stat-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.game-result-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}
.game-result-path {
  margin-bottom: 20px;
}
.game-result-path h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.game-result-route {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.game-result-leaderboard {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
}
.game-result-leaderboard h3 {
  font-size: 0.95rem;
  margin: 0 0 12px;
}
.game-result-cta {
  text-align: center;
  margin-top: 24px;
  padding: 20px;
  background: var(--accent-tint);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.game-result-cta p {
  color: var(--text-muted);
  margin: 0 0 12px;
  font-size: 0.9rem;
}
.game-result-actions {
  text-align: center;
  margin-top: 20px;
}

/* Room page */
.game-room {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.game-room-header {
  text-align: center;
  margin-bottom: 32px;
}
.game-room-title {
  font-size: 1.5rem;
  margin: 0 0 12px;
}
.game-room-code-display {
  font-size: 0.95rem;
  color: var(--text-muted);
}
.game-room-code-big {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-shadow: 0 2px 0 var(--accent-shadow);
  margin: 0 8px;
}
.game-room-waiting {
  text-align: center;
  padding: 40px 0;
}
.game-room-waiting-text {
  color: var(--text-muted);
  margin-top: 20px;
  line-height: 1.6;
}
.game-room-battle {
  padding: 20px 0;
}
.game-room-players {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.game-room-player {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  text-align: center;
  min-width: 180px;
  box-shadow: var(--brick-sm);
}
.game-room-player-name {
  font-size: 1rem;
  margin: 0 0 8px;
}
.game-room-player-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.game-room-player-moves {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.game-room-player-status {
  font-size: 0.82rem;
  color: var(--green);
}
.game-room-vs {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--red);
  text-shadow: 0 3px 0 var(--lego-red-shadow, #8b0000);
}
.game-room-completed {
  text-align: center;
  padding: 40px 0;
}
.game-room-play-link {
  text-align: center;
}

/* ── Game Directory (lobby grid) ─────────────────────────────────────────── */

.game-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.game-dir-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--brick-md);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.game-dir-card:not(.game-dir-card--disabled):hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--brick-yellow);
}

/* Disabled / coming-soon card */
.game-dir-card--disabled {
  opacity: 0.55;
  filter: grayscale(0.35);
  cursor: default;
}
.game-dir-card--disabled .game-mode-btn {
  pointer-events: none;
}

.game-dir-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.game-dir-icon {
  font-size: 2rem;
  line-height: 1;
}
.game-dir-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.game-dir-badge {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 3px;
}
.game-dir-badge--live {
  background: rgba(27, 197, 87, 0.15);
  color: var(--green);
  border: 1px solid rgba(27, 197, 87, 0.3);
}
.game-dir-badge--soon {
  background: rgba(245, 124, 32, 0.12);
  color: var(--orange);
  border: 1px solid rgba(245, 124, 32, 0.3);
}
.game-dir-badge--players {
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.game-dir-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: uppercase;
  margin: 0;
}
.game-dir-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.game-dir-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.game-dir-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: capitalize;
}

.game-dir-footer {
  margin-top: 4px;
}
.game-dir-footer .game-mode-btn {
  width: 100%;
}

/* ── Tic-Tac-Toe Page ────────────────────────────────────────────────────── */

.ttt-page {
  max-width: 520px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.ttt-back {
  margin-bottom: 20px;
}

.ttt-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.ttt-header {
  text-align: center;
}
.ttt-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
}
.ttt-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Legend + mode toggle row */
.ttt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
  flex-wrap: wrap;
}
.ttt-legend {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ttt-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.ttt-brick-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ttt-brick-sm .ttt-brick-svg {
  width: 32px;
  height: 32px;
}
.ttt-vs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}
.ttt-mode-wrap {
  display: flex;
  align-items: center;
}
.ttt-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  user-select: none;
}
.ttt-toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.ttt-toggle-text {
  font-weight: 600;
}

/* Status banner */
.ttt-status {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 20px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 2px solid var(--border);
  box-shadow: var(--brick-sm);
  width: 100%;
  box-sizing: border-box;
  transition:
    background var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.ttt-status--win {
  background: rgba(27, 197, 87, 0.12);
  border-color: rgba(27, 197, 87, 0.4);
  color: var(--green);
}
.ttt-status--draw {
  background: rgba(245, 124, 32, 0.1);
  border-color: rgba(245, 124, 32, 0.3);
  color: var(--orange);
}

/* Score strip */
.ttt-scores {
  display: flex;
  width: 100%;
  gap: 8px;
}
.ttt-score-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  gap: 4px;
  box-shadow: var(--brick-sm);
}
.ttt-score-label {
  font-family: var(--font-body);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.ttt-score-val {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
}
.ttt-score-draw .ttt-score-val {
  color: var(--text-muted);
}

/* Board */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--brick-md);
  box-sizing: border-box;
}
.ttt-cell {
  aspect-ratio: 1;
  background: var(--bg-deep);
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  transition:
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.ttt-cell:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: scale(1.03);
  box-shadow: var(--brick-yellow);
}
.ttt-cell:disabled {
  cursor: default;
}
.ttt-cell--win {
  border-color: var(--green) !important;
  background: rgba(27, 197, 87, 0.1) !important;
  animation: winPulse 1.2s ease-in-out infinite;
}

/* Brick SVGs inside cells */
.ttt-brick-svg {
  width: 100%;
  height: 100%;
  max-width: 80px;
  max-height: 80px;
  display: block;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.5));
}
.ttt-cell--x .ttt-brick-svg {
  animation: brickPop 0.18s ease-out;
}
.ttt-cell--o .ttt-brick-svg {
  animation: brickPop 0.18s ease-out;
}
@keyframes brickPop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Controls row */
.ttt-controls {
  display: flex;
  gap: 10px;
  width: 100%;
}
.ttt-btn {
  flex: 1;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid var(--border);
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}
.ttt-btn:hover {
  transform: translateY(-2px);
}
.ttt-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}
.ttt-btn--reset {
  background: var(--accent);
  color: var(--lego-black);
  border-color: var(--accent);
  box-shadow: var(--brick-yellow);
}
.ttt-btn--reset:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 0 var(--accent-shadow);
}
.ttt-btn--clear {
  background: var(--bg-card);
  color: var(--text-muted);
}
.ttt-btn--clear:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

/* ── Daily Challenge banner ───────────────────────────────────────────────── */
.ttt-daily-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ttt-daily-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--lego-black);
  border: none;
  box-shadow: var(--brick-yellow);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ttt-daily-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Daily leaderboard placeholder ───────────────────────────────────────── */
.ttt-leaderboard-ph {
  width: 100%;
  margin-top: 16px;
  padding: 18px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.ttt-lb-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
  opacity: 0.5;
}
.ttt-lb-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.ttt-lb-coming {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin: 0;
  line-height: 1.5;
}

/* ── Game feature pills ───────────────────────────────────────────────────── */
.game-dir-features {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.game-feat {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.game-feat--on {
  background: rgba(27, 197, 87, 0.1);
  border-color: rgba(27, 197, 87, 0.35);
  color: var(--green);
}
.game-feat--off {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  opacity: 0.55;
}

/* ── Lobby action button variants ────────────────────────────────────────── */
.game-mode-btn--daily {
  background: var(--lego-red) !important;
  border-color: var(--lego-red) !important;
  color: var(--lego-black) !important;
  box-shadow: 0 4px 0 #8b0000 !important;
}
.game-mode-btn--daily:hover {
  background: var(--red) !important;
  box-shadow: 0 6px 0 #8b0000 !important;
  transform: translateY(-2px) !important;
}
.game-mode-btn--daily:active {
  transform: translateY(2px) !important;
  box-shadow: none !important;
}
.game-mode-btn--fallback {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
  box-shadow: var(--brick-sm) !important;
}
.game-mode-btn--fallback:hover {
  background: var(--bg-hover) !important;
  color: var(--text) !important;
}

/* ── Tic-Tac-Toe lobby ───────────────────────────────────────────────────── */
.ttt-lobby {
  max-width: 740px;
  margin: 0 auto;
  text-align: center;
}
.ttt-lobby-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 28px;
}
@media (max-width: 600px) {
  .ttt-lobby-options {
    grid-template-columns: 1fr;
  }
}
.ttt-lobby-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--brick-md);
  transition:
    transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}
.ttt-lobby-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--brick-yellow);
}
.ttt-lobby-icon {
  font-size: 2.4rem;
  line-height: 1;
}
.ttt-lobby-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.ttt-lobby-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
}
.ttt-btn--primary {
  background: var(--accent);
  color: var(--lego-black);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 22px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--brick-yellow);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
  width: 100%;
}
.ttt-btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--accent-shadow);
}
.ttt-btn--primary:active {
  transform: translateY(2px);
  box-shadow: none;
}
.ttt-btn--primary:disabled {
  opacity: 0.5;
  cursor: default;
}
.ttt-join-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.ttt-join-input {
  flex: 1;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ttt-join-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.ttt-btn--join {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--brick-sm);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.ttt-btn--join:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--brick-md);
}
.ttt-btn--join:active {
  transform: translateY(2px);
  box-shadow: none;
}
.ttt-join-error {
  font-size: 0.78rem;
  color: var(--red, #e55);
  min-height: 1em;
  margin: 0;
}

/* ── Tic-Tac-Toe room page ───────────────────────────────────────────────── */
.ttt-room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.ttt-room-code-row strong {
  font-family: var(--font-mono);
  color: var(--text);
  letter-spacing: 0.08em;
  font-size: 0.95rem;
}
.ttt-waiting-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 0;
}
.ttt-waiting-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.7;
  margin: 0;
}
.ttt-waiting-text strong {
  font-family: var(--font-mono);
  color: var(--text);
  letter-spacing: 0.06em;
}
.ttt-legend-item--me > span {
  color: var(--accent);
  font-weight: 700;
}
.ttt-me-badge {
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--lego-black);
  border-radius: 3px;
  padding: 1px 7px;
  vertical-align: middle;
}
.ttt-cell--active {
  cursor: pointer;
}
.ttt-cell--active:hover {
  background: var(--bg-hover);
}

/* ── Mode toggle buttons (processing page) ───────────────────────────────── */

.mode-section {
  margin-top: 14px;
}

.mode-section-label {
  font-family: var(--font-body);
  font-size: 0.73rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.mode-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.mode-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Small --force opt shown below the mode toggle */
.mode-item-opt {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 4px;
  cursor: pointer;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.mode-item:has(.mode-btn.selected) .mode-item-opt {
  opacity: 1;
  pointer-events: auto;
}

.mode-item-opt input[type="checkbox"] {
  accent-color: var(--accent);
  width: 11px;
  height: 11px;
  cursor: pointer;
}

/* Selected state for mode toggle buttons */
.mode-btn.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

.mode-run-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--border);
  flex-wrap: wrap;
}

.mode-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Separator between run button group and operational controls */
.job-controls-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px solid var(--border);
  align-items: center;
}

.job-controls-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

/* ── Job param controls (processing page) ───────────────────────────────── */

.job-params {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--border);
  align-items: flex-end;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-label {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.param-input {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 4px 8px;
  width: 90px;
  transition: border-color var(--t-fast) var(--ease);
}

.param-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Inline checkbox param */
.param-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  padding-bottom: 2px;
  user-select: none;
}

.param-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Single-set input row */
.param-set-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.param-set-input {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 4px 8px;
  width: 130px;
  transition: border-color var(--t-fast) var(--ease);
}

.param-set-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Sub-section within a job panel (e.g. backfill modes) */
.job-subpanel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--border);
}

.job-subpanel-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

/* ── CSS tooltips ────────────────────────────────────────────────────────── */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--lego-black);
  border: 2px solid var(--accent);
  border-radius: 3px;
  color: var(--text);
  font-size: 0.74rem;
  line-height: 1.45;
  padding: 6px 10px;
  white-space: pre-wrap;
  max-width: 260px;
  width: max-content;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  text-align: left;
  box-shadow:
    var(--brick-yellow),
    0 8px 20px rgba(0, 0, 0, 0.55);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* Tooltip arrow */
[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--accent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 101;
}

[data-tooltip]:hover::before {
  opacity: 1;
}

/* Tooltip anchored to right edge for buttons near right margin */
[data-tooltip-pos="left"]::after {
  left: auto;
  right: 0;
  transform: none;
}

[data-tooltip-pos="left"]::before {
  left: auto;
  right: 12px;
  transform: none;
}

/* Browse state restore — highlight the card the user came back to */
@keyframes browseHighlight {
  0% {
    box-shadow:
      0 0 0 3px var(--accent),
      var(--brick-yellow);
    transform: translateY(-3px);
  }
  100% {
    box-shadow: var(--brick-sm);
    transform: translateY(0);
  }
}
.browse-card-highlight {
  animation: browseHighlight 1.8s ease-out;
}

/* ── New keyframes (spec §9h, §9n) ───────────────────────────────────────── */

@keyframes winPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px var(--green),
      var(--brick-green);
  }
  50% {
    box-shadow:
      0 0 0 5px var(--green),
      var(--brick-green);
  }
}

@keyframes modalPop {
  from {
    transform: translateY(20px) scale(0.94);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes modalFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE LAYER
   Phone/tablet refinements layered on top of the existing 900/768/700/600px
   queries earlier in this file. Everything here lives inside max-width media
   queries (plus one harmless image guard), so the desktop layout is untouched.
   Added during the mobile-readability pass.
   ════════════════════════════════════════════════════════════════════════════ */

/* Images never blow past their container's width (no-op when already sized). */
img {
  max-width: 100%;
}

/* Public detail-page gutters (was inline padding on the wrapper divs). */
.pub-detail-head {
  padding: 20px 24px 0;
}
.pub-detail-pad {
  padding: 0 24px 40px;
}

/* ── Tablet / small-laptop (≤768px) ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .content {
    padding: 20px 16px;
  }
  .page-header h2 {
    font-size: 1.35rem;
  }

  /* Dashboard stat cards: denser so they don't stretch to one-per-row */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }

  /* Public landing hero: rein in oversized type + top padding */
  .public-hero {
    padding: 48px 18px 36px;
  }
  .public-title {
    font-size: 2.4rem;
  }
  .public-subtitle {
    font-size: 0.98rem;
    margin-bottom: 28px;
  }

  /* Public browse + game lobby padding */
  .pub-browse-layout {
    padding: 16px;
    gap: 0 16px;
  }
  .game-lobby {
    padding: 28px 16px 60px;
  }

  /* Card grids: slightly tighter minimums */
  .set-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* ── Phone (≤480px) ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Global: tightest padding + smaller headings */
  .content {
    padding: 14px 12px;
  }
  .page-header {
    margin-bottom: 18px;
  }
  .page-header h2 {
    font-size: 1.2rem;
  }

  /* Public detail-page gutters shrink on phones */
  .pub-detail-head {
    padding: 14px 12px 0;
  }
  .pub-detail-pad {
    padding: 0 12px 24px;
  }

  /* Admin top nav (sidebar collapsed to a bar at 900px): wrap, don't overflow */
  .nav-links {
    flex-wrap: wrap;
    gap: 2px;
  }
  .nav-links li a {
    padding: 7px 11px;
    font-size: 0.85rem;
  }

  /* ── Public landing ──────────────────────────────────────────────────────── */
  .public-hero {
    padding: 32px 14px 28px;
  }
  .public-title {
    font-size: 1.9rem;
  }
  .public-subtitle {
    font-size: 0.92rem;
    margin-bottom: 22px;
  }
  /* Nav cards stop forcing 210px and span the row */
  .pub-nav-cards {
    gap: 14px;
    width: 100%;
  }
  .pub-nav-card {
    min-width: 0;
    width: 100%;
    padding: 26px 20px;
  }

  /* ── Dashboard ───────────────────────────────────────────────────────────── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }
  .stat-card {
    padding: 16px 10px 18px;
  }

  /* ── Card grids: keep 2-across rather than one giant card ─────────────────── */
  .set-grid,
  .catalog-grid,
  .minifig-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .parts-visual-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
  }

  /* ── Browse / filters ────────────────────────────────────────────────────── */
  .pub-browse-layout {
    padding: 12px;
    gap: 0 14px;
  }
  /* Admin filter bar (flex row at 900px) → stacked full-width on phones */
  .filter-section {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    width: 100%;
  }
  .year-range-slider {
    margin: 0 4px;
  }
  .pub-theme-select {
    min-width: 0;
  }

  /* ── Detail pages (set / part / minifig, public + admin) ─────────────────── */
  .detail-layout {
    gap: 18px;
    margin-bottom: 20px;
  }
  /* Stack the part image and the color-picker so the image gets full width */
  .detail-hero-wrap {
    flex-direction: column;
    gap: 10px;
  }
  .color-picker-strip {
    flex-direction: row;
    width: 100%;
  }
  /* Swatches become a 2-row horizontally-scrolling strip below the image */
  .color-picker-swatches {
    grid-template-columns: none;
    grid-template-rows: repeat(2, 1fr);
    grid-auto-flow: column;
    grid-auto-columns: 32px;
    max-height: none;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .meta-table th,
  .meta-table td {
    padding: 8px 8px;
    font-size: 0.8rem;
  }
  .meta-table th {
    width: 42%;
  }

  /* ── Games ───────────────────────────────────────────────────────────────── */
  .game-lobby {
    padding: 22px 12px 50px;
  }
  .game-directory-grid,
  .game-mode-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .game-room-join {
    flex-wrap: wrap;
  }
  .game-room-input {
    width: 100%;
  }
  .ttt-page {
    padding: 22px 12px 60px;
  }
  .ttt-controls {
    flex-wrap: wrap;
  }
}

/* ── Icon framework ────────────────────────────────────────────────────────
   Monochrome SVGs in /static/img/icons/ rendered via CSS mask so they take the
   current text/accent color and follow the active theme. Usage:
     <span class="icon icon-search" aria-hidden="true"></span>
   Size follows font-size (1em). Add a new icon by dropping foo.svg in the
   folder and adding a .icon-foo rule below. Replace any icon by overwriting
   its file — the class/name stays the same (hot-swappable). */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  background-color: currentColor;
  vertical-align: -0.125em;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon-search { --icon: url("/static/img/icons/search.svg"); }
.icon-games { --icon: url("/static/img/icons/games.svg"); }
.icon-processing { --icon: url("/static/img/icons/processing.svg"); }
.icon-settings { --icon: url("/static/img/icons/settings.svg"); }
.icon-wrench { --icon: url("/static/img/icons/wrench.svg"); }
.icon-user { --icon: url("/static/img/icons/user.svg"); }
.icon-swords { --icon: url("/static/img/icons/swords.svg"); }
.icon-image { --icon: url("/static/img/icons/image.svg"); }
.icon-lock { --icon: url("/static/img/icons/lock.svg"); }
.icon-filter { --icon: url("/static/img/icons/filter.svg"); }
.icon-grid { --icon: url("/static/img/icons/grid.svg"); }
.icon-list { --icon: url("/static/img/icons/list.svg"); }

/* ── Brand mark (logo image) ───────────────────────────────────────────────
   Full-color SVG in /static/img/brick-mark.svg, sized by height to sit beside
   the "BrickOSINT" wordmark. Replace the file to change the logo. */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.34em;
}
.brand-mark {
  height: 1em;
  width: auto;
  flex-shrink: 0;
}
/* Sidebar: the wordmark is a solid-yellow chip, so the mark sits OUTSIDE it
   (a yellow brick on a yellow chip would vanish). Fixed height, not em. */
.sidebar-header .brand-lockup {
  gap: 10px;
}
.sidebar-header .brand-mark {
  height: 30px;
}
/* Public nav-card / game-mode icon tiles: big accent-colored glyphs */
.pub-nav-card-icon .icon,
.game-mode-icon .icon {
  width: 1em;
  height: 1em;
  color: var(--accent);
}
