:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --panel: #ffffff;
  --ink: #1b1b1f;
  --muted: #68635b;
  --line: #ded8cf;
  --accent: #0f766e;
  --accent-2: #b3261e;
  --soft: #e8f2ef;
  --shadow: 0 18px 50px rgba(44, 38, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.13), transparent 35%),
    linear-gradient(315deg, rgba(179, 38, 30, 0.10), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 48px);
}

.controls,
.stage {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(222, 216, 207, 0.92);
  box-shadow: var(--shadow);
}

.controls {
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 6px;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #0f766e 0 50%, transparent 50%),
    linear-gradient(315deg, #b3261e 0 50%, #f2b544 50%);
  border: 1px solid rgba(27, 27, 31, 0.12);
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(222, 216, 207, 0.7);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  min-height: 152px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.check {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  padding: 0 12px;
  color: var(--ink);
  cursor: pointer;
}

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

.check span {
  font-size: 14px;
  color: var(--ink);
}

.advanced {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  overflow: hidden;
}

.advanced summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}

.advanced-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px 12px;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 12px;
}

.primary,
.ghost {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary {
  margin-top: 4px;
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.primary:disabled {
  cursor: progress;
  opacity: 0.68;
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
}

.stage {
  border-radius: 8px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto minmax(120px, 190px);
  gap: 14px;
  min-width: 0;
}

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

.status {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.status strong {
  font-size: 16px;
}

.status span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ghost {
  padding: 0 14px;
  background: #fffdf9;
  border-color: var(--line);
  color: var(--ink);
}

.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, #f0ede7 25%, transparent 25%),
    linear-gradient(-45deg, #f0ede7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0ede7 75%),
    linear-gradient(-45deg, transparent 75%, #f0ede7 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.preview img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: rgba(255, 253, 249, 0.68);
}

.empty {
  text-align: center;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 12px;
}

.spark {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  border: 1px solid rgba(27, 27, 31, 0.12);
  background:
    conic-gradient(from 20deg, #0f766e, #f2b544, #b3261e, #3164a8, #0f766e);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  padding: 12px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metrics strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.timeline {
  margin: 0;
  padding: 12px 12px 12px 32px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.timeline li::marker {
  color: var(--accent);
}

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

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

  .stage {
    min-height: 72vh;
  }
}

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

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

  .ghost {
    width: 100%;
  }
}
