:root {
  --ink: #26332b;
  --muted: #6f746f;
  --desk: #e9e3d8;
  --paper: #fffdf7;
  --paper-edge: #d5cdbf;
  --green: #35ad62;
  --green-soft: #e8f7eb;
  --coral: #ef5651;
  --coral-soft: #fff0ed;
  --blue: #5b9dc6;
  --hot: clamp(58px, 11vmin, 92px);
  --gap: clamp(6px, 1.1vmin, 13px);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  font: 16px/1.35 ui-rounded, "Avenir Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 25% 15%, rgba(255,255,255,.48), transparent 34%),
    linear-gradient(135deg, #f0ece4, var(--desk));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

button, input, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, label:focus-within {
  outline: 3px solid rgba(55, 133, 184, .55);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--app-vw, 100dvw);
  height: var(--app-vh, 100dvh);
  max-width: 100%;
  max-height: 100%;
}

/* --------------------------------------------------------------- cover */

.cover-screen {
  overflow: hidden;
  background: #c8e0c1;
}

.cover-enter {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: #cde6ef;
}

.cover-enter::before {
  content: "";
  position: absolute;
  inset: -2.5vmax;
  pointer-events: none;
  background-image: var(--cover-art);
  background-size: cover;
  background-position: center;
  filter: blur(18px) saturate(1.05) brightness(.92);
  opacity: .58;
  transform: scale(1.04);
}

.cover-enter::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,.04),
    rgba(0,0,0,.035)
  );
}

.cover-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  filter: saturate(1.08);
}

.cover-enter:hover .cover-scene {
  filter: saturate(1.1);
}

.cover-title {
  position: absolute;
  top: clamp(24px, 6.8vh, 66px);
  left: 50%;
  z-index: 3;
  transform: translateX(-50%) rotate(-1deg);
  white-space: nowrap;
  font-weight: 900;
  line-height: .86;
  letter-spacing: -.065em;
  font-size: clamp(54px, 11vw, 132px);
  text-shadow:
    0 5px 0 #fff8e9,
    0 8px 0 rgba(111, 91, 55, .12),
    0 13px 18px rgba(52, 68, 54, .22);
  -webkit-text-stroke: clamp(4px, .6vw, 8px) #fff8e9;
  paint-order: stroke fill;
}

