/* =======================================================================
   DR-329 — App shell: sidebar + topbar + view wrap + dual credit pills
   Lifted from the Claude Design prototype (styles/app.css) and pruned
   to the parts the production app actually uses.
   ======================================================================= */

/* The shell layout ONLY engages when body has .app-shell-on (authenticated
   dashboard). Anonymous landing/login/etc keep their existing layout.
   Atmosphere (radial gradients + grid) is provided by the existing
   .bg-atmosphere divs already in index.html — no extra ::before rule. */

body[data-shell-page] > .topbar.app-topbar,
body[data-shell-page] .view-wrap > .topbar.app-topbar,
body[data-shell-page] > main > .mode-tabs.tab-bar,
body[data-shell-page] .view-wrap .mode-tabs.tab-bar {
  display: none !important;
}

.app-shell-on .app-root {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
@media (max-width: 960px) {
  .app-shell-on .app-root { grid-template-columns: 1fr; }
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.app-shell-on .app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--line-1);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
@media (max-width: 960px) {
  .app-shell-on .app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 280ms var(--ease);
  }
  .app-shell-on .app-sidebar.open { transform: translateX(0); }
  .app-shell-on .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 39;
    opacity: 0; pointer-events: none;
    transition: opacity 200ms var(--ease);
  }
  .app-shell-on .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
}

.app-shell-on .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--line-1);
  color: var(--fg-0);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  text-decoration: none;
}
.app-shell-on .sidebar-brand svg { flex-shrink: 0; }

.app-shell-on .sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4) 10px var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.app-shell-on .sidebar-nav::-webkit-scrollbar { width: 6px; }
.app-shell-on .sidebar-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.app-shell-on .nav-group { display: flex; flex-direction: column; gap: 2px; }
.app-shell-on .nav-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 6px 10px 4px;
}
.app-shell-on .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--fg-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 180ms var(--ease);
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
  position: relative;
  width: 100%;
}
.app-shell-on .nav-item svg { flex-shrink: 0; opacity: 0.7; transition: opacity 180ms var(--ease); }
.app-shell-on .nav-item:hover { background: var(--bg-3); color: var(--fg-0); }
.app-shell-on .nav-item:hover svg { opacity: 1; }
/* (Motion Control visual pass) Premium active nav — a "designed" highlighted
   state: a subtle amber gradient wash + a hairline inset amber border (the
   pill), a brighter amber icon, bolder label, and a stronger glowing left
   accent bar. Clearly distinct from hover (plain bg-3, no border/glow). */
.app-shell-on .nav-item.active {
  background:
    linear-gradient(90deg, rgba(255, 179, 0, 0.15), rgba(255, 179, 0, 0.035) 62%, transparent),
    var(--bg-3);
  color: var(--fg-0);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 179, 0, 0.22);
}
.app-shell-on .nav-item.active svg { opacity: 1; color: var(--amber-bright); }
.app-shell-on .nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px; top: 6px; bottom: 6px;
  width: 3px;
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-deep));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px 1px var(--amber-glow);
}
/* Wash section keeps the same premium treatment in its red accent. */
.app-shell-on .nav-item.wash.active {
  background:
    linear-gradient(90deg, rgba(239, 72, 72, 0.15), rgba(239, 72, 72, 0.035) 62%, transparent),
    var(--bg-3);
  box-shadow: inset 0 0 0 1px rgba(239, 72, 72, 0.22);
}
.app-shell-on .nav-item.wash.active svg { color: var(--spoof-bright); }
.app-shell-on .nav-item.wash.active::before {
  background: linear-gradient(180deg, var(--spoof-bright), var(--spoof-deep));
  box-shadow: 0 0 10px 1px var(--spoof-glow);
}

.app-shell-on .nav-item .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-4);
  border: 1px solid var(--line-2);
  color: var(--fg-3);
}
.app-shell-on .nav-item .badge.new { background: var(--amber-soft); border-color: rgba(255,179,0,0.3); color: var(--amber); }

.app-shell-on .sidebar-foot {
  padding: var(--s-3) 10px var(--s-4);
  border-top: 1px solid var(--line-1);
}
.app-shell-on .sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  cursor: pointer;
  transition: background 200ms var(--ease);
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.app-shell-on .sidebar-user:hover { background: var(--bg-4); }
.app-shell-on .sidebar-user .ava {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep));
  color: #000; font-weight: 600; font-size: 11px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.app-shell-on .sidebar-user .ident { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.app-shell-on .sidebar-user .name { font-size: 13px; color: var(--fg-0); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell-on .sidebar-user .email { font-size: 11px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── App topbar ──────────────────────────────────────────────────────── */
.app-shell-on .app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-shell-on .app-topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(8,8,11,0.88);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-bottom: 1px solid var(--line-1);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--s-5);
  gap: var(--s-3);
}
.app-shell-on .app-topbar .menu-btn { display: none; }
@media (max-width: 960px) {
  .app-shell-on .app-topbar .menu-btn {
    display: grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--bg-3); border: 1px solid var(--line-2);
    color: var(--fg-1); cursor: pointer;
  }
}
.app-shell-on .app-topbar .crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--fg-2); font-weight: 500;
  flex: 1; min-width: 0;
}
.app-shell-on .app-topbar .crumbs .here { color: var(--fg-0); }
.app-shell-on .app-topbar .crumbs .sep { color: var(--fg-4); }

.app-shell-on .topbar-spacer { flex: 1; }
.app-shell-on .topbar-actions { display: flex; align-items: center; gap: 8px; }
.app-shell-on .topbar-actions #logoutBtn {
  white-space: nowrap;
  min-width: 76px;
  text-align: center;
}

/* Credit pills (dual system) */
.credit-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-1);
  cursor: pointer;
  transition: all 200ms var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.credit-pill:hover { background: var(--bg-3); border-color: var(--line-2); }
.credit-pill .ball {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.credit-pill .lbl { color: var(--fg-3); font-size: 11px; }
.credit-pill .num { color: var(--fg-0); font-weight: 600; }
.credit-pill.spoof { background: var(--spoof-soft); border-color: rgba(239,72,72,0.22); }
.credit-pill.spoof .ball { background: var(--spoof); box-shadow: 0 0 8px var(--spoof-glow); }
.credit-pill.spoof .lbl { color: rgba(239,72,72,0.7); }
.credit-pill.spoof .num { color: var(--spoof-bright); }
.credit-pill.creator { background: var(--amber-soft); border-color: rgba(255,179,0,0.22); }
.credit-pill.creator .ball { background: var(--amber); box-shadow: 0 0 8px var(--amber-glow); }
.credit-pill.creator .lbl { color: rgba(255,179,0,0.75); }
.credit-pill.creator .num { color: var(--amber-bright); }
.credit-pill.loading .num { color: var(--fg-3); }
@media (max-width: 720px) {
  .credit-pill .lbl { display: none; }
}

/* Topbar sign-out — a real text+icon button sized to match the credit
   pills beside it (same height/base/hover), so "Sign out" never wraps. */
.topbar-signout {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  color: var(--fg-2);
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: all 180ms var(--ease);
}
.topbar-signout .icon { width: 15px; height: 15px; color: var(--fg-3); transition: color 180ms var(--ease); }
.topbar-signout:hover { background: var(--bg-3); border-color: var(--line-2); color: var(--fg-0); }
.topbar-signout:hover .icon { color: var(--fg-1); }
.topbar-signout:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
/* Collapse to an icon-only button on narrow screens — mirrors how the
   credit pills hide their .lbl at the same breakpoint. */
@media (max-width: 720px) {
  .topbar-signout span { display: none; }
  .topbar-signout { width: 32px; padding: 0; justify-content: center; }
}

/* ── View area ───────────────────────────────────────────────────────── */
.app-shell-on .view-wrap {
  padding: var(--s-5) var(--s-5) var(--s-9);
  max-width: var(--view-max);
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 600px) {
  .app-shell-on .view-wrap { padding: var(--s-4) var(--s-4) var(--s-8); }
}

/* View header */
.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  flex-wrap: wrap;
}
.view-head .title { display: flex; flex-direction: column; gap: 6px; }
.view-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.025em;
  font-weight: 600;
  color: var(--fg-0);
}
.view-head p {
  margin: 0;
  color: var(--fg-2);
  font-size: 14.5px;
  max-width: 560px;
}
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Hide the legacy top tabbar when the new shell is on (keeps the buttons
   in the DOM so existing controllers continue to wire click handlers). */
.app-shell-on .mode-tabs.tab-bar { display: none !important; }
.app-shell-on .nav-rail { display: none !important; }
.app-shell-on .topbar { display: none !important; }
.app-shell-on .topbar-shell { display: none !important; }

/* The mode-panel sections retain their existing IDs and content; we only
   adjust their spacing inside the new view-wrap. */
.app-shell-on .mode-panel.view {
  padding-top: 0;
}

/* (DR-822) Kill the top "dead band". The legacy <main class="container app-main">
   still hosts the old generation-suite panels inside the new shell, but its
   residual vertical padding (~32px top / 96px bottom) rendered a ~128px empty
   band ABOVE every new mode-panel — so Dashboard / Hive Flow / History / Billing
   floated mid-page (read as sparse/unfinished), while the legacy Image-Gen panel
   (nested INSIDE it) started at a different offset. Zeroing it under the shell
   makes every view's header sit flush beneath the 56px topbar and start at the
   SAME offset. The outer #appViewWrap already supplies the page's top/bottom
   breathing room (24px / 96px). Tag selector `main.app-main` targets only the
   legacy wrapper — the new shell main is a <div>, so its flex layout is untouched. */
.app-shell-on main.app-main {
  padding-top: 0;
  padding-bottom: 0;
}
/* (DR-822 P3D) The Admin page uses a standalone <main class="container"> (not
   .app-main), so the dead-band fix above didn't reach it — it kept the legacy
   .container 32px top / 80px bottom padding + 920px cap. Scoped to the admin
   body so its .page-head sits flush under the topbar and the content fills the
   shell view-max like every other surface. Does not touch the marketing pages
   (no .app-shell-on) or the index legacy main (.container.app-main). */
.app-shell-on[data-shell-page="admin"] main.container {
  padding-top: 0;
  padding-bottom: 0;
  max-width: var(--view-max);
}

/* Sidebar item icons inherit currentColor for hover swap */
.app-shell-on .nav-item svg path,
.app-shell-on .nav-item svg circle,
.app-shell-on .nav-item svg rect,
.app-shell-on .nav-item svg polyline,
.app-shell-on .nav-item svg polygon,
.app-shell-on .nav-item svg line {
  stroke: currentColor;
}

/* =====================================================================
   Billing page (DR-329 Phase UI-3)
   ===================================================================== */
.billing-balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
@media (max-width: 720px) { .billing-balances { grid-template-columns: 1fr; } }
.billing-balance-card {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.billing-balance-card.creator { border-color: rgba(255,179,0,0.25); background: linear-gradient(180deg, rgba(255,179,0,0.04), var(--bg-2)); }
.billing-balance-card.spoofer { border-color: rgba(239,72,72,0.22); background: linear-gradient(180deg, rgba(239,72,72,0.04), var(--bg-2)); }
.bb-label {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--fg-3);
}
.bb-dot { width: 9px; height: 9px; border-radius: 50%; }
.creator-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber-glow); }
.spoof-dot { background: var(--spoof); box-shadow: 0 0 8px var(--spoof-glow); }
.bb-val {
  font-size: 36px; font-weight: 600; color: var(--fg-0);
  letter-spacing: -0.025em; line-height: 1; margin: var(--s-1) 0 var(--s-2);
}
.bb-sub { color: var(--fg-2); font-size: 13px; }
.bb-meta { color: var(--fg-3); font-size: 12.5px; margin-top: var(--s-2); }
.bb-actions { margin-top: var(--s-3); }

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
}
.billing-pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
}
.billing-plan-card, .billing-pack-card {
  padding: var(--s-4) var(--s-5);
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.billing-plan-card.is-popular { border-color: rgba(255,179,0,0.4); }
.billing-plan-card .bp-pop {
  position: absolute; top: -10px; right: 12px;
  background: var(--amber); color: #000;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 999px;
}
.bp-name { font-weight: 600; color: var(--fg-0); font-size: 14px; }
.bp-price {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--fg-0);
}
.bp-period { font-size: 13px; font-weight: 400; color: var(--fg-3); margin-left: 4px; }
.bp-credits { color: var(--fg-2); font-size: 13px; }
.bp-aud { color: var(--fg-3); font-size: 12.5px; margin-top: 2px; }
/* (DR-681) Per-plan feature list on Creator plan cards + included-tools
   chips on Spoofer cards. Markers are CSS ::before glyphs (check / cross,
   no emoji). Mirrors the public pricing page so both surfaces show the
   same backend-derived tier breakdown. */
.bp-feats {
  list-style: none;
  margin: 4px 0 2px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.bp-feat {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 7px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--fg-1);
}
.bp-feat::before {
  content: "\2713"; /* check mark */
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--green);
}
.bp-feat.off { color: var(--fg-3); }
.bp-feat.off::before { content: "\2715"; color: var(--fg-3); } /* cross */
.bp-feat-note {
  width: 100%;
  margin-left: 16px;
  font-size: 11.5px;
  color: var(--amber-bright);
}
.bp-includes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 2px 0;
}
.bp-include-chip {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--fg-2);
}
.billing-pack-card.is-unavailable { opacity: 0.6; }
.billing-plan-card .btn, .billing-pack-card .btn { align-self: flex-start; margin-top: var(--s-2); }

.form-select-sm {
  height: 32px;
  padding: 0 10px;
  background: var(--bg-3);
  color: var(--fg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
}

/* =====================================================================
   Library page (DR-329 Phase UI-4)
   ===================================================================== */
.lib-subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-1);
  margin-bottom: var(--s-4);
}
.lib-subtab {
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.lib-subtab:hover { color: var(--fg-0); }
.lib-subtab.active { color: var(--fg-0); border-bottom-color: var(--amber); }

.lib-filters {
  display: flex; gap: var(--s-2);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-3);
}
.lib-card {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease);
  display: flex; flex-direction: column;
}
.lib-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.lib-media {
  position: relative;
  background: var(--bg-3);
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.lib-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.lib-thumb-placeholder {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  color: var(--fg-3); font-family: var(--font-mono);
  font-size: 13px; letter-spacing: 0.06em;
}
.lib-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.lib-badge.spoofer {
  color: #fff;
  background: rgba(239,72,72,0.78);
}
.lib-save {
  position: absolute; top: 8px; right: 8px;
  min-width: 48px; height: 30px;
  padding: 0 10px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  transition: transform 200ms var(--ease), color 200ms var(--ease);
}
.lib-save:hover { transform: scale(1.08); }
.lib-save[data-saved="1"] { color: var(--amber); }
.lib-meta {
  padding: var(--s-3) var(--s-4) var(--s-4);
  display: flex; flex-direction: column; gap: 4px;
  flex: 1;
}
.lib-title {
  font-size: 13.5px; color: var(--fg-0); font-weight: 500;
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.lib-sub {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--fg-3);
  margin-top: 2px;
}
.lib-credits { font-family: var(--font-mono); }
.lib-actions {
  display: flex; gap: 6px;
  margin-top: var(--s-2);
}
.lib-actions .btn { flex: 0 0 auto; }
.lib-pager { margin-top: var(--s-4); display: flex; justify-content: center; }

/* LoRA card variant */
.lora-card .lib-media-lora {
  background: linear-gradient(135deg, var(--amber-soft), rgba(255,179,0,0.02));
  display: grid; place-items: center;
}
.lora-card .lora-thumb {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep));
  color: #000;
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 700;
  display: grid; place-items: center;
  overflow: hidden;
}
/* (DR-329) When the LoRA has a saved checkpoint preview image, the
   gradient background is replaced by the actual image. The container
   keeps its circular clip via overflow: hidden + border-radius above. */
.lora-card .lora-thumb.has-image {
  background: var(--bg-3);
  color: transparent;
}
.lora-card .lora-thumb .lora-thumb-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ----------------------------------------------------------------------
   (DR-730) Saved Model Images — reusable reference-photo folders.
   Folder grid + folder detail (multi-upload, image grid, cover/delete).
   Reuses .lib-grid / .lib-card / .lib-media / .lib-meta primitives; the
   .mi-* classes below add only what's specific to this page.
   --------------------------------------------------------------------- */
