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

body {
  background: #1a1b2e;
  color: #d0d0e8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: #22243a;
  border-bottom: 1px solid #2e3050;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 20px; }

h1 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.3px;
}

.tabs { display: flex; gap: 4px; }

.tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #888;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: all .15s;
}

.tab.active { background: #2e3155; border-color: #4a4f80; color: #a8aeff; }
.tab:hover:not(.active) { color: #bbb; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Dashboard layout ── */
.dashboard {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left panel (controls) ── */
.panel-left {
  width: 300px;
  flex-shrink: 0;
  background: #1e2035;
  border-right: 1px solid #2e3050;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding: 16px;
}

/* ── Right panel (output) ── */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 12px;
}

/* ── Spy pane ── */
.spy-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}

.tab-pane { display: none; width: 100%; }
.tab-pane.active { display: flex; flex: 1; overflow: hidden; }

/* ── Section label ── */
.sec-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #555a80;
  margin-bottom: 5px;
  margin-top: 14px;
}
.sec-label:first-child { margin-top: 0; }

/* ── Field with lock ── */
.field-lock {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.field-lock select,
.field-lock input {
  flex: 1;
  background: #252742;
  border: 1px solid #353760;
  border-radius: 7px;
  color: #d0d0e8;
  padding: 8px 10px;
  font-size: 12px;
  outline: none;
  transition: border-color .15s;
}

.field-lock select:focus,
.field-lock input:focus { border-color: #6c6fff; }

.lock {
  width: 30px;
  height: 30px;
  background: #252742;
  border: 1px solid #353760;
  border-radius: 7px;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.lock.on { background: #2a2660; border-color: #6c6fff; color: #8b8fff; }

/* ── Suggest box ── */
.suggest-box {
  background: #202050;
  border: 1px solid #4a4f90;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12px;
  color: #b0b0ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid #2e3050; margin: 10px 0; }

/* ── Buttons ── */
.btn {
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  border: 1px solid #353760;
  background: #252742;
  color: #ccc;
  transition: all .15s;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none;
}

.btn:hover { background: #2e3060; border-color: #6c6fff; color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.accent { background: #4040b0; border-color: #6c6fff; color: #fff; }
.btn.accent:hover { background: #5050c8; }
.btn.ghost { background: transparent; border-color: #4a4f80; color: #8888cc; }
.btn.ghost:hover { background: #1e2050; color: #fff; }
.btn.full { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 11px; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 2px;
}

.action-grid .btn:last-child { grid-column: span 2; }

/* ── Output card ── */
.out-card {
  background: #1e2035;
  border: 1px solid #2e3050;
  border-radius: 10px;
  padding: 14px;
}

.out-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.out-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  flex: 1;
}

.out-tags {
  font-size: 11px;
  color: #555a80;
  margin-bottom: 8px;
}

pre {
  font-family: inherit;
  font-size: 12px;
  color: #aaa;
  white-space: pre-wrap;
  line-height: 1.6;
  border-top: 1px solid #2e3050;
  padding-top: 10px;
  margin-top: 4px;
}

/* ── Progress ── */
.bar-bg { background: #252742; border-radius: 20px; height: 4px; margin-top: 8px; overflow: hidden; }
#bar { background: #6c6fff; height: 100%; width: 0%; border-radius: 20px; transition: width .4s; }
#progress-msg { color: #888; font-size: 12px; }

/* ── Video ── */
video { width: 100%; max-height: 340px; border-radius: 8px; background: #000; display: block; margin: 8px 0; object-fit: contain; }
.ok { color: #4ade80; font-weight: 700; font-size: 12px; margin-bottom: 4px; }

/* ── Spy controls ── */
.spy-controls { display: flex; align-items: flex-end; gap: 8px; }
.spy-controls select { background: #252742; border: 1px solid #353760; border-radius: 7px; color: #d0d0e8; padding: 8px 10px; font-size: 12px; outline: none; }

/* ── Loading msg ── */
.loading-msg { color: #555a80; font-size: 12px; text-align: center; padding: 40px 0; }

/* ── Channel Grid (Niche Spy) ── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.channel-card {
  background: #1e2035;
  border: 1px solid #2e3050;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .2s;
}
.channel-card:hover { border-color: #4a4f80; }

.channel-header { display: flex; align-items: center; gap: 10px; }

.channel-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4040b0, #6c6fff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
  flex-shrink: 0;
}

.channel-name { font-weight: 700; font-size: 13px; color: #e0e0f0; }
.channel-handle { font-size: 11px; color: #555a80; margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.channel-stats { display: flex; gap: 20px; }
.stat { display: flex; flex-direction: column; }
.stat-val { font-size: 16px; font-weight: 800; color: #a8aeff; }
.stat-lbl { font-size: 10px; color: #555a80; text-transform: uppercase; letter-spacing: .5px; }

.formats-row { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  background: #252742;
  border: 1px solid #353760;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  color: #8888cc;
}

.viral-title {
  font-size: 12px; color: #aaa; font-style: italic;
  background: #151628;
  border-left: 2px solid #4a4f80;
  padding: 6px 10px; border-radius: 0 6px 6px 0;
  line-height: 1.5;
}

.growth-badge { font-size: 10px; font-weight: 700; }
.growth-badge.rising  { color: #4ade80; }
.growth-badge.stable  { color: #facc15; }
.growth-badge.declining { color: #f87171; }

/* ── Bend Controls ── */
.bend-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.bend-controls select {
  width: 100%;
  background: #252742;
  border: 1px solid #353760;
  border-radius: 7px;
  color: #d0d0e8;
  padding: 8px 10px;
  font-size: 12px;
  outline: none;
}
.bend-arrow-mid {
  font-size: 22px; color: #4a4f80;
  margin-bottom: 8px; flex-shrink: 0;
}

/* ── Bend Grid ── */
.bend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.bend-card {
  background: #1e2035;
  border: 1px solid #2e3050;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .2s;
}
.bend-card:hover { border-color: #4a4f80; }

.bend-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bend-tag {
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
}
.bend-tag.source   { background: #2a2050; color: #c09fff; border: 1px solid #4a3888; }
.bend-tag.target-tag { background: #1a3050; color: #6cadff; border: 1px solid #2a4888; }
.bend-arrow-sm { color: #444; font-size: 13px; }

.bend-format-name {
  font-size: 10px; font-weight: 800; color: #6c6fff;
  text-transform: uppercase; letter-spacing: .8px;
}

.bend-adapted-title {
  font-size: 15px; font-weight: 800; color: #fff; line-height: 1.3;
}

.bend-hook {
  font-size: 12px; font-style: italic; color: #888;
  background: #151628;
  border-left: 2px solid #6c6fff;
  padding: 6px 10px; border-radius: 0 6px 6px 0;
  line-height: 1.5;
}

.bend-why { font-size: 11px; color: #4ade80; line-height: 1.4; }

/* ── Pill ── */
.pill {
  background: #252742;
  border: 1px solid #353760;
  border-radius: 20px;
  color: #999;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.pill:hover { border-color: #6c6fff; color: #fff; }

.hidden { display: none !important; }
