:root {
  --bg: #0f1117;
  --bg2: #181c27;
  --bg3: #1e2435;
  --border: #2a3045;
  --border2: #374162;
  --text: #e8eaf0;
  --text2: #9aa3be;
  --text3: #5c6480;
  --accent: #4f7cff;
  --accent2: #3a5fd4;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a78bfa;
  --teal: #2dd4bf;
  --sidebar-w: 260px;
  --panel-w: 640px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Layout ── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-toggle:hover { color: var(--text); background: var(--bg3); }

.stats-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stat-chip {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 6px;
  text-align: center;
}

.stat-chip span {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-chip small {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-group label {
  display: block;
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  font-weight: 600;
}

.filter-input,
.filter-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font);
}

.filter-input:focus,
.filter-select:focus {
  border-color: var(--accent);
}

.filter-select option { background: var(--bg2); }

.filter-select.sm { width: auto; min-width: 60px; }

.btn-clear {
  margin: 12px 16px;
  width: calc(100% - 32px);
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text2);
  padding: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-clear:hover { border-color: var(--red); color: var(--red); }

/* ── Main ── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
  gap: 12px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-count {
  font-size: 13px;
  color: var(--text2);
}

.per-page-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}

.view-toggle { display: flex; gap: 4px; }

.view-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.view-btn.active,
.view-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s;
}

.icon-btn:hover { color: var(--text); background: var(--bg3); }

/* ── Grid ── */
.grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  align-content: start;
}

.grid.list-view {
  grid-template-columns: 1fr;
}

.empty, .loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 15px;
  padding: 40px;
}

/* ── Combo Card ── */
.combo-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.combo-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.combo-card.has-work {
  border-left: 3px solid var(--amber);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-topic {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.card-format-badge {
  flex-shrink: 0;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-format-badge.longform { background: rgba(79,124,255,0.15); color: var(--accent); }
.card-format-badge.shortform { background: rgba(34,197,94,0.15); color: var(--green); }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.chip-function { background: rgba(167,139,250,0.12); color: var(--purple); border-color: rgba(167,139,250,0.2); }
.chip-lens { background: rgba(45,212,191,0.1); color: var(--teal); border-color: rgba(45,212,191,0.2); }
.chip-category { background: rgba(245,158,11,0.1); color: var(--amber); border-color: rgba(245,158,11,0.2); }

.card-ideas {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-idea-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg3);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text2);
  transition: background 0.1s;
}

.card-idea-row:hover { background: var(--border); color: var(--text); }

.idea-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text3);
}

.idea-status-dot.used { background: var(--green); }
.idea-status-dot.in_progress { background: var(--amber); }

.card-idea-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* List view overrides */
.list-view .combo-card {
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  gap: 14px;
}

.list-view .card-top { flex: 0 0 300px; }
.list-view .card-meta { flex: 0 0 auto; }
.list-view .card-ideas { flex: 1; flex-direction: row; flex-wrap: wrap; }
.list-view .card-idea-row { flex: 0 0 auto; max-width: 240px; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.page-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 34px;
  text-align: center;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-ellipsis { color: var(--text3); padding: 0 4px; }

/* ── Detail Panel ── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
  display: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.panel-overlay.visible { display: block; opacity: 1; }

.detail-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  width: auto;
  max-width: none;
  height: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}

.detail-panel.open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-breadcrumb {
  font-size: 12px;
  color: var(--text2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Panel sections */
.panel-combo-header {
  margin-bottom: 20px;
}

.panel-topic {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 10px;
}

.panel-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.fit-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 16px;
}

.fit-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 4px;
}

/* Ideas tabs */
.ideas-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.ideas-tabs::-webkit-scrollbar { display: none; }

.idea-tab {
  padding: 8px 14px;
  font-size: 12px;
  border: none;
  background: none;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.idea-tab:hover { color: var(--text); }

.idea-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.idea-tab .tab-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--text3);
  vertical-align: middle;
}

.idea-tab.tab-used .tab-dot { background: var(--green); }
.idea-tab.tab-in_progress .tab-dot { background: var(--amber); }

/* Idea detail */
.idea-detail { display: flex; flex-direction: column; gap: 16px; }

