/* ----------------------------------------------------------------------
   The Hive Spoofer — Dashboard styles (Phase 4 v3 redesign, [DR-308])

   Pixel-matched port of the Claude Design v2 dashboard handoff
     https://api.anthropic.com/v1/design/h/tjCb0MC_7GZDckhuqdq9og
   The handoff shipped a React-based prototype (dashboard.jsx + styles/
   dashboard.css). This file is the plain-CSS port that lights up the
   existing index.html — every JS-bound ID and class on the page is
   preserved; this CSS just retargets the design system onto them.

   Loading order is critical (defined in index.html <head>):
     1. /static/styles/tokens.css   — design tokens (--bg-1, --amber, ...)
     2. /static/styles.css          — legacy structural rules (specificity
                                      `.chip .chip-dot` etc.)
     3. /static/styles/dashboard.css — THIS FILE, last so it wins

   To beat the legacy stylesheet, every rule that re-styles an element
   the legacy also targets uses MATCHING OR HIGHER specificity. Where the
   legacy uses `.chip .chip-dot` (0,2,0), this file uses `.chip .chip-dot`
   too — same specificity, but later in the cascade wins.
   --------------------------------------------------------------------- */

:root {
  --bg: var(--bg-1);
  --bg-elev: var(--bg-2);
  --bg-elev-2: var(--bg-3);
  --border: var(--line-1);
  --text: var(--fg-1);
  --text-dim: var(--fg-2);
  --accent: var(--amber);
  --accent-soft: var(--amber-soft);
  --danger: var(--red);
  --ok: var(--green);
  --radius: var(--r-md);
}

/* ---- Base ---------------------------------------------------------- */

html, body {
  background: var(--bg-1);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { background: var(--bg-1); }

.bg-atmosphere { z-index: 0; }
main, header, footer, .img-editor-root { position: relative; z-index: 2; }

::selection { background: var(--amber); color: #000; }

/* ---- Topbar (design class names .app-topbar / .app-topbar-inner /
       .app-nav / .brand-mark / .avatar pair with the legacy classes
       .topbar / .nav so dashboard.css rules from the design apply
       natively to the same elements) -------------------------------- */

body .app-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--s-5);
  gap: var(--s-3);
}
body .app-topbar.topbar {
  /* The .topbar/.app-topbar dual class lives on the outer <header>;
     the existing body .topbar rules below set sticky/blur/border-bottom.
     The 56px height comes from .app-topbar-inner; reset the legacy
     padding so the inner div controls the gutters. */
  padding: 0;
  height: auto;
}
body .topbar .brand,
body .app-topbar .brand {
  text-decoration: none;
}
body .brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
}
body .brand-mark svg, body .brand-mark .hex-icon { width: 26px; height: 26px; }
body .nav.app-nav,
body .app-nav { gap: var(--s-3); display: flex; align-items: center; }

/* Avatar (round amber-gradient circle with 2-letter initials computed
   by the inline script that watches #navUser). */
body .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-deep) 100%);
  color: #0a0a0a;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  display: grid;
  place-items: center;
  font-family: var(--font-body);
  box-shadow: 0 0 0 1px rgba(255, 179, 0, 0.3) inset;
  flex-shrink: 0;
  user-select: none;
}

/* The legacy .user-pill shows the full username as a long pill. The
   design replaces it with the round avatar; keep .user-pill in the DOM
   (app.js writes #navUser.textContent) but hide it visually. */
body .user-pill { display: none !important; }

/* ---- Topbar -------------------------------------------------------- */

body .topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  padding: 0 var(--s-5);
  background: rgba(8, 8, 11, 0.85);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
body .topbar.scrolled {
  background: rgba(8, 8, 11, 0.92);
  border-bottom-color: var(--line-2);
}
body .topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-0);
  font-size: 15px;
}
body .topbar .brand-text { font-size: 15px; font-weight: 600; }
body .topbar .hex-icon { width: 26px; height: 26px; }

body .topbar .nav { gap: var(--s-3); display: flex; align-items: center; }
body .topbar .nav a {
  font-weight: 500;
  font-size: 14px;
  color: var(--fg-2);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: color 150ms var(--ease);
}
body .topbar .nav a:hover { color: var(--fg-0); background: transparent; text-decoration: none; }

