:root {
  color-scheme: light;
  --ink: #25211d;
  --muted: #766f67;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: #d8cab9;
  --accent: #4f8cff;
  --shadow: 0 18px 40px rgba(78, 55, 31, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f7efe2;
  -webkit-text-size-adjust: 100%;
}

button,
input,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.studio-shell {
  min-height: 100svh;
  width: 100%;
  padding: clamp(12px, 2.5vw, 28px);
}

.choose-shell {
  display: grid;
  gap: 18px;
  align-content: start;
}

.choose-hero,
.top-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.5rem);
  letter-spacing: 0;
}

.request-box {
  display: grid;
  gap: 8px;
  min-width: min(440px, 100%);
}

.request-box label,
.color-panel h2 {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.88rem;
}

.request-box div,
.canvas-actions {
  display: flex;
  gap: 8px;
}

.request-box input {
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

.request-box input {
  min-height: 54px;
  padding: 0 14px;
}

button {
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fff4b8;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.request-box button,
.change-picture-button,
.canvas-actions button,
.surprise-button {
  padding: 0 14px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  padding: 2px 3px 8px;
}

.category-tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  background: #fffdf8;
}

.category-tab.active {
  background: #fff4b8;
  box-shadow: 0 0 0 4px var(--ink), 0 3px 0 var(--ink);
}

.choose-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.large-picture-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #fffdf8;
  text-align: left;
  min-height: 0;
}

.large-picture-card span {
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.picture-preview {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  background: var(--paper);
  border-radius: 6px;
}

.color-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.draw-top-bar {
  align-items: center;
}

.draw-top-bar h1 {
  font-size: clamp(1.35rem, 3.2vw, 2.7rem);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  gap: 12px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  min-height: 0;
}

.canvas-card,
.color-panel {
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.canvas-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 3px solid var(--ink);
}

.canvas-header h2 {
  font-size: clamp(1rem, 2.5vw, 1.35rem);
}

.canvas-actions {
  flex-wrap: wrap;
  justify-content: end;
}

.canvas-actions button {
  min-width: 72px;
}

.canvas-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: clamp(8px, 2vw, 18px);
  background: var(--paper);
  overflow: hidden;
  touch-action: none;
}

.coloring-page,
.raster-coloring-page {
  display: block;
  width: min(100%, 760px);
  aspect-ratio: 1;
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--paper);
}

.raster-coloring-page {
  position: relative;
  overflow: hidden;
}

.fill-canvas,
.raster-line-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.fill-canvas {
  background: transparent;
}

.raster-line-art {
  mix-blend-mode: multiply;
  pointer-events: none;
}

.region > * {
  cursor: pointer;
  transition: fill 120ms ease, filter 120ms ease;
}

.region > *:hover,
.region > *:focus {
  filter: brightness(0.96);
  outline: none;
}

.line-art-image {
  mix-blend-mode: multiply;
  pointer-events: none;
}

.color-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
  position: sticky;
  top: 12px;
  max-height: calc(100svh - 24px);
}

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

.swatch {
  aspect-ratio: 1;
  min-height: 48px;
  padding: 0;
}

.swatch.active {
  box-shadow: 0 0 0 5px var(--ink), inset 0 0 0 4px rgba(255, 255, 255, 0.9);
}

.selected-color {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.selected-dot {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ink);
  border-radius: 50%;
}

@media (max-width: 820px) {
  .choose-hero,
  .top-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .color-panel {
    position: static;
    max-height: none;
  }

  .swatches {
    display: flex;
    overflow-x: auto;
    padding: 4px 3px 8px;
  }

  .swatch {
    min-width: 52px;
  }
}

@media (max-width: 560px) {
  .studio-shell {
    padding: 8px;
  }

  .choose-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .request-box div {
    flex-direction: column;
  }

  .canvas-header {
    align-items: stretch;
    flex-direction: column;
    padding: 8px;
  }

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

  .canvas-actions button {
    min-width: 0;
    padding: 0 6px;
    font-size: 0.78rem;
  }

  .canvas-stage {
    padding: 6px;
  }

  .coloring-page,
  .raster-coloring-page {
    width: min(100%, calc(100dvh - 116px));
  }

  .color-panel {
    padding: 8px;
  }

  .swatches {
    display: grid;
    grid-template-columns: repeat(4, minmax(36px, 1fr));
    gap: 6px;
    overflow: visible;
    padding: 0;
  }

  .swatch {
    min-height: 36px;
    min-width: 0;
  }

  .selected-color,
  .surprise-button {
    display: none;
  }
}
