:root {
  color-scheme: light;
  --ink: #1b2422;
  --muted: #63706b;
  --line: #d8dfdc;
  --panel: #fbfcfb;
  --control: #ffffff;
  --accent: #147d5d;
  --accent-strong: #0b5d45;
  --warning: #895b10;
  --shadow: 0 12px 36px rgba(24, 37, 33, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.86)),
    repeating-linear-gradient(45deg, #e9eeeb 0 12px, #f6f8f7 12px 24px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
}

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

button:hover:not(:disabled),
.file-button:hover {
  border-color: var(--accent);
}

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

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
}

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

.file-button,
.actions button,
.preset,
#resetButton {
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

#downloadButton {
  background: #202927;
  color: #fff;
  border-color: #202927;
}

.stage-wrap {
  display: grid;
  min-height: 0;
  padding: 28px;
}

.canvas-panel {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background-color: #fff;
}

.canvas-panel.checker {
  background-image:
    linear-gradient(45deg, #dfe5e2 25%, transparent 25%),
    linear-gradient(-45deg, #dfe5e2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe5e2 75%),
    linear-gradient(-45deg, transparent 75%, #dfe5e2 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

canvas {
  display: block;
  max-width: min(100%, 1100px);
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  image-rendering: auto;
}

.drop-hint {
  position: absolute;
  inset: auto;
  display: grid;
  place-items: center;
  width: min(460px, calc(100% - 40px));
  min-height: 120px;
  padding: 24px;
  border: 2px dashed #9ba9a4;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
  font-weight: 700;
}

.canvas-panel.has-image .drop-hint {
  display: none;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  overflow: auto;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

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

.control-group.compact {
  gap: 8px;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#resetButton {
  min-height: 34px;
  color: var(--muted);
  background: #f6f8f7;
}

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

.preset {
  min-height: 42px;
  background: #f8faf9;
}

.preset.is-active {
  border-color: var(--accent);
  background: #e5f4ee;
  color: var(--accent-strong);
}

.check-row,
.color-row,
.slider-row {
  display: grid;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-row {
  grid-template-columns: 20px 1fr;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.color-row {
  grid-template-columns: 1fr 48px;
}

.color-row input {
  width: 48px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
}

.slider-row {
  grid-template-columns: minmax(90px, 1fr) 42px;
}

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

output {
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

#statusText {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.is-dragging .canvas-panel {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 125, 93, 0.14), var(--shadow);
}

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

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

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

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

  .stage-wrap {
    padding: 18px;
  }

  .canvas-panel {
    min-height: 340px;
  }

  canvas {
    max-height: 62vh;
  }
}