/* Credits pill — three-state (default / low / crit). */
body .credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-1);
  letter-spacing: 0.02em;
  transition: all 200ms var(--ease);
  cursor: pointer;
}
body .credits-pill:hover { background: var(--bg-3); border-color: var(--line-3); text-decoration: none; }
body .credits-pill .credits-label { color: var(--fg-3); }
body #navCreditsAmount { color: var(--fg-0); font-weight: 600; }
body .credits-pill.is-low {
  background: rgba(255, 179, 0, 0.1);
  border-color: rgba(255, 179, 0, 0.3);
  color: var(--amber);
}
body .credits-pill.is-low #navCreditsAmount { color: var(--amber); }
body .credits-pill.is-crit,
body .credits-pill.crit {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}
body .credits-pill.is-crit #navCreditsAmount,
body .credits-pill.crit #navCreditsAmount { color: var(--red); }

body .user-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  font-size: 12px;
  color: var(--fg-2);
  font-family: var(--font-mono);
}

/* ---- Main wrapper -------------------------------------------------- */

body .container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-9);
  background: transparent;
}

/* ---- Mode tabs (existing .mode-tabs / .mode-tab) ------------------- */

body .mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--s-6);
  border-bottom: 1px solid var(--line-1);
  position: relative;
  background: transparent;
  border-radius: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body .mode-tabs::-webkit-scrollbar { display: none; }
body .mode-tab {
  padding: 14px 20px;
  background: transparent;
  border: 0;
  color: var(--fg-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  position: relative;
  transition: color 200ms var(--ease);
  white-space: nowrap;
  border-radius: 0;
}
body .mode-tab:hover { color: var(--fg-1); background: transparent; }
body .mode-tab .mode-tab-label {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  color: inherit;
}
body .mode-tab .mode-tab-sub {
  font-size: 11px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
body .mode-tab.active {
  color: var(--fg-0);
  background: transparent;
}
body .mode-tab.active .mode-tab-sub { color: var(--amber); }
body .mode-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber-glow);
}

/* ---- View transition ---------------------------------------------- */

body .mode-panel {
  animation: viewIn 320ms var(--ease-out) both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Hero (small intro inside each mode panel) --------------------- */

body .hero { margin-bottom: var(--s-5); }
body .hero h1 {
  font-size: clamp(24px, 2.4vw, 30px);
  letter-spacing: -0.025em;
  line-height: 1.1;
  font-weight: 600;
  color: var(--fg-0);
  margin: 0 0 var(--s-3);
}
body .hero p {
  color: var(--fg-2);
  font-size: 14.5px;
  max-width: 760px;
  margin: 0;
}
body .hero p code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--amber);
}

/* (DR-822 P5) The Pixel Spoofer .spoof-intro* card CSS was removed — Pixel
   Spoofer now uses the shared .page-head (DR-822 P3D). Verified 0 .spoof-intro
   usages across all HTML/JS before removal. */

/* ---- Panel --------------------------------------------------------- */

