:root {
  color-scheme: light;
  --ink: #17191f;
  --muted: #646b77;
  --line: #d9dde5;
  --panel: #ffffff;
  --paper: #f6f4ef;
  --accent: #0c7c86;
  --accent-strong: #09656d;
  --gold: #d99f22;
  --rose: #d9536f;
  --shadow: 0 18px 50px rgba(30, 35, 45, 0.12);
}

* {
  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(12, 124, 134, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(217, 83, 111, 0.11), transparent 36%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

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

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

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 4px solid var(--ink);
  background:
    linear-gradient(90deg, var(--gold) 0 50%, var(--rose) 50%),
    var(--accent);
  box-shadow: inset 0 0 0 5px #fff;
  image-rendering: pixelated;
}

h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 154px;
  padding: 18px;
  border: 2px dashed #b7beca;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f0f2f5 25%, transparent 25%),
    linear-gradient(-45deg, #f0f2f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f2f5 75%),
    linear-gradient(-45deg, transparent 75%, #f0f2f5 75%);
  background-color: #fff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  cursor: pointer;
  text-align: center;
}

.drop-zone.dragging {
  border-color: var(--accent);
  outline: 3px solid rgba(12, 124, 134, 0.18);
}

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

.drop-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-size: 1.6rem;
  line-height: 1;
}

.drop-title {
  display: block;
  font-weight: 700;
}

.drop-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.83rem;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  min-width: 0;
}

label > span,
figcaption {
  display: block;
  margin-bottom: 6px;
  color: #3a414d;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input[type="number"],
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
}

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

output {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.checkline {
  display: flex;
  grid-column: span 2;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.checkline span {
  margin: 0;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

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

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

#downloadBtn {
  color: var(--ink);
  background: var(--gold);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-width: 0;
}

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

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(45deg, #e9edf2 25%, transparent 25%),
    linear-gradient(-45deg, #e9edf2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9edf2 75%),
    linear-gradient(-45deg, transparent 75%, #e9edf2 75%);
  background-color: #fff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.canvas-wrap.empty canvas {
  display: none;
}

.canvas-wrap.empty span {
  color: var(--muted);
  font-weight: 700;
}

.canvas-wrap:not(.empty) span {
  display: none;
}

canvas {
  max-width: 100%;
  max-height: 76vh;
  image-rendering: pixelated;
}

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

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

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

  .control-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .checkline {
    grid-column: span 1;
  }
}
