/* Content Factory — App UI Styles (post-login) */

/* ─── Fix: dark theme for elements using --pp/--ink vars ─── */
/* Cards in the book overlay panel */
.card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary);
}
.cc { background: var(--bg-card) !important; border: 1px solid var(--border) !important; }
.cn2, .ct { color: var(--text-primary) !important; }
.cr2, .cd, .ct2 { color: var(--text-secondary) !important; }
.cref { background: rgba(200,169,110,0.08) !important; color: var(--accent) !important; border-radius: 5px; }

/* Book overlay (studio panels) */
.ob { background: var(--bg-panel) !important; }
.pl { background: var(--bg-panel) !important; border-right: 1px solid var(--border) !important; }
.pr { background: var(--bg-main) !important; }
.bt { color: var(--text-primary) !important; }
.til { color: var(--text-primary) !important; }
.tib { background: var(--bg-input) !important; color: var(--text-secondary) !important; }
.tth { color: var(--text-secondary) !important; }
.ti:hover { background: rgba(200,169,110,0.08) !important; }
.ti.active { background: rgba(200,169,110,0.14) !important; }
.tag { background: var(--bg-input) !important; color: var(--text-secondary) !important; }
.st { color: var(--text-secondary) !important; }
.empty { color: var(--text-secondary) !important; }

/* Misc forms inside panels */
.fi { background: var(--bg-input) !important; border-color: var(--border) !important; color: var(--text-primary) !important; }
.fi:focus { border-color: var(--accent) !important; }
.fs { background: var(--bg-input) !important; border-color: var(--border) !important; color: var(--text-primary) !important; }
.ur { background: var(--bg-card) !important; border-color: var(--border) !important; }
.pb { background: var(--bg-input) !important; }
.ptxt { color: var(--accent) !important; }
.ptool { color: var(--text-secondary) !important; }

