:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --text: #172026;
  --muted: #66747f;
  --line: #d8e0e6;
  --line-strong: #bcc8d1;
  --accent: #0f7b74;
  --accent-strong: #0a5f59;
  --violet: #6d57c8;
  --danger: #b34242;
  --warning: #a86217;
  --success: #197d45;
  --shadow: 0 18px 45px rgba(24, 36, 48, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(244, 246, 248, 0.96)),
    repeating-linear-gradient(90deg, rgba(15, 123, 116, 0.05) 0 1px, transparent 1px 96px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.compose-pane,
.result-pane {
  min-width: 0;
}

.compose-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-pane {
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto auto minmax(120px, auto);
  gap: 14px;
}

.topbar,
.creator-form,
.job-panel,
.preview-surface,
.output-actions,
.service-panel,
.recent-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.status-pill,
.job-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warning);
}

.status-pill[data-state="online"] .status-dot {
  background: var(--success);
}

.status-pill[data-state="offline"] .status-dot {
  background: var(--danger);
}

.creator-form {
  padding: 18px;
}

.field-block,
.field {
  display: block;
}

.field-block > span,
.field > span {
  display: block;
  margin-bottom: 7px;
  color: #35444f;
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 116, 0.16);
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 13px;
  line-height: 1.55;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.chip {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--surface-2);
  color: #26343d;
  font-size: 13px;
  font-weight: 700;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

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

.action-row,
.output-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.action-row {
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.download-link,
.recent-header button {
  min-height: 40px;
  border-radius: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: #fff;
}

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

.button-icon {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 15px 0 0 rgba(255, 255, 255, 0.72);
}

.secondary-button,
.recent-header button {
  background: #fff;
  border-color: var(--line-strong);
  color: #2d3b45;
}

.download-link {
  display: inline-flex;
  align-items: center;
  color: #fff;
  background: var(--violet);
}

.job-panel,
.service-panel,
.recent-panel {
  padding: 16px;
}

.job-header,
.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.job-badge[data-state="queued"] {
  color: var(--warning);
  border-color: rgba(168, 98, 23, 0.3);
}

.job-badge[data-state="running"] {
  color: var(--accent);
  border-color: rgba(15, 123, 116, 0.32);
}

.job-badge[data-state="succeeded"] {
  color: var(--success);
  border-color: rgba(25, 125, 69, 0.32);
}

.job-badge[data-state="failed"],
.job-badge[data-state="canceled"] {
  color: var(--danger);
  border-color: rgba(179, 66, 66, 0.32);
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  margin: 16px 0;
  overflow: hidden;
  background: #e3e9ee;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  transition: width 240ms ease;
}

.meta-grid,
.service-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.service-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dd {
  margin: 4px 0 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
}

.error-text {
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
  line-height: 1.45;
}

.preview-surface {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(15, 123, 116, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(109, 87, 200, 0.12), transparent 34%),
    #0f1519;
}

.preview-empty {
  max-width: 360px;
  padding: 28px;
  color: #e9eef1;
  text-align: center;
}

.preview-empty p {
  margin: 9px 0 0;
  color: #b8c4cc;
}

.film-mark {
  display: grid;
  grid-template-columns: repeat(4, 36px);
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}

.film-mark span {
  display: block;
  aspect-ratio: 16 / 10;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 4px;
}

video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 190px);
  object-fit: contain;
  background: #05080a;
}

.output-actions {
  padding: 12px;
}

.service-panel {
  display: block;
}

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

.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.recent-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.recent-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

  .result-pane {
    grid-template-rows: minmax(320px, auto) auto auto auto;
  }
}

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

  .topbar,
  .job-header,
  .recent-header {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 22px;
  }

  .settings-grid,
  .meta-grid,
  .service-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 460px) {
  .settings-grid,
  .meta-grid,
  .service-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .download-link {
    width: 100%;
    justify-content: center;
  }
}