body .panel {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-4);
}
body .panel .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
  gap: var(--s-3);
}
body .panel .panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-0);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
body .panel .panel-head h2 .num-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--fg-2);
  font-weight: 500;
}
body .panel .panel-head h2 .num-badge.on {
  background: var(--amber-soft);
  border-color: rgba(255, 179, 0, 0.3);
  color: var(--amber);
}
body .panel .panel-head h2 .muted {
  font-weight: 400;
  font-size: 12px;
  color: var(--fg-3);
  margin-left: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
body .panel .panel-head-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
body .panel .panel-row { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }

/* ---- Segmented control (existing .seg / .seg-btn) ------------------ */

body .seg {
  display: inline-flex;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
body .seg .seg-btn {
  padding: 6px 13px;
  background: transparent;
  border: 0;
  color: var(--fg-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 200ms var(--ease);
}
body .seg .seg-btn:hover { color: var(--fg-1); }
body .seg .seg-btn.active {
  background: var(--bg-1);
  color: var(--fg-0);
  box-shadow: 0 1px 0 var(--line-2);
}

body .img-filter-mode {
  margin-bottom: var(--s-4);
  padding: var(--s-3) 0 var(--s-4);
  border-bottom: 1px dashed var(--line-1);
}
body .img-filter-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}
body .img-filter-mode-label { color: var(--fg-3); font-size: 12px; }
body .img-filter-mode-desc {
  margin-top: 8px;
  font-size: 12px;
  color: var(--fg-3);
  font-family: var(--font-mono);
}

/* ---- Chips (matches the design's amber-square checkbox exactly) ---- */
/*
   Specificity strategy: the legacy /static/styles.css uses `.chip .chip-dot`
   (0,2,0). This file uses `.chip-grid .chip .chip-dot` (0,3,0) so it always
   wins regardless of cascade ordering. Same trick for .chip-row and label.
*/

body .chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
body .chip-grid .chip {
  position: relative;
  padding: 11px 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 200ms var(--ease);
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  font-family: inherit;
  user-select: none;
  margin: 0;
  min-height: auto;
  /* (Fix 1) — clip the slider thumb's box-shadow ring + the
     "filter on/off" pill if either pushes past the chip edge on
     narrow grid cells. min-width:0 lets the inner spans actually
     wrap their text instead of forcing the chip wider. */
  overflow: hidden;
  min-width: 0;
}
body .chip-grid .chip:hover { border-color: var(--line-3); background: var(--bg-4); }
body .chip-grid .chip.active {
  border-color: var(--amber);
  background: var(--amber-soft);
}

/* Hide the native checkbox; the <label class="chip"> wrapper makes any
   click flip the input, so the visual indicator is purely cosmetic. */
body .chip-grid .chip input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

/* The chip-row collapses; we treat the chip itself as the layout container. */
body .chip-grid .chip .chip-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  background: transparent;
  margin: 0;
}

/* The chip label becomes the design's .name. */
body .chip-grid .chip .chip-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-1);
  padding-right: 24px; /* room for the absolute-positioned check */
  letter-spacing: -0.005em;
  line-height: 1.3;
}

/* Optional .chip-desc subtitle, injected post-render by the inline
   enhancement script in index.html. Matches the design's .desc rule. */
body .chip-grid .chip .chip-desc {
  font-size: 11px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  line-height: 1.4;
  padding-right: 24px;
  margin-top: 1px;
}

/* The .chip-dot becomes the amber square check. The legacy circle look
   is fully overridden here. */
body .chip-grid .chip .chip-dot {
  position: absolute !important;
  top: 9px !important;
  right: 10px !important;
  left: auto !important;
  width: 14px !important;
  height: 14px !important;
  border: 1.5px solid var(--line-3) !important;
  border-radius: 4px !important;
  background: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
  transition: all 200ms var(--ease);
  display: block !important;
  box-shadow: none;
}
body .chip-grid .chip.active .chip-dot {
  background: var(--amber) !important;
  border-color: var(--amber) !important;
  box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.18) !important;
}
body .chip-grid .chip.active .chip-dot::after {
  content: "" !important;
  position: absolute !important;
  left: 3px !important;
  top: 0px !important;
  width: 4px !important;
  height: 8px !important;
  border: solid #000 !important;
  border-width: 0 1.6px 1.6px 0 !important;
  transform: rotate(45deg);
  background: transparent !important;
}

/* Strength slider strip on filter chips (.chip.has-strength).
   (Fix 1) — the value label is now a fixed 32 px column so "100%"
   doesn't shove the slider track narrower than the rest of the row;
   the input gets min-width:0 so flex:1 can actually shrink, and
   the thumb's outer box-shadow ring is reduced to 1.5 px so the
   thumb at 100% doesn't overflow the chip's right padding. */
body .chip-grid .chip .chip-strength {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 0;
  background: transparent;
  border: 0;
  width: 100%;
  min-width: 0;
}
body .chip-grid .chip .chip-strength.layout-only { display: none; }
body .chip-grid .chip .chip-strength input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--bg-1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
body .chip-grid .chip .chip-strength input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  box-shadow: 0 0 0 1.5px var(--bg-3);
}
body .chip-grid .chip .chip-strength input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
}
body .chip-grid .chip .chip-strength-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-2);
  width: 32px;
  flex: 0 0 32px;
  text-align: right;
  white-space: nowrap;
}

