/* Generate page — page-specific styles. Tokens, base form controls, button
   variants, and the .rb-topnav primitive come from /shared/brand.css. */

[hidden] {
  display: none !important;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* The chat benefits from a wider canvas while the form-heavy modes retain
   their deliberately compact reading width. generate.js keeps this data
   attribute in sync with the active tab. */
#app[data-mode="agent"] {
  max-width: 1160px;
}
#app[data-mode="agent"] #recent-runs-section {
  display: none;
}

#page-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 12px 0;
}
.group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.group h3 {
  margin: 0;
  font-family: var(--font-headline);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}
.group label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
/* One-line pointer shown under the tabstrip when the AG Guide has moved to
   its own host (generate.js AGGUIDE_MOVED_URL); the tab itself is removed. */
.agguide-moved {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted, var(--muted, #555));
}
.agguide-moved a {
  color: var(--accent, #d9531e);
  font-weight: 600;
  text-decoration: underline;
}

.hint {
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 400;
}
.hint code {
  font-family: var(--font-mono);
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

textarea {
  resize: vertical;
  min-height: 140px;
  font-family: var(--font-mono);
  font-size: 13px;
}

#badge-texts {
  text-transform: uppercase;
}

.copy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .copy-grid { grid-template-columns: 1fr; }
}

.copy-warning {
  padding: 8px 12px;
  border: 1px solid var(--state-warning);
  border-radius: 4px;
  background: rgba(255, 196, 0, 0.10);
  color: var(--state-warning);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

#image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
#image-list:empty { display: none; }

#image-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.image-filter-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
  cursor: pointer;
}
.image-filter-btn:hover { color: var(--fg); border-color: var(--fg-muted); }
.image-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  /* Black, as on .rb-btn-accent: white on brand orange is only ~3:1. */
  color: var(--rb-black);
}
#image-filter .hint { margin-left: auto; }

.thumb {
  position: relative;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.thumb img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}
.thumb figcaption {
  font-size: 11px;
  color: var(--fg-muted);
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border);
}
.thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rb-black);
  color: var(--rb-white);
  border: none;
}
.thumb-remove:hover {
  background: var(--accent);
  color: var(--rb-white);
}
.thumb-hidden { display: none; }
.thumb-chip {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border: none;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--rb-white);
}
.thumb-chip-single { background: var(--accent); color: var(--rb-black); }
.thumb-chip-multi { background: var(--rb-black); }

#dimensions-controls {
  display: flex;
  gap: 8px;
}
#dimensions-controls button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--btn-radius-sm);
}

#dimensions-custom {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: var(--surface-alt);
}
#dimensions-custom .dim-custom-field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}
#dimensions-custom input[type="number"] {
  width: 90px;
  padding: 6px 8px;
  font-variant-numeric: tabular-nums;
}
#dimensions-custom #custom-add {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--btn-radius-sm);
}
#dimensions-custom .hint { margin-left: auto; }

#dimensions {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.dim-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dim-item:hover {
  border-color: var(--fg);
}
.dim-item:has(input:checked) {
  border-color: var(--accent);
  background: rgba(232, 117, 17, 0.04);
}
.dim-item input {
  margin: 0;
  padding: 0;
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}
/* One-shot pulse confirming a freshly-added custom size. JS adds
   .dim-item-added then removes it on animationend, so the row self-resets. */
.dim-item-added {
  animation: dim-item-pulse 1s ease-out 1;
}
@keyframes dim-item-pulse {
  0%   { background: rgba(232, 117, 17, 0.22); }
  100% { background: rgba(232, 117, 17, 0.04); }
}
.dim-label {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.dim-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--fg-muted);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-alt);
  white-space: nowrap;
}

#generate {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#status {
  min-height: 1.2em;
  color: var(--fg-muted);
  font-size: 13px;
}
#status.warn { color: var(--state-warning); }
#status.error { color: var(--state-error); }

.progress {
  width: 100%;
  height: 8px;
  background: var(--rb-black-10);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.15s ease;
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Transient note shown when an SSE stream dropped and recovered, so the
   forward jump in the bar isn't silent. Cleared on the next progress render. */
.progress-recovered {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--state-warning);
}

#results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#results:empty { display: none; }

.results-path {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
}
.results-path code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.results-path .copy-path {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--btn-radius-sm);
}
/* "View run" links look and press like an accent button. One rule for the
   Light results, the recent-runs list and the Ultra results; each selector is
   scoped so the Agent transcript's .agent-run-view.view-run link keeps its own
   plain-link style. */
.results-path .view-run,
.recent-runs .view-run,
#ultra-results .view-run {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  /* Black, as on .rb-btn-accent: white on brand orange is only ~3:1. */
  color: var(--rb-black);
  text-decoration: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--btn-radius-sm);
  box-shadow: var(--btn-shadow);
  transition: var(--btn-transition);
}
.results-path .view-run:hover,
.recent-runs .view-run:hover,
#ultra-results .view-run:hover {
  color: var(--rb-black);
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--btn-shadow-hover);
  translate: 0 var(--btn-lift);
}
.results-path .view-run:active,
.recent-runs .view-run:active,
#ultra-results .view-run:active {
  box-shadow: var(--btn-shadow-press);
  translate: 0 var(--btn-sink);
}

.recent-runs {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recent-runs li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
}
.recent-runs .recent-meta {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#results details {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
#results details > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  user-select: none;
}
#results details > summary::-webkit-details-marker { display: none; }
#results details > summary::before {
  content: '▸';
  display: inline-block;
  width: 14px;
  color: var(--fg-muted);
  transition: transform 0.1s ease;
}
#results details[open] > summary::before { transform: rotate(90deg); }

