:root {
  color-scheme: light;
  --page: #eef0e6;
  --ink: #334239;
  --muted: #506658;
  --surface: #f8f8ef;
  --border: #b8c2b5;
}
:root[data-theme="night"] {
  color-scheme: dark;
  --page: #19222a;
  --ink: #edf1ea;
  --muted: #c3d2cf;
  --surface: #25323b;
  --border: #526571;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 1rem system-ui, sans-serif; }
.page-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 24px; width: min(calc(100% - 24px), 1374px, max(794px, calc((100svh - 110px) * 1.63 + 324px))); margin: 10px auto; }
.viewer { min-width: 0; width: 100%; margin: 0; }
.banner { width: 300px; height: 250px; }
.banner iframe { display: block; width: 300px; height: 250px; border: 0; }
.scene { position: relative; overflow: hidden; border-radius: 22px; background: #b9b69a; box-shadow: 0 3px 14px #18351e20; }
canvas { display: block; width: 100%; aspect-ratio: 1000 / 615; touch-action: none; cursor: default; }
canvas[data-petting], canvas[data-item-hover] { cursor: grab; }
canvas[data-item-drag] { cursor: grabbing; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible, input:focus-visible { outline: 2px solid #cb7749; outline-offset: 3px; }
canvas:focus-visible { outline-offset: -5px; }
.icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); font-size: 24px; }
.icon:hover, .icon[aria-pressed="true"], .icon[aria-expanded="true"] { box-shadow: inset 0 0 0 1px var(--muted); }
.theme { position: absolute; top: 12px; right: 12px; }
.toolbar { position: relative; display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.cats { display: flex; align-items: center; justify-content: space-between; gap: 9px; flex: 1; min-width: 0; overflow-x: auto; padding: 5px; scrollbar-width: thin; }
.swatch { position: relative; flex: none; width: clamp(34px, 4vw, 49px); aspect-ratio: 1; border: 1px solid #7777; border-radius: 50%; background: var(--coat); }
.swatch[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch[aria-pressed="true"]::after { content: "✓"; position: absolute; right: -3px; bottom: -2px; border: 1px solid var(--border); border-radius: 50%; width: 16px; height: 16px; background: var(--surface); font-size: 10px; line-height: 14px; }
.actions { display: flex; gap: 5px; }
.panel { position: absolute; z-index: 1; bottom: calc(100% + 12px); right: 0; width: min(270px, 100%); padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 6px 22px #0003; }
.panel label { display: flex; justify-content: space-between; font-size: .9rem; }
.slider-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; align-items: center; gap: 8px; margin: 3px 0 9px; }
.slider-row input { width: 100%; margin: 0; accent-color: #748c64; }
.slider-row svg { width: 28px; height: 28px; fill: currentColor; }
.slider-row .small-cat { transform: scale(.63); }
.cat-tail { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#reset { border: 1px solid var(--border); border-radius: 7px; background: transparent; padding: 4px 10px; font-size: .875rem; }
#instructions { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: .875rem; line-height: 1.5; }
#instructions span { display: inline-block; margin-left: .4em; }
kbd { font: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 0 .25em; }
.viewer:fullscreen, .viewer.expanded { width: 100%; height: 100%; margin: 0; padding: 8px; background: var(--page); display: flex; flex-direction: column; justify-content: center; }
.viewer.expanded { position: fixed; inset: 0; z-index: 2; }
.viewer:fullscreen canvas, .viewer.expanded canvas { height: min(calc(100svh - 112px), 61.5vw); }
@media (max-width: 800px) {
  .page-layout { grid-template-columns: minmax(0, 1fr); width: min(calc(100% - 24px), 650px); }
  .banner { justify-self: center; }
}
@media (max-width: 560px) {
  .page-layout { margin-top: max(8px, env(safe-area-inset-top)); }
  .toolbar { gap: 5px; }
  .actions { gap: 3px; }
  .toolbar .icon { width: 40px; height: 40px; }
  .theme { top: 7px; right: 7px; }
}

.cat-items { position: absolute; inset: 0; pointer-events: none; }
.cat-item { position: absolute; width: 9%; height: 12%; padding: 0; border: 0; background: transparent; color: transparent; pointer-events: none; font-size: 0; border-radius: 50%; }
#kibble { left: 19.8%; top: 75%; }
#cat-toy { left: 15%; top: 13%; height: 18%; }
.cat-item:focus-visible { outline: 2px dashed #f8e6bb; outline-offset: 4px; }
#item-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); pointer-events: none; }

#view-toggle { position: absolute; top: 12px; left: 12px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: 13px; }
.viewer[data-view="side"] #kibble { left: 20.5%; top: 80%; }
.viewer[data-view="side"] #cat-toy { left: 17%; top: 15%; }
@media (max-width:560px) { #view-toggle { top:7px;left:7px;padding:7px 10px;font-size:11px; } }

/* Standalone v3 export: center the scene without an advertisement column. */
.page-layout { grid-template-columns: minmax(0, 1fr); width: min(calc(100% - 24px), 1050px, max(470px, calc((100svh - 110px) * 1.63))); }

#species-toggle { position: absolute; top: 12px; right: 66px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 0 15px; height: 44px; }
.viewer[data-species="narcuga"] .cats, .viewer[data-species="dragon"] .cats { visibility: hidden; }
#view-toggle[hidden] { display: none; }

/* Artwork pets keep their proportions controls below the carpet. */
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .cats,
.viewer:is([data-species="dragon"], [data-species="narcuga"]) #fit { display: none; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .panel {
  position: static; order: 0; flex: 1; min-width: 0; width: auto;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 4px 16px; padding: 10px 12px; box-shadow: none;
}
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .actions { order: 1; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .panel label[for="size"] { grid-area: 1 / 1; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .panel label[for="weight"] { grid-area: 1 / 2; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .panel .slider-row:nth-child(2) { grid-area: 2 / 1; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .panel .slider-row:nth-child(4) { grid-area: 2 / 2; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) #reset { grid-area: 1 / 3 / 3 / 4; align-self: center; }
.viewer:is([data-species="dragon"], [data-species="narcuga"]) .slider-row { margin: 0; }
@media (max-width: 560px) {
  .viewer:is([data-species="dragon"], [data-species="narcuga"]) .toolbar { flex-wrap: wrap; }
  .viewer:is([data-species="dragon"], [data-species="narcuga"]) .panel { flex-basis: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; }
  .viewer:is([data-species="dragon"], [data-species="narcuga"]) #reset { grid-area: 3 / 1 / 4 / 3; justify-self: center; }
  .viewer:is([data-species="dragon"], [data-species="narcuga"]) .actions { margin-left: auto; }
}
