:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #ffffff;
  --panel: #f6f7f9;
  --accent: #2f80ed;
  --danger: #d64045;
}

* {
  box-sizing: border-box;
}

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

body {
  background: #e9edf2;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

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

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

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

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 34%, #fff 35% 46%, transparent 47%),
    linear-gradient(135deg, #2f80ed, #12a150);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 55%);
  flex: 0 0 auto;
}

.tool-row,
.actions {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: 1fr 1fr;
  background: #e4e9f0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #aeb8c7;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgb(47 128 237 / 30%);
  outline-offset: 2px;
}

.tool {
  border: 0;
  background: transparent;
}

.tool.active {
  background: #fff;
  box-shadow: 0 1px 3px rgb(16 24 40 / 16%);
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

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

input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

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

.swatches button {
  min-height: 34px;
  padding: 0;
  background: var(--swatch);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.actions {
  grid-template-columns: 1fr 1fr;
  margin-top: auto;
}

#clear {
  color: var(--danger);
}

#save {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.stage {
  display: grid;
  padding: 18px;
  min-width: 0;
}

canvas {
  width: 100%;
  height: calc(100vh - 36px);
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgb(16 24 40 / 14%);
  touch-action: none;
  cursor: crosshair;
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
    gap: 12px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .actions,
  .tool-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .stage {
    padding: 10px;
  }

  canvas {
    height: calc(100vh - 300px);
    min-height: 360px;
  }
}
