:root {
  --bg: #0f1115; --card: #171a21; --line: #262b36; --text: #e8eaf0; --muted: #8b93a7;
  --accent: #ff4d6d; --accent2: #ff8f4d; --ok: #4dd18f; --win: rgba(77,163,255,.35); --peak: #ffd84d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.top { display: flex; align-items: baseline; gap: 18px; padding: 22px 28px 6px; flex-wrap: wrap; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.logo { color: var(--accent); }
.tag { color: var(--muted); font-size: 14px; }
main { max-width: 1400px; margin: 0 auto; padding: 16px 20px 60px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.card { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.hidden { display: none !important; }
#video-section { display: grid; gap: 16px; }
h2 { margin: 0 0 4px; font-size: 18px; } h3 { margin: 0 0 12px; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.error { color: var(--accent); }
form { display: flex; gap: 10px; }
input, select { background: #0f1115; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
#url { flex: 1; min-width: 0; }
button, .btn { background: var(--line); color: var(--text); border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, #analyze-btn { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #fff; }
button:disabled { opacity: .5; cursor: wait; }
.prog-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.bar { height: 8px; background: #0f1115; border-radius: 99px; overflow: hidden; }
#prog-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; }
.video-meta { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.video-meta img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #000; }
.sub { color: var(--muted); font-size: 13px; }
.pill { background: #0f1115; border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; font-size: 12px; }
.player-wrap { position: relative; width: 100%; padding-top: 56.25%; background: #000; border-radius: 10px; overflow: hidden; }
.player-wrap iframe, .player-wrap > div, .player-wrap .ph { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.chart-wrap { position: relative; margin-top: 14px; }
#chart { width: 100%; height: 140px; display: block; border-radius: 8px; background: #0f1115; cursor: crosshair; }
.tip { position: absolute; top: 6px; pointer-events: none; background: #000c; padding: 2px 8px; border-radius: 6px; font-size: 12px; transform: translateX(-50%); }
.legend { color: var(--muted); font-size: 12px; margin-top: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; }
.sw.hot { background: var(--accent); } .sw.win { background: var(--win); border: 1px solid #4da3ff; } .sw.peak { background: var(--peak); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { background: #0f1115; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip b { color: var(--peak); }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.opts label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.opts input, .opts select { width: 100%; }
#generate-btn { margin-top: 14px; }
.clips-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.clip { position: relative; background: #0f1115; border: 1px solid var(--line); border-radius: 12px; overflow: visible; display: flex; flex-direction: column; z-index: 1; }
.clip:hover { z-index: 40; }
.clip video { width: 100%; aspect-ratio: 9/16; background: #000; object-fit: contain; border-radius: 11px 11px 0 0; }
.clip.landscape video { aspect-ratio: 16/9; }
.clip .ph { aspect-ratio: 9/16; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: #000; border-radius: 11px 11px 0 0; }
.clip.landscape .ph { aspect-ratio: 16/9; }
.clip .info { padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.clip .row { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.clip .rank { font-weight: 700; color: var(--text); }
.clip .actions { display: flex; gap: 8px; }
.clip .actions .btn { flex: 1; font-size: 12px; padding: 7px 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.clip .chkres { font-size: 12px; min-height: 0; }
.clip .chkres:empty { display: none; }
.clip .err { color: var(--accent); font-size: 12px; word-break: break-word; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 1s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recent li { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.recent a { color: var(--text); text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .x { color: var(--muted); cursor: pointer; background: none; padding: 2px 6px; }
.recent .st { font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { form { flex-direction: column; } .video-meta img { width: 90px; } }
.log { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; color: var(--muted); max-height: 140px; overflow-y: auto; }
.log li { display: flex; gap: 10px; } .log li:last-child { color: var(--text); }
.log time { flex: none; opacity: .6; font-variant-numeric: tabular-nums; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 14px; }
.toggles label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.clip .hook { color: var(--text); font-size: 12px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tabs { margin-left: auto; display: flex; gap: 6px; }
.tab { background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 8px; }
.tab.active { background: var(--line); color: var(--text); }
.check-list { display: grid; gap: 10px; }
.check-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; background: #0f1115; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.check-row video { width: 90px; aspect-ratio: 9/16; border-radius: 6px; background: #000; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge.low { background: #1f3d2e; color: var(--ok); } .badge.medium { background: #40361a; color: var(--peak); } .badge.high { background: #4a1f28; color: var(--accent); }
.report { margin-top: 14px; background: #0f1115; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.report ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.report .music a { color: var(--peak); }
.linkish { background: none; color: var(--muted); padding: 0; font-size: 12px; font-weight: 500; text-decoration: underline; }
.linkish:hover { color: var(--text); }
.outpath { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }

/* SEO Container & Popover */
.seo-container { position: absolute; top: 8px; right: 8px; z-index: 99; }
.seo-btn {
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: all 0.2s ease;
}
.seo-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.seo-popup {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 290px;
  max-height: 380px;
  overflow-y: auto;
  background: rgba(23, 26, 33, 0.97);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  z-index: 100;
}
.seo-container:hover .seo-popup,
.seo-popup:hover,
.seo-popup.force-show {
  display: block !important;
}
.seo-pop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.seo-copy-all {
  background: var(--line);
  color: var(--text);
  border: 0;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.seo-copy-all:hover {
  background: var(--ok);
  color: #000;
}
.seo-field {
  margin-bottom: 10px;
}
.seo-field:last-child {
  margin-bottom: 0;
}
.seo-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.seo-item-copy {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 2px 4px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 4px;
}
.seo-item-copy:hover {
  color: var(--accent);
  background: rgba(255, 77, 109, 0.1);
}
.seo-val {
  background: #0f1115;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text);
  max-height: 65px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

/* User Menu Wrapper & Dropdown */
.user-menu-wrapper { position: relative; display: inline-block; }
.avatar-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s, border-color 0.2s;
}
.avatar-btn:hover .avatar-circle {
  transform: scale(1.05);
  border-color: var(--accent);
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: rgba(23, 26, 33, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 500;
}
.user-dropdown-header {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-email-text {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.user-status-pill {
  display: inline-block;
  align-self: flex-start;
  background: linear-gradient(120deg, rgba(255, 77, 109, 0.2), rgba(255, 143, 77, 0.2));
  border: 1px solid var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.user-dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}
.user-dropdown-item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 9px 14px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 0;
  font-weight: 500;
  transition: background 0.15s;
}
.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.user-dropdown-item.danger:hover {
  background: rgba(255, 77, 109, 0.15);
  color: var(--accent);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.upgrade-card { max-width: 720px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: #fff; }

.auth-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-bottom: 8px; }
.auth-tab { background: transparent; color: var(--muted); border: none; padding: 8px 12px; font-size: 14px; cursor: pointer; border-radius: 6px; }
.auth-tab.active { background: var(--line); color: var(--text); font-weight: 600; }

#auth-form { display: flex; flex-direction: column; gap: 14px; }
#auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
#auth-form input { width: 100%; }

/* Pricing Grid */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; }
.price-box {
  background: #0f1115;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.price-box.featured {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 77, 109, 0.08), rgba(15, 17, 21, 0.95));
}
.price-box .badge {
  position: absolute;
  top: -12px;
  right: 16px;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 99px;
}
.price-box h3 { margin: 0 0 8px; font-size: 18px; }
.price-box .price { font-size: 32px; font-weight: 800; margin-bottom: 16px; color: #fff; }
.price-box .price span { font-size: 14px; font-weight: 400; color: var(--muted); }
.price-box ul { list-style: none; padding: 0; margin: 0 0 24px; font-size: 13px; display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.price-box button { margin-top: auto; width: 100%; text-align: center; }

/* Footer */
.app-footer { margin-top: 60px; padding: 30px 20px; text-align: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer-links a { color: var(--muted); text-decoration: none; margin: 0 6px; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.copyright { margin-top: 10px; font-size: 12px; opacity: 0.7; }