.idea-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.alt-titles {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.alt-title-item {
  font-size: 12px;
  color: var(--text3);
  padding: 3px 0;
  padding-left: 10px;
  border-left: 2px solid var(--border2);
}

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  font-weight: 700;
  margin-bottom: 5px;
}

.hook-text {
  font-size: 14px;
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
  line-height: 1.5;
}

.thesis-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.core-points {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.core-point {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
}

.core-point::before {
  content: "→";
  color: var(--accent);
  flex-shrink: 0;
}

.thumbnail-preview {
  background: linear-gradient(135deg, #1a1f3a, #0f1422);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: white;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
  letter-spacing: 0.02em;
  line-height: 1.3;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.generated-thumbnail {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

.thumb-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.thumb-gallery-empty {
  color: var(--text-dim);
  font-size: 12px;
  padding: 12px 0;
}
.thumb-item {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg3);
}
.thumb-item.selected {
  border-color: var(--accent, #4f9cf9);
  box-shadow: 0 0 0 2px rgba(79, 156, 249, 0.3);
}
.thumb-item img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.thumb-item-overlay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.4);
  font-size: 11px;
}
.thumb-select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #fff;
}
.thumb-delete {
  background: transparent;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.7;
}
.thumb-delete:hover { opacity: 1; color: #f66; }

/* Production section */
.production-section {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.prod-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.prod-section-header:hover { background: var(--bg2); }

.prod-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.prod-section-chevron {
  font-size: 10px;
  color: var(--text3);
  transition: transform 0.2s;
}

.prod-section-chevron.open { transform: rotate(180deg); }

.prod-section-body {
  padding: 12px 14px;
  display: none;
}

.prod-section-body.open { display: block; }

.status-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.status-select-row label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.status-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.status-select:focus { border-color: var(--accent); }

.editable-area {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font);
  resize: vertical;
  min-height: 80px;
  outline: none;
  line-height: 1.6;
  transition: border-color 0.15s;
}

.editable-area:focus { border-color: var(--accent); }

.editable-area.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

.ctx-input {
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 4px;
}
.ctx-input:focus { opacity: 1; }
.ctx-input::placeholder { font-style: italic; }

.section-hint {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
  line-height: 1.4;
}

.audio-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.audio-file-input {
  flex: 1;
  font-size: 12px;
  color: var(--text2);
}
.audio-file-info {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 6px;
}

.gen-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn-gen {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(79,124,255,0.12);
  border: 1px solid rgba(79,124,255,0.3);
  border-radius: 6px;
  color: var(--accent);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-gen:hover { background: rgba(79,124,255,0.22); border-color: var(--accent); }
.btn-gen:disabled { opacity: 0.4; cursor: default; }
.btn-gen.loading { opacity: 0.6; cursor: default; }

.btn-save {
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 6px;
  color: var(--green);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-save:hover { background: rgba(34,197,94,0.22); }

.btn-copy {
  background: rgba(148,163,184,0.10);
  border: 1px solid rgba(148,163,184,0.3);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-copy:hover { background: rgba(148,163,184,0.22); }

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { border-color: var(--border2); color: var(--text); }

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 380px;
  max-width: 90vw;
}

.modal-box h3 { font-size: 16px; margin-bottom: 8px; }
.modal-box p { font-size: 13px; color: var(--text2); margin-bottom: 14px; }

#baseImageInput {
  display: block;
  margin-bottom: 10px;
  color: var(--text2);
  font-size: 13px;
}

#baseImagePreview img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  display: block;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ── Template system ── */
.modal-box--wide { width: 560px; max-height: 85vh; overflow-y: auto; }
.modal-section-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }

.template-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px;
}

.tpl-picker-item {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16/9;
  background: var(--bg3);
  transition: border-color 0.15s;
}
.tpl-picker-item:hover { border-color: var(--text3); }
.tpl-picker-item.selected { border-color: var(--accent); }
.tpl-picker-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-picker-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 10px;
  padding: 3px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl-picker-none {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  color: var(--text3);
}
.tpl-picker-empty { font-size: 12px; color: var(--text3); padding: 8px 0; }

.thumb-suggest-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.tpl-upload-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.tpl-upload-label { white-space: nowrap; }

.tpl-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.tpl-manager-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg3);
}
.tpl-manager-item img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.tpl-manager-name {
  font-size: 11px;
  padding: 5px 6px 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text2);
}
.tpl-manager-delete {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.7;
}
.tpl-manager-delete:hover { opacity: 1; color: #f66; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Standalone pages (detail, thumbnail, templates) ── */
.page-layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

/* ── Detail page: Idea tabs bar ── */
.di-idea-tabs-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
.di-idea-tabs-bar::-webkit-scrollbar { display: none; }

.di-idea-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg2);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.di-idea-tab:hover { border-color: var(--border2); color: var(--text); }
.di-idea-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.di-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
}
.di-dot.used { background: var(--green); }
.di-dot.in_progress { background: var(--amber); }