.results-list {
  margin: 0;
  padding: 4px 12px 12px 36px;
  list-style: disc;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
}
.results-list li { word-break: break-all; }

.results-error-header {
  margin: 8px 0 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--state-error);
}
.results-errors { color: var(--state-error); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
}
.modal-card {
  max-width: 460px;
  width: 100%;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-card h3 {
  margin: 0;
  font-family: var(--font-headline);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}
.modal-summary {
  margin: 0;
  font-size: 15px;
  color: var(--fg);
  line-height: 1.5;
}
.modal-summary strong {
  color: var(--accent);
  font-weight: 700;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
/* Black label, as on .rb-btn-accent: white on brand orange is only ~3:1. */
.modal-confirm {
  background: var(--accent);
  color: var(--rb-black);
  border-color: var(--accent);
}
.modal-confirm:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--rb-black);
}

/* §3.3 — tab strip between page-head and the first panel section. Tokens
   from /shared/brand.css; no new colors. */
.rb-tabstrip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.035);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
  margin-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}
/* Segmented control: the strip is a recessed track, idle tabs sit flat in it,
   the selected tab is the raised glass segment, and any tab presses in while
   held. Tabs do not lift on hover; the track keeps them level. */
.rb-tabstrip [role="tab"] {
  position: relative;
  min-width: 0;
  min-height: 58px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--btn-radius-sm);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1.2;
  box-shadow: none;
  translate: none;
  transition: var(--btn-transition);
}
.rb-tabstrip [role="tab"]:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.72);
}
/* Greyed (restricted) tab — present but inert, e.g. Maintenance Agent for
   anyone who isn't its allowlisted operator. */
.rb-tabstrip [role="tab"][aria-disabled="true"],
.rb-tabstrip [role="tab"][aria-disabled="true"]:hover {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--fg-muted);
  background: transparent;
  box-shadow: none;
}
.rb-tabstrip [data-mode][aria-selected="true"],
.rb-tabstrip[data-active="light"] [data-mode="light"],
.rb-tabstrip[data-active="ultra"] [data-mode="ultra"],
.rb-tabstrip[data-active="bulk"]  [data-mode="bulk"] {
  color: var(--fg);
  background: var(--btn-glass-fill);
  box-shadow: var(--btn-shadow);
}
.rb-tabstrip [role="tab"]:not([aria-disabled="true"]):active {
  box-shadow: var(--btn-shadow-press);
  translate: 0 var(--btn-sink);
}
.rb-tabstrip [data-mode][aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 4px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
}
.rb-tab-tag {
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.025em;
  margin-left: 0;
}
/* Keep one unambiguous tab row on narrow screens. Horizontal scroll is less
   surprising than a wrapped tablist whose active underline changes rows. */
@media (max-width: 760px) {
  .rb-tabstrip {
    grid-template-columns: repeat(6, minmax(132px, 1fr));
    scroll-snap-type: x proximity;
  }
  .rb-tabstrip [role="tab"] {
    min-height: 54px;
    padding: 8px 12px;
    scroll-snap-align: start;
  }
}
#light-panel:not([hidden]),
#ultra-panel:not([hidden]),
#bulk-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.recent-runs .recent-mode {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.recent-runs .recent-mode-ultra {
  background: var(--accent);
  color: var(--rb-white);
  border-color: var(--accent);
}

/* §3.4 — ultra panel layout. KPI strip mirrors the PDF report's hero band;
   the winners list is a flex-wrap grid of selection cards. */
.ultra-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.ultra-kpi-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 64px;
}
.ultra-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}
.ultra-kpi-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
}
.ultra-pattern-callout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: var(--surface-alt);
}
.ultra-pattern-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.ultra-winners {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.ultra-winner-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: default;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ultra-winner-card:hover { border-color: var(--fg-muted); }
.ultra-winner-selected {
  border-color: var(--accent);
  background: rgba(232, 117, 17, 0.06);
}
.ultra-winner-pick {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
}
.ultra-winner-pick input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.ultra-winner-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-alt);
  display: block;
}
.ultra-winner-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-align: center;
  padding: 8px;
  word-break: break-word;
}
.ultra-winner-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}
.ultra-winner-ctr {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.ultra-winner-ctr small {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--fg-muted);
}
.ultra-winner-spend,
.ultra-winner-imps {
  font-size: 11px;
  color: var(--fg);
}
.ultra-winner-headline {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ultra-winner-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 10px;
}
.ultra-winner-template,
.ultra-winner-rank,
.ultra-winner-campaign {
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-alt);
  color: var(--fg-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ultra-winner-template-select {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--surface-alt);
  color: var(--fg-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  max-width: 100%;
}
.ultra-winner-empty,
.ultra-winner-error {
  list-style: none;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--fg-muted);
  font-size: 13px;
}
.ultra-winner-error { color: var(--state-error); }
.ultra-winner-error .ultra-pack-retry {
  margin-left: 10px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--btn-radius-sm);
}
/* Elapsed-seconds caption shown alongside the loading skeleton so a long cold
   load reads as progressing, not hung. Spans the winners grid so it sits above
   the skeleton cards. */
.ultra-pack-elapsed {
  grid-column: 1 / -1;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.ultra-skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 0%, var(--surface) 50%, var(--surface-alt) 100%);
  background-size: 200% 100%;
  animation: ultra-shimmer 1.4s ease-in-out infinite;
  min-height: 64px;
  border-radius: 4px;
}
.ultra-winner-card.ultra-skeleton {
  min-height: 240px;
  border-style: dashed;
}
@keyframes ultra-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

label.ultra-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
label.ultra-inline input[type="number"] {
  width: 80px;
  padding: 6px 8px;
  font-variant-numeric: tabular-nums;
}

