:root {
  --bg: #0a0c16;
  --bg2: #0e1120;
  --card: #151a2e;
  --card2: #1d2440;
  --line: #2c3354;
  --text: #f2ecdc;
  --muted: #9197ad;
  --gold: #d4af37;
  --gold2: #f0d77b;
  --emerald: #2ec27e;
  --danger: #ff5c7a;
  --radius: 14px;
  --serif: Georgia, "Times New Roman", serif;
}

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

body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(212, 175, 55, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

h1, h2, h3, .logo { font-family: var(--serif); }

.shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 14px;
  gap: 18px;
}
.logo { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; padding: 0 8px; }
.logo span {
  background: linear-gradient(90deg, var(--gold), #fff3c4, var(--gold));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 4s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }

nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; gap: 10px; align-items: center;
  background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  text-align: left; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card2); color: var(--gold2); }

.side-badge {
  margin-top: auto;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.16), rgba(46, 194, 126, 0.08));
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius);
  padding: 14px;
}
.badge-title { font-weight: 800; font-size: 13px; color: var(--gold); letter-spacing: 1px; }
.badge-sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* ---------- main ---------- */
main { flex: 1; padding: 44px 40px 60px; max-width: 1100px; margin: 0 auto; width: 100%; }

h1 { font-size: 36px; letter-spacing: -0.5px; font-weight: 700; }
h1 em { font-style: italic; color: var(--gold); }
.sub { color: var(--muted); margin: 10px 0 26px; }

.link-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 10px 10px 10px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.link-bar:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.14);
}
.link-ico { font-size: 18px; }
#url-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font: inherit; font-size: 15px; min-width: 0;
}
#url-input::placeholder { color: var(--muted); }

.btn {
  background: linear-gradient(90deg, var(--gold), var(--gold2));
  border: none; color: #241b02; font-weight: 800; font-size: 14px;
  padding: 10px 18px; border-radius: 12px; cursor: pointer;
  transition: filter 0.15s, transform 0.08s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.95); }
.btn:disabled { filter: grayscale(0.7); cursor: wait; }
.btn.cta { font-size: 15px; padding: 12px 22px; }
.btn.download { background: linear-gradient(90deg, var(--emerald), #5fe0a8); color: #042415; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn.secondary { background: var(--card2); border: 1px solid var(--line); color: var(--text); font-weight: 600; }

#dropzone {
  margin-top: 14px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
#dropzone:hover, #dropzone.drag { border-color: var(--gold); background: rgba(212, 175, 55, 0.06); }
.dz-icon { font-size: 22px; display: inline-block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}
.link-btn {
  background: none; border: none; color: var(--gold);
  font: inherit; cursor: pointer; text-decoration: underline;
}

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 18px; }
.opt { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.opt label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 9px; font-weight: 600; }
.opt label span { color: var(--gold2); }
.opt select {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line); font: inherit; font-size: 13px;
}
.range-pair { display: grid; gap: 6px; }
input[type="range"] { width: 100%; accent-color: var(--gold); }
input[type="checkbox"] { accent-color: var(--gold); }

