:root {
  color-scheme: light;
  --ink: #355b55;
  --muted: #78877a;
  --paper: #fffaf0;
  --selected: #edc253;
  --line: #6b7164;
}
* { box-sizing: border-box; }
body { margin: 0; background: #eeeadd; color: var(--ink); font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button, a { transition: transform .16s, box-shadow .16s, background .16s; }
button:focus-visible, a:focus-visible { outline: 3px solid #2b7771; outline-offset: 4px; }
button:disabled { opacity: .45; cursor: default; }
svg { display: block; width: 100%; height: 100%; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.studio { width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.studio .topbar { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 17px; padding: 19px 0; }
.studio .home-link { width: 42px; height: 42px; border: 1px solid #d2d4c4; border-radius: 50%; box-shadow: 0 2px 0 #d4d5c8; background: #faf6e9; color: var(--ink); font-size: 22px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 50px; height: 50px; padding: 4px; border-radius: 15px; background: #dbe3d5; color: #d68a74; transform: rotate(-5deg); }
.eyebrow { margin: 0 0 5px; font-size: 9px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(21px, 2.5vw, 30px); line-height: 1.1; letter-spacing: -.045em; font-weight: 750; }


.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 23px; align-items: stretch; height: min(620px, calc(100svh - 129px)); min-height: 510px; }
.drawing-board { min-width: 0; min-height: 0; position: relative; display: flex; flex-direction: column; padding: 13px; border: 1px solid #b8a889; border-radius: 17px; background: repeating-linear-gradient(0deg, #cdb99122 0 1px, transparent 1px 9px), #d9c7a5; box-shadow: 0 5px 0 #baaa8b, 0 15px 35px #585d4710; }
.paper-clip { position: absolute; z-index: 2; width: 91px; height: 22px; left: calc(50% - 45px); top: -7px; border: 1px solid #74877b; border-radius: 6px 6px 9px 9px; background: linear-gradient(#b7c4b9, #93a597 50%, #b2c0b1); box-shadow: 0 3px 2px #41564b22; }
.paper-clip::before { content: ""; position: absolute; inset: 4px 11px; border: 1px solid #d1d9ca; border-radius: 3px; }
.page-heading { display: flex; align-items: center; gap: 16px; min-height: 44px; padding: 9px 18px 5px; background: var(--paper); border-radius: 3px 3px 0 0; }
.page-number { font-size: 8px; letter-spacing: .13em; color: #9a9d89; }
.page-title { font-size: 11px; font-weight: 650; margin-left: auto; }
.little-star { color: #c6a662; font-size: 22px; }
.scene-wrap { position: relative; flex: 1; min-height: 0; padding: 0 12px; background: var(--paper); }
.city-scene { overflow: hidden; touch-action: manipulation; }
.colorable { fill: var(--paper); stroke: var(--line); stroke-width: 2.7; stroke-linejoin: round; stroke-linecap: round; cursor: pointer; transition: fill .2s; }
.colorable:hover { stroke: #265e54; stroke-width: 4.5; }
.colorable:focus-visible { outline: none; stroke: #d36639; stroke-width: 5; stroke-dasharray: 7 4; }
.colorable.backdrop { stroke: none; }
.detail { fill: none; stroke: var(--line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.detail.light { stroke: #b9b5a0; stroke-width: 1.5; }
.ink-fill { fill: var(--line); stroke: none; pointer-events: none; }
.scene-label { fill: #697965; font-family: "Trebuchet MS", sans-serif; font-size: 12px; font-weight: bold; letter-spacing: 2px; text-anchor: middle; pointer-events: none; }
.page-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--paper); border-radius: 0 0 3px 3px; min-height: 38px; padding: 5px 18px 10px; font-size: 10px; }
#helperText { font-weight: 650; }
#paintedCount { color: #8a907c; white-space: nowrap; font-size: 9px; }
.tool-cabinet { display: flex; flex-direction: column; min-height: 0; padding: 20px 17px 12px; border: 1px solid #c6cebc; background: #e2e7d7; border-radius: 19px; box-shadow: 0 4px 0 #cad2bf; gap: 15px; }
.cabinet-heading { display: flex; justify-content: space-between; align-items: center; }
.cabinet-heading>span { font-size: 28px; color: #a7b490; }
h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
h3 { margin: 0; font-size: 10px; font-weight: 750; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; gap: 5px; }
.section-heading>span { color: #778470; font-size: 9px; }
.palette-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px 8px; padding: 10px; background: #d4dbc9; border: 1px solid #c7cfbd; border-radius: 13px; box-shadow: inset 0 2px 4px #52684515; }
.color-button { position: relative; width: 100%; aspect-ratio: 1; border: 1px solid #8d987459; padding: 3px; background: #edeadd; border-radius: 50%; box-shadow: 0 3px 1px #66725640; }
.color-button::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: radial-gradient(ellipse at 33% 27%, #ffffff45 0 13%, transparent 16%), var(--swatch); box-shadow: inset 0 1px 3px #364f363d; }
.color-button.is-selected { outline: 2px solid #3b6a5d; outline-offset: 2px; transform: translateY(-2px); }
.color-button.is-selected::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; right: 0; top: -3px; background: #355b55; border: 1px solid #fffaf0; }
.paint-tool { display: flex; align-items: center; gap: 9px; padding: 6px 10px; background: #eff1e4; border: 1px solid #c8d0bd; border-radius: 12px; text-align: left; }
.paint-tool>svg { width: 42px; height: 42px; color: var(--selected); flex: none; }
.paint-tool>span:not(.mode-dot), .rainbow-button>span:not(:last-child) { display: grid; gap: 4px; }
.paint-tool strong, .rainbow-button strong { font-size: 11px; }
.paint-tool small, .rainbow-button small { font-size: 9px; color: #7c8873; }
.paint-tool.is-selected { border-color: #719584; background: #f7f6e9; box-shadow: 0 2px 0 #abbda5; }
.mode-dot { width: 6px; height: 6px; background: #b8c4ac; border-radius: 50%; margin-left: auto; }
.is-selected .mode-dot { background: #4e8870; box-shadow: 0 0 0 3px #d6e3cb; }
.stamp-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stamp-button { position: relative; display: grid; justify-items: center; padding: 7px 4px 8px; gap: 3px; border: 1px solid #c8c9b5; border-radius: 11px; background: #ede9d8; box-shadow: 0 3px 0 #bbc4ad; font-size: 9px; }
.stamp-handle { display: block; width: 15px; height: 9px; border-radius: 5px 5px 2px 2px; background: #b89976; box-shadow: inset 0 2px #d2b28f; }
.stamp-button svg { width: 30px; height: 30px; color: #dfb958; }
.stamp-button[data-stamp="heart"] svg { color: #d98c83; }
.stamp-button[data-stamp="circle"] svg { color: #8fb3c0; }
.stamp-button[aria-pressed="true"] { outline: 2px solid #5b8472; outline-offset: 2px; background: #fff7de; }
.rainbow-button { display: flex; align-items: center; gap: 8px; padding: 7px 8px; background: #f6edd9; border: 1px solid #d4c8a9; border-radius: 12px; text-align: left; box-shadow: 0 3px 0 #c9c8af; }
.rainbow-button svg { width: 51px; height: 43px; flex: none; }
.rainbow-button>span:last-child { margin-left: auto; font-size: 19px; color: #9b9f82; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.actions button { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 37px; padding: 7px 3px; border: 1px solid #bbc8b0; border-radius: 10px; background: #eef0e3; font-size: 10px; font-weight: 650; box-shadow: 0 2px 0 #c1cbb6; }
.actions svg { width: 18px; height: 20px; }
button:not(:disabled):hover { filter: brightness(1.025); }
button:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.cabinet-note { margin: 0; font-size: 9px; color: #7d8a72; text-align: center; }
.cabinet-note span { color: #ab985f; margin-right: 4px; }
.studio-footer { display: flex; justify-content: space-between; gap: 15px; padding: 15px 3px; color: #8a8e7d; font-size: 9px; }
.studio-footer>span:first-child { font-style: italic; }
.sparkle-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.sparkle { position: absolute; width: 13px; height: 13px; color: var(--sparkle-color); animation: scatter .65s ease-out forwards; }
.sparkle svg { overflow: visible; }
@keyframes scatter { from { opacity: 1; transform: translate(-50%, -50%) scale(.4); } to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(30deg) scale(1); } }
@media (min-width: 851px) and (max-height: 740px) {
  .studio .topbar { padding: 15px 0; }
  .workbench { height: calc(100svh - 116px); min-height: 510px; }
  .tool-cabinet { gap: 12px; padding-top: 17px; }
  .palette-grid { gap: 8px; padding: 8px; }
}
@media (max-width: 1000px) {
  .studio { width: calc(100% - 28px); }
  .workbench { grid-template-columns: minmax(0, 1fr) 222px; gap: 15px; }
  .tool-cabinet { padding-left: 13px; padding-right: 13px; }
  .page-number { display: none; }
  .page-title { margin-left: 0; }
  .little-star { margin-left: auto; }
  #paintedCount { display: none; }
}
@media (max-width: 850px) {
  .workbench { height: auto; min-height: 0; grid-template-columns: 1fr; gap: 20px; }
  .drawing-board { height: auto; }
  .scene-wrap { flex: auto; aspect-ratio: 1100 / 680; }
  .tool-cabinet { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 18px; }
  .cabinet-heading { grid-column: 1 / -1; }
  .paint-section { grid-row: span 2; }
  .palette-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; }
  .paint-tool { align-self: start; }
  .stamp-section { grid-column: 2; }
  .rainbow-button, .actions { align-self: center; }
  .cabinet-note { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .studio { width: calc(100% - 22px); }
  .studio .topbar { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 9px; padding: 17px 0; }
  .studio .home-link { width: 34px; height: 34px; font-size: 19px; }

  .brand-mark { display: none; }
  .eyebrow { font-size: 7px; letter-spacing: .12em; }
  h1 { font-size: 18px; }
  .drawing-board { padding: 8px; border-radius: 12px; }
  .page-heading { min-height: 39px; padding: 7px 10px 0; }
  .page-title { font-size: 9px; }
  .scene-wrap { padding: 0 3px; }
  .page-footer { padding: 6px 10px 9px; font-size: 9px; min-height: 32px; }
  .tool-cabinet { padding: 15px; gap: 15px 12px; }
  .palette-grid { grid-template-columns: repeat(4, 1fr); }
  .paint-tool { padding: 7px; gap: 3px; }
  .paint-tool>svg { width: 31px; height: 34px; }
  .paint-tool strong { font-size: 10px; }
  .paint-tool small { font-size: 8px; }
  .mode-dot { display: none; }
  .stamp-row { gap: 5px; }
  .stamp-button { padding: 6px 3px; }
  .stamp-button svg { width: 25px; height: 25px; }
  .section-heading { gap: 5px; }
  .section-heading h3 { font-size: 9px; }
  .section-heading>span { font-size: 8px; }
  .rainbow-button { gap: 5px; padding: 7px 5px; }
  .rainbow-button svg { width: 36px; height: 33px; }
  .rainbow-button strong { font-size: 9px; }
  .rainbow-button small { font-size: 8px; }
  .rainbow-button>span:last-child { display: none; }
  .actions { gap: 5px; }
  .actions button { font-size: 9px; gap: 3px; }
  .actions svg { width: 15px; }
  .studio-footer { font-size: 8px; line-height: 1.5; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
/* Keep the entire paint box visible on ordinary laptop-height displays. */
@media (min-width: 851px) and (max-height: 780px) {
  .tool-cabinet { gap: 10px; padding-top: 15px; padding-bottom: 12px; }
  .cabinet-heading .eyebrow { margin-bottom: 3px; }
  .cabinet-heading h2 { font-size: 19px; }
  .section-heading { margin-bottom: 8px; }
  .palette-grid { gap: 7px; padding: 8px; }
  .color-button { width: 32px; height: 32px; justify-self: center; }
  .paint-tool { padding-top: 4px; padding-bottom: 4px; }
  .paint-tool>svg { width: 36px; height: 36px; }
  .stamp-button { padding-top: 5px; padding-bottom: 6px; }
  .stamp-button svg { width: 26px; height: 26px; }
  .rainbow-button { padding-top: 5px; padding-bottom: 5px; }
  .rainbow-button svg { height: 36px; }
  .cabinet-note { display: none; }
}
@media (max-width: 600px) {
  .paint-section { grid-column: 1 / -1; grid-row: auto; }
  .palette-grid { grid-template-columns: repeat(6, 1fr); }
  .paint-tool { align-self: stretch; }
  .paint-tool>svg { width: 37px; height: 42px; }
}

.studio .topbar > .brand:last-child {
  grid-column: 2;
  justify-self: start;
}