.mi-toolbar {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.mi-grid { margin-top: var(--s-2); }

/* Folder card cover */
.mi-folder-media { cursor: pointer; }
.mi-folder-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.mi-folder-cover-empty {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--amber-soft), rgba(255,179,0,0.02));
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 34px; font-weight: 700;
  text-transform: uppercase;
}
.mi-folder-media:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

/* Empty state (no folders / no images) */
.mi-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  text-align: center;
  padding: var(--s-7) var(--s-4);
}
.mi-empty-title { color: var(--fg-0); font-size: 16px; font-weight: 600; }
.mi-empty-sub { color: var(--fg-3); font-size: 13.5px; max-width: 460px; line-height: 1.5; }

/* Folder detail header */
.mi-folder-head {
  display: flex; align-items: flex-start; gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.mi-back { flex: 0 0 auto; }
.mi-folder-title { flex: 1 1 240px; min-width: 0; }
.mi-folder-title h2 {
  margin: 0; font-size: 20px; font-weight: 600; color: var(--fg-0);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mi-folder-title p { margin: 4px 0 0; color: var(--fg-3); font-size: 13px; }
.mi-folder-head-actions { display: flex; gap: var(--s-2); flex: 0 0 auto; }

/* Danger button variant (delete) */
.btn.mi-danger:hover { color: var(--red); border-color: rgba(239,68,68,0.5); }

/* Upload dropzone */
.mi-dropzone {
  display: block;
  border: 1.5px dashed var(--line-3);
  border-radius: var(--r-md);
  background: var(--bg-2);
  padding: var(--s-5);
  text-align: center;
  cursor: pointer;
  transition: border-color 180ms var(--ease), background 180ms var(--ease);
  margin-bottom: var(--s-3);
}
.mi-dropzone:hover { border-color: var(--line-3); background: var(--bg-3); }
.mi-dropzone:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.mi-dropzone-over { border-color: var(--amber); background: var(--amber-soft); }
.mi-dropzone-title { color: var(--fg-1); font-size: 14px; }
.mi-dropzone-sub { color: var(--fg-3); font-size: 12px; margin-top: 4px; }
.mi-link { color: var(--amber); text-decoration: underline; }

/* Upload progress */
.mi-upload-progress { margin-bottom: var(--s-3); }
.mi-upload-bar {
  height: 6px; border-radius: 999px;
  background: var(--bg-4); overflow: hidden;
}
.mi-upload-fill {
  height: 100%; width: 0%;
  background: var(--amber);
  transition: width 160ms linear;
}
.mi-upload-label { color: var(--fg-3); font-size: 12px; margin-top: 6px; }

/* Upload status (accepted / rejected) */
.mi-upload-status { margin-bottom: var(--s-3); font-size: 13px; }
.mi-status-ok { color: var(--green); }
.mi-status-err { color: var(--red); }
.mi-status-list { margin: 4px 0 0; padding-left: 18px; color: var(--fg-2); }

/* Image card */
.mi-image-media { background: var(--bg-3); }
.mi-image-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.mi-cover-badge { background: var(--amber); color: #0a0a0a; }
.mi-image-name {
  font-family: var(--font-mono);
  font-size: 11.5px !important;
  -webkit-line-clamp: 1 !important;
  word-break: break-all;
}

/* (DR-731) Styled modal — replaces native prompt/confirm/alert in the Model
   Images flow. Appended to <body> so it centers in the viewport. Self-contained
   (the app has no generic modal base rule), scoped under .mi-modal-root. */
.mi-modal-root {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  padding: var(--s-4);
}
.mi-modal-root[hidden] { display: none; }
.mi-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 4, 8, 0.72);
  backdrop-filter: blur(2px);
}
.mi-modal-card {
  position: relative;
  width: 100%; max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: 0 24px 60px -12px rgba(0,0,0,0.6);
  animation: fadeUp 240ms var(--ease-out) both;
}
.mi-modal-title { margin: 0 0 8px; font-size: 17px; font-weight: 600; color: var(--fg-0); }
.mi-modal-msg { margin: 0 0 var(--s-4); font-size: 13.5px; line-height: 1.5; color: var(--fg-2); }
.mi-modal-input {
  width: 100%; height: 42px; padding: 0 13px;
  background: var(--bg-3); color: var(--fg-0);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  font: inherit; font-size: 14px; outline: none;
  transition: border-color 160ms var(--ease);
}
.mi-modal-input:focus { border-color: var(--amber); }
.mi-modal-err {
  margin-top: 10px; font-size: 12.5px;
  color: var(--spoof-bright);
  background: var(--spoof-soft);
  border: 1px solid rgba(239,72,72,0.25);
  border-radius: var(--r-sm); padding: 8px 11px;
}
.mi-modal-err[hidden] { display: none; }
.mi-modal-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-4); }
.mi-modal-danger { background: var(--spoof); box-shadow: 0 0 0 1px rgba(239,72,72,0.4) inset, 0 8px 24px -8px rgba(239,72,72,0.45); color: #fff; }
.mi-modal-danger:hover { background: var(--spoof-bright); box-shadow: 0 0 0 1px rgba(239,72,72,0.5) inset, 0 14px 28px -8px rgba(239,72,72,0.55); }

/* (DR-329) Image Generation: per-prompt rows + Add prompt button. */
.img-gen-prompt-rows {
  display: flex; flex-direction: column;
  gap: var(--s-3);
}
.img-gen-prompt-row {
  position: relative;
}
.img-gen-prompt-input {
  display: block;
  width: 100%;
  resize: vertical;
  padding-right: 36px; /* room for the × button when it shows */
}
.img-gen-prompt-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--fg-2);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.img-gen-prompt-remove:hover {
  background: var(--bg-1);
  color: var(--fg-0);
}
.img-gen-prompt-tools {
  display: flex; align-items: center; gap: var(--s-3);
  margin-top: var(--s-2);
}

/* (DR-329) Image Generation: selected-LoRA chip. */
.img-gen-lora-chip {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  margin-top: var(--s-2);
  max-width: max-content;
}
.img-gen-lora-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep));
  color: #000;
  font-family: var(--font-mono);
  font-size: 14px; font-weight: 700;
  display: grid; place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.img-gen-lora-avatar.has-image {
  background: var(--bg-2);
  color: transparent;
}
.img-gen-lora-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.img-gen-lora-chip-meta {
  display: flex; flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.img-gen-lora-chip-name {
  font-size: 13.5px; font-weight: 500;
  color: var(--fg-0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-gen-lora-chip-trigger {
  font-size: 11.5px;
  color: var(--amber-bright);
}

/* (DR-329) Make the chip clickable (re-opens the picker modal). The
   .img-gen-lora-chip element is a <button> now — strip default button
   chrome so it still reads as a chip. */
button.img-gen-lora-chip {
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  width: auto;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
button.img-gen-lora-chip:hover {
  border-color: var(--amber);
  background: var(--bg-2);
}
.img-gen-lora-chip-change {
  margin-left: var(--s-2);
  color: var(--fg-3);
  flex: 0 0 auto;
}
button.img-gen-lora-chip:hover .img-gen-lora-chip-change {
  color: var(--amber-bright);
}

/* (DR-329) Empty-state trigger button — replaces the <select> when no
   LoRA is selected. Same height + chrome as a form input so the field
   row reads consistently. */
.img-gen-lora-trigger {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--fg-1);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.img-gen-lora-trigger:hover {
  border-color: var(--amber);
  background: var(--bg-2);
}
.img-gen-lora-trigger-text {
  color: var(--fg-2);
}
.img-gen-lora-trigger-chevron {
  display: inline-flex; align-items: center;
  color: var(--fg-3);
  flex: 0 0 auto;
}

/* (DR-329) LoRA picker modal — sibling of #loraConfirmModalRoot in
   the DOM. Reuses the .lora-modal-root + .lora-modal-backdrop /
   .lora-modal-card shell (positioning rules duplicated here because
   the existing CSS scoped them tightly to #loraConfirmModalRoot). */
body #loraPickerModal.lora-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
body #loraPickerModal[hidden] { display: none; }
body #loraPickerModal .lora-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
body #loraPickerModal .lora-modal-card.lora-picker-card {
  position: relative;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  padding: 0;
  background: #1a1a1d;
  color: #f0f0f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lora-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}
.lora-picker-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.lora-picker-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.lora-picker-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg-0);
  border-color: rgba(255, 255, 255, 0.08);
}
.lora-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
  padding: 18px 22px;
  overflow: auto;
  flex: 1 1 auto;
}
@media (max-width: 560px) {
  .lora-picker-grid { grid-template-columns: 1fr; }
}
.lora-picker-section-label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  padding-top: var(--s-2);
}
.lora-picker-section-label:first-child { padding-top: 0; }
.lora-picker-empty {
  grid-column: 1 / -1;
  padding: var(--s-5);
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--r-md);
}
.lora-picker-card {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 12px 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}
.lora-picker-card:hover {
  border-color: var(--amber);
  background: var(--bg-2);
}
.lora-picker-card-selected {
  border-color: var(--amber);
  background: var(--amber-soft);
  box-shadow: 0 0 0 1px var(--amber);
}
.lora-picker-card:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.lora-picker-card-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep));
  color: #000;
  font-family: var(--font-mono);
  font-size: 16px; font-weight: 700;
  display: grid; place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.lora-picker-card-avatar.has-image {
  background: var(--bg-2);
  color: transparent;
}
.lora-picker-card-avatar.is-none {
  background: var(--bg-2);
  color: var(--fg-3);
  border: 1px dashed rgba(255, 255, 255, 0.18);
}
.lora-picker-card-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.lora-picker-card-meta {
  display: flex; flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.lora-picker-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lora-picker-card-trigger {
  font-size: 12px;
  color: var(--amber-bright);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lora-picker-card-trigger.muted { color: var(--fg-3); }
.lora-picker-card-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  flex: 0 0 auto;
}
.lora-picker-foot {
  padding: 0 22px 18px;
  margin: 0;
  flex: 0 0 auto;
}

/* (DR-329) Prevent body scroll while the LoRA picker is open. */
body.lora-modal-open { overflow: hidden; }

/* (DR-695) Motion Control subject-image onboarding modal. Reuses the
   .lora-modal shell; positioning is re-declared scoped to this id (same
   convention as #loraPickerModal / #loraConfirmModalRoot — there is no
   generic .lora-modal-root base rule in the app). Good = green / Bad =
   red, matching the app's positive + warning accents. */
body #genSubjectGuideModal.lora-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
body #genSubjectGuideModal[hidden] { display: none; }
body #genSubjectGuideModal .lora-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
}
body #genSubjectGuideModal .mcg-card {
  position: relative;
  width: calc(100% - 32px);
  max-width: 860px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: var(--s-6);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.mcg-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg-3);
  color: var(--fg-2);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.mcg-close:hover { color: var(--fg-0); border-color: var(--line-3); }
.mcg-head { margin-bottom: var(--s-5); padding-right: 40px; }
.mcg-head h3 {
  margin: 0 0 6px;
  font-size: 20px; letter-spacing: -0.02em;
  color: var(--fg-0);
}
.mcg-sub {
  margin: 0;
  font-size: 13.5px; line-height: 1.45;
  color: var(--fg-2);
  max-width: 62ch;
}
.mcg-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
.mcg-col {
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.mcg-col-good {
  border-color: rgba(46, 182, 125, 0.32);
  background: linear-gradient(180deg, rgba(46, 182, 125, 0.05), transparent 60%);
}
.mcg-col-bad {
  border-color: rgba(239, 72, 72, 0.30);
  background: linear-gradient(180deg, rgba(239, 72, 72, 0.05), transparent 60%);
}
.mcg-col-head { margin-bottom: var(--s-3); }
.mcg-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 999px;
}
.mcg-badge::before { font-weight: 700; }
.mcg-badge-good { background: rgba(46, 182, 125, 0.14); color: var(--green); }
.mcg-badge-good::before { content: "\2713"; }
.mcg-badge-bad { background: rgba(239, 72, 72, 0.14); color: var(--spoof-bright); }
.mcg-badge-bad::before { content: "\2715"; }
.mcg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}
.mcg-shot {
  position: relative;
  margin: 0;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
}
.mcg-shot img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.mcg-shot::after {
  position: absolute;
  top: 6px; right: 6px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.mcg-shot-good::after { content: "\2713"; background: var(--green); color: #06281b; }
.mcg-shot-bad::after { content: "\2715"; background: var(--spoof); color: #fff; }
.mcg-list {
  list-style: none;
  margin: var(--s-3) 0 0;
  padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.mcg-list li {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12.5px; line-height: 1.35;
  color: var(--fg-1);
}
.mcg-list li::before { flex: 0 0 auto; font-weight: 700; }
.mcg-list-good li::before { content: "\2713"; color: var(--green); }
.mcg-list-bad li::before { content: "\2715"; color: var(--spoof-bright); }
.mcg-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line-1);
  flex-wrap: wrap;
}
.mcg-dismiss {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--fg-2);
  cursor: pointer;
}
.mcg-dismiss input { accent-color: var(--amber); }
@media (max-width: 720px) {
  body #genSubjectGuideModal .mcg-cols { grid-template-columns: 1fr; }
}

/* (DR-703) Compliance/terms modal. Uses the same .lora-modal shell as the
   other app modals but never had scoped CSS, so it rendered unstyled.
   Same per-id scoping convention as #loraPickerModal / #genSubjectGuideModal
   (the app has no generic .lora-modal-root base rule). */
body #genTermsModal.lora-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
body #genTermsModal[hidden] { display: none; }
body #genTermsModal .lora-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
}
body #genTermsModal .lora-modal-card {
  position: relative;
  width: calc(100% - 32px);
  max-width: 440px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: var(--s-6);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
body #genTermsModal .lora-modal-card h3 {
  margin: 0 0 var(--s-3);
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--fg-0);
}
body #genTermsModal .lora-modal-card p {
  margin: 0;
  color: var(--fg-2);
  font-size: 13.5px;
  line-height: 1.5;
}
body #genTermsModal .lora-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-5);
}

/* Dashboard page (DR-329 v2) */
.dashboard-content { display: flex; flex-direction: column; gap: var(--s-5); }
/* (DR-822) Shared page-header band — one consistent hero rhythm flush under the
   topbar. Introduced as the Dashboard adopts it; reused by other views next. */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-5); flex-wrap: wrap; margin-bottom: var(--s-6);
}
.page-head-main { min-width: 0; }
.page-head .page-title {
  margin: 8px 0 0; font-size: clamp(26px, 3vw, 34px); letter-spacing: -0.03em;
  font-weight: 600; color: var(--fg-0); line-height: 1.04;
}
.page-head .page-sub { margin: 10px 0 0; color: var(--fg-2); font-size: 14.5px; max-width: 580px; line-height: 1.5; }
.page-head-cta { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; padding-top: var(--s-2); }
.page-head-cta .btn .icon { width: 18px; height: 18px; }
/* (Motion Control refinement) Generate-suite page-head as a contained premium
   header panel. The amber glow is now the panel's OWN background (top-right
   corner) clipped to its rounded box via overflow:hidden — so it reads as a
   glowing panel corner that fades inward, with NO stray hard clip line on the
   page background. (The previous ::before glow overflowed the header and was
   cut off by the content edge near "Open history".) Shared by Image Edit /
   Video from Image / Motion Control; content sits above the glow via z-index. */
.app-shell-on [data-mode-panel="generate-suite"] .page-head {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5) calc(var(--s-5) + 2px);
  background:
    radial-gradient(150% 175% at 100% 0%, rgba(255, 179, 0, 0.11), transparent 50%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
}
.app-shell-on [data-mode-panel="generate-suite"] .page-head-main,
.app-shell-on [data-mode-panel="generate-suite"] .page-head-cta {
  position: relative;
  z-index: 1;
}
.app-shell-on [data-mode-panel="generate-suite"] .page-head .page-title {
  font-size: clamp(28px, 3.2vw, 38px);
}
/* (Dashboard visual pass) Premium hero — the shared .page-head turned into a
   glowing panel with a decorative amber hex/grid on the right (CSS-only) and a
   gradient on the name. Content sits above the art via z-index. */