/* ---------- settings screen ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font: inherit;
  font-weight: 600; font-size: 13.5px; transition: all 0.15s;
}
.tab.active { background: var(--card2); color: var(--gold2); border-color: rgba(212, 175, 55, 0.5); }

.opt.full { grid-column: 1 / -1; }
.text-input {
  width: 100%; background: var(--card2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); font: inherit; font-size: 13.5px;
  padding: 9px 11px;
}
.text-input:focus { outline: none; border-color: var(--gold); }

#style-gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.style-card {
  display: flex; flex-direction: column; gap: 7px; align-items: center;
  background: var(--bg2); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 10px 8px; cursor: pointer; min-width: 108px;
  font: inherit; transition: border-color 0.15s, transform 0.1s;
}
.style-card:hover { transform: translateY(-2px); }
.style-card.selected { border-color: var(--gold); background: rgba(212, 175, 55, 0.08); }
.sc-name { font-size: 11px; color: var(--muted); font-weight: 600; }
.sc-demo { font-size: 13px; font-weight: 800; line-height: 1.2; }
.sc-bold .sc-demo { color: #fff; text-transform: uppercase; -webkit-text-stroke: 0.5px #000; }
.sc-bold .sc-demo em { color: #ffd700; font-style: normal; }
.sc-neon .sc-demo { color: #fff; text-transform: uppercase; -webkit-text-stroke: 0.5px #000; }
.sc-neon .sc-demo em { color: #6aff00; font-style: normal; }
.sc-minimal .sc-demo { color: #ddd; font-weight: 600; }
.sc-minimal .sc-demo em { color: #fff; font-style: normal; }
.sc-box .sc-demo { background: #141414; color: #fff; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; }
.sc-box .sc-demo em { color: #ffd700; font-style: normal; }
.sc-royal .sc-demo { font-family: var(--serif); color: #ece6f2; }
.sc-royal .sc-demo em { color: var(--gold); }

.brand-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px; align-items: center;
}
.mini { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
input[type="color"] {
  width: 38px; height: 26px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card2); padding: 1px; cursor: pointer;
}
#cap-text {
  width: 100%; background: var(--card2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); font: inherit; font-size: 12.5px;
  padding: 8px 10px; resize: vertical;
}
#cap-text:focus { outline: none; border-color: var(--gold); }

.settings-cta {
  display: flex; gap: 12px; justify-content: flex-end; align-items: center;
  margin-top: 20px; flex-wrap: wrap;
}
.settings-cta .btn.cta { min-width: 180px; }

/* ---------- progress ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.progress-card { text-align: center; max-width: 560px; margin: 60px auto; }
.progress-card h2 { margin-bottom: 18px; }
.bar { height: 10px; border-radius: 6px; background: var(--bg2); overflow: hidden; margin-bottom: 12px; }
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold2), var(--gold));
  background-size: 200% auto;
  animation: shimmer 1.6s linear infinite;
  border-radius: 6px;
  transition: width 0.4s ease;
}
.muted { color: var(--muted); font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- results grid ---------- */
.results-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.ghost-btn {
  background: none; border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 13.5px;
  transition: border-color 0.15s, transform 0.08s;
}
.ghost-btn:hover { border-color: var(--gold); }
.ghost-btn:active { transform: scale(0.95); }

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.clip-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  animation: pop-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards;
  display: flex; flex-direction: column;
}
.clip-card:nth-child(2) { animation-delay: 0.06s; }
.clip-card:nth-child(3) { animation-delay: 0.12s; }
.clip-card:nth-child(4) { animation-delay: 0.18s; }
.clip-card:nth-child(5) { animation-delay: 0.24s; }
.clip-card:nth-child(6) { animation-delay: 0.30s; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.thumb {
  position: relative; aspect-ratio: 9 / 16; max-height: 330px;
  background: linear-gradient(160deg, #20264a, #123a30);
  cursor: pointer; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 44px; opacity: 0; transition: opacity 0.15s; background: rgba(0,0,0,0.35);
}
.thumb:hover .play { opacity: 1; }
.score-chip {
  position: absolute; top: 8px; left: 8px;
  background: rgba(8, 10, 18, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 9px; padding: 5px 9px;
  font-weight: 800; font-size: 13px;
  display: flex; gap: 5px; align-items: center;
}
.score-chip.hot { color: var(--gold2); }
.score-chip.good { color: var(--emerald); }
.score-chip.ok { color: var(--muted); }
.dur-chip {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(8, 10, 18, 0.85);
  border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 600;
}

.clip-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.clip-hook {
  font-weight: 700; font-size: 13.5px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.why { font-size: 11.5px; color: var(--gold); }
.clip-set { display: flex; gap: 6px; }
.clip-set select {
  flex: 1; min-width: 0; padding: 7px 6px; border-radius: 8px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line); font-size: 12px;
}
.cap-toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.clip-buttons { display: flex; gap: 8px; margin-top: auto; }
.clip-buttons .btn { flex: 1; text-align: center; text-decoration: none; }
.export-status { font-size: 12px; color: var(--muted); min-height: 15px; }
.export-status.error { color: var(--danger); }

/* ---------- projects ---------- */
.proj-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px;
}
.proj-row .t { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row .s { color: var(--muted); font-size: 13px; white-space: nowrap; }
.del-btn {
  background: none; border: 1px solid transparent; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 7px 9px; border-radius: 8px;
  cursor: pointer; opacity: 0; transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.proj-row:hover .del-btn { opacity: 1; }
.del-btn:hover { color: var(--danger); border-color: var(--danger); }
@media (hover: none) { .del-btn { opacity: 1; } }

/* ---------- editor modal ---------- */
#modal[hidden] { display: none; }
#modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 5, 10, 0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal-box {
  display: flex; gap: 18px; align-items: stretch;
  max-width: 96vw; max-height: 92vh; flex-wrap: wrap; justify-content: center;
}
.stage {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(76vh, 600px);
  background: #000;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.ovl {
  position: absolute; transform: translate(-50%, -50%);
  width: max-content; max-width: 85%; text-align: center;
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 2px #000;
  z-index: 2; line-height: 1.25;
  padding: 10px 14px; border-radius: 10px;
  border: 1.5px dashed rgba(212, 175, 55, 0.55);
}
.ovl::after {
  content: "⠿ drag"; position: absolute; top: -9px; right: -6px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  background: var(--gold); color: #241b02;
  padding: 1px 6px; border-radius: 6px;
  font-family: "Segoe UI", system-ui, sans-serif;
  text-shadow: none;
}
.ovl.dragging, .ovl:active { cursor: grabbing; border-style: solid; background: rgba(212, 175, 55, 0.12); }
.ovl-title {
  font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--gold);
}
.ovl-caps { font-weight: 900; font-size: 17px; color: #fff; letter-spacing: 0.5px; }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; width: 270px; display: flex; flex-direction: column; gap: 12px;
  align-self: center;
}
.panel h3 { font-size: 18px; color: var(--gold2); }
.panel-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
#title-text {
  background: var(--card2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 9px 10px; width: 100%;
}
#title-text:focus { outline: none; border-color: var(--gold); }
.panel-btns { display: flex; gap: 8px; }
.panel-btns .btn, .panel-btns .ghost-btn { flex: 1; }

#error-box {
  margin-top: 24px; background: rgba(255, 92, 122, 0.08);
  border: 1px solid var(--danger); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
#error-msg { color: var(--danger); margin-bottom: 14px; }

.confetti {
  position: fixed; top: -12px; width: 10px; height: 14px;
  border-radius: 2px; pointer-events: none; z-index: 99;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0.6; } }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center;
    padding: 12px 14px; gap: 12px;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .logo { font-size: 18px; }
  nav { flex-direction: row; margin-left: auto; }
  .nav-item { padding: 8px 10px; }
  .nav-item span { display: none; }
  .side-badge { display: none; }
  main { padding: 22px 14px 50px; }
  h1 { font-size: 25px; }
  .link-bar { flex-wrap: wrap; padding: 10px; }
  #url-input { flex: 1 1 100%; padding: 4px 6px; }
  .btn.cta { flex: 1; }
  .clip-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .thumb { max-height: 280px; }
  .clip-buttons .btn { padding: 11px 8px; }
  input[type="range"] { height: 28px; }
  .modal-box { flex-direction: column; align-items: center; gap: 10px; overflow-y: auto; }
  .stage { height: min(58vh, 460px); }
  .panel { width: 100%; max-width: 340px; }
}