.word-sticker { color: #075985; }
.word-book { color: #ed820a; }
.word-book::first-letter { color: #ed820a; }

.cover-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(22px, 5vh, 54px);
  z-index: 3;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 3px 14px rgba(43, 54, 46, .12);
  color: #53665a;
  font-size: clamp(12px, 1.8vw, 16px);
  font-weight: 700;
  letter-spacing: .03em;
}

.adult-hotspot {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 8;
  width: clamp(48px, 7vmin, 68px);
  height: clamp(48px, 7vmin, 68px);
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 16px;
  background: rgba(34, 45, 39, .14);
  color: rgba(255,255,255,.74);
  font-size: clamp(20px, 3vmin, 28px);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background .15s ease, color .15s ease;
}

.adult-hotspot:hover,
.adult-hotspot:focus-visible {
  background: rgba(34,45,39,.34);
  color: white;
}

/* ------------------------------------------------------------- gallery */

.gallery-screen,
.creator-screen {
  overflow: auto;
  padding:
    max(8px, env(safe-area-inset-top))
    env(safe-area-inset-right)
    max(12px, env(safe-area-inset-bottom))
    env(safe-area-inset-left);
  background:
    radial-gradient(circle at 10% 6%, rgba(255,255,255,.82), transparent 30%),
    linear-gradient(145deg, #f4efe5, #e4ddcf);
}

.gallery-header {
  width: 100%;
  margin: 0 0 8px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.gallery-header h1,
.library-header h2,
.adult-card h2 {
  margin: 0;
  line-height: 1;
  letter-spacing: -.03em;
}

.gallery-header h1 {
  font-size: clamp(30px, 5vw, 48px);
}

.eyebrow {
  margin-bottom: 4px;
  color: #5b8264;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .13em;
}

.round-control {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border: 1px solid #cec4b4;
  border-radius: 50%;
  background: rgba(255,253,247,.94);
  box-shadow: 0 5px 15px rgba(72, 61, 47, .10);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 34px;
  line-height: 1;
}

.round-control.small {
  width: 42px;
  height: 42px;
  font-size: 26px;
}

.page-gallery {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
  gap: clamp(4px, .8vw, 10px);
}

.page-tile {
  position: relative;
  min-height: 220px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: #dfe6dd;
  box-shadow: none;
  cursor: pointer;
  padding: 0;
  transition: transform .14s ease, filter .14s ease;
}

.page-tile:hover,
.page-tile:focus-visible {
  transform: translateY(-2px);
  filter: saturate(1.06) brightness(1.01);
}

.page-tile svg {
  width: 100%;
  height: 100%;
  display: block;
}

.page-tile-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255,253,247,.89);
  box-shadow: 0 3px 10px rgba(57,46,35,.13);
  font-size: 14px;
  font-weight: 800;
}

.page-tile.new-page {
  display: grid;
  place-items: center;
  border-style: dashed;
  border-color: #b9ad99;
  background:
    linear-gradient(135deg, rgba(255,255,255,.54), rgba(255,255,255,.20)),
    #e7dfd0;
}

.new-page-inner {
  display: grid;
  place-items: center;
  gap: 8px;
  color: #716856;
}

.new-page-inner .plus {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #fffdf7;
  box-shadow: 0 5px 16px rgba(69,57,43,.12);
  font-size: 48px;
  font-weight: 300;
  color: #4f805b;
}

.new-page-inner strong {
  font-size: 18px;
}

/* ------------------------------------------------------------- creator */

.creator-body {
  width: min(900px, 100%);
  margin: 4vh auto 0;
  display: grid;
  gap: 14px;
}

.upload-card {
  min-height: min(56vh, 520px);
  display: grid;
  cursor: pointer;
  border: 3px dashed #b8ab98;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255,253,247,.72);
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.28);
}

.upload-card.compact {
  min-height: 270px;
}

.upload-preview {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 24px;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  text-align: center;
}

.upload-preview.has-image {
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,.65);
}

.upload-plus {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: #4f805b;
  box-shadow: 0 4px 16px rgba(69,57,43,.13);
  font-size: 47px;
  line-height: 1;
  text-shadow: none;
}

.upload-preview strong { font-size: 20px; }
.upload-preview small { color: inherit; opacity: .78; }

.creator-note {
  justify-self: center;
  color: var(--muted);
  font-size: 12.5px;
}

.creator-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 6px;
  border: 1px solid #d2c7b7;
  border-radius: 18px;
  background: rgba(255,253,247,.62);
}

.creator-mode-switch.compact {
  margin-bottom: 14px;
}

.creator-mode {
  min-height: 70px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #746c60;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 14px;
  font-size: 14px;
}

.creator-mode span { font-size: 22px; }

.creator-mode.active {
  background: #fffdf7;
  color: #315f3c;
  box-shadow:
    0 2px 0 rgba(109,91,66,.08),
    0 7px 18px rgba(72,61,47,.10);
}

.agent-creator {
  min-height: min(54vh, 480px);
  display: grid;
  align-content: center;
  justify-items: stretch;
  gap: 12px;
  padding: clamp(20px, 4vw, 42px);
  border: 1px solid #d0c6b7;
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.76), transparent 35%),
    #f7f0e5;
}

.agent-creator.compact {
  min-height: 300px;
  padding: 22px;
}

.agent-creator-icon {
  justify-self: center;
  font-size: 38px;
}

.agent-creator label {
  font-weight: 800;
  color: #526258;
}