#ultra-account {
  width: 100%;
}
#ultra-refresh {
  align-self: flex-start;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--btn-radius-sm);
}
#ultra-dimensions {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
#ultra-status {
  min-height: 1.2em;
  color: var(--fg-muted);
  font-size: 13px;
}
#ultra-status.warn { color: var(--state-warning); }
#ultra-status.error { color: var(--state-error); }

#ultra-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#ultra-results:empty { display: none; }
#ultra-results .results-path {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
}
#ultra-results .results-path code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#ultra-results .copy-path {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--btn-radius-sm);
}
#ultra-results details {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
#ultra-results details > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  user-select: none;
}
#ultra-results details > summary::-webkit-details-marker { display: none; }
#ultra-results details > summary::before {
  content: '▸';
  display: inline-block;
  width: 14px;
  color: var(--fg-muted);
  transition: transform 0.1s ease;
}
#ultra-results details[open] > summary::before { transform: rotate(90deg); }
#ultra-results .results-list {
  margin: 0;
  padding: 4px 12px 12px 36px;
  list-style: disc;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
}
#ultra-results .results-list li { word-break: break-all; }
#ultra-results .results-error-header {
  margin: 8px 0 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--state-error);
}
#ultra-results .results-errors { color: var(--state-error); }

.combobox {
  position: relative;
}
.combobox input[type="text"] {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  box-sizing: border-box;
}
.combobox input[type="text"]:focus {
  outline: none;
  border-color: var(--fg);
}
.combobox input[type="text"]:disabled {
  background: var(--surface-alt);
  color: var(--fg-muted);
  cursor: not-allowed;
}
.combobox-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 320px;
  overflow-y: auto;
  z-index: 210;
}
.combobox-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.combobox-item.active,
.combobox-item:hover {
  background: var(--surface-alt);
  border-left-color: var(--fg);
}
.combobox-name {
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combobox-meta {
  font-size: 11px;
  color: var(--fg-subtle);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combobox-empty,
.combobox-more {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--fg-muted);
  font-style: italic;
}

.ultra-campaign-label .combobox { margin-top: 4px; }
.ultra-campaign-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; font-size: 18px; line-height: 1;
  color: var(--fg-subtle); cursor: pointer; padding: 2px 6px; border-radius: 3px;
  /* A bare glyph inside the input, not a raised button. */
  box-shadow: none; translate: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.ultra-campaign-clear:hover { background: var(--surface-alt); color: var(--fg); }

/* Bulk-Upload tab — Segment 3. Tokens reuse /shared/brand.css; no new colors.
   `.row-*` and `.warn-*` are scoped to bulk tables to avoid leaking into the
   Light/Ultra panels. */
.bulk-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 16px;
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.bulk-dropzone:hover { border-color: var(--fg-muted); }
.bulk-dropzone.is-active {
  background: rgba(232, 117, 17, 0.06);
  border-color: var(--accent);
}
.bulk-dropzone-label {
  text-align: center;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}

.bulk-naming-help {
  font-size: 12px;
  color: var(--fg);
  display: inline-block;
  margin-top: 6px;
  text-decoration: underline;
}
.bulk-naming-help:hover { color: var(--accent); }
.bulk-naming-doc {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg);
}
.bulk-naming-doc code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
}

.bulk-summary {
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-muted);
  text-transform: none;
  letter-spacing: normal;
}

/* Scroll container for the 6-column preview table: lets Matches/Warnings
   columns scroll into view on narrow viewports instead of clipping, with a
   right-edge gradient fade hinting there's more. The fade is painted on the
   scroll box itself and stays pinned because the box is the scroll viewport. */
.bulk-table-scroll {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bulk-table-scroll::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--surface));
}

.bulk-preview-table,
.bulk-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}
/* Sticky header so column labels stay visible while scrolling a long batch.
   z-index sits below .combobox-list (210) and modals so dropdowns/overlays
   still paint above it; the solid surface fill keeps rows from showing
   through as they scroll under the header. */
.bulk-table-scroll .bulk-preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}
.bulk-preview-table th,
.bulk-results-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--fg-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
}
.bulk-preview-table td,
.bulk-results-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--fg);
}
.bulk-preview-table code,
.bulk-results-table code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-alt);
  padding: 1px 4px;
  border-radius: 3px;
  word-break: break-all;
}
/* Loading placeholders for the preview body while /api/bulk/preview is in
   flight. Reuses the Ultra shimmer keyframes (.ultra-skeleton) so the body
   reads as pending instead of blank under the header. Non-interactive. */
.bulk-skeleton-row td { vertical-align: middle; }
.bulk-skeleton-cell {
  height: 14px;
  border-radius: 3px;
}

.bulk-preview-table tr.row-blocked { opacity: 0.55; }
.bulk-preview-table .row-error,
.bulk-results-table tr.row-error td { color: var(--state-error); }
.bulk-results-table tr.row-ok td   { color: var(--fg); }
/* Duplicate guard: the ad already existed in the target ad set (retry of a
   chunk that landed despite an edge timeout) — informational, not an error. */
.bulk-results-table tr.row-exists td { color: var(--fg-muted, #777); }
.row-warn { color: var(--state-warning); }

/* Degraded bulk result: sizes that were meant to group into one Flexible ad but
   shipped as separate single-image ads (Meta rejected the grouped shape). */
.bulk-degraded {
  color: var(--state-warning);
  font-size: 11px;
  margin-top: 3px;
}

/* Staged-files controls (task 7): accumulate across picks + clear. */
.bulk-files-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.bulk-clear-files {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--btn-radius-sm);
  cursor: pointer;
}
/* Names the files that were refused at staging (not images) so a drop that
   stages fewer files than were dropped explains itself. Warning-coloured, not
   error-coloured: the rest of the batch is fine and still previews. */
.bulk-files-skipped {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--state-warning);
  background: rgba(0, 0, 0, 0.03);
  color: var(--state-warning);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Schedule-CSV (task 5) per-ad URL match note + summary banner. */
.bulk-schedule {
  font-size: 11px;
  margin-top: 3px;
  color: var(--text-muted, #555);
}
.bulk-schedule-warn { color: var(--state-warning); }
.bulk-schedule-dates { opacity: 0.85; }
.bulk-schedule-banner {
  font-size: 12px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.04);
}
.bulk-schedule-warnings {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--state-warning);
}

