:root {
  color-scheme: dark;
  --bg: #11120f;
  --panel: #1c1d19;
  --panel-2: #25261f;
  --ink: #f4f1e8;
  --muted: #a7a394;
  --line: #3a3b32;
  --accent: #f05d43;
  --accent-2: #2bb4a6;
  --accent-3: #d8c35d;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(240, 93, 67, .13), transparent 32%),
    radial-gradient(circle at 78% 22%, rgba(43, 180, 166, .16), transparent 28%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.stage,
.control-rail,
.preview-panel {
  border: 1px solid var(--line);
  background: rgba(28, 29, 25, .92);
  box-shadow: var(--shadow);
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 20px;
}

.brand-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 850px;
  font-size: clamp(30px, 5vw, 64px);
  line-height: .94;
}

h2 {
  font-size: 24px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr);
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.panel-title span:first-child {
  color: var(--ink);
  font-weight: 750;
}

.drop-zone {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 260px;
  border: 1px dashed #666755;
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .03) 10px, transparent 10px, transparent 20px);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragging {
  border-color: var(--accent-2);
  background-color: rgba(43, 180, 166, .08);
}

.drop-zone strong {
  color: var(--ink);
  font-size: 18px;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent-2);
  font-size: 28px;
}

.drop-zone input,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

video,
canvas {
  width: 100%;
  min-height: 260px;
  max-height: calc(100vh - 190px);
  border-radius: 8px;
  background: #060705;
  object-fit: contain;
}

#sourceVideo,
#outputVideo {
  display: none;
}

.has-video #sourceVideo,
.has-output #outputVideo {
  display: block;
}

.has-video .drop-zone,
.has-output #outputCanvas {
  display: none;
}

.control-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  overflow: auto;
}

.control-header {
  padding-bottom: 4px;
}

.field,
.slider-row {
  display: grid;
  gap: 8px;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.two-col > div {
  display: grid;
  gap: 8px;
}

.slider-row {
  grid-template-columns: 1fr auto;
}

.slider-row input {
  grid-column: 1 / -1;
}

label,
output {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="text"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11120f;
  color: var(--ink);
  padding: 0 12px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fffaf2;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

#sampleButton {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.save-button {
  background: var(--accent-2);
}

.download-link {
  background: var(--accent-3);
  color: #17150d;
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
}

progress::-webkit-progress-bar {
  background: var(--panel-2);
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.thumb-strip canvas {
  min-height: 0;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-rail {
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .stage,
  .control-rail {
    padding: 12px;
  }

  .preview-grid,
  .actions,
  .two-col {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 36px;
    line-height: 1;
  }
}