.agent-creator textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid #cbbfac;
  border-radius: 14px;
  background: #fffdf8;
  color: var(--ink);
  padding: 13px 14px;
  font: inherit;
  line-height: 1.4;
}

.agent-go {
  justify-self: start;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: #476f52;
  color: white;
  font-weight: 800;
  padding: 0 20px;
  cursor: pointer;
}

.agent-go:hover,
.agent-go:focus-visible {
  background: #365a41;
}

.agent-status {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 12.5px;
}

.clip-intent {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.clip-intent button {
  border: 1px solid #cbbfac;
  border-radius: 999px;
  background: #fffdf8;
  color: #766e62;
  padding: 6px 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.clip-intent button.active {
  border-color: #7da387;
  background: #eaf5ea;
  color: #315f3c;
}

/* ---------------------------------------------------------------- play */

.play-screen {
  overflow: hidden;
  padding: 0;
  background: #dfe6dd;
}

.play-screen::before {
  content: "";
  position: absolute;
  inset: -2.5vmax;
  z-index: 0;
  pointer-events: none;
  background-image: var(--page-art);
  background-size: cover;
  background-position: center;
  filter: blur(20px) saturate(1.02) brightness(.88);
  opacity: .56;
  transform: scale(1.05);
}

#page-wrap {
  position: absolute;
  inset: 0 0 calc(var(--hot) + 14px + env(safe-area-inset-bottom)) 0;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
}

#page {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: block;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  touch-action: none;
  transition: filter .18s ease;
}

#page.placing {
  filter: drop-shadow(0 0 8px rgba(85,126,90,.34));
}

#page.placing:hover { cursor: copy; }

#reference-layer {
  pointer-events: none;
  opacity: 1;
  transition: opacity .42s ease;
}

#reference-layer.reference-fade {
  opacity: 0;
}

.deictic-reference {
  pointer-events: none;
}

.deictic-point {
  fill: rgba(255, 246, 183, .26);
  stroke: rgba(255, 250, 224, .98);
  stroke-width: 5;
  stroke-dasharray: 10 7;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 5px rgba(50, 58, 48, .28));
}

.deictic-point-core {
  fill: rgba(255, 241, 141, .92);
  stroke: rgba(74, 83, 69, .48);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.deictic-box {
  fill: rgba(255, 246, 183, .15);
  stroke: rgba(255, 250, 224, .98);
  stroke-width: 5;
  stroke-dasharray: 14 9;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 5px rgba(50, 58, 48, .28));
}

.deictic-reference-drafting {
  opacity: .78;
}

/* ------------------------------------------------------------- stickers */

.sticker {
  cursor: grab;
  outline: none;
}

.sticker .art,
.placement-preview .art {
  pointer-events: none;
  transform-origin: center;
  filter: drop-shadow(0 3px 2px rgba(52,47,39,.24));
  transition: transform .13s ease, filter .13s ease, opacity .13s ease;
}

.sticker.held { cursor: grabbing; }

.sticker.held .art {
  animation: none !important;
  transition: none;
  transform: none;
  filter: drop-shadow(0 13px 8px rgba(52,47,39,.30));
}

.sticker.refused .art { animation: refuse .28s ease; }

@keyframes refuse {
  0%, 100% { transform: translateX(0); }
  28% { transform: translateX(-5px) rotate(-1deg); }
  72% { transform: translateX(5px) rotate(1deg); }
}

.sticker.alive:not(.held) .art {
  animation: var(--alive) 1.15s ease-in-out infinite;
}

.sticker[data-alive="flutter"] { --alive: flutter; }
.sticker[data-alive="chew"] { --alive: chew; }
.sticker[data-alive="paddle"] { --alive: paddle; }
.sticker[data-alive="peck"] { --alive: peck; }
.sticker[data-alive="hop"] { --alive: hop; }
.sticker[data-alive="swim"] { --alive: swim; }
.sticker[data-alive="sway"] { --alive: sway; }
.sticker[data-alive="drift"] { --alive: drift; }