/* Failed-preview row (task 7 issue 3): keeps the staged files recoverable
   in place with a Retry button instead of a dead table + stale push button. */
.bulk-preview-failed {
  padding: 14px 12px;
  text-align: center;
  color: var(--state-warning);
  font-size: 13px;
}
.bulk-retry-preview {
  margin-top: 8px;
  padding: 6px 14px;
  border: 1px solid currentColor;
  border-radius: var(--btn-radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.bulk-retry-preview:hover { background: rgba(178, 106, 0, 0.08); }
.bulk-retry-preview:disabled { cursor: default; opacity: 0.7; }
.bulk-retry-preview:disabled:hover { background: transparent; }

/* Push paused by Meta's rate limit (Kelvin 2026-08-14): the push is not
   failed, it is waiting out Meta's block and will resume the remaining ticked
   rows on its own. Warning-coloured, inline under the Push button, with a
   Stop that hands control back to the operator. */
.bulk-push-paused {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--state-warning);
  background: rgba(0, 0, 0, 0.03);
  color: var(--state-warning);
  font-size: 13px;
  line-height: 1.45;
}
.bulk-push-paused-stop {
  padding: 4px 12px;
  border: 1px solid currentColor;
  border-radius: var(--btn-radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.bulk-push-paused-stop:hover { background: rgba(178, 106, 0, 0.08); }

.warn-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(178, 106, 0, 0.12);
  color: var(--state-warning);
  margin: 1px 4px 1px 0;
  white-space: nowrap;
}
.warn-chip.warn-no-pattern,
.warn-chip.warn-no-campaign,
.warn-chip.warn-no-live-adset,
.warn-chip.warn-adset-expired,
.warn-chip.warn-no-sibling,
.warn-chip.warn-below {
  background: rgba(176, 39, 26, 0.12);
  color: var(--state-error);
}
/* Not a warning: marks a preview row as a video (and shows its length). */
.warn-chip.bulk-video-chip {
  background: rgba(60, 72, 88, 0.12);
  color: inherit;
  margin-left: 6px;
}
.warn-chip.warn-review,
.warn-chip.warn-at-threshold,
.warn-chip.warn-campaign-paused,
.warn-chip.warn-sibling-borrowed {
  background: rgba(178, 106, 0, 0.16);
  color: var(--state-warning);
}

/* Per-row state chips for the Part 3 routing-fix UI. Live next to adset /
   campaign names; thinner than warn-chips so they don't compete visually
   with the row-level warning column. */
.bulk-state-chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 3px;
  font-weight: 600;
  vertical-align: middle;
}
.bulk-state-campaign-paused {
  background: rgba(178, 106, 0, 0.16);
  color: var(--state-warning);
  border: 1px solid var(--state-warning);
}
.bulk-state-inherit-paused {
  background: rgba(74, 99, 120, 0.12);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  font-weight: 500;
}
.bulk-state-adset-paused {
  background: rgba(178, 106, 0, 0.12);
  color: var(--state-warning);
  border: 1px solid var(--state-warning);
  font-weight: 500;
}
.bulk-state-expired {
  background: rgba(176, 39, 26, 0.12);
  color: var(--state-error);
  border: 1px solid var(--state-error);
}
/* Borrowed-copy chip (Kelvin task 7): an empty ad set that will clone its copy
   from a peer ad set in the same campaign. Informational amber — benign and
   operator-overridable, distinct from the red "expired" hard-reject. */
.bulk-state-borrowed {
  background: rgba(178, 106, 0, 0.12);
  color: var(--state-warning);
  border: 1px solid var(--state-warning);
  font-weight: 500;
}

/* Expired adset rows: greyed but readable. :has() ships in modern Chrome /
   Safari / Firefox; older browsers fall back to no opacity which is still
   readable thanks to the EXPIRED chip + disabled checkbox. */
.bulk-adset-pick:has(input[data-expired="1"]) { opacity: 0.6; }

.bulk-match {
  margin-bottom: 6px;
  padding: 4px 6px;
  border-left: 2px solid var(--border-strong);
}
/* Campaign blocks outside the operator's status filter: unticked + dimmed.
   Checkboxes stay operable — a manual re-tick is an explicit override. */
.bulk-match.bulk-filtered-out { opacity: 0.45; }

/* Campaign-status scope radios above the preview table (task 8). */
.bulk-status-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
  font-size: 13px;
}
.bulk-status-filter-label { font-weight: 600; }
.bulk-status-filter label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bulk-status-filter-hint { flex-basis: 100%; }
/* Bulk tick / untick for every campaign the filter is showing (Kelvin 7/23). */
.bulk-tick-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.bulk-tick-all-btn {
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--border, #c9c9c9);
  border-radius: var(--btn-radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.bulk-tick-all-btn:hover:not(:disabled) { background: rgba(127, 127, 127, 0.12); }
.bulk-tick-all-btn:disabled { opacity: 0.45; cursor: default; }
.bulk-match-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.bulk-adset-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 20px;
  font: inherit;
  font-weight: 400;
}
.bulk-adset-tick:disabled,
.bulk-campaign-tick:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Locked adset rows: dim + a faint diagonal hatch so the disabled state reads
   at a glance (not just a slightly-faded checkbox). The hatch is drawn behind
   the row content with a low-alpha border-strong tint; not-allowed cursor
   reinforces it on hover. */
.bulk-adset-pick:has(.bulk-adset-tick:disabled),
.bulk-adset-pick:has(.bulk-adset-tick[aria-disabled="true"]) {
  cursor: not-allowed;
  color: var(--fg-muted);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 5px,
    rgba(74, 99, 120, 0.10) 5px,
    rgba(74, 99, 120, 0.10) 7px
  );
  border-radius: 3px;
}

