/* B-Roll view (mockups/03-b-roll.png). Desktop (M1): tab strip over a
   three-column grid — source/pace/style/crop/audio cards on the left,
   preview + timeline in the center, output destinations + summary +
   approve on the right. Web (M2, .broll-web-* below): a simpler stacked
   card list — job status, proxy preview + crop guide, actions, library.
   Sharp radii, flat sans, violet primary per tokens.css. */

.broll-tabs {
  margin-bottom: 16px;
}

.tab-disabled {
  opacity: 0.4;
  cursor: default;
}

.broll-worker-advanced {
  margin: 8px 0;
}

.broll-worker-advanced summary {
  cursor: pointer;
  font-size: 0.85em;
  color: var(--text-muted);
}

.broll-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.broll-col-left,
.broll-col-center,
.broll-col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.broll-library-card {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.broll-thumbnail {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
  margin: 6px 0;
}

.broll-selected-source {
  font-weight: 600;
  color: var(--text);
}

.broll-clip-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.broll-clip-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  font: inherit;
}

.broll-clip-row.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.broll-clip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.broll-preset-row,
.broll-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btn-pill,
.btn-choice {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 6px 14px;
  font: inherit;
  cursor: pointer;
}

.btn-choice {
  border-radius: var(--radius-sm);
}

.btn-pill.active,
.btn-choice.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.broll-custom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.broll-plan-summary {
  font-weight: 600;
}

.broll-preview-frame {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-sunken);
  margin: 10px 0;
}

.broll-preview-video {
  width: 100%;
  display: block;
  max-height: 420px;
}

.broll-beat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 4px 0 12px;
}

.broll-beat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  font-size: 0.75em;
  font-weight: 700;
  color: #fff;
}

.broll-beat-r {
  background: var(--coral);
}

.broll-beat-f {
  background: var(--teal);
}

.broll-output-group-label {
  font-size: 0.85em;
  color: var(--text-muted);
  margin: 10px 0 4px;
}

.broll-output-group-label:first-child {
  margin-top: 0;
}

.broll-output-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.broll-output-chip {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: 0.85em;
}

.broll-plan-json {
  max-height: 260px;
  overflow: auto;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.8em;
  white-space: pre-wrap;
  word-break: break-word;
}

.broll-beat-list-row {
  display: grid;
  grid-template-columns: 50px 1fr 50px 70px;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85em;
}

.broll-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.9em;
}

.broll-library-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}

/* ---- Web (M2) ---- */

.broll-web-liveness-card {
  padding: 10px 14px;
}

.broll-web-job-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.broll-web-job-card,
.broll-web-library-card {
  gap: 10px;
}

.broll-web-job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.broll-web-job-title {
  font-weight: 600;
}

.broll-web-status-badge {
  text-transform: none;
}

.broll-web-job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.broll-web-error {
  color: var(--coral);
}

.broll-web-preview-frame {
  position: relative;
}

.broll-crop-guide-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.broll-crop-guide {
  position: absolute;
  border: 2px dashed #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.broll-web-liveness-offline {
  border-color: var(--coral);
}

.broll-web-attach-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.broll-web-attach-select {
  width: 100%;
}

/* ---------- Batch tab (views/broll_batch.js) ---------- */

.broll-batch-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.broll-batch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  text-align: left;
}

.broll-batch-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.broll-batch-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

/* Per-clip failure text: a batch keeps going after one clip fails, so the
   error has to live on its own row rather than in a transient toast. */
