:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --line: #1a1a1a;
  --line-soft: #dddddd;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "IBM Plex Mono", "SF Mono", "Fira Code", "Menlo", monospace;
  color: var(--fg);
  background: var(--bg);
}

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

.controls,
.preview {
  border: 1px solid var(--line);
  background: #fff;
}

.controls {
  overflow-y: auto;
  padding: 12px;
}

.panel-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.eyebrow {
  display: none;
}

.desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.group {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.group h2 {
  margin: 0 0 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

label {
  display: block;
  margin: 8px 0;
}

label span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 0.76rem;
}

input[type="range"],
input[type="number"],
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--fg);
  padding: 7px 8px;
  font-family: inherit;
  font-size: 0.78rem;
}

input[type="range"] {
  padding: 0;
  accent-color: #000;
}

input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  cursor: pointer;
}

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

.inline-grid label:last-child:nth-child(odd) {
  grid-column: span 2;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.inline-check span {
  margin: 0;
}

.inline-check input {
  width: 14px;
  height: 14px;
  accent-color: #000;
}

.file-upload {
  position: relative;
  display: block;
  border: 1px dashed var(--line);
  background: #fff;
  text-align: center;
  padding: 9px;
  cursor: pointer;
}

.file-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.source-info {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
  word-break: break-all;
}

.single-btn-row {
  margin-top: 8px;
}

.single-btn-row button {
  width: 100%;
}

button {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 10px;
  background: #fff;
  color: #000;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn {
  background: #000;
  color: #fff;
}

.ghost-btn {
  background: #fff;
  color: #000;
}

.action-row {
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.preview {
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.preview-head h2 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.preview-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--line);
  background-color: #f8f8f8;
  background-image:
    radial-gradient(circle, rgba(0, 0, 0, 0.14) 0.7px, transparent 0.8px),
    radial-gradient(circle, rgba(0, 0, 0, 0.08) 0.7px, transparent 0.8px);
  background-size: 12px 12px, 12px 12px;
  background-position: 0 0, 6px 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#previewCanvas {
  max-width: 100%;
  max-height: calc(100vh - 86px);
  width: auto;
  height: auto;
  border: 1px solid #000;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.hint {
  position: absolute;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #000;
  font-size: 0.72rem;
}

.hidden {
  display: none !important;
}

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

  .controls {
    max-height: none;
  }

  #previewCanvas {
    max-height: 72vh;
  }
}
