:root {
  color-scheme: dark;
  --bg: #090a0b;
  --surface: #101214;
  --surface-raised: #15181b;
  --surface-soft: #1b1e21;
  --line: #292d31;
  --line-strong: #3a4046;
  --text: #f3f5f7;
  --muted: #8d969f;
  --muted-bright: #b8c0c7;
  --accent: #41d9ff;
  --accent-strong: #10bfe9;
  --accent-ink: #031217;
  --success: #55df9c;
  --danger: #ff6b75;
  --warning: #f5c451;
  --radius: 6px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select,
.checkbox {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 40px 40px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--text);
  color: var(--bg);
  font-size: 18px;
  font-weight: 800;
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 14px;
  letter-spacing: 0;
}

.brand-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.privacy-note,
.result-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-bright);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px rgba(85, 223, 156, 0.7);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 0.92fr) minmax(460px, 1.08fr);
  min-height: calc(100vh - 121px);
  border-bottom: 1px solid var(--line);
}

.control-pane {
  padding: 64px clamp(36px, 5vw, 80px) 64px 0;
  border-right: 1px solid var(--line);
}

.intro {
  max-width: 620px;
  margin-bottom: 56px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  max-width: 580px;
  margin: 0;
  font-size: 62px;
  font-weight: 730;
  line-height: 0.98;
}

.sub {
  max-width: 570px;
  margin: 24px 0 0;
  color: var(--muted-bright);
  font-size: 16px;
  line-height: 1.7;
}

#export-form {
  display: grid;
  gap: 0;
  max-width: 680px;
  border-top: 1px solid var(--line);
}

