:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card2: #273449;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent2: #3b82f6;
  --danger: #ef4444;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #0b1220;
  border-bottom: 1px solid #1e293b;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.engine-status {
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card2);
  white-space: nowrap;
}
.engine-status.loading { color: #fbbf24; }
.engine-status.ready { color: #4ade80; }
.engine-status.error { color: #f87171; }

.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #2b3a55;
}
.card h2 { margin: 0 0 6px; font-size: 1.15rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }
.empty { color: var(--muted); font-style: italic; font-size: 0.9rem; }

/* Dropzone */
.dropzone {
  border: 2px dashed #475569;
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(34,197,94,.06);
  color: var(--text);
}
.dz-icon { font-size: 2rem; margin-bottom: 8px; }
.link { color: var(--accent2); text-decoration: underline; }

/* Clip list */
.clip-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.clip-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card2);
  border-radius: 10px;
  padding: 10px;
}
.clip-item video {
  width: 110px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  flex-shrink: 0;
}
.clip-info { flex: 1; min-width: 0; }
.clip-name { font-weight: 600; font-size: 0.92rem; word-break: break-all; }
.clip-meta { color: var(--muted); font-size: 0.82rem; }
.clip-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-btn {
  background: #334155;
  border: none;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.icon-btn:hover { background: #475569; }
.icon-btn.danger { background: #7f1d1d; }
.icon-btn.danger:hover { background: #991b1b; }

/* Buttons */
.btn {
  background: var(--accent2);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #334155; }
.btn.primary { background: var(--accent); color: #052e16; font-weight: 700; }
.btn.big { font-size: 1.05rem; padding: 14px 26px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
a.btn { text-decoration: none; display: inline-block; }

/* Trim */
.preview-video {
  width: 100%;
  max-height: 380px;
  background: #000;
  border-radius: 10px;
}
.trim-controls { margin-top: 14px; }
.dual-slider { position: relative; height: 34px; margin: 6px 0 4px; }
.dual-slider input[type=range] {
  position: absolute;
  left: 0; right: 0; top: 8px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  margin: 0;
}
.dual-slider input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px; background: #334155;
}
.dual-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -7px;
  cursor: pointer;
  border: 2px solid #052e16;
}
.dual-slider input[type=range]::-moz-range-track {
  height: 8px; border-radius: 4px; background: #334155;
}
.dual-slider input[type=range]::-moz-range-thumb {
  pointer-events: auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #052e16;
}
.time-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.time-row label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.time-input {
  width: 90px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
  font-size: 0.95rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input[type=text],
.form-grid input[type=number],
.form-grid select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
  font-size: 0.95rem;
  width: 100%;
}
.form-grid input[type=color] {
  padding: 4px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  width: 100%;
  cursor: pointer;
}

/* Text list */
.text-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.text-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.text-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-item .m { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid #475569; flex-shrink: 0; }

/* Player */
.player-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #000; }
.overlays { position: absolute; inset: 0; pointer-events: none; }
.overlay-text {
  position: absolute;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0,0,0,.8);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 90%;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.seek { flex: 1; accent-color: var(--accent); }
.time-label { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

/* Export */
.progress-wrap { margin-top: 16px; }
.progress-bar {
  height: 14px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #334155;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .3s;
}
.log-details { margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.log {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow: auto;
  font-size: 0.75rem;
  white-space: pre-wrap;
  color: #a5b4fc;
}
#exportResult h3 { margin: 16px 0 10px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 30px;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .clip-item video { width: 84px; height: 54px; }
  .card { padding: 16px; }
  .btn.big { width: 100%; }
}