.broll-batch-error {
  flex: 1 0 100%;
  margin: 4px 0 0;
  color: var(--danger, #b3261e);
  font-size: 0.85rem;
}

/* Output destinations are TOGGLES now, not labels (owner, 2026-08-02) —
   off by default, so exporting a format is always a deliberate choice. */
.broll-output-chip {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.broll-output-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Plain-language help under each control (views/broll_copy.js). Owner,
   2026-08-03: "It's not really clear what all those controls do." */
.control-help {
  display: block;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 3px;
}

.beat-explainer {
  margin-bottom: 8px;
}

/* Live engine progress. Sticky so it stays visible while the founder
   scrolls a long settings column during a multi-minute render. */
.broll-engine-status {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Watch the source video (wave step B.3): the thumbnail is the play control,
   so it needs to read as pressable without becoming a second button style. */
.broll-source-thumb-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.broll-source-thumb-button:hover .broll-source-play-badge,
.broll-source-thumb-button:focus-visible .broll-source-play-badge {
  opacity: 1;
}

/* The badge brightening is a nicety, not the focus indicator: keyboard focus
   gets the app's standard ring (tokens.css :focus-visible), stated here so
   the button's own overflow/radius can never quietly swallow it. */
.broll-source-thumb-button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.broll-source-play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0.82;
  transition: opacity 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .broll-source-play-badge {
    transition: none;
  }
}

.broll-source-player-error {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
}

.broll-source-player-error-text {
  margin: 0 0 10px;
  line-height: 1.45;
}

/* ---------- Clip source video (views/broll_trim_ui.js) ---------- */
/*
 * A plain overlay modal (rebuilt 2026-08-04). The editor used to be the
 * source card itself, grown into place with a FLIP, a spacer holding its
 * slot and a dim class on the pane — all of which reached into structure
 * other code owns, and broke whenever that code redrew. The overlay owns
 * nothing but itself, so there is nothing to leave behind.
 */

.broll-trim-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;          /* over the views, under toasts (1500) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.broll-trim-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  animation: broll-trim-fade 160ms ease-out;
}

.broll-trim-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  animation: broll-trim-rise 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.broll-trim-panel:focus {
  outline: none;      /* it takes focus on open; the ring would be noise */
}

@keyframes broll-trim-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes broll-trim-rise {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* Reduced motion: appear, do not move. */
.broll-trim-no-motion .broll-trim-backdrop,
.broll-trim-no-motion .broll-trim-panel {
  animation: none;
}

/* A detached modal has to name its subject; the card used to do that. */
.broll-trim-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}

.broll-trim-title-text {
  margin: 0;
  font-size: 1.05em;
}

.broll-trim-title-file {
  margin: 0;
  color: var(--text-muted);
}

.broll-trim-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  margin-top: 10px;
}

.broll-trim-stage {
  /* A DEFINITE height, not flex-derived: the panel has no fixed height, so
     a flex-basis here resolves from the video's natural size — a portrait
     video then drives the stage taller than the panel and gets cropped.
     Pinning to the viewport gives object-fit:contain a real box to
     letterbox inside (2026-08-05, portrait 4K preview cropped). */
  flex: none;
  height: 52vh;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.broll-trim-video {
  /* Fill the stage but NEVER crop: object-fit keeps the video's own aspect
     ratio and letterboxes the rest, so what's on screen is the whole frame
     (a cropped preview hides exactly the part being trimmed). */
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.broll-trim-scrub {
  flex: none;
}

.broll-trim-track {
  position: relative;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  touch-action: none;
  cursor: pointer;
}

.broll-trim-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  border-top: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  pointer-events: none;
}

.broll-trim-handle {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 14px;
  margin-left: -7px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--primary);
  cursor: ew-resize;
  touch-action: none;
}

/* Hit area, not look: the bar stays 14px wide while the grabbable region
   is 40px, which is what a pointer (and a shaky hand) actually needs. */
.broll-trim-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 40px;
  transform: translateX(-50%);
}

.broll-trim-handle::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 40%;
  width: 2px;
  height: 20%;
  background: var(--bg-elevated);
  border-radius: 1px;
}

.broll-trim-handle:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.broll-trim-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  pointer-events: none;
  transition: left 90ms linear;
}

.broll-trim-readout {
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.broll-trim-scrub-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-top: 8px;
}

.broll-trim-hint,
.broll-trim-minnote {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9em;
}

.broll-trim-minnote {
  margin-top: 6px;
}

/* The two cut modes. Each option is its own block: run together on one
   line they read as a single run-on sentence and the owner cannot see
   where one choice ends and the next begins. */
.broll-trim-modes {
  margin: 0;
  padding: 8px 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.broll-trim-modes-legend {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 0.9em;
}

.broll-trim-mode {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  max-width: 80ch;
  cursor: pointer;
}

.broll-trim-mode-input {
  margin: 2px 0 0;
  flex: none;
}

.broll-trim-namefield {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
}

.broll-trim-namelabel {
  color: var(--text-muted);
  white-space: nowrap;
}

/* The one primary action in the editor; everything else steps back. */
.broll-trim-save {
  font-weight: 600;
}

/* Quieter than "Save clip", but never a bare word: while a trim is running
   this is the ONLY way to stop it (Escape is deliberately ignored then), so
   it has to keep looking like a button. */
.broll-trim-cancel {
  color: var(--text-muted);
}

.broll-trim-cancel:hover {
  color: var(--text);
}

.broll-trim-saverow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.broll-trim-name {
  flex: 1 1 220px;
  min-width: 160px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
}

.broll-trim-dest {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40ch;
}

.broll-trim-errorbox {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.broll-trim-error {
  margin: 0;
  color: var(--coral);
}

.broll-trim-unsupported {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.broll-trim-bar {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  overflow: hidden;
}

.broll-trim-bar-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.broll-trim-bar-label {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .broll-trim-playhead,
  .broll-trim-bar-fill {
    transition: none;
  }
}