/* Brief modal */
.bmod-hdr, .bmod-footer { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.bmod-nav { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.bmod-content { background: var(--bg-main) !important; }
.bmod-section-title, .bmod-hdr-title { color: var(--text-primary) !important; }
.bmod-label { color: var(--text-secondary) !important; }
.bmod-input, .bmod-textarea, .bmod-select {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
.bmod-input:focus, .bmod-textarea:focus, .bmod-select:focus { border-color: var(--accent) !important; }
.bmod-char-card, .bmod-lib-picker { background: var(--bg-card) !important; border-color: var(--border) !important; }
.bmod-nav-lb { color: var(--text-primary) !important; }
.bmod-nav-item:hover { background: rgba(200,169,110,0.08) !important; }
.bmod-nav-item.active { background: rgba(200,169,110,0.14) !important; }
.bmod-footer-status { color: var(--text-secondary) !important; }
.bmod-btn {
  color: var(--accent) !important;
  border-color: rgba(200,169,110,0.4) !important;
  background: transparent !important;
}
.bmod-btn:hover { border-color: var(--accent) !important; background: rgba(200,169,110,0.08) !important; }
.bmod-btn-primary {
  background: var(--accent-btn) !important;
  color: var(--text-primary) !important;
  border: none !important;
}
.bmod-btn-primary:hover { background: var(--accent) !important; color: #0D0B09 !important; }
.bmod-btn-secondary { color: var(--text-primary) !important; border-color: var(--border) !important; background: transparent !important; }
.bmod-btn-secondary:hover { border-color: var(--accent) !important; color: var(--accent) !important; background: rgba(200,169,110,0.06) !important; }
.bmod-btn-danger { color: var(--danger) !important; border-color: rgba(192,57,43,0.4) !important; }
.bmod-drop-zone { border-color: var(--border) !important; }
.bmod-drop-zone.drag-over { border-color: var(--accent) !important; background: rgba(200,169,110,0.06) !important; }

/* Script modal */
.smod-hdr, .smod-tab-bar, .smod-toolbar { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.smod-title { color: var(--text-primary) !important; }
.smod-tab { color: var(--text-secondary) !important; }
.smod-tab.active { background: var(--accent) !important; color: #0D0B09 !important; }
.smod-tab:not(.active):hover { background: rgba(200,169,110,0.1) !important; color: var(--text-primary) !important; }
.smod-ver-panel { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.smod-ver-hdr { border-color: var(--border) !important; color: var(--text-primary) !important; }
.smod-ver-item { border-color: var(--border) !important; }
.smod-ver-date { color: var(--text-secondary) !important; }
.smod-ver-num { color: var(--accent) !important; }
.smod-ver-restore { color: var(--accent) !important; border-color: var(--accent) !important; }
.smod-ver-restore:hover { background: var(--accent) !important; color: #0D0B09 !important; }
#brief-modal, #script-modal { background: var(--bg-main) !important; }

/* ─── Script table ─── */
.sc-table { background: var(--bg-main); }
.sc-table th {
  background: var(--bg-panel) !important;
  color: var(--text-secondary) !important;
  border-bottom: 1px solid var(--border) !important;
}
.sc-ep-row td {
  background: rgba(200,169,110,0.1) !important;
  border-top: 2px solid rgba(200,169,110,0.3) !important;
  border-bottom: 1px solid var(--border) !important;
}
.sc-ep-num { color: var(--accent) !important; }
.sc-ep-title { color: var(--text-primary) !important; }
.sc-ep-dur, .sc-dur { color: var(--text-secondary) !important; }
.sc-sc-row td {
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border) !important;
}
.sc-sc-row:hover td { background: var(--bg-input) !important; }
.sc-sc-num { color: var(--text-secondary) !important; }
.sc-sh-row td {
  background: var(--bg-main) !important;
  border-bottom: 1px solid rgba(58,53,48,0.6) !important;
}
.sc-sh-row.has-prompt td { background: rgba(200,169,110,0.04) !important; }
.sc-sh-num { color: var(--text-secondary) !important; }
.sc-sh-type { color: var(--text-secondary) !important; font-size: 10px !important; font-weight: 500 !important; }
.sc-desc, .sc-chars, .sc-loc { color: var(--text-primary) !important; }
.sc-dialogue { color: #C8A96E !important; }
.sc-ai-prompt { color: var(--text-secondary) !important; font-style: italic; }
.editable-cell { color: var(--text-primary) !important; }
.editable-cell:hover { background: rgba(200,169,110,0.06) !important; }
.editable-cell:focus { background: rgba(200,169,110,0.1) !important; outline-color: var(--accent) !important; }
.sc-expand-btn { color: var(--text-secondary) !important; }
.sc-expand-btn:hover { background: rgba(200,169,110,0.1) !important; color: var(--accent) !important; }

/* ─── Shot plan ─── */
.sp-table th {
  background: var(--bg-panel) !important;
  color: var(--text-secondary) !important;
  border-bottom: 2px solid var(--border) !important;
}
.sp-table td { border-bottom: 1px solid var(--border) !important; }
.sp-table tr:hover td { background: rgba(200,169,110,0.04) !important; }
.sp-table tr.selected td { background: rgba(200,169,110,0.1) !important; }
.sp-scene-row td { background: rgba(200,169,110,0.06) !important; color: var(--text-primary) !important; }
.sp-scene-row:hover td { background: rgba(200,169,110,0.12) !important; }
.sp-right { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.sp-section { background: var(--bg-card) !important; border-radius: 8px; }
.sp-section-title { color: var(--text-secondary) !important; }
.sp-field label { color: var(--text-secondary) !important; }
.sp-field input, .sp-field select, .sp-field textarea {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
.sp-toolbar { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.sp-prompt-card { background: var(--bg-input) !important; border-color: var(--border) !important; }
.sp-prompt-card.primary { border-color: var(--accent) !important; }
.sp-prompt-text { color: var(--text-primary) !important; }
.sp-prompt-actions button {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-secondary) !important;
}
.sp-prompt-actions button:hover { color: var(--text-primary) !important; }
.sp-prompt-actions button.pri { border-color: var(--accent) !important; color: var(--accent) !important; }
.sp-approve-btn.approved { background: rgba(39,174,96,0.18) !important; color: var(--success) !important; border: 1px solid var(--success) !important; }
.sp-approve-btn.unapproved { background: var(--accent-btn) !important; color: var(--text-primary) !important; }
.sp-approved { color: var(--success) !important; }
.sp-detail-title { color: var(--accent) !important; }
.sp-detail-hdr { border-color: var(--border) !important; }
.sp-detail-close { color: var(--text-secondary) !important; }
.sp-detail-close:hover { color: var(--text-primary) !important; }
.sp-add-row input, .sp-add-row textarea {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
.sp-gen-row select {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
/* export dropdown */
.export-menu { background: var(--bg-card) !important; border-color: var(--border) !important; }
.export-menu button { color: var(--text-primary) !important; }
.export-menu button:hover { background: rgba(200,169,110,0.1) !important; }
.smod-bible-form { background: var(--bg-card) !important; border-color: var(--border) !important; }
.smod-bible-form input {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
.bible-save-btn { background: var(--accent-btn) !important; }

/* ─── Generation panels (full-page) ─── */
.gen-fullpage {
  min-height: calc(100vh - 80px);
  padding: 24px 32px;
  max-width: 1300px;
}
.gen-fullpage .st {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: var(--text-secondary) !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  margin-bottom: 20px !important;
}
/* Make the gen form label colors match dark theme */
.gen-fullpage [style*="color:var(--sep)"],
.gen-fullpage [style*="color: var(--sep)"] {
  color: var(--text-secondary) !important;
}
.gen-fullpage [style*="color:var(--ink2)"],
.gen-fullpage [style*="color: var(--ink2)"] {
  color: var(--text-primary) !important;
}
/* References drop zone */
.gen-fullpage [style*="border:2px dashed"] {
  border-color: var(--border) !important;
  background: var(--bg-card) !important;
  border-radius: 8px !important;
  transition: border-color 0.2s !important;
}
.gen-fullpage [style*="border:2px dashed"]:hover {
  border-color: var(--accent) !important;
}
/* Model select */
.gen-fullpage [style*="background:var(--s2)"],
.gen-fullpage [style*="background: var(--s2)"] {
  background: var(--bg-input) !important;
}
/* Aspect ratio buttons (rpill) */
.rpill { border-color: var(--border) !important; }
.rpill label { color: var(--text-secondary) !important; }
.rpill input[type=radio]:checked + label { background: var(--accent) !important; color: #0D0B09 !important; }
.rpill label:hover { background: rgba(200,169,110,0.1) !important; color: var(--text-primary) !important; }
/* Generate button override */
.gen-fullpage [style*="background:#185FA5"],
.gen-fullpage [style*="background: #185FA5"],
[id^="sa-gen-"],
[id="vid-btn"],
button[onclick*="runStudioGenerate"],
button[onclick*="runVideoGenerate"],
button[onclick*="runAppGenerate"] {
  background: var(--accent-btn) !important;
  color: var(--text-primary) !important;
  border: none !important;
}
/* Video form labels */
.gen-fullpage label[style*="color:var(--ink2)"] { color: var(--text-primary) !important; }
.gen-fullpage input[type=radio] { accent-color: var(--accent) !important; }

/* ─── Project Cards (new design) ─── */
.projects-grid-new {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.pc-new {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s;
  min-height: 280px;
}
.pc-new:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}
.pc-img {
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: var(--bg-input);
  flex-shrink: 0;
}
.pc-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s; }
.pc-new:hover .pc-img img { transform: scale(1.04); }
.pc-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}
.pc-body {
  padding: 16px 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pc-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.pc-date { font-size: 12px; color: var(--text-secondary); }
.pc-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.pc-stage {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.pc-stage.pc-stage-ok {
  background: rgba(200,169,110,0.12);
  color: var(--accent);
  border-color: rgba(200,169,110,0.3);
}
.pc-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.pc-open-btn {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.pc-open-btn:hover {
  background: var(--accent);
  color: #0D0B09;
}
/* Create new project card */
.pc-create {
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.pc-create:hover {
  border-color: var(--accent);
  background: rgba(200,169,110,0.04);
}
.pc-create-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.pc-create:hover .pc-create-icon {
  border-color: var(--accent);
  color: var(--accent);
}
.pc-create-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.03em;
}
.pc-create:hover .pc-create-label { color: var(--accent); }

/* ─── Character / Environment cards ─── */
.char-card-grid, .env-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}
.char-card {
  width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.char-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(200,169,110,0.3);
}
.char-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--bg-input);
}
.char-card-img-placeholder {
  width: 100%;
  height: 160px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  opacity: 0.4;
}
.char-card-body {
  padding: 10px 12px;
}
.char-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-card-slug {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ─── Sidebar active state with left accent bar ─── */
.sbn { position: relative; }
.sbn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* ─── Header ─── */
#hdr {
  background: var(--bg-panel) !important;
  border-bottom: 1px solid var(--border) !important;
}
#hdr-title { color: var(--text-primary) !important; }
.bg { color: var(--text-secondary) !important; border-color: var(--border) !important; }
.bg:hover { color: var(--text-primary) !important; border-color: var(--border-light) !important; }

/* ─── Project page styles ─── */
.pp-hdr { background: var(--bg-card) !important; border-color: var(--border) !important; }
.pp-title { color: var(--text-primary) !important; }
.pp-title:hover { background: var(--bg-input) !important; }
.pp-title:focus { background: var(--bg-input) !important; outline-color: var(--accent) !important; }
.pp-desc { color: var(--text-secondary) !important; }
.pp-desc:hover, .pp-desc:focus { background: var(--bg-input) !important; }
.pp-meta { color: var(--text-secondary) !important; }
.pp-back { color: var(--text-secondary) !important; }
.pp-back:hover { color: var(--text-primary) !important; }

/* ─── Main page area ─── */
#sv { background: var(--bg-main); }
.sh { color: var(--text-secondary) !important; }
.sh::after { background: var(--border) !important; }

/* ─── Modals (new/style) ─── */
#new-proj-modal > div { background: var(--bg-panel) !important; border-color: var(--border) !important; }
#new-proj-modal .sbn-l { color: var(--text-primary) !important; }

/* ─── Video history panel overrides ─── */
#vid-hist-preview > div { background: var(--bg-card) !important; }
.vc { background: var(--bg-input) !important; }
.vl { color: var(--text-secondary) !important; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .projects-grid-new { grid-template-columns: repeat(2, 1fr); }
  .gen-fullpage { padding: 16px; }
}
@media (max-width: 480px) {
  .projects-grid-new { grid-template-columns: 1fr; }
  .char-card-grid, .env-card-grid { justify-content: center; }
}


/* ═══════════════════════════════════════════════════════
   SCRIPT TABLE — fixed column widths
═══════════════════════════════════════════════════════ */
#smod-content { padding: 0; }
.sc-table {
  table-layout: fixed !important;
  width: 100%;
  border-collapse: collapse;
}
/* Override inline widths with !important */
.sc-table thead th:nth-child(1) { width: 60px !important; }
.sc-table thead th:nth-child(2) { width: 160px !important; }
.sc-table thead th:nth-child(3) { width: 100px !important; }
.sc-table thead th:nth-child(4) { width: 100px !important; }
.sc-table thead th:nth-child(5) { width: 90px !important; }
.sc-table thead th:nth-child(6) { width: 60px !important; }
/* col 6 (Description) = auto = takes remaining ~50%+ */

/* Cell overflow rules */
.sc-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-table td:nth-child(7) {
  white-space: normal;
  word-break: break-word;
  line-height: 1.55;
}
.sc-sh-row td { min-height: 60px; }

/* ═══════════════════════════════════════════════════════
   SHOT PLAN TABLE — fixed column widths
═══════════════════════════════════════════════════════ */
.sp-table {
  table-layout: fixed !important;
  width: 100%;
}
.sp-table thead th:nth-child(1) { width: 40px !important; text-align: center !important; }
.sp-table thead th:nth-child(2) { width: 70px !important; }
.sp-table thead th:nth-child(3) { width: 40px !important; text-align: center !important; }
/* col 4 = Описание = остаток */
.sp-table thead th:nth-child(5) { width: 90px !important; }
.sp-table thead th:nth-child(6) { width: 80px !important; }
.sp-table thead th:nth-child(7) { width: 50px !important; text-align: center !important; }
.sp-table thead th:nth-child(8) { width: 60px !important; text-align: center !important; }
.sp-table thead th:nth-child(9) { width: 50px !important; text-align: center !important; }

.sp-table td:nth-child(4) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-approved { color: var(--success) !important; font-size: 16px !important; }
.sp-unapproved { color: var(--border-light) !important; font-size: 14px !important; }

/* ═══════════════════════════════════════════════════════
   SHOT DETAIL PANEL — 50vw fixed overlay
═══════════════════════════════════════════════════════ */
.sp-right {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  width: 50vw !important;
  min-width: 580px !important;
  max-width: 900px !important;
  height: 100vh !important;
  background: var(--bg-panel) !important;
  border-left: 1px solid var(--border) !important;
  overflow-y: auto !important;
  z-index: 100 !important;
  box-shadow: -8px 0 32px rgba(0,0,0,0.5) !important;
  display: none !important;
  flex-direction: column !important;
  padding: 0 !important;
}
.sp-right.open {
  display: flex !important;
}
/* Narrow table when panel is open */
#smod-sp-content:has(.sp-right.open) .sp-left {
  max-width: 50vw;
  min-width: 0;
}
/* Fallback for browsers without :has() — add class via JS */
.sp-left.panel-open {
  max-width: 50vw;
  min-width: 0;
}

/* ── Panel header: sticky, dark background ── */
.sp-detail-hdr {
  position: sticky !important;
  top: 0 !important;
  z-index: 2 !important;
  background: var(--bg-card) !important;
  border-bottom: 2px solid var(--accent) !important;
  padding: 14px 18px !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-wrap: wrap !important;
}
.sp-detail-title {
  color: var(--accent) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  flex: 1 !important;
}
.sp-detail-close {
  margin-left: auto;
  background: none !important;
  border: none !important;
  color: var(--text-secondary) !important;
  font-size: 20px !important;
  cursor: pointer !important;
  padding: 2px 8px !important;
  border-radius: 4px !important;
  line-height: 1 !important;
  transition: color 0.15s !important;
  flex-shrink: 0 !important;
}
.sp-detail-close:hover { color: var(--text-primary) !important; }
.sp-approve-btn {
  font-size: 12px !important;
  padding: 6px 14px !important;
  border-radius: 5px !important;
  font-weight: 600 !important;
}
.sp-approve-btn.approved {
  background: rgba(39,174,96,0.18) !important;
  color: var(--success) !important;
  border: 1px solid var(--success) !important;
}
.sp-approve-btn.unapproved {
  background: var(--accent-btn) !important;
  color: var(--text-primary) !important;
  border: none !important;
}

/* ── Panel body ── */
.sp-detail-body {
  padding: 0 !important;
  gap: 0 !important;
  display: block !important;
}

/* ── Collapsible sections ── */
.sp-section {
  background: transparent !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin-bottom: 0 !important;
  border-bottom: 1px solid var(--border) !important;
}
.sp-section-title {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 11px 18px !important;
  cursor: pointer !important;
  user-select: none !important;
  background: var(--bg-card) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--text-secondary) !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  transition: background 0.15s !important;
  margin-bottom: 0 !important;
}
.sp-section-title:hover { background: var(--bg-input) !important; color: var(--text-primary) !important; }
.sp-section-title .sp-col-arrow {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s;
  margin-left: 8px;
}
.sp-section.sp-collapsed .sp-col-arrow { transform: rotate(-90deg); }
.sp-section-inner {
  padding: 14px 18px;
  background: var(--bg-main);
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
}
.sp-section.sp-collapsed .sp-section-inner {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden !important;
}

/* ── Inner elements styling ── */
.sp-section-inner .sp-grid { gap: 10px !important; }
.sp-section-inner .sp-field label {
  color: var(--text-secondary) !important;
  font-size: 10px !important;
  margin-bottom: 4px !important;
  display: block;
}
.sp-section-inner .sp-field input,
.sp-section-inner .sp-field select,
.sp-section-inner .sp-field textarea {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  color: var(--text-primary) !important;
  font-size: 12px !important;
  padding: 6px 10px !important;
  width: 100% !important;
  box-sizing: border-box;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.sp-section-inner .sp-field input:focus,
.sp-section-inner .sp-field select:focus,
.sp-section-inner .sp-field textarea:focus { border-color: var(--accent) !important; }

/* Prompt cards inside panel */
.sp-prompt-card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.sp-prompt-card.primary { border-color: var(--accent) !important; }
.sp-prompt-text { color: var(--text-primary) !important; font-size: 12px !important; line-height: 1.55 !important; }

.sp-add-row { gap: 8px !important; margin-top: 10px !important; }
.sp-add-row input,
.sp-add-row textarea {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  color: var(--text-primary) !important;
  font-size: 12px !important;
  padding: 7px 10px !important;
  outline: none;
  transition: border-color 0.15s;
}
.sp-add-row input:focus { border-color: var(--accent) !important; }

.sp-gen-row { gap: 8px !important; margin-top: 10px !important; flex-wrap: wrap !important; }
.sp-gen-row select {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  color: var(--text-primary) !important;
  font-size: 12px !important;
  padding: 6px 10px !important;
  height: auto !important;
}
/* Generate button inside panel */
.sp-gen-row .bmod-btn[onclick*="spGen"],
#sp-right .bmod-btn[onclick*="spGen"],
#sp-right button[id^="sp-img-gen"],
#sp-right button[id^="sp-vid-gen"] {
  background: var(--accent-btn) !important;
  color: var(--text-primary) !important;
  border: none !important;
  padding: 7px 14px !important;
}
#sp-right .bmod-btn {
  border-color: rgba(200,169,110,0.4) !important;
  color: var(--accent) !important;
  background: transparent !important;
}
#sp-right .bmod-btn:hover { background: rgba(200,169,110,0.08) !important; }

/* Gallery thumbnails */
.sp-gallery { gap: 8px !important; margin-bottom: 10px !important; }
.sp-thumb { border: 2px solid transparent; }
.sp-thumb.primary { border-color: var(--accent) !important; }

/* Refs */
.sp-ref-item img {
  width: 80px !important;
  height: 60px !important;
  border: 1px solid var(--border) !important;
  border-radius: 5px;
}

/* Scene label in sp-scene-row */
.sp-scene-row td { color: var(--accent) !important; font-size: 12px !important; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .sp-right { width: 100vw !important; min-width: 0 !important; }
  #smod-sp-content:has(.sp-right.open) .sp-left,
  .sp-left.panel-open { max-width: 0 !important; overflow: hidden !important; }
  .sc-table thead th:nth-child(4),
  .sc-table td:nth-child(4),
  .sc-table thead th:nth-child(5),
  .sc-table td:nth-child(5) { display: none; }
}


/* ═══════════════════════════════════════════════════════
   CHARACTER GRID (fullscreen page)
═══════════════════════════════════════════════════════ */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  padding: 16px;
}
.char-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.char-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.char-card-photo {
  width: 100%;
  height: 170px;
  overflow: hidden;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #555;
}
.char-card-info {
  padding: 8px 10px;
}
.char-card-name {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}
.char-card-slug {
  color: var(--text-secondary);
  font-size: 11px;
  margin-top: 2px;
}
.char-card-create {
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.2s, background 0.2s;
}
.char-card-create:hover {
  border-color: var(--accent);
  background: rgba(200,169,110,0.04);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════
   STUDIO FULLSCREEN PAGE LAYOUT
═══════════════════════════════════════════════════════ */
.studio-fullpage {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.studio-toc {
  width: 200px;
  min-width: 200px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
.studio-toc .tth {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}
.studio-pr {
  flex: 1;
  overflow-y: auto;
}
/* Inside studio fullpage, the .pr class padding should be 0 */
.studio-fullpage .studio-pr > .pr,
.studio-fullpage #pr {
  padding: 0;
  max-width: none;
}

/* ═══════════════════════════════════════════════════════
   GENERATION TWO-COLUMN LAYOUT (380px left + flex right)
═══════════════════════════════════════════════════════ */
.gen-twocol {
  display: flex;
  height: calc(100vh - 120px);
  overflow: hidden;
  margin: 0;
}
.gen-left-panel {
  width: 380px;
  min-width: 380px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
}
.gen-right-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: auto;
  padding: 20px;
}
/* Override .gen-fullpage st inside gen-twocol (hide the title — it's now in the panel) */
.gen-twocol .st { display: none !important; }

/* When gen-fullpage wraps gen-twocol, remove its padding/max-width */
.gen-fullpage:has(.gen-twocol) {
  padding: 0 !important;
  max-width: none !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
/* Fallback for browsers without :has() */
.gen-fullpage.gen-twocol-wrap {
  padding: 0 !important;
  max-width: none !important;
  overflow: hidden !important;
}
/* studio-pr should not have extra padding from .pr class */
.studio-pr {
  padding: 0 !important;
}
/* char-card photo img hover fix */
.char-card:hover .char-card-photo img { transform: scale(1.05); }
.char-card-photo img { width:100%;height:100%;object-fit:cover;transition: transform 0.2s; }

.sc-light { 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ═══════════════════════════════════════════════════════
   GLOBAL DARK INPUTS for studio panels (#pr, .studio-pr)
   Fix white background on all textarea/input/select
═══════════════════════════════════════════════════════ */
#pr input:not([type=radio]):not([type=checkbox]):not([type=file]):not([type=range]),
#pr textarea,
#pr select,
.studio-pr input:not([type=radio]):not([type=checkbox]):not([type=file]):not([type=range]),
.studio-pr textarea,
.studio-pr select {
  background: var(--bg-input, #221E19) !important;
  color: var(--text-primary, #F0EDE8) !important;
  border: 1px solid var(--border, #3A3530) !important;
  border-radius: 6px !important;
}
#pr input:focus, #pr textarea:focus, #pr select:focus,
.studio-pr input:focus, .studio-pr textarea:focus, .studio-pr select:focus {
  border-color: var(--accent, #C8A96E) !important;
  outline: none !important;
}
#pr input::placeholder, #pr textarea::placeholder,
.studio-pr input::placeholder, .studio-pr textarea::placeholder {
  color: var(--text-secondary, #6A6460) !important;
}

/* Fix inline bgcolor=f5f0e8/eef5f0 info boxes in studio panels */
#pr [style*="background:#eef5f0"],
#pr [style*="background:#f5f0e8"],
#pr [style*="background: #eef5f0"],
#pr [style*="background: #f5f0e8"] {
  background: rgba(200,169,110,0.08) !important;
  border: 1px solid rgba(200,169,110,0.2) !important;
  border-radius: 6px !important;
}
#pr [style*="color:#4a7c5b"] { color: var(--accent, #C8A96E) !important; }

/* Fix card backgrounds in studio panels */
#pr [style*="background:#2a2a3e"],
#pr [style*="background: #2a2a3e"] { background: var(--bg-input, #221E19) !important; }

/* Fix inline sep color */
#pr [style*="color:var(--sep)"], #pr [style*="color: var(--sep)"] { color: var(--text-secondary) !important; }
#pr [style*="color:var(--ink)"], #pr [style*="color: var(--ink)"] { color: var(--text-primary) !important; }
#pr [style*="color:var(--ink2)"], #pr [style*="color: var(--ink2)"] { color: var(--text-primary) !important; }

/* Fix inline button colors */
#pr button[style*="background:#4a7c5b"],
#pr button[style*="background: #4a7c5b"] {
  background: var(--accent-btn, #8B6914) !important;
  color: var(--text-primary) !important;
}
#pr button[style*="background:#5b4a7c"],
#pr button[style*="background: #5b4a7c"] {
  background: var(--accent-btn, #8B6914) !important;
  color: var(--text-primary) !important;
}

/* Fix dashed drop zone in studio */
#pr [style*="border:2px dashed #d4c9a8"],
#pr [style*="border: 2px dashed #d4c9a8"],
#pr [style*="border:2px dashed #444"],
#pr [style*="border: 2px dashed #444"] {
  border-color: var(--border, #3A3530) !important;
  background: var(--bg-card, #221E19) !important;
}

/* Larger font in studio panels */
#pr .st { font-size: 14px !important; margin-bottom: 20px !important; }
#pr [style*="font-size:11px;color:var(--sep)"],
#pr [style*="font-size:11px;color: var(--sep)"] { font-size: 12px !important; }

/* ═══════════════════════════════════════════════════════
   CHARACTER / ENVIRONMENT create form — dark tips box
═══════════════════════════════════════════════════════ */
#char-tips {
  background: rgba(200,169,110,0.08) !important;
  border: 1px solid rgba(200,169,110,0.25) !important;
  color: var(--accent) !important;
  border-radius: 8px !important;
  padding: 12px 14px !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
}

/* Create char/env drop zone */
#char-drop, #env-drop {
  border-color: var(--border) !important;
  background: var(--bg-card) !important;
  border-radius: 8px !important;
}

/* Create button styling */
button[onclick*="submitCreateCharacter"],
button[onclick*="submitCreateEnvironment"] {
  background: var(--accent-btn) !important;
  color: var(--text-primary) !important;
  border: none !important;
  font-size: 15px !important;
  padding: 13px !important;
}

/* ═══════════════════════════════════════════════════════
   ENVIRONMENT GRID (same as character grid)
═══════════════════════════════════════════════════════ */
.env-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  padding: 16px;
}
.env-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.env-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.env-card-photo {
  width: 100%;
  height: 170px;
  overflow: hidden;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #555;
}
.env-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.env-card-info { padding: 8px 10px; }
.env-card-name { color: var(--text-primary); font-size: 14px; font-weight: 600; }
.env-card-slug { color: var(--text-secondary); font-size: 11px; margin-top: 2px; }
.env-card-create {
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.2s, background 0.2s;
}
.env-card-create:hover {
  border-color: var(--accent);
  background: rgba(200,169,110,0.04);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════
   VIDEO GENERATION: 3-column layout (wider left)
   Left 480px settings | Center flex result | Right 240px history
═══════════════════════════════════════════════════════ */
.gen-twocol-3col {
  display: flex;
  height: calc(100vh - 120px);
  overflow: hidden;
  margin: 0;
}
.gen-left-480 {
  width: 480px;
  min-width: 480px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
}
.gen-center-result {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: auto;
  padding: 20px;
  min-width: 300px;
}
.gen-right-history {
  width: 240px;
  min-width: 240px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}
.gen-right-history .hist-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE: gen-twocol-3col (image + video generation forms)
   Bug fix: this 3-column layout (480px settings + flexible result +
   240px history) had NO responsive rules at all, so on any viewport
   under ~1050px wide it either overflowed horizontally or squeezed the
   center result column unusably. Collapse right history first, then
   stack everything vertically on narrow/mobile viewports.
═══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .gen-right-history {
    display: none;
  }
}
@media (max-width: 860px) {
  .gen-twocol-3col {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .gen-left-480 {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
  }
  .gen-center-result {
    min-width: 0;
    min-height: 260px;
  }
  .gen-right-history {
    display: none;
  }
}

/* Model dropdown styling */
.model-select-wrap {
  position: relative;
  margin-bottom: 16px;
}
.model-select-wrap select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 10px 36px 10px 14px;
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--text-primary) !important;
  font-size: 14px !important;
  cursor: pointer;
}
.model-select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: 12px;
}
.model-nav-btns {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.model-nav-btn {
  flex: 1;
  padding: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.model-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Side-by-side start+end frames */
.vid-frame-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.vid-frame-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════
   SHOT PLAN PANEL: fix gap
═══════════════════════════════════════════════════════ */
.sp-section-inner {
  max-height: none !important;
  overflow: visible !important;
}
.sp-section.sp-collapsed .sp-section-inner {
  max-height: 0 !important;
  overflow: hidden !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* ═══════════════════════════════════════════════════════
   SCRIPT TABLE: column 2 editable cell alignment
═══════════════════════════════════════════════════════ */
.sc-sh-row td:nth-child(2) .editable-cell:first-child {
  color: var(--text-primary) !important;
}
.sc-sh-row td:nth-child(2) .editable-cell:nth-child(2) {
  color: var(--text-secondary) !important;
}

/* ═══════════════════════════════════════════════════════
   PROJECT PAGE: max-width for large screens
═══════════════════════════════════════════════════════ */
/* Project open pages use #sc with .pp-* classes */
/* Will address after seeing current structure */

/* ═══════════════════════════════════════════════════════
   PROJECT COVER IMAGE UPLOAD BUTTON
═══════════════════════════════════════════════════════ */
.pc-cover-upload-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(200,169,110,0.4);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  display: none;
  transition: background 0.15s;
}
.pc-new:hover .pc-cover-upload-btn {
  display: block;
}
.pc-cover-upload-btn:hover {
  background: rgba(200,169,110,0.2);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════
   SVG ICONS IN SIDEBAR
═══════════════════════════════════════════════════════ */
.sbn-ic svg {
  display: block;
  color: inherit;
  stroke: currentColor;
}
.sbn .sbn-ic svg { color: var(--text-secondary, #6A6460); }
.sbn.active .sbn-ic svg,
.sbn:hover .sbn-ic svg { color: var(--accent, #C8A96E); }
.sbn-disabled .sbn-ic svg { opacity: 0.35; }