.form-section {
  padding: 28px 0 30px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.section-heading-inline {
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.heading-copy {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.step-number {
  flex: 0 0 auto;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted-bright);
  font-size: 12px;
  font-weight: 650;
}

.field-grid,
.animation-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.animation-fields {
  margin-top: 18px;
}

.field-group {
  min-width: 0;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 140ms ease, background-color 140ms ease;
}

input {
  padding: 11px 13px;
}

select {
  padding: 10px 38px 10px 13px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted-bright) 50%),
    linear-gradient(135deg, var(--muted-bright) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 19px,
    calc(100% - 12px) 19px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  appearance: none;
}

input:hover,
select:hover {
  border-color: #59616a;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background-color: var(--surface-raised);
}

input::placeholder {
  color: #5f676e;
  opacity: 1;
}

.url-field,
.unit-field {
  position: relative;
}

.url-field input {
  min-height: 54px;
  padding-left: 45px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.url-icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 16px;
  color: var(--accent);
  font-family: var(--font-mono);
  transform: translateY(-50%);
  pointer-events: none;
}

.unit-field input {
  padding-right: 48px;
}

.unit-field > span {
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  transform: translateY(-50%);
  pointer-events: none;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.animation-hint {
  grid-column: 1 / -1;
  margin-top: -2px;
}

.presets {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.preset-btn {
  min-height: 30px;
  margin: 0;
  padding: 5px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.preset-btn:hover {
  color: var(--text);
}

.preset-btn.active {
  background: var(--surface-soft);
  color: var(--accent);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.checkbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted-bright);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.checkbox:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.checkbox:has(input:checked) {
  border-color: rgba(65, 217, 255, 0.36);
  background: rgba(65, 217, 255, 0.055);
  color: var(--text);
}

.checkbox input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.checkbox span {
  min-width: 0;
  font-size: 13px;
}

.toggle-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.toggle-row {
  align-items: flex-start;
  min-height: 58px;
}

.toggle-row input {
  margin-top: 3px;
}

.toggle-row span {
  display: grid;
  gap: 2px;
}

.toggle-row strong {
  font-size: 13px;
  font-weight: 650;
}

.toggle-row small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.checkbox:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}

.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 28px;
}

.submit-row p {
  max-width: 310px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

#submit-btn,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-width: 172px;
  min-height: 48px;
  margin: 0;
  padding: 11px 14px 11px 17px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

#submit-btn:hover,
.download-link:hover {
  border-color: #80e7ff;
  background: #80e7ff;
  transform: translateY(-1px);
}

#submit-btn:disabled {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: wait;
  transform: none;
}

.button-arrow {
  font-size: 18px;
  font-weight: 500;
}

.result-pane {
  min-width: 0;
  padding: 64px 0 64px clamp(36px, 5vw, 80px);
}

.result-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.result-header .eyebrow {
  margin-bottom: 6px;
}

.result-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.result-state {
  padding-bottom: 2px;
}

.result-state::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.result-state.processing::before {
  background: var(--warning);
  box-shadow: 0 0 10px rgba(245, 196, 81, 0.5);
  animation: pulse 1.4s ease-in-out infinite;
}

.result-state.complete::before {
  background: var(--success);
}

.result-state.failed::before {
  background: var(--danger);
}

.result-stage {
  position: sticky;
  top: 32px;
  display: grid;
  min-height: min(680px, calc(100vh - 210px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(65, 217, 255, 0.025), transparent 38%),
    var(--surface);
}

.result-stage::before {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--accent);
  content: "";
  opacity: 0.7;
}

.empty-state {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 48px;
  text-align: center;
}

.capture-frame {
  position: relative;
  display: grid;
  width: min(210px, 55%);
  aspect-ratio: 1;
  margin-bottom: 28px;
  place-items: center;
}

.capture-frame::before,
.capture-frame::after {
  position: absolute;
  background: var(--line);
  content: "";
}

.capture-frame::before {
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
}

.capture-frame::after {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
}

.frame-corner {
  position: absolute;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-color: var(--line-strong);
  border-style: solid;
}

.corner-tl { top: 0; left: 0; border-width: 1px 0 0 1px; }
.corner-tr { top: 0; right: 0; border-width: 1px 1px 0 0; }
.corner-bl { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.corner-br { right: 0; bottom: 0; border-width: 0 1px 1px 0; }

.media-glyph {
  position: relative;
  z-index: 2;
  color: #252a2e;
  font-size: 64px;
  font-weight: 850;
}

.empty-state h3 {
  margin: 0;
  font-size: 16px;
}

.empty-state p {
  max-width: 300px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 18px;
  left: 20px;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(16, 18, 20, 0.94);
  color: var(--muted-bright);
  font-family: var(--font-mono);
  font-size: 11px;
  backdrop-filter: blur(8px);
}

.status::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
  animation: pulse 1.4s ease-in-out infinite;
}

.status.error {
  border-color: rgba(255, 107, 117, 0.5);
  color: var(--danger);
}

.status.error::before {
  background: var(--danger);
  animation: none;
}

.status.done {
  border-color: rgba(85, 223, 156, 0.45);
  color: var(--success);
}

.status.done::before {
  background: var(--success);
  animation: none;
}

.preview {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 32px 32px 94px;
}

.preview img,
.preview video {
  display: block;
  max-width: 100%;
  max-height: min(570px, calc(100vh - 300px));
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #000;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

.preview > p {
  margin: 0;
  padding: 32px;
  border: 1px dashed var(--line-strong);
  color: var(--muted-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
}

.preview .download-link {
  position: absolute;
  right: 20px;
  bottom: 20px;
  min-width: 150px;
  min-height: 42px;
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (max-width: 1080px) {
  .app-shell {
    padding-inline: 28px;
  }

  .workspace {
    grid-template-columns: minmax(460px, 1fr) minmax(360px, 0.9fr);
  }

  .control-pane {
    padding-right: 40px;
  }

  h1 {
    font-size: 52px;
  }

  .result-pane {
    padding-left: 40px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 0 22px 32px;
  }

  .workspace {
    display: block;
  }

  .control-pane {
    padding: 48px 0 54px;
    border-right: 0;
  }

  .intro {
    margin-bottom: 42px;
  }

  #export-form {
    max-width: none;
  }

  .result-pane {
    padding: 48px 0 0;
    border-top: 1px solid var(--line);
  }

  .result-stage {
    position: relative;
    top: auto;
    min-height: 520px;
  }
}

@media (max-width: 580px) {
  body {
    font-size: 14px;
  }

  .app-shell {
    padding-inline: 16px;
  }

  .masthead {
    min-height: 68px;
  }

  .brand-copy span {
    display: none;
  }

  .privacy-note {
    font-size: 9px;
  }

  .control-pane {
    padding-top: 38px;
  }

  h1 {
    font-size: 40px;
  }

  .sub {
    margin-top: 18px;
    font-size: 14px;
  }

  .field-grid,
  .animation-fields,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .section-heading-inline {
    align-items: flex-start;
    flex-direction: column;
  }

  .presets {
    width: 100%;
  }

  .submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  #submit-btn {
    width: 100%;
  }

  .result-stage {
    min-height: 430px;
  }

  .empty-state {
    padding: 30px;
  }

  .preview {
    padding: 20px 20px 82px;
  }

  .preview img,
  .preview video {
    max-height: 480px;
  }

  .preview .download-link {
    right: 14px;
    bottom: 14px;
    left: 16px;
    width: auto;
  }

  .status {
    right: 12px;
    bottom: 12px;
    left: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