@keyframes flutter {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  25% { transform: translateY(-10px) rotate(2deg) scaleX(.88); }
  52% { transform: translateY(-4px) rotate(-2deg); }
  76% { transform: translateY(-12px) rotate(3deg) scaleX(.92); }
}

@keyframes chew {
  0%, 100% { transform: rotate(0deg); }
  48% { transform: rotate(-3.5deg) translateY(2px); }
}

@keyframes paddle {
  0%, 100% { transform: translateX(0) rotate(-1deg); }
  50% { transform: translateX(12px) rotate(3deg); }
}

@keyframes peck {
  0%, 100% { transform: rotate(0deg); }
  38% { transform: rotate(16deg) translateY(4px); }
}

@keyframes hop {
  0%, 100% { transform: translateY(0) scaleY(1); }
  45% { transform: translateY(-18px) scaleY(.95); }
}

@keyframes swim {
  0%, 100% { transform: translateX(-8px) rotate(-2deg); }
  50% { transform: translateX(13px) rotate(3deg); }
}

@keyframes sway {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(3deg); }
}

@keyframes drift {
  0%, 100% { transform: translateX(-6px); }
  50% { transform: translateX(8px); }
}

.placement-preview {
  pointer-events: none;
  opacity: .65;
}

.placement-preview .art {
  filter: drop-shadow(0 10px 7px rgba(52,47,39,.25));
}

/* -------------------------------------------------------------- hotbar */

.hotbar {
  position: absolute;
  z-index: 70;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: 100%;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: calc(var(--hot) + 14px);
  display: grid;
  grid-template-columns: var(--hot) minmax(0, 1fr) var(--hot);
  align-items: stretch;
  overflow: hidden;
  border: 0;
  border-top: 1px solid #cbbfab;
  border-radius: 0;
  background: #fbf7ed;
  box-shadow: 0 -5px 18px rgba(75,63,49,.10);
}

.hotbar-end {
  width: var(--hot);
  min-width: var(--hot);
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.home-btn {
  background: var(--green-soft);
  color: #279b50;
  border-right: 1px solid rgba(53,173,98,.24);
}

.library-btn {
  background: var(--coral-soft);
  color: #e53e3e;
  border-left: 1px solid rgba(239,86,81,.24);
  font-size: clamp(34px, 6vmin, 50px);
  font-weight: 300;
}

.home-btn svg {
  width: 42%;
  fill: currentColor;
}

.hotbar-end:hover,
.hotbar-end:focus-visible {
  filter: saturate(1.15) brightness(.98);
}

.voice-orb {
  position: fixed;
  z-index: 76;
  right: max(18px, calc(env(safe-area-inset-right) + 12px));
  top: max(18px, calc(env(safe-area-inset-top) + 12px));
  width: clamp(54px, 7vmin, 68px);
  height: clamp(54px, 7vmin, 68px);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 50%;
  background: rgba(255,253,247,.88);
  box-shadow: 0 8px 24px rgba(42,53,45,.18);
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  transition: transform .14s ease, background .14s ease, box-shadow .14s ease;
}

.voice-orb:hover,
.voice-orb:focus-visible {
  transform: translateY(-2px);
}

.voice-orb.listening {
  background: #eef8ee;
  box-shadow:
    0 0 0 6px rgba(53,173,98,.16),
    0 10px 28px rgba(42,53,45,.20);
}

.voice-orb.speaking {
  background: #eef4fb;
  box-shadow:
    0 0 0 6px rgba(91,157,198,.16),
    0 10px 28px rgba(42,53,45,.20);
}

.voice-orb.thinking { background: #fff2d5; }

.conversation-status {
  position: fixed;
  z-index: 77;
  right: max(18px, calc(env(safe-area-inset-right) + 12px));
  top: max(96px, calc(env(safe-area-inset-top) + 90px));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 18px;
  background: #fff2d5;
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(42,53,45,.15);
  pointer-events: none;
}
.conversation-status[hidden] { display: none; }
.thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: thinking-pulse 1.2s ease-in-out infinite;
}
@keyframes thinking-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  .thinking-dot { animation: none; }
}

