:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #eef2f6;
  --text: #171b22;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --shadow: 0 16px 44px rgba(21, 28, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto 18px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab-button.active {
  background: var(--accent);
  color: white;
}

.tab-panel {
  display: none;
  max-width: 1440px;
  margin: 0 auto;
}

.tab-panel.active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
}

.preview-panel,
.controls-panel,
.panel-block,
.guide-step,
.source-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-panel {
  min-height: calc(100vh - 126px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

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

h1 {
  font-size: clamp(25px, 3vw, 42px);
  line-height: 1;
}

h2 {
  font-size: 16px;
}

.topbar h2,
.section-heading h2 {
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.05;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--text);
  color: white;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone {
  position: relative;
  flex: 1;
  min-height: 460px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
  border: 1px solid #1f2937;
}

.drop-zone.is-dragging {
  outline: 3px solid rgba(15, 118, 110, 0.32);
}

video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  display: none;
}

.has-video video {
  display: block;
}

.empty-state {
  display: grid;
  gap: 8px;
  text-align: center;
  color: white;
  padding: 24px;
}

.empty-state strong {
  font-size: 26px;
}

.empty-state span {
  color: #cbd5e1;
}

.has-video .empty-state {
  display: none;
}

.video-meta,
.status-row,
.actions,
.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.video-meta {
  min-height: 28px;
  color: var(--muted);
  font-size: 14px;
}

.status-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel-strong);
  border-radius: 8px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: #d8e1ea;
  border-radius: 999px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.actions {
  justify-content: flex-end;
}

.primary,
.secondary {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-dark);
}

.primary:disabled,
.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.secondary {
  color: var(--text);
  background: white;
  border-color: var(--line);
}

.controls-panel {
  max-height: calc(100vh - 126px);
  overflow: auto;
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.control-group {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.recipe-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auto-summary {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.readonly-toggle {
  opacity: 0.78;
}

.download-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel-block {
  padding: 18px;
  display: grid;
  gap: 18px;
}

.section-heading {
  display: grid;
  gap: 3px;
}

.source-form {
  display: grid;
  gap: 14px;
}

.source-form label {
  font-size: 14px;
}

.download-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.source-status {
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: #344054;
  font-size: 14px;
  line-height: 1.45;
}

.source-grid {
  display: grid;
  gap: 12px;
  align-content: start;
}

.source-card {
  padding: 16px;
  display: grid;
  gap: 8px;
}

.source-card strong {
  font-size: 17px;
}

.source-card span {
  color: var(--muted);
  line-height: 1.45;
}

.guide-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.guide-step {
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 230px;
}

.guide-step span {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--accent);
  font-weight: 900;
}

.guide-step h2 {
  font-size: 20px;
  line-height: 1.15;
}

.guide-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

output {
  float: right;
  color: var(--muted);
  font-weight: 700;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--text);
  background: white;
}

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

input:disabled {
  cursor: default;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented label:has(input:checked) {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
}

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

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  cursor: pointer;
}

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

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab-button {
    flex: 1 0 auto;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .download-layout,
  .guide-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: auto;
  }

  .controls-panel {
    max-height: none;
  }

  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .file-button,
  .primary,
  .secondary {
    width: 100%;
  }

  .drop-zone {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .segmented {
    grid-template-columns: repeat(2, 1fr);
  }

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