:root {
  color-scheme: light;
  --bg: #f3f0ea;
  --panel: #ffffff;
  --ink: #1d2328;
  --muted: #65717b;
  --line: #d9d7d1;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --warn: #b45309;
  --shadow: 0 20px 60px rgba(29, 35, 40, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  max-width: 1480px;
  margin: 0 auto;
}

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

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  min-height: calc(100vh - 48px);
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  padding: 24px;
  border: 1px dashed #9aa3aa;
  border-radius: 8px;
  background: #f9faf8;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent);
  background: #eef8f6;
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

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

.drop-note {
  color: var(--muted);
  font-size: 13px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-group label,
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

.control-group strong {
  color: var(--ink);
}

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

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink);
}

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

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

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

.stats {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 5px;
  gap: 10px;
  min-height: calc(100vh - 48px);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 560px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #ebe8e1 25%, transparent 25%),
    linear-gradient(-45deg, #ebe8e1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ebe8e1 75%),
    linear-gradient(-45deg, transparent 75%, #ebe8e1 75%);
  background-color: #f8f7f3;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 90px);
  background: #fff;
  box-shadow: 0 10px 32px rgba(29, 35, 40, 0.18);
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
}

.placeholder.hidden {
  display: none;
}

.progress-shell {
  overflow: hidden;
  height: 5px;
  border-radius: 99px;
  background: #ddd7ce;
}

#progressBar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 120ms ease;
}

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

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

  .controls,
  .stage {
    min-height: auto;
  }

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

  canvas {
    max-height: 68vh;
  }
}