.dash-hero {
  position: relative; overflow: hidden;
  margin-bottom: var(--s-5);
  padding: var(--s-6) var(--s-6) calc(var(--s-6) + 2px);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background:
    radial-gradient(135% 150% at 100% 0%, rgba(255,179,0,0.11), transparent 52%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
}
.dash-hero .page-head-main { position: relative; z-index: 2; max-width: 600px; }
.dash-hero .page-head-cta { position: relative; z-index: 2; }
.dash-hero-name {
  background: linear-gradient(92deg, var(--amber-bright) 8%, #c79bff 78%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dash-hero-art {
  position: absolute; z-index: 1; pointer-events: none;
  top: 50%; right: -30px; transform: translateY(-50%);
  width: 340px; height: 340px;
  background: radial-gradient(closest-side, rgba(255,179,0,0.20), rgba(255,179,0,0.05) 46%, transparent 72%);
}
.dash-hero-art::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 104px; height: 118px; transform: translate(-50%, -50%);
  background: linear-gradient(155deg, var(--amber-bright), var(--amber-deep));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  box-shadow: 0 0 56px rgba(255,179,0,0.45), inset 0 0 28px rgba(255,255,255,0.16);
}
.dash-hero-art::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,179,0,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,179,0,0.10) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask: radial-gradient(closest-side, #000, transparent 68%);
  mask: radial-gradient(closest-side, #000, transparent 68%);
}
@media (max-width: 980px) { .dash-hero-art { display: none; } }
.dash-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
@media (max-width: 900px) { .dash-stat-strip { grid-template-columns: repeat(2, 1fr); } }
.dash-stat {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.dash-stat.amber { border-color: rgba(255,179,0,0.22); background: linear-gradient(180deg, rgba(255,179,0,0.04), var(--bg-2)); }
.dash-stat.spoof { border-color: rgba(239,72,72,0.22); background: linear-gradient(180deg, rgba(239,72,72,0.04), var(--bg-2)); }
/* (Dashboard visual pass) Per-card accent + glowing icon badge (top-right),
   matching the target comp: Creator=amber, Spoofer=red, Recent usage=violet,
   Trained=blue. Informational cards (not clickable) so no hover lift. */
.dash-stat.violet { border-color: rgba(167,139,250,0.24); background: linear-gradient(180deg, rgba(167,139,250,0.05), var(--bg-2)); }
.dash-stat.blue { border-color: rgba(79,139,255,0.24); background: linear-gradient(180deg, rgba(79,139,255,0.05), var(--bg-2)); }
.dash-stat-icon {
  position: absolute; top: var(--s-4); right: var(--s-4);
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-3);
}
.dash-stat-icon .icon { width: 20px; height: 20px; }
.dash-stat.amber .dash-stat-icon { color: var(--amber); background: var(--amber-soft); border-color: rgba(255,179,0,0.30); box-shadow: 0 0 20px rgba(255,179,0,0.18); }
.dash-stat.spoof .dash-stat-icon { color: var(--spoof-bright); background: var(--spoof-soft); border-color: rgba(239,72,72,0.30); box-shadow: 0 0 20px rgba(239,72,72,0.20); }
.dash-stat.violet .dash-stat-icon { color: var(--violet); background: rgba(167,139,250,0.10); border-color: rgba(167,139,250,0.32); box-shadow: 0 0 20px rgba(167,139,250,0.20); }
.dash-stat.blue .dash-stat-icon { color: var(--blue); background: rgba(79,139,255,0.10); border-color: rgba(79,139,255,0.32); box-shadow: 0 0 20px rgba(79,139,255,0.20); }
/* keep value/label clear of the badge */
.dash-stat-lbl, .dash-stat-val, .dash-stat-sub { padding-right: 46px; }
.dash-stat-metrics { padding-right: 0; }
.dash-stat-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: var(--s-2);
}
.dash-stat-val {
  font-size: 28px; font-weight: 600; color: var(--fg-0);
  letter-spacing: -0.025em; line-height: 1;
}
.dash-stat-sub { color: var(--fg-2); font-size: 12.5px; margin-top: var(--s-2); }
.dash-quick-section .dash-quick-grid { margin-bottom: 0; }

.dash-balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
@media (max-width: 720px) { .dash-balances { grid-template-columns: 1fr; } }
.dash-balance {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.dash-balance.creator { border-color: rgba(255,179,0,0.22); background: linear-gradient(180deg, rgba(255,179,0,0.04), var(--bg-2)); }
.dash-balance.spoofer { border-color: rgba(239,72,72,0.22); background: linear-gradient(180deg, rgba(239,72,72,0.04), var(--bg-2)); }
.dash-balance-lbl {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-3);
}
.dash-balance-num {
  font-size: 32px; font-weight: 600; color: var(--fg-0);
  letter-spacing: -0.025em; margin-top: var(--s-2); line-height: 1;
}
.dash-balance-sub { color: var(--fg-2); font-size: 13px; margin-top: var(--s-2); }

.dash-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s-3);
}
.dash-quick {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease), background 180ms var(--ease), box-shadow 180ms var(--ease);
  display: flex; align-items: center; gap: var(--s-3);
  position: relative;
  font: inherit; color: inherit;
}
.dash-quick:hover { transform: translateY(-2px); background: var(--bg-3); box-shadow: 0 10px 24px -12px rgba(0,0,0,0.5); }
.dash-quick.amber:hover { border-color: rgba(255,179,0,0.32); }
.dash-quick.spoof:hover { border-color: rgba(239,72,72,0.32); }
.dash-quick-icon {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--fg-2); transition: all 180ms var(--ease);
}
.dash-quick-icon .icon { width: 18px; height: 18px; }
.dash-quick.amber .dash-quick-icon { color: var(--amber); background: var(--amber-soft); border-color: rgba(255,179,0,0.22); }
.dash-quick.spoof .dash-quick-icon { color: var(--spoof); background: var(--spoof-soft); border-color: rgba(239,72,72,0.22); }
.dash-quick.amber:hover .dash-quick-icon { background: rgba(255,179,0,0.14); border-color: rgba(255,179,0,0.42); box-shadow: 0 0 16px rgba(255,179,0,0.20); }
.dash-quick.spoof:hover .dash-quick-icon { background: rgba(239,72,72,0.14); border-color: rgba(239,72,72,0.42); box-shadow: 0 0 16px rgba(239,72,72,0.22); }
.dash-quick-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.dash-quick-title { color: var(--fg-0); font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.dash-quick-sub { color: var(--fg-3); font-size: 12px; }
.dash-quick-arrow { flex: 0 0 auto; color: var(--fg-4); display: grid; place-items: center; transition: transform 180ms var(--ease), color 180ms var(--ease); }
.dash-quick:hover .dash-quick-arrow { color: var(--fg-2); transform: translateX(2px); }

.dash-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s-3);
}
.dash-recent-card {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  text-align: left; font: inherit; color: inherit;
  padding: 0;
  /* (DR-329 dashboard bug) Establish a positioned containing block so
     the workflow `.lib-badge` (rendered with inline
     `position:absolute;top:8px;left:8px`) anchors to the card instead
     of escaping all the way up to the nearest positioned ancestor
     (.app-root). Without this every recent-activity badge stacked at
     the top-left of the layout, producing the stray "Image Edit /
     Image Generation / ..." overlay above the Dashboard heading. */
  position: relative;
}
.dash-recent-card { transition: transform 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease); }
.dash-recent-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 10px 22px -14px rgba(0,0,0,0.55); }
.dash-recent-thumb {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; background: var(--bg-3);
}
.dash-thumb-placeholder {
  display: grid; place-items: center;
  color: var(--fg-3); font-family: var(--font-mono); font-size: 12px;
}
.dash-recent-meta { padding: var(--s-3) var(--s-3) var(--s-3); display: flex; flex-direction: column; gap: 2px; }
.dash-recent-title {
  color: var(--fg-0); font-size: 12.5px; font-weight: 500;
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.dash-recent-sub { color: var(--fg-3); font-size: 11.5px; }

/* Empty state primitive */
.empty {
  background: var(--bg-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: var(--s-7) var(--s-5);
  text-align: center;
  color: var(--fg-2);
  font-size: 14px;
}
.empty-title {
  color: var(--fg-0); font-size: 16px; font-weight: 600;
  margin-bottom: var(--s-2);
}

/* =====================================================================
   DR-329 — Workflow grid card icons (replaces emoji with line icons)
   ===================================================================== */
.app-shell-on .gen-workflow-icon {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--amber-soft);
  border: 1px solid rgba(255,179,0,0.25);
  color: var(--amber);
  margin-bottom: var(--s-3);
}
.app-shell-on .gen-workflow-icon svg { stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* =====================================================================
   DR-329 v3 — Generation Suite as a TRUE two-pane workspace.
   The existing form DOM is treated as the controls pane (left). We
   inject a synthetic preview pane (right) via the dual-region grid
   on the parent panel using CSS subgrid-style positioning.
   ===================================================================== */

/* The result + active-job panels become the right-pane content. We
   stack the three .panel sections inside generate-suite into a grid
   that puts: workflow-form panel + active-job panel + result panel
   side-by-side as "right column", with the rest as "left column". */
.app-shell-on [data-mode-panel="generate-suite"] .gen-subpanel[data-gen-subpanel="workflows"] {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  grid-template-areas:
    "form preview"
    "form preview";
  gap: var(--s-4);
  align-items: start;
}
@media (max-width: 1024px) {
  .app-shell-on [data-mode-panel="generate-suite"] .gen-subpanel[data-gen-subpanel="workflows"] {
    grid-template-columns: 1fr;
    grid-template-areas: "form" "preview";
  }
}

/* (DR-329) #genWorkflowGrid rule removed — the picker grid was deleted
   when the sidebar became the only entry point into a workflow. */

.app-shell-on #genWorkflowFormPanel {
  grid-area: form;
  margin-bottom: 0;
}
.app-shell-on #genActiveJobPanel,
.app-shell-on #genResultPanel {
  grid-area: preview;
  margin-bottom: var(--s-3);
  position: sticky;
  top: 80px;
  align-self: start;
}
/* When BOTH active-job + result panels are present (e.g. polling
   finished mid-render), keep them stacked in the same column. */
.app-shell-on #genActiveJobPanel + #genResultPanel { margin-top: var(--s-3); }

.app-shell-on #genWorkflowFormPanel .panel-h h2 {
  font-size: 20px; letter-spacing: -0.015em;
}
.app-shell-on #genWorkflowFormPanel .form-row { margin-bottom: var(--s-4); }
.app-shell-on .gen-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s-3);
}
.app-shell-on [data-mode-panel="generate-suite"] .gen-form select,
.app-shell-on [data-mode-panel="generate-suite"] .gen-form input {
  flex: 0 0 auto;
  min-height: 42px;
}
.app-shell-on [data-mode-panel="generate-suite"] input[type="file"] {
  flex: 0 0 auto;
  width: 100%;
  min-height: 120px;
  padding: 22px;
  border: 1.5px dashed rgba(255, 179, 0, 0.28);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 150% at 50% 0%, rgba(255, 179, 0, 0.05), transparent 58%),
    linear-gradient(180deg, var(--bg-3), var(--bg-2));
  color: var(--fg-2);
  cursor: pointer;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.app-shell-on [data-mode-panel="generate-suite"] input[type="file"]:hover {
  border-color: rgba(255, 179, 0, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.06);
}
.app-shell-on [data-mode-panel="generate-suite"] input[type="file"]:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}
.app-shell-on [data-mode-panel="generate-suite"] input[type="file"]::file-selector-button {
  border: 1px solid rgba(255,179,0,0.28);
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber-bright);
  font: inherit;
  font-weight: 600;
  padding: 7px 12px;
  margin-right: 10px;
  cursor: pointer;
}
/* (Motion Control visual pass) Premium dropdowns — Resolution + Character
   Orientation (and the other create-suite selects) get a custom amber chevron,
   subtle gradient, and an amber focus ring. Still native <select>s so the
   controller's value read on submit is untouched. */
.app-shell-on [data-mode-panel="generate-suite"] select.form-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--bg-3);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffb300' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: center, right 13px center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--fg-0);
  padding: 0 38px 0 14px;
  font-weight: 500;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.app-shell-on [data-mode-panel="generate-suite"] select.form-select:hover {
  border-color: var(--line-3);
}
.app-shell-on [data-mode-panel="generate-suite"] select.form-select:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}
.app-shell-on .gen-cost-chip {
  font-family: var(--font-mono);
  background: var(--amber-soft);
  border: 1px solid rgba(255,179,0,0.25);
  color: var(--amber-bright);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
/* (DR-822 P2) Prominent cost-aware CTA — the per-workflow Generate button
   ("Generate edit" / "Generate video" / "Generate motion clip", set by
   generation.js) spans the form column full-width, with the existing
   billing-aware cost pill (#genCostChip) + any submit error centered
   beneath it. Layout only — submit/cost/billing logic is untouched. */
.app-shell-on .gen-submit-row {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line-1);
  margin-top: var(--s-5);
}
.app-shell-on .gen-submit-row #genJobSubmitBtn {
  order: 1; width: 100%; min-height: 52px; font-size: 15.5px;
  font-weight: 700; letter-spacing: 0.01em;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-deep));
  box-shadow: 0 8px 24px rgba(255, 179, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), filter 160ms var(--ease);
}
.app-shell-on .gen-submit-row #genJobSubmitBtn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(255, 179, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: brightness(1.03);
}
.app-shell-on .gen-submit-row #genJobSubmitBtn:disabled {
  background: var(--bg-4);
  box-shadow: none;
  color: var(--fg-3);
}
.app-shell-on .gen-submit-row .gen-cost-chip { order: 2; align-self: center; font-size: 13.5px; padding: 6px 16px; }
.app-shell-on .gen-submit-row #genSubmitError {
  order: 3; align-self: center; text-align: center;
}
/* (DR-680) Tier-lock hint — shown above the submit row when the selected
   resolution (or model) is gated to a higher plan. Amber upsell styling,
   deliberately distinct from the red .error submit message: this is a
   "premium feature" nudge, not a failure. The [hidden] override is
   required because the base rule sets display:block, which would
   otherwise beat the user-agent [hidden] { display:none }. */
.app-shell-on .gen-tier-lock-hint {
  display: block;
  margin-top: var(--s-4);
  padding: 10px 14px;
  border: 1px solid rgba(255,179,0,0.28);
  border-left: 3px solid var(--amber-bright);
  border-radius: var(--r-md);
  background: var(--amber-soft);
  color: var(--amber-bright);
  line-height: 1.4;
}
.app-shell-on .gen-tier-lock-hint[hidden] { display: none; }
.app-shell-on .gen-preview-img,
.app-shell-on .gen-preview-vid {
  max-width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
}
/* (Motion Control visual pass) Selected subject / reference thumbnail —
   a refined, contained preview card (amber-tinted border + depth) instead of a
   raw full-width image. Applies to the source-image + motion-upload previews. */
