/* =========================================================
   GEXI — Step-by-step guide (idea to content, automate at any step)

   A page layer on the shared design system (brand tokens from styles.css + the
   gx-ui kit). Same Gemini-grade, GEXI-green look and dark mode as the homepage and
   Create. Mobile-correctness contract (the inherited overflow bug, fixed at the
   root): body is a flex COLUMN, so any max-width container that is a flex child also
   sets width:100% and min-width:0, and every horizontal strip is a bounded,
   swipeable scroll region. (Never place the comment-close sequence inside a comment.)
   ========================================================= */

:root {
  --gd-grad: var(--grad-creative);   /* P2 — collapse onto the single canonical brand gradient (styles.css) */
  --gd-ease: cubic-bezier(.2, .7, .3, 1);
}

/* ---- header ---- */
.gd-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.gd-home { color: var(--brand-500); font-weight: 700; text-decoration: none; font-size: 15px; }
.gd-home:hover { text-decoration: underline; }
.gd-title { font-weight: 650; color: var(--muted); }
.gd-spacer { flex: 1; }
.gd-switch-link { color: var(--brand-500); font-weight: 650; font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.gd-switch-link:hover { text-decoration: underline; }

/* ---- page canvas (mobile-correctness keystone) ---- */
.gd-main {
  max-width: 1000px; width: 100%; min-width: 0; box-sizing: border-box;
  margin-inline: auto; padding: clamp(18px, 4vw, 36px) 16px 96px;
}
.gd-step { animation: gd-rise .42s var(--gd-ease) both; }
.gd-h1 {
  font-size: clamp(24px, 5vw, 34px); font-weight: 800; margin: 0 0 8px; line-height: 1.14;
  letter-spacing: -0.022em; padding-bottom: 1px;
  background: var(--gd-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.gd-sub { margin: 0 auto 22px; font-size: clamp(15px, 2vw, 16px); color: var(--muted); line-height: 1.5; }

/* ---- idea entry (mirrors Create's hero) ---- */
.gd-hero { text-align: center; padding-top: clamp(4px, 2vh, 18px); }
.gd-hero .gd-sub { max-width: 52ch; }
/* P2.4 — the prompt card now lives ONCE as .gx-promptcard in gx-ui.css (guide.html consumes it,
   keeping #gd-desc / #gd-start-btn). The old .gd-promptcard rules were retired here. */
.gd-or {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin: 24px auto 14px; max-width: 620px; color: var(--muted);
  font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
}
.gd-or::before, .gd-or::after { content: ''; height: 1px; flex: 1; background: var(--line); max-width: 120px; }
.gd-chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; min-width: 0; }
@media (max-width: 640px) {
  .gd-chips { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; justify-content: flex-start;
    -webkit-overflow-scrolling: touch; padding-bottom: 4px; margin-inline: -16px; padding-inline: 16px; }
  .gd-chips::-webkit-scrollbar { display: none; }
  .gd-chip { scroll-snap-align: start; flex: 0 0 auto; }
}
.gd-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: var(--radius-pill);
  cursor: pointer; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 650; white-space: nowrap;
  transition: background .16s, border-color .16s, transform .1s var(--gd-ease), box-shadow .16s;
}
.gd-chip-ico { font-size: 17px; line-height: 1; }
.gd-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.gd-chip.is-active { background: var(--gd-grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-md); }
/* Rich chip: label + a one-line "where this takes you" tagline. */
.gd-chip-rich { align-items: center; padding: 9px 16px; }
.gd-chip-text { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.2; text-align: left; }
.gd-chip-label { font-size: 14px; font-weight: 650; }
.gd-chip-tag { font-size: 11px; font-weight: 500; opacity: .62; white-space: nowrap; }
.gd-chip.is-active .gd-chip-tag { opacity: .85; }

/* The journey strip — shows the path a chosen type leads through. */
.gd-flow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px;
  margin-top: 14px; animation: gd-rise .22s var(--gd-ease) both; }