/* IG-filter sub-toggle on each wash-type chip (.has-filter-toggle).
   (Fix 5) — pin to the chip's left edge with a small bottom margin,
   constrain max-width so it can't push past the right border on
   narrow grid cells, and clip the text + ellipsize if a future label
   gets longer than "filter on". */
body .chip-grid .chip .chip-filter-toggle {
  display: flex;
  align-items: center;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100%;
  min-width: 0;
}
body .chip-grid .chip .chip-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 150ms var(--ease);
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
body .chip-grid .chip .chip-filter-btn:hover { border-color: var(--line-3); color: var(--fg-2); }
body .chip-grid .chip .chip-filter-btn[aria-pressed="true"],
body .chip-grid .chip .chip-filter-btn.is-on {
  background: rgba(255, 179, 0, 0.12);
  border-color: rgba(255, 179, 0, 0.3);
  color: var(--amber);
}
body .chip-grid .chip .chip-filter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-3);
  transition: background 150ms var(--ease);
}
body .chip-grid .chip .chip-filter-btn[aria-pressed="true"] .chip-filter-dot,
body .chip-grid .chip .chip-filter-btn.is-on .chip-filter-dot { background: var(--amber); }
body .chip-grid .chip .chip-filter-text { letter-spacing: 0.04em; }

/* "No filter" baseline chip — hide the strength slider since baseline
   has no strength. */
body .chip-grid .chip.is-no-filter .chip-strength,
body .chip-grid .chip.is-no-filter .chip-no-filter-sub { display: none; }

/* ---- Dropzone ------------------------------------------------------ */

body .dropzone {
  position: relative;
  padding: var(--s-7) var(--s-5);
  background:
    radial-gradient(ellipse at center, rgba(255, 179, 0, 0.04), transparent 70%),
    var(--bg-2);
  border: 1.5px dashed var(--line-3);
  border-radius: var(--r-lg);
  text-align: center;
  cursor: pointer;
  transition: all 250ms var(--ease);
  margin-bottom: var(--s-4);
}
body .dropzone:hover {
  border-color: var(--line-3);
  background:
    radial-gradient(ellipse at center, rgba(255, 179, 0, 0.06), transparent 70%),
    var(--bg-3);
}
body .dropzone.dragover, body .dropzone.is-drag, body .dropzone.drag {
  border-color: var(--amber);
  background:
    radial-gradient(ellipse at center, rgba(255, 179, 0, 0.12), transparent 70%),
    var(--bg-2);
  animation: pulseBorder 1.4s ease-in-out infinite;
}
@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 179, 0, 0.3); }
  50% { box-shadow: 0 0 0 10px rgba(255, 179, 0, 0); }
}
body .dropzone .dropzone-inner { display: contents; }
body .dropzone .dropzone-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  color: var(--amber);
  margin: 0 auto var(--s-4);
  transition: all 250ms var(--ease);
}
body .dropzone .dropzone-icon svg {
  width: 28px !important;
  height: 28px !important;
  color: var(--amber);
}
body .dropzone.dragover .dropzone-icon, body .dropzone.is-drag .dropzone-icon, body .dropzone.drag .dropzone-icon {
  transform: scale(1.05);
  border-color: var(--amber);
  background: var(--amber-soft);
}
body .dropzone .dropzone-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
body .dropzone .dropzone-sub { color: var(--fg-2); font-size: 14px; }
body .dropzone .dropzone-sub .link { color: var(--amber); text-decoration: underline; }
body .dropzone .dropzone-meta {
  color: var(--fg-3);
  font-size: 12px;
  margin-top: var(--s-3);
  font-family: var(--font-mono);
}

/* ---- Buttons ------------------------------------------------------- */

body .btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  transition: all 200ms var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
body .btn.btn-lg { height: 50px; padding: 0 22px; font-size: 15px; }
body .btn.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }

body .btn.btn-primary {
  background: var(--amber);
  color: #0a0a0a;
  font-weight: 600;
  box-shadow:
    0 0 0 1px rgba(255, 179, 0, 0.4) inset,
    0 8px 24px -8px rgba(255, 179, 0, 0.45);
}
body .btn.btn-primary:hover:not(:disabled) {
  background: var(--amber-bright);
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(255, 179, 0, 0.5) inset,
    0 14px 28px -8px rgba(255, 179, 0, 0.55);
}
body .btn.btn-primary:active:not(:disabled) { transform: translateY(0); }
body .btn.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

