:root {
  --bg: #e8e4df;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --text: #1f1a17;
  --muted: #7f746b;
  --line: rgba(31, 26, 23, 0.08);
  --shadow: 0 20px 60px rgba(30, 24, 18, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  position: relative;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.35), transparent 24%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
}

.noise,
.grid,
canvas {
  position: absolute;
  inset: 0;
}

.grid {
  pointer-events: none;
  background-image:
    linear-gradient(rgba(31, 26, 23, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 26, 23, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.15));
}

.noise {
  pointer-events: none;
  opacity: 0.08;
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.4) 1px, transparent 0);
  background-size: 18px 18px;
  mix-blend-mode: multiply;
}

#paintCanvas {
  z-index: 3;
  cursor: crosshair;
  touch-action: none;
}

.shell {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px;
  pointer-events: none;
}

.topbar {
  width: min(1180px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(28px, 6vh, 64px);
  gap: 16px;
}

.brand {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(31, 26, 23, 0.82);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(31, 26, 23, 0.05);
}

.brand-time {
  letter-spacing: 0.1em;
}

.brand-label {
  color: var(--muted);
}

.hero {
  width: min(980px, 100%);
  text-align: center;
  padding-top: clamp(24px, 3vh, 48px);
}

h1 {
  margin: 0 auto;
  max-width: 10ch;
  font-size: clamp(2.5rem, 7vw, 6rem);
  line-height: 0.94;
  letter-spacing: -0.06em;
  font-weight: 900;
}

.toolbar-shell {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.toolbar-open {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(31, 26, 23, 0.08);
  background: var(--panel-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(31, 26, 23, 0.07);
  backdrop-filter: blur(12px);
  transition: transform 120ms ease, background 150ms ease, opacity 180ms ease;
  opacity: 0;
  visibility: hidden;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
}

.toolbar-open:hover {
  background: rgba(255, 255, 255, 0.96);
}

.toolbar-open:active {
  transform: translateY(1px) scale(0.99);
}

.toolbar-shell.show-open .toolbar-open {
  opacity: 1;
  visibility: visible;
}

.toolbar {
  width: min(86vw, 760px);
  padding: 12px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid rgba(31, 26, 23, 0.08);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.toolbar-shell.active {
  pointer-events: auto;
}

.toolbar-shell.active .toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-row-top,
.toolbar-row-bottom {
  justify-content: space-between;
}

.group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(31, 26, 23, 0.05);
  min-width: 0;
}

.group-colors {
  flex: 1 1 auto;
}

.modes-group {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.actions-group {
  flex: 0 0 auto;
}

button,
.swatch,
input[type="range"] {
  pointer-events: auto;
}

.toolbar button,
.swatch,
input[type="range"] {
  pointer-events: auto;
}

.toolbar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 150ms ease, transform 120ms ease, color 150ms ease;
  white-space: nowrap;
}

.toolbar button:hover {
  background: rgba(31, 26, 23, 0.06);
}

.toolbar button:active {
  transform: translateY(1px) scale(0.99);
}

.toolbar button.active {
  background: var(--text);
  color: white;
}

.toolbar-close {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  border-radius: 999px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.58) !important;
  border: 1px solid rgba(31, 26, 23, 0.06) !important;
  font-size: 1.25rem !important;
  line-height: 1 !important;
  flex: 0 0 auto;
}

.swatches {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  padding: 0;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch.selected {
  box-shadow: 0 0 0 2px rgba(31, 26, 23, 0.6), 0 2px 10px rgba(0, 0, 0, 0.08);
}

.size-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  flex: 0 0 auto;
}

input[type="range"] {
  width: 108px;
  accent-color: var(--text);
  cursor: ew-resize;
}

@media (max-width: 820px) {
  .toolbar {
    width: min(94vw, 620px);
  }

  .toolbar-row {
    flex-wrap: wrap;
  }

  .group-colors,
  .modes-group,
  .actions-group,
  .size-wrap {
    width: 100%;
    justify-content: center;
  }

  .toolbar-row-top {
    justify-content: center;
  }

  .toolbar-close {
    margin-left: auto;
  }
}

@media (max-width: 740px) {
  .shell {
    padding: 18px;
  }

  .topbar {
    margin-bottom: 28px;
    flex-direction: column;
    justify-content: center;
  }

  .brand {
    font-size: 0.82rem;
  }

  h1 {
    max-width: 12ch;
  }

  .toolbar-shell {
    bottom: 16px;
    width: calc(100vw - 16px);
  }

  .toolbar {
    width: 100%;
    border-radius: 20px;
    padding: 10px;
  }
}
