:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #fbfcfd;
  --surface-strong: #ffffff;
  --ink: #171717;
  --muted: #6f756f;
  --soft: #eef2f4;
  --line: #d9dee3;
  --line-strong: #c2cad1;
  --accent: #0f766e;
  --accent-dark: #0a5f59;
  --accent-soft: #d8f0ec;
  --gold: #9a6a11;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(25, 24, 20, .10);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

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

button {
  border: 0;
}

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

.workspace,
.settings,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.titleBlock,
.settingsHead {
  display: grid;
  gap: 6px;
}

.eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

h3 {
  color: var(--ink);
  font-size: 13px;
  line-height: 1;
}

.topbar p,
.panelHead p {
  color: var(--muted);
}

.topActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: #4a514b;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
}

.flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px 0;
}

.flowStep {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.flowStep b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #e2e8ed;
  color: var(--ink);
  font-size: 12px;
}

.flowStep.active {
  border-color: #91c7bf;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.flowStep.active b {
  background: var(--accent);
  color: #fff;
}

.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  flex: 1;
  padding: 18px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  box-shadow: none;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.panelHead > div {
  display: grid;
  gap: 5px;
}

.previewFrame {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 500px;
  overflow: hidden;
  background:
    linear-gradient(rgba(23, 23, 23, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 23, 23, .05) 1px, transparent 1px),
    #e9edf1;
  background-size: 18px 18px;
}

.checker {
  background-color: #e7edf1;
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, .06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, .06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, .06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, .06) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.previewFrame::after {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px dashed rgba(23, 23, 23, .18);
  border-radius: 8px;
  pointer-events: none;
}

.previewFrame img,
.previewFrame canvas {
  display: none;
  max-width: calc(100% - 36px);
  max-height: calc(100% - 36px);
  border: 1px solid rgba(23, 23, 23, .16);
  border-radius: 6px;
  background: #111;
  image-rendering: pixelated;
  box-shadow: 0 16px 34px rgba(23, 23, 23, .18);
}

.previewFrame.hasMedia img,
.previewFrame.hasMedia canvas {
  display: block;
}

.previewFrame.hasMedia span {
  display: none;
}

.previewFrame span {
  width: min(260px, calc(100% - 44px));
  color: var(--muted);
  text-align: center;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  overflow: auto;
}

.settingGroup {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
}

.hiddenConfig {
  display: none;
}

.settings label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

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

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

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

button,
.fileBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 7px;
  padding: 9px 13px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, .24);
}

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

.ghost,
.fileBtn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.ghost:hover,
.fileBtn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
  box-shadow: none;
}

.fileBtn input {
  display: none;
}

.status {
  position: sticky;
  bottom: 0;
  border: 1px solid #b8d8d2;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 12px;
  min-height: 48px;
  font-weight: 700;
}

.status.error {
  border-color: #efb5ad;
  background: #fff1ef;
  color: var(--danger);
}

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

  .settings {
    order: -1;
    max-height: none;
  }
}

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

  .panes,
  .flow {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panelHead {
    align-items: flex-start;
    flex-direction: column;
  }

  .topActions {
    width: 100%;
    justify-content: flex-start;
  }

  .primary {
    width: 100%;
  }

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

  .previewFrame {
    min-height: 320px;
  }
}