/* R3 confirm strip: yellow band above the campaign blocks on at-threshold
   rows. Disabled adset ticks read at 0.55 alpha so the operator sees the
   gate even without hovering. */
.bulk-row-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  margin-bottom: 4px;
  background: rgba(178, 106, 0, 0.10);
  border: 1px solid var(--state-warning);
  border-radius: 3px;
  font-weight: 600;
  color: var(--state-warning);
}
.warn-ok {
  font-size: 11px;
  color: var(--state-success);
  font-weight: 600;
}

.sibling-excerpt { max-width: 280px; word-break: break-word; }
.sibling-excerpt small { color: var(--fg-muted); }
.adset-list { max-width: 240px; word-break: break-word; }
.adset-fanout {
  color: var(--fg-muted);
  font-size: 11px;
  margin-top: 2px;
}
.bulk-campaign-name { white-space: normal; word-break: break-word; }

#bulk-push { margin-top: 12px; align-self: flex-start; }

/* Bulk Upload polish (2026-11-13). `.group label` (generic form fields) is a
   flex COLUMN, and it out-ranks the single-class bulk rules, so every checkbox
   and radio in this tab rendered stacked above its own text. Re-assert a row
   layout for the tick/radio labels, scoped to the bulk panel. */
#bulk-panel .bulk-adset-pick,
#bulk-panel .bulk-match-header,
#bulk-panel .bulk-row-confirm,
#bulk-panel .bulk-status-filter label {
  flex-direction: row;
  align-items: center;
  text-align: left;
  gap: 8px;
}
#bulk-panel .bulk-status-filter label { font-weight: 500; }
#bulk-panel .bulk-adset-pick {
  font-weight: 400;
  margin: 0 0 0 22px;
  padding: 3px 4px;
  border-radius: 4px;
  flex-wrap: wrap;
  align-items: flex-start;
  row-gap: 3px;
}
#bulk-panel .bulk-adset-pick input { margin-top: 2px; }
/* The name keeps a floor so a wide chip wraps to the next line instead of
   squeezing the name to a letter per line. */
#bulk-panel .bulk-adset-name { flex: 1 1 8em; min-width: 8em; overflow-wrap: anywhere; }
#bulk-panel .bulk-adset-pick .bulk-state-chip,
#bulk-panel .bulk-adset-pick .row-warn { flex: 0 1 auto; min-width: 0; margin-left: auto; }
#bulk-panel .bulk-adset-pick .bulk-state-borrowed { white-space: normal; overflow-wrap: anywhere; }
#bulk-panel .bulk-adset-pick:hover { background: var(--surface-alt); }
#bulk-panel .bulk-adset-pick input,
#bulk-panel .bulk-match-header input,
#bulk-panel .bulk-row-confirm input { margin: 0; flex: none; }
#bulk-panel .bulk-state-chip { margin-left: 0; }

/* Campaign blocks: a light card per campaign with its ad sets nested under it. */
#bulk-panel .bulk-match {
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
}
#bulk-panel .bulk-match:last-child { margin-bottom: 0; }
#bulk-panel .bulk-match-header {
  flex-wrap: nowrap;
  align-items: flex-start;
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
#bulk-panel .bulk-match-header input { margin-top: 2px; }
#bulk-panel .bulk-match-header .bulk-state-chip { flex: none; }
#bulk-panel .bulk-campaign-name {
  flex: 1 1 0;
  min-width: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  background: none;
  padding: 0;
  word-break: normal;
  overflow-wrap: anywhere;
}
#bulk-panel .adset-list { max-width: none; }

/* File cell: thumbnail + a readable name that wraps at separators instead of
   being chopped mid-word into grey boxes. */
.bulk-file-cell { display: flex; align-items: flex-start; gap: 10px; min-width: 140px; }
.bulk-thumb {
  flex: none;
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.bulk-file-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.bulk-file-name {
  font-size: 12px;
  line-height: 1.4;
  word-break: normal;
  overflow-wrap: anywhere;
}
.bulk-file-meta .bulk-video-chip { margin-left: 0; }
.bulk-pattern { white-space: nowrap; }

/* Column balance: File and Matches get the room; Pattern/Size stay compact. */
/* Fixed column floors only where there is room for them; narrower windows
   keep the auto layout, which fits without a sideways scroll. */
@media (min-width: 1200px) {
  .bulk-preview-table td:nth-child(2),
  .bulk-preview-table td:nth-child(3) { white-space: nowrap; }
  .bulk-preview-table td:nth-child(1) { width: 22%; }
  .bulk-preview-table td:nth-child(4) { width: 38%; min-width: 300px; }
  .bulk-preview-table td:nth-child(5) { width: 18%; min-width: 170px; }
  .bulk-preview-table td:nth-child(6) { min-width: 120px; }
  .bulk-file-cell { min-width: 200px; }
}

/* The preview and results tables need more room than the 900px form column:
   let those two sections widen to the window (up to 1320px), centred. */
@media (min-width: 1000px) {
  #bulk-preview-section,
  #bulk-results-section {
    margin-inline: calc((100% - min(1320px, 100vw - 48px)) / 2);
  }
}
#bulk-panel .sibling-excerpt { word-break: normal; overflow-wrap: break-word; }
.bulk-preview-table tbody tr:hover > td { background: rgba(127, 127, 127, 0.04); }