body .btn.btn-ghost {
  background: transparent;
  color: var(--fg-1);
  border-color: var(--line-2);
}
body .btn.btn-ghost:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--line-3);
  color: var(--fg-0);
}
body .btn.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

body .btn.btn-secondary {
  background: var(--bg-3);
  color: var(--fg-0);
  border-color: var(--line-2);
}
body .btn.btn-secondary:hover:not(:disabled) { background: var(--bg-4); border-color: var(--line-3); }

body .btn.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
}
body .btn.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.5);
}

body .btn.btn-ok {
  background: var(--green);
  color: #06180f;
  font-weight: 600;
  border-color: transparent;
}

/* Spinner inside btn-primary while a wash is running. */
body .btn .btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top-color: #000;
  animation: spin 800ms linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Cost tag pill ------------------------------------------------- */

body .cost-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--amber-soft);
  border: 1px solid rgba(255, 179, 0, 0.2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber);
}
body .cost-tag.muted {
  background: var(--bg-3);
  border-color: var(--line-2);
  color: var(--fg-2);
}
body .cost-tag.is-insufficient {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

/* ---- Counter row --------------------------------------------------- */

body .counter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  margin-bottom: var(--s-4);
  font-size: 13px;
  color: var(--fg-2);
  flex-wrap: wrap;
  gap: var(--s-3);
}
body .counter-row strong { color: var(--fg-0); }
body .counter-row .actions { display: flex; gap: 6px; }

/* ---- Sticky cost footer ------------------------------------------- */

body .sticky-footer {
  position: sticky;
  bottom: var(--s-4);
  z-index: 30;
  margin-top: var(--s-6);
  padding: 14px 18px;
  background: rgba(12, 12, 17, 0.92);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
}
body .sticky-footer .info {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--fg-2);
}
body .sticky-footer .info strong { color: var(--fg-0); }
body .sticky-footer .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Processing card (wraps existing #progress) -------------------- */

body .processing-card,
body .progress-panel {
  background: var(--bg-2);
  border: 1px solid rgba(255, 179, 0, 0.25);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-4);
  box-shadow:
    0 0 0 1px rgba(255, 179, 0, 0.05),
    0 30px 60px -20px rgba(255, 179, 0, 0.1);
}
body .progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
  gap: var(--s-3);
}
body .progress-head strong {
  margin: 0;
  font-size: 14px;
  color: var(--fg-0);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
body .progress-head strong::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
  animation: pulseDot 1.2s ease-in-out infinite;
}
body .progress-head .muted, body .progress-head #progressCounts {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-2);
}

body .progress-bar,
body .progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-1);
  overflow: hidden;
  position: relative;
}
body .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber-bright));
  border-radius: 3px;
  box-shadow: 0 0 12px var(--amber-glow);
  transition: width 400ms var(--ease);
  position: relative;
}
body .progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

body .progress-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--s-4);
  padding: 0;
  list-style: none;
}
body .progress-list li {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: var(--s-3);
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--fg-1);
}

/* ---- Queue panel + file list (legacy structures from styles.css) --- */

body .queue-panel,
body .file-list-wrap,
body .resume-banner {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
}
body .queue-head, body .file-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
body .queue-head strong, body .file-list-head strong { color: var(--fg-0); font-size: 14px; }
body .queue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body .queue-list li {
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--fg-1);
  font-family: var(--font-mono);
}
body .resume-banner {
  border-color: rgba(255, 179, 0, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 179, 0, 0.05), transparent),
    var(--bg-2);
}

