:root {
  color-scheme: light;
  --ink: #1e2329;
  --muted: #68707c;
  --line: #d8dde3;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --accent: #1d7f74;
  --accent-strong: #145f58;
  --shadow: 0 18px 54px rgba(34, 40, 48, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(90deg, rgba(29, 127, 116, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(214, 74, 65, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  padding: 32px;
}

.color-screen {
  display: grid;
  place-items: center;
}

.panel {
  width: min(620px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  margin: 16px 0 24px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.color-swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid rgba(30, 35, 41, 0.14);
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.color-swatch:hover {
  transform: translateY(-2px);
}

.color-swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(29, 127, 116, 0.2);
}

.color-swatch.selected::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-left: 0;
  border-top: 0;
  transform: rotate(45deg);
}

.custom-color,
.tool-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.custom-color {
  justify-content: space-between;
  padding: 14px 0 24px;
  border-top: 1px solid var(--line);
}

input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 24px rgba(29, 127, 116, 0.2);
}

.primary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button.compact {
  width: auto;
  min-width: 112px;
}

.secondary-button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.secondary-button:hover {
  background: #edf0f2;
}

.drawing-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(34, 40, 48, 0.08);
}

.toolbar h1 {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.range-control {
  min-width: 190px;
}

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

output {
  min-width: 2ch;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #edf0f2;
  color: var(--ink);
  font-size: 1.45rem;
}

.canvas-wrap {
  min-height: 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #fff;
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}

@media (max-width: 720px) {
  .screen {
    padding: 16px;
  }

  .panel {
    padding: 22px;
  }

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

  .tools {
    justify-content: flex-start;
  }

  .range-control {
    flex: 1 1 100%;
  }

  .primary-button.compact {
    flex: 1 1 100%;
  }

  .secondary-button {
    flex: 1 1 100%;
  }

  canvas {
    min-height: 520px;
  }
}

.hidden {
  display: none;
}