/* ── Topic title ── */
.di-topic-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ── Brief card ── */
.di-brief-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px 24px;
  margin-bottom: 14px;
}

.di-brief-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.di-brief-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.di-fit-badge {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  white-space: nowrap;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 10px;
  padding: 2px 9px;
  flex-shrink: 0;
}

.di-video-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.di-video-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  flex: 1;
  margin: 0;
}

.di-copy-btn { flex-shrink: 0; }

.di-alt-titles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 16px;
}

.di-alt-title {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
}

.di-brief-fields {
  display: flex;
  flex-direction: column;
  gap: 13px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.di-brief-field {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: baseline;
}

.di-brief-field--top { align-items: start; }

.di-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  padding-top: 2px;
  flex-shrink: 0;
}

.di-hook-text {
  font-size: 14px;
  color: var(--accent);
  font-style: italic;
  line-height: 1.55;
  font-weight: 500;
}

.di-thesis-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.65;
}

.di-points-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.di-point-chip {
  font-size: 12px;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 9px;
  line-height: 1.4;
}

.di-thumb-text-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ── Meta card ── */
.di-meta-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.di-meta-row {
  display: grid;
  grid-template-columns: 150px 1fr 1fr;
  gap: 16px;
  align-items: end;
}

.di-meta-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.di-meta-notes-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.di-inline-field {
  display: flex;
  gap: 6px;
  align-items: center;
}

.di-field-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.di-field-input:focus { border-color: var(--accent); }

.di-notes-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.di-notes-input:focus { border-color: var(--accent); }

/* ── Production workspace ── */
.di-workspace {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.di-workspace-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  padding: 0 4px;
}
.di-workspace-tabs::-webkit-scrollbar { display: none; }

.di-tab {
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  position: relative;
}
.di-tab:hover { color: var(--text); }
.di-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
  background: var(--bg2);
}
.di-tab.done::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0.8;
}

.di-workspace-body {
  padding: 24px;
  min-height: 300px;
}

.di-tab-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.di-thumb-banner {
  background: linear-gradient(135deg, #1a1f3a, #0f1422);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
  letter-spacing: 0.02em;
  line-height: 1.3;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.di-alter-block {
  margin-top: 8px;
  padding: 12px 14px;
  background: rgba(148,163,184,0.05);
  border: 1px dashed rgba(148,163,184,0.2);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.di-alter-label {
  font-size: 11px;
  color: var(--text3);
}

.di-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.yt-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.yt-title-row:hover { border-color: var(--border2); }
.yt-title-text { flex: 1; font-size: 14px; color: var(--text); line-height: 1.4; }
.btn-copy-title {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border2);
  border-radius: 4px;
  color: var(--text2);
  padding: 3px 7px;
  font-size: 13px;
  cursor: pointer;
}
.btn-copy-title:hover { background: var(--bg2); color: var(--text); }

@media (max-width: 640px) {
  .di-meta-row { grid-template-columns: 1fr; }
  .di-brief-field { grid-template-columns: 60px 1fr; gap: 8px; }
  .di-two-col { grid-template-columns: 1fr; }
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-breadcrumb {
  font-size: 13px;
  color: var(--text2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.btn-secondary, a.btn-gen {
  display: inline-block;
  text-decoration: none;
}

.btn-secondary.sm {
  font-size: 12px;
  padding: 5px 10px;
}

/* Thumbnail page two-column grid */
.thumb-page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.thumb-result-placeholder {
  font-size: 13px;
  color: var(--text3);
  padding: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .thumb-page-grid { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .detail-panel { top: 0; left: 0; right: 0; bottom: 0; border-radius: 0; }
}
