/* ============================================================================
   IWC Thumbnails — styles
   Elegant, premium UI for iWorship Centre. Dark by default, light supported.
   All assets are local (fonts under /static/fonts) — works fully offline.
   ========================================================================== */

/* The [hidden] attribute must always win over element display rules
   (e.g. .cutouts{display:grid}, .uploader__busy{display:flex}). */
[hidden] { display: none !important; }

/* ----------------------------- Fonts (local) ----------------------------- */
@font-face {
  font-family: "Playfair Display";
  src: url("/static/fonts/PlayfairDisplay.ttf") format("truetype");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("/static/fonts/PlayfairDisplay-Italic.ttf") format("truetype");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Great Vibes";
  src: url("/static/fonts/GreatVibes-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ----------------------------- Design tokens ----------------------------- */
:root {
  /* Brand */
  --cream:   #EBE1A6;
  --pink:    #F1C9DB;
  --magenta: #D98BD3;
  --gold:    #D4AF6A;
  --gold-deep: #B8873E;
  --hero-gradient: linear-gradient(120deg, #EBE1A6 0%, #F1C9DB 52%, #D98BD3 100%);

  /* Fonts */
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --script: "Great Vibes", cursive;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Radii / motion / shadow */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 22px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 140ms var(--ease);
  --t: 240ms var(--ease);
}

/* Dark theme (default) */
:root,
:root[data-theme="dark"] {
  --bg:        #0A0D1E;
  --bg-2:      #0E1230;
  --surface:   rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-solid: #161A38;
  --border:    rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text:      #ECEAF6;
  --muted:     #9E9DC0;
  --faint:     #6E6E93;
  --accent:    var(--gold);
  --ring:      rgba(217, 139, 211, 0.55);
  --shadow:    0 18px 50px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --input-bg:  rgba(255, 255, 255, 0.05);
  --input-bg-focus: rgba(255, 255, 255, 0.09);
}

/* Light theme */
:root[data-theme="light"] {
  --bg:        #F6F2E9;
  --bg-2:      #FBF8F1;
  --surface:   #FFFFFF;
  --surface-2: #FBF7EF;
  --surface-solid: #FFFFFF;
  --border:    rgba(28, 26, 54, 0.10);
  --border-strong: rgba(28, 26, 54, 0.20);
  --text:      #1B1E38;
  --muted:     #5C5B72;
  --faint:     #8C8AA0;
  --accent:    var(--gold-deep);
  --ring:      rgba(184, 135, 62, 0.45);
  --shadow:    0 18px 44px rgba(50, 40, 70, 0.14);
  --shadow-sm: 0 6px 16px rgba(50, 40, 70, 0.10);
  --input-bg:  #FFFFFF;
  --input-bg-focus: #FFFFFF;
}

/* ----------------------------- Base ----------------------------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 82% -8%, rgba(217, 139, 211, 0.16), transparent 60%),
    radial-gradient(900px 560px at 8% 4%, rgba(235, 225, 166, 0.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ----------------------------- Header ----------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Always dark so the light logo reads well in either theme */
  background: linear-gradient(100deg, #0B0E22 0%, #141033 55%, #241640 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.app-header__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand__logo { height: 38px; width: auto; }
.brand__divider { width: 1px; height: 30px; background: rgba(255, 255, 255, 0.16); }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__title {
  font-family: var(--serif);
  font-size: 1.22rem;
  color: #fff;
  letter-spacing: 0.01em;
}
.brand__sub {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(235, 225, 166, 0.85);
}
.brand__sub em {
  font-family: var(--script);
  font-style: normal;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--pink);
  vertical-align: -2px;
}

.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.15); transform: translateY(-1px); }
.theme-toggle__icon { font-size: 1rem; }

/* ----------------------------- Hero strip ----------------------------- */
.hero-strip { padding: 40px 26px 8px; }
.hero-strip__inner { max-width: 1240px; margin: 0 auto; }
.hero-strip__eyebrow {
  margin: 0 0 10px;
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.hero-strip__title {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.4vw, 2.7rem);
  line-height: 1.08;
  max-width: 20ch;
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-strip__lead {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 56ch;
}

/* ----------------------------- Layout ----------------------------- */
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 26px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 30px;
  align-items: start;
}
.form-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* ----------------------------- Cards ----------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
.card__head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.card__step {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: #1A1330;
  background: var(--hero-gradient);
  box-shadow: 0 4px 14px rgba(217, 139, 211, 0.4);
}
.card__step--muted { background: var(--surface-2); color: var(--muted); box-shadow: none; border: 1px solid var(--border); }
.card__step--done { background: linear-gradient(120deg, #7bd3a0, #34b57f); color: #08351f; box-shadow: 0 4px 14px rgba(52, 181, 127, 0.4); }
.card__title { font-family: var(--serif); font-size: 1.32rem; }
.card__hint { margin: 3px 0 0; color: var(--muted); font-size: 0.9rem; }

/* ----------------------------- Fields ----------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field--small { grid-column: auto; }

.field label,
.picker label,
.toggle-field__label,
.slider-head label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}
.req { color: var(--magenta); font-weight: 700; }

/* Every text-like input shares one look.
   Written as an EXCLUSION list rather than a list of allowed types: naming the types meant that
   adding a field of a NEW type silently fell back to the raw browser control, which is exactly how
   the "Email address" and "Change password" boxes ended up looking unlike their neighbours (they
   became type=email / type=password when logins moved to email addresses, and this list was never
   updated). Excluding the handful of controls that must stay native means tel/search/date and
   anything else added later are styled automatically.

   The exclusions sit inside :where() ON PURPOSE — :where() contributes ZERO specificity, so this
   stays a low-priority default and every intentional override (.field input:invalid.touched,
   .login__card input, .pw-gen input …) still wins, exactly as it did before. A bare :not() chain
   would have raised specificity to 0,0,8,1 and quietly broken those. */
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"])),
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--faint); }

/* Same exclusion list as the base rule above — keep the two in step. */
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"])):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px var(--ring);
}

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute; right: 14px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; }
select option { color: #1B1E38; }

.field__error { margin: 0; color: #ff8fa3; font-size: 0.8rem; }
.field__note { margin: 2px 0 0; color: var(--faint); font-size: 0.78rem; }
.field__note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2); padding: 1px 5px; border-radius: 5px;
}
.field input:invalid.touched { border-color: rgba(255, 143, 163, 0.7); }

