.canvas-shell {
  display: grid;
  gap: 1rem;
}

.canvas-topbar {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.canvas-topbar h1 {
  margin: 0;
}

.canvas-subtitle {
  margin: 0.35rem 0 0;
  max-width: 52ch;
}

.save-status {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--rule);
  background: rgba(255, 252, 244, 0.94);
  font-size: 0.84rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid var(--rule);
  background: rgba(255, 252, 244, 0.9);
}

.toolbar-label {
  font-size: 0.78rem;
  letter-spacing: 0.06rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.toolbar-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(35, 29, 22, 0.7);
  background: #fffdf8;
  color: #18130f;
  padding: 0.55rem 2.2rem 0.55rem 0.75rem;
  min-height: 44px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2318130f'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

.toolbar-select:focus {
  outline: 2px solid #18130f;
  outline-offset: 1px;
}

.tool-button {
  appearance: none;
  border: 1px solid rgba(35, 29, 22, 0.7);
  background: #fffdf8;
  color: #18130f;
  padding: 0.55rem 0.85rem;
  min-height: 44px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tool-button:hover {
  background: #fff2c7;
}

.tool-button.is-active {
  background: #18130f;
  color: #fff9ef;
}

/* Color dot buttons — exception to monochrome rule */
.toolbar-group--colors {
  gap: 0.5rem;
  align-items: center;
}

.color-dot {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--dot-color, #111);
  border: 2px solid rgba(35, 29, 22, 0.25);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  flex-shrink: 0;
  position: relative;
}

/* Expand touch target to 44px without affecting layout */
.color-dot::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.color-dot.is-active {
  border-color: transparent;
  box-shadow: 0 0 0 2px #fffdf8, 0 0 0 4px #18130f;
}

.color-dot:disabled {
  opacity: 0.35;
  cursor: default;
}

.size-control {
  display: inline-grid;
  grid-template-columns: auto minmax(8rem, 11rem) auto;
  gap: 0.6rem;
  align-items: center;
}

.size-control input {
  width: 100%;
}

.stage {
  position: relative;
  border: 1px solid var(--rule);
  background: #fbfaf6;
  overflow: hidden;
}

#draw-canvas {
  display: block;
  width: 100%;
  height: 72vh;
  min-height: 72vh;
  touch-action: none;
  background: #fbfaf6;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
}

#draw-canvas.is-pan,
#draw-canvas.is-space-pan {
  cursor: grab;
}

#draw-canvas.is-panning {
  cursor: grabbing;
}

.hud {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  pointer-events: none;
}

.hud-item {
  min-width: 7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(35, 29, 22, 0.65);
  background: rgba(255, 252, 244, 0.93);
}

.hud-label {
  display: block;
  margin-bottom: 0.12rem;
  font-size: 0.72rem;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
}

.canvas-notes {
  margin: 0;
  font-size: 0.92rem;
}

@media (max-width: 900px) {
  .size-control {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  #draw-canvas {
    height: 64vh;
    min-height: 64vh;
  }
}

@media (max-width: 600px) {
  .canvas-topbar h1 {
    font-size: 1.1rem;
  }

  .canvas-subtitle {
    display: none;
  }

  .toolbar {
    gap: 0.5rem;
    padding: 0.6rem;
  }

  .toolbar-group {
    gap: 0.35rem;
  }

  .tool-button {
    padding: 0.55rem 0.65rem;
    font-size: 0.9rem;
  }

  .size-control {
    width: 100%;
    grid-template-columns: auto 1fr auto;
  }

  .hud {
    gap: 0.4rem;
  }

  .hud-item {
    min-width: 5rem;
    padding: 0.4rem 0.5rem;
  }

  .hud-label {
    font-size: 0.65rem;
  }

  #draw-canvas {
    height: calc(100svh - 280px);
    min-height: 300px;
  }

  .canvas-notes {
    display: none;
  }
}