.voice-orb.error {
  background: #fff0ed;
}

.voice-orb-icon {
  font-size: clamp(24px, 3.5vmin, 32px);
}

.accessibility-chat {
  position: fixed;
  z-index: 75;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 72vw);
  max-height: min(34vh, 250px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: 16px;
  background: rgba(255,253,247,.72);
  box-shadow: 0 10px 30px rgba(34,42,37,.18);
  backdrop-filter: blur(12px) saturate(1.05);
  color: var(--ink);
}

.accessibility-chat-header {
  min-height: 34px;
  padding: 6px 8px 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #53665a;
  font-size: 12px;
}

.accessibility-chat-header button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.54);
  color: #69756d;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.accessibility-chat-log {
  min-height: 0;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px 12px 7px;
  display: grid;
  gap: 5px;
  font-size: 13px;
  line-height: 1.35;
}

.accessibility-chat-line {
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,.52);
}

.accessibility-chat-line strong {
  color: #4f6b58;
}

.accessibility-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 7px;
  background: rgba(255,255,255,.34);
}

.accessibility-chat-compose input {
  min-width: 0;
  border: 1px solid rgba(112,103,88,.28);
  border-radius: 10px;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

.accessibility-chat-compose button {
  border: 0;
  border-radius: 10px;
  background: rgba(71,111,82,.92);
  color: white;
  padding: 0 13px;
  font-weight: 800;
  cursor: pointer;
}

.tray-zone {
  position: relative;
  min-width: 0;
  padding: 5px 9px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(110,95,72,.035) 0,
      rgba(110,95,72,.035) 1px,
      transparent 1px,
      transparent 11px
    ),
    #fbf7ed;
}

.tray-zone.drop-ready {
  background: #edf8ec;
  box-shadow: inset 0 0 0 3px rgba(53,173,98,.22);
}

.hotbar.drop-ready {
  box-shadow:
    inset 0 0 0 4px rgba(53,173,98,.24),
    0 8px 24px rgba(75,63,49,.11);
}

#tray-items {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.2vmin, 13px);
  min-height: var(--hot);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

#tray-items::-webkit-scrollbar { display: none; }

.tray-sticker {
  flex: 0 0 auto;
  width: var(--hot);
  height: var(--hot);
  border: 0;
  border-radius: 12px;
  padding: 3px;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.tray-sticker svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
  filter: drop-shadow(0 2px 1px rgba(52,47,39,.14));
  transition: transform .12s ease;
}

.tray-sticker:hover svg,
.tray-sticker:focus-visible svg {
  transform: translateY(-3px) rotate(-1deg) scale(1.04);
}

.tray-empty {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  color: #9e9587;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
}

#ghost {
  position: fixed;
  z-index: 120;
  width: var(--hot);
  height: var(--hot);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08) rotate(-1deg);
  filter: drop-shadow(0 12px 8px rgba(52,47,39,.28));
}

#ghost svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ----------------------------------------------------- sticker library */

.sticker-overlay {
  position: fixed;
  inset: 0 0 calc(var(--hot) + 30px + env(safe-area-inset-bottom)) 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vmin, 30px);
  pointer-events: none;
}

.library-backdrop,
.adult-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(34,42,37,.28);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.sticker-library-panel {
  position: relative;
  width: min(920px, 96vw);
  max-height: min(72vh, 650px);
  overflow: auto;
  pointer-events: auto;
  padding: clamp(16px, 2.8vmin, 28px);
  border: 1px solid #cfc3af;
  border-radius: 24px 18px 27px 20px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(111,91,61,.028) 0,
      rgba(111,91,61,.028) 1px,
      transparent 1px,
      transparent 10px
    ),
    #fbf5e8;
  box-shadow:
    0 3px 0 rgba(110,93,67,.12),
    0 22px 60px rgba(37,33,27,.28);
}