/* ----------------------------- Word picker (hero word) ----------------------------- */
.word-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.word-picker:empty { display: none; }
.word-chip {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.word-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.word-chip[aria-pressed="true"] {
  color: #1A1330;
  background: var(--hero-gradient);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(217, 139, 211, 0.35);
}
.word-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ----------------------------- Uploader ----------------------------- */
.uploader {
  margin-top: 20px;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 26px;
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--input-bg);
  cursor: pointer;
  transition: border-color var(--t), background var(--t), transform var(--t-fast);
}
.uploader:hover { border-color: var(--gold); background: var(--input-bg-focus); }
.uploader.is-dragging {
  border-color: var(--magenta);
  background: rgba(217, 139, 211, 0.10);
  transform: scale(1.01);
}
.uploader__icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: #1A1330;
  background: var(--hero-gradient);
  box-shadow: 0 6px 18px rgba(217, 139, 211, 0.4);
}
.uploader__title { margin: 0; font-weight: 600; font-size: 1rem; }
.uploader__sub { margin: 5px 0 0; color: var(--muted); font-size: 0.86rem; }
.uploader__link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.uploader__busy { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.uploader__error { margin: 12px 0 0; color: #ff8fa3; font-size: 0.86rem; }

/* Spinner */
.spinner {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--magenta);
  animation: spin 0.8s linear infinite;
}
.spinner--btn { width: 18px; height: 18px; border-width: 2px; display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Cut-out previews */
.cutouts {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.cutout { margin: 0; text-align: center; }
.cutout__frame {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.05) 75%) 0 0 / 22px 22px,
    linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.05) 75%) 11px 11px / 22px 22px,
    var(--surface-solid);
  min-height: 130px;
  display: grid; place-items: center;
}
.cutout__frame img { width: 100%; height: auto; object-fit: contain; }
.cutout figcaption { margin-top: 9px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.cutout__redo { grid-column: 1 / -1; justify-self: center; }

/* ----------------------------- Saved speakers (face gallery) ----------------------------- */
.speakers { margin-top: 22px; }
.speakers__title {
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px;
}
/* Horizontally-scrollable row of faces */
.speakers__row {
  display: flex; gap: 14px;
  overflow-x: auto; overflow-y: hidden;
  padding: 4px 2px 10px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.speakers__row::-webkit-scrollbar { height: 8px; }
.speakers__row::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.speakers__empty {
  margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.4;
  padding: 6px 2px;
}
/* One face card */
.speaker-card {
  position: relative;
  flex: 0 0 auto; width: 92px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  scroll-snap-align: start;
}
.speaker-card__face {
  width: 76px; height: 76px; padding: 0;
  border-radius: 50%; overflow: hidden; cursor: pointer;
  border: 2px solid var(--border);
  /* Neutral checkerboard so transparent-PNG faces still read */
  background:
    linear-gradient(45deg, rgba(128,128,128,0.16) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.16) 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, rgba(128,128,128,0.16) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.16) 75%) 8px 8px / 16px 16px,
    var(--surface-solid);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.speaker-card__face:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.speaker-card__face:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.speaker-card__face img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.speaker-card.is-selected .speaker-card__face {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), var(--shadow-sm);
}
.speaker-card__name {
  max-width: 92px; text-align: center;
  font-size: 0.78rem; line-height: 1.2; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.speaker-card__actions {
  position: absolute; top: -6px; right: -6px;
  display: flex; gap: 4px;
  opacity: 0; transform: translateY(-2px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.speaker-card:hover .speaker-card__actions,
.speaker-card:focus-within .speaker-card__actions { opacity: 1; transform: none; }
.speaker-card__action {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.speaker-card__action:hover { color: var(--text); border-color: var(--border-strong); transform: scale(1.08); }
.speaker-card__action.js-delete:hover { background: rgba(255, 100, 120, 0.92); color: #fff; border-color: rgba(255, 143, 163, 0.6); }
/* Touch devices can't hover — keep the controls visible */
@media (hover: none) { .speaker-card__actions { opacity: 1; transform: none; } }

/* ----------------------------- Segmented toggle ----------------------------- */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 20px;
}
.segmented__btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.segmented__btn.is-active {
  color: #1A1330;
  background: var(--hero-gradient);
  box-shadow: 0 4px 14px rgba(217, 139, 211, 0.35);
}
/* Compact variant used inline inside a form field (e.g. Title style). */
.segmented--sm { margin-bottom: 6px; margin-top: 2px; }
.segmented--sm .segmented__btn { padding: 7px 16px; font-size: 0.86rem; }

.mode-panel { animation: fade 0.25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Palettes */
.palettes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.palettes__loading { color: var(--muted); grid-column: 1 / -1; margin: 0; }
.palette {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 12px 13px;
  background: var(--surface);
  text-align: left;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}
.palette:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.palette.is-selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold) inset, var(--shadow-sm);
}
.palette__swatches { display: flex; height: 42px; border-radius: 9px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
.palette__swatches span { flex: 1; }
.palette__name { display: block; margin-top: 10px; font-size: 0.86rem; font-weight: 600; }
.palette__hex { display: block; font-size: 0.7rem; color: var(--faint); margin-top: 1px; letter-spacing: 0.03em; }
.palette__check {
  position: absolute; top: 9px; right: 9px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gold); color: #1A1330;
  display: none; place-items: center; font-size: 0.7rem; font-weight: 800;
}
.palette.is-selected .palette__check { display: grid; }

/* "Show more / fewer" toggle beneath the palette grid (reuses .btn--ghost) */
.palettes-toggle { margin-top: 14px; }
.palettes-toggle__chevron { transition: transform var(--t-fast); }
.palettes-toggle[aria-expanded="true"] .palettes-toggle__chevron { transform: rotate(180deg); }

/* Manual pickers */
.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker__row { display: flex; align-items: center; gap: 10px; }
.picker__swatch {
  width: 42px; height: 42px; flex: none;
  border-radius: 11px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.picker input[type="color"] {
  width: 46px; height: 42px; padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px; background: none; cursor: pointer;
}
.picker input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.picker input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
.picker__hex {
  flex: 1;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
}

/* ----------------------------- Formats ----------------------------- */
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.format {
  display: flex; align-items: center; gap: 13px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.format:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.format input { position: absolute; opacity: 0; width: 0; height: 0; }
.format__box {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.format__box::after {
  content: "";
  width: 11px; height: 6px;
  border-left: 2.5px solid #1A1330;
  border-bottom: 2.5px solid #1A1330;
  transform: rotate(-45deg) scale(0);
  transition: transform var(--t-fast);
  margin-top: -2px;
}
.format input:checked + .format__box { background: var(--hero-gradient); border-color: transparent; }
.format input:checked + .format__box::after { transform: rotate(-45deg) scale(1); }
.format input:focus-visible + .format__box { box-shadow: 0 0 0 3px var(--ring); }
.format input:checked ~ .format__text .format__name { color: var(--text); }
.format__text { display: flex; flex-direction: column; line-height: 1.25; }
.format__name { font-weight: 600; font-size: 0.94rem; }
.format__meta { font-size: 0.76rem; color: var(--faint); letter-spacing: 0.02em; }

/* ----------------------------- Advanced ----------------------------- */
.card--advanced { padding: 0; }
.advanced { }
.advanced__summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
}
.advanced__summary::-webkit-details-marker { display: none; }
.advanced__summary .card__title { font-size: 1.2rem; }
.advanced__summary > div { flex: 1; }
.advanced__chevron { color: var(--muted); transition: transform var(--t); }
.advanced[open] .advanced__chevron { transform: rotate(180deg); }
.advanced__body { padding: 4px 28px 28px; display: flex; flex-direction: column; gap: 20px; }

.slider-head { display: flex; align-items: center; justify-content: space-between; }
.slider-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem; color: var(--accent); font-weight: 700;
  background: var(--surface-2); padding: 2px 9px; border-radius: 7px;
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; margin-top: 4px;
  background: var(--surface-2);
  border-radius: 999px; outline-offset: 6px; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--hero-gradient);
  border: 2px solid var(--bg-2);
  box-shadow: 0 3px 10px rgba(217, 139, 211, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bg-2);
  background: var(--magenta); box-shadow: 0 3px 10px rgba(217, 139, 211, 0.5);
}

.toggle-field { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.switch {
  flex: none;
  border: 0; background: none; padding: 0; cursor: pointer;
}
.switch__track {
  display: block;
  width: 50px; height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--t-fast);
}
.switch__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform var(--t) ;
}
.switch[aria-checked="true"] .switch__track { background: var(--hero-gradient); border-color: transparent; }
.switch[aria-checked="true"] .switch__thumb { transform: translateX(22px); }
.switch:focus-visible .switch__track { box-shadow: 0 0 0 3px var(--ring); }

/* ----------------------------- Sidebar / summary ----------------------------- */
.side-col { position: sticky; top: 88px; }
.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 24px 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.summary__title { font-family: var(--serif); font-size: 1.25rem; margin-bottom: 16px; }
.summary__list { margin: 0 0 18px; display: flex; flex-direction: column; gap: 0; }
.summary__row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.summary__row:last-child { border-bottom: 0; }
.summary__row dt { color: var(--muted); font-size: 0.84rem; }
.summary__row dd {
  margin: 0; font-weight: 600; font-size: 0.9rem; text-align: right;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary__row dd.is-empty { color: var(--faint); font-weight: 400; }
.summary__colors { display: inline-flex; gap: 6px; }
.summary__dot {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1px solid var(--border-strong);
  display: inline-block;
  background: var(--faint);
}
.summary__validation {
  margin: 0 0 14px; padding: 10px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 143, 163, 0.12);
  border: 1px solid rgba(255, 143, 163, 0.3);
  color: #ffabb9; font-size: 0.82rem;
}
.summary__foot { margin: 14px 0 0; text-align: center; color: var(--faint); font-size: 0.76rem; }

/* ----------------------------- Buttons ----------------------------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 12px 20px;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), opacity var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
}
.btn--sm { padding: 8px 15px; font-size: 0.85rem; }
.btn--ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.btn--primary {
  color: #1A1330;
  background: var(--hero-gradient);
  background-size: 160% 160%;
  box-shadow: 0 10px 26px rgba(217, 139, 211, 0.42);
}
.btn--primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(217, 139, 211, 0.55); background-position: 100% 50%; }
.btn--primary:active:not(:disabled) { transform: translateY(0); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn--generate { width: 100%; font-size: 1.02rem; padding: 15px 20px; letter-spacing: 0.01em; }
.btn.is-busy .btn__label { opacity: 0.75; }
.btn.is-busy .spinner--btn { display: inline-block; border-top-color: #1A1330; border-color: rgba(26, 19, 48, 0.3); border-top-color: #1A1330; }

/* Progress */
.progress { margin-top: 14px; }
.progress__bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress__fill {
  display: block; height: 100%; width: 40%;
  border-radius: 999px;
  background: var(--hero-gradient);
  animation: indeterminate 1.3s var(--ease) infinite;
}
@keyframes indeterminate {
  0% { margin-left: -42%; width: 42%; }
  50% { width: 62%; }
  100% { margin-left: 100%; width: 42%; }
}
.progress__text { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 0.82rem; }

.generate-error {
  margin: 14px 0 0; padding: 12px 14px;
  border-radius: var(--r-sm);
  background: rgba(255, 100, 120, 0.12);
  border: 1px solid rgba(255, 100, 120, 0.35);
  color: #ff9fae; font-size: 0.85rem;
}

/* ----------------------------- Results gallery ----------------------------- */
.results { animation: fade 0.35s var(--ease); }
.results__folder-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
}
/* Push the results-panel "Download all" to the far right of the card header. */
.results__downloadAll { margin-left: auto; align-self: center; flex: none; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.result-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.result-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.result-card__preview {
  background:
    linear-gradient(45deg, rgba(128,128,128,0.16) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.16) 75%) 0 0 / 20px 20px,
    linear-gradient(45deg, rgba(128,128,128,0.16) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.16) 75%) 10px 10px / 20px 20px,
    #20233f;
  display: grid; place-items: center; padding: 10px;
  min-height: 150px;
}
.result-card__preview img { width: 100%; height: auto; border-radius: 6px; }
/* name/meta on top, an actions row (Edit + Download) beneath — so both buttons always fit
   the (narrow, 3-up) cards instead of the Download button being pushed off the edge. */
