/* RP visual-novel chat styles, building on the app.css variable system. */

.rp-card {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--panel, #fff);
}

.rp-card__title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.rp-card__meta {
  color: var(--muted, #667085);
  font-size: 0.85rem;
}

.rp-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--ink, #111827);
  margin-right: 0.25rem;
}

.rp-badge--main { background: #dbeafe; }
.rp-badge--adult { background: #111827; color: #fff; }
.rp-badge--approved { background: #dcfce7; }
.rp-badge--pending { background: #fef9c3; }

.bible-preview {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 0.9rem;
  font-size: 0.78rem;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.rp-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.rp-ref {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.rp-ref__thumb {
  aspect-ratio: 1 / 1;
  background: #0f172a center/cover no-repeat;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 0.75rem;
}

.rp-ref__thumb img { width: 100%; height: 100%; object-fit: cover; }
.rp-ref__body { padding: 0.5rem; font-size: 0.75rem; }
.rp-ref-status { margin-top: 0.5rem; }
.rp-ref__hint { color: #64748b; margin-top: 0.25rem; }
.rp-ref__error {
  color: #b42318;
  margin-top: 0.25rem;
  word-break: break-word;
}

.rp-ref--missing {
  background: #f8fafc;
}

.rp-ref--missing .rp-ref__thumb {
  background: #e2e8f0;
  color: #64748b;
}

.rp-refpkg {
  display: grid;
  gap: 1rem;
}

.rp-refpkg-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.rp-refpkg-seed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.rp-refpkg-seed {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 0.85rem;
}

.rp-refpkg-seed__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.rp-refpkg-seed__preview {
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 0.78rem;
}

.rp-refpkg-seed__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.rp-refpkg-source {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  margin-bottom: 0.75rem;
}

/* ----- Character workspace ----- */
.rp-character-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.rp-character-directory {
  display: grid;
  gap: 1rem;
}

.rp-character-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: var(--panel, #fff);
}

.rp-character-filters {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.rp-character-filters .form-select {
  width: auto;
  max-width: 220px;
}

.rp-character-search {
  width: min(100%, 380px);
}

@media (max-width: 640px) {
  .rp-character-toolbar { flex-wrap: wrap; }
  .rp-character-filters { width: 100%; }
  .rp-character-filters .form-select,
  .rp-character-search { width: 100%; max-width: none; }
}

.rp-character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.rp-character-card {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: var(--panel, #fff);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 210px;
}

.rp-character-card__body {
  display: grid;
  gap: 0.55rem;
  padding: 0.95rem;
  color: inherit;
  text-decoration: none;
  flex: 1 1 auto;
}

.rp-character-card__body:hover {
  background: #f8fafc;
}

.rp-character-card__thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #0f172a;
  display: block;
}

.rp-character-card__title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.rp-character-card__title > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-character-card__desc {
  margin: 0;
  color: #475569;
  font-size: 0.84rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rp-character-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: auto;
}

.rp-character-card__actions {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem 0.95rem;
  border-top: 1px solid var(--line, #eef2f7);
  background: #fbfcfe;
}

.rp-character-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 1.5rem;
  background: #f8fafc;
  text-align: center;
  grid-column: 1 / -1;
}

.rp-character-empty__title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.rp-character-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.rp-character-main,
.rp-character-side {
  min-width: 0;
}

.rp-character-side {
  position: sticky;
  top: 86px;
}

.rp-character-formbar {
  position: sticky;
  top: 78px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

.rp-character-form-section {
  display: grid;
  gap: 0.75rem;
  padding: 0 0 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line, #eef2f7);
}

.rp-character-form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.rp-character-form-section h3 {
  margin: 0;
  color: #334155;
}

.rp-character-field {
  display: grid;
  gap: 0.25rem;
}

/* ── Character editor: sectioned cards + per-field refine ───────────── */
.rp-form-section {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 12px;
  background: var(--panel, #fff);
  margin-bottom: 1rem;
  overflow: hidden;
}

.rp-form-section:last-child {
  margin-bottom: 0;
}

.rp-form-section__head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--line, #e7edf3);
}

.rp-form-section__icon {
  font-size: 1.15rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 9px;
  flex-shrink: 0;
}

.rp-form-section__title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  line-height: 1.2;
}

.rp-form-section__sub {
  font-size: 0.76rem;
  color: var(--muted, #667085);
}

.rp-form-section__body {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.rp-field {
  display: grid;
  gap: 0.3rem;
}

.rp-field__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.6rem;
  flex-wrap: wrap;
}

.rp-field__label {
  font-weight: 600;
  font-size: 0.82rem;
  color: #334155;
  margin: 0;
}

.rp-field__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rp-field__refine {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.55rem;
  border: 1px solid #c7d2fe;
  color: #4338ca;
  background: #eef2ff;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.rp-field__refine:hover:not(:disabled) {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

.rp-field__refine:disabled {
  opacity: 0.7;
  cursor: progress;
}

.rp-field__undo {
  font-size: 0.72rem;
  text-decoration: none;
  color: var(--muted, #667085);
}

.rp-field__undo:hover {
  color: #334155;
}

.rp-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.rp-field--switch {
  background: #f8fafc;
  border: 1px solid var(--line, #e7edf3);
  border-radius: 9px;
  padding: 0.65rem 0.8rem;
}

@media (max-width: 575.98px) {
  .rp-field-grid {
    grid-template-columns: 1fr;
  }
}

.rp-character-refstats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.rp-character-refstat {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  padding: 0.5rem;
  background: #f8fafc;
  display: grid;
  gap: 0.1rem;
  text-align: center;
}

.rp-character-refstat strong {
  font-size: 1rem;
  line-height: 1;
}

.rp-character-refstat span {
  font-size: 0.68rem;
  color: var(--muted, #667085);
}

.rp-character-refstrip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.rp-character-refthumb {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: #0f172a;
  display: block;
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.rp-character-refthumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ----- Sessions list ----- */
.rp-session-card-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.rp-session-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 16px;
  padding: 1rem;
  padding-right: 4.75rem;
  margin-bottom: 0;
  background: var(--panel, #fff);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none !important;
  color: inherit !important;
}

.rp-session-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--brand, #2563eb);
}

.rp-session-card__thumb {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  background: #f1f5f9;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 1.5rem;
}

.rp-session-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rp-session-card__content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rp-session-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.rp-session-card__title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-session-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.rp-session-card__beat {
  font-size: 0.8rem;
  color: var(--muted, #667085);
  margin-bottom: 0.6rem;
  display: block;
}

.rp-session-card__footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--muted, #667085);
}

.rp-session-card__progress {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  margin-bottom: 0.4rem;
  overflow: hidden;
}

.rp-session-card__progress-fill {
  height: 100%;
  background: var(--brand, #2563eb);
  border-radius: inherit;
}

.rp-session-card__delete {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
}

/* ----- Chat session view ----- */
.rp-chat {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  min-height: calc(100vh - 140px);
  align-items: start;
  position: relative; /* anchors the dossier "preparing" overlay (inset: 0) */
}

/* Full-chat overlay shown while the per-playthrough layer generates: its own
   backdrop intercepts every pointer event, so no per-control disabling is needed. */
.rp-chat__gate {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bs-body-bg, #fff) 70%, transparent);
  backdrop-filter: blur(3px);
  border-radius: 16px;
}

.rp-chat__gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 22rem;
  padding: 1.5rem 1.75rem;
  text-align: center;
}

.rp-chat__gate-title {
  font-weight: 600;
}

.rp-chat__gate-body {
  font-size: 0.875rem;
  color: var(--muted, #6b7785);
}

/* Left column: the stage hero plus its filmstrip, stacked. Keeping them in one
   grid cell stops the strip from being auto-placed into the chat's column. */
.rp-stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 360px;
  height: calc(100vh - 140px);
}

.rp-stage {
  position: relative;
  background: #0b1120;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 240px;
}

.rp-stage__media {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Absolute fill + contain reliably bounds the media to the flex-sized stage area;
   percentage max-height fails here because the ancestors only have max-height. */
.rp-stage__media img,
.rp-stage__media video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

@media (min-width: 992px) {
  .rp-stage__media img,
  .rp-stage__media video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}

.rp-stage__placeholder {
  color: #64748b;
  padding: 2rem;
  text-align: center;
  max-width: 360px;
}

.rp-stage__loading {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.5rem;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 6px;
  line-height: 1;
}

.rp-stage__loading .spinner-border {
  width: 0.75rem;
  height: 0.75rem;
  border-width: 0.12em;
}

.rp-stage__loading span {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 0.7rem !important;
  white-space: nowrap;
}

.rp-side {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 16px;
  background: var(--panel, #fff);
  overflow: hidden;
  max-height: calc(100vh - 140px);
}

.rp-settings {
  position: relative;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line, #d8e0ea);
}

.rp-chatbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.rp-chatbar__main {
  min-width: 0;
}

.rp-chatbar__title {
  display: block;
  font-size: 0.85rem;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-chatbar__actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.rp-chatbar__actions .btn {
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
}

.rp-progress {
  margin-top: 0.25rem;
}

.rp-progress__meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted, #667085);
  font-size: 0.68rem;
  line-height: 1.1;
  min-width: 0;
}

.rp-progress__meta span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-progress__bar {
  height: 4px;
  margin-top: 0.2rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.rp-progress__bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand, #2563eb);
  transition: width 180ms ease;
}

/* Per-model "≈ Xs" countdown: a thin fill bar + a tabular seconds label, shown in the
   turn typing bubble, pending-media panels and the session-start gate. */
.rp-countdown {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.rp-countdown__bar {
  flex: 1 1 auto;
  min-width: 60px;
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.rp-countdown__fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand, #2563eb);
  transition: width 240ms linear;
}

.rp-countdown__fill--overrun {
  background: var(--muted, #94a3b8);
}

.rp-countdown__label {
  flex: 0 0 auto;
  color: var(--muted, #667085);
  font-size: 0.68rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rp-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  right: 0.75rem;
  left: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
  font-size: 0.75rem;
  color: var(--ink, #111827);
  /* Cap to the column so a tall dropdown (e.g. the full models list) scrolls
     inside itself instead of growing past .rp-side and getting clipped by its
     overflow:hidden — which left the bottom rows unreachable. The 250px budget
     covers the column's 140px viewport offset plus the settings bar above. */
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rp-usage__row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.1rem 0;
}

/* People / cast knowledge panel */
.rp-people-panel {
  max-height: min(70vh, 480px);
  overflow-y: auto;
}

.rp-people__head {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted, #667085);
  border-bottom: 1px solid var(--line, #e2e8f0);
  padding-bottom: 0.15rem;
  margin-bottom: 0.35rem;
}

/* Player objectives panel */
.rp-objective {
  padding: 0.3rem 0.1rem;
  border-bottom: 1px solid var(--line, #e2e8f0);
}
.rp-objective:last-child {
  border-bottom: 0;
}
.rp-objectives__ladder {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.rp-beat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}
.rp-beat__dot {
  flex: 0 0 auto;
  width: 1.1rem;
  text-align: center;
}
.rp-beat--future .rp-beat__lbl--redacted {
  letter-spacing: 0.15em;
  color: var(--muted, #98a2b3);
  opacity: 0.6;
}
.rp-beat--current .rp-beat__lbl {
  font-weight: 600;
}
.rp-beat--done .rp-beat__lbl {
  color: var(--muted, #667085);
}

.rp-people__empty {
  color: var(--muted, #667085);
  font-size: 0.78rem;
  padding: 0.15rem 0 0.35rem;
}

.rp-people__add {
  margin-bottom: 0.6rem;
}

.rp-people__add-block {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 0.45rem;
  background: #fff;
}

.rp-people__add-title {
  font-weight: 600;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

.rp-people__add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem auto;
  gap: 0.35rem;
  align-items: center;
}

.rp-people__role-select {
  min-width: 0;
}

.rp-people__two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.35rem;
}

.rp-people__item {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  background: #f8fafc;
}

.rp-people__name {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.82rem;
}

.rp-people__traits {
  font-size: 0.74rem;
  color: var(--ink, #111827);
  margin-top: 0.15rem;
  word-break: break-word;
}

.rp-people__facts {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.74rem;
  color: var(--ink, #111827);
}

.rp-people__facts li {
  margin-bottom: 0.15rem;
  word-break: break-word;
}

/* Redesigned people panel: persistent notice + tabbed, read-first body */
.rp-people__notice {
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 7px;
  font-size: 0.74rem;
  line-height: 1.3;
}

.rp-people__notice--error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.rp-people__notice--success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.rp-people__loading {
  color: var(--muted, #667085);
  font-size: 0.78rem;
  padding: 0.6rem 0;
  text-align: center;
}

.rp-people__tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.2rem;
  margin-bottom: 0.65rem;
  border-radius: 9px;
  background: #f1f5f9;
}

.rp-people__tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 0;
  border-radius: 7px;
  padding: 0.32rem 0.4rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted, #667085);
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.rp-people__tab:hover {
  color: var(--ink, #111827);
}

.rp-people__tab.is-active {
  background: #fff;
  color: var(--ink, #111827);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.rp-people__tab-count {
  min-width: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.66rem;
  line-height: 1.15rem;
  background: #e2e8f0;
  color: var(--muted, #667085);
}

.rp-people__tab.is-active .rp-people__tab-count {
  background: var(--brand, #2563eb);
  color: #fff;
}

.rp-people__hint {
  color: var(--muted, #667085);
  font-size: 0.72rem;
  line-height: 1.3;
  margin-bottom: 0.4rem;
}

.rp-people__item--cast {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.rp-people__avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  overflow: hidden;
  background: #e2e8f0;
  display: grid;
  place-items: center;
}

.rp-people__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rp-people__avatar--empty {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted, #667085);
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

.rp-people__main {
  flex: 1 1 auto;
  min-width: 0;
}

.rp-people__name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-people__name .rp-badge {
  flex: 0 0 auto;
  margin-right: 0;
}

.rp-people__meta-line {
  font-size: 0.72rem;
  color: var(--muted, #667085);
  margin-top: 0.15rem;
  word-break: break-word;
}

.rp-people__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.rp-people__inline {
  margin-top: 0.45rem;
  padding: 0.5rem;
  border: 1px dashed var(--line, #cbd5e1);
  border-radius: 8px;
  background: #fff;
}

.rp-people__inline-title {
  font-weight: 600;
  font-size: 0.76rem;
  margin-bottom: 0.3rem;
}

.rp-people__inline-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.rp-usage__model {
  color: var(--muted, #667085);
  overflow-wrap: anywhere;
}

.rp-modal-help {
  color: var(--muted, #667085);
  font-size: 0.85rem;
}

.rp-model-picker {
  display: grid;
  gap: 0.5rem;
}

.rp-model-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  cursor: pointer;
}

.rp-model-option:has(input:checked) {
  border-color: var(--brand, #2563eb);
  background: #eff6ff;
}

.rp-model-option__title {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.rp-model-option__meta,
.rp-model-option__desc {
  color: var(--muted, #667085);
  font-size: 0.76rem;
}

/* Compact variant for the regenerate modal */
.rp-model-picker--compact {
  gap: 0.2rem;
}

.rp-model-option--compact {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}

.rp-model-option--compact .rp-model-option__name {
  flex: 1;
  font-size: 0.84rem;
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-model-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.38rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rp-model-badge--edit {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.rp-model-badge--adult {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.rp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rp-msg {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.9rem;
  max-width: 92%;
  white-space: pre-wrap;
  word-break: break-word;
}

.rp-msg--user {
  align-self: flex-end;
  background: var(--brand, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.rp-msg--assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--ink, #111827);
  border-bottom-left-radius: 4px;
}

.rp-msg--system {
  align-self: center;
  max-width: 86%;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 0.78rem;
}

.rp-msg__who { font-size: 0.7rem; opacity: 0.7; margin-bottom: 0.15rem; }
.rp-msg__text {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.rp-msg__block {
  white-space: pre-wrap;
}

.rp-msg__block--quote {
  align-self: flex-start;
  max-width: 100%;
  padding: 0.48rem 0.62rem;
  border-left: 3px solid rgba(37, 99, 235, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  font-style: italic;
}

.rp-msg__speaker {
  margin-bottom: 0.18rem;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 700;
  color: var(--muted, #667085);
}

.rp-msg__warn { font-size: 0.72rem; color: #b45309; margin-top: 0.25rem; }
.rp-msg__scene { font-size: 0.72rem; color: var(--muted, #667085); margin-top: 0.25rem; }

.rp-msg__fold {
  margin-top: 0.45rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.rp-msg__fold-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 32px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.rp-msg__fold-summary::-webkit-details-marker {
  display: none;
}

.rp-msg__fold-summary::before {
  content: "▸";
  color: var(--muted, #667085);
  font-size: 0.78rem;
  transition: transform 0.15s ease;
}

.rp-msg__fold[open] > .rp-msg__fold-summary::before {
  transform: rotate(90deg);
}

.rp-msg__fold-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #334155;
}

.rp-msg__fold-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted, #667085);
  font-size: 0.7rem;
}

.rp-msg__fold-body {
  padding: 0 0.55rem 0.55rem;
}

.rp-msg__fold-body > .rp-msg__footer {
  margin-top: 0.1rem !important;
}

.rp-msg__fold-body > .rp-msg__media-preview,
.rp-msg__fold-body > .rp-video-ref,
.rp-msg__fold-body > .rp-attached-refs,
.rp-msg__fold-body > .rp-msg-media-gallery {
  margin-top: 0.1rem !important;
}

.rp-msg__pending-media {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  box-shadow: 0 4px 12px rgba(154, 52, 18, 0.08);
}

.rp-msg__failed-media {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  box-shadow: 0 4px 12px rgba(153, 27, 27, 0.08);
}

.rp-msg__pending-spinner {
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  border: 3px solid rgba(234, 88, 12, 0.25);
  border-top-color: #ea580c;
  animation: rp-spin 0.9s linear infinite;
  flex: 0 0 auto;
}

.rp-msg__pending-body {
  display: grid;
  gap: 0.15rem;
}

.rp-msg__pending-body strong {
  font-size: 0.84rem;
}

.rp-msg__pending-body span {
  font-size: 0.74rem;
  color: inherit;
}

@keyframes rp-spin {
  to { transform: rotate(360deg); }
}

.btn-xs {
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  border-radius: 4px;
}

.rp-msg__footer {
  row-gap: 0.25rem !important;
  column-gap: 0.35rem !important;
}

.rp-msg__prompt {
  border-top: 1px solid rgba(0,0,0,0.05);
  padding-top: 0.4rem;
  font-style: italic;
  word-break: break-word;
}

.rp-msg__media-preview {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.1);
  background: #000;
  max-width: 240px;
}

.rp-msg__media-preview img,
.rp-msg__media-preview video {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

.rp-video-ref {
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 0.45rem;
}

.rp-video-ref__label {
  font-size: 0.72rem;
  color: var(--muted, #667085);
  font-weight: 600;
}

.rp-video-ref__preview {
  max-width: 180px;
}

.rp-attached-refs {
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 0.45rem;
}

.rp-attached-refs__label {
  font-size: 0.72rem;
  color: var(--muted, #667085);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.rp-attached-refs__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.5rem;
}

.rp-attached-ref {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.92);
}

.rp-attached-ref__thumb {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  overflow: hidden;
  background: #0f172a;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 0.66rem;
  text-align: center;
  cursor: zoom-in;
}

.rp-attached-ref__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rp-attached-ref__meta {
  min-width: 0;
  display: grid;
  gap: 0.05rem;
}

.rp-attached-ref__meta strong,
.rp-attached-ref__meta span,
.rp-attached-ref__meta small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-attached-ref__meta strong {
  font-size: 0.75rem;
}

.rp-attached-ref__meta span {
  color: #475569;
  font-size: 0.7rem;
}

.rp-attached-ref__meta small {
  color: var(--muted, #667085);
  font-size: 0.64rem;
}

/* Play badge centered on a video thumbnail so the media type reads at a glance. */
.rp-media-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(2, 6, 23, 0.6);
  color: #fff;
  pointer-events: none;
}
.rp-media-play svg { width: 14px; height: 14px; }

/* Per-message variant switcher: a slim row of thumbnails, shown only when a message
   has more than one generated render. The current pick carries a ring + check. */
.rp-variants {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.5rem;
}

.rp-variants__label {
  color: var(--muted, #667085);
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.rp-variants__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.rp-variant {
  position: relative;
  flex: 0 0 auto;
  width: 78px;
  height: 58px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: #020617;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rp-variant:hover { border-color: #94a3b8; }

.rp-variant img,
.rp-variant video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.rp-variant.is-rep {
  border-color: var(--brand, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
  cursor: zoom-in;
}

.rp-variant__badge {
  position: absolute;
  left: 0.25rem;
  bottom: 0.25rem;
  max-width: calc(100% - 0.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.04rem 0.28rem;
  border-radius: 4px;
  background: rgba(2, 6, 23, 0.72);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
}

.rp-variant__check {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand, #2563eb);
  color: #fff;
}
.rp-variant__check svg { width: 12px; height: 12px; }

.rp-input {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  border-top: 1px solid var(--line, #d8e0ea);
}

.rp-input__textarea-row {
  display: flex;
  gap: 0.5rem;
}

.rp-input__media-choice {
  border-bottom: 1px solid var(--line, #f1f5f9);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem !important;
}

.rp-input textarea { resize: none; }

@media (max-width: 991px) {
  .rp-chat {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .rp-stage-col { height: auto; min-height: 0; }
  .rp-stage { height: auto; min-height: 240px; flex: none; }
  .rp-stage__media { height: auto; flex: none; }
  .rp-side { max-height: none; }
  .rp-messages { max-height: 50vh; }
  .rp-people__add-row,
  .rp-people__two-col {
    grid-template-columns: 1fr;
  }
}

/* Stage paging + zoom controls */
.rp-stage__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(8, 12, 24, 0.55);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.rp-stage__nav:hover { background: rgba(8, 12, 24, 0.85); }
.rp-stage__nav--prev { left: 0.6rem; }
.rp-stage__nav--next { right: 0.6rem; }

.rp-stage__expand,
.rp-stage__toggle-strip {
  position: absolute;
  top: 0.6rem;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(8, 12, 24, 0.55);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rp-stage__expand:hover,
.rp-stage__toggle-strip:hover { background: rgba(8, 12, 24, 0.85); }
.rp-stage__expand { right: 0.6rem; }
.rp-stage__toggle-strip { right: 3.2rem; }
.rp-stage__expand svg,
.rp-stage__toggle-strip svg { width: 18px; height: 18px; display: block; }

.rp-stage__counter {
  position: absolute;
  top: 0.7rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(8, 12, 24, 0.6);
  color: #e2e8f0;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.rp-stage__strip {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  margin: 0.6rem 0 0;
  z-index: 4;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.6rem;
  border-radius: 12px;
  background: #f1f5f9;
  border: 1px solid var(--line, #d8e0ea);
}

.rp-stage-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 74px;
  height: 56px;
  border-radius: 7px;
}

.rp-stage-thumb__select {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 2px solid rgba(226, 232, 240, 0.25);
  border-radius: 7px;
  background: #020617;
  cursor: pointer;
}

.rp-stage-thumb.is-active .rp-stage-thumb__select,
.rp-stage-thumb__select.is-active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25);
}

.rp-stage-thumb__select img,
.rp-stage-thumb__select video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rp-stage-thumb__type {
  position: absolute;
  left: 0.25rem;
  bottom: 0.25rem;
  max-width: calc(100% - 0.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.05rem 0.28rem;
  border-radius: 4px;
  background: rgba(2, 6, 23, 0.72);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
}

/* Fullscreen lightbox */
.rp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: rgba(3, 6, 15, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.rp-lightbox__media {
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.rp-lightbox__img,
.rp-lightbox__media video {
  max-width: 96vw;
  max-height: 96vh;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.15s ease;
}
.rp-lightbox__img.is-zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  cursor: zoom-out;
}
.rp-lightbox__close,
.rp-lightbox__nav {
  position: absolute;
  z-index: 1082;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rp-lightbox__close:hover,
.rp-lightbox__nav:hover { background: rgba(255, 255, 255, 0.28); }
.rp-lightbox__close {
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
}
.rp-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
}
.rp-lightbox__nav--prev { left: 1.2rem; }
.rp-lightbox__nav--next { right: 1.2rem; }
.rp-lightbox__counter {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1082;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.85rem;
}
.rp-lightbox__actions {
  position: absolute;
  bottom: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1082;
  display: flex;
  gap: 0.5rem;
}

/* Debug prompt panel */
.rp-debug-panel {
  background: #1a1f2b;
  border: 1px solid #2e3648;
  border-radius: 8px;
  padding: 0.75rem;
  color: #e2e8f0;
}
.rp-debug-panel__label {
  font-size: 0.78rem;
  color: #7c8db0;
  margin-bottom: 0.5rem;
}
.rp-debug-panel__prompt {
  font-size: 0.82rem;
  color: #c9d6f0;
  background: #111620;
  border: 1px solid #2e3648;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 0;
}

.rp-regen-control {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 0.75rem;
}

.rp-regen-control__label {
  color: #334155;
  font-size: 0.82rem;
  font-weight: 700;
}

.rp-force-ref-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.rp-force-ref-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  white-space: nowrap;
}

.rp-force-ref-body {
  margin-top: 0.75rem;
}

.rp-force-ref-characters-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: #374151;
}

.rp-force-ref-char-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rp-force-ref-char-row {
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #fafbfc;
}

.rp-force-ref-char-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.rp-force-ref-char-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: #1f2937;
}

.rp-force-ref-char-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rp-force-ref-thumb-wrap {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: #0f172a;
}

.rp-force-ref__thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #0f172a;
}

.rp-force-ref-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.rp-force-ref-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.55rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
}

.rp-force-ref-mode:has(input:checked) {
  border-color: var(--brand, #2563eb);
  background: #eff6ff;
}

.rp-force-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.rp-force-ref {
  display: grid;
  grid-template-columns: auto 44px minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  min-height: 56px;
  padding: 0.42rem;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.rp-force-ref:has(input:checked) {
  border-color: var(--brand, #2563eb);
  background: #eff6ff;
}

.rp-force-ref__thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #0f172a;
}

.rp-force-ref__meta {
  display: grid;
  min-width: 0;
  gap: 0.05rem;
}

.rp-force-ref__meta strong,
.rp-force-ref__meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-force-ref__meta strong {
  color: #1f2937;
  font-size: 0.74rem;
}

.rp-force-ref__meta small {
  color: var(--muted, #667085);
  font-size: 0.66rem;
}

@media (max-width: 991px) {
  .rp-character-workspace {
    grid-template-columns: 1fr;
  }

  .rp-character-side {
    position: static;
  }
}

@media (max-width: 640px) {
  .rp-character-heading,
  .rp-character-toolbar {
    align-items: stretch;
  }

  .rp-character-heading > *,
  .rp-character-toolbar > * {
    width: 100%;
  }

  .rp-character-search {
    width: 100%;
  }

  .rp-character-grid {
    grid-template-columns: 1fr;
  }

  .rp-character-card__actions {
    flex-direction: column;
  }

  .rp-character-refstats {
    grid-template-columns: 1fr;
  }

  .rp-refpkg-seed-grid {
    grid-template-columns: 1fr;
  }
}

/* Multi-upload grid for generator */
.multi-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.multi-upload-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.multi-upload-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-align: center;
}

.multi-upload-box {
  position: relative;
  aspect-ratio: 1;
  background: #f8fafc;
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.multi-upload-box:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.multi-upload-placeholder {
  font-size: 1.5rem;
  color: #94a3b8;
}

.multi-upload-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.multi-upload-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  z-index: 2;
  cursor: pointer;
}

.multi-upload-clear:hover {
  background: #ef4444;
}

/* ── Story workspace: link saved character ────────────────────────────── */
.rp-ws__linked-thumb {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  margin-right: 8px;
  vertical-align: middle;
}

.rp-ws__overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  z-index: 1050;
  overflow-y: auto;
}

.rp-ws__modal {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.rp-ws__picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.rp-ws__picker-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rp-ws__picker-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.rp-ws__picker-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
}

.rp-ws__picker-thumb--empty {
  background: #f1f5f9;
}

.rp-ws__picker-meta {
  min-width: 0;
}

.rp-ws__picker-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-ws__imgsrc-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.rp-ws__imgsrc-name {
  font-weight: 600;
}

/* Story workspace: characters in two columns on wider screens. */
.rp-ws__char-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .rp-ws__char-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Character studio: identity rail + tabbed main ===== */
.rp-studio {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .rp-studio { grid-template-columns: 1fr; }
}

/* --- Identity rail --- */
.rp-studio__rail {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 960px) {
  .rp-studio__rail { position: static; }
}

.rp-studio__portrait {
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: #0f172a center/cover no-repeat;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 0.85rem;
}

.rp-studio__portrait img { width: 100%; height: 100%; object-fit: cover; }

.rp-studio__name {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.rp-studio__sub { color: var(--muted, #667085); font-size: 0.85rem; }

.rp-studio__readiness {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.rp-studio__ready-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.rp-studio__ready-dot {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  background: #e2e8f0;
  color: #64748b;
  flex: 0 0 auto;
}

.rp-studio__ready-dot.is-done { background: #dcfce7; color: #166534; }
.rp-studio__ready-dot.is-partial { background: #fef9c3; color: #854d0e; }

.rp-studio__rail-actions { display: grid; gap: 0.5rem; }

/* --- Tabs --- */
.rp-studio__tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line, #d8e0ea);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.rp-studio__tab {
  border: 0;
  background: transparent;
  padding: 0.6rem 1rem;
  font-weight: 600;
  color: var(--muted, #667085);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.rp-studio__tab:hover { color: var(--ink, #111827); }

.rp-studio__tab.is-active {
  color: var(--ink, #111827);
  border-bottom-color: var(--accent, #2563eb);
}

.rp-studio__tab-count {
  font-size: 0.72rem;
  color: var(--muted, #667085);
  font-weight: 500;
}

/* --- Reference groups --- */
.rp-studio__group { margin-bottom: 1.75rem; }

.rp-studio__group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.rp-studio__group-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.rp-studio__group-sub { color: var(--muted, #667085); font-size: 0.83rem; margin: 0 0 0.75rem; }

.rp-studio__gate-hint {
  border: 1px dashed var(--line, #d8e0ea);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--muted, #667085);
  font-size: 0.83rem;
  background: #fbfcfe;
}

/* Collapsible "source photos" (seeds) */
.rp-studio__sources { margin-bottom: 1.5rem; }
.rp-studio__sources > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
  color: var(--ink, #111827);
}
.rp-studio__sources[open] > summary { margin-bottom: 0.75rem; }

/* Hero portrait tile slightly larger than the grid tiles */
.rp-studio__hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 220px));
  gap: 0.75rem;
}

/* Per-type reference card: source + model + generate on top, all its images below */
.rp-studio__type {
  padding: 0.85rem;
  margin-bottom: 0.85rem;
}

.rp-studio__type-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.rp-studio__type-name { font-weight: 600; }

.rp-studio__type-ctrl {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rp-studio__model-select { max-width: 240px; }

.rp-studio__source-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
  padding: 0.4rem 0.55rem;
  background: #fbfcfe;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: 8px;
}

.rp-studio__source-label {
  font-size: 0.8rem;
  color: var(--muted, #667085);
}

.rp-studio__source-row .form-select { max-width: 200px; }

/* In-page image lightbox with zoom/pan. */
.rp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: rgba(2, 6, 23, 0.92);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.rp-lightbox__img {
  max-width: 94vw;
  max-height: 92vh;
  transform-origin: center center;
  transition: transform 0.04s linear;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
}

.rp-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.rp-lightbox__close:hover { background: rgba(255, 255, 255, 0.26); }

.rp-lightbox__hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}

/* Tiny model caption under reference / gallery tiles. */
.rp-studio__model-tag {
  font-size: 0.66rem;
  color: var(--muted, #667085);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Source photos (seed slots): one row of four. */
.rp-studio__sources .rp-refpkg-seed-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .rp-studio__sources .rp-refpkg-seed-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