.sticker-library-panel.return-ready {
  border-color: rgba(239,86,81,.72);
  box-shadow:
    0 0 0 4px rgba(239,86,81,.16),
    0 22px 60px rgba(37,33,27,.28);
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.library-header h2 { font-size: clamp(24px, 4vw, 36px); }

.sticker-catalog-tools {
  display: grid;
  gap: 10px;
  margin: -2px 0 14px;
}

.sticker-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfc3af;
  border-radius: 13px;
  background: rgba(255,253,247,.96);
  padding: 9px 12px;
  color: var(--ink);
  font: inherit;
}

.sticker-search input:focus {
  outline: 2px solid rgba(85,126,90,.28);
  outline-offset: 1px;
}

.sticker-categories {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.sticker-themes {
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(126, 111, 89, .12);
}

.sticker-theme {
  background: rgba(239, 247, 250, .88);
  border-color: #c4d5dc;
}

.sticker-theme.active,
.sticker-theme[aria-pressed="true"] {
  background: #e7f2f6;
  border-color: #81aebf;
  color: #315f70;
}

.sticker-category {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid #d4c9b8;
  border-radius: 999px;
  background: rgba(255,253,247,.86);
  padding: 6px 11px;
  color: #6d665b;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.sticker-category.active,
.sticker-category[aria-pressed="true"] {
  border-color: #8eae93;
  background: #edf5ec;
  color: #42634a;
}

.sticker-library-empty {
  margin: 12px 2px 0;
  color: #81786b;
  font-size: 13px;
}

.sticker-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
}

.library-sticker,
.make-sticker-card {
  min-height: 150px;
  border: 1px solid #d4c9b8;
  border-radius: 16px;
  background: rgba(255,253,247,.88);
  box-shadow: 0 3px 8px rgba(75,63,49,.07);
  cursor: grab;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 10px;
  touch-action: none;
}

.library-sticker:hover,
.library-sticker:focus-visible,
.make-sticker-card:hover,
.make-sticker-card:focus-visible {
  background: #fffdf7;
  transform: translateY(-2px);
}

.library-sticker svg {
  width: 94px;
  height: 94px;
  overflow: visible;
}

.library-sticker span,
.make-sticker-card span {
  font-size: 12px;
  font-weight: 750;
  text-transform: capitalize;
  color: #766e61;
}

.make-sticker-card {
  cursor: pointer;
  border-style: dashed;
  color: #d94d48;
}

.make-sticker-card .make-plus {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--coral-soft);
  font-size: 42px;
  font-weight: 300;
}

.sticker-maker-view {
  min-height: 320px;
}

.maker-back {
  margin: 0 0 12px;
  border: 0;
  background: transparent;
  color: #5b8264;
  font-weight: 800;
  cursor: pointer;
}


.help-orb {
  position: fixed;
  z-index: 76;
  left: max(18px, calc(env(safe-area-inset-left) + 12px));
  top: max(18px, calc(env(safe-area-inset-top) + 12px));
  width: clamp(48px, 6.5vmin, 60px);
  height: clamp(48px, 6.5vmin, 60px);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 50%;
  background: rgba(255,253,247,.88);
  box-shadow: 0 8px 24px rgba(42,53,45,.18);
  color: #4f6c58;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: clamp(24px, 3.4vmin, 31px);
  font-weight: 900;
  backdrop-filter: blur(6px);
  transition: transform .14s ease, background .14s ease;
}

.help-orb:hover,
.help-orb:focus-visible {
  transform: translateY(-2px);
  background: rgba(255,255,250,.96);
}

.child-help-panel {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 18px;
}

.help-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(34,42,37,.28);
  backdrop-filter: blur(3px);
}

