:root {
  color-scheme: dark;
  --bg: #151514;
  --panel: #20201e;
  --panel-2: #292925;
  --ink: #f3efe4;
  --muted: #a9a393;
  --line: #3d3c35;
  --accent: #52d3b6;
  --accent-2: #f2b84b;
  --danger: #ff6b5f;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

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

.panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

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

.mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent), white 15%);
  border-radius: 8px;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 28px;
  font-style: italic;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

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

.file-picker,
button,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
}

.file-picker {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

.control-group label,
.control-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

select {
  width: 100%;
  padding: 0 12px;
}

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

.toggle-row {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.toggle-row input {
  accent-color: var(--accent-2);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

button {
  cursor: pointer;
}

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

#downloadButton {
  color: #14140f;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 700;
}

.stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 100vh;
  padding: clamp(12px, 3vw, 34px);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #111311;
  background-size: 32px 32px;
}

canvas {
  display: block;
  width: min(100%, calc((100vh - 68px) * 4 / 3));
  max-height: calc(100vh - 68px);
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050505;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

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

  .panel {
    gap: 14px;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    gap: 10px;
  }

  .mark {
    width: 38px;
    height: 38px;
    font-size: 24px;
  }

  h1 {
    font-size: 20px;
  }

  .file-picker,
  button,
  select {
    min-height: 38px;
  }

  .control-grid {
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
  }

  .button-row {
    margin-top: 0;
  }

  .stage {
    min-height: auto;
  }

  canvas {
    width: 100%;
    max-height: none;
  }
}
