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

[hidden] { display: none !important; }

:root {
  --bg: #0f1115;
  --bg-2: #171a21;
  --bg-3: #1f232d;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #9aa1b0;
  --primary: #e53935;
  --primary-hover: #f4433f;
  --success: #2e9e5b;
  --warn: #d9a013;
  --danger: #d64545;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
.sidebar-header h1 { font-size: 17px; }
.lang-switch { display: flex; gap: 4px; margin-top: 10px; }
.lang-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { border-color: var(--primary); color: var(--text); background: rgba(229,57,53,0.1); }
.project-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.project-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s;
}
.project-item:hover { background: var(--bg-3); }
.project-item.active { background: var(--bg-3); border-color: var(--primary); }
.project-item .p-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .p-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ---------- Main ---------- */
.main { flex: 1; overflow-y: auto; padding: 24px 32px; position: relative; }
.empty-state { text-align: center; margin-top: 20vh; color: var(--text-dim); }
.empty-state h2 { margin-bottom: 8px; color: var(--text); }

.project-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.project-title {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text);
  border-bottom: 1px solid transparent;
  padding: 4px 0;
}
.project-title:focus { outline: none; border-bottom-color: var(--primary); }

/* ---------- Steps ---------- */
.step {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.step h2 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
}
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }

input, textarea, select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
select { max-width: 420px; }
#voiceSelect { flex: 1; }
#searchInput { flex: 1; }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
.input-sm { width: 70px; }

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
  background: var(--bg-3);
  color: var(--text);
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger-ghost { background: transparent; border: 1px solid var(--border); color: var(--danger); }
.btn-block { width: 100%; }

/* ---------- Video grid ---------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.video-card {
  background: var(--bg-3);
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.video-card:hover { border-color: var(--border); }
.video-card.selected { border-color: var(--primary); }
.video-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.video-card .v-body { padding: 10px; }
.video-card .v-title { font-size: 13px; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-card .v-meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

/* ---------- Transcripts ---------- */
.transcript-item {
  background: var(--bg-3);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.transcript-item summary {
  padding: 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.transcript-item .t-text {
  padding: 0 12px 12px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.badge-ok { background: rgba(46,158,91,0.2); color: #5fd68f; }
.badge-fail { background: rgba(214,69,69,0.2); color: #ef8080; }

/* ---------- Results ---------- */
.result-box {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.result-box h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-dim); }
.md-content { line-height: 1.7; font-size: 14px; white-space: pre-wrap; }

.change-item {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.change-item .c-original { color: #ef8080; text-decoration: line-through; }
.change-item .c-corrected { color: #5fd68f; }
.change-item .c-reason { color: var(--text-dim); margin-top: 4px; font-size: 12px; }

.finding-item {
  border-left: 4px solid var(--warn);
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.finding-item.sev-yuqori { border-left-color: var(--danger); }
.finding-item.sev-past { border-left-color: var(--success); }
.finding-item .f-quote { font-style: italic; color: var(--text-dim); margin-bottom: 6px; }
.finding-item .f-suggestion { color: #5fd68f; margin-top: 6px; }

.verdict {
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 500;
}
.verdict-toza { background: rgba(46,158,91,0.15); color: #5fd68f; }
.verdict-ogohlantirish { background: rgba(217,160,19,0.15); color: #e8c35a; }
.verdict-jiddiy_muammo { background: rgba(214,69,69,0.15); color: #ef8080; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(700px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
}
.modal-content h2 { margin-bottom: 8px; }
.hint { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }

/* ---------- Toast / loading ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  z-index: 200;
  max-width: 400px;
}
.toast.error { border-color: var(--danger); }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Rasm tanlash ---------- */
.scene-card {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.scene-card .s-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.scene-card .s-query { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.photo-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
}
.photo-item img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.photo-item:hover { border-color: var(--border); }
.photo-item.picked { border-color: var(--success); }
.photo-item.picked::after {
  content: "✓";
  position: absolute;
  top: 4px; right: 6px;
  background: var(--success);
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.photo-item .p-credit {
  position: absolute;
  inset: auto 0 0 0;
  font-size: 10px;
  color: #ddd;
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-item .p-zoom {
  position: absolute;
  top: 4px; left: 4px;
  background: rgba(0,0,0,0.55);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: zoom-in;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-item:hover .p-zoom { opacity: 1; }

/* ---------- Kanal ustaxonasi ---------- */
.channel-chip {
  padding: 8px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.channel-chip:hover { border-color: var(--text-dim); }
.channel-chip.active { border-color: var(--primary); }
.channel-chip .c-del { color: var(--danger); cursor: pointer; font-size: 12px; }
.channel-section { margin-top: 16px; }
.channel-section h3 { font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
.pillar-item {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 13px;
}
.pillar-item b { display: block; margin-bottom: 2px; }
.audience-box {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
}

/* ---------- Hikoya ustaxonasi ---------- */
.mode-switch { display: flex; gap: 8px; margin-bottom: 18px; }
.mode-btn {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { border-color: var(--primary); color: var(--text); background: rgba(229,57,53,0.08); }

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.variant-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.variant-card .v-dir { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 4px; }
.variant-card .v-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.variant-card .v-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-bottom: 10px;
  flex: 1;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 900px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-col {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare-col.enriched { border-color: rgba(46,158,91,0.5); }
.compare-head {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.compare-col.enriched .compare-head { color: #5fd68f; }
.compare-text {
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 380px;
  overflow-y: auto;
}

/* ---------- Sahna promptlari ---------- */
.scene-prompt-item {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 6px 0;
}
.scene-prompt-item .sp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.scene-prompt-item .sp-prompt {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
}

/* ---------- Outlier jadval va g'oya kartalari ---------- */
.outlier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
.outlier-table th, .outlier-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.outlier-table th { color: var(--text-dim); font-weight: 500; font-size: 12px; }
.outlier-table a { color: var(--text); text-decoration: none; }
.outlier-table a:hover { text-decoration: underline; }
.score-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.score-high { background: rgba(229,57,53,0.2); color: #ff8a80; }
.score-mid { background: rgba(217,160,19,0.2); color: #e8c35a; }
.score-low { background: var(--bg-3); color: var(--text-dim); }
.idea-card {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 14px;
  margin: 8px 0;
}
.idea-card .i-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.idea-card .i-combining { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.idea-card .i-why { font-size: 13px; margin-bottom: 10px; line-height: 1.5; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- SEO ---------- */
.seo-h { font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
.btn-copy {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.btn-copy:hover { color: var(--text); }
.title-option {
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.title-option:hover { border-color: var(--text-dim); }
.title-option.selected { border-color: var(--primary); background: rgba(229,57,53,0.08); }
.title-option .t-len { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

/* Thumbnail rasm tanlash */
#thumbImagePick .photo-item.picked { border-color: var(--primary); }
#thumbImagePick .photo-item.picked::after { background: var(--primary); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: zoom-out;
}
.lightbox img, .lightbox video {
  max-width: 94vw;
  max-height: 94vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

/* ---------- Montaj: rasm to'plami ---------- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.image-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.image-card img, .image-card video { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.image-card .i-actions {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  background: rgba(0,0,0,0.55);
  padding: 4px 6px;
}
.image-card .i-actions button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
}
.image-card .i-actions button:hover { background: rgba(255,255,255,0.15); }
.image-card .i-num {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
}
