/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: #1f2937; background: #f1f5f9; }

/* ── Layout ── */
body { display: flex; }

.sidebar {
  width: 220px; min-width: 220px; height: 100vh; position: fixed; top: 0; left: 0;
  background: #0f172a; color: #e2e8f0; display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
}
.main {
  margin-left: 220px; flex: 1; min-height: 100vh; padding: 0;
  background: #f1f5f9;
}

/* ── Sidebar ── */
.sidebar-header {
  padding: 20px 16px 16px; border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 10px;
}
.channel-logo {
  width: 36px; height: 36px; border-radius: 8px; background: #ef4444;
  color: white; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.channel-name { font-weight: 700; font-size: 13px; line-height: 1.3; color: #f8fafc; }

.nav-list { list-style: none; padding: 10px 0; flex: 1; }
.nav-list li { margin: 2px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: #94a3b8; text-decoration: none; font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: #1e293b; color: #e2e8f0; }
.nav-link.active { background: #1e293b; color: #fff; font-weight: 600; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-footer { padding: 12px 14px 16px; border-top: 1px solid #1e293b; }
.quota-bar { }
.quota-label { font-size: 11px; color: #64748b; display: block; margin-bottom: 4px; }
.quota-track { height: 4px; background: #1e293b; border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.quota-fill { height: 100%; background: #22c55e; border-radius: 2px; transition: width 0.3s; }
.quota-fill.warn { background: #f59e0b; }
.quota-fill.danger { background: #ef4444; }
.quota-text { font-size: 11px; color: #64748b; }

/* ── Page sections ── */
.section { padding: 28px 32px; max-width: 1400px; }
.section.hidden { display: none !important; }

.page-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: #0f172a; flex: 1; }
.header-actions { display: flex; gap: 8px; }

/* ── Stats bar ── */
.stats-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: white; border-radius: 12px; padding: 18px 20px;
  border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-value { font-size: 26px; font-weight: 800; color: #0f172a; line-height: 1; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Filters ── */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center;
}
.filters-bar select, .filters-bar input {
  padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 7px;
  background: white; font-size: 13px; color: #374151;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
  padding-right: 28px; cursor: pointer;
}
.filters-bar input[type="number"],
.filters-bar input[type="date"] { background-image: none; padding-right: 10px; }

/* ── Tables ── */
.table-wrap { background: white; border-radius: 12px; border: 1px solid #e2e8f0; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  background: #f8fafc; padding: 11px 14px; text-align: left;
  font-weight: 600; color: #64748b; font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table td { padding: 10px 14px; vertical-align: middle; }
.data-table td.loading { text-align: center; color: #94a3b8; padding: 32px; }

.video-title-link { color: #3b82f6; text-decoration: none; font-weight: 500; cursor: pointer; }
.video-title-link:hover { text-decoration: underline; }

/* Inline editable fields in table */
.inline-input {
  border: 1px solid transparent; background: transparent; padding: 3px 6px;
  border-radius: 5px; font-size: 13px; width: 100%;
  transition: border-color .15s, background .15s;
}
.inline-input:hover { border-color: #e2e8f0; background: white; }
.inline-input:focus { border-color: #3b82f6; background: white; outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.inline-select { border: 1px solid transparent; background: transparent; padding: 3px 6px; border-radius: 5px; font-size: 13px; cursor: pointer; }
.inline-select:focus { border-color: #3b82f6; outline: none; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-dark-green  { background: #dcfce7; color: #15803d; }
.badge-green       { background: #d1fae5; color: #059669; }
.badge-amber       { background: #fef3c7; color: #d97706; }
.badge-gray        { background: #f3f4f6; color: #6b7280; }
.badge-red         { background: #fee2e2; color: #dc2626; }
.badge-blue        { background: #dbeafe; color: #1d4ed8; }
.badge-purple      { background: #ede9fe; color: #7c3aed; }
.badge-orange      { background: #ffedd5; color: #ea580c; }
.badge-cyan        { background: #cffafe; color: #0891b2; }

/* Status colors */
.status-Publicado  { background: #dcfce7; color: #15803d; }
.status-Script     { background: #dbeafe; color: #1d4ed8; }
.status-Research   { background: #fef3c7; color: #d97706; }
.status-Idea       { background: #f3f4f6; color: #6b7280; }
.status-Análisis   { background: #ede9fe; color: #7c3aed; }
.status-Voiceover  { background: #ffedd5; color: #ea580c; }
.status-Edición    { background: #cffafe; color: #0891b2; }

.alert-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fef2f2; border: 1px solid #fecaca; color: #dc2626;
  padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 13.5px; font-weight: 500; transition: all .15s; white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-outline { background: white; color: #374151; border: 1px solid #e2e8f0; }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #15803d; }
.btn-success:hover { background: #bbf7d0; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 5px 8px; background: transparent; color: #94a3b8; border: none; cursor: pointer; border-radius: 5px; font-size: 14px; }
.btn-icon:hover { background: #f1f5f9; color: #374151; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: white; border-radius: 12px; border: 1px solid #e2e8f0;
  padding: 20px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: #0f172a; }

/* ── Category summary ── */
.category-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
  margin-top: 12px;
}
.category-card {
  background: white; border-radius: 10px; border: 1px solid #e2e8f0;
  padding: 14px 16px;
}
.category-card .cat-name { font-weight: 700; font-size: 14px; color: #0f172a; }
.category-card .cat-stats { font-size: 12px; color: #64748b; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.category-card .cat-rec { margin-top: 8px; font-size: 12.5px; font-weight: 600; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab {
  padding: 8px 18px; border: none; background: transparent; color: #64748b;
  font-size: 13.5px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; border-radius: 6px 6px 0 0; transition: all .15s;
}
.tab:hover { color: #1f2937; background: #f8fafc; }
.tab.active { color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 600; }
.tab-content { animation: fadeIn .2s; }
.tab-content.hidden { display: none !important; }

/* ── Video Detail ── */
.vd-metrics-grid {
  display: grid; grid-template-columns: 1fr 2fr; gap: 20px;
}
.vd-thumbnail img { width: 100%; border-radius: 8px; }
.vd-thumbnail-placeholder {
  width: 100%; aspect-ratio: 16/9; background: #f1f5f9; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 13px;
}
.metric-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.metric-row:last-child { border-bottom: none; }
.metric-label { color: #64748b; font-size: 13px; }
.metric-value { font-weight: 600; font-size: 13px; color: #0f172a; }
.edit-field { width: 100%; padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 7px; font-size: 13px; }
.edit-field:focus { border-color: #3b82f6; outline: none; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }

.comments-list { display: flex; flex-direction: column; gap: 10px; }
.comment-card {
  background: white; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px;
}
.comment-card.hook-candidate { border-left: 3px solid #f59e0b; }
.comment-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.comment-user { font-weight: 600; font-size: 13px; color: #1d4ed8; }
.comment-meta { font-size: 11.5px; color: #94a3b8; white-space: nowrap; }
.comment-text { font-size: 13.5px; line-height: 1.5; color: #374151; }
.comment-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag-btn { padding: 2px 8px; border-radius: 5px; font-size: 11.5px; cursor: pointer; border: 1px solid #e2e8f0; background: white; }
.tag-btn.active-hook       { background: #fef3c7; border-color: #f59e0b; color: #d97706; }
.tag-btn.active-objection  { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.tag-btn.active-question   { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.tag-btn.active-praise     { background: #dcfce7; border-color: #86efac; color: #15803d; }
.tag-btn.active-attack     { background: #fce7f3; border-color: #f9a8d4; color: #be185d; }

.transcript-wrap { max-height: 500px; overflow-y: auto; font-size: 13px; line-height: 1.8; }
.transcript-segment { display: flex; gap: 12px; padding: 4px 0; }
.transcript-segment.hook-zone { background: #fefce8; border-radius: 4px; padding: 4px 6px; }
.ts-time { color: #94a3b8; font-size: 12px; min-width: 60px; padding-top: 1px; }
.ts-text { color: #374151; }

.keywords-check { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.kw-chip { padding: 3px 10px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.kw-chip.found { background: #dcfce7; color: #15803d; }
.kw-chip.not-found { background: #f3f4f6; color: #9ca3af; }

/* AI analysis display */
.ai-result { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px 18px; margin-top: 12px; }
.ai-section { margin-bottom: 14px; }
.ai-section h4 { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #64748b; margin-bottom: 8px; }
.ai-section ul { padding-left: 18px; }
.ai-section li { margin-bottom: 4px; font-size: 13.5px; color: #374151; }
.sentiment-score { font-size: 36px; font-weight: 900; color: #3b82f6; }

/* ── Kanban ── */
.kanban-board {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px;
  align-items: flex-start; min-height: calc(100vh - 120px);
}
.kanban-column {
  min-width: 220px; width: 220px; flex-shrink: 0;
  background: #f8fafc; border-radius: 10px; border: 1px solid #e2e8f0;
  display: flex; flex-direction: column; max-height: calc(100vh - 140px);
}
.kanban-column.drag-over { border-color: #3b82f6; background: #eff6ff; }
.column-header {
  padding: 12px 14px; font-weight: 700; font-size: 13px; color: #374151;
  border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: inherit; border-radius: 10px 10px 0 0;
}
.column-count { background: #e2e8f0; color: #64748b; border-radius: 9px; padding: 1px 7px; font-size: 11.5px; }
.cards-container {
  padding: 10px 10px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; flex: 1;
}
.kanban-card {
  background: white; border-radius: 8px; border: 1px solid #e2e8f0;
  padding: 11px 12px; cursor: grab; transition: box-shadow .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.kanban-card.dragging { opacity: .5; cursor: grabbing; }
.card-title { font-weight: 600; font-size: 12.5px; color: #0f172a; margin-bottom: 6px; line-height: 1.4; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.priority-badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.priority-Alta  { background: #fee2e2; color: #dc2626; }
.priority-Media { background: #fef3c7; color: #d97706; }
.priority-Baja  { background: #dcfce7; color: #15803d; }
.score-badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; background: #eff6ff; color: #3b82f6; }
.card-indicators { display: flex; gap: 4px; margin-top: 4px; }
.indicator { font-size: 11px; color: #64748b; }

/* ── Formula ── */
.formula-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .formula-grid { grid-template-columns: 1fr; } }
.kw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kw-table th { background: #f8fafc; padding: 8px 10px; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: #64748b; border-bottom: 1px solid #e2e8f0; }
.kw-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; }
.kw-table tr:last-child td { border-bottom: none; }
.mult-bar { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.mult-bar-fill { height: 100%; background: #3b82f6; border-radius: 3px; }

/* ── Settings ── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-section { background: white; border-radius: 12px; border: 1px solid #e2e8f0; padding: 20px 22px; }
.settings-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; color: #0f172a; padding-bottom: 10px; border-bottom: 1px solid #f1f5f9; }
.input-row { margin-bottom: 12px; }
.input-row label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.input-row input, .input-row select {
  width: 100%; padding: 8px 11px; border: 1px solid #e2e8f0; border-radius: 7px;
  font-size: 13px; color: #374151; transition: border-color .15s;
}
.input-row input:focus, .input-row select:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.key-set { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #15803d; font-weight: 600; padding: 3px 8px; background: #dcfce7; border-radius: 5px; }

/* Setup wizard */
.wizard-wrap { max-width: 640px; margin: 0 auto; }
.wizard-step {
  display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid #f1f5f9; align-items: flex-start;
}
.wizard-step:last-child { border-bottom: none; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: #3b82f6; color: white; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-content h4 { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.step-content p { font-size: 13px; color: #64748b; line-height: 1.5; }
.step-content code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-family: monospace; font-size: 12.5px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none !important; }
.modal {
  background: white; border-radius: 14px; padding: 24px 26px; width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 18px; color: #0f172a; }
.modal-close {
  position: absolute; top: 14px; right: 16px; border: none; background: none;
  font-size: 22px; color: #94a3b8; cursor: pointer; line-height: 1; padding: 2px 6px;
  border-radius: 5px;
}
.modal-close:hover { background: #f1f5f9; color: #374151; }

/* ── Forms in modal ── */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 8px 11px; border: 1px solid #e2e8f0; border-radius: 7px;
  font-size: 13px; color: #374151; font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: #3b82f6; outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row-inline { display: flex; gap: 10px; }
.form-row-inline .form-row { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #f1f5f9; }

/* Score preview */
.score-preview {
  padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 700;
  display: inline-block; margin-top: 6px;
}
.score-strong { background: #fef3c7; color: #d97706; }
.score-good   { background: #dcfce7; color: #15803d; }
.score-weak   { background: #ffedd5; color: #ea580c; }
.score-skip   { background: #fee2e2; color: #dc2626; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); animation: slideUp .25s;
  max-width: 360px;
}
.toast.hidden { display: none !important; }
.toast-success { background: #0f172a; color: white; }
.toast-error   { background: #dc2626; color: white; }
.toast-info    { background: #3b82f6; color: white; }

/* ── Alert badges ── */
.alert-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ── Loading spinner ── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #e2e8f0; border-top-color: #3b82f6; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Star rating */
.stars { display: inline-flex; gap: 2px; cursor: pointer; }
.star { font-size: 15px; color: #e2e8f0; transition: color .1s; }
.star.filled { color: #f59e0b; }

/* Misc */
.text-muted { color: #94a3b8; font-size: 12px; }
.divider { border: none; border-top: 1px solid #f1f5f9; margin: 16px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: #94a3b8; }
.empty-state p { margin-top: 8px; font-size: 13px; }

.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input {
  flex: 1; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px;
}
.search-bar input:focus { border-color: #3b82f6; outline: none; }

.ai-loading { display: flex; align-items: center; gap: 8px; color: #64748b; padding: 20px 0; font-size: 13px; }

/* ── Script Generator ── */
.sg-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .sg-layout { grid-template-columns: 1fr; }
}
.sg-form-col, .sg-output-col { min-width: 0; }

/* Progress steps */
.sg-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  transition: opacity .3s;
}
.sg-step:last-child { border-bottom: none; }
.sg-step-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.sg-step-label { font-size: 13px; font-weight: 600; color: #374151; }
.sg-step-sub   { font-size: 12px; color: #64748b; margin-top: 2px; }

/* ── Script Reviewer ── */
.sr-analyze-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .sr-analyze-layout { grid-template-columns: 1fr; }
}
.sr-materials-layout { display: flex; flex-direction: column; gap: 20px; }

.sr-material-item {
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fff;
  transition: opacity .2s;
}
.sr-material-item.disabled { opacity: .55; background: #f8fafc; }
.sr-material-item:hover { border-color: #cbd5e1; }

/* Chat messages */
.sr-msg {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 90%;
}
.sr-msg-user    { background: #eff6ff; color: #1e3a8a; align-self: flex-end; border: 1px solid #dbeafe; }
.sr-msg-bot     { background: #f8fafc; color: #1e293b; align-self: flex-start; border: 1px solid #e2e8f0; }
.sr-msg-loading { background: #fef3c7; color: #92400e; align-self: flex-start; font-style: italic; }
.sr-msg-error   { background: #fef2f2; color: #991b1b; align-self: flex-start; border: 1px solid #fecaca; }

/* ── Thumbnail Generator ── */
.th-generate-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1100px) {
  .th-generate-layout { grid-template-columns: 1fr; }
}
.th-sg-layout { display: flex; flex-direction: column; gap: 18px; }

.th-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.th-img-card {
  position: relative;
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 2px solid transparent;
  transition: border-color .2s, transform .15s;
}
.th-img-card:hover { transform: translateY(-2px); }
.th-img-card.winner { border-color: #f59e0b; box-shadow: 0 4px 14px rgba(245,158,11,.3); }
.th-img-card img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.th-img-style-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.7); color: #fff;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  padding: 3px 8px; border-radius: 12px;
  letter-spacing: .5px; z-index: 2;
  backdrop-filter: blur(4px);
}
.th-winner-star {
  position: absolute; top: 8px; right: 8px;
  font-size: 18px; z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
.th-img-actions {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; gap: 4px; justify-content: center;
  background: linear-gradient(to top, rgba(0,0,0,.85), transparent);
  padding: 18px 8px 8px;
  opacity: 0; transition: opacity .15s;
  z-index: 2;
}
.th-img-card:hover .th-img-actions { opacity: 1; }
/* Compare mode */
.th-img-card.compare-selected { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.4); transform: translateY(-2px); }
.th-compare-checkbox {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid rgba(255,255,255,.7);
  background: rgba(0,0,0,.5); color: #fff;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
  backdrop-filter: blur(4px);
}
.th-compare-checkbox.checked { background: #3b82f6; border-color: #3b82f6; }

/* ═══════════════════════════════════════════════════════════
   CHANNEL SWITCHER (sidebar)
   ═══════════════════════════════════════════════════════════ */
.channel-switcher {
  position: relative;
  padding: 14px 12px 10px;
  border-bottom: 1px solid #1e293b;
}
.channel-switcher-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  color: #f8fafc;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.channel-switcher-btn:hover {
  background: #1f2e47;
  border-color: #475569;
}
.channel-switcher-info {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.channel-switcher-info .channel-name {
  font-weight: 700;
  font-size: 13px;
  color: #f8fafc;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-switcher-tier {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.channel-switcher-caret {
  margin-left: auto;
  font-size: 9px;
  opacity: .7;
}
.channel-tier-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: .5px;
}
.channel-tier-badge.tier-pro {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}
.channel-tier-badge.tier-basic {
  background: #334155;
  color: #cbd5e1;
}

/* Dropdown */
.channel-switcher-dropdown {
  position: absolute;
  top: calc(100% - 4px);
  left: 12px;
  right: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 150;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}
.channel-switcher-dropdown.hidden { display: none; }

.channel-switch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #273449;
  transition: background .1s;
}
.channel-switch-item:hover { background: #253449; }
.channel-switch-item:last-child { border-bottom: none; }
.channel-switch-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.channel-switch-info { flex: 1; min-width: 0; }
.channel-switch-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-switch-tier {
  font-size: 9.5px;
  margin-top: 2px;
  font-weight: 700;
  letter-spacing: .5px;
}
.channel-switch-tier.pro   { color: #fbbf24; }
.channel-switch-tier.basic { color: #94a3b8; }

.channel-switcher-actions {
  padding: 8px 12px;
  border-top: 1px solid #273449;
  background: #172032;
}
.channel-switcher-manage {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  text-decoration: none;
  padding: 4px 0;
}
.channel-switcher-manage:hover { color: #e2e8f0; }

/* The logo inside the switcher button */
.channel-switcher-btn .channel-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   CHANNELS MANAGEMENT (section-channels)
   ═══════════════════════════════════════════════════════════ */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.channel-card {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.channel-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.channel-card.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.channel-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}
.channel-card-logo {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: white;
  flex-shrink: 0;
}
.channel-card-name {
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.channel-card-meta {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.channel-active-badge {
  font-size: 10.5px;
  color: #15803d;
  background: #dcfce7;
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.channel-card-desc {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 12px;
}
.channel-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.channel-stat {
  font-size: 11px;
  color: #475569;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 6px;
}
.channel-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.th-img-actions button {
  background: rgba(255,255,255,.95); border: none;
  width: 30px; height: 30px; border-radius: 6px;
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.th-img-actions button:hover { transform: scale(1.1); background: #fff; }
.th-img-failed {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 16px; text-align: center;
  background: #fef2f2;
}

.th-style-item, .th-block-item, .th-learning-item {
  display: flex; gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
  align-items: flex-start;
}
.th-style-item.disabled, .th-block-item.disabled, .th-learning-item.disabled {
  opacity: .55; background: #f8fafc;
}
.th-style-item:hover, .th-block-item:hover, .th-learning-item:hover {
  border-color: #cbd5e1;
}

/* Chat refinement messages */
.th-chat-msg {
  padding: 8px 11px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.55; max-width: 92%;
}
.th-chat-user    { background: #eff6ff; color: #1e3a8a; align-self: flex-end; }
.th-chat-bot     { background: #fff; color: #1e293b; border: 1px solid #e2e8f0; align-self: flex-start; }
.th-chat-loading { background: #fef3c7; color: #92400e; font-style: italic; }
.th-chat-error   { background: #fef2f2; color: #991b1b; }
.th-chat-action  { background: #f0fdf4; color: #166534; border: 1px dashed #86efac; }

/* Credit exhausted banner */
.th-credit-banner {
  background: #fef2f2;
  border: 2px solid #fca5a5;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
  animation: slideUp .3s;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.15);
}