.app-shell-on [data-mode-panel="generate-suite"] .gen-preview-row {
  margin-top: var(--s-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}
.app-shell-on [data-mode-panel="generate-suite"] .gen-preview-row .gen-preview-img {
  max-width: 168px;
  max-height: 200px;
}
.app-shell-on [data-mode-panel="generate-suite"] .gen-preview-row .gen-preview-img,
.app-shell-on [data-mode-panel="generate-suite"] .gen-preview-row .gen-preview-vid {
  border: 1px solid rgba(255, 179, 0, 0.3);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}

/* =====================================================================
   DR-329 — Motion Control template picker.
   Dual-mode UI: "Templates" (built-in clips, default) vs "Pick your own"
   (the existing user-upload flow). The mode toggle is a pill segmented
   control; templates render as 2×2 cards with looping muted previews.
   ===================================================================== */
.app-shell-on .gen-motion-mode-toggle {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  margin-bottom: var(--s-4);
}
.app-shell-on .gen-motion-mode-btn {
  flex: 1 1 0;
  background: transparent;
  color: var(--fg-2);
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-align: center;
  transition: background 180ms var(--ease), color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.app-shell-on .gen-motion-mode-btn.active {
  background: linear-gradient(180deg, rgba(255, 179, 0, 0.16), rgba(255, 179, 0, 0.07));
  color: var(--amber-bright);
  box-shadow: inset 0 0 0 1px rgba(255, 179, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.25);
}
.app-shell-on .gen-motion-mode-btn:not(.active):hover {
  color: var(--fg-0);
}

/* (Motion Control polish) #genMotionTemplatesGrid is the slide VIEWPORT; the
   JS-built .gen-motion-track holds one .gen-motion-page (a 3×3 grid) per page
   and translateX-es between pages for a smooth, no-resize slide. */
.app-shell-on .gen-motion-templates {
  overflow: hidden;
  margin-bottom: var(--s-2);
}
.app-shell-on .gen-motion-track {
  display: flex;
  transition: transform 360ms var(--ease-out);
  will-change: transform;
}
.app-shell-on .gen-motion-page {
  flex: 0 0 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  align-content: start;
}
@media (max-width: 460px) {
  .app-shell-on .gen-motion-page { grid-template-columns: repeat(2, 1fr); }
}
/* (Motion Control visual pass) Premium selectable template cards — resting
   depth, a hover lift, and an elegant active state (amber ring + glow + a ✓
   badge). The label sits as a gradient scrim over the bottom of the clip so it
   reads cleanly without a separate text strip. */
.app-shell-on .gen-motion-template-card {
  position: relative;
  aspect-ratio: 3 / 4;          /* uniform gallery cells (compact, fits 3 rows) */
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: border-color 180ms var(--ease), transform 180ms var(--ease), box-shadow 180ms var(--ease);
}
.app-shell-on .gen-motion-template-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-3);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}
.app-shell-on .gen-motion-template-card:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}
.app-shell-on .gen-motion-template-card.active {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber), 0 10px 28px rgba(255, 179, 0, 0.2);
}
.app-shell-on .gen-motion-template-card.active::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--amber-bright), var(--amber));
  color: #1a1205;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--bg-2), 0 2px 8px rgba(255, 179, 0, 0.45);
}
.app-shell-on .gen-motion-template-vid {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-2);
  pointer-events: none; /* clicks go to the parent button */
}
.app-shell-on .gen-motion-template-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  padding: 22px 11px 9px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55) 45%, rgba(0, 0, 0, 0.82));
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.app-shell-on .gen-motion-template-card.active .gen-motion-template-label {
  color: var(--amber-bright);
}

/* (Motion Control polish) Metadata badges (Hot / Popular / Trending) — premium
   glass/gradient pill, top-LEFT so it never collides with the ✓ (top-right). */
.app-shell-on .gen-motion-badge {
  position: absolute;
  top: 7px; left: 7px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(10, 10, 14, 0.5);
  -webkit-backdrop-filter: blur(7px) saturate(1.3);
  backdrop-filter: blur(7px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.app-shell-on .gen-motion-badge--hot {
  background: linear-gradient(180deg, rgba(255, 99, 71, 0.95), rgba(214, 40, 40, 0.95));
  border-color: rgba(255, 150, 130, 0.55);
}
.app-shell-on .gen-motion-badge--trending {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.95), rgba(124, 92, 240, 0.95));
  border-color: rgba(196, 178, 255, 0.55);
}
.app-shell-on .gen-motion-badge--popular {
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-deep));
  border-color: rgba(255, 210, 120, 0.6);
  color: #1a1205;
}

/* Disabled "Coming soon" filler — completes the 3×3 without looking broken. */
.app-shell-on .gen-motion-soon {
  cursor: default;
  display: grid;
  place-items: center;
  border-style: dashed;
  border-color: var(--line-2);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.014) 0 10px, transparent 10px 20px),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
  box-shadow: none;
}
.app-shell-on .gen-motion-soon:hover { transform: none; border-color: var(--line-2); box-shadow: none; }
.app-shell-on .gen-motion-soon-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--fg-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.app-shell-on .gen-motion-soon-inner svg { opacity: 0.65; }

/* (Motion Control refinement) Template browser pager — premium round arrow
   controls + page dots, shown only when templates span more than one 3×3 page. */
.app-shell-on .gen-motion-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: var(--s-3) 0 var(--s-2);
}
.app-shell-on .gen-motion-arrow {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--fg-1);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease);
}
.app-shell-on .gen-motion-arrow:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber-bright);
  background: var(--amber-soft);
  transform: translateY(-1px);
}
.app-shell-on .gen-motion-arrow:disabled { opacity: 0.35; cursor: default; }
.app-shell-on .gen-motion-dots { display: flex; align-items: center; gap: 7px; }
.app-shell-on .gen-motion-dot {
  width: 7px; height: 7px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--line-3);
  cursor: pointer;
  transition: background 160ms var(--ease), transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.app-shell-on .gen-motion-dot:hover { background: var(--fg-3); }
.app-shell-on .gen-motion-dot.active {
  background: var(--amber);
  transform: scale(1.25);
  box-shadow: 0 0 8px var(--amber-glow);
}

/* (Motion Control refinement) Premium segmented control — Character Orientation.
   The native <select> (#genOrientationSelect, .gen-sr-select) is hidden and
   used only as the value source the submit reads; these buttons drive it. */
.app-shell-on .gen-sr-select { display: none; }
.app-shell-on .gen-segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  min-height: 42px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.app-shell-on .gen-seg-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.app-shell-on .gen-seg-btn:not(.active):hover { color: var(--fg-0); }
.app-shell-on .gen-seg-btn.active {
  background: linear-gradient(180deg, rgba(255, 179, 0, 0.18), rgba(255, 179, 0, 0.08));
  color: var(--amber-bright);
  box-shadow: inset 0 0 0 1px rgba(255, 179, 0, 0.32), 0 1px 4px rgba(0, 0, 0, 0.25);
}
.app-shell-on .gen-seg-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--amber), 0 0 0 3px var(--amber-soft);
}

/* (DR-822 P2) Result empty state. A real .generation-empty element
   (#genResultEmpty — amber icon tile + per-workflow title/copy set by
   generation.js applyWorkflowChrome) replaces the old generic ::after
   text, matching the Image Generation page. Lives in the preview column;
   shown by default and hidden the moment a real preview (active job OR
   result) appears — same proven inverse :has() logic as the old ::after. */
.app-shell-on #genResultEmpty {
  grid-area: preview;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  padding: var(--s-7) var(--s-5);
  position: sticky;
  top: 80px;
  align-self: start;
  margin-bottom: var(--s-3);
}
.app-shell-on [data-mode-panel="generate-suite"] .gen-subpanel[data-gen-subpanel="workflows"]:has(#genActiveJobPanel:not([hidden])) #genResultEmpty,
.app-shell-on [data-mode-panel="generate-suite"] .gen-subpanel[data-gen-subpanel="workflows"]:has(#genResultPanel:not([hidden])) #genResultEmpty {
  display: none;
}
@media (max-width: 1024px) {
  .app-shell-on #genResultEmpty {
    display: none;
  }
}
/* (Motion Control visual pass) Premium empty preview — a larger, glowing icon
   tile with a soft amber halo *centered behind the icon*. Deliberately NOT a
   bottom reflection / "puddle": the bloom is a radial centered on the tile, so
   the panel reads premium and reassuring without the water-like surface. */
.app-shell-on [data-mode-panel="generate-suite"] #genResultEmpty .generation-empty {
  max-width: 420px;
  gap: 8px;
}
.app-shell-on [data-mode-panel="generate-suite"] #genResultEmpty .generation-empty-icon {
  position: relative;
  isolation: isolate;
  width: 88px;
  height: 88px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 179, 0, 0.16), rgba(255, 179, 0, 0.06));
  border: 1px solid rgba(255, 179, 0, 0.32);
  box-shadow: 0 0 0 10px rgba(255, 179, 0, 0.05), 0 12px 40px rgba(255, 179, 0, 0.16);
  margin-bottom: var(--s-4);
}
.app-shell-on [data-mode-panel="generate-suite"] #genResultEmpty .generation-empty-icon::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 179, 0, 0.22), rgba(255, 179, 0, 0.06) 50%, transparent 72%);
}
.app-shell-on [data-mode-panel="generate-suite"] #genResultEmpty .generation-empty-icon .icon {
  width: 40px;
  height: 40px;
}
.app-shell-on [data-mode-panel="generate-suite"] #genResultEmpty .result-placeholder-title {
  font-size: 20px;
}

/* Generation suite sub-tabs (Workflows / History / Account) */
.app-shell-on .gen-subtabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line-1);
  margin-bottom: var(--s-4);
}
.app-shell-on .gen-subtab {
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.app-shell-on .gen-subtab:hover { color: var(--fg-0); }
.app-shell-on .gen-subtab.active { color: var(--fg-0); border-bottom-color: var(--amber); }
.app-shell-on .gen-subpanel { margin-top: var(--s-2); }
.app-shell-on .gen-account-chip { color: var(--fg-2); }
.app-shell-on .gen-beta-banner {
  background: rgba(79, 139, 255, 0.08);
  border: 1px solid rgba(79, 139, 255, 0.2);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--fg-1);
  margin-bottom: var(--s-4);
  font-size: 13px;
}

/* Image Generation page surface inside shell */
.app-shell-on .img-gen-form,
.app-shell-on .img-filter-mode {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
}

/* Direct Create workspaces: sidebar entries open the workflow itself,
   not the generic picker/subtab surface. */
.app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow > .hero,
.app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow #genHeaderPanel {
  display: none;
}
.app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow > .gen-subtabs {
  display: none;
}
.app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow .gen-subpanel[data-gen-subpanel="workflows"] {
  /* (Motion Control refinement) Wider control column so the 3×3 template
     browser has real estate; the preview still takes the larger remaining
     share. Rebalances the prior squeezed-left / empty-right split. */
  grid-template-columns: minmax(380px, 560px) minmax(0, 1fr);
}
/* ============================================================
   (Motion Control polish) Dedicated Motion Control layout — the
   shared form splits into a compact control RAIL (left) + a wide
   template GALLERY (right); the preview keeps the outer right
   column. Resolution / Character Orientation / Generate live in the
   rail so they stay visible regardless of the gallery's height.
   Scoped to .is-motion-control — Image Edit / Video from Image keep
   the single-column form unchanged.
   ============================================================ */
/* The rail reproduces the form's own flex-column rhythm (the form wrapper used
   to provide it directly) so row spacing is unchanged for every workflow. */
.app-shell-on .gen-form-rail { display: flex; flex-direction: column; gap: 18px; }
.app-shell-on [data-mode-panel="generate-suite"].is-motion-control .gen-subpanel[data-gen-subpanel="workflows"] {
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}
.app-shell-on .is-motion-control #genWorkflowForm {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  column-gap: var(--s-5);
  align-items: start;
}
.app-shell-on .is-motion-control .gen-form-rail,
.app-shell-on .is-motion-control .gen-form-gallery { min-width: 0; }
.app-shell-on .is-motion-control .gen-form-gallery .form-row { margin-bottom: 0; }
/* Compact the rail + tighten the header→form gap so Resolution / Orientation /
   Generate clear the fold on standard desktop heights (the gallery lives in its
   own column, so this only affects the controls' density, not the gallery). */
.app-shell-on [data-mode-panel="generate-suite"].is-motion-control .page-head { margin-bottom: var(--s-4); }
.app-shell-on .is-motion-control .gen-form-rail { gap: 13px; }
.app-shell-on .is-motion-control .gen-form-rail input[type="file"] { min-height: 96px; padding: 16px; }
.app-shell-on .is-motion-control .gen-form-rail textarea { min-height: 84px; }

/* =====================================================================
   DR-840 — "Choose from library" affordance + shared Model Images picker.
   ===================================================================== */
.app-shell-on .gen-lib-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.app-shell-on .gen-lib-or { color: var(--fg-3); font-size: 12px; }
.app-shell-on .gen-lib-btn { display: inline-flex; align-items: center; gap: 7px; }
.app-shell-on .gen-lib-btn svg { opacity: 0.85; }
/* "From library" chip shown in the preview after a library pick. */
.app-shell-on .gen-lib-chip {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 10px; padding: 5px 6px 5px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  border: 1px solid rgba(255, 179, 0, 0.28);
  color: var(--amber-bright);
  font-size: 12px; font-weight: 600; max-width: 100%;
}
.app-shell-on .gen-lib-chip svg { flex: 0 0 auto; }
.app-shell-on .gen-lib-chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell-on .gen-lib-chip-x {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; border: 0; cursor: pointer;
  background: rgba(255, 179, 0, 0.16); color: var(--amber-bright);
  font-size: 14px; line-height: 1;
}
.app-shell-on .gen-lib-chip-x:hover { background: rgba(255, 179, 0, 0.3); }
.app-shell-on .gen-lib-loading { margin-top: 10px; }

/* ── Shared asset picker modal (window.AssetPicker) ─────────────────── */
body.asset-picker-open { overflow: hidden; }
.asset-picker-overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(5, 5, 8, 0.66);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.asset-picker-overlay[hidden] { display: none; }
.asset-picker {
  display: flex; flex-direction: column;
  width: min(760px, 100%); max-height: min(82vh, 760px);
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.asset-picker-head { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line-1); }
.asset-picker-title { flex: 1 1 auto; font-size: 15px; font-weight: 600; color: var(--fg-0); }
.asset-picker-back, .asset-picker-close {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid var(--line-2); color: var(--fg-1);
  transition: background 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.asset-picker-close { font-size: 22px; line-height: 1; }
.asset-picker-back:hover, .asset-picker-close:hover { background: var(--bg-3); border-color: var(--line-3); color: var(--fg-0); }
.asset-picker-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; min-height: 220px; }
.asset-picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-1); }
.asset-picker-count { color: var(--fg-3); font-size: 12.5px; }
.asset-picker-actions { display: flex; gap: 8px; }
.asset-picker-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 280px; text-align: center; color: var(--fg-2); }
.asset-picker-empty-ic { color: var(--fg-3); opacity: 0.8; }
.asset-picker-spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--amber); animation: ap-spin 800ms linear infinite; }
@keyframes ap-spin { to { transform: rotate(360deg); } }
.asset-picker-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.asset-picker-folder { display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; text-align: left; transition: border-color 160ms var(--ease), transform 160ms var(--ease); }
.asset-picker-folder:hover { border-color: var(--amber); transform: translateY(-2px); }
.asset-picker-folder-thumb { aspect-ratio: 4 / 3; border-radius: var(--r-sm); overflow: hidden; background: var(--bg-1); display: grid; place-items: center; }
.asset-picker-folder-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-picker-folder-ic { color: var(--fg-3); }
.asset-picker-folder-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.asset-picker-folder-nm { font-size: 13px; font-weight: 600; color: var(--fg-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-picker-folder-ct { font-size: 11.5px; color: var(--fg-3); }
.asset-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
.asset-picker-img { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; padding: 0; transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease); }
.asset-picker-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-picker-img-check { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, 0.4); color: #fff; opacity: 0; transform: scale(0.8); transition: opacity 140ms var(--ease), transform 140ms var(--ease); }
.asset-picker-img.is-selected { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber); }
.asset-picker-img.is-selected .asset-picker-img-check { opacity: 1; transform: scale(1); background: linear-gradient(180deg, var(--amber-bright), var(--amber)); color: #1a1205; }
@media (max-width: 560px) {
  .asset-picker { max-height: 88vh; }
  .asset-picker-folders { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
@media (max-width: 1024px) {
  .app-shell-on .is-motion-control #genWorkflowForm {
    grid-template-columns: 1fr;
    row-gap: var(--s-4);
  }
}
.app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow #genWorkflowFormPanel {
  position: sticky;
  top: 80px;
  align-self: start;
}
/* (DR-329) #genWorkflowBack hide rule removed — the back button itself
   was deleted along with the picker page. */
/* (DR-822 P2) The per-workflow title now lives in the shared .page-head
   (#genPageHead) above the grid, so the form card's own .panel-head title
   ("Workflow") would be a redundant double-header — hide it. The h2
   (#genWorkflowFormTitle) stays in the DOM; generation.js still writes to
   it harmlessly. Scoped to #genWorkflowFormPanel so the active-job /
   result panel heads are unaffected. */
.app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow #genWorkflowFormPanel .panel-head {
  display: none;
}
/* Only show the shared page-head in the direct-workflow view (the only way
   in via the sidebar). In the legacy subtab-nav view #genHeaderPanel owns
   the header, so suppress the page-head there to avoid two headers. */
.app-shell-on [data-mode-panel="generate-suite"]:not(.is-direct-workflow) #genPageHead {
  display: none;
}

