/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d0d0f;
  --bg2: #131316;
  --bg3: #18181c;
  --bg4: #1e1e23;
  --border: #2a2a32;
  --border2: #33333d;
  --text: #e8e8f0;
  --text2: #9898b0;
  --text3: #606070;
  --accent: #7c6ef9;
  --accent2: #5a4fd9;
  --accent-glow: rgba(124,110,249,0.25);
  --green: #3dd68c;
  --red: #f2685a;
  --yellow: #f5a623;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
  --sidebar-w: 260px;
}
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.logo-sub { font-size: 10px; color: var(--text3); margin-top: 1px; }
.sidebar-nav {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 12px; opacity: 0.8; }
.sidebar-controls { padding: 12px 12px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.ctrl-group { display: flex; flex-direction: column; gap: 6px; }
.ctrl-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text3); }
.chip-row { display: flex; gap: 4px; }
.chip {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { background: var(--bg4); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.ctrl-select, .ctrl-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  appearance: none;
  outline: none;
  transition: border-color 0.12s;
}
.ctrl-select:focus, .ctrl-input:focus { border-color: var(--accent); }
.duo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diag-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.diag-name { font-size: 12px; color: var(--text2); }
.diag-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--text3); padding: 2px 0; }
.diag-row strong { font-size: 11px; color: var(--text2); }
.diag-detail { font-size: 10px; color: var(--text3); line-height: 1.5; margin-top: 4px; }
.pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pill.good { background: rgba(61,214,140,0.15); color: var(--green); }
.pill.bad { background: rgba(242,104,90,0.15); color: var(--red); }
.pill.warn { background: rgba(245,166,35,0.15); color: var(--yellow); }
.pill.neutral { background: var(--bg3); color: var(--text3); }
.jobs-mini { display: flex; flex-direction: column; gap: 4px; max-height: 140px; overflow-y: auto; }
.job-mini { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; }
.job-mini-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.job-mini-dot.good { background: var(--green); }
.job-mini-dot.bad { background: var(--red); }
.job-mini-dot.warn { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.job-mini-dot.neutral { background: var(--text3); }
.job-mini-info { flex: 1; min-width: 0; }
.job-mini-name { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-mini-time { font-size: 10px; color: var(--text3); margin-top: 1px; }
.mini-copy { font-size: 11px; color: var(--text3); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.footer-btn {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
}
.footer-btn:hover { background: var(--bg4); color: var(--text); }
.footer-btn.danger:hover { background: rgba(242,104,90,0.15); color: var(--red); border-color: rgba(242,104,90,0.3); }

/* ── Main ────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.tab-panel { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.tab-panel.active { display: flex; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
}
.topbar-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.topbar-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.topbar-actions { display: flex; gap: 8px; }
.tb-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
}
.tb-btn:hover { background: var(--bg4); color: var(--text); }

/* ── Gallery ─────────────────────────────────────────────────────── */
.gallery-area { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  min-height: 200px;
}
.img-card {
  background: var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s;
}
.img-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.img-card img, .img-card video { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}
.img-card:hover .img-overlay { opacity: 1; }
.img-meta { font-size: 10px; color: rgba(255,255,255,0.8); line-height: 1.4; margin-bottom: 6px; }
.img-actions { display: flex; gap: 4px; }
.img-action-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
}
.img-action-btn:hover { background: rgba(255,255,255,0.3); }
.img-action-btn.delete:hover { background: rgba(242,104,90,0.7); }
.empty-state { text-align: center; padding: 80px 20px; color: var(--text3); grid-column: 1/-1; }
.empty-icon { font-size: 36px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 17px; color: var(--text2); margin-bottom: 8px; font-weight: 600; }
.empty-state p { font-size: 13px; color: var(--text3); max-width: 320px; margin: 0 auto; line-height: 1.6; }

/* ── Input Bar ───────────────────────────────────────────────────── */
.input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--accent); }
.input-icon { font-size: 14px; color: var(--accent); flex-shrink: 0; margin-bottom: 2px; }
.input-wrap textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.input-wrap textarea::placeholder { color: var(--text3); }
.input-send {
  background: var(--accent);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, transform 0.1s;
}
.input-send:hover { background: var(--accent2); transform: scale(1.05); }
.input-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Video Mode ──────────────────────────────────────────────────── */
.video-mode-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.video-mode-info {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.vmode-badge {
  background: linear-gradient(135deg, var(--accent), #b06ef5);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
}
.video-mode-info p { font-size: 12px; color: var(--text3); }
.video-gallery { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-content: start; min-height: 0; min-height: 200px; }
.video-card {
  background: var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  aspect-ratio: 9/16;
  position: relative;
}
.video-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.video-card video { width: 100%; height: 100%; object-fit: cover; }
.video-card .img-overlay { opacity: 0; }
.video-card:hover .img-overlay { opacity: 1; }

/* ── Long Video ──────────────────────────────────────────────────── */
.longvideo-area { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 20px; gap: 16px; min-height: 0; }
.longvideo-header { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.longvideo-config { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.longvideo-hint { font-size: 12px; color: var(--text3); line-height: 1.5; background: var(--bg2); border: 1px solid var(--border); padding: 10px 14px; border-radius: var(--radius-sm); flex-shrink: 0; }
.segment-inputs { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.segment-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  flex-shrink: 0;
}
.segment-num {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}
.segment-row textarea {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  resize: vertical;
  outline: none;
  min-height: 80px;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.12s;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.segment-row textarea:focus { border-color: var(--accent); }
.segment-row textarea::placeholder { color: var(--text3); }
.segment-status { font-size: 10px; color: var(--text3); min-width: 60px; max-width: 60px; text-align: right; margin-top: 6px; flex-shrink: 0; overflow: hidden; }
.longvideo-actions { display: flex; gap: 10px; }
.longvideo-results { display: flex; flex-direction: column; gap: 12px; }
.segment-result {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.segment-result video { width: 120px; height: 68px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg3); }
.segment-result-info { flex: 1; }
.segment-result-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.segment-result-prompt { font-size: 11px; color: var(--text3); }

/* ── Bulk Generate ───────────────────────────────────────────────── */
.bulk-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.bulk-header { display: flex; flex-direction: column; gap: 10px; }
.bulk-header p { font-size: 13px; color: var(--text2); }
.bulk-prompt-list { display: flex; flex-direction: column; gap: 8px; }
.bulk-prompt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.bulk-prompt-num { font-size: 11px; color: var(--text3); min-width: 20px; font-family: var(--mono); }
.bulk-prompt-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}
.bulk-prompt-row input::placeholder { color: var(--text3); }
.bulk-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s;
}
.bulk-remove:hover { color: var(--red); }
.bulk-actions { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.bulk-progress-list { display: flex; flex-direction: column; gap: 8px; }
.bulk-job-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bulk-job-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bulk-job-dot.running { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); animation: pulse 1s infinite; }
.bulk-job-dot.done { background: var(--green); }
.bulk-job-dot.error { background: var(--red); }
.bulk-job-dot.pending { background: var(--text3); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.bulk-job-info { flex: 1; min-width: 0; }
.bulk-job-prompt { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bulk-job-status { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* ── AI Brain ────────────────────────────────────────────────────── */
.brain-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.brain-config {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.brain-api-row { display: flex; gap: 12px; flex-wrap: wrap; }
.api-key-wrap { position: relative; display: flex; align-items: center; }
.api-key-wrap .ctrl-input { padding-right: 38px; }
.api-lock-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
  transition: opacity 0.12s;
  padding: 2px;
}
.api-lock-btn:hover { opacity: 1; }
.brain-test-result {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
}
.brain-test-result.success { background: rgba(61,214,140,0.1); color: var(--green); border: 1px solid rgba(61,214,140,0.2); }
.brain-test-result.error { background: rgba(242,104,90,0.1); color: var(--red); border: 1px solid rgba(242,104,90,0.2); }
.brain-sections { display: flex; flex-direction: column; gap: 16px; }
.brain-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brain-section h4 { font-size: 13px; font-weight: 700; }
.brain-section p { font-size: 12px; color: var(--text3); line-height: 1.5; }
.brain-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.12s;
}
.brain-textarea:focus { border-color: var(--accent); }
.brain-textarea::placeholder { color: var(--text3); }
.brain-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.brain-output {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text2);
  white-space: pre-wrap;
  position: relative;
}
.brain-output .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.12s;
}
.brain-output .copy-btn:hover { background: var(--accent); color: #fff; }
.brain-output .prompt-item {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
}
.brain-output .prompt-item:last-child { margin-bottom: 0; }
.brain-output .prompt-label { font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 5px; }
.brain-output .use-prompt-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.12s;
}
.brain-output .use-prompt-btn:hover { background: var(--accent2); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Settings Panel ──────────────────────────────────────────────── */
.settings-panel {
  position: fixed;
  top: 0; right: -540px;
  width: 520px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: right 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
}
.settings-panel.open { right: 0; }
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-head h3 { font-size: 15px; font-weight: 700; }
.settings-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 20px; }
.settings-section { display: flex; flex-direction: column; gap: 12px; }
.settings-section h4 { font-size: 13px; font-weight: 700; color: var(--text); }
.sfield { display: flex; flex-direction: column; gap: 5px; }
.sfield label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.sfield input, .sfield select, .sfield textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.12s;
}
.sfield input:focus, .sfield select:focus, .sfield textarea:focus { border-color: var(--accent); }
.cookie-box { min-height: 80px; resize: vertical; font-family: var(--mono); font-size: 11px; }
.settings-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-field { display: flex; gap: 6px; }
.inline-field input { flex: 1; }
.s-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}
.s-btn:hover { background: var(--bg4); color: var(--text); }
.s-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.s-btn.primary:hover { background: var(--accent2); }
.info-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text3);
  line-height: 1.6;
}
.settings-foot { padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ── Lightbox ────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-inner { max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; gap: 10px; }
.lightbox-top { display: flex; justify-content: flex-end; gap: 8px; }
.lb-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
}
.lb-btn:hover { background: rgba(255,255,255,0.2); }
.lightbox-inner img, .lightbox-inner video {
  max-width: 90vw;
  max-height: 82vh;
  border-radius: var(--radius);
  object-fit: contain;
}
.hidden { display: none !important; }

