:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4efe5;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 15%, rgba(37, 99, 235, 0.14), transparent 20rem),
    radial-gradient(circle at 85% 5%, rgba(236, 72, 153, 0.16), transparent 18rem),
    #f4efe5;
}

button,
a,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100% - 1.5rem, 1120px);
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  border: 2px solid #1f2933;
  border-radius: 1.25rem;
  background: rgba(255, 252, 245, 0.92);
  box-shadow: 8px 8px 0 #1f2933;
  padding: 1rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: #2563eb;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: center;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 2rem);
  gap: 0.35rem;
}

.tool-buttons,
.tabs,
.gallery-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tool-button,
.tab-button,
.like-button,
.save-button,
.sort-control {
  border: 2px solid #1f2933;
  border-radius: 999px;
  background: #fffdf7;
  color: #1f2933;
  font-weight: 900;
  box-shadow: 2px 2px 0 #1f2933;
}

.tool-button,
.tab-button,
.like-button,
.save-button {
  cursor: pointer;
  padding: 0.55rem 0.85rem;
}

.save-button {
  background: #facc15;
}

.save-button:disabled {
  background: #e5e7eb;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.8;
}

.like-button:disabled {
  cursor: default;
  opacity: 0.75;
}

.tool-button {
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  padding: 0;
}

.tool-button span {
  font-size: 1.35rem;
  line-height: 1;
}

.tool-button.selected,
.tab-button.selected {
  background: #dbeafe;
}

.swatch {
  width: 2rem;
  height: 2rem;
  border: 2px solid #1f2933;
  border-radius: 0.5rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 #1f2933;
}

.swatch.selected {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

.custom-color {
  border: 2px solid #1f2933;
  border-radius: 999px;
  background: #fffdf7;
  color: #1f2933;
  font-weight: 800;
}

.tabs {
  margin: 0 0 1rem;
}

.tab-panel {
  display: none;
}

.tab-panel.selected {
  display: block;
}

.custom-color {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.7rem;
}

.custom-color input {
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.canvas-panel {
  overflow: auto;
  border: 2px solid #1f2933;
  border-radius: 1.25rem;
  background: #fffdf7;
  box-shadow: 8px 8px 0 #1f2933;
  padding: 0.75rem;
}

canvas {
  display: block;
  width: min(800px, 100%);
  height: auto;
  margin: 0 auto;
  border: 2px solid #1f2933;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}

canvas.bucket-cursor {
  cursor: cell;
}

.gallery-panel {
  border: 2px solid #1f2933;
  border-radius: 1.25rem;
  background: rgba(255, 252, 245, 0.92);
  box-shadow: 8px 8px 0 #1f2933;
  padding: 1rem;
}

.gallery-header {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.gallery-header h2,
.private-editor h2,
.painting-card h3 {
  margin: 0;
}

.painting-nickname {
  margin: -0.35rem 0 0;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 800;
}

.sort-control {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.7rem;
}

.sort-control select {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: inherit;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.painting-card {
  display: grid;
  gap: 0.75rem;
  border: 2px solid #1f2933;
  border-radius: 1rem;
  background: #fffdf7;
  padding: 0.75rem;
}

.painting-card:hover,
.painting-card:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

.painting-card canvas {
  width: 100%;
  border-radius: 0.65rem;
}

.private-editor {
  width: min(100% - 1rem, 980px);
  max-height: min(92vh, 860px);
  border: 2px solid #1f2933;
  border-radius: 1.25rem;
  background: #fffdf7;
  box-shadow: 8px 8px 0 #1f2933;
  padding: 1rem;
}

.private-editor::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.private-editor-header,
.private-editor-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.private-editor-controls {
  justify-content: flex-start;
}

.close-button {
  border: 2px solid #1f2933;
  border-radius: 999px;
  background: #fffdf7;
  color: #1f2933;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 2px 2px 0 #1f2933;
  padding: 0.55rem 0.85rem;
}

.private-status {
  font-weight: 800;
}

.private-status[data-state="error"] {
  color: #b91c1c;
}

.private-status[data-state="ok"] {
  color: #166534;
}

.private-canvas-wrap {
  overflow: auto;
}

.private-canvas-wrap canvas {
  width: min(800px, 100%);
}

@media (max-width: 880px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .controls {
    justify-self: stretch;
  }

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

@media (max-width: 520px) {
  .swatches {
    grid-template-columns: repeat(4, 2rem);
  }

  .toolbar,
  .canvas-panel,
  .gallery-panel,
  .private-editor {
    box-shadow: 4px 4px 0 #1f2933;
  }
}
.home-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, 0.72);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.home-link:hover,
.home-link:focus-visible {
  background: rgba(56, 189, 248, 0.9);
  outline: none;
}