/* Image Generation direct page */
.app-shell-on .image-gen-page .view-head {
  margin-bottom: var(--s-4);
}
.app-shell-on .img-gen-workspace.workflow {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}
.app-shell-on .img-gen-controls {
  min-width: 0;
}
.app-shell-on .img-gen-controls .panel {
  position: sticky;
  top: 80px;
}
.app-shell-on .image-gen-page .img-gen-form {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
}
.app-shell-on .image-gen-page .panel-head .seg {
  margin-left: auto;
}
.app-shell-on .image-gen-page .seg.wrap {
  flex-wrap: wrap;
  border-bottom: 0;
  gap: 6px;
}
.app-shell-on .image-gen-page .seg.wrap .seg-btn {
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg-3);
}
.app-shell-on .image-gen-page .img-gen-field,
.app-shell-on .image-gen-page .img-gen-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.app-shell-on .image-gen-page .img-gen-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s-3);
}
.app-shell-on .image-gen-page textarea,
.app-shell-on .image-gen-page input,
.app-shell-on .image-gen-page select,
.app-shell-on [data-mode-panel="generate-suite"] textarea,
.app-shell-on [data-mode-panel="generate-suite"] input,
.app-shell-on [data-mode-panel="generate-suite"] select {
  width: 100%;
  background: var(--bg-3);
  color: var(--fg-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font: inherit;
}
.app-shell-on .image-gen-page textarea,
.app-shell-on [data-mode-panel="generate-suite"] textarea {
  resize: vertical;
  min-height: 112px;
}
.app-shell-on .image-gen-page .img-gen-label,
.app-shell-on [data-mode-panel="generate-suite"] .form-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.app-shell-on .image-gen-page .img-gen-advanced {
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  padding: var(--s-3);
  background: var(--bg-1);
}
.app-shell-on .image-gen-page .img-gen-advanced summary {
  cursor: pointer;
  color: var(--fg-1);
  font-weight: 600;
  font-size: 13px;
}
.app-shell-on .image-gen-page .img-gen-actions {
  display: flex; flex-direction: column; align-items: stretch;
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line-1);
}
/* (DR-822 P2) Prominent, cost-aware primary CTA: full-width Generate button with
   the (billing-aware) cost pill centered beneath it. Cost text/logic unchanged. */
.app-shell-on .image-gen-page .img-gen-actions #genSubmitBtn { width: 100%; }
.app-shell-on .image-gen-page .img-gen-actions #genCost { align-self: center; }
.app-shell-on .cost-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  border: 1px solid rgba(255,179,0,0.25);
  color: var(--amber-bright);
  font-family: var(--font-mono);
}
.app-shell-on .img-gen-output {
  min-height: 520px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.app-shell-on .img-gen-output .panel-head {
  margin-bottom: var(--s-4);
}
.app-shell-on .result-stage {
  min-height: 430px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  background:
    linear-gradient(180deg, rgba(255,179,0,0.03), transparent 38%),
    var(--bg-1);
  text-align: center;
  padding: var(--s-6);
}
.app-shell-on .result-placeholder-title {
  color: var(--fg-0);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
/* (DR-822 P2) Shared premium empty-state primitive (used by generation pages). */
.app-shell-on .generation-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 380px; margin: 0 auto; }
.app-shell-on .generation-empty-icon {
  width: 52px; height: 52px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: var(--s-2);
  background: var(--amber-soft); border: 1px solid rgba(255,179,0,0.25); color: var(--amber);
}
.app-shell-on .generation-empty-icon .icon { width: 26px; height: 26px; }
.app-shell-on .img-gen-output:has(#genSingleResult:not([hidden])) .img-gen-empty-stage,
.app-shell-on .img-gen-output:has(#genBatchPanel:not([hidden])) .img-gen-empty-stage {
  display: none;
}
.app-shell-on .img-gen-result-panel {
  background: transparent;
  border: 0;
  padding: 0;
}
.app-shell-on .img-gen-result-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.app-shell-on #genSingleImage {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--r-md);
  background: var(--bg-1);
  border: 1px solid var(--line-1);
}
@media (max-width: 1024px) {
  .app-shell-on .img-gen-workspace.workflow,
  .app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow .gen-subpanel[data-gen-subpanel="workflows"] {
    grid-template-columns: 1fr;
  }
  .app-shell-on .img-gen-controls .panel,
  .app-shell-on [data-mode-panel="generate-suite"].is-direct-workflow #genWorkflowFormPanel {
    position: static;
  }
}

/* Train LoRA visual pass */
.app-shell-on [data-mode-panel="train-lora"] > .hero {
  background: transparent;
  border: 0;
  padding: 0;
  margin-bottom: var(--s-5);
}
.app-shell-on [data-mode-panel="train-lora"] > .hero h1 {
  font-size: 28px;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.app-shell-on [data-mode-panel="train-lora"] > .hero p {
  max-width: 720px;
  color: var(--fg-2);
}
.app-shell-on .lora-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
  margin: var(--s-4) 0 var(--s-5);
}
.app-shell-on .lora-stepper-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--fg-3);
}
.app-shell-on .lora-stepper-item.active {
  border-color: rgba(255,179,0,0.32);
  background: linear-gradient(180deg, rgba(255,179,0,0.05), var(--bg-2));
  color: var(--fg-0);
}
.app-shell-on .lora-stepper-item.done {
  color: var(--fg-1);
  border-color: rgba(46,182,125,0.25);
}
.app-shell-on .lora-stepper-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
}
.app-shell-on .lora-stepper-label {
  font-size: 13px;
  font-weight: 600;
}
.app-shell-on [data-mode-panel="train-lora"] #loraWizard {
  overflow: hidden;
}
.app-shell-on [data-mode-panel="train-lora"] .panel-body {
  padding-top: var(--s-1);
}
.app-shell-on [data-mode-panel="train-lora"] .lora-step {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.app-shell-on [data-mode-panel="train-lora"] .lora-step[hidden] {
  display: none !important;
}
.app-shell-on [data-mode-panel="train-lora"] .lora-character-block,
.app-shell-on [data-mode-panel="train-lora"] .lora-character-summary,
.app-shell-on [data-mode-panel="train-lora"] .lora-billing-summary {
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--bg-1);
  padding: var(--s-4);
}
.app-shell-on [data-mode-panel="train-lora"] .form-row {
  gap: var(--s-3);
}
.app-shell-on [data-mode-panel="train-lora"] .lora-image-grid,
.app-shell-on [data-mode-panel="train-lora"] .lora-caption-grid,
.app-shell-on [data-mode-panel="train-lora"] .lora-sample-grid,
.app-shell-on [data-mode-panel="train-lora"] .lora-library-grid {
  gap: var(--s-3);
}
@media (max-width: 800px) {
  .app-shell-on .lora-stepper {
    grid-template-columns: 1fr 1fr;
  }
}

/* Sidebar SVG sizing consistency */
.app-shell-on .nav-item svg { width: 16px; height: 16px; }
.app-shell-on .sidebar-brand svg { width: 22px; height: 22px; }

/* =====================================================================
   DR-329 final parity polish
   ===================================================================== */

.billing-balances-premium .billing-balance-card {
  min-height: 230px;
}
/* (DR-822 P3A) Real credit-composition bar — replaces the old decorative
   .bb-spark sparkline. Segments are flex-sized by the live monthly/top-up
   (or spoofer) values, so the bar actually shows how the balance breaks down;
   the exact figures stay in .bb-sub. */
.billing-credit-bar {
  display: flex; gap: 2px; height: 8px;
  margin: 8px 0 4px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-4);
  border: 1px solid var(--line-1);
}
.bcb-seg { display: block; min-width: 4px; border-radius: 999px; }
.bcb-seg.monthly { background: var(--amber); }
.bcb-seg.topup { background: rgba(255,179,0,0.4); }
.bcb-seg.spoofer { background: var(--spoof); }
.billing-ledger-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin: 0 0 var(--s-5);
}
@media (max-width: 760px) { .billing-ledger-guide { grid-template-columns: 1fr; } }
.ledger-guide-card {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background: var(--bg-2);
}
.ledger-guide-card.creator { border-color: rgba(255,179,0,0.18); }
.ledger-guide-card.spoofer { border-color: rgba(239,72,72,0.2); }
.ledger-guide-card h3 {
  margin: 0 0 4px;
  color: var(--fg-0);
  font-size: 15px;
}
.ledger-guide-card p {
  margin: 0;
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.55;
}
/* (DR-822 P3A) Billing trust row — short, true trust signals (Stripe-secured,
   credits-on-submit, cancel-anytime) between the credit guide and the tabs, to
   support purchase confidence. Calm/factual, not salesy. */
.billing-trust-row {
  display: flex; flex-wrap: wrap; gap: 8px var(--s-5);
  margin: 0 0 var(--s-5);
  padding: 11px var(--s-4);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--bg-2);
}
.billing-trust-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg-2); }
.billing-trust-item svg { width: 15px; height: 15px; color: var(--amber); flex: 0 0 auto; }
.billing-tabs-panel { padding: 0; overflow: hidden; }
/* (DR-329) Inline status banner inside the billing panel — surfaces
   checkout/subscription-gate messages from onActionClick. */
