:root {
  color-scheme: light;
  --page: #f5f7f8;
  --ink: #1b2528;
  --muted: #607076;
  --panel: #ffffff;
  --border: #cfd8dc;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b45309;
  --shadow: 0 18px 48px rgba(14, 29, 34, 0.14);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

.controls,
.preview-area {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
}

.brand {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.15;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0 0 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
}

fieldset:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

legend {
  margin-bottom: 10px;
  padding: 0;
  color: var(--ink);
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input[type="number"],
select {
  padding: 6px 10px;
}

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

input[type="color"] {
  height: 42px;
  padding: 3px;
}

output {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.construction-output {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.two-up,
.swatches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.swatches {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.preset-list {
  display: grid;
  gap: 8px;
}

.preset-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 650;
}

.preset-option input {
  min-height: 18px;
}

.preset-option small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent-strong);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

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

button:disabled {
  border-color: var(--border);
  background: #d7e0e3;
  color: #77868c;
  cursor: wait;
}

#clearExportsButton {
  border-color: var(--border);
  background: #fff;
  color: var(--ink);
}

#clearExportsButton:hover {
  background: #eef3f4;
}

.preview-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: 16px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding-bottom: 14px;
}

.preview-toolbar strong {
  display: block;
}

.preview-toolbar span,
.warning {
  color: var(--muted);
  font-size: 0.88rem;
}

.warning {
  max-width: 46rem;
  color: var(--danger);
  text-align: right;
}

.canvas-frame {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(20, 30, 34, 0.07) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(20, 30, 34, 0.07) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(20, 30, 34, 0.07) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(20, 30, 34, 0.07) 75%);
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 116px);
  width: auto;
  height: auto;
}

.export-output {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding-top: 14px;
}

.export-output:empty {
  display: none;
}

.export-link {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent-strong);
  background: #fff;
  text-decoration: none;
  font-weight: 750;
}

.export-link small {
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.export-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

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

  .controls {
    max-height: none;
  }

  .preview-area {
    min-height: 70vh;
  }

  .preview-toolbar {
    display: grid;
  }

  .warning {
    text-align: left;
  }
}

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