:root {
  --ink: #161511;
  --paper: #f7f2e8;
  --panel: #fffaf1;
  --line: #25221a;
  --muted: #6f685d;
  --accent: #0e7c66;
  --accent-2: #e84d2a;
  --tile: #ece4d5;
  --shadow: 10px 10px 0 #161511;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  background:
    linear-gradient(90deg, rgba(22, 21, 17, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(22, 21, 17, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input {
  font: inherit;
}

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

.tool-panel,
.workspace {
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  align-self: start;
  position: sticky;
  top: 28px;
  padding: 28px;
}

.brand-block {
  border-bottom: 2px solid var(--line);
  padding-bottom: 22px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 12ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 44px;
  line-height: 0.96;
}

.drop-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 188px;
  margin: 24px 0;
  padding: 24px;
  border: 2px dashed var(--line);
  background:
    linear-gradient(45deg, var(--tile) 25%, transparent 25%),
    linear-gradient(-45deg, var(--tile) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--tile) 75%),
    linear-gradient(-45deg, transparent 75%, var(--tile) 75%);
  background-color: #fffdf8;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
  cursor: pointer;
  text-align: center;
}

.drop-zone.dragging {
  border-style: solid;
  outline: 4px solid rgba(14, 124, 102, 0.18);
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 2px solid var(--line);
  background: var(--accent);
  color: #fffaf1;
  font-size: 38px;
  line-height: 1;
}

.drop-title {
  font-size: 18px;
  font-weight: 900;
}

.drop-note {
  max-width: 31ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.controls {
  display: grid;
  gap: 16px;
}

.controls label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

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

.controls input[type="text"],
.controls input[type="number"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 2px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  outline: none;
}

.controls input[type="range"] {
  grid-column: 1 / 2;
  width: 100%;
  accent-color: var(--accent);
}

.controls input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent-2);
}

.controls .toggle-row {
  grid-template-columns: 1fr auto;
  padding: 10px 0;
  border-top: 2px solid rgba(37, 34, 26, 0.14);
  border-bottom: 2px solid rgba(37, 34, 26, 0.14);
}

.controls output {
  color: var(--ink);
  font-weight: 900;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

button {
  min-height: 44px;
  border: 2px solid var(--line);
  background: var(--ink);
  color: #fffaf1;
  cursor: pointer;
  font-weight: 900;
}

button:disabled {
  background: #cbc3b3;
  color: #706a60;
  cursor: not-allowed;
}

#downloadButton:not(:disabled) {
  background: var(--accent-2);
}

.status {
  min-height: 44px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 2px solid var(--line);
  overflow: auto;
  background:
    linear-gradient(45deg, #d8cfbf 25%, transparent 25%),
    linear-gradient(-45deg, #d8cfbf 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8cfbf 75%),
    linear-gradient(-45deg, transparent 75%, #d8cfbf 75%);
  background-color: #fffdf8;
  background-position:
    0 0,
    0 14px,
    14px -14px,
    -14px 0;
  background-size: 28px 28px;
}

#sourceCanvas {
  display: none;
  max-width: 100%;
  height: auto;
}

.has-image #sourceCanvas {
  display: block;
}

.has-image .empty-state {
  display: none;
}

.empty-state {
  color: var(--muted);
  font-weight: 900;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 14px;
}

.results-head h2 {
  font-size: 22px;
}

#countBadge {
  border: 2px solid var(--line);
  padding: 5px 10px;
  background: #fffdf8;
  font-weight: 900;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 14px;
}

.cut-card {
  border: 2px solid var(--line);
  background: #fffdf8;
}

.cut-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 10px;
  border-bottom: 2px solid var(--line);
  border-left: 0;
  border-right: 0;
  border-top: 0;
  background:
    linear-gradient(45deg, #eee8dc 25%, transparent 25%),
    linear-gradient(-45deg, #eee8dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee8dc 75%),
    linear-gradient(-45deg, transparent 75%, #eee8dc 75%);
  background-color: #fffdf8;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

button.cut-preview {
  color: inherit;
}

.cut-preview:hover,
.cut-preview:focus-visible {
  outline: 4px solid rgba(232, 77, 42, 0.24);
  outline-offset: -4px;
}

.cut-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.cut-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 900;
}

.cut-meta span:last-child {
  color: var(--muted);
  white-space: nowrap;
}

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

  .tool-panel {
    position: static;
  }

  h1 {
    max-width: 15ch;
    font-size: 34px;
  }
}
