:root {
  --bg: #0a0a0a;
  --bg-soft: #101010;
  --panel: #141414;
  --panel-2: #1a1a1a;
  --border: #2a2a2a;
  --border-strong: #3d3d3d;
  --text: #f0f0f0;
  --dim: #9c9c9c;
  --faint: #666;
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.12);
  --accent-line: rgba(255, 255, 255, 0.35);
  --danger: #d4d4d4;
  --danger-bg: rgba(255, 255, 255, 0.06);
  --danger-line: rgba(255, 255, 255, 0.5);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.6rem 1.2rem 0.4rem;
}

.logo { display: flex; align-items: center; gap: 0.9rem; }

.logo-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font: 700 22px/1 var(--mono);
  color: #111;
  background: var(--text);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(255, 255, 255, 0.15);
}

header h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.02em;
  color: var(--text);
}

.tagline { margin: 0.1rem 0 0; color: var(--dim); font-size: 0.88rem; }

.gh-link {
  color: var(--dim);
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  transition: color 0.15s, border-color 0.15s;
}
.gh-link:hover { color: var(--text); border-color: var(--text); }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.2rem 3rem;
  display: grid;
  gap: 1rem;
}

/* ---------- dropzone ---------- */

#dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 2.6rem 1rem;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.7), rgba(20, 20, 20, 0.35));
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  outline: none;
}
#dropzone:hover, #dropzone:focus-visible {
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  transform: translateY(-1px);
}

#dropzone.has-file {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  text-align: left;
  padding: 1.1rem 1.2rem;
}

.dz-icon {
  color: var(--text);
  width: 38px;
  height: 38px;
  margin: 0 auto 0.7rem;
  padding: 9px;
  border-radius: 10px;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.dz-icon svg { width: 100%; height: 100%; }
#dropzone.has-file .dz-icon { margin: 0; }

#file-preview {
  width: 108px;
  height: 108px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
  background: #000;
}

.dz-text { min-width: 0; flex: 1; }

.dz-main { margin: 0; font-size: 1.05rem; font-weight: 600; }
.dz-sub { margin: 0.2rem 0 0; color: var(--dim); font-size: 0.85rem; }

.dz-file {
  margin: 0.8rem auto 0;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 0.82rem var(--mono);
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
}
#dropzone.has-file .dz-file { margin: 0.2rem 0 0; }

.dz-meta {
  margin: 0.35rem 0 0;
  color: var(--faint);
  font: 0.78rem var(--mono);
  letter-spacing: 0.02em;
}

.dz-row { margin-top: 0.55rem; }

.dz-link {
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.dz-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.dz-link.danger { color: var(--danger); }

/* ---------- sample / drag overlay ---------- */

.sample-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: -0.35rem;
  color: var(--faint);
  font-size: 0.85rem;
}

#btn-sample {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
#btn-sample:hover {
  border-color: var(--text);
  background: var(--accent-soft);
}

#drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.drag-card {
  display: grid;
  place-items: center;
  gap: 0.9rem;
  padding: 2.6rem 3.4rem;
  border: 2px dashed var(--text);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 600;
  box-shadow: 0 0 60px rgba(255, 255, 255, 0.06);
}
.drag-card p { margin: 0; }

.drag-icon {
  width: 44px;
  height: 44px;
  padding: 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}
.drag-icon svg { width: 100%; height: 100%; }

/* ---------- controls ---------- */

#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.1rem;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
#controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}
#controls label em { color: var(--faint); font-style: normal; font-weight: 500; }
#controls label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  padding-bottom: 0.4rem;
  cursor: pointer;
  user-select: none;
}

#controls input[type="number"],
#controls input[type="text"],
#controls select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.42rem 0.55rem;
  font: 0.95rem var(--mono);
  max-width: 8.5rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#controls select { font-family: system-ui, sans-serif; }
#controls input:focus, #controls select:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

#controls input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 8.5rem;
  height: 4px;
  border-radius: 4px;
  background: var(--border-strong);
  margin-top: 0.55rem;
}
#controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
  cursor: pointer;
}
#controls input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}

#controls output {
  display: inline;
  color: var(--text);
  font: 0.75rem var(--mono);
  text-transform: none;
  letter-spacing: 0;
}

#controls input[type="checkbox"] {
  accent-color: #fff;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ---------- status bar ---------- */

#status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
}
#stat-text { color: var(--dim); font-size: 0.88rem; }

#view-toggle { display: flex; gap: 0.3rem; }

.tab {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active {
  color: #111;
  background: var(--text);
  border-color: transparent;
  font-weight: 600;
}

#actions { display: flex; align-items: center; gap: 0.5rem; }

#actions button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
#actions button:hover:not(:disabled) { border-color: var(--text); background: var(--accent-soft); }
#actions button:disabled { opacity: 0.35; cursor: default; }

#ctl-speed {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.35rem 0.4rem;
  font-size: 0.85rem;
}

/* ---------- stage ---------- */

#stage { min-height: 220px; }

#pre {
  background: #000;
  color: #fff;
  font: 12.5px/1 var(--mono);
  letter-spacing: 0;
  word-spacing: 0;
  padding: 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: auto;
  max-height: 70vh;
  margin: 0;
  white-space: pre;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

#gif-preview {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

#error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  word-break: break-word;
  font-size: 0.9rem;
}

/* ---------- timeline ---------- */

#timeline {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
}
#ctl-frame {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--border-strong);
}
#ctl-frame::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
#ctl-frame::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
#frame-count { color: var(--dim); font: 0.8rem var(--mono); white-space: nowrap; }

@media (max-width: 640px) {
  header { flex-wrap: wrap; }
  #actions { flex-wrap: wrap; }
  #pre { font-size: 10px; }
}