/* The long ticking explanation now sits behind a toggle. */
#bulk-panel .bulk-status-filter-hint { flex-basis: 100%; font-size: 12px; }
#bulk-panel .bulk-status-filter-hint > summary {
  cursor: pointer;
  color: var(--fg-muted);
  width: max-content;
}
#bulk-panel .bulk-status-filter-hint > summary:hover { color: var(--fg); }
#bulk-panel .bulk-status-filter-hint > .hint { display: block; margin-top: 6px; max-width: 72ch; }

/* Keep Push reachable on long batches: it rides the bottom of the window
   while the preview is scrolled. */
#bulk-panel #bulk-push {
  position: sticky;
  bottom: 16px;
  z-index: 2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.bulk-naming-industries { margin: 4px 0 6px; padding-left: 18px; }
.bulk-naming-industries li { margin: 1px 0; }

/* Dropzone: a clearer target with an icon-like cue. */
#bulk-panel .bulk-dropzone { min-height: 110px; border-radius: 10px; }
#bulk-panel .bulk-dropzone-label { font-size: 14px; color: var(--fg); }
#bulk-panel .bulk-dropzone-label::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background:
    linear-gradient(var(--accent), var(--accent)) center / 2px 14px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 14px 2px no-repeat,
    rgba(232, 117, 17, 0.12);
}

/* Bulk "Ad copy (optional)" repeaters. Copied from meta.css's .copy-* rules
   (the /generate surface loads only shared/brand.css + generate.css, not
   meta.css). Vanilla CSS, same CSS vars as the rest of the bulk tab. */
.bulk-copy-details > .hint { display: block; margin: 6px 0 10px; }
.bulk-copy-details > div { margin-bottom: 12px; }
.copy-repeater {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.copy-repeater > label { font-weight: 600; }
.copy-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.copy-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.copy-row > input[type="text"],
.copy-row > textarea {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  box-sizing: border-box;
  width: auto;
}
.copy-row > textarea {
  min-height: 44px;
  resize: vertical;
}
/* .copy-add / .copy-remove live in /shared/brand.css (shared with Meta). */
.copy-counter {
  margin-top: 4px;
}

/* AG Guide tab */
.ag-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}
.ag-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ag-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.ag-field-grid label {
  min-width: 0;
}
.ag-field-wide {
  grid-column: 1 / -1;
}
.ag-field-grid textarea {
  min-height: 74px;
  font-family: inherit;
}
/* Asana project picker: search input + button on one row. */
.ag-asana-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.ag-finalize-result {
  margin-top: 8px;
}
.ag-tm-library-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.ag-tm-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.ag-tm-actions .rb-btn {
  white-space: nowrap;
}
.ag-tm-headshot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 12px;
  align-items: end;
}
.ag-tm-headshot-preview {
  width: 78px;
  height: 78px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  overflow: hidden;
}
.ag-tm-headshot-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Hero image for the auction web page: revealed only when the operator answers
   Yes to the hero question, and pushed to Asana rather than printed. */