.gd-flow-lead { font-size: 12px; font-weight: 650; color: var(--muted); margin-right: 2px; }
.gd-flow-step { font-size: 12px; font-weight: 600; color: var(--ink); padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--card); border: 1px solid var(--line); white-space: nowrap; }
.gd-flow-arrow { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) {
  .gd-flow { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin-inline: -16px; padding-inline: 16px; }
  .gd-flow::-webkit-scrollbar { display: none; }
  .gd-flow-step, .gd-flow-arrow, .gd-flow-lead { flex: 0 0 auto; }
}

/* ---- workspace: rail + panel ---- */
.gd-workspace { display: grid; grid-template-columns: 210px 1fr; gap: 26px; align-items: start; }
@media (max-width: 760px) { .gd-workspace { grid-template-columns: 1fr; gap: 14px; } }

/* the step rail — vertical tracker on desktop, swipeable strip on phones */
.gd-rail { display: flex; flex-direction: column; gap: 3px; position: sticky; top: 74px; min-width: 0; }
@media (max-width: 760px) {
  .gd-rail {
    position: static; flex-direction: row; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; margin-inline: -16px; padding: 2px 16px 8px;
  }
  .gd-rail::-webkit-scrollbar { display: none; }
}
.gd-rail-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  border: 1px solid transparent; color: var(--muted); font-size: 14px; font-weight: 600;
  background: transparent; cursor: default; white-space: nowrap; transition: background .16s, color .16s, border-color .16s;
}
@media (max-width: 760px) { .gd-rail-item { scroll-snap-align: start; flex: 0 0 auto; padding: 8px 12px; } }
.gd-rail-item.is-current { color: var(--ink); background: var(--grad-brand-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.gd-rail-item.is-done { color: var(--ink); }
.gd-rail-item.is-done .gd-rail-num { background: var(--gd-grad); color: #fff; border-color: transparent; }
.gd-rail-item.is-current .gd-rail-num { border-color: var(--accent); color: var(--brand-500); }
.gd-rail-num {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.gd-rail-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* the focused panel */
.gd-panel { min-width: 0; }
.gd-panel-head { margin: 0 0 4px; }
.gd-panel-title {
  font-size: clamp(20px, 3.4vw, 26px); font-weight: 800; margin: 0; line-height: 1.18; letter-spacing: -0.02em;
  padding-bottom: 1px; background: var(--gd-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.gd-panel-sub { margin: 4px 0 18px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }

.gd-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.gd-card + .gd-card { margin-top: 12px; }
.gd-field-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 6px; }
.gd-textarea, .gd-input {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--card-alt); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; resize: vertical;
  transition: border-color .16s, box-shadow .16s;
}
.gd-textarea:focus, .gd-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }
.gd-help { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }

/* scene list (Script step) */
.gd-scenes { display: flex; flex-direction: column; gap: 10px; }
.gd-scene { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.gd-scene-n { font-size: 11.5px; font-weight: 700; color: var(--brand-500); letter-spacing: 0.03em; }
.gd-scene .gd-textarea { margin-top: 7px; }

/* look summary */
.gd-look { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.gd-look-tag { font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: var(--radius-pill); background: var(--grad-brand-soft); color: var(--brand-500); }
.gd-look-frame { margin: 14px 0 2px; max-width: 360px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.gd-look-frame img { width: 100%; display: block; }

/* tiles (Generate / Review) */
.gd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; min-width: 0; }
@media (max-width: 460px) { .gd-grid { grid-template-columns: 1fr 1fr; } }
.gd-tile { aspect-ratio: 1; border-radius: 14px; overflow: hidden; position: relative; background: var(--card-alt); border: 1px solid var(--line); display: grid; place-items: center; }
.gd-tile img, .gd-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gd-tile.is-error { border-color: var(--red); }
.gd-tile.is-flagged { outline: 2px solid #f59e0b; outline-offset: 1px; }
.gd-tile-ph { color: var(--muted); font-size: 12.5px; text-align: center; }
.gd-tile-fail { color: #fca5a5; padding: 0 10px; }
.gd-tile-fail-t { display: block; margin-top: 5px; font-size: 11px; line-height: 1.35; opacity: .9; }
.gd-ops-edit { width: 100%; margin: 6px 0; }

/* E5 — contextual manual-operations on a review tile (Enhance/Animate/Extend/Edit) */
.gd-tile-actions { position: absolute; top: 7px; right: 7px; z-index: 2; opacity: 0; transition: opacity .15s ease; }
.gd-tile:hover .gd-tile-actions, .gd-tile:focus-within .gd-tile-actions { opacity: 1; }
@media (hover: none) { .gd-tile-actions { opacity: 1; } }
.gd-tile-btn { width: 30px; height: 30px; border-radius: 9px; border: 1px solid rgba(255,255,255,0.18); background: rgba(15,17,21,0.62); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; backdrop-filter: blur(6px); transition: transform .12s ease, background .12s ease; }
.gd-tile-btn:hover { background: rgba(15,17,21,0.85); transform: translateY(-1px); }
.gd-tile-btn:active { transform: none; }
.gd-tile.is-working { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.gd-tile-busy { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; background: rgba(10,12,16,0.55); backdrop-filter: blur(2px); }
.gd-tile-busy-t { color: #fff; font-size: 12px; font-weight: 650; }
.gd-tile-bar { width: 72%; max-width: 140px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.22); overflow: hidden; }
.gd-tile-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--brand-500); transition: width .5s ease; }

/* the op picker panel — a floating card anchored to the tile; it escapes the tile's
   rounded clip (via .is-ops-open) and grows downward so the model picker + Run are
   always visible, never trapped below a square tile's fold. */
.gd-tile.is-ops-open { overflow: visible; z-index: 6; }
.gd-ops { position: absolute; top: 0; left: 0; right: 0; z-index: 4; display: flex; flex-direction: column; gap: 8px; padding: 11px; min-height: 100%; max-height: 340px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); text-align: left; }
.gd-ops-load { margin: auto; }
.gd-ops-head { display: flex; align-items: center; justify-content: space-between; }
.gd-ops-title { font-size: 12px; font-weight: 800; letter-spacing: .02em; color: var(--ink); }
.gd-ops-x { border: none; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; line-height: 1; padding: 2px; }
.gd-ops-empty { color: var(--muted); font-size: 12.5px; margin: auto 0; }
.gd-ops-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.gd-ops-chip { font-size: 11.5px; font-weight: 650; padding: 5px 9px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--card-alt); color: var(--ink); cursor: pointer; }
.gd-ops-chip.is-active { background: var(--grad-brand-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--brand-500); }
.gd-ops-chip.is-suggested { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.gd-ops-star { color: var(--brand-500); font-size: 9px; vertical-align: 1px; }
.gd-ops-why { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.gd-ops-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.gd-ops-model, .gd-ops-prompt { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 9px; background: var(--card-alt); color: var(--ink); font-size: 12.5px; padding: 7px 8px; font-family: inherit; }
.gd-ops-err { color: var(--red); font-size: 11.5px; }
.gd-ops-row { margin-top: auto; }
.gd-ops-run { width: 100%; padding: 8px; border-radius: 10px; border: 1px solid var(--brand-500); background: var(--brand-500); color: #fff; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.gd-ops-run:disabled { opacity: .6; cursor: default; }
.gd-ops-chain { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink); cursor: pointer; }
.gd-ops-chain input { accent-color: var(--brand-500); }

/* B4 — "Enhance all" batch affordance above the review grid */
.gd-batch { margin: 0 0 12px; }
.gd-batch-btn { font-size: 13px; font-weight: 650; padding: 8px 14px; border-radius: var(--radius-pill); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--grad-brand-soft); color: var(--brand-500); cursor: pointer; }
.gd-batch-btn:hover { filter: brightness(1.03); }
.gd-batch-btn:disabled { opacity: .6; cursor: default; }
.gd-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--brand-500); animation: gd-spin .8s linear infinite; }
.gd-progress { height: 8px; border-radius: var(--radius-pill); background: var(--card-alt); overflow: hidden; margin: 4px 0 14px; }
.gd-progress-fill { height: 100%; width: 0; border-radius: var(--radius-pill); background: var(--gd-grad); transition: width .4s ease; }

/* result */
.gd-result { display: flex; justify-content: center; margin: 6px 0; }
.gd-result video, .gd-result img, .gd-result audio { width: 100%; max-width: 440px; border-radius: 16px; }
/* image_set result — a gallery of every image, not just the first */
.gd-result-set { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; width: 100%; max-width: 560px; }
.gd-result-set img { width: 100%; border-radius: 12px; box-shadow: var(--shadow); background: #000; }
.gd-result video, .gd-result img { box-shadow: var(--shadow-lg); background: #000; }
.gd-doc { white-space: pre-wrap; margin: 0; font: inherit; line-height: 1.6; color: var(--ink); }

/* producer status strip */
.gd-producer { margin: 0 0 14px; padding: 13px 15px; border-radius: 14px; font-size: 14.5px; line-height: 1.5; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.gd-producer-line { display: flex; gap: 9px; align-items: center; }
.gd-producer-vision { margin-top: 7px; font-size: 13.5px; font-style: italic; color: var(--muted); }
.gd-producer.is-running { border-color: rgba(37,99,235,0.4); background: rgba(37,99,235,0.07); }
.gd-producer.is-running .gd-spinner { border-top-color: #2563eb; }
.gd-producer.is-paused, .gd-producer.is-escalated { border-color: rgba(251,191,36,0.45); background: rgba(251,191,36,0.10); }
.gd-producer.is-done { border-color: rgba(22,163,74,0.4); background: rgba(34,197,94,0.09); }

/* note / review summary */
.gd-note { padding: 13px 15px; border-radius: 13px; background: var(--card-alt); color: var(--ink); font-size: 14px; line-height: 1.5; }
.gd-note-info { background: color-mix(in srgb, var(--accent) 12%, var(--card-alt)); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); font-size: 13px; margin-bottom: 12px; }
.gd-review { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; }
.gd-review.all-ok { color: var(--brand-500); }
.gd-review.has-flags { color: #b45309; }

/* actions */
.gd-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; min-width: 0; }
.gd-btn {
  flex: 1; min-width: 0; padding: 13px 20px; border-radius: var(--radius-pill); font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; border: 1.5px solid transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: filter .16s, transform .1s var(--gd-ease), box-shadow .16s, border-color .16s;
}
.gd-btn:active { transform: translateY(1px); }
.gd-btn-primary { background: var(--gd-grad); color: #fff; box-shadow: var(--shadow-md); }
.gd-btn-primary:hover { filter: brightness(1.05); }
.gd-btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; filter: none; }
.gd-btn-ghost { flex: 0 0 auto; background: transparent; border-color: var(--line-strong); }
.gd-btn-ghost:hover { border-color: var(--accent); }
.gd-btn-magic { background: linear-gradient(135deg, #7c3aed, #2563eb 55%, var(--accent-2)); color: #fff; box-shadow: 0 6px 18px rgba(124,58,237,0.32); }
.gd-btn-magic:hover { filter: brightness(1.06); }
.gd-btn-magic:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.gd-error { margin-top: 12px; color: var(--red); font-size: 14px; }

/* disabled state */
.gd-disabled { padding: 48px 0; }
.gd-disabled-card { border: 1px dashed var(--line-strong); border-radius: 18px; padding: 28px; text-align: center; color: var(--ink); }
.gd-disabled-card code { background: var(--card-alt); padding: 2px 7px; border-radius: 6px; }

/* =========================================================
   Creative Director — the brainstorm (diverge) step. Desktop and mobile are
   PURPOSE-BUILT, not one responsive layout: desktop compares directions in
   side-by-side columns; mobile is a calm vertical stack with a sticky confirm bar.
   ========================================================= */

/* step header row: title + a Back control on every step (lossless) */
.gd-stephead { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 14px; }
.gd-stephead .gd-panel-head { flex: 1; min-width: 0; margin: 0; }
.gd-back {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; margin-top: 2px;
  padding: 8px 13px 8px 11px; border-radius: var(--radius-pill); font: inherit; font-size: 13.5px; font-weight: 650;
  cursor: pointer; color: var(--ink); background: var(--card); border: 1.5px solid var(--line-strong);
  transition: border-color .16s, transform .1s var(--gd-ease), background .16s;
}
.gd-back:hover { border-color: var(--accent); transform: translateX(-1px); }
.gd-back:disabled { opacity: .4; cursor: not-allowed; }

/* a soft "revisit?" flag on a rail item whose upstream choice changed */
.gd-rail-item.is-stale .gd-rail-num { border-color: #f59e0b; color: #b45309; }
.gd-rail-dot { width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; margin-left: auto; flex: 0 0 auto; }

/* candidate grid — DESKTOP: comparison columns */
.gd-cands { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 761px) {
  .gd-cands.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .gd-cands.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .gd-cands.cols-4 { grid-template-columns: repeat(2, 1fr); }   /* 4 → balanced 2×2 */
}

/* UC2 — the CAST gate ("Who's in it?"): a grid of the owner's characters to pick one */
.gd-cast-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin: 0 0 4px; }
@media (min-width: 561px) { .gd-cast-grid { grid-template-columns: repeat(3, 1fr); } }
.gd-cast-card {
  position: relative; appearance: none; width: 100%; min-width: 0; box-sizing: border-box; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 16px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink); font: inherit;
  transition: border-color .16s, box-shadow .18s, transform .12s var(--gd-ease), background .16s;
}
.gd-cast-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.gd-cast-card:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }
.gd-cast-card.is-selected { border-color: transparent; background: var(--grad-brand-soft); box-shadow: 0 0 0 2px var(--accent), var(--shadow-md); }
.gd-cast-ph { font-size: 30px; line-height: 1; }
.gd-cast-name { font-size: 14px; font-weight: 650; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-cast-check { position: absolute; top: 8px; right: 9px; font-size: 13px; font-weight: 800; color: var(--accent); opacity: 0; transition: opacity .14s; }
.gd-cast-card.is-selected .gd-cast-check { opacity: 1; }

/* a candidate "direction" card */
.gd-cand {
  position: relative; text-align: left; appearance: none; width: 100%; min-width: 0; box-sizing: border-box;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 16px 16px 15px;
  cursor: pointer; display: flex; flex-direction: column; gap: 8px; color: var(--ink); font: inherit;
  max-height: 392px; overflow: hidden;   /* a longer idea + sample scenes scroll WITHIN the card */
  transition: border-color .16s, box-shadow .18s, transform .12s var(--gd-ease), background .16s;
}
@media (max-width: 760px) { .gd-cand { max-height: 340px; } }
/* the scrollable body — header (badge/title/check) stays pinned, story content scrolls */
.gd-cand-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 9px; padding-right: 4px; }
.gd-cand-body::-webkit-scrollbar { width: 6px; }
.gd-cand-body::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 30%, transparent); border-radius: 3px; }
.gd-cand-body::-webkit-scrollbar-track { background: transparent; }
/* a soft bottom fade hints "there's more to read" */
.gd-cand-fade { position: absolute; left: 1px; right: 1px; bottom: 1px; height: 26px; border-radius: 0 0 17px 17px;
  pointer-events: none; background: linear-gradient(to top, var(--card), transparent); }
.gd-cand.is-selected .gd-cand-fade { background: linear-gradient(to top, color-mix(in srgb, var(--accent) 12%, var(--card)), transparent); }
.gd-cand:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.gd-cand:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }
.gd-cand.is-selected {
  border-color: transparent; background: var(--grad-brand-soft);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
}
.gd-cand-top { display: flex; align-items: center; gap: 10px; }
.gd-cand-badge {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: var(--brand-500);
  background: var(--grad-brand-soft); border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
}
.gd-cand.is-selected .gd-cand-badge { background: var(--gd-grad); color: #fff; border-color: transparent; }
.gd-cand-title { font-weight: 750; font-size: 15.5px; letter-spacing: -0.01em; min-width: 0; line-height: 1.25; }
.gd-cand-check {
  margin-left: auto; flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); color: transparent; font-size: 13px; transition: all .16s;
}
.gd-cand.is-selected .gd-cand-check { background: var(--gd-grad); border-color: transparent; color: #fff; }
.gd-cand-summary { font-size: 13.5px; color: var(--ink); line-height: 1.55; opacity: .92; }
.gd-cand-scenes { margin-top: 2px; padding-top: 9px; border-top: 1px dashed var(--line); }
.gd-cand-sceneslabel { margin: 0 0 7px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: color-mix(in srgb, var(--accent) 65%, var(--muted)); }
.gd-cand-beats { margin: 0; padding: 0; list-style: none; counter-reset: gd-scene; display: flex; flex-direction: column; gap: 11px; }
.gd-cand-beats li { counter-increment: gd-scene; position: relative; padding-left: 26px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.gd-cand-beats li::before {
  content: counter(gd-scene); position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 6px;
  display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--brand-500);
  background: var(--grad-brand-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}
/* a scene = a short title + a small paragraph you can read */
.gd-cand-beat-t { display: block; font-weight: 750; font-size: 12.5px; color: var(--ink); letter-spacing: -0.01em; }
.gd-cand-beat-s { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-top: 2px; }
.gd-cand-media { aspect-ratio: 16/10; border-radius: 12px; background: var(--card-alt); border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; }
.gd-cand-media img { width: 100%; height: 100%; object-fit: cover; }
.gd-cand-media-ph { font-size: 22px; opacity: .5; }

/* the diverge toolbar: blend toggle + regenerate (left), live count (right) */
.gd-diverge-tools { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; flex-wrap: wrap; }
.gd-tool {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: var(--radius-pill);
  font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line-strong); transition: border-color .16s, background .16s, color .16s;
}
.gd-tool:hover { border-color: var(--accent); }
.gd-tool.is-on { background: var(--grad-brand-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--brand-500); }
.gd-tool:disabled { opacity: .5; cursor: not-allowed; }
.gd-diverge-hint { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* confirm bar — inline on desktop; sticky to the bottom on mobile */
.gd-confirm {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; min-width: 0;
}
.gd-confirm .gd-btn-magic { flex: 0 0 auto; }
@media (max-width: 760px) {
  .gd-confirm {
    position: sticky; bottom: 0; z-index: 8; margin-inline: -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-top: 1px solid var(--line);
  }
  .gd-confirm .gd-btn-magic { flex: 1; order: 2; }
  .gd-confirm .gd-btn-primary { order: 1; }
}

/* inline-edit affordance under a selected card */
.gd-cand-edit { margin-top: 10px; }
.gd-cand-edit .gd-textarea { font-size: 14px; }

@keyframes gd-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes gd-spin { to { transform: rotate(360deg); } }
@keyframes gd-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.gd-cand { animation: gd-pop .32s var(--gd-ease) both; }
.gd-cand:nth-child(2) { animation-delay: .05s; }
.gd-cand:nth-child(3) { animation-delay: .1s; }
.gd-cand:nth-child(4) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) { .gd-step, .gd-spinner, .gd-cand { animation: none !important; } }

/* ---- The Library (saved work) on the start screen ---- */
.gd-library { margin: 36px auto 0; max-width: 640px; width: 100%; text-align: left; animation: gd-rise .42s var(--gd-ease) both; }
.gd-lib-lane + .gd-lib-lane { margin-top: 22px; }
.gd-lib-title { font-size: 12.5px; font-weight: 750; color: var(--muted); margin: 0 0 10px; letter-spacing: 0.01em; text-transform: uppercase; }
.gd-lib-grid { display: grid; gap: 9px; grid-template-columns: 1fr 1fr; min-width: 0; }
@media (max-width: 560px) { .gd-lib-grid { grid-template-columns: 1fr; } }
/* card = a relative container holding the full-width OPEN button + a kebab + a menu */
.gd-lib-card { position: relative; min-width: 0; border-radius: 14px;
  transition: border-color .16s, transform .1s var(--gd-ease), box-shadow .16s; }
.gd-lib-open { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-width: 0; box-sizing: border-box;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 11px 44px 11px 13px; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .16s, transform .1s var(--gd-ease), box-shadow .16s; }
.gd-lib-open:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.gd-lib-ico { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: var(--grad-brand-soft); }
.gd-lib-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.gd-lib-name { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gd-lib-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gd-lib-go { flex: 0 0 auto; color: var(--muted); font-size: 17px; font-weight: 700; position: absolute; right: 40px; top: 50%; transform: translateY(-50%); }
.gd-lib-open:hover .gd-lib-go { color: var(--brand-500); }
/* kebab + dropdown menu */
.gd-lib-kebab { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center; transition: background .16s, color .16s; }
.gd-lib-kebab:hover { background: var(--card-alt); color: var(--ink); }
.gd-lib-menu { position: absolute; top: 38px; right: 8px; z-index: 12; min-width: 184px; padding: 5px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg); }
.gd-lib-menu button { text-align: left; background: transparent; border: 0; padding: 9px 11px; border-radius: 8px; font: inherit; font-size: 13.5px;
  color: var(--ink); cursor: pointer; transition: background .12s; }
.gd-lib-menu button:hover { background: var(--card-alt); }
.gd-lib-menu button.is-danger { color: var(--red); }
.gd-lib-menu button.is-danger:hover { background: rgba(220,38,38,0.08); }
.gd-lib-rename { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; font-weight: 650; color: var(--ink);
  background: var(--card-alt); border: 1.5px solid var(--accent); border-radius: 8px; padding: 4px 8px; outline: none; }
.gd-lib-confirm { display: flex; align-items: center; gap: 8px; box-sizing: border-box; width: 100%;
  background: var(--card); border: 1.5px solid var(--red); border-radius: 14px; padding: 11px 13px; }
.gd-lib-confirm-q { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 650; }
.gd-lib-confirm-yes, .gd-lib-confirm-no { flex: 0 0 auto; border: 0; border-radius: var(--radius-pill); padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.gd-lib-confirm-yes { background: var(--red); color: #fff; }
.gd-lib-confirm-no { background: var(--card-alt); color: var(--ink); }

/* F2 — compose-ladder verdict badges (only the user-meaningful ones) */
.gd-tile-sel {
  position: absolute; left: 6px; bottom: 6px; z-index: 2;
  font-size: 10.5px; font-weight: 800; letter-spacing: .01em; white-space: nowrap;
  color: #fff; border-radius: 999px; padding: 3px 8px;
  background: rgba(17, 24, 39, .78); backdrop-filter: blur(4px);
}
.gd-tile-sel.is-upgrade { background: linear-gradient(135deg, rgba(16,185,129,.92), rgba(132,204,22,.92)); }
.gd-tile-sel.is-rescue { background: rgba(180, 83, 9, .9); }
.gd-tile-sel.gd-tile-sel-voice { left: auto; right: 6px; padding: 3px 6px; }   /* F1: the narration marker sits opposite the visual badge */