.result-card__body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 12px; }
.result-card__name { font-weight: 600; font-size: 0.9rem; }
.result-card__meta { font-size: 0.74rem; color: var(--faint); margin-top: 1px; word-break: break-word; }
/* Up to three buttons (Edit · Video · Download) — WRAP instead of pushing Download
   off the edge on the narrow 3-up cards. Each keeps a sensible min width and grows to fill. */
.result-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.result-card__actions > * { flex: 1 1 auto; min-width: 84px; justify-content: center; }
.result-card__dl {
  text-decoration: none;
  font-size: 0.82rem; font-weight: 600;
  color: var(--accent);
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.result-card__dl:hover { background: var(--surface-2); border-color: var(--border-strong); }
.result-card__edit {
  cursor: pointer;
  font: inherit; font-size: 0.82rem; font-weight: 600;
  color: var(--text);
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.result-card__edit:hover { background: var(--surface); border-color: var(--accent); }
/* "Make video" + "vMix/OBS" card buttons (same shape as Edit) */
.result-card__video,
.result-card__obs {
  cursor: pointer;
  font: inherit; font-size: 0.82rem; font-weight: 600;
  color: var(--text);
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.result-card__video:hover,
.result-card__obs:hover { background: var(--surface); border-color: var(--accent); }
/* A video result card: poster with a play badge overlaid */
.result-card__preview--video { position: relative; cursor: pointer; }
.result-card__play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; pointer-events: none;
}
.result-card__play svg {
  width: 54px; height: 54px;
  background: rgba(20, 20, 34, 0.55); border-radius: 999px; padding: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35); backdrop-filter: blur(2px);
}
.result-card__preview--video .result-card__ph {
  color: var(--faint); font-size: 0.8rem; text-align: center; padding: 30px 10px;
}

/* ----------------------------- Recent graphics ----------------------------- */
.recent-section {
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 40%);
}
.recent-section__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 26px 20px;
}
.recent-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 22px;
}
.recent-head__title { font-family: var(--serif); font-size: 1.5rem; }
.recent-head__hint { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.recent-state {
  grid-column: 1 / -1;
  margin: 0; padding: 30px 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}
.recent-state--error { color: #ff9fae; }

/* A single past set (card + overlaid quick-delete, wrapped for positioning) */
.set-card-wrap { position: relative; display: flex; }
.set-card {
  flex: 1 1 auto;
  min-width: 0;
  display: flex; flex-direction: column;
  text-align: left;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit; color: inherit;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.set-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.set-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.set-card__cover {
  position: relative;
  aspect-ratio: 16 / 9;
  /* Neutral checkerboard so transparent-PNG covers still read */
  background:
    linear-gradient(45deg, rgba(128,128,128,0.16) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.16) 75%) 0 0 / 20px 20px,
    linear-gradient(45deg, rgba(128,128,128,0.16) 25%, transparent 25%, transparent 75%, rgba(128,128,128,0.16) 75%) 10px 10px / 20px 20px,
    #20233f;
  display: grid; place-items: center;
  overflow: hidden;
}
.set-card__cover img { width: 100%; height: 100%; object-fit: cover; }
.set-card__cover.is-transparent img { object-fit: contain; padding: 8px; }
.set-card__badge {
  position: absolute; top: 10px; right: 10px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  color: #1A1330;
  background: var(--hero-gradient);
  box-shadow: 0 4px 12px rgba(217, 139, 211, 0.35);
}
.set-card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 5px; }
.set-card__title {
  font-family: var(--serif); font-size: 1.02rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.set-card__date { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.02em; }

/* Quick-delete affordance, revealed on hover/focus (top-left, clear of the badge) */
.set-card__delete {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 13, 30, 0.62);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  backdrop-filter: blur(3px);
  transition: opacity var(--t-fast), background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.set-card-wrap:hover .set-card__delete,
.set-card__delete:focus-visible { opacity: 1; }
.set-card__delete:hover {
  background: rgba(255, 100, 120, 0.92);
  border-color: rgba(255, 143, 163, 0.6);
  transform: scale(1.06);
}
/* Touch devices can't hover — keep it visible there */
@media (hover: none) { .set-card__delete { opacity: 1; } }
/* View-only users never see the destructive control */
body.is-viewer .set-card__delete { display: none; }

/* Quick-edit affordance, sits just right of the delete button (same reveal-on-hover) */
.set-card__edit {
  position: absolute; top: 10px; left: 50px; z-index: 2;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 13, 30, 0.62);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  backdrop-filter: blur(3px);
  transition: opacity var(--t-fast), background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.set-card-wrap:hover .set-card__edit,
.set-card__edit:focus-visible { opacity: 1; }
.set-card__edit:hover {
  background: var(--accent, #6C32DC);
  border-color: color-mix(in srgb, var(--accent, #6C32DC) 70%, #fff);
  transform: scale(1.06);
}
@media (hover: none) { .set-card__edit { opacity: 1; } }
body.is-viewer .set-card__edit { display: none; }

/* Add-a-part affordance, sits right of the edit button (same reveal-on-hover). Makes a
   NEW part (a new "… Part N" set) from this one — a green hover to read as "create". */
.set-card__add {
  position: absolute; top: 10px; left: 90px; z-index: 2;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 13, 30, 0.62);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  backdrop-filter: blur(3px);
  transition: opacity var(--t-fast), background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.set-card-wrap:hover .set-card__add,
.set-card__add:focus-visible { opacity: 1; }
.set-card__add:hover {
  background: #1F9D74;
  border-color: color-mix(in srgb, #1F9D74 70%, #fff);
  transform: scale(1.06);
}
@media (hover: none) { .set-card__add { opacity: 1; } }
body.is-viewer .set-card__add { display: none; }

/* SERIES card: a tab strip (one per part) above the cover; the cover is its own button.
   The quick-actions drop onto the cover (below the tab strip) so they never cover the tabs. */
.set-card-wrap--series .set-card__delete,
.set-card-wrap--series .set-card__edit,
.set-card-wrap--series .set-card__add { top: 56px; }
.set-card--series { cursor: default; }
.set-card__coverbtn {
  display: block; width: 100%; padding: 0;
  border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit;
}
.set-card__coverbtn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.set-card__tabs {
  display: flex; gap: 6px;
  padding: 10px 12px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.set-card__tabs::-webkit-scrollbar { display: none; }
.set-card__tab {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.02em;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.set-card__tab:hover { color: inherit; border-color: var(--border-strong); }
.set-card__tab.is-active {
  background: var(--hero-gradient);
  color: #1A1330;
  border-color: transparent;
}
.set-card__tab:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ----------------------------- Modal / lightbox ----------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }

/* ---- Big full-screen image viewer (above everything) ------------------- */
.viewer {
  position: fixed; inset: 0; z-index: 300;
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: 1fr auto;
  align-items: center; gap: 4px; padding: 12px;
  animation: fade 0.18s var(--ease);
}
.viewer[hidden] { display: none; }
.viewer__backdrop { position: absolute; inset: 0; background: rgba(4, 6, 16, 0.92); }
.viewer__stage {
  grid-column: 2; grid-row: 1; position: relative; z-index: 1;
  min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center;
}
.viewer__img {
  max-width: 100%; max-height: 82vh; width: auto; height: auto;
  object-fit: contain; border-radius: 8px; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  touch-action: pan-y;
}
.viewer__nav {
  grid-row: 1; position: relative; z-index: 2;
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(20, 24, 40, 0.6); color: #fff; cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.viewer__nav:hover { background: rgba(40, 46, 72, 0.85); }
.viewer__nav:active { transform: scale(0.94); }
.viewer__nav--prev { grid-column: 1; }
.viewer__nav--next { grid-column: 3; }
.viewer__bar {
  grid-column: 1 / -1; grid-row: 2; position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 6px 2px; color: rgba(255, 255, 255, 0.86); flex-wrap: wrap;
}
.viewer__count { font-size: 0.85rem; letter-spacing: 0.02em; }
.viewer__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.viewer__actions .btn { text-decoration: none; }
@media (max-width: 560px) {
  .viewer { padding: 6px; gap: 2px; }
  .viewer__nav { width: 42px; height: 42px; }
  .viewer__img { max-height: 74vh; }
}

/* zoom affordance on gallery previews */
.result-card__preview { position: relative; cursor: zoom-in; }
.result-card__zoom {
  position: absolute; top: 8px; right: 8px;
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 8px; background: rgba(10, 12, 24, 0.55); color: #fff;
  opacity: 0; transition: opacity var(--t-fast);
  pointer-events: none;
}
.result-card__preview:hover .result-card__zoom,
.result-card__preview:focus-visible .result-card__zoom { opacity: 1; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 8, 20, 0.66);
  backdrop-filter: blur(4px);
  animation: fade 0.2s var(--ease);
}
.modal__panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(86vh, 900px);
  display: flex; flex-direction: column;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  animation: modalIn 0.24s var(--ease);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-family: var(--serif); font-size: 1.3rem; line-height: 1.2; }
.modal__sub { margin: 4px 0 0; color: var(--muted); font-size: 0.86rem; }
.modal__close {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.modal__close:hover { background: var(--surface); border-color: var(--border-strong); transform: rotate(90deg); }
.modal__body {
  padding: 22px 24px 26px;
  overflow-y: auto;
}
/* Set-lightbox action bar (Regenerate / Delete). Sits below the scrolling body. */
.modal__foot {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
/* View-only users can still Download all — the destructive Delete, the
   story-editing "Video QR + points" and the full-edit "Edit" buttons are hidden. */
body.is-viewer #modalDelete,
body.is-viewer #modalEdit,
body.is-viewer #modalVideoExtras { display: none; }
/* Four items in the action bar can crowd narrow screens — allow a wrap. */
.modal__foot { flex-wrap: wrap; }

/* ----------------------------- Edit-a-set banner ----------------------------- */
/* Shown at the top of the form while a past set is loaded for a full edit. */
.edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius, 12px);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text, inherit);
  font-size: 14px;
}
.edit-banner__icon { flex: 0 0 auto; color: var(--accent); }
.edit-banner__text { flex: 1 1 auto; line-height: 1.4; }
.edit-banner__text strong { font-weight: 700; }
.edit-banner__cancel {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: inherit;
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.edit-banner__cancel:hover { background: var(--surface); border-color: var(--accent); }
/* "Add a part" variant: a green tint so it reads as CREATE (new set), not edit (replace). */
.edit-banner--series {
  border-color: color-mix(in srgb, #1F9D74 55%, var(--border));
  background: color-mix(in srgb, #1F9D74 12%, var(--surface));
}
.edit-banner--series .edit-banner__icon { color: #1F9D74; }

/* ----------------------------- Story extras editor (video QR + points) ----------------------------- */
/* Lives inside the set lightbox; when open it fills the space beneath the
   header (the gallery + action bar are hidden) and scrolls internally. */
.ve-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fade 0.2s var(--ease);
}
.ve-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.ve-panel__intro { }
.ve-panel__title { font-family: var(--serif); font-size: 1.1rem; }
.ve-panel__hint { margin: 5px 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.ve-panel__hint strong { color: var(--text); }

/* The two views of the Stories manager each fill the panel (scrolling body + sticky foot). */
#storyListView, #storyFormView {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
#storyListView[hidden], #storyFormView[hidden] { display: none; }

/* List of the stories in a set. */
.story-list { display: flex; flex-direction: column; gap: 10px; }
.story-list__empty { color: var(--muted); font-size: 0.9rem; margin: 4px 0; }
.story-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.story-row__thumb {
  flex: none; width: 46px; aspect-ratio: 9 / 16; object-fit: cover;
  border-radius: 6px; background: var(--surface-3, rgba(0,0,0,.15));
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.story-row__meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.story-row__title {
  font-weight: 600; font-size: 0.92rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.story-row__sub { font-size: 0.78rem; color: var(--muted); }
.story-row__actions { flex: none; display: flex; align-items: center; gap: 6px; }
.story-row__btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer;
  text-decoration: none;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.story-row__btn:hover { color: var(--text); border-color: var(--accent, #7c8cff); }
.story-row__btn--danger:hover {
  color: #fff; background: rgba(255, 100, 120, 0.92); border-color: rgba(255, 143, 163, 0.6);
}

.ve-bullets-group { display: flex; flex-direction: column; gap: 10px; }
.ve-bullets__label {
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em; color: var(--text);
}
.ve-bullets { display: flex; flex-direction: column; gap: 10px; }
.ve-bullets:empty { display: none; }
.ve-bullet { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ve-bullet__input { flex: 1 1 auto; min-width: 0; }
/* each talking point's word-picker sits on its own line under that row's input */
.ve-bullet__words { flex: 0 0 100%; margin: 2px 0 0; }
/* talking-points style switch + mapping connector picker */
.ve-points-style { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.ve-map-opts { display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: rgba(255,255,255,.02); }
.ve-map-opts__label { color: var(--muted); font-size: 0.84rem; }
.ve-marks { display: flex; flex-wrap: wrap; gap: 6px; }
.ve-mark {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 36px; padding: 0 8px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; font-size: 0.8rem;
}
.ve-mark:hover { border-color: var(--border-strong); }
.ve-mark.is-active { border-color: var(--ring); box-shadow: 0 0 0 2px rgba(255,255,255,.06) inset; }
.ve-mark__text { max-width: 120px; }
.ve-bullet__remove {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.ve-bullet__remove:hover {
  color: #fff;
  background: rgba(255, 100, 120, 0.92);
  border-color: rgba(255, 143, 163, 0.6);
  transform: scale(1.05);
}
.ve-add-bullet { align-self: flex-start; }

/* ----------------------------- Header account menu ----------------------------- */
.header-actions { display: flex; align-items: center; gap: 12px; }

.account { position: relative; }
.account[hidden] { display: none; }
.account__trigger {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #fff; font: inherit; cursor: pointer;
  transition: background var(--t-fast);
}
.account__trigger:hover { background: rgba(255, 255, 255, 0.15); }
.account__avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.9rem; color: #1A1330;
  background: var(--hero-gradient);
}
.account__meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1; }
.account__name { font-size: 0.85rem; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__role {
  padding: 1px 7px; border-radius: 999px;
  font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
  background: rgba(255, 255, 255, 0.16); color: #fff;
}
.account__role--admin  { background: rgba(212, 175, 106, 0.92); color: #2a1c00; }
.account__role--member { background: rgba(120, 180, 255, 0.28); color: #d6ecff; }
.account__role--viewer { background: rgba(200, 160, 230, 0.28); color: #ecdcff; }
.account__chevron { color: rgba(255, 255, 255, 0.65); flex: none; }

.account__menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 216px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 6px; z-index: 60;
  animation: fade 0.15s var(--ease);
}
.account__menu[hidden] { display: none; }
.account__item {
  display: block; width: 100%;
  padding: 10px 12px; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 0.9rem; text-align: left;
  border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--t-fast);
  text-decoration: none;                 /* so an <a> menu item matches the buttons */
}
.account__item:hover { background: var(--surface-2); }
.account__item--danger { color: #ff8fa3; }
.account__item[hidden] { display: none; }
.account__sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ----------------------------- View-only banner ----------------------------- */
.viewer-banner { display: none; border-bottom: 1px solid var(--border); }
body.is-viewer .viewer-banner { display: block; }
body.is-viewer .hero-strip,
body.is-viewer .layout { display: none; }
.viewer-banner__inner {
  max-width: 1240px; margin: 0 auto; padding: 24px 26px;
  display: flex; align-items: center; gap: 14px;
}
.viewer-banner__inner p { margin: 0; color: var(--text); font-size: 1rem; }
.viewer-banner__icon {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  color: #1A1330; background: var(--hero-gradient);
  box-shadow: 0 6px 16px rgba(217, 139, 211, 0.35);
}

/* ----------------------------- Modal size variants + in-modal forms ----------------------------- */
.modal__panel--sm { width: min(460px, 100%); }
.modal__panel--lg { width: min(760px, 100%); }

.stack-form { display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-actions--start { justify-content: flex-start; }

.form-msg { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); font-size: 0.85rem; line-height: 1.4; }
.form-msg[hidden] { display: none; }
.form-msg.is-error   { background: rgba(255, 100, 120, 0.12); border: 1px solid rgba(255, 100, 120, 0.35); color: #ff9fae; }
.form-msg.is-success { background: rgba(52, 181, 127, 0.14); border: 1px solid rgba(52, 181, 127, 0.4); color: #7bd3a0; }

.subhead { margin: 0 0 12px; font-family: var(--serif); font-size: 1.08rem; }

/* Add-member form */
.add-user__grid { display: grid; grid-template-columns: 1fr 160px; gap: 14px; }
.add-user__pw { grid-column: 1 / -1; }
.pw-gen { display: flex; gap: 8px; }
.pw-gen input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; }
.pw-gen .btn { flex: none; white-space: nowrap; }

.callout {
  margin-top: 14px; padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(235, 225, 166, 0.12);
  border: 1px solid rgba(212, 175, 106, 0.4);
  font-size: 0.9rem; line-height: 1.55; color: var(--text);
}
.callout[hidden] { display: none; }
.temp-pass {
  display: inline-block; margin: 0 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700; letter-spacing: 0.04em;
  background: var(--surface-2); padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--border); user-select: all;
}

.users-divider { height: 1px; background: var(--border); margin: 24px 0; }

/* Member rows */
.users-list { display: flex; flex-direction: column; gap: 10px; }
.user-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
}
.user-row__main { min-width: 0; }
.user-row__name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-row__sub { font-size: 0.78rem; color: var(--faint); margin-top: 3px; }
.user-row__controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-role { padding-top: 8px; padding-bottom: 8px; font-size: 0.85rem; min-width: 118px; }
.user-reset-form {
  grid-column: 1 / -1; padding-top: 12px; margin-top: 2px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.user-reset-form[hidden] { display: none; }
.user-row__msg { grid-column: 1 / -1; margin-top: 2px; }

.chip {
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.chip--you  { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip--warn { background: rgba(212, 175, 106, 0.18); color: var(--accent); border: 1px solid rgba(212, 175, 106, 0.4); }

.btn--danger { color: #ff8fa3; }
.btn--danger:hover { border-color: rgba(255, 143, 163, 0.5); background: rgba(255, 100, 120, 0.10); }

/* ----------------------------- Toasts ----------------------------- */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 18px; border-radius: 999px;
  background: var(--surface-solid); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 0.88rem; font-weight: 500; max-width: 90vw; text-align: center;
  opacity: 0; transform: translateY(10px);
  transition: opacity var(--t), transform var(--t);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--error { border-color: rgba(255, 100, 120, 0.4); color: #ff9fae; }

/* ----------------------------- Footer ----------------------------- */
.app-footer {
  text-align: center;
  color: var(--faint);
  font-size: 0.8rem;
  padding: 26px;
  border-top: 1px solid var(--border);
}

/* ----------------------------- Responsive ----------------------------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { position: static; order: 2; }
  .form-col { order: 1; }
}
@media (max-width: 620px) {
  .app-header__inner, .hero-strip, .layout, .recent-section__inner { padding-left: 18px; padding-right: 18px; }
  .card { padding: 22px 18px; }
  .grid, .formats, .pickers, .cutouts { grid-template-columns: 1fr; }
  .recent-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .field--small { grid-column: 1 / -1; }
  .theme-toggle__label { display: none; }
  .brand__divider { display: none; }
  .modal { padding: 0; }
  .modal__panel { max-height: 100vh; height: 100%; width: 100%; border-radius: 0; border: 0; }
  .modal__panel--sm, .modal__panel--lg { width: 100%; }
  .add-user__grid { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr; }
  .user-row__controls { justify-content: flex-start; }
  .viewer-banner__inner { padding-left: 18px; padding-right: 18px; }
  .account__name { max-width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ============================ CANVA-STYLE EDITOR ============================ */
.editor {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  background: #0b0e1a;
  color: #eef;
}
.editor__bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 8px 12px;
  background: #141a30;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.editor__name { font-weight: 700; font-size: 14px; margin-right: 4px; }
.ed-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: rgba(255,255,255,.14); }
.ed-spacer { flex: 1 1 auto; }
.ed-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: #eef; cursor: pointer;
  border-radius: 8px; padding: 7px 12px;
  font: inherit; font-size: 13px; line-height: 1;
  transition: background .12s, border-color .12s, opacity .12s;
}
.ed-btn:hover { background: rgba(255,255,255,.13); }
.ed-btn:disabled { opacity: .4; cursor: default; }
.ed-btn.ed-icon { padding: 7px 10px; min-width: 34px; justify-content: center; font-size: 15px; }
.ed-btn.ed-primary { background: var(--accent, #6C32DC); border-color: transparent; font-weight: 600; }
.ed-btn.ed-primary:hover { filter: brightness(1.08); }
.ed-btn.ed-danger:hover { background: rgba(255,90,110,.85); border-color: rgba(255,120,140,.6); }
.ed-btn.is-active { background: var(--accent, #6C32DC); border-color: transparent; }
.ed-obj-tools, .ed-text-tools { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ed-field {
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  color: #eef; border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px;
}
.ed-size { width: 88px; }
.ed-color { width: 34px; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid rgba(255,255,255,.16); background: transparent; cursor: pointer; }

.editor__stage {
  flex: 1 1 auto; position: relative; overflow: hidden;
  display: grid; place-items: center;
  background:
    linear-gradient(45deg, #1a2036 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(-45deg, #1a2036 25%, transparent 25%) -10px 0/20px 20px,
    #10152a;
}
.editor__canvaswrap { position: relative; transform-origin: 0 0; box-shadow: 0 12px 48px rgba(0,0,0,.5); }
#edFrame { display: block; border: 0; background: #fff; }
.editor__overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
/* selection outline + handles (screen-space; positioned by JS) */
.ed-select { position: absolute; border: 1.5px solid var(--accent, #6C32DC); box-shadow: 0 0 0 1px rgba(255,255,255,.6); pointer-events: none; }
.ed-handle {
  position: absolute; width: 14px; height: 14px;
  transform: translate(-50%, -50%);   /* JS adds a counter-scale so handles stay constant size */
  background: #fff; border: 1.5px solid var(--accent, #6C32DC); border-radius: 50%;
  pointer-events: auto; touch-action: none; z-index: 6;
}
.ed-handle.ed-rot { background: var(--accent, #6C32DC); }
.ed-handle[data-h="nw"], .ed-handle[data-h="se"] { cursor: nwse-resize; }
.ed-handle[data-h="ne"], .ed-handle[data-h="sw"] { cursor: nesw-resize; }
.ed-handle[data-h="n"], .ed-handle[data-h="s"] { cursor: ns-resize; }
.ed-handle[data-h="e"], .ed-handle[data-h="w"] { cursor: ew-resize; }
.ed-handle.ed-rot { cursor: grab; }
.editor__busy {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(10,13,30,.9); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px; padding: 8px 16px; font-size: 13px; z-index: 10;
}
.editor__hint { margin: 0; padding: 7px 12px; font-size: 12px; color: #9aa3c0; background: #141a30; border-top: 1px solid rgba(255,255,255,.08); text-align: center; }

/* Viewers never get the editor / make-video entry buttons. */
body.is-viewer .result-card__edit,
body.is-viewer .result-card__video,
body.is-viewer .result-card__obs,
body.is-viewer #viewerMakeVideo,
body.is-viewer #viewerObsFile,
body.is-viewer #modalCanvaEdit { display: none; }

/* ---- Editor: floating contextual toolbar + colour popover ---- */
.ed-field.ed-font { width: 132px; }
.ed-field.ed-size { width: 88px; }
.ed-float {
  position: absolute; z-index: 30;
  display: flex; align-items: center; gap: 5px; flex-wrap: nowrap;
  padding: 6px 8px;
  background: #1b2238; border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.ed-float .ed-text-tools { display: inline-flex; align-items: center; gap: 5px; }
.ed-float-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: rgba(255,255,255,.16); }
/* colour trigger: a rounded swatch showing the current fill */
.ed-swatch {
  width: 34px; height: 34px; border-radius: 8px; padding: 3px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06);
}
.ed-swatch > span { display: block; width: 100%; height: 100%; border-radius: 5px; background: #fff; }
.ed-colorpop {
  position: absolute; z-index: 40; width: 244px;
  padding: 10px; background: #1b2238; border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.5);
}
.ed-cp-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.ed-cp-tabs button {
  flex: 1; padding: 6px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); color: #eef;
}
.ed-cp-tabs button.is-active { background: var(--accent, #6C32DC); border-color: transparent; }
.ed-cp-pane { display: flex; flex-direction: column; gap: 10px; }
.ed-cp-pane > input[type=color] { width: 100%; height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; background: transparent; cursor: pointer; padding: 2px; }
.ed-cp-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.ed-cp-swatches button { height: 26px; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); cursor: pointer; padding: 0; }
.ed-cp-custom { display: flex; align-items: center; gap: 6px; }
.ed-cp-custom input[type=color] { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; background: transparent; cursor: pointer; padding: 2px; }
.ed-cp-label { font-size: 12px; color: #9aa3c0; }
.ed-cp-apply { margin-left: auto; padding: 6px 12px; }

/* Editor colour popover: "Default" gradient swatch + brand-default marker */
.ed-cp-default { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ed-cp-defsw { flex: 1; height: 30px; border-radius: 7px; border: 1px solid rgba(255,255,255,.24); cursor: pointer; padding: 0; }
.ed-cp-deflabel { font-size: 12px; font-weight: 600; color: #cdd3ea; }
.ed-cp-swatches button.is-brand-default { outline: 2px solid var(--accent, #6C32DC); outline-offset: 1px; }

/* Editor: outline box around each selected title word (multi-select) */
.ed-wordbox {
  position: absolute;
  border: 2px solid var(--accent, #6C32DC);
  background: color-mix(in srgb, var(--accent, #6C32DC) 20%, transparent);
  border-radius: 3px;
  pointer-events: none;
  z-index: 5;
}

.field__opt { font-weight: 400; font-size: 0.82em; color: var(--faint); }

/* ----------------------------- Make Video dialog --------------------------- */
/* Segmented control (choose one of a small set) */
.seg { display: inline-flex; gap: 6px; flex-wrap: nowrap; }
.seg--wrap { flex-wrap: wrap; }
.seg__btn {
  font: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.seg__btn:hover { border-color: var(--border-strong); }
.seg__btn.is-on {
  color: #1A1330; background: var(--hero-gradient); background-size: 160% 160%;
  border-color: transparent;
}
:root[data-theme="light"] .seg__btn.is-on { color: #1A1330; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }
#videoWait, #videoRepeats {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px;
}

/* Video in the big viewer */
.viewer__video { max-width: 100%; max-height: 100%; border-radius: 6px; background: #000; }
#videoDialog .modal__panel { max-width: 460px; }

/* ---- Floating video-generation progress (top-right, above every modal/viewer) ---- */
.vidprog {
  position: fixed; top: 14px; right: 14px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  width: 320px; max-width: calc(100vw - 28px);
  pointer-events: none;                       /* only the cards catch clicks */
}
.vidprog__card {
  pointer-events: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.40);
  padding: 12px 14px;
  animation: vidprogIn 0.22s ease;
}
@keyframes vidprogIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.vidprog__top { display: flex; align-items: center; gap: 8px; }
.vidprog__icon { flex: none; width: 16px; height: 16px; display: grid; place-items: center; }
.vidprog__spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: vidprogSpin 0.8s linear infinite;
}
@keyframes vidprogSpin { to { transform: rotate(360deg); } }
.vidprog__title { font-weight: 600; font-size: 0.86rem; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vidprog__close {
  flex: none; cursor: pointer; background: none; border: none; color: var(--muted);
  font-size: 1.15rem; line-height: 1; padding: 0 4px; border-radius: 6px;
}
.vidprog__close:hover { color: var(--text); background: var(--surface-2); }
.vidprog__stage { font-size: 0.78rem; color: var(--muted); margin: 9px 0 6px; }
.vidprog__bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.vidprog__fill { display: block; height: 100%; width: 0%; border-radius: 999px; background: var(--hero-gradient); transition: width 0.4s ease; }
.vidprog__meta { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--faint); margin-top: 5px; font-variant-numeric: tabular-nums; }
.vidprog__actions { display: flex; gap: 8px; margin-top: 11px; }
.vidprog__actions > * { flex: 1 1 0; justify-content: center; text-decoration: none; }
.vidprog__card.is-done .vidprog__bar,
.vidprog__card.is-done .vidprog__meta,
.vidprog__card.is-error .vidprog__bar,
.vidprog__card.is-error .vidprog__meta { display: none; }
.vidprog__card.is-error .vidprog__stage { color: #ff8fa3; }

/* ---- Speaker titles: multi-select checkboxes + ordered chips (combinable, e.g. "REV DR") ---- */
.hon-checks { display: flex; flex-wrap: wrap; gap: 7px 16px; margin: 2px 0 10px; }
.hon-check { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--text); cursor: pointer; }
.hon-check input { width: 15px; height: 15px; accent-color: var(--gold); cursor: pointer; }
.honorifics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.honorifics:empty { display: none; }
.hon-chip { display: inline-flex; align-items: center; gap: 1px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 6px; }
.hon-label { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.03em; padding: 0 4px; }
.hon-move, .hon-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 0.8rem; line-height: 1; padding: 3px 4px; border-radius: 6px; }
.hon-move:disabled { opacity: 0.3; cursor: default; }
.hon-move:hover:not(:disabled), .hon-x:hover { color: var(--text); background: var(--surface); }
.hon-x:hover { color: #ff8fa3; }

/* ----------------------------- DOMINION event mode ----------------------------- */
.mode-bar { max-width: 1240px; margin: 0 auto -6px; padding: 16px 24px 0; }
.mode-switch { display: inline-flex; }
/* Toggle the two isolated forms + the sermon summary by the page mode. */
#dominionForm { display: none; }
body[data-mode="dominion"] #dominionForm { display: flex; }
body[data-mode="dominion"] #thumbForm,
body[data-mode="dominion"] #summary { display: none; }
/* DOMINION gets its own sticky summary in the side rail (mirrors the sermon #summary). */
#domSummary { display: none; }
body[data-mode="dominion"] #domSummary { display: block; }
.dom-datefull, .dom-datetime { margin-top: 4px; }
.dom-people .dom-fig, .dom-photo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dom-fig__prev, .dom-photo__prev {
  height: 54px; width: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}
/* Background-photo focal-point + zoom editor (WYSIWYG: same background-size/position/scale as render) */
.dom-photo__editor { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.dom-photo__crop {
  position: relative; width: 100%; max-width: 340px; aspect-ratio: 16 / 9;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border-strong);
  background: #111; cursor: grab; touch-action: none; user-select: none;
}
.dom-photo__crop:active { cursor: grabbing; }
.dom-photo__img {
  position: absolute; inset: 0; background-size: cover; background-repeat: no-repeat;
  background-position: center 32%; will-change: transform;
}
.dom-photo__zoom { display: flex; align-items: center; gap: 12px; max-width: 340px;
  font-size: 0.84rem; color: var(--muted); }
.dom-photo__zoom input[type="range"] { flex: 1; }
.dom-fig.is-busy .dom-fig__pick { opacity: .5; pointer-events: none; }
.dom-fig__clear {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: inherit; cursor: pointer; line-height: 1; font-size: 15px;
}
.dom-fig__clear:hover { background: rgba(255, 100, 120, .85); color: #fff; border-color: transparent; }
/* Saved-background gallery: a wrapping grid of small pickable thumbnails. */
.dom-bg { margin-top: 14px; width: 100%; }
.dom-bg__grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.dom-bg__item {
  position: relative; width: 108px; height: 61px; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border); background: var(--surface-2) center/cover no-repeat;
  cursor: pointer; padding: 0; transition: border-color var(--t-fast), transform var(--t-fast);
}
.dom-bg__item:hover { transform: translateY(-1px); border-color: var(--accent); }
.dom-bg__item.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.dom-bg__item:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.dom-bg__del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; line-height: 1;
  font-size: 13px; display: none; align-items: center; justify-content: center;
}
.dom-bg__item:hover .dom-bg__del, .dom-bg__item:focus-within .dom-bg__del { display: flex; }
.dom-bg__del:hover { background: rgba(255, 80, 100, .95); }
.dom-advanced > summary {
  cursor: pointer; font-weight: 700; font-size: 1.02rem; font-family: var(--serif);
  list-style: none; padding: 2px 0;
}
.dom-advanced > summary::-webkit-details-marker { display: none; }
.dom-advanced > summary::before { content: "▸ "; color: var(--muted); }
.dom-advanced[open] > summary::before { content: "▾ "; }
.dom-advanced .grid { margin-top: 14px; }
.dom-check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.dom-check input { width: auto; }
input[type="color"] { height: 40px; padding: 4px; cursor: pointer; }
#domGallery .result-card__actions { display: flex; gap: 8px; margin-top: 8px; }
#domGallery .result-card__actions > * { flex: 1; text-align: center; }
/* DOMINION saved-people picker (per figure slot) */
.dom-fig__saved-btn { flex: none; }
.dom-fig__saved { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 6px; }
.dom-face {
  width: 48px; height: 48px; border-radius: 8px; overflow: hidden; padding: 0;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.dom-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dom-face:hover { border-color: var(--accent, #6C32DC); transform: scale(1.05); }

/* ---- Organisation switcher (account menu) --------------------------------
   Only rendered when a person belongs to more than one organisation. */
.account__orgs { padding: 6px 0 0; }
.account__orgs-label {
  padding: 4px 14px 6px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.account__item--org {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.account__item--org.is-current { color: var(--text); font-weight: 600; }
.account__org-role { font-size: 0.72rem; color: var(--faint); }

/* ---- Branding modal (per-organisation logo, colours, details) ---- */
.field__hint { margin: 2px 0 12px; font-size: 0.78rem; color: var(--faint); line-height: 1.4; }
.form-msg--ok { color: #93e6b6; }
.form-msg--error { color: #ffabb9; }

.brand-logos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.brand-logo { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.brand-logo__label { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.brand-logo__preview {
  width: 100%; height: 92px; border: 1px solid var(--border); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.brand-logo__preview--dark { background: #1b1b1f; }
.brand-logo__preview--light { background: #ece7dc; }
.brand-logo__preview img { max-width: 84%; max-height: 72%; object-fit: contain; }

.brand-colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.brand-color { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text); }
.brand-color span { flex: 1; }
.brand-color input[type="color"] {
  width: 34px; height: 26px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: none; cursor: pointer;
}
.brand-color__clear {
  border: none; background: none; color: var(--faint); font-size: 0.72rem;
  cursor: pointer; text-decoration: underline; padding: 2px;
}
.brand-color__clear:hover { color: var(--text); }

/* Secondary text inside a callout (e.g. "skipped" addresses, delivery notes). */
.muted { color: var(--faint); }
.callout code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2); padding: 1px 5px; border-radius: 5px;
}

/* ---- Add a member + Invitations layout ------------------------------------------------
   Deliberately NOT a change to .add-user__grid (1fr/160px), which the Branding screen also
   uses: that shared narrow column is what squeezed the first name into 160px while the email
   box got the wide one. These two grids are scoped to their own forms. */
.member-grid,
.invite-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) {
  .member-grid,
  .invite-grid { grid-template-columns: 1fr; }
}

/* Staged invitations: each person is added to this list, then all are sent together. */
.invite-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex;
               flex-direction: column; gap: 8px; }
.invite-list__row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.invite-list__who { flex: 1; min-width: 0; }
.invite-list__email {
  display: block; color: var(--text); font-size: 0.9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.invite-list__title { display: block; color: var(--faint); font-size: 0.76rem; }
.invite-list__act {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 0.78rem; padding: 3px 6px; border-radius: 5px;
}
.invite-list__act:hover { color: var(--text); background: var(--surface); }
.invite-list__act--remove { font-size: 1.05rem; line-height: 1; }
.invite-empty { margin: 10px 0 0; color: var(--faint); font-size: 0.82rem; }
