html, body { background: #000; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
.dz { transition: all 0.15s ease; }
.dz.active { background: rgba(99, 102, 241, 0.12); border-color: #6366F1; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Custom file input look */
input[type="text"], input[type="url"], textarea {
  background-color: #0a0a0a;
  color: #fafafa;
  border-color: #27272a;
}
input::placeholder, textarea::placeholder { color: #52525b; }
input:focus, textarea:focus { border-color: #6366F1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); outline: none; }

/* Collapsible Brief sections (native <details>) with a custom chevron. */
.brief-acc > summary { list-style: none; }
.brief-acc > summary::-webkit-details-marker { display: none; }
.brief-acc .chev::before { content: '\25B8'; }
.brief-acc[open] .chev::before { content: '\25BE'; }

.brief-item { transition: all 0.12s ease; }
.brief-item.is-selected { border-color: #6366F1; background-color: rgba(99, 102, 241, 0.10); }
.brief-item.is-selected .brief-check { background-color: #6366F1; border-color: #6366F1; color: white; }

/* Inline spinner row: shared by section-level "Loading…" placeholders */
.loader-row { display: inline-flex; align-items: center; gap: 0.5rem; }

/* Tile-level overlay used while a thumbnail is being deleted */
.tile-busy { position: relative; pointer-events: none; }
.tile-busy::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(0,0,0,0.55); border-radius: inherit;
  z-index: 5;
}
.tile-busy::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  z-index: 6;
}

/* Custom scrollbars (dark-mode) ----------------------------------
   Browser defaults render a stark white track inside this otherwise
   all-black UI. Theme both Firefox and WebKit/Blink so every
   scrollable area (template grid, Active Runs list, Brief lists,
   etc.) blends in. Track stays transparent so each host element's
   own background shows through unchanged. */
* { scrollbar-width: thin; scrollbar-color: #3f3f46 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #3f3f46;            /* zinc-700 — subtle */
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #52525b;            /* zinc-600 — slightly brighter on hover */
  background-clip: content-box;
  border: 2px solid transparent;
}
::-webkit-scrollbar-corner { background: transparent; }

/* ── Foreplay reference selection: tick + number badge + slide-in staging ──
   Motion is transform/opacity only (compositor-cheap). Curve is a fast,
   softened easeOutExpo. Honors prefers-reduced-motion. */
:root { --brand: #6366F1; --brand-600: #4F46E5; }  /* Airpost blue (matches Tailwind `brand`) */

.fp-tick, .fp-num {
  position: absolute;
  top: 6px;
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;          /* fixed dims = circle */
  border-radius: 9999px;
  font-size: 12px; font-weight: 800; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.55);
  opacity: 0; transform: scale(0.2);
}
.fp-tick {            /* top-LEFT confirmation check */
  left: 6px;
  background: var(--brand); color: #fff;
}
.fp-num {             /* top-RIGHT blend-order number — Airpost-blue circle */
  right: 6px;
  background: var(--brand); color: #fff;
  border: 2px solid rgba(255,255,255,.92);  /* white ring so it reads over any image */
}
/* In the staging strip the top-right corner holds the × remove button, so the
   number goes to the top-LEFT there to avoid overlapping it. */
#staged-refs .fp-num { left: 6px; right: auto; }
.fp-card.selected { border-color: var(--brand); }
.fp-card.selected .fp-tick,
.fp-card.selected .fp-num {
  opacity: 1; transform: scale(1);
  transition: opacity 180ms ease, transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* check-mark stroke draw-in */
.fp-tick svg path { stroke-dasharray: 18; stroke-dashoffset: 18; }
.fp-card.selected .fp-tick svg path {
  animation: fp-draw 240ms cubic-bezier(0.22, 1, 0.36, 1) 60ms forwards;
}
@keyframes fp-draw { to { stroke-dashoffset: 0; } }

/* staged cards slide in from the left */
.fp-stage { opacity: 0; transform: translateX(-22px); }
.fp-stage.in {
  opacity: 1; transform: translateX(0);
  transition: opacity 200ms ease, transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .fp-card.selected .fp-tick, .fp-card.selected .fp-num,
  .fp-stage, .fp-stage.in { transition: none !important; animation: none !important; transform: none !important; opacity: 1 !important; }
  .fp-tick svg path { stroke-dashoffset: 0 !important; }
}

/* Auto-batch concept cards: clamp long angle/ICP so the grid stays tidy; the
   card expands to full width + full text on click (see #ab-cards handler). */
.ab-card .ab-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ab-card.expanded { grid-column: 1 / -1; border-color: var(--brand); }
.ab-card.expanded .ab-clamp { -webkit-line-clamp: unset; overflow: visible; }
.ab-card.expanded .ab-more { display: none; }

/* Batch strip side drawer: collapse shrinks it to a compact header pill (width
   sizes to the title) so it no longer covers the delivery area. */
#batch-strip.collapsed { width: auto; }
#batch-strip.collapsed #batch-cards { display: none; }
#batch-strip.collapsed #batch-delivery-row { display: none; }
#batch-strip.collapsed #batch-strip-chevron { transform: rotate(-90deg); }

/* When a run finishes while the strip is collapsed, pulse the pill so the user
   notices it's done (the title also updates with the ready count). */
@keyframes batch-strip-ping {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
  50% { box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.55); }
}
#batch-strip.batch-strip-ping { animation: batch-strip-ping 0.8s ease-in-out 2; }

/* Auto-assigned delivery number: pop the chip + a sparkle that drifts up and fades. */
@keyframes deliv-pop {
  0% { transform: scale(0.6); opacity: 0; }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes deliv-spark {
  0% { opacity: 0; transform: translate(0, 0) scale(0.5) rotate(0deg); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(8px, -14px) scale(1.25) rotate(20deg); }
}
.delivery-chip.sparkle-pop {
  animation: deliv-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 10px 1px rgba(99, 102, 241, 0.55);
}
.delivery-spark {
  position: absolute; top: -2px; left: 100%;
  font-size: 11px; line-height: 1; pointer-events: none;
  animation: deliv-spark 1s ease-out forwards;
}
@media (prefers-reduced-motion: reduce) {
  .delivery-chip.sparkle-pop, .delivery-spark { animation: none; }
}

/* Gallery delivery folders: collapsed = cover tile; expanded = full row + sub-grid. */
.gallery-folder .gf-open { display: none; }
.gallery-folder.expanded { grid-column: 1 / -1; }
.gallery-folder.expanded .gf-cover { display: none; }
.gallery-folder.expanded .gf-open { display: block; }

/* ============================================================
   Step-by-step wizard shell (opt-in via ?wizard=1).
   When body.wizard-on is set, a fixed left rail drives the existing panels and
   the classic top tab bar is hidden (reachable behind the ⚙ Advanced toggle).
   Nothing here applies unless .wizard-on is present, so the classic UI is
   byte-for-byte unchanged when the flag is off.
   ============================================================ */
#wizard-rail { display: none; }
body.wizard-on #wizard-rail { display: flex; }
body.wizard-on #app-shell { margin-left: 256px; }

#wizard-rail {
  position: fixed; top: 0; left: 0; bottom: 0; width: 240px; z-index: 60;
  flex-direction: column;
  background: #09090b;                 /* zinc-950 */
  border-right: 1px solid #18181b;     /* zinc-900 */
  padding: 22px 14px 16px;
  overflow-y: auto;
}
.wiz-title {
  font-size: 18px; font-weight: 800; letter-spacing: -0.01em; color: #fff;
  text-align: left; background: transparent; cursor: pointer; line-height: 1.1;
}
.wiz-title span { color: #a1a1aa; font-weight: 500; }
.wiz-sub { font-size: 11px; color: #52525b; margin: 4px 0 18px; }

.wiz-steps { display: flex; flex-direction: column; gap: 2px; }
.wiz-step {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  padding: 10px; border-radius: 10px; border: 1px solid transparent;
  color: #a1a1aa; background: transparent; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.wiz-step:hover:not(.is-locked) { background: #18181b; color: #fff; }
.wiz-step.is-active { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.5); color: #fff; }
.wiz-step.is-locked { opacity: .4; cursor: not-allowed; }
.wiz-dot {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; line-height: 1;
  background: #27272a; color: #a1a1aa; border: 1px solid #3f3f46;
}
.wiz-step.is-active .wiz-dot {
  background: var(--brand); color: #fff; border-color: var(--brand);
  animation: wiz-pulse 1.6s ease-in-out infinite;
}
.wiz-step.is-done .wiz-dot { background: #10b981; color: #fff; border-color: #10b981; } /* emerald-500 */
@keyframes wiz-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(99,102,241,.55);} 50% { box-shadow: 0 0 0 4px rgba(99,102,241,0);} }
.wiz-step-body { min-width: 0; }
.wiz-step-label { font-size: 13px; font-weight: 600; line-height: 1.2; }
.wiz-step-value { display: block; font-size: 11px; color: #71717a; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiz-step.is-active .wiz-step-value { color: #a5b4fc; }

@keyframes wiz-shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-4px);} 75% { transform: translateX(4px);} }
.wiz-step.wiz-shake { animation: wiz-shake .28s ease; }

.wiz-next {
  margin-top: 16px; width: 100%; padding: 10px; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background .12s ease;
}
.wiz-next:hover { background: var(--brand-600); }

.wiz-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid #18181b; display: flex; flex-direction: column; gap: 2px; }
.wiz-link {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: #71717a; background: transparent; cursor: pointer;
  text-align: left; width: 100%; transition: background .12s ease, color .12s ease;
}
.wiz-link:hover { background: #18181b; color: #fff; }

/* Wizard-native canvases (the one-vs-batch fork, the results grid). */
#wizard-canvas { padding-top: 8px; }
.wiz-canvas-h { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.wiz-canvas-sub { font-size: 14px; color: #a1a1aa; margin: 6px 0 22px; }
.wiz-fork { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; max-width: 720px; }
.wiz-fork-card {
  border: 1px solid #27272a; background: #09090b; border-radius: 16px; padding: 28px 24px;
  text-align: left; cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
}
.wiz-fork-card:hover { border-color: var(--brand); background: #0f0f12; transform: translateY(-2px); }
.wiz-fork-emoji { font-size: 30px; line-height: 1; }
.wiz-fork-title { font-size: 17px; font-weight: 700; color: #fff; margin-top: 12px; }
.wiz-fork-desc { font-size: 13px; color: #a1a1aa; margin-top: 6px; line-height: 1.45; }
.wiz-secondary {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid #27272a; background: #09090b; color: #e4e4e7; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
}
.wiz-secondary:hover { border-color: #3f3f46; color: #fff; }
.wiz-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-width: 720px; margin: 4px 0 18px; }
.wiz-result { position: relative; border: 1px solid #27272a; border-radius: 10px; overflow: hidden; background: #0a0a0a; }
.wiz-result-img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.wiz-result-dl { position: absolute; bottom: 8px; right: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 8px; border: 1px solid #3f3f46; background: rgba(0,0,0,.82); color: #fff; font-size: 12px; font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s; }
.wiz-result-dl:hover { background: var(--brand); border-color: var(--brand); }
.wiz-results-empty { max-width: 720px; margin: 4px 0 18px; font-size: 14px; color: #71717a; }

/* Persistent brand chip (shown on steps 2-5): the brief, demoted to context. */
#wiz-chip { margin: 0 0 18px; }
.wiz-chip-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 9999px;
  border: 1px solid #27272a; background: #09090b; color: #a1a1aa; font-size: 12px; cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
}
.wiz-chip-btn:hover { border-color: #3f3f46; color: #fff; }
.wiz-chip-btn b { color: #e4e4e7; font-weight: 600; }
.wiz-chip-dot { width: 7px; height: 7px; border-radius: 9999px; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.wiz-chip-edit { color: #71717a; text-decoration: underline; text-underline-offset: 2px; }
.wiz-chip-btn:hover .wiz-chip-edit { color: #a5b4fc; }

/* Narrow screens: the rail stacks on top instead of fixing to the side. */
@media (max-width: 720px) {
  #wizard-rail { position: static; width: 100%; height: auto; bottom: auto; border-right: 0; border-bottom: 1px solid #18181b; }
  body.wizard-on #app-shell { margin-left: 0; }
  .wiz-foot { margin-top: 14px; }
}
