:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --ink: #1d2527;
  --muted: #657170;
  --line: #d7d4ca;
  --panel: #fffdf8;
  --panel-2: #eef6f3;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --warn: #a9571d;
  --bad: #a3333d;
  --good: #1d7a49;
  --shadow: 0 18px 50px rgba(29, 37, 39, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.85), rgba(245, 243, 238, 0.95)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.05) 0 1px, transparent 1px 72px);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 54px) 18px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.top-actions,
.download-actions,
.runbar,
.dialog-actions,
.job-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  min-width: 112px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.status-pill.ready {
  color: var(--good);
  border-color: rgba(29, 122, 73, 0.3);
  background: rgba(29, 122, 73, 0.08);
}

.status-pill.missing {
  color: var(--warn);
  border-color: rgba(169, 87, 29, 0.3);
  background: rgba(169, 87, 29, 0.08);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(390px, 1.05fr);
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 54px) 38px;
}

.composer,
.results {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.composer {
  padding: 18px;
}

.results {
  padding: 18px;
  min-height: 640px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  background: #f0eee7;
}

.tab {
  min-height: 42px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.mode-pane {
  display: none;
}

.mode-pane.active {
  display: block;
}

.field-label,
.control span {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.prompt-area,
.wide-input,
select,
input[type="number"],
input[type="password"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.prompt-area {
  min-height: 188px;
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
}

.prompt-area.bulk {
  min-height: 230px;
}

.prompt-area.compact-area {
  min-height: 116px;
}

.wide-input,
select,
input[type="number"],
input[type="password"],
input[type="text"] {
  min-height: 42px;
  padding: 0 11px;
}

.prompt-area:focus,
.wide-input:focus,
select:focus,
input:focus {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.option-grid,
.prompt-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.prompt-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.file-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 10px;
  margin: 10px 0 16px;
}

.thumb {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.thumb figcaption {
  overflow-wrap: anywhere;
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.consistency-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.control {
  min-width: 0;
}

.control.compact {
  width: 106px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 720;
}

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

.runbar {
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.button,
.mini {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

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

.button.secondary,
.mini {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button:disabled,
.mini:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button:not(:disabled):hover,
.mini:not(:disabled):hover {
  transform: translateY(-1px);
}

.results-head,
.job-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.summary {
  margin: 16px 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 12px;
  line-height: 1.35;
}

.job-list {
  display: grid;
  gap: 12px;
}

.job {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.job-state {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 840;
  text-transform: uppercase;
}

.job[data-state="ready"] .job-state {
  color: var(--good);
}

.job[data-state="error"] .job-state {
  color: var(--bad);
}

.job[data-state="running"] .job-state {
  color: var(--accent);
}

.job-prompt {
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.video-slot {
  min-height: 126px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #faf8f1, #edf6f4);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.video-slot video {
  width: 100%;
  max-height: 320px;
  display: block;
  background: #111;
}

.video-slot:empty::before {
  content: "Waiting for video";
  color: var(--muted);
  font-size: 0.9rem;
}

.job-error {
  display: none;
  margin: 12px 0 0;
  color: var(--bad);
  line-height: 1.4;
  white-space: pre-line;
}

.job[data-state="error"] .job-error {
  display: block;
}

.mini {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.key-dialog {
  width: min(520px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.key-dialog::backdrop {
  background: rgba(29, 37, 39, 0.45);
}

.dialog-body {
  padding: 20px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

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

@media (max-width: 640px) {
  .topbar,
  .results-head,
  .job-top {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .download-actions,
  .runbar {
    width: 100%;
  }

  .button,
  .top-actions .status-pill,
  .download-actions .button,
  .runbar .button {
    flex: 1 1 auto;
  }

  .option-grid,
  .prompt-tools {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .block-head {
    flex-direction: column;
    align-items: stretch;
  }
}