.ag-hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  align-items: end;
}
.ag-hero-row[hidden] {
  display: none;
}
.ag-hero-preview {
  width: 96px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  overflow: hidden;
}
.ag-hero-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#ag-tm-status {
  min-height: 1.2em;
  color: var(--fg-muted);
  font-size: 12px;
}
#ag-tm-status.error {
  color: var(--state-error);
}
.ag-viewing-preview {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--fg-muted);
  min-height: 1.1em;
}
.ag-viewing-preview.error {
  color: var(--state-error);
}
.ag-section-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--fg-muted);
}
.ag-autofill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.ag-autofill-row .ag-section-hint {
  margin: 0;
}
.ag-tm-combo {
  position: relative;
}
.ag-tm-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.ag-tm-results li {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.ag-tm-results li.active,
.ag-tm-results li:hover {
  background: var(--surface-alt, rgba(232, 117, 17, 0.12));
}
.ag-tm-results li.none {
  color: var(--fg-muted);
  cursor: default;
}
.ag-tm-result-meta {
  display: block;
  font-size: 11px;
  color: var(--fg-muted);
}
.ag-consigners {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 10px;
}
.ag-consigner-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: end;
}
.ag-consigner-row .ag-consigner-name-field {
  grid-column: 1 / -1;
}
.ag-consigner-remove {
  align-self: end;
  white-space: nowrap;
}
.ag-tm2 {
  margin-top: 12px;
}
.ag-tm2 > .rb-btn {
  margin-bottom: 4px;
}
#ag-tm2-fields[hidden] {
  display: none;
}
.ag-auto-brighten {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
}
.ag-auto-brighten input {
  width: auto;
  margin: 0;
}
.ag-order {
  margin-bottom: 12px;
}
.ag-order-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.ag-order-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
}
.ag-order-radio input {
  width: auto;
  margin: 0;
}
.ag-order-help {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--fg-muted);
}
.ag-order-reset {
  margin-top: 8px;
}
.ag-bulk {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2, rgba(255, 255, 255, 0.02));
  color: var(--fg-muted);
  font-size: 12.5px;
  cursor: pointer;
}
.ag-bulk:hover { border-color: var(--fg); }
.ag-bulk.ag-drop {
  border-color: var(--accent, #E87511);
  background: rgba(232, 117, 17, 0.08);
}
.ag-bulk-icon { font-size: 18px; line-height: 1; }
.ag-bulk-text strong { color: var(--fg); }
.ag-slots {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ag-page-slots {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ag-page-slots-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ag-slot-row {
  display: grid;
  gap: 5px;
}
.ag-slot-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ag-slot-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ag-slot-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ag-slot {
  position: relative;
  min-height: 82px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: #D5102E;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ag-slot:hover {
  border-color: var(--fg);
}
.ag-slot[draggable="true"] { cursor: grab; }
.ag-slot.ag-dragging { opacity: .5; }
.ag-slot.ag-slot-drop-target { outline: 2px dashed var(--accent, #E87511); outline-offset: 2px; }
.ag-slot img {
  width: 100%;
  height: 100%;
  min-height: 82px;
  object-fit: cover;
  display: block;
  /* Live framing preview: the box is the printed image shape (see
     .ag-slot-row-sized) and the thumbnail is scaled about its centre by the
     zoom in force, so what shows is the centred cover crop the page gets.
     Four-column rows focus the vertical crop where the detector found the
     machine (object-position), exactly as the renderer does. */
  transform: scale(var(--ag-zoom, 1));
  transform-origin: 50% 50%;
  object-position: 50% calc(var(--ag-focus-y, 0.5) * 100%);
  transition: transform 0.15s ease;
}
/* Rows with server preview geometry: a filled box stacks a print-shaped photo
   frame, the zoom pill row, and the name field, so the whole crop is visible
   and the controls never cover it (the four-column frames are too short for
   overlays). Empty boxes keep the plain add target. */
.ag-slot-row-sized .ag-slot-sized {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  background: #111;
}
.ag-slot-photo {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ag-slot-aspect, 2 / 1);
  overflow: hidden;
  background: #D5102E;
  order: 1;
}
.ag-slot-photo img {
  min-height: 0;
}
.ag-slot-row-sized .ag-slot-sized .ag-slot-zoom {
  position: static;
  order: 2;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.9);
  justify-content: flex-start;
}
.ag-slot-row-sized .ag-slot-sized .ag-slot-caption {
  position: static;
  order: 3;
  border-top: 0;
}
/* Four-column frames are ~110px wide: smaller corner controls so the photo
   stays visible behind them. */
.ag-slot-row-4.ag-slot-row-sized .ag-slot-remove,
.ag-slot-row-4.ag-slot-row-sized .ag-slot-replace,
.ag-slot-row-4.ag-slot-row-sized .ag-slot-secondary {
  width: 17px;
  height: 17px;
  top: 4px;
  font-size: 11px;
}
.ag-slot-row-4.ag-slot-row-sized .ag-slot-remove { right: 4px; }
.ag-slot-row-4.ag-slot-row-sized .ag-slot-replace { right: 24px; }
.ag-slot-row-4.ag-slot-row-sized .ag-slot-secondary { right: 44px; }
.ag-slot-row-4.ag-slot-row-sized .ag-slot-label { top: 4px; left: 4px; padding: 1px 4px; font-size: 9px; }
.ag-slot-label {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 10px;
  font-weight: 700;
  z-index: 2;
}
.ag-slot-label-muted {
  font-weight: 700;
  opacity: 0.75;
}
.ag-slot-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.78);
  color: white;
  line-height: 1;
  z-index: 3;
  cursor: pointer;
}
.ag-slot-empty { background: #D5102E; }
.ag-slot-add {
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  pointer-events: none;
}
.ag-slot-filled { cursor: default; }
.ag-slot-filled[draggable="true"] { cursor: grab; }
.ag-slot-filled.ag-dragging { cursor: grabbing; }
.ag-slot-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 1px 6px;
  line-height: 1.15;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 10px;
  font-family: inherit;
  z-index: 3;
}
.ag-slot-caption:focus {
  outline: 2px solid var(--accent, #E87511);
  outline-offset: -2px;
  background: rgba(0, 0, 0, 0.86);
}
/* Selecting the equipment name must stay readable. The field paints white text on
   a dark bar; with no ::selection rule the browser falls back to its default
   selected-text colour (dark glyphs), which reads as near-black on the dark bar
   (Venice 2026-07-08 "highlighting equipment name is black and hard to read").
   Force white text on the brand accent so the selection is high-contrast. */
.ag-slot-caption::selection {
  color: #fff;
  background-color: var(--accent, #E87511);
}
.ag-slot-caption::-moz-selection {
  color: #fff;
  background-color: var(--accent, #E87511);
}
.ag-slot-replace {
  position: absolute;
  top: 5px;
  right: 31px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.78);
  color: white;
  line-height: 1;
  font-size: 12px;
  z-index: 3;
  cursor: pointer;
}
/* Secondary-consigner mark (AG Guide Phase II): a per-photo asterisk toggle in
   the same circular-button rail as replace/remove. Toggled on = brand accent,
   matching the asterisk the renderer prints on the item and beside the
   secondary consigner line. */
.ag-slot-secondary {
  position: absolute;
  top: 5px;
  right: 57px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.78);
  color: white;
  line-height: 1;
  font-size: 14px;
  font-weight: 700;
  z-index: 3;
  cursor: pointer;
}
.ag-slot-secondary-on { background: var(--accent, #E87511); }
/* Manual per-photo zoom (Anna 2026-09-01): a − Auto/% + pill sitting just above
   the caption bar. The readout doubles as the reset-to-Auto button and flips to
   the brand accent while a manual factor is in force, mirroring the secondary
   toggle's on-state language. */
.ag-slot-zoom {
  position: absolute;
  left: 5px;
  bottom: 26px;
  display: flex;
  align-items: stretch;
  border-radius: 9px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.78);
  -webkit-backdrop-filter: var(--btn-glass-blur);
  backdrop-filter: var(--btn-glass-blur);
  box-shadow: var(--btn-shadow);
  z-index: 3;
}
.ag-slot-zoom-btn,
.ag-slot-zoom-val {
  border: 0;
  padding: 0 6px;
  height: 18px;
  background: transparent;
  color: white;
  line-height: 18px;
  font-size: 11px;
  cursor: pointer;
  /* Segments of the dark zoom pill, which is the raised surface. */
  border-radius: 0;
  box-shadow: none;
  translate: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.ag-slot-zoom-val {
  font-size: 9px;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
  padding: 0 2px;
}
.ag-slot-zoom-btn:hover,
.ag-slot-zoom-val:hover { background: rgba(255, 255, 255, 0.18); }
.ag-slot-zoom-manual .ag-slot-zoom-val { background: var(--accent, #E87511); }
/* Auto readout: the factor the automatic framing will print at (from the
   server's look at the photo), shown beside the pill while Auto is in force. */
.ag-slot-zoom-auto {
  align-self: center;
  padding: 0 6px 0 2px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 9px;
  line-height: 18px;
  white-space: nowrap;
}
.ag-slot-zoom-auto[hidden] { display: none; }
/* Right-hand rail: Output + Save progress live here (Erica 2026-07-10 asked for
   the save button on the right, always in reach) and stick together while the
   long left column scrolls. */
.ag-side {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  /* With a generated preview open the rail can outgrow a laptop viewport; the
     rail scrolls internally so Save progress stays reachable while pinned. */
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
/* Keep the checkpoint history compact inside the sticky rail; the list scrolls
   internally instead of pushing the panel off-screen. */
.ag-side .ag-ckpt-list {
  max-height: 220px;
  overflow-y: auto;
}
#ag-status {
  min-height: 1.2em;
  color: var(--fg-muted);
  font-size: 13px;
}
#ag-status.error {
  color: var(--state-error);
}
.ag-warnings {
  margin: 0;
  padding: 8px 12px 8px 26px;
  border: 1px solid var(--state-warning);
  border-radius: 4px;
  background: rgba(255, 196, 0, 0.10);
  color: var(--state-warning);
  font-size: 12px;
}
.ag-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ag-result .rb-btn {
  align-self: flex-start;
}
.ag-preview-zoom {
  max-width: 180px;
}
#ag-preview {
  width: 100%;
  height: 640px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
}
@media (max-width: 860px) {
  .ag-workspace {
    grid-template-columns: 1fr;
  }
  .ag-side {
    position: static;
  }
}
@media (max-width: 640px) {
  .ag-field-grid {
    grid-template-columns: 1fr;
  }
  .ag-tm-library-row,
  .ag-tm-headshot-row,
  .ag-hero-row {
    grid-template-columns: 1fr;
  }
  .ag-consigner-row {
    grid-template-columns: 1fr;
  }
  .ag-slot-row-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* AG Guide build checkpoints (save progress & rollback) */
.ag-checkpoints .ag-ckpt-bar,
.ag-checkpoints .ag-ckpt-save {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ag-checkpoints .ag-ckpt-bar label { flex: 1 1 200px; }
.ag-checkpoints .ag-ckpt-bar select { width: 100%; }
.ag-checkpoints .ag-ckpt-save input { flex: 1 1 240px; }
.ag-checkpoints .ag-ckpt-search { margin-bottom: 12px; }
.ag-ckpt-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.ag-ckpt-search-head label {
  font-weight: 600;
}
.ag-ckpt-search-head .rb-btn {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
  border-radius: var(--btn-radius-sm);
}
.ag-checkpoints .ag-ckpt-search input { width: 100%; }
.ag-ckpt-search-help,
.ag-ckpt-search-summary {
  display: block;
  margin-top: 4px;
  color: var(--fg-muted);
  font-size: 12px;
}
.ag-ckpt-search-summary:not(:empty) { color: var(--fg); font-weight: 600; }
.ag-ckpt-search-summary[data-state="error"] { color: var(--state-error); }
.ag-ckpt-search-results {
  list-style: none;
  max-height: 240px;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.ag-ckpt-search-results li + li { border-top: 1px solid var(--border); }
.ag-ckpt-search-result {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  /* A list row, not a raised button. */
  box-shadow: none;
  translate: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.ag-ckpt-search-result:hover { background: var(--surface-alt); }
.ag-ckpt-search-result:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.ag-ckpt-search-result-title { font-weight: 600; overflow-wrap: anywhere; }
.ag-ckpt-search-result-meta { color: var(--fg-muted); font-size: 12px; overflow-wrap: anywhere; }
.ag-ckpt-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ag-ckpt-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
}
.ag-ckpt-list li.none {
  color: var(--fg-muted);
  border-style: dashed;
  background: transparent;
  justify-content: flex-start;
}
.ag-ckpt-list li.ag-ckpt-search-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}
.ag-ckpt-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ag-ckpt-title { color: var(--fg); font-weight: 600; overflow-wrap: anywhere; }
.ag-ckpt-meta { color: var(--fg-muted); font-size: 12px; }
.ag-ckpt-restore { flex: 0 0 auto; }

/* Upload progress for Generate / Finalize (Erica 2026-09-02: a 30 MB photo
   upload was the step that failed, silently). A thin accent bar under the
   status line fills as the bytes go up and carries a "12 of 31 MB" label. */
.ag-upload-progress {
  position: relative;
  margin: 6px 0 2px;
  padding-top: 8px; /* the track */
}
.ag-upload-progress::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 4px;
  background: rgba(127, 127, 127, 0.22);
}
.ag-upload-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  width: 0;
  border-radius: 4px;
  background: var(--accent, #E87511);
  transition: width 0.12s linear;
}
.ag-upload-progress-label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--fg-muted, #666);
}
.ag-upload-progress.ag-upload-progress-done .ag-upload-progress-bar { background: #2e9e4f; }
.ag-upload-progress.ag-upload-progress-error .ag-upload-progress-bar { background: #d5102e; }
