:root {
  color-scheme: dark;
  --bg: #090a0b;
  --panel: #121314;
  --panel-2: #191a1b;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f1e8;
  --muted: #9d9a90;
  --accent: #86f3e8;
  --accent-2: #ffb35b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 22% 8%, rgba(134, 243, 232, 0.16), transparent 32%),
    radial-gradient(circle at 78% 22%, rgba(255, 179, 91, 0.14), transparent 28%),
    linear-gradient(135deg, #070707, #111111 52%, #17110d);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: rgba(134, 243, 232, 0.7);
  background: rgba(134, 243, 232, 0.12);
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  max-width: 100vw;
  min-height: 100vh;
  padding: 18px;
  overflow-x: hidden;
}

.stage-panel,
.controls {
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(16px);
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.sample-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 520px, calc(100vw - 72px));
  min-width: 0;
}

.actions button {
  padding: 0 12px;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  max-width: 100%;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

canvas {
  display: block;
  width: min(100%, calc((100vh - 108px) * 0.7519), calc(100vw - 76px));
  max-width: 900px;
  height: auto;
  aspect-ratio: 1200 / 1596;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #050505;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}

.drop-zone {
  position: absolute;
  display: grid;
  place-items: center;
  gap: 6px;
  width: min(360px, 42vw);
  min-height: 128px;
  padding: 22px;
  border: 1px dashed rgba(244, 241, 232, 0.45);
  border-radius: 8px;
  background: rgba(5, 5, 5, 0.62);
  color: var(--text);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.drop-zone span {
  color: var(--muted);
  font-size: 12px;
}

.drop-zone.hidden {
  opacity: 0;
  transform: translateY(10px);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-height: calc(100vh - 36px);
  padding: 14px;
  overflow: auto;
}

.upload {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.upload span,
legend {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.upload input {
  max-width: 100%;
  color: var(--muted);
}

.sample-row button {
  flex: 1;
}

fieldset {
  display: grid;
  gap: 11px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

legend {
  padding: 0 6px;
  color: var(--accent);
}

label {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
}

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

input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.colors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.colors label {
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
}

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

  .controls {
    max-height: none;
  }
}

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

  .topbar,
  label {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button {
    width: 100%;
  }

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, calc(100vw - 54px));
  }

  canvas {
    width: min(100%, calc(100vw - 44px));
  }

  .canvas-wrap {
    padding: 10px;
  }
}
