/* ChatFlow Creatives view (#creatives-view, design A): the uniqueizer's jobs. Needs
   tokens.css, components.css and chrome.css (.cf-page) first. Page header, the New Job
   form on the shared fields, then the jobs: one card per job with its status as a word
   chip and its variants ranked by frame distance, the decision number first. Chips follow
   the colour language (COLOUR-TOKENS): Queued amber, Running blue, Done green, Failed red,
   Most Distinct green. The form, the jobs and the skeleton are raised surfaces (--shadow-card).
   Colours come from tokens only, so night needs no rules here. Class names are cr-* so
   the old night layer's .flow-list, .flow-card and .wrap rules never reach this view. */

/* The page frame of Settings: the header spans the page, the content stops at 1200px */
.cr-page > .cr-section { max-width: 1200px; }
.cr-section + .cr-section { margin-top: 32px; }
.cr-section > .section-head { margin-bottom: 12px; }
.cr-count { margin-left: 4px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- New Job form ---------- */
.cr-form { display: flex; flex-direction: column; gap: 20px; padding: 16px; overflow: visible; }
.cr-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}
.cr-levels { margin: 0; padding: 0; border: 0; min-width: 0; }
.cr-levels legend { padding: 0; margin-bottom: 6px; }
.cr-level-list { display: flex; flex-wrap: wrap; gap: 0 28px; }
.cr-level-name { font-weight: var(--fw-semibold); }
.cr-level-desc { color: var(--ink-2); }
.cr-form-foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.cr-form-foot .field { width: 150px; }
.cr-form-foot .btn-primary { margin-left: auto; height: var(--field-h); padding: 0 16px; }
/* busy while a request runs; it keeps focus, so it is aria-disabled rather than disabled */
.cr-page .btn[aria-disabled="true"] { opacity: .5; }
/* the form's one line of feedback: validation, "Queuing…", queued, or why it failed */
.cr-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: -8px 0 0;
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
  color: var(--ink-2);
}
.cr-msg:empty { display: none; }
.cr-msg > .ic { flex: none; margin-top: 1px; }
.cr-msg.is-ok { color: var(--ok); }
.cr-msg.is-error { color: var(--alert); font-weight: var(--fw-semibold); }
.cr-msg-text { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Notices and inline errors (a failed load or refresh) ---------- */
.cr-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 8px 8px 8px 12px;
  border-radius: var(--radius-control);
  background: var(--fail-fill);
  color: var(--fail-label);
  font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font);
}
.cr-error > .ic { flex: none; }
.cr-error-text { flex: 1 1 240px; min-width: 0; margin: 0; overflow-wrap: anywhere; }

/* ---------- Jobs ---------- */
.cr-list { display: flex; flex-direction: column; gap: 12px; }
.cr-job-head .row-title { margin: 0; }
.cr-job-head .row-title-line .chip { flex: none; }
.cr-job-head .row-actions a.btn .ic { margin-right: -2px; }
/* the text actions (Drive Folder, Retry, Cancel) sit with Remove on desktop; phones below */
.cr-acts { display: contents; }
/* lines under the head: the wait (queued, running), the failure, the notes */
.cr-job-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: -4px 16px 12px;
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.cr-job-line > .ic { flex: none; margin-top: 1px; }
.cr-job-line b { font-weight: var(--fw-semibold); color: var(--ink); }
.cr-job-fail { padding: 8px 10px; border-radius: var(--radius-control); background: var(--fail-fill); color: var(--fail-label); }
.cr-job-fail .cr-job-text { overflow-wrap: anywhere; }
/* a running job far past its estimate: the worker may have stopped */
.cr-job-warn { padding: 8px 10px; border-radius: var(--radius-control); background: var(--warn-tint); color: var(--warn); }
.cr-job-warn b { color: inherit; }
.cr-job-text { min-width: 0; }

/* Variants: ranked by frame distance, the decision number is the row title */
.cr-vars { border-top: 1px solid var(--line); }
.cr-vars-head { margin: 0; padding: 10px 16px 0; font: var(--fw-semibold) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.cr-var-list { margin: 0; padding: 0; list-style: none; }
.cr-var { min-height: 56px; }
.cr-var-title { font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cr-var .row-meta { white-space: normal; overflow-wrap: anywhere; }
/* with a Most Distinct variant, the runners-up are lighter so the number to pick stands out */
.cr-var.is-other .cr-var-title { font-weight: var(--fw-regular); color: var(--ink-2); }

/* ---------- List states: skeleton and empty ---------- */
.cr-skel { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--pop); box-shadow: var(--shadow-card); overflow: hidden; }
.cr-skel + .cr-skel { margin-top: 12px; }
.cr-skel-row { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 16px; }
.cr-skel-row + .cr-skel-row { border-top: 1px solid var(--line); height: 52px; }
.cr-skel-bar { display: block; height: 12px; border-radius: 4px; background: var(--skeleton-a); animation: cr-pulse 1.2s ease-in-out infinite alternate; }
.cr-skel-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.cr-skel-col .cr-skel-bar:first-child { width: 200px; height: 14px; }
.cr-skel-col .cr-skel-bar:last-child { width: 320px; max-width: 80%; }
.cr-skel-btn { width: 64px; height: 28px; border-radius: var(--radius-control); }
@keyframes cr-pulse { from { background: var(--skeleton-a); } to { background: var(--skeleton-b); } }

.cr-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 24px; }
.cr-empty-title { margin: 0; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.cr-empty-text { margin: 0 0 12px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  .cr-skel-bar { animation: none; }
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
  .cr-form { padding: 12px; }
  .cr-level-list { flex-direction: column; }
  .cr-form-foot .field { width: auto; flex: 1 1 120px; }
  .cr-form-foot .btn-primary { flex: 1 1 100%; margin-left: 0; }
  /* The card reads top to bottom: title and Remove, details, the wait and notes lines,
     then the text actions, then the variants. */
  .cr-job { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .cr-job-head, .cr-job-head > .row-actions { display: contents; }
  .cr-job-head > .row-main { grid-column: 1; padding: 10px 0 10px 16px; }
  .cr-job-head > .row-actions > .icon-btn { grid-column: 2; grid-row: 1; align-self: start; margin: 6px 8px 0 4px; }
  .cr-job > .cr-job-line { grid-column: 1 / -1; }
  .cr-acts { order: 1; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
  .cr-job > .cr-vars { order: 2; grid-column: 1 / -1; }
  .cr-job-head .row-meta { white-space: normal; overflow-wrap: anywhere; }
  .cr-job-head .row-title-line { flex-wrap: wrap; row-gap: 2px; }
  .cr-job-head .row-title { white-space: normal; overflow-wrap: anywhere; }
  .cr-var { align-items: flex-start; padding-right: 8px; }
  .cr-var .row-title-line { flex-wrap: wrap; row-gap: 2px; }
}
@media (pointer: coarse) {
  .cr-form-foot .btn-primary { height: 44px; }
}