.billing-status {
  margin: var(--s-3) var(--s-4) 0;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.45;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--fg-1);
}
.billing-status[data-type="error"] {
  border-color: rgba(239, 72, 72, 0.32);
  background: rgba(239, 72, 72, 0.08);
  color: var(--spoof-bright);
}
.billing-status[data-type="success"] {
  border-color: rgba(46, 182, 125, 0.32);
  background: rgba(46, 182, 125, 0.08);
  color: var(--green);
}
.billing-tabs {
  display: flex;
  gap: 4px;
  padding: var(--s-3) var(--s-4) 0;
  border-bottom: 1px solid var(--line-1);
  overflow-x: auto;
}
.billing-tab {
  background: transparent;
  color: var(--fg-2);
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.billing-tab:hover { color: var(--fg-0); }
.billing-tab.active {
  color: var(--fg-0);
  border-bottom-color: var(--amber);
}
.billing-tab-body { padding: var(--s-5); }
.billing-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.billing-section-head h2 {
  margin: 0;
  color: var(--fg-0);
  font-size: 22px;
  letter-spacing: -0.02em;
}
.billing-section-head p {
  margin: 0;
  color: var(--fg-2);
  font-size: 13px;
  max-width: 560px;
}
.billing-ledger-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
@media (max-width: 980px) { .billing-ledger-columns { grid-template-columns: 1fr; } }
.panel-h.compact {
  margin-bottom: var(--s-3);
  padding: 0;
}
.billing-pack-card.creator,
.billing-plan-card.creator {
  border-color: rgba(255,179,0,0.16);
}
.billing-pack-card.spoofer,
.billing-plan-card.spoofer {
  border-color: rgba(239,72,72,0.17);
}
.billing-plan-card.spoofer-popular {
  border-color: rgba(239,72,72,0.42);
  box-shadow: 0 0 0 1px rgba(239,72,72,0.12) inset;
}
.billing-plan-card .bp-pop.spoofer-pop {
  background: var(--spoof);
  color: #fff;
}
/* (DR-329 final pricing) Creator middle-tier Most Popular accent —
   yellow to keep Creator visually distinct from Spoofer's red pop. */
.billing-plan-card.creator-popular {
  border-color: rgba(255,179,0,0.42);
  box-shadow: 0 0 0 1px rgba(255,179,0,0.14) inset;
}
.billing-plan-card .bp-pop.creator-pop {
  background: var(--amber);
  color: #1a1102;
}
.bp-config {
  color: var(--fg-3);
  font-size: 12px;
  line-height: 1.45;
}
.billing-config-empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  color: var(--fg-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.billing-config-empty strong { color: var(--fg-0); }
.billing-usage-grid,
.billing-portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
@media (max-width: 760px) {
  .billing-usage-grid,
  .billing-portal-grid { grid-template-columns: 1fr; }
}
.billing-usage-card,
.billing-portal-card {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.billing-usage-card.creator,
.billing-portal-card.creator { border-color: rgba(255,179,0,0.22); }
.billing-usage-card.spoofer,
.billing-portal-card.spoofer { border-color: rgba(239,72,72,0.24); }
.billing-usage-card h3 {
  margin: 0 0 var(--s-4);
  color: var(--fg-0);
  font-size: 16px;
}
.usage-row,
.billing-history-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 10px 0;
  border-top: 1px solid var(--line-1);
  color: var(--fg-2);
  font-size: 13px;
}
.usage-row:first-of-type { border-top: 0; }
.usage-row strong {
  color: var(--fg-0);
  text-align: right;
  font-weight: 600;
}
.billing-history-list {
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: 0 var(--s-5);
  background: var(--bg-2);
}
.billing-history-row div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.billing-history-row strong { color: var(--fg-0); }
.billing-history-row span { color: var(--fg-3); font-size: 12px; }
.billing-history-row code {
  color: var(--amber);
  font-family: var(--font-mono);
}
.billing-portal-card {
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease);
}
.billing-portal-card:hover {
  transform: translateY(-2px);
  background: var(--bg-3);
}
.billing-portal-card span {
  color: var(--fg-0);
  font-weight: 700;
}
.billing-portal-card small {
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.5;
}
.btn.btn-spoofer {
  background: var(--spoof);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(239,72,72,0.42) inset, 0 8px 24px -8px rgba(239,72,72,0.48);
}
.btn.btn-spoofer:hover:not(:disabled) {
  background: var(--spoof-bright);
  box-shadow: 0 0 0 1px rgba(239,72,72,0.5) inset, 0 14px 28px -8px rgba(239,72,72,0.55);
}

/* (DR-822 P2) Real monthly/top-up split bar — replaced the synthetic sparkline. */
.dash-credit-bar {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--bg-1); border: 1px solid var(--line-1); margin-top: var(--s-3);
}
.dash-credit-bar .seg { height: 100%; }
.dash-credit-bar .seg-empty { width: 100%; background: var(--bg-3); }
.dash-credit-bar.creator .seg-monthly { background: var(--amber); }
.dash-credit-bar.creator .seg-topup { background: rgba(255,179,0,0.34); }
.dash-credit-bar.spoof .seg-monthly { background: var(--spoof); }
.dash-credit-bar.spoof .seg-topup { background: rgba(239,72,72,0.34); }
.dash-stat-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--s-3);
}
.dash-metric-pill {
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--fg-2);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11.5px;
}
.dash-activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-3);
  color: var(--fg-2);
  font-size: 13px;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
  margin: 0 0 var(--s-5);
}
@media (max-width: 960px) { .admin-stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .admin-stat-grid { grid-template-columns: 1fr; } }
.admin-stat-card {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
}
.admin-stat-card.creator { border-color: rgba(255,179,0,0.2); }
.admin-stat-card.spoofer { border-color: rgba(239,72,72,0.22); }
.admin-stat-label {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.admin-stat-value {
  color: var(--fg-0);
  font-size: 28px;
  line-height: 1;
  font-weight: 650;
  margin-top: var(--s-3);
}
.admin-stat-sub {
  color: var(--fg-2);
  font-size: 12.5px;
  margin-top: var(--s-2);
}

.app-shell-on [data-mode-panel="video"] .chip.active,
.app-shell-on [data-mode-panel="image"] .chip.active,
.app-shell-on [data-mode-panel="spoofer"] .chip.active {
  border-color: var(--spoof);
  background: var(--spoof-soft);
}
.app-shell-on [data-mode-panel="video"] .chip.active .chip-dot,
.app-shell-on [data-mode-panel="image"] .chip.active .chip-dot,
.app-shell-on [data-mode-panel="spoofer"] .chip.active .chip-dot,
.app-shell-on [data-mode-panel="video"] .chip-filter-btn.is-on .chip-filter-dot,
.app-shell-on [data-mode-panel="image"] .chip-filter-btn.is-on .chip-filter-dot {
  background: var(--spoof);
  border-color: var(--spoof);
}
.app-shell-on [data-mode-panel="video"] .chip-filter-btn.is-on,
.app-shell-on [data-mode-panel="image"] .chip-filter-btn.is-on {
  border-color: rgba(239,72,72,0.55);
  background: var(--spoof-soft);
  color: var(--spoof-bright);
}
.app-shell-on [data-mode-panel="video"] .chip-filter-btn.is-on:hover,
.app-shell-on [data-mode-panel="image"] .chip-filter-btn.is-on:hover {
  border-color: rgba(255,91,91,0.72);
}
.app-shell-on [data-mode-panel="video"] .chip-filter-btn:focus-visible,
.app-shell-on [data-mode-panel="image"] .chip-filter-btn:focus-visible,
.app-shell-on [data-mode-panel="spoofer"] .chip-filter-btn:focus-visible {
  outline-color: var(--spoof);
}
.app-shell-on [data-mode-panel="video"] .chip-strength input[type="range"],
.app-shell-on [data-mode-panel="image"] .chip-strength input[type="range"] {
  background: linear-gradient(to right, #2a2a30 0%, #444 49%, var(--spoof) 50%, #444 51%, #2a2a30 100%);
}
.app-shell-on [data-mode-panel="video"] .chip-strength input[type="range"]::-webkit-slider-thumb,
.app-shell-on [data-mode-panel="image"] .chip-strength input[type="range"]::-webkit-slider-thumb,
.app-shell-on [data-mode-panel="video"] .chip-strength input[type="range"]::-moz-range-thumb,
.app-shell-on [data-mode-panel="image"] .chip-strength input[type="range"]::-moz-range-thumb {
  background: var(--spoof);
}
.app-shell-on [data-mode-panel="video"] .seg-btn.active,
.app-shell-on [data-mode-panel="image"] .seg-btn.active,
.app-shell-on [data-mode-panel="spoofer"] .seg-btn.active {
  background: var(--spoof);
  color: #fff;
}
.app-shell-on [data-mode-panel="video"] .btn.btn-primary,
.app-shell-on [data-mode-panel="image"] .btn.btn-primary,
.app-shell-on [data-mode-panel="spoofer"] .btn.btn-primary {
  background: var(--spoof);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(239,72,72,0.42) inset, 0 8px 24px -8px rgba(239,72,72,0.5);
}
.app-shell-on [data-mode-panel="video"] .btn.btn-primary:hover:not(:disabled),
.app-shell-on [data-mode-panel="image"] .btn.btn-primary:hover:not(:disabled),
.app-shell-on [data-mode-panel="spoofer"] .btn.btn-primary:hover:not(:disabled) {
  background: var(--spoof-bright);
  box-shadow: 0 0 0 1px rgba(239,72,72,0.5) inset, 0 14px 28px -8px rgba(239,72,72,0.55);
}
.app-shell-on [data-mode-panel="video"] .cost-tag,
.app-shell-on [data-mode-panel="image"] .cost-tag,
.app-shell-on [data-mode-panel="spoofer"] .cost-tag,
.app-shell-on [data-mode-panel="spoofer"] .num-badge {
  background: var(--spoof-soft);
  border-color: rgba(239,72,72,0.28);
  color: var(--spoof-bright);
}
.app-shell-on [data-mode-panel="video"] .dropzone .dropzone-sub .link,
.app-shell-on [data-mode-panel="image"] .dropzone .dropzone-sub .link,
.app-shell-on [data-mode-panel="spoofer"] .dropzone .dropzone-sub .link {
  color: var(--spoof-bright);
}
.app-shell-on [data-mode-panel="video"] .dropzone .dropzone-icon,
.app-shell-on [data-mode-panel="image"] .dropzone .dropzone-icon,
.app-shell-on [data-mode-panel="spoofer"] .dropzone .dropzone-icon {
  color: var(--spoof);
  border-color: rgba(239,72,72,0.3);
  background: var(--spoof-soft);
}
.app-shell-on [data-mode-panel="video"] .dropzone .dropzone-icon svg,
.app-shell-on [data-mode-panel="image"] .dropzone .dropzone-icon svg,
.app-shell-on [data-mode-panel="spoofer"] .dropzone .dropzone-icon svg {
  color: var(--spoof);
}
.app-shell-on .mode-tab[data-mode="video"].active,
.app-shell-on .mode-tab[data-mode="image"].active,
.app-shell-on .mode-tab[data-mode="spoofer"].active {
  border-bottom-color: var(--spoof);
}

/* =====================================================================
   (DR-731) Hive Flow — guided content workflow. 3-zone layout
   (recipe+estimate / stage / Smart Path+stack+summary). Ported from the
   Claude Design reference, re-tokenized to the app's dark premium theme
   + amber Creator accent. All .hf-* classes are uniquely prefixed.
   ===================================================================== */
.hf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
/* (DR-822 P2) .hf-eyebrow / .hf-title h1 / .hf-pos / .hf-title p retired — the
   Hive Flow header now uses the shared .page-head primitives (.eyebrow /
   .page-title / .page-sub). .hf-head (kept above) + .hf-smart-toggle (below)
   remain in use. */
.hf-smart-toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--fg-2); background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 13px; cursor: pointer; }
.hf-smart-toggle .hf-sw { width: 28px; height: 16px; border-radius: 999px; background: var(--line-3); position: relative; transition: background .15s; }
.hf-smart-toggle .hf-sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--fg-2); transition: transform .15s; }
.hf-smart-toggle.on { color: var(--amber-bright); border-color: rgba(255,179,0,0.35); }
.hf-smart-toggle.on .hf-sw { background: var(--amber); }
.hf-smart-toggle.on .hf-sw::after { transform: translateX(12px); background: #1a1102; }

.hf-zones { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; gap: var(--s-5); align-items: start; }
@media (max-width: 1180px) { .hf-zones { grid-template-columns: 260px minmax(0, 1fr); } .hf-zone-right { grid-column: 1 / -1; } }
@media (max-width: 820px) { .hf-zones { grid-template-columns: 1fr; } }
/* (DR-731) Hive Flow needs more room than other views — comparing/selecting
   media is cramped at the shared 1280px cap. Widen the view-wrap ONLY while the
   Hive Flow panel is visible (scoped via :has so other views are untouched), so
   the centre work panel gets ~900px instead of ~600px. */
#appViewWrap:has(.mode-panel[data-mode-panel="hive-flow"]:not([hidden])) { max-width: 1640px; }
@media (min-width: 1400px) { .hf-zones { grid-template-columns: 300px minmax(0, 1fr) 340px; gap: var(--s-6); } }

/* Left — recipe + estimate */
.hf-recipe, .hf-estimate, .hf-smartpath, .hf-stack, .hf-summary { background: var(--bg-2); border: 1px solid var(--line-1); border-radius: var(--r-lg); padding: var(--s-4); }
.hf-recipe { margin-bottom: var(--s-4); }
.hf-recipe-h, .hf-est-h, .hf-stack-h, .hf-sum-h { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--fg-1); margin-bottom: var(--s-3); }
.hf-prog, .hf-stack-cnt { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.hf-recipe-steps { display: flex; flex-direction: column; gap: 2px; }
.hf-rstep { display: flex; gap: 11px; align-items: flex-start; text-align: left; padding: 9px 10px; border-radius: var(--r-md); border: 1px solid transparent; background: none; cursor: pointer; color: var(--fg-2); }
.hf-rstep:hover:not(.locked):not(.active) { background: var(--bg-3); }
.hf-rstep.active { background: var(--bg-3); border-color: rgba(255,179,0,0.30); }
.hf-rstep.locked { opacity: 0.5; cursor: not-allowed; }
.hf-circ { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; font-family: var(--font-mono); background: var(--bg-4); color: var(--fg-2); border: 1px solid var(--line-2); }
.hf-rstep.active .hf-circ { background: var(--amber); color: #1a1102; border-color: var(--amber); }
.hf-rstep.done .hf-circ { background: rgba(46,182,125,0.16); color: var(--green); border-color: rgba(46,182,125,0.4); }
.hf-rbody { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hf-rname { font-size: 13px; font-weight: 600; color: var(--fg-1); display: flex; align-items: center; gap: 7px; }
.hf-rstep.active .hf-rname { color: var(--fg-0); }
.hf-opt { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); border: 1px solid var(--line-2); padding: 1px 5px; border-radius: 4px; }
.hf-rdesc { font-size: 11.5px; color: var(--fg-3); }
.hf-rval { font-size: 11.5px; color: var(--amber-bright); margin-top: 2px; }
.hf-est-tot { color: var(--amber-bright); font-family: var(--font-mono); font-size: 13px; }
.hf-erow { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--fg-2); padding: 5px 0; }
.hf-erow .c { font-family: var(--font-mono); color: var(--fg-1); }
.hf-erow.skipped { opacity: 0.5; text-decoration: line-through; }
.hf-enote { font-size: 11px; color: var(--fg-3); margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line-1); line-height: 1.4; }

/* Center — stage */
.hf-stage { background: var(--bg-2); border: 1px solid var(--line-1); border-radius: var(--r-lg); padding: var(--s-5); }
.hf-stage-h { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.hf-sh-title { font-size: 18px; font-weight: 600; color: var(--fg-0); letter-spacing: -0.01em; }
.hf-sh-sub { font-size: 13px; color: var(--fg-2); margin-top: 3px; max-width: 520px; }
.hf-stage-body { display: flex; flex-direction: column; }
.hf-na { display: flex; gap: 11px; align-items: flex-start; background: var(--amber-soft); border: 1px solid rgba(255,179,0,0.20); border-radius: var(--r-md); padding: 12px 14px; margin-top: var(--s-5); }
.hf-na-ic { flex: 0 0 auto; color: var(--amber-bright); margin-top: 1px; }
.hf-na-lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber-bright); margin-bottom: 3px; }
.hf-na-msg { font-size: 13px; color: var(--fg-1); line-height: 1.45; }
.hf-na-msg strong { color: var(--amber-bright); font-weight: 600; }
.hf-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); margin: var(--s-5) calc(-1 * var(--s-5)) calc(-1 * var(--s-5)); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-1); flex-wrap: wrap; }
.hf-foot-l { font-size: 13px; color: var(--fg-2); }
.hf-foot-l .amber, .v.amber, .hf-stat-v.amber, .hf-sum-row .v.amber { color: var(--amber-bright); }
.hf-foot-acts { display: flex; gap: 8px; }
.hf-err { font-size: 13px; color: var(--spoof-bright); background: var(--spoof-soft); border: 1px solid rgba(239,72,72,0.25); border-radius: var(--r-md); padding: 10px 13px; margin-top: var(--s-3); }
/* (DR-731) Inline settings-validation warning (not an error) — amber, advisory. */
.hf-warn { font-size: 12.5px; color: var(--amber-bright); background: var(--amber-soft); border: 1px solid rgba(255,179,0,0.28); border-radius: var(--r-md); padding: 9px 12px; margin-top: var(--s-2); }
/* (DR-731) Per-image refine settings panel (prompt + resolution + aspect). */
.hf-brf-settings { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-1); }
.hf-brf-settings .hf-seg-row { margin-bottom: 0; }
.hf-brf-settings .hf-seg-lbl { min-width: 64px; }
.hf-placeholder { font-size: 13px; color: var(--fg-2); line-height: 1.5; background: var(--bg-3); border: 1px dashed var(--line-2); border-radius: var(--r-md); padding: var(--s-5); text-align: center; }
.hf-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 280px; text-align: center; }
.hf-ring { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--amber); animation: hf-spin 0.8s linear infinite; }
@keyframes hf-spin { to { transform: rotate(360deg); } }
.hf-lstep { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-1); }
.hf-lsub { font-size: 12px; color: var(--fg-3); }

/* Option rows + cards */
.hf-opt-row { display: grid; gap: var(--s-3); margin-bottom: var(--s-4); }
.hf-opt-row-4 { grid-template-columns: repeat(4, 1fr); }
.hf-opt-row-5 { grid-template-columns: repeat(5, 1fr); } /* (DR-730) Image step: +Saved model photo */
.hf-opt-row-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .hf-opt-row-4, .hf-opt-row-5 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 641px) and (max-width: 900px) { .hf-opt-row-5 { grid-template-columns: repeat(3, 1fr); } }
.hf-opt { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px 13px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; }
.hf-opt:hover:not(.soon):not(.on) { border-color: var(--line-3); }
.hf-opt.on { border-color: var(--amber); background: linear-gradient(180deg, var(--amber-soft), var(--bg-3)); }
.hf-opt.soon { opacity: 0.5; cursor: not-allowed; }
.hf-opt-nm { font-size: 13px; font-weight: 600; color: var(--fg-0); }
.hf-opt-ds { font-size: 11.5px; color: var(--fg-3); }

.hf-goal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
@media (max-width: 640px) { .hf-goal-grid { grid-template-columns: 1fr; } }
/* (DR-731) Two-path entry screen: give the two choices more presence. */
.hf-goal-grid-2 .hf-goal { padding: var(--s-5); gap: 7px; min-height: 116px; }
.hf-goal-grid-2 .hf-goal-title { font-size: 16px; }
/* (DR-786) Three-path entry (Standard / Batch / Carousel). */
.hf-goal-grid-3 { grid-template-columns: repeat(3, 1fr); }
.hf-goal-grid-3 .hf-goal { padding: var(--s-4); gap: 6px; min-height: 108px; }
@media (max-width: 920px) { .hf-goal-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .hf-goal-grid-3 { grid-template-columns: 1fr; } }
.hf-goal { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; transition: border-color 160ms var(--ease), transform 160ms var(--ease), box-shadow 160ms var(--ease); }
.hf-goal:hover:not(.on):not(.soon) { border-color: var(--line-3); transform: translateY(-2px); box-shadow: 0 8px 22px -12px rgba(0,0,0,0.55); }
.hf-goal.on { border-color: var(--amber); background: linear-gradient(180deg, var(--amber-soft), var(--bg-3)); box-shadow: 0 0 0 1px rgba(255,179,0,0.12) inset; }
/* (DR-822 P2) Flow-choice icon tile — presentational glyph from GOALS[].icon. */
.hf-goal-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--amber-soft); border: 1px solid rgba(255,179,0,0.22); color: var(--amber); margin-bottom: 2px; transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease); }
.hf-goal-ico svg { width: 20px; height: 20px; }
.hf-goal.on .hf-goal-ico { background: var(--amber); color: #1a1102; border-color: var(--amber); }
.hf-goal-rec { position: absolute; top: -9px; left: 14px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; background: var(--amber); color: #1a1102; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.hf-goal-title { font-size: 15px; font-weight: 600; color: var(--fg-0); }
.hf-goal-desc { font-size: 12.5px; color: var(--fg-2); line-height: 1.4; }
.hf-goal-best { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); margin-top: 4px; }

.hf-model-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
@media (max-width: 640px) { .hf-model-grid { grid-template-columns: repeat(2, 1fr); } }
.hf-model-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; }
.hf-model-card.on { border-color: var(--amber); }
.hf-model-ava { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
.hf-model-card.on .hf-model-ava { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-model-nm { font-size: 12.5px; font-weight: 600; color: var(--fg-1); }
.hf-model-sub { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; color: var(--fg-3); }

/* (DR-730) Saved model-folder picker — folder tiles (Model step + Image step). */
.hf-folder-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
@media (max-width: 640px) { .hf-folder-grid { grid-template-columns: repeat(2, 1fr); } }
.hf-folder-card { display: flex; flex-direction: column; gap: 8px; padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; text-align: left; }
.hf-folder-card:hover { border-color: var(--line-3); }
.hf-folder-card.on { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-folder-cover { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); color: var(--amber); font-family: var(--font-mono); font-size: 26px; font-weight: 700; text-transform: uppercase; overflow: hidden; }
.hf-folder-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hf-folder-t { font-size: 13px; font-weight: 600; color: var(--fg-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hf-folder-c { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.hf-folder-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.hf-folder-name { font-size: 14px; font-weight: 600; color: var(--fg-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hf-prompt { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 12px; margin-bottom: var(--s-3); }
.hf-prompt-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 8px; }
.hf-prompt textarea { width: 100%; min-height: 64px; resize: vertical; background: transparent; border: 0; color: var(--fg-0); font: inherit; font-size: 14px; outline: none; }
.hf-prompt-foot { display: flex; justify-content: flex-end; font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); margin-top: 6px; }

.hf-seg-row { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); flex-wrap: wrap; }
.hf-seg-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); min-width: 72px; }
.hf-seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 3px; gap: 2px; flex-wrap: wrap; }
.hf-seg-b { font-size: 12.5px; font-weight: 600; color: var(--fg-2); background: none; border: 0; padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; }
.hf-seg-b.on { background: var(--amber-soft); color: var(--amber-bright); }
.hf-seg-b.locked { color: var(--fg-3); opacity: 0.75; }

.hf-gen-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
@media (max-width: 1240px) { .hf-gen-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .hf-gen-grid { grid-template-columns: 1fr 1fr; } }
.hf-gen-card { display: flex; flex-direction: column; gap: 8px; }
/* (DR-731) Image-selection carousel controls — keeps the picker short so the
   CTA stays in view instead of a long vertical scroll (Issue 2). */
.hf-carousel-nav { display: flex; align-items: center; justify-content: center; gap: var(--s-4); margin-bottom: var(--s-3); }
.hf-carousel-arrow { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg-1); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; transition: border-color 160ms var(--ease), background 160ms var(--ease); }
.hf-carousel-arrow:hover:not([disabled]) { border-color: var(--amber); color: var(--amber); }
.hf-carousel-arrow[disabled] { opacity: 0.35; cursor: not-allowed; }
.hf-carousel-count { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); min-width: 150px; text-align: center; }
.hf-gimg { position: relative; aspect-ratio: 3 / 4; border-radius: var(--r-md); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); cursor: pointer; }
.hf-gen-card.on .hf-gimg { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
/* (DR-822 P2) Cost pill defaults to top-LEFT (clear of the top-right ✓ select
   badge .hf-gsel on batch image options). On carousel slots — which carry a
   top-left .hf-beat-tag beat label — it moves to top-RIGHT so the two never
   overlap. Scoped via :has() so each context gets the right corner. */
.hf-gcost { position: absolute; top: 6px; left: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--fg-1); background: rgba(0,0,0,0.6); padding: 2px 6px; border-radius: 999px; }
.hf-gimg:has(.hf-beat-tag) .hf-gcost { left: auto; right: 6px; }
.hf-gsel { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--amber); color: #1a1102; display: none; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.hf-gen-card.on .hf-gsel { display: flex; }
.hf-gen-again { display: flex; justify-content: center; margin-bottom: var(--s-2); }
.hf-gen-actions { display: flex; flex-direction: column; gap: 8px; }
.hf-gen-btn { width: 100%; height: 46px; }
.hf-gen-btn1 { width: 100%; }