.help-card {
  position: relative;
  z-index: 1;
  width: min(760px, 94vw);
  max-height: min(84vh, 760px);
  overflow: auto;
  padding: clamp(24px, 4vmin, 38px);
  border: 1px solid #d5c9b8;
  border-radius: 26px 20px 28px 22px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(32,29,24,.30);
  color: var(--ink);
  user-select: text;
}

.help-card .round-control {
  position: absolute;
  top: 14px;
  right: 14px;
}

.help-card h2 {
  margin: 0 58px 8px 0;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: -.03em;
}

.help-card > p {
  max-width: 62ch;
  color: var(--muted);
  font-size: clamp(16px, 2.4vmin, 19px);
  line-height: 1.45;
}

.help-topics {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 12px;
}

.help-topic {
  padding: 15px 16px;
  border: 1px solid #ded3c3;
  border-radius: 16px;
  background: #faf6ed;
}

.help-topic h3 {
  margin: 0 0 6px;
  color: #456c52;
  font-size: 17px;
}

.help-topic p {
  margin: 0;
  color: #5f625e;
  line-height: 1.42;
}

/* --------------------------------------------------------------- adult */

.adult-panel {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: 18px;
}

.adult-card {
  position: relative;
  z-index: 1;
  width: min(680px, 94vw);
  max-height: min(88vh, 820px);
  overflow: auto;
  padding: 28px;
  border-radius: 18px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(32,29,24,.32);
  user-select: text;
}

.adult-card .round-control {
  position: absolute;
  top: 14px;
  right: 14px;
}

.adult-card p {
  max-width: 44ch;
  color: var(--muted);
}

.adult-card a {
  display: inline-block;
  margin-top: 6px;
  color: #376d8c;
  font-weight: 750;
}

.adult-guide {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #ddd2c3;
}

.adult-guide h3 {
  margin: 0 48px 8px 0;
  font-size: 20px;
}

.adult-guide > p {
  max-width: 60ch;
  margin: 0 0 12px;
  line-height: 1.45;
}

.adult-guide-section {
  margin: 8px 0;
  border: 1px solid #ddd2c3;
  border-radius: 12px;
  background: #fbf7ef;
}

.adult-guide-section summary {
  padding: 11px 13px;
  cursor: pointer;
  font-weight: 800;
  color: #496953;
}

.adult-guide-section p {
  max-width: none;
  margin: 0;
  padding: 0 13px 11px;
  line-height: 1.45;
}

.adult-developer-links {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #ddd2c3;
}

.adult-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
}

.agent-adult-controls {
  margin: 18px 0 12px;
  padding: 14px;
  border: 1px solid #d8cebe;
  border-radius: 14px;
  background: #f8f3e9;
}

.adult-inference {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid #d8cebe;
  border-radius: 14px;
  background: #fffaf1;
}

.adult-inference > strong {
  color: #496953;
  font-size: 15px;
}

.adult-inference label {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 800;
  color: #67645d;
}

.adult-inference select,
.adult-inference input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfc4b3;
  border-radius: 10px;
  background: #fffef9;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

.adult-inference select:disabled,
.adult-inference input:disabled {
  opacity: .62;
  cursor: not-allowed;
}

.adult-inference button {
  justify-self: start;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid #b8c7b8;
  border-radius: 10px;
  background: #eef5eb;
  color: #3f654b;
  font-weight: 800;
  cursor: pointer;
}

.adult-inference button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.adult-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  cursor: pointer;
}

.adult-toggle input {
  position: relative;
  z-index: 1;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin: 0;
  cursor: pointer;
  pointer-events: auto;
}

.adult-toggle span {
  pointer-events: none;
}

.adult-note {
  margin: 7px 0 12px !important;
  font-size: 12px;
}

/* ------------------------------------------------------------ developer */

#dev[hidden] { display: none; }