/* ---- File card grid (app.js + spoofer.js queue cards) -------------- */
/*
   app.js builds: <div class="file-card video?"><span class="media-badge">
     VIDEO</span><video|img/><div class="file-name"><div class="file-size">
     <button class="file-remove">. spoofer.js builds the same .file-card
   structure with a .file-card-name child. We style both to match the
   design's tinted-thumbnail card aesthetic.
*/
body .file-list,
body #spfQueue {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
}
body .file-list .file-card,
body #spfQueue .file-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 200ms var(--ease);
  padding: 0;
  margin: 0;
}
body .file-list .file-card:hover,
body #spfQueue .file-card:hover {
  border-color: var(--line-2);
  transform: translateY(-1px);
}
body .file-list .file-card.video::before,
body .file-list .file-card:not(.video) > img,
body .file-list .file-card > video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: linear-gradient(135deg, #1a2530 0%, #0e1a25 100%);
}
body .file-list .file-card > video {
  background: #000;
}
body .file-list .file-card .media-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.65);
  color: var(--fg-1);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
body .file-list .file-card .file-name,
body #spfQueue .file-card .file-card-name {
  font-size: 12px;
  color: var(--fg-1);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 10px 2px;
  margin: 0;
}
body .file-list .file-card .file-size {
  font-size: 11px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  padding: 0 10px 8px;
  margin: 0;
}
body .file-list .file-card .file-remove,
body #spfQueue .file-card button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: var(--fg-1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  margin: 0;
  font-family: inherit;
  opacity: 0;
  transition: all 200ms var(--ease);
  z-index: 3;
}
body .file-list .file-card:hover .file-remove,
body #spfQueue .file-card:hover button { opacity: 1; }
body .file-list .file-card .file-remove:hover,
body #spfQueue .file-card button:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ---- Image-tab cards (image.js + spoofer.js results) -------------- */

body .img-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: var(--s-4);
  padding: 0;
}
body .img-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 200ms var(--ease);
  margin: 0;
  padding: 0;
}
body .img-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
body .img-card.is-washed { border-color: rgba(46, 182, 125, 0.35); }
body .img-card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #2a2230 0%, #1a1620 100%);
  overflow: hidden;
}
body .img-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
body .img-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 4;
}
body .img-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.65);
  color: var(--fg-1);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
body .img-card-badge.washed {
  background: rgba(46, 182, 125, 0.18);
  color: var(--green);
  border-color: rgba(46, 182, 125, 0.35);
}
body .img-card-badge.edits {
  background: rgba(255, 179, 0, 0.18);
  color: var(--amber);
  border-color: rgba(255, 179, 0, 0.35);
  left: auto;
  right: 8px;
  top: auto;
  bottom: 8px;
}
body .img-card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: var(--fg-1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  margin: 0;
  font-family: inherit;
  opacity: 0;
  transition: all 200ms var(--ease);
  z-index: 4;
}
body .img-card:hover .img-card-remove { opacity: 1; }
body .img-card-remove:hover { background: var(--red); border-color: var(--red); color: #fff; }
body .img-card-name {
  font-size: 12px;
  color: var(--fg-1);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 10px 2px;
}
body .img-card-error {
  font-size: 11px;
  color: var(--red);
  padding: 0 10px 4px;
}
body .img-card-actions {
  display: flex;
  gap: 4px;
  padding: 0 8px 10px;
}
body .img-card-actions .btn {
  flex: 1;
  height: 28px;
  font-size: 11px;
  padding: 0 8px;
}

/* ---- Action bars + image-tab toolbars ----------------------------- */

body .img-actionbar,
body .img-toolbar {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}
body .img-actionbar-left, body .img-actionbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
body .img-toolbar { flex-direction: column; align-items: stretch; gap: var(--s-3); }

/* (DR-309 v2) — Image-tab toolbar floats at the viewport bottom matching
   the Video-tab .sticky-footer treatment. Two changes from the previous
   attempt:
     1. The toolbar element is now positioned AFTER #imgGrid in
        index.html so position:sticky;bottom:0 actually has scrolling
        content above it to pin against. Sticky-to-bottom doesn't work
        when the element is the FIRST child of its scroll container —
        there's nothing for it to stick over.
     2. The legacy `body .img-toolbar { flex-direction: column }` rule
        forced .info and .actions to stack vertically; the override
        below promotes #imgToolbar back to flex-row when it has the
        .sticky-footer class so the design's side-by-side layout works.
   The :not([hidden]) selector keeps the legacy initial state intact —
   image.js sets elToolbar.hidden = (total === 0), and we only sticky-
   position once it's actually rendered. */
body #imgToolbar.sticky-footer {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
body #imgToolbar.sticky-footer:not([hidden]) {
  position: sticky;
  bottom: var(--s-4);
  z-index: 30;
  margin-top: var(--s-6);
  padding: 14px 18px;
  background: rgba(12, 12, 17, 0.92);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
}
body #imgToolbar.sticky-footer .info {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--fg-2);
  min-width: 0;
}
body #imgToolbar.sticky-footer .info strong { color: var(--fg-0); }
body #imgToolbar.sticky-footer .info-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
body #imgToolbar.sticky-footer .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
body #imgToolbar.sticky-footer .actions .btn { white-space: nowrap; }
body .img-toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}
body .img-toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
body .img-toolbar-math { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); }

