/* Brand templates, per-video options, caption gallery, B-roll (templates.js, captions.js, broll.js).
   Uses the app's tokens only. */

/* ---- Brand templates page section ---- */
.tpl-section { margin-top: 28px; }
.tpl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.tpl-head h3 { margin: 0 0 4px; }
.tpl-head p { margin: 0; max-width: 62ch; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.tpl-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 14px; align-content: start; }
.tpl-card.is-default { border-color: var(--accent-line); }
.tpl-card header { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tpl-logo { width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; font-size: 11px; }
.tpl-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tpl-title { min-width: 0; display: grid; gap: 5px; }
.tpl-title b { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.tpl-facts { margin: 0; display: grid; gap: 8px; font-size: 13px; }
.tpl-facts > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tpl-facts dt { color: var(--muted); }
.tpl-facts dd { margin: 0; display: flex; gap: 6px; align-items: center; text-align: right; }
.tpl-sw { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-3); display: inline-block; }
.tpl-cap { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.tpl-card footer { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-danger-text { color: var(--danger); }
.tpl-empty { padding: 22px; border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--muted); font-size: 13.5px; }
.tpl-modal { align-items: center; }
.tpl-sheet { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 20px; padding: 24px; display: grid; gap: 16px; position: relative; box-shadow: var(--shadow-float); animation: sheet-in .3s var(--ease-out); }
.tpl-sheet h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -.03em; padding-right: 40px; }
.tpl-sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tpl-sheet .row p { margin: 2px 0 0; }
.tpl-actions { display: flex; justify-content: flex-end; gap: 8px; }
.tpl-err { margin: 0; color: var(--danger); font-size: 13px; }
.tpl-house { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
@media (max-width: 640px) {
  .tpl-head { flex-direction: column; }
  .tpl-modal { place-items: end stretch; padding: 0; }
  .tpl-sheet { border-radius: 20px 20px 0 0; max-height: 100dvh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .tpl-actions .btn { flex: 1; }
}

/* ---- Per-video options: Create composer bar and editor popover ---- */
.jo[hidden] { display: none; }
.jo-create { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 10px 2px 0; align-items: flex-end; }
.jo-create .jo-f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.jo-create .select { height: 44px; font-size: 13px; }
.jo-btn { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font-size: 13px; text-align: left; }
.jo-btn:hover { border-color: var(--line-3); }
.jo-btn .jo-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jo-check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.jo-check .hint { font-size: 12px; }
@media (max-width: 640px) { .jo-create .jo-f { max-width: none; flex-basis: 100%; } }

/* ---- Caption look gallery (captions.js) ---- */
.cap-modal { align-items: center; }
.cap-sheet { width: 100%; max-width: 980px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 20px; padding: 24px; display: grid; gap: 14px; position: relative; box-shadow: var(--shadow-float); animation: sheet-in .3s var(--ease-out); }
.cap-sheet h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -.03em; padding-right: 40px; }
.cap-sheet .hint { margin: 0; }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cap-tile { display: grid; gap: 6px; text-align: left; padding: 8px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); align-content: start; cursor: pointer; }
.cap-tile:hover { border-color: var(--line-3); }
.cap-tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cap-tile b { font-size: 13.5px; padding: 0 2px; }
.cap-tile small { font-size: 12px; color: var(--muted); line-height: 1.35; padding: 0 2px 2px; }
.cap-thumb { display: block; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden; background: #111; }
.cap-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cap-mini { width: 22px; height: 40px; border-radius: 4px; object-fit: cover; flex: none; border: 1px solid var(--line-2); margin: 0 2px 0 -4px; }
.cap-btn { height: 44px; }
@media (max-width: 640px) {
  .cap-modal { place-items: end stretch; padding: 0; }
  .cap-sheet { border-radius: 20px 20px 0 0; max-height: 92dvh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .cap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- AI B-roll switch (broll.js) ---- */
.jo-create .jo-broll { max-width: 340px; flex-basis: 280px; }
.jo-broll .jo-check { min-height: 46px; height: auto; align-items: center; gap: 12px; }
.jo-broll .jo-check .hint { line-height: 1.35; }

/* ---- Watch a channel (watch.js) ---- */
.watch-row { align-items: center; gap: 12px; }
.watch-row .grow { display: grid; gap: 2px; min-width: 0; }
.watch-row .grow b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-sub { font-size: 12.5px; color: var(--muted); }
.watch-sub.err { color: var(--warn); }
.watch-note { color: var(--warn); font-size: 13px; margin: 0 0 10px; }
.watch-row { display: flex; min-width: 0; max-width: 100%; }
.watch-row .grow { flex: 1 1 0; min-width: 0; white-space: normal; }
.watch-sub { display: block; white-space: normal; overflow-wrap: anywhere; }
.watch-row .switch, .watch-row .icon-btn { flex: none; }
