:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: #f4f3ef;
  --panel-2: #ffffff;
  --ink: #202020;
  --muted: #8c8c88;
  --rule: #dedbd2;
  --stage: #10100f;
  --accent: #57d47a;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

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

.controls {
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #2a2a28;
  background: var(--panel);
  color: var(--ink);
}

.brand {
  display: flex;
  gap: 12px;
  padding: 18px 18px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel-2);
}

.mark {
  width: 30px;
  height: 30px;
  border: 2px solid #191919;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #191919;
}

.eyebrow {
  margin: 0 0 4px;
  color: #4f8c5d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.22rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.panel {
  padding: 16px 18px 18px;
  border-bottom: 1px solid var(--rule);
}

.panel.closed > :not(.panel-header) {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: #9b9992;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.collapse {
  width: auto;
  min-height: 0;
  border: 0;
  background: transparent;
  color: #9b9992;
  padding: 0;
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px dashed #aaa69d;
  border-radius: 4px;
  background: #fff;
  color: #202020;
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.preset-row,
.button-row,
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.preset-row {
  grid-template-columns: 1fr 1fr 1fr;
}

.control {
  margin-top: 12px;
}

.control label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #6f6d67;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.control output {
  color: #333;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  accent-color: #8c8b87;
}

button,
.toggle {
  min-height: 36px;
  width: 100%;
  border: 1px solid #d5d1c8;
  border-radius: 0;
  background: #f8f7f4;
  color: #333;
  cursor: pointer;
}

.toggle.active {
  border-color: #111;
  background: #1c1c1b;
  color: #fff;
}

.mini-button {
  min-height: 32px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.color-picker {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.color-well {
  position: relative;
  display: block;
  min-height: 50px;
  border: 1px solid #d5d1c8;
  background:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-color: #fff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  cursor: pointer;
}

.color-well input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.color-well span {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: var(--accent);
}

.hex-field {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  border: 1px solid #d5d1c8;
  background: #fff;
}

.hex-field span {
  display: grid;
  place-items: center;
  border-right: 1px solid #e7e3da;
  color: #4a4944;
}

.hex-field input {
  width: 100%;
  border: 0;
  background: #f7f6f2;
  color: #202020;
  padding: 0 12px;
  font-size: 1rem;
  text-transform: uppercase;
}

.text-field {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  align-items: center;
  margin-top: 8px;
  border: 1px solid #d5d1c8;
  background: #fff;
}

.text-field span {
  padding-left: 10px;
  color: #6f6d67;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.text-field input {
  min-width: 0;
  min-height: 34px;
  border: 0;
  border-left: 1px solid #e7e3da;
  background: #f7f6f2;
  color: #202020;
  padding: 0 10px;
}

.select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #d5d1c8;
  background: #fff;
  color: #333;
  padding: 0 12px;
}

.segmented button.active {
  background: #1c1c1b;
  color: #fff;
  border-color: #111;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 100vh;
  padding: 24px;
  background: var(--stage);
  color: #f2f0e9;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 18px;
}

.toolbar h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
  letter-spacing: 0;
}

.palette {
  display: flex;
  gap: 8px;
}

.color {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 1px solid #555;
  border-radius: 50%;
  background: var(--color);
}

.color.active {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.custom-chip {
  border-radius: 8px;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  border: 1px solid #2d2d2a;
  background: #050505;
  overflow: hidden;
}

canvas {
  display: block;
  width: auto;
  height: min(100%, calc(100vh - 118px));
  max-width: 100%;
  background: #0a0a09;
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .controls {
    height: auto;
    max-height: 58vh;
  }

  .stage {
    min-height: 70vh;
    padding: 16px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