/* ---- Output settings panel (Image tab) ----------------------------- */

body .output-settings { /* visible-by-default settings card on the Image tab */
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-4);
}
body .output-settings .panel-head { margin-bottom: var(--s-4); }
body .setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line-1);
  flex-wrap: wrap;
}
body .setting-row:first-child { border-top: 0; padding-top: 0; }
body .setting-row > div:first-child { flex: 1; min-width: 200px; }
body .setting-row .label { font-size: 13px; color: var(--fg-1); font-weight: 500; }
body .setting-row .desc { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* Stepper (- / N / +). */
body .stepper {
  display: inline-flex;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 2px;
}
body .stepper button {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--fg-1);
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  display: grid;
  place-items: center;
  transition: all 200ms var(--ease);
}
body .stepper button:hover:not(:disabled) { background: var(--bg-4); color: var(--fg-0); }
body .stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
body .stepper .v {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-0);
  min-width: 32px;
  text-align: center;
}

/* ---- Image-tab settings panel (collapsible legacy block) ---------- */

body .img-settings {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-4);
}
body .img-settings h2 {
  margin: 0 0 var(--s-4);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: -0.01em;
}
body .img-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-3) var(--s-5);
}
body .img-range-row, body .img-single-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-1);
}
body .img-range-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--fg-1);
}
body .img-range-value { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
body .img-range-controls { display: flex; gap: 6px; }
body .img-range-controls input[type="range"], body .img-single-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--bg-1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
body .img-range-controls input[type="range"]::-webkit-slider-thumb,
body .img-single-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg-3);
}
body .img-settings-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  padding-top: var(--s-3);
  margin-top: var(--s-3);
  border-top: 1px solid var(--line-1);
}
body .img-settings-checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-2);
  cursor: pointer;
}
body .img-settings-checks input { accent-color: var(--amber); }

/* ---- Extras grid (video tab) -------------------------------------- */

body .extras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-3);
}
body .extra {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 200ms var(--ease);
  margin: 0;
}
body .extra:hover { background: var(--bg-4); border-color: var(--line-3); }
body .extra input[type="checkbox"] { accent-color: var(--amber); margin-top: 3px; }
body .extra-text strong { display: block; font-size: 13px; color: var(--fg-1); font-weight: 600; margin-bottom: 2px; }
body .extra-text small { font-size: 11px; color: var(--fg-3); line-height: 1.5; }

body .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-2);
}

/* ---- Status / error messages --------------------------------------- */

body .status {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
  font-size: 13px;
}
body .error { color: var(--red); }
body .ok-msg { color: var(--green); }
body .muted { color: var(--fg-2); }
body .small { font-size: 12px; }

/* ---- Download-ready row inside #progress --------------------------- */

body .download-ready {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: rgba(46, 182, 125, 0.1);
  border: 1px solid rgba(46, 182, 125, 0.3);
  border-radius: var(--r-md);
  margin-top: var(--s-4);
  flex-wrap: wrap;
}
body .download-ready .muted { color: var(--green); }

/* ---- Waiting panel ------------------------------------------------- */

body .waiting-panel {
  margin-top: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
}
body .waiting-headline { font-size: 13px; color: var(--fg-1); margin-bottom: 4px; }

/* ---- Actions row (legacy back-compat) ----------------------------- */

body .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Admin tables -------------------------------------------------- */

body .data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
body .data-table thead th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  background: var(--bg-3);
  border-bottom: 1px solid var(--line-1);
  padding: 10px 12px;
  text-align: left;
}
body .data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-1);
  color: var(--fg-1);
}
body .data-table tbody tr:hover { background: var(--bg-3); }
body .table-wrap {
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-2);
  margin-bottom: var(--s-4);
}