.hf-drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: var(--s-6); border: 1px dashed var(--line-3); border-radius: var(--r-md); background: var(--bg-3); cursor: pointer; text-align: center; }
.hf-drop:hover { border-color: var(--amber); }
.hf-drop-ic { color: var(--amber-bright); }
.hf-drop-t { font-size: 14px; font-weight: 600; color: var(--fg-0); }
.hf-drop-s { font-size: 12px; color: var(--fg-3); }
.hf-up-prev { margin-top: var(--s-3); }
.hf-up-prev img { max-width: 220px; max-height: 260px; border-radius: var(--r-md); border: 1px solid var(--line-2); }

.hf-refine-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: 14px 16px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-md); margin-bottom: var(--s-4); }
.hf-rb-t { font-size: 14px; font-weight: 600; color: var(--fg-0); }
.hf-rb-s { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.hf-refine-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
@media (max-width: 640px) { .hf-refine-grid { grid-template-columns: 1fr 1fr; } }
.hf-refine-op { font-size: 12.5px; font-weight: 600; color: var(--fg-2); padding: 11px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; text-align: center; }
.hf-refine-op.on { border-color: var(--amber); color: var(--amber-bright); background: var(--amber-soft); }

.hf-motion-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
.hf-motion-card { position: relative; padding: 0; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; overflow: hidden; text-align: left; }
.hf-motion-card.on { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber-soft) inset; }
.hf-motion-vid { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: var(--bg-4); }
.hf-motion-info { padding: 8px 11px; }
.hf-motion-nm { font-size: 13px; font-weight: 600; color: var(--fg-0); }
.hf-motion-best { font-size: 11px; color: var(--fg-3); }
.hf-motion-dur { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-2); margin-bottom: var(--s-3); }

.hf-export-media { display: flex; justify-content: center; margin-bottom: var(--s-5); }
.hf-export-vid { max-width: 100%; max-height: 460px; border-radius: var(--r-lg); border: 1px solid var(--line-2); background: var(--bg-3); }
.hf-export-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hf-export-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: var(--s-5); }
@media (max-width: 640px) { .hf-export-stats { grid-template-columns: 1fr 1fr; } }
.hf-stat { padding: 13px 15px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-md); }
.hf-stat-link { cursor: pointer; }
.hf-stat-l { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 6px; }
.hf-stat-v { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg-0); }

/* Right — smart path + stack + summary */
.hf-smartpath { margin-bottom: var(--s-4); background: linear-gradient(180deg, var(--amber-soft), var(--bg-2)); border-color: rgba(255,179,0,0.22); }
.hf-sp-h { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--fg-0); margin-bottom: var(--s-3); }
.hf-sp-ic { color: var(--amber-bright); }
.hf-sp-role { display: block; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber-bright); font-weight: 500; margin-top: 1px; }
.hf-sp-msg { font-size: 13px; color: var(--fg-1); line-height: 1.5; }
.hf-sp-msg strong { color: var(--amber-bright); font-weight: 600; }
.hf-stack { margin-bottom: var(--s-4); }
.hf-stack-body { display: flex; flex-direction: column; gap: var(--s-3); max-height: 420px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
/* (DR-786) Polished custom scrollbar for the output stack (replaces the default
   chunky one the user flagged). */
.hf-stack-body::-webkit-scrollbar { width: 8px; }
.hf-stack-body::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 999px; }
.hf-stack-body::-webkit-scrollbar-track { background: transparent; }
.hf-stack-empty { text-align: center; padding: var(--s-6) var(--s-3); }
.hf-stack-empty-t { font-size: 13px; font-weight: 600; color: var(--fg-1); }
.hf-stack-empty-s { font-size: 12px; color: var(--fg-3); margin: 4px auto 0; max-width: 230px; line-height: 1.45; }
/* (DR-822 P2) Output-stack item card — adopt the History card language: a
   hover affordance + a real status chip (instead of plain green text). The
   card markup is unchanged; this is presentation only. */
.hf-ocard { display: flex; gap: 11px; padding: 9px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); transition: border-color 160ms var(--ease), background 160ms var(--ease); }
.hf-ocard:hover { border-color: var(--line-3); background: var(--bg-2); }
.hf-ocard.final { border-color: rgba(255,179,0,0.3); }
.hf-ocard.final:hover { border-color: rgba(255,179,0,0.45); }
.hf-othumb { position: relative; flex: 0 0 auto; width: 46px; height: 58px; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; }
.hf-vplay { color: #fff; font-size: 13px; opacity: 0.9; }
.hf-obody { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.hf-osource { font-size: 12.5px; font-weight: 600; color: var(--fg-0); }
.hf-ometa { font-size: 11px; color: var(--fg-3); }
.hf-ometa .cost { font-family: var(--font-mono); color: var(--amber-bright); }
.hf-ostatus { align-self: flex-start; display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--green); background: rgba(46,182,125,0.12); border: 1px solid rgba(46,182,125,0.28); border-radius: 999px; padding: 2px 8px; margin-top: 3px; }
.hf-oacts { display: flex; gap: 4px; margin-top: 5px; }
.hf-oact { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--fg-2); cursor: pointer; }
.hf-oact:hover { color: var(--fg-0); border-color: var(--line-3); }
.hf-oact.danger:hover { color: var(--spoof-bright); border-color: rgba(239,72,72,0.4); }
.hf-sum-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--fg-2); padding: 5px 0; }
.hf-sum-row .v { color: var(--fg-1); font-weight: 600; }

/* (DR-731 QA) Refine before/after, Animate subject preview, deferred-option
   note, saved-star state — all within the Hive Flow panel. */
.hf-ba { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-bottom: var(--s-3); }
.hf-ba-pane { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.hf-ba-pane figcaption { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.hf-ba-pane.active figcaption { color: var(--amber-bright); }
.hf-ba-img { aspect-ratio: 3 / 4; border-radius: var(--r-md); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
.hf-ba-pane.active .hf-ba-img { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-subject { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); margin-bottom: var(--s-4); }
.hf-subject-thumb { flex: 0 0 auto; width: 44px; height: 52px; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
.hf-subject-text { flex: 1; min-width: 0; }
.hf-subject-lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); }
.hf-subject-nm { font-size: 13px; font-weight: 600; color: var(--fg-0); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf-soon-note { font-size: 12px; color: var(--fg-3); line-height: 1.45; background: var(--bg-3); border: 1px solid var(--line-1); border-radius: var(--r-md); padding: 11px 13px; margin-bottom: var(--s-3); }
.hf-soon-note strong { color: var(--fg-1); }
.hf-oact.on { color: var(--amber-bright); border-color: rgba(255,179,0,0.4); }

/* (DR-731 batch) Image-option loading slots + failed state. */
.hf-gen-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.hf-gen-prog { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.hf-gimg-loading { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; }
/* (DR-822 P2) In-flight slot label → a calm status chip with a leading status
   dot. The dot colour reflects the slot's data-status: queued = neutral/steady
   ("waiting in line"), submitting/generating = amber pulse ("working"),
   provider_pending = amber steady ("still rendering"). Failed is the only red
   state (.hf-gimg-failed) so normal queued/backpressure work never reads as an
   error. Image-option slots (no data-status) default to the amber pulse. */
.hf-gimg-loading .hf-gloading-lbl { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; color: var(--fg-1); background: rgba(8,8,11,0.66); border: 1px solid var(--line-3); border-radius: 999px; padding: 4px 10px; margin-bottom: 10px; }
.hf-gloading-lbl::before { content: ""; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: hf-dot-pulse 1.4s ease-in-out infinite; }
.hf-gen-card[data-status="queued"] .hf-gloading-lbl::before { background: var(--fg-3); animation: none; }
.hf-gen-card[data-status="provider_pending"] .hf-gloading-lbl::before { animation: none; }
@keyframes hf-dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.hf-shimmer { position: absolute; inset: 0; background: linear-gradient(100deg, var(--bg-3) 30%, var(--bg-4) 50%, var(--bg-3) 70%); background-size: 220% 100%; animation: hf-shimmer 1.4s ease-in-out infinite; }
@keyframes hf-shimmer { 0% { background-position: 180% 0; } 100% { background-position: -80% 0; } }
.hf-gimg-failed { display: flex; align-items: center; justify-content: center; background: var(--spoof-soft); border-color: rgba(239,72,72,0.3); }
/* (DR-822 P2) Failed slot — clear but not alarming: a soft-red chip with a
   compact warning glyph. The Retry control lives separately in .hf-car-acts and
   only renders for true failures (provider_pending stays a loading state). */
.hf-gfail { display: inline-flex; align-items: center; gap: 6px; max-width: 94%; font-size: 11px; font-weight: 500; color: var(--spoof-bright); text-align: left; padding: 5px 10px; line-height: 1.3; background: rgba(239,72,72,0.12); border: 1px solid rgba(239,72,72,0.30); border-radius: var(--r-sm); }
.hf-gfail::before { content: "!"; flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; background: var(--spoof-bright); color: #fff; font-size: 9px; font-weight: 700; line-height: 14px; text-align: center; }

/* Batch picks strip + note. */
.hf-batch-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--s-3); }
.hf-batch-thumb { width: 52px; height: 64px; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-batch-empty { font-size: 12.5px; color: var(--fg-3); }
.hf-batch-note { font-size: 12px; color: var(--fg-3); margin-bottom: var(--s-3); }

/* Batch render queue. */
.hf-bq-head { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2); margin-bottom: var(--s-3); }
.hf-bq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-3); }
.hf-bq-card { border: 1px solid var(--line-2); border-radius: var(--r-md); overflow: hidden; background: var(--bg-3); }
.hf-bq-card.failed { border-color: rgba(239,72,72,0.35); }
.hf-bq-thumb { position: relative; aspect-ratio: 1 / 1; background: var(--bg-4) center/cover no-repeat; display: flex; align-items: flex-start; justify-content: flex-end; }
.hf-bq-thumb > span { margin: 6px; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 12px; font-weight: 700; }
.hf-bq-ok { background: var(--green); color: #06281b; }
.hf-bq-fail { background: var(--spoof); color: #fff; }
.hf-bq-wait { background: var(--bg-2); border: 1px solid var(--line-2); }
.hf-bq-spin { background: transparent; border: 2px solid var(--line-2); border-top-color: var(--amber); animation: hf-spin 0.8s linear infinite; }
.hf-bq-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.hf-bq-status { font-size: 12px; color: var(--fg-2); }
.hf-bq-card.failed .hf-bq-status { color: var(--spoof-bright); }

/* Batch export grid. */
.hf-export-head { font-size: 16px; font-weight: 600; color: var(--fg-0); margin-bottom: var(--s-4); }
.hf-export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5); }
.hf-export-card { border: 1px solid var(--line-2); border-radius: var(--r-md); overflow: hidden; background: var(--bg-3); display: flex; flex-direction: column; }
.hf-export-card .hf-export-vid { max-height: 260px; border: 0; border-radius: 0; width: 100%; }
.hf-export-card-acts { display: flex; gap: 6px; padding: 10px; }
.hf-export-card-acts .btn { flex: 1; justify-content: center; }
/* (DR-786) Carousel pack — per-image action row + image-tile export card. */
.hf-car-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.hf-car-acts .btn, .hf-car-acts > a.btn { flex: 1 1 auto; justify-content: center; }
.hf-export-img { aspect-ratio: 4 / 5; background: var(--bg-4) center/cover no-repeat; }

/* (DR-786) GPT carousel setup — template picker + identity picker. */
.hf-section-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); margin: var(--s-4) 0 var(--s-2); }
.hf-section-lbl:first-child { margin-top: 0; }
.hf-section-lbl .hf-sel-count { float: right; text-transform: none; letter-spacing: 0; color: var(--fg-2); font-size: 10px; }
/* (DR-786) Template MULTI-SELECT — horizontal snap rail with arrow nav, so 26
   templates browse cleanly with no ugly nested vertical scrollbar. */
.hf-rail-wrap { position: relative; margin-bottom: var(--s-2); }
.hf-tpl-rail { display: flex; gap: var(--s-3); overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 10px; scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
.hf-tpl-rail::-webkit-scrollbar { height: 8px; }
.hf-tpl-rail::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 999px; }
.hf-tpl-rail::-webkit-scrollbar-track { background: transparent; }
.hf-tpl-card { flex: 0 0 148px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-3); cursor: pointer; text-align: left; transition: border-color 160ms var(--ease), transform 160ms var(--ease); }
.hf-tpl-card:hover { border-color: var(--line-3); transform: translateY(-2px); }
.hf-tpl-card.on { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-tpl-thumb { position: relative; aspect-ratio: 4 / 5; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
.hf-tpl-badge { position: absolute; top: 6px; left: 6px; min-width: 20px; height: 20px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--amber); color: #0a0a0a; font-family: var(--font-mono); font-size: 11px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.hf-tpl-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 0 2px 2px; }
.hf-tpl-t { font-size: 12px; font-weight: 600; color: var(--fg-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hf-tpl-c { font-size: 10.5px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hf-rail-arrow { position: absolute; top: 38%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--line-3); background: var(--bg-2); color: var(--fg-1); font-size: 20px; line-height: 1; cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center; opacity: 0.92; }
.hf-rail-arrow:hover { background: var(--bg-4); border-color: var(--amber); color: var(--amber); }
.hf-rail-prev { left: -6px; }
.hf-rail-next { right: -6px; }
.hf-car-summary { display: flex; gap: var(--s-4); flex-wrap: wrap; margin: var(--s-3) 0; padding: 10px 13px; border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--bg-3); font-size: 12.5px; color: var(--fg-2); }
.hf-car-summary strong { color: var(--fg-0); font-weight: 600; }
/* Per-template pack section (multi-template results grouped by template). */
.hf-pack { margin-bottom: var(--s-4); }
.hf-pack-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin: var(--s-2) 0; font-size: 12px; font-weight: 600; color: var(--fg-1); }
.hf-pack-name { font-family: var(--font-mono); letter-spacing: 0.02em; }
.hf-pack-meta { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 400; color: var(--fg-3); font-size: 11px; }
/* (DR-786) Storyboard preview — planned beats per selected template, shown
   before generation so the user sees a real carousel (and which shots drop the
   face) up front. */
.hf-storyboard { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-3); }
.hf-story-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.hf-story-name { font-family: var(--font-mono); font-size: 11px; color: var(--fg-2); min-width: 120px; }
.hf-story-beats { display: flex; gap: 6px; flex-wrap: wrap; }
.hf-beat { font-size: 10.5px; line-height: 1; padding: 5px 9px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-2); white-space: nowrap; }
.hf-beat-hero { background: var(--amber-soft); border-color: rgba(255,179,0,0.3); color: var(--amber-bright); }
.hf-beat-closing { border-color: var(--line-3); color: var(--fg-1); }
.hf-beat.noface { border-style: dashed; color: var(--fg-3); }
/* Per-slot beat tag overlaid on the generation card (Hero / Detail / …). */
.hf-beat-tag { position: absolute; top: 6px; left: 6px; z-index: 2; font-size: 10px; line-height: 1; padding: 4px 7px; border-radius: 999px; background: rgba(8,8,11,0.72); color: var(--fg-1); border: 1px solid var(--line-3); }
/* (DR-786) Styled confirm overlay (Start Over while jobs still render). */
.hf-confirm-root { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.hf-confirm-backdrop { position: absolute; inset: 0; background: rgba(8,8,11,0.66); backdrop-filter: blur(2px); }
.hf-confirm-card { position: relative; z-index: 1; width: 100%; max-width: 420px; margin: var(--s-4); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: 0 24px 64px -16px rgba(0,0,0,0.7); }
.hf-confirm-title { font-size: 16px; font-weight: 600; color: var(--fg-0); margin-bottom: var(--s-2); }
.hf-confirm-msg { font-size: 13.5px; line-height: 1.55; color: var(--fg-2); margin-bottom: var(--s-4); }
.hf-confirm-acts { display: flex; justify-content: flex-end; gap: var(--s-2); }
.hf-id-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--s-2); margin-bottom: var(--s-2); max-height: 180px; overflow-y: auto; padding-right: 4px; }
.hf-id-card { padding: 0; border-radius: var(--r-md); border: 2px solid transparent; background: none; cursor: pointer; overflow: hidden; }
.hf-id-card.on { border-color: var(--amber); }
.hf-id-thumb { display: block; aspect-ratio: 1 / 1; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
/* (DR-786) A carousel pack is one cohesive set — keep the export view on the
   same responsive 3-up grid as the pack view (overrides .hf-export-grid's
   wider auto-fill so a finished pack doesn't read as oversized loose tiles). */
.hf-carousel-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1240px) { .hf-carousel-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .hf-carousel-grid { grid-template-columns: 1fr 1fr; } }