/* ── Video Loading Overlay ───────────────────────────────────────── */
.video-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.vl-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 300px;
  max-width: 400px;
}
.vl-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.vl-title { font-size: 16px; font-weight: 700; text-align: center; }
.vl-step { font-size: 12px; color: var(--text3); text-align: center; }
.vl-progress {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}
.vl-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #b06ef5);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.vl-elapsed { font-size: 11px; color: var(--text3); font-family: var(--mono); }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-area { position: fixed; bottom: 20px; right: 20px; z-index: 400; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 240px;
  max-width: 360px;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warn { border-left: 3px solid var(--yellow); }
.toast-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.toast.success .toast-title { color: var(--green); }
.toast.error .toast-title { color: var(--red); }
.toast.warn .toast-title { color: var(--yellow); }
.toast-copy { font-size: 12px; color: var(--text2); line-height: 1.4; }

/* ── Brain loading animation ─────────────────────────────────────── */
.brain-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 12px;
  padding: 10px 0;
}
.brain-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite ease-in-out;
  margin: 0 2px;
}
.brain-dots span:nth-child(1) { animation-delay: 0s; }
.brain-dots span:nth-child(2) { animation-delay: 0.2s; }
.brain-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* ── Connection Hero ─────────────────────────────────────────────── */
.connection-hero {
  display: grid;
  grid-template-columns: minmax(260px, 1.25fr) minmax(360px, 1fr);
  gap: 14px;
  padding: 16px 20px 0;
  background: linear-gradient(180deg, rgba(124,110,249,0.08), transparent 70%);
}
.connection-hero-main,
.status-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
}
.connection-hero-main {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}
.hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b6adff;
}
.connection-hero-main h2 {
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.connection-hero-main p {
  color: var(--text2);
  line-height: 1.7;
  max-width: 60ch;
}
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.connection-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.status-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 132px;
}
.status-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
}
.status-card-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.status-card-value.good { color: var(--green); }
.status-card-value.bad { color: var(--red); }
.status-card-value.warn { color: var(--yellow); }
.status-card-value.neutral { color: var(--text); }
.status-card-hint {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
}

/* ── Settings Validation ──────────────────────────────────────────── */
.settings-validation {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-validation.good { border-color: rgba(61,214,140,0.28); background: rgba(61,214,140,0.08); }
.settings-validation.warn { border-color: rgba(245,166,35,0.28); background: rgba(245,166,35,0.08); }
.settings-validation.bad { border-color: rgba(242,104,90,0.28); background: rgba(242,104,90,0.08); }
.settings-validation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.settings-validation-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.settings-validation-copy {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
}
.validation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.validation-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}
.validation-row strong { color: var(--text); }
.validation-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.field-help {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.5;
}

/* ── Responsive polish ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .connection-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .connection-cards {
    grid-template-columns: 1fr;
  }

  .connection-hero-main h2 {
    font-size: 22px;
  }

  .hero-actions {
    flex-direction: column;
  }
}
