:root {
  color-scheme: light;
  --ink: #262129;
  --ink-soft: #5f5763;
  --cream: #fffaf0;
  --paper: #fffef9;
  --mint: #acd7c8;
  --coral: #f47f69;
  --mustard: #e6b743;
  --lilac: #b9aad9;
  --line: #2d2730;
  --shadow: 0 18px 60px rgb(43 32 45 / 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(circle at 10% 8%, rgb(172 215 200 / 0.32), transparent 24rem),
    radial-gradient(circle at 95% 95%, rgb(244 127 105 / 0.18), transparent 28rem),
    var(--cream);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.sr-only {
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  position: absolute;
}

.app-shell {
  min-height: 100svh;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.topbar {
  min-height: 74px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 2px solid var(--line);
  background: rgb(255 250 240 / 0.92);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  border: 0;
  background: transparent;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 13px 17px 14px 18px;
  background: var(--mustard);
  display: grid;
  place-items: center;
  font-size: 24px;
  transform: rotate(-3deg);
  box-shadow: 3px 3px 0 var(--line);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  line-height: 1.05;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prototype-pill {
  padding: 6px 9px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--mint);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.icon-button,
.close-button {
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  font-weight: 900;
  cursor: pointer;
}

.locked-view {
  min-height: calc(100svh - 76px);
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.lock-card {
  width: min(100%, 560px);
  padding: 30px;
  border: 2px solid var(--line);
  border-radius: 30px 22px 34px 24px;
  background: var(--paper);
  box-shadow: var(--shadow), 8px 8px 0 var(--mint);
}

.lock-art {
  height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 2rem;
}

.lock-art span:nth-child(2) {
  width: 64px;
  height: 64px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--lilac);
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 3rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: #766c79;
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.lock-card h1,
.sheet h2,
.art-heading h1,
.palette-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
}

.lock-card h1 {
  max-width: 420px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 0.98;
}

.lock-card > p:not(.eyebrow) {
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.55;
}

.locked-pack,
.library-pack,
.future-pack {
  width: 100%;
  min-height: 86px;
  margin-top: 24px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #f8f1e4;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.locked-pack img,
.library-pack img {
  width: 64px;
  height: 64px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  object-fit: contain;
  background: white;
}

.library-pack + .library-pack {
  margin-top: 12px;
}

.locked-pack strong,
.locked-pack span,
.library-pack strong,
.library-pack small,
.future-pack strong,
.future-pack small {
  display: block;
}

.locked-pack span,
.library-pack small,
.future-pack small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.lock-chip,
.locked-pack .lock-chip,
.future-pack b {
  padding: 6px 9px;
  border-radius: 999px;
  background: #ddd4df;
  font-size: 0.72rem;
}

.coloring-view {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px 24px;
}

.art-heading {
  margin: 4px 2px 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.back-link {
  min-height: 34px;
  margin: 0 0 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b626e;
  font-size: 0.86rem;
  font-weight: 750;
  cursor: pointer;
}

.art-heading h1 {
  margin-bottom: 2px;
  font-size: clamp(1.6rem, 6vw, 2.5rem);
  line-height: 1.05;
}

.art-heading p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.save-status {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #e9e3ec;
  color: #6d6370;
  font-size: 0.7rem;
  font-weight: 750;
}

.workspace-card {
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.workspace {
  height: min(64svh, 720px);
  min-height: 360px;
  overflow: auto;
  overscroll-behavior: contain;
  background: #e9e3dc;
  display: grid;
  place-items: start center;
  scrollbar-color: var(--lilac) transparent;
}

.canvas-stack {
  position: relative;
  flex: 0 0 auto;
  margin: 10px;
  background: white;
  box-shadow: 0 8px 26px rgb(38 33 41 / 0.17);
  touch-action: pan-x pan-y;
}

.canvas-stack canvas,
.canvas-stack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#numberCanvas {
  z-index: 2;
  pointer-events: none;
}

#lineArt {
  z-index: 3;
}

.canvas-stack img {
  pointer-events: none;
  user-select: none;
  mix-blend-mode: multiply;
}

.loading {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-weight: 700;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #cfc6d1;
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toolbar {
  padding: 10px;
  border-top: 2px solid var(--line);
  background: #f9f3e8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-group {
  display: flex;
  gap: 5px;
}

.toolbar button {
  min-height: 44px;
  padding: 8px 11px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 780;
  cursor: pointer;
}

.toolbar button:disabled {
  opacity: 0.38;
  cursor: default;
}

.zoom-group {
  margin-left: auto;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.zoom-group button {
  min-width: 38px;
  border: 0;
}

.zoom-group output {
  min-width: 45px;
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
}

.toolbar .save-button {
  border-color: var(--line);
  background: var(--coral);
  box-shadow: 2px 2px 0 var(--line);
}

.toolbar #fullscreenButton {
  background: var(--mint);
}

.palette-panel {
  margin-top: 14px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 22px 28px 20px 26px;
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--mustard);
}

.mode-row {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mode-switch {
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #eee7ed;
  display: inline-flex;
  gap: 3px;
}

.mode-button {
  min-height: 38px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 850;
  cursor: pointer;
}

.mode-button.active {
  background: var(--paper);
  box-shadow: 0 2px 0 var(--line);
}

.mode-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.number-progress {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.palette-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.palette-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.palette-picker select {
  min-width: 190px;
  min-height: 44px;
  padding: 7px 36px 7px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 700;
}

.custom-color {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 750;
}

.custom-color input {
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
}

.swatches {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(16, minmax(34px, 1fr));
  gap: 8px;
}

.swatch {
  aspect-ratio: 1;
  min-width: 38px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.swatch.numbered {
  color: var(--number-ink, #231e25);
  font-size: 0.86rem;
  font-weight: 950;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.72);
}

.swatch.complete::after {
  content: "✓";
}

.swatch[aria-pressed="true"] {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 4px 0 var(--line);
}

.gentle-wobble {
  animation: gentle-wobble 240ms ease;
}

@keyframes gentle-wobble {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

.tap-hint {
  margin: 13px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.sheet-dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100svh - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
  box-shadow: var(--shadow);
}

.sheet-dialog::backdrop {
  background: rgb(31 25 33 / 0.72);
  backdrop-filter: blur(4px);
}

.sheet {
  position: relative;
  padding: 28px 20px 22px;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: var(--cream);
}

.sheet h2 {
  margin-bottom: 8px;
  padding-right: 44px;
  font-size: 2rem;
  line-height: 1;
}

.sheet-copy {
  color: var(--ink-soft);
  line-height: 1.45;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1.5rem;
}

.library-pack {
  appearance: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--mint);
}

.library-pack b {
  color: #715426;
}

.future-pack {
  opacity: 0.65;
}

.future-icon {
  width: 64px;
  height: 64px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 1.6rem;
}

.help-list {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: help;
}

.beta-note {
  margin-top: 1.15rem;
  padding: 1rem 1.05rem;
  border: 2px solid var(--ink);
  border-radius: 1rem;
  background: var(--gold-soft, #f5df9b);
}

.beta-note strong {
  display: block;
  margin-bottom: 0.4rem;
}

.beta-note p {
  margin: 0;
  line-height: 1.5;
}

.help-list li {
  min-height: 72px;
  padding: 12px 0 12px 54px;
  border-top: 1.5px solid #cfc4ce;
  position: relative;
}

.help-list li::before {
  counter-increment: help;
  content: counter(help);
  width: 36px;
  height: 36px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--mint);
  display: grid;
  place-items: center;
  position: absolute;
  left: 2px;
  top: 13px;
  font-weight: 900;
}

.help-list b,
.help-list span {
  display: block;
}

.help-list span {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.4;
}

.toast {
  min-width: 220px;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 750;
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 50;
  transform: translate(-50%, 120px);
  opacity: 0;
  transition: 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

body.coloring-fullscreen {
  overflow: hidden;
}

.coloring-view.fullscreen-mode {
  width: 100%;
  max-width: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.fullscreen-mode .art-heading {
  display: none;
}

.fullscreen-mode .workspace-card {
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
}

.fullscreen-mode .workspace {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  touch-action: none;
}

.fullscreen-mode .canvas-stack {
  touch-action: none;
}

.fullscreen-mode .toolbar {
  flex: 0 0 auto;
}

.fullscreen-mode .palette-panel {
  margin: 0;
  padding: 9px 12px max(10px, env(safe-area-inset-bottom));
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  box-shadow: none;
  flex: 0 0 auto;
}

.fullscreen-mode .palette-heading {
  align-items: center;
}

.fullscreen-mode .mode-row {
  margin-bottom: 5px;
}

.fullscreen-mode .palette-heading .eyebrow,
.fullscreen-mode .tap-hint,
.fullscreen-mode .custom-color > span {
  display: none;
}

.fullscreen-mode .swatches {
  margin-top: 8px;
  padding: 2px 2px 7px;
  display: flex;
  gap: 9px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.fullscreen-mode .swatch {
  width: 44px;
  min-width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

@media (max-width: 760px) {
  .swatches {
    grid-template-columns: repeat(8, minmax(34px, 1fr));
  }
  .prototype-pill,
  .save-status {
    display: none;
  }

  .coloring-view {
    padding-inline: 8px;
  }

  .workspace {
    height: 56svh;
    min-height: 330px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .tool-group:first-child {
    order: 1;
  }

  .zoom-group {
    order: 2;
  }

  .toolbar #fullscreenButton {
    order: 3;
    flex: 1 1 auto;
  }

  .toolbar .save-button {
    order: 4;
    flex: 1 1 auto;
  }

  .swatches {
    padding: 4px 2px 9px;
    grid-template-columns: repeat(6, 1fr);
  }

  .palette-panel {
    margin-inline: 2px;
  }
}

@media (max-width: 390px) {
  .brand small {
    display: none;
  }

  .toolbar button {
    padding-inline: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