#dev {
  position: fixed;
  z-index: 160;
  top: 10px;
  left: max(10px, env(safe-area-inset-left));
  width: min(300px, calc(100vw - 20px));
  max-height: min(78vh, 680px);
  overflow: auto;
  padding: 42px 12px 12px;
  border: 1px solid #cdc7bb;
  border-radius: 10px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 6px 22px rgba(30,30,30,.17);
  font-size: 13px;
  user-select: text;
}

.dev-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  margin: 0;
  border: 1px solid #cdc7bb;
  border-radius: 50%;
  background: rgba(255,255,255,.96);
  color: #5d655f;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.dev-close:hover,
.dev-close:focus-visible {
  background: #fff;
  color: #26352c;
}

#dev .row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 0;
}

#dev .row span:first-child { color: var(--muted); }

#dev h2 {
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.verdict {
  margin-top: 10px;
  padding: 7px 9px;
  border: 1px solid #d5d2ca;
  border-radius: 6px;
}

.verdict.idle { color: var(--muted); }
.verdict.accepted { border-color: #b9e2cd; background: #eefaf3; color: #1d7a4c; }
.verdict.rejected { border-color: #f0c9c5; background: #fdf1f0; color: #a8332a; }

#receipts {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 11.5px;
}

#receipts li {
  padding: 5px 0;
  border-top: 1px solid #e1ddd5;
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-word;
}

#receipts .ok { color: #1d7a4c; font-weight: 700; }
#receipts .no { color: #a8332a; font-weight: 700; }

/* ------------------------------------------------------------ responsive */

@media (orientation: landscape) {
  .sticker-overlay {
    bottom: calc(var(--hot) + 14px + env(safe-area-inset-bottom));
  }
}

@media (orientation: portrait) {
  :root { --hot: clamp(58px, 15.5vmin, 84px); }

  .cover-title {
    top: 8vh;
    font-size: clamp(48px, 15vw, 96px);
  }

  .cover-hint { bottom: 13vh; }

  .sticker-overlay {
    bottom: calc(var(--hot) + 20px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .help-orb {
    width: 48px;
    height: 48px;
    left: max(10px, calc(env(safe-area-inset-left) + 8px));
    top: max(10px, calc(env(safe-area-inset-top) + 8px));
  }

  .help-card,
  .adult-card {
    width: 96vw;
    max-height: 90vh;
    border-radius: 18px;
  }

  .help-topics {
    grid-template-columns: 1fr;
  }

  .accessibility-chat {
    top: max(72px, calc(env(safe-area-inset-top) + 66px));
    width: min(94vw, 620px);
    max-height: min(31vh, 220px);
  }

  .gallery-screen,
  .creator-screen {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .page-gallery {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .page-tile {
    min-height: 140px;
    border-radius: 3px;
  }

  .page-tile-label {
    left: 7px;
    bottom: 7px;
    font-size: 11px;
    padding: 5px 8px;
  }

  .new-page-inner .plus {
    width: 58px;
    height: 58px;
    font-size: 38px;
  }

  .new-page-inner strong { font-size: 13px; }

  .sticker-library-panel {
    width: 98vw;
    padding: 13px;
    border-radius: 18px;
  }

  .sticker-library-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .library-sticker,
  .make-sticker-card {
    min-height: 116px;
    padding: 6px;
  }

  .library-sticker svg {
    width: 70px;
    height: 70px;
  }
}

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

  .sticker.alive:not(.held) .art {
    animation-duration: 2.4s;
  }
}

/* Input evidence: actual bounded pointer samples, alongside the reference box. */
.deictic-path {
  fill: none;
  stroke: rgba(255, 238, 122, .95);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
/* Pixel drafts remain previews until the child accepts a sticker design. */
.creator-preview { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.creator-preview[hidden] { display: none; }
.creator-preview img { max-width: 160px; max-height: 160px; object-fit: contain; }
.creator-preview button { flex-basis: 100%; }
