:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66727d;
  --line: #d8e0e5;
  --paper: #f7f4ee;
  --panel: #ffffff;
  --teal: #007c82;
  --teal-dark: #005e65;
  --coral: #d95c47;
  --gold: #dba52d;
  --shadow: 0 18px 48px rgba(33, 45, 52, 0.14);
}

* {
  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;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(0, 124, 130, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(217, 92, 71, 0.13), transparent 34%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  place-items: center;
}

.workspace {
  width: 100%;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(216, 224, 229, 0.9);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 92px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
}

h2 {
  font-size: 15px;
}

.file-button,
.download-button,
.ghost-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.file-button {
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background: var(--teal);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 640px;
}

.preview-panel {
  min-width: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.canvas-wrap {
  position: relative;
  min-height: 520px;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background-color: #f3f7f7;
  background-image:
    linear-gradient(45deg, #dce5e5 25%, transparent 25%),
    linear-gradient(-45deg, #dce5e5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce5e5 75%),
    linear-gradient(-45deg, transparent 75%, #dce5e5 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.canvas-wrap.is-dragging {
  outline: 4px solid rgba(0, 124, 130, 0.28);
}

canvas {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 210px);
  object-fit: contain;
}

.empty-state {
  position: absolute;
  inset: 26px;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 24px;
}

.sample-chip {
  justify-self: center;
  padding: 7px 10px;
  background: rgba(219, 165, 45, 0.22);
  color: #6f4b00;
  font-size: 12px;
  font-weight: 800;
}

.status-line {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--teal-dark);
  background: transparent;
  border: 1px solid var(--line);
}

.ghost-button.wide {
  width: 100%;
}

.controls {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-left: 1px solid var(--line);
  background: rgba(249, 251, 250, 0.92);
}

.control-block {
  padding: 16px;
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.block-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.block-title svg,
button svg,
.file-button svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.format-grid label {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.format-grid input {
  position: absolute;
  opacity: 0;
}

.format-grid label:has(input:checked) {
  color: #fff;
  background: var(--coral);
  border-color: var(--coral);
}

.range-row,
.switch-row,
.split-row label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

input[type="number"],
input[type="color"],
.text-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

input[type="color"] {
  padding: 4px;
}

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

input[type="checkbox"] {
  width: 42px;
  height: 24px;
  accent-color: var(--teal);
}

.download-button {
  min-height: 52px;
  margin-top: auto;
  color: #fff;
  background: var(--teal-dark);
}

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

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

  .workspace {
    min-height: 100vh;
    border: 0;
  }

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

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

  .controls {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .canvas-wrap {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .preview-panel,
  .controls,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .status-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .split-row,
  .format-grid {
    grid-template-columns: 1fr;
  }
}