/* (DR-786) Download all / export ZIP controls. (.hf-foot-acts already exists
   and lays out the pack-view foot buttons; only the stack-header bits are new.) */
.hf-stack-actions { display: flex; align-items: center; gap: var(--s-2); }
/* Compact stack-header "Download all" — quiet until hovered, never as loud as
   the export-screen primary action. */
.hf-stack-dl { font-family: var(--font-mono); font-size: 11px; line-height: 1; color: var(--amber); background: var(--amber-soft); border: 1px solid rgba(255,179,0,0.22); border-radius: 999px; padding: 5px 10px; cursor: pointer; transition: background 160ms var(--ease), border-color 160ms var(--ease); }
.hf-stack-dl:hover { background: rgba(255,179,0,0.16); border-color: rgba(255,179,0,0.4); }
.hf-stack-dl[disabled] { opacity: 0.55; cursor: default; }
.hf-stack-err { margin: 0 0 var(--s-2); }

/* (DR-731 batch2) Validation hint, batch refine grid, per-image custom cards. */
.hf-hint { font-size: 12.5px; color: var(--amber-bright); background: var(--amber-soft); border: 1px solid rgba(255,179,0,0.22); border-radius: var(--r-md); padding: 9px 12px; margin-top: var(--s-3); }
.hf-hint[hidden] { display: none; }
.hf-brf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-3); }
.hf-brf-card { border: 1px solid var(--line-2); border-radius: var(--r-md); padding: var(--s-3); background: var(--bg-3); display: flex; flex-direction: column; gap: 8px; }
.hf-brf-card.on { border-color: var(--amber); }
.hf-brf-card.failed { border-color: rgba(239,72,72,0.35); }
.hf-brf-card > .hf-ba-img { aspect-ratio: 3 / 4; border-radius: var(--r-sm); }
.hf-brf-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hf-brf-pair figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.hf-brf-pair figure:only-child { grid-column: 1 / -1; }
.hf-brf-pair figcaption { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.hf-brf-pair figure.active figcaption { color: var(--amber-bright); }
.hf-brf-pair .hf-ba-img { aspect-ratio: 3 / 4; }
.hf-brf-pair figure.active .hf-ba-img { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-brf-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg-1); cursor: pointer; }
.hf-brf-check input { accent-color: var(--amber); }
.hf-brf-input { width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--fg-0); font: inherit; font-size: 12.5px; padding: 7px 9px; outline: none; }
.hf-brf-input:focus { border-color: var(--amber); }
.hf-brf-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hf-brf-err { font-size: 11.5px; color: var(--spoof-bright); }
.hf-brf-note { font-size: 11.5px; color: var(--fg-3); }
.hf-bcustom-grid { display: flex; flex-direction: column; gap: var(--s-3); margin: var(--s-3) 0; }
.hf-bcustom-card { border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px; background: var(--bg-3); }
.hf-bcustom-row { display: flex; gap: 11px; align-items: center; }
.hf-bcustom-thumb { flex: 0 0 auto; width: 44px; height: 52px; border-radius: var(--r-sm); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
.hf-bcustom-fields { flex: 1; display: flex; gap: 8px; align-items: center; min-width: 0; flex-wrap: wrap; }
.hf-bcustom-fields .hf-brf-input { flex: 1; min-width: 160px; }
/* Per-image Motion Control template: visual chip (preview + name) + change. */
.hf-bcustom-tplsel { display: flex; align-items: center; gap: 8px; }
.hf-bcustom-tplvid { width: 40px; height: 30px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg-4); }
.hf-bcustom-tplnm { font-size: 12px; color: var(--fg-1); }
.hf-bcustom-picker { margin-top: var(--s-3); }

/* (DR-731) Larger refine before/after review. Flows at page level (no cramped
   inner scrollbar — DR-731 Issue 5); click any card to open the big compare
   modal. Wider container (Issue 1) gives room for 2–3 across. */
.hf-brf-review { display: grid; grid-template-columns: 1fr; gap: var(--s-4); margin-bottom: var(--s-3); }
@media (min-width: 1100px) { .hf-brf-review { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1500px) { .hf-brf-review { grid-template-columns: repeat(3, 1fr); } }
.hf-brf-card .hf-brf-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hf-brf-card .hf-brf-pair.single { grid-template-columns: 1fr; max-width: 360px; }
.hf-brf-card .hf-brf-pair { cursor: zoom-in; position: relative; }
.hf-brf-zoom { position: absolute; top: 6px; right: 6px; font-size: 10.5px; font-weight: 600; color: #fff; background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 999px; pointer-events: none; opacity: 0; transition: opacity 160ms var(--ease); }
.hf-brf-card .hf-brf-pair:hover .hf-brf-zoom { opacity: 1; }

/* (DR-731) Before/after compare lightbox — large, dark-themed, viewport-centered. */
.hf-compare { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: var(--s-4); }
.hf-compare-backdrop { position: absolute; inset: 0; background: rgba(4,4,8,0.78); backdrop-filter: blur(3px); cursor: zoom-out; }
.hf-compare-card { position: relative; width: 100%; max-width: 960px; max-height: 92vh; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: 0 24px 60px -12px rgba(0,0,0,0.6); animation: fadeUp 220ms var(--ease-out) both; }
.hf-compare-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); font-size: 14px; font-weight: 600; color: var(--fg-0); }
.hf-compare-x { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg-2); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.hf-compare-x:hover { color: var(--fg-0); border-color: var(--line-3); }
.hf-compare-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); margin-bottom: var(--s-4); }
@media (max-width: 640px) { .hf-compare-pair { grid-template-columns: 1fr; } }
.hf-compare-pair figcaption { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3); margin-bottom: 6px; }
.hf-compare-pair figure.active figcaption { color: var(--amber); }
.hf-compare-img { aspect-ratio: 3 / 4; max-height: 64vh; border-radius: var(--r-md); background: var(--bg-4) center/contain no-repeat; border: 1px solid var(--line-2); }
.hf-compare-pair figure.active .hf-compare-img { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-compare-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }
.hf-brf-img { aspect-ratio: 3 / 4; border-radius: var(--r-md); background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line-2); }
.hf-brf-pair figure.active .hf-brf-img { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hf-brf-loading { position: relative; overflow: hidden; }
.hf-brf-hdr { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.hf-brf-num { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.hf-brf-state { font-size: 12px; color: var(--amber-bright); }

/* ───────────────────────── DR-808 History — premium asset library ───────────────────────── */
/* Toolbar: search + filter chips + sort. */
.hist-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.hist-search { flex: 1 1 220px; min-width: 180px; }
.hist-search-input { width: 100%; height: 34px; padding: 0 12px; border-radius: var(--r-md); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--fg-1); font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.hist-search-input:focus { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hist-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.hist-chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-3);
  color: var(--fg-2); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.hist-chip:hover { color: var(--fg-1); border-color: var(--line-1); }
.hist-chip.on { background: var(--amber); border-color: var(--amber); color: #1a1205; }
.hist-sort { height: 34px; }

/* Batch action bar (multi-select). */
.hist-batchbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 12px; border-radius: var(--r-md); border: 1px solid var(--amber-soft);
  background: linear-gradient(0deg, var(--amber-soft), var(--amber-soft)), var(--bg-3); }
.hist-batch-count { font-size: 13px; font-weight: 700; color: var(--fg-1); }
.hist-batch-acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* Grid. */
.hist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.hist-card { position: relative; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--bg-2);
  overflow: hidden; cursor: pointer; transition: transform .12s ease, border-color .12s, box-shadow .12s; outline: none; }
.hist-card:hover { transform: translateY(-2px); border-color: var(--line-1); box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.hist-card:focus-visible { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
.hist-card.sel { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-soft); }
/* Stacked look for carousel bundles. */
.hist-card.is-car { box-shadow: 0 1px 0 0 var(--bg-2), 4px 5px 0 -1px var(--bg-4), 5px 6px 0 -1px var(--line-2); }
.hist-card.is-car:hover { box-shadow: 0 1px 0 0 var(--bg-2), 4px 5px 0 -1px var(--bg-4), 5px 6px 0 -1px var(--line-2), 0 10px 24px rgba(0,0,0,.3); }
.hist-stack { display: none; }
.hist-thumb { position: relative; aspect-ratio: 4 / 5; background: var(--bg-4); overflow: hidden; }
.hist-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hist-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 12px;
  color: var(--fg-3); background: var(--bg-4); text-align: center; padding: 8px; }
.hist-ph-processing { color: var(--amber-bright); }
.hist-ph-failed { color: #ff8a8a; }
.hist-badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.hist-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 3px 7px; border-radius: 6px;
  background: rgba(8,10,14,.72); color: #fff; backdrop-filter: blur(4px); }
.hist-badge.type.car { background: rgba(124,92,255,.9); }
.hist-badge.type.video, .hist-badge.type.motion { background: rgba(40,120,230,.85); }
.hist-badge.wf { background: rgba(8,10,14,.6); color: var(--fg-2); font-weight: 600; }
.hist-badge.st-processing { background: var(--amber); color: #1a1205; }
.hist-badge.st-failed { background: rgba(200,60,60,.92); }
.hist-badge.st-partial { background: rgba(180,120,30,.92); }
/* select checkbox */
.hist-check { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 6px; border: 2px solid #fff;
  background: rgba(8,10,14,.55); display: none; align-items: center; justify-content: center; }
.hist-grid.selecting .hist-check { display: flex; }
.hist-grid.selecting .hist-badges { right: 36px; }
.hist-card.sel .hist-check { background: var(--amber); border-color: var(--amber); }
.hist-card.sel .hist-check::after { content: "✓"; color: #1a1205; font-size: 13px; font-weight: 900; }
.hist-cmeta { padding: 9px 10px 11px; }
.hist-title { font-size: 12.5px; color: var(--fg-1); line-height: 1.35; max-height: 2.7em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hist-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--fg-3); }
.hist-wf { color: var(--fg-2); font-weight: 600; }
.hist-when { margin-left: auto; }
.hist-credits { color: var(--amber-bright); font-weight: 600; }
.hist-none { grid-column: 1 / -1; padding: 40px 16px; text-align: center; color: var(--fg-3); font-size: 13px; }
.hist-none.err { color: #ff9b9b; }
.hist-pager { display: flex; justify-content: center; margin-top: 18px; }

/* Skeletons. */
.hist-card.skel { cursor: default; }
.hist-card.skel:hover { transform: none; box-shadow: none; border-color: var(--line-2); }
.skel-box { aspect-ratio: 4 / 5; }
.skel-box, .skel-line { position: relative; overflow: hidden; background: var(--bg-4); border-radius: 6px; }
.skel-line { height: 10px; margin: 9px 10px; } .skel-line.short { width: 55%; }
.skel-box::after, .skel-line::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); transform: translateX(-100%); animation: histShimmer 1.3s infinite; }
@keyframes histShimmer { 100% { transform: translateX(100%); } }

/* Details drawer (right slide-in). */
.hist-drawer-root { position: fixed; inset: 0; z-index: 1200; }
.hist-drawer-backdrop { position: absolute; inset: 0; background: rgba(4,6,10,0); transition: background .24s ease; }
.hist-drawer-root.in .hist-drawer-backdrop { background: rgba(4,6,10,.6); }
.hist-drawer { position: absolute; top: 0; right: 0; height: 100%; width: min(440px, 94vw); display: flex; flex-direction: column;
  background: var(--bg-1); border-left: 1px solid var(--line-2); box-shadow: -16px 0 40px rgba(0,0,0,.4);
  transform: translateX(100%); transition: transform .24s cubic-bezier(.4,0,.2,1); }
.hist-drawer-root.in .hist-drawer { transform: translateX(0); }
.hist-dhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.hist-dtitle { display: flex; flex-wrap: wrap; gap: 6px; }
.hist-dclose { background: none; border: none; color: var(--fg-3); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.hist-dclose:hover { color: var(--fg-1); }
.hist-dbody { flex: 1 1 auto; overflow-y: auto; padding: 16px; }
.hist-dpreview { display: flex; justify-content: center; }
.hist-dpv { max-width: 100%; max-height: 52vh; border-radius: var(--r-md); background: var(--bg-4); display: block; object-fit: contain; }
.hist-dpv.hist-ph { width: 100%; aspect-ratio: 4 / 5; }
.hist-dnav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }
.hist-dnav-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-3);
  color: var(--fg-1); font-size: 20px; line-height: 1; cursor: pointer; }
.hist-dnav-btn:disabled { opacity: .35; cursor: default; }
.hist-dcount { font-size: 12.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; min-width: 54px; text-align: center; }
.hist-dthumbs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; }
.hist-dthumb { flex: 0 0 auto; width: 52px; height: 64px; border-radius: 8px; overflow: hidden; border: 2px solid transparent;
  background: var(--bg-4); cursor: pointer; padding: 0; }
.hist-dthumb.on { border-color: var(--amber); }
.hist-dthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hist-dthumb-ph { display: block; width: 100%; height: 100%; }
.hist-dcounts { display: flex; gap: 12px; margin-top: 12px; font-size: 12px; }
.hist-dcounts .ok { color: var(--amber-bright); } .hist-dcounts .proc { color: var(--fg-2); } .hist-dcounts .fail { color: #ff8a8a; }
.hist-dmeta { margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.hist-mrow { display: flex; gap: 12px; padding: 5px 0; font-size: 12.5px; }
.hist-mk { flex: 0 0 84px; color: var(--fg-3); } .hist-mv { color: var(--fg-1); word-break: break-word; }
.hist-dactions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line-2); background: var(--bg-2); }
.hist-dgrow { flex: 1 1 auto; }

/* Toast. */
.lib-toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px); z-index: 1300; opacity: 0;
  padding: 10px 16px; border-radius: var(--r-md); background: var(--bg-1); border: 1px solid var(--line-1); color: var(--fg-1);
  font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: opacity .25s, transform .25s; pointer-events: none; }
.lib-toast.in { opacity: 1; transform: translate(-50%, 0); }
.lib-toast.err { border-color: rgba(200,80,80,.7); }

@media (max-width: 640px) {
  .hist-grid { grid-template-columns: repeat(auto-fill, minmax(46%, 1fr)); gap: 10px; }
  .hist-drawer { width: 100vw; border-left: none; }
  .hist-toolbar { gap: 8px; }
}