/* ---- Output estimate (legacy) ------------------------------------- */

body #outputEstimate { color: var(--fg-2); font-size: 13px; }

/* ---- Empty state --------------------------------------------------- */

body .empty {
  padding: var(--s-7) var(--s-5);
  text-align: center;
  color: var(--fg-3);
  font-size: 13px;
}
body .empty-title {
  color: var(--fg-2);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

/* ---- Responsive ---------------------------------------------------- */

@media (max-width: 768px) {
  body .container { padding: var(--s-4) var(--s-4) var(--s-9); }
  body .panel { padding: var(--s-4); }
  body .chip-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  body .img-grid, body .file-list, body #spfQueue { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  body .mode-tab .mode-tab-sub, body .tab .sub { display: none; }
  body .mode-tab, body .tab { padding: 12px 14px; }
  body .sticky-footer { flex-direction: column; align-items: stretch; }
  body .sticky-footer .actions { justify-content: stretch; }
  body .sticky-footer .actions .btn { flex: 1; }
}

/* -------------------------------------------------------------------- */
/*  Design-class-name aliases — pair the design's literal class names   */
/*  on the same elements as the legacy ones so design CSS applies       */
/*  natively. Loaded last so any override here wins.                    */
/* -------------------------------------------------------------------- */

/* Tab bar — .tab-bar / .tab / .tab .label / .tab .sub mirror the
   .mode-tabs / .mode-tab / .mode-tab-label / .mode-tab-sub rules
   above. The dual-classed elements get both selectors. */
body .tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: var(--s-6);
  border-bottom: 1px solid var(--line-1);
  position: relative;
  background: transparent;
  border-radius: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body .tab-bar::-webkit-scrollbar { display: none; }
body .tab {
  padding: 14px 20px;
  background: transparent;
  border: 0;
  color: var(--fg-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  position: relative;
  transition: color 200ms var(--ease);
  white-space: nowrap;
  border-radius: 0;
}
body .tab:hover { color: var(--fg-1); background: transparent; }
body .tab .label {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  color: inherit;
}
body .tab .sub {
  font-size: 11px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
body .tab.active { color: var(--fg-0); background: transparent; }
body .tab.active .sub { color: var(--amber); }
body .tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber-glow);
}

/* Panel header — .panel-h is the design's class name (alongside
   legacy .panel-head). Same selectors apply to both. */
body .panel .panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
  gap: var(--s-3);
}
body .panel .panel-h h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-0);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Num-badge selection counter (e.g. "4 / 9"). Inline script toggles
   .on when count > 0 — amber pill. */
body .num-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--fg-2);
  font-weight: 500;
  letter-spacing: 0.02em;
}
body .num-badge.on {
  background: var(--amber-soft);
  border-color: rgba(255, 179, 0, 0.3);
  color: var(--amber);
}

/* Hint text inside panel header — design uses monospace fg-3. */
body .panel-h .hint, body .panel-head .hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  margin-left: 4px;
}

/* Quick-actions cluster (legacy .panel-head-actions + design alias). */
body .quick-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* The .view class on each .mode-panel matches the design's per-tab
   wrapper. Re-trigger the fade-up animation when the tab activates. */
body .view { animation: viewIn 320ms var(--ease-out) both; }

/* Sticky-footer info decomposition — the inline script populates these
   span groups. .info-summary holds "X outputs from Y files",
   .cost-tag is the amber pill, .info-balance is the trailing balance
   chip. When parsing fails the script falls back to the raw
   #outputEstimate text. */
body .sticky-footer .info-summary,
body .sticky-footer .info-balance {
  font-size: 13px;
  color: var(--fg-2);
}
body .sticky-footer .info-summary strong,
body .sticky-footer .info-balance strong { color: var(--fg-0); }

/* Admin-link spacing in the topbar (kept for legacy admins). */
body .nav #navAdmin {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
}
body .nav #navAdmin:hover { color: var(--amber); border-color: rgba(255, 179, 0, 0.3); }

/* ---- Empty placeholder positioning when sibling-of-grid ----------- */
body .empty[data-empty-for] { margin-bottom: var(--s-4); }

