/* ─────────────────────────────────────────────────────────────
   vellichor woods — guestbook (butterflies)
   Matches guestbook.js (uses #preview-sky + .butterfly)
   ──────────────────────────────────────────────────────────── */

/* — Theme tokens — */
:root{
  --gold:#e0c97a; --cream:#f6f1e7; --moss:#0a1b18;
  --glass: rgba(44,54,51,.78);
  --paper: #efe9db;      /* fallback colour if textures fail */
  --ink:   #2b1e12;

  /* texture URLs */
  --tx-paper: url("/images/tx/paper_base.webp");
  --tx-stain: url("/images/tx/tea_stain.webp");

  /* stamp (inline SVG data URI) */
  --tx-stamp: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220'>\
<g fill='none' stroke='%23633' stroke-width='2.5'>\
<circle cx='110' cy='110' r='86'/>\
<circle cx='110' cy='110' r='70'/>\
<path d='M30 70c40 8 120 8 160 0'/>\
</g>\
<text x='110' y='115' text-anchor='middle' font-size='16' fill='%23633' font-family='Georgia,serif'>CARTE POSTALE</text>\
</svg>");
}

.guestbook body, .guestbook main{ position:relative; }

body{
  overflow-x:hidden;    /* Hide horizontal scrollbar */
  overflow-y:scroll;    /* Add vertical scrollbar */
}

.guestbook main, .gb-canvas-wrap{
  contain:layout;       /* protect from butterfly repaints */
  overflow:visible;
  will-change:contents;
}

/* ── Controls card ─────────────────────────────────────────── */
.controls{ display:flex; align-items:center; gap:.8rem; }
.controls .hint{ opacity:.85; }

/* ── Sky (butterflies from sheet) ──────────────────────────── */
.sky{
  height:min(70vh, 900px);
  position:relative;
  background: radial-gradient(1200px 600px at 50% 40%, rgba(10,27,24,.35), rgba(10,27,24,.78));
}

/* ── Flying butterflies (sheet + preview) ──────────────────── */
.butterfly{
  position:relative;
  width:120px; height:90px;
  cursor:pointer;
  will-change: transform, offset-distance;
  animation: flyAcross var(--dur, 20s) linear infinite,
             floatBob 6s ease-in-out infinite;
  transform-origin:50% 50%;
  transform: translateZ(0);
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.35));
}
.butterfly svg{ width:100%; height:100%; display:block; }
.butterfly svg{ overflow:visible; } /* ensure wings overflow is visible */

/* Translate across with a gentle vertical drift (y0→y1) */
@keyframes flyAcross{
  0%   { transform: translateX(-12%) translateY(var(--y0,0)) rotate(-2deg); }
  100% { transform: translateX(112%) translateY(var(--y1,0)) rotate(4deg); }
}
@keyframes floatBob{
  0%,100%{ transform: translateY(-2px) }
  50%    { transform: translateY(2px) }
}

/* Pause button */
.sky.paused .butterfly{ animation-play-state: paused; }

/* ── Wing flap + dark body (shared for all butterflies) ───── */
.butterfly .body{
  fill:#0b0f0d;
  stroke:rgba(224,201,122,.28);
  stroke-width:.75;
}
.butterfly .antenna{
  stroke:rgba(224,201,122,.35);
  stroke-width:1.25;
  fill:none;
  stroke-linecap:round;
}
.butterfly .wing{
  transform-box:view-box;
  transform-origin:80px 60px;
  animation: wingFlap var(--flapDur, 220ms) linear infinite alternate;
  will-change: transform;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
}
.butterfly .wing.right{ animation-delay: calc(var(--flapDur,220ms) * -0.18); }

/* vertical insect -> flap over the Y axis */
@keyframes wingFlap{
  0%   { transform: rotateY(0deg)  rotateZ(-6deg); }
  25%  { transform: rotateY(45deg) rotateZ(-1deg); }  /* halfway */
  50%  { transform: rotateY(90deg) rotateZ( 4deg); }  /* fully open */
  75%  { transform: rotateY(45deg) rotateZ(-1deg); }
  100% { transform: rotateY(0deg)  rotateZ(-6deg); }  /* back to start */
}

/* ── Composer / drawing area ───────────────────────────────── */
.gb-grid{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:1.4rem 1.6rem;
  align-items:start;
}
@media (max-width: 860px){
  .gb-grid{ grid-template-columns:1fr; }
}

.gb-canvas-wrap{
  position:relative;
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(0,0,0,.18));
  border:1px solid rgba(224,201,122,.12);
  border-radius:14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
  overflow:hidden;
}
#butterfly-canvas{
  display:block; width:100%; height:auto; max-width:100%;
  cursor:crosshair; touch-action:none;
}
.gb-midline{
  position:absolute; inset:0;
  background: linear-gradient(90deg, transparent 49.7%, rgba(224,201,122,.12) 50%, transparent 50.3%);
  pointer-events:none;
}

/* tools */
.gb-tools{
  display:flex; flex-wrap:wrap; gap:.6rem .8rem;
  align-items:center; margin-top:.7rem;
}
.gb-tool{ display:flex; align-items:center; gap:.5rem; }
#gb-brush{ width:160px; }

.gb-palette{
  display:flex; flex-wrap:wrap; gap:.35rem;
  padding:.2rem .1rem;
}
.gb-swatch{
  width:22px; height:22px; border-radius:50%;
  border:1px solid rgba(0,0,0,.35);
  box-shadow: 0 0 0 1px rgba(255,255,255,.15) inset;
  cursor:pointer;
}
.gb-swatch:focus-visible{ outline:2px solid var(--gold); outline-offset:2px; }

/* fields */
.gb-fields{ display:grid; gap:.9rem; }
.gb-field{ display:grid; gap:.35rem; }
.gb-field input, .gb-field textarea{
  width:100%;
  background: rgba(255,255,255,.92);
  color:#1b1f1d;
  border:1px solid rgba(224,201,122,.28);
  border-radius:10px;
  padding:.55rem .7rem;
  font:inherit;
}

/* actions/buttons */
.gb-actions{ margin-top:.4rem; }

.pill{
  appearance:none; border:1px solid rgba(224,201,122,.35);
  background: rgba(224,201,122,.14); color: var(--cream);
  padding:.45rem .8rem; border-radius:999px; cursor:pointer;
}
.pill:hover{ background: rgba(224,201,122,.22); }
.pill.primary{ background: rgba(224,201,122,.22); border-color: rgba(224,201,122,.45); }
.pill.primary:hover{ background: rgba(224,201,122,.32); }

/* ── Guestbook card surface ───────────────────────────────── */
.card.sky, .card.controls, .card.guestbook{ background: var(--glass); }
.guestbook h2{ margin-bottom:.8rem; }
.card.sky{ background: rgba(168, 160, 104, .3); }

/* ── Preview runway (bottom-right, non-overlapping) ───────── */
.card.guestbook{ position:relative; }

/* This matches the JS: document.getElementById('preview-sky') */
#preview-sky{
  position:absolute;
  left:524px;            /* leave space for canvas column */
  right:24px;
  bottom:10px;
  height:170px;          /* “bottom yellow zone” runway */
  pointer-events:none;   /* only the butterflies catch clicks */
  overflow:visible;
}
#preview-sky .butterfly{ pointer-events:auto; }
#preview-sky .butterfly .wing{ --flapDur: 600ms; }  /* slower */

/* hide runway on small screens */
@media (max-width: 900px){
  #preview-sky{ display:none; }
}

/* ── Generic buttons (for top controls + modal) ───────────── */
.btn{
  appearance:none; border:1px solid rgba(224,201,122,.35);
  background: rgba(224,201,122,.12);
  color: var(--cream);
  padding:.45rem .75rem; border-radius:999px; cursor:pointer;
}
.btn:hover{ border-color: rgba(224,201,122,.6); }
.btn.primary{ background: rgba(224,201,122,.2); }
.btn.ghost{ background: transparent; }

/* ── Vintage note modal ───────────────────────────────────── */
.note-backdrop{
  position:fixed; inset:0; display:grid; place-items:center; z-index:30;
  /* warm, smoky vignette */
  background:
    radial-gradient(1100px 600px at 50% 40%, rgba(30,20,10,.35), rgba(15,10,6,.85));
  backdrop-filter: blur(1px);
}

/* Paper window with layered textures */
.note-window{
  position:relative;
  width:min(620px, 92vw);
  color:var(--ink);
  border-radius:8px;
  overflow:hidden;
  aspect-ratio:1280 / 768;

  /* Multi-background: paper base, stains, grain */
  background:
    var(--tx-stain) center/110% 110% no-repeat,   /* stains (multiplied) */
    var(--tx-paper) center/cover no-repeat,       /* base fibre */
    var(--paper);                                 /* solid fallback */
  background-blend-mode: multiply, normal, normal;

  /* age + depth */
  filter: saturate(.9) sepia(.08);
  box-shadow:
    0 28px 80px rgba(0,0,0,.55),
    0 0 0 1px rgba(0,0,0,.10) inset,
    0 18px 36px rgba(0,0,0,.18) inset;
  padding:0;
}

/* edge darkening + deckled feel + corner tape + stamp are pseudo-elements */
.note-window::before{
  content:"";
  position:absolute; inset:0; pointer-events:none;
  /* inner vignette & rough edge */
  background:
    radial-gradient(140% 110% at -10% -10%, #0000 60%, #000 72%),
    radial-gradient(140% 110% at 110% -10%, #0000 60%, #000 72%),
    radial-gradient(140% 110% at -10% 110%, #0000 60%, #000 72%),
    radial-gradient(140% 110% at 110% 110%, #0000 60%, #000 72%);
  background-repeat:no-repeat;
  background-size:50% 50%;
  mix-blend-mode:multiply;
  opacity:.28;
}
.note-window::after{
  content:"";
  position:absolute; inset:0; pointer-events:none;
  /* stamp + subtle crease lines */
  background:
    var(--tx-stamp) top 24px right 28px / 120px 120px no-repeat,
    linear-gradient(90deg, #0000 0 55%, rgba(0,0,0,.05) 56% 57%, #0000 58%) center/100% 100% no-repeat;
  opacity:.55;
  mix-blend-mode:multiply;
  transform: rotate(-0.2deg);
}

/* optional tape corners (tiny gradients) */
.note-window .tape{
  position:absolute; width:84px; height:22px; background:
    linear-gradient(#eddabc,#d1b28c);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  opacity:.75; mix-blend-mode:multiply;
}
.note-window .tape.tl{ top:10px; left:12px; transform: rotate(-12deg); }
.note-window .tape.tr{ top:10px; right:14px; transform: rotate(9deg); }

/* Header strip */
.note-head{ display:none; }

/* Body: printlike text with subtle letterpress shadow */
.note-body{
  padding:1.1rem 1.25rem 1.4rem;
  position:absolute; inset:0;
  font-family:"EB Garamond", Georgia, serif;
  font-size:1.05rem;
  line-height:1.55;
  color:#2a1f15;
  text-shadow: 0 .4px 0 rgba(0,0,0,.15);
}

/* Handwritten flavour for name/signature lines if you add them */
.note-body em, .note-body .sig{
  font-style:italic;
  letter-spacing:.2px;
}
.note-body .sig{ text-align:right; opacity:.9; }

/* these two overrides intentionally come AFTER the ::before/::after defs */
.note-window::before{ opacity:0; }   /* or remove entirely */
.note-window::after{ content:none; } /* no extra stamp/crease */

/* Message block: LEFT panel (yellow rectangle) */
.note-message{
  position:absolute;
  top:10%; left:6%;
  width:38%; height:72%;
  display:flex; align-items:center; /* vertical centring */
  justify-content:flex-start; text-align:left;
  pointer-events:auto;  /* text selectable / scrollable */
  overflow:auto;
}

/* Signature block: LOWER-RIGHT strip (red rectangle) */
.note-sig{
  position:absolute;
  bottom:9%; right:6%;
  width:32%;
  text-align:center;
  font-style:italic;
  pointer-events:auto;
}

/* Optional: scale down text a touch on small modals */
@media (max-width: 640px){
  .note-body{ font-size:1rem; }
}

/* ── Reduced motion: show static list instead of flying chaos ─ */
@media (prefers-reduced-motion: reduce){
  .sky{ height:auto; }
  .butterfly{ position:static; display:block; margin:.4rem 0; animation:none; }
}

/* ── Small screens layout tweaks ──────────────────────────── */
@media (max-width: 760px){
  .gb-grid{ grid-template-columns:1fr; }
  .sky{ height:60vh; }
}

/* ── SKY-ONLY MOVEMENT (leave preview alone) ──────────────── */

/* Motion-path flight for butterflies inside the sky only */
.sky .butterfly{
  position:absolute;
  top:0; left:0;

  /* fixed box; we scale via transform only */
  width:120px;
  height:90px;

  offset-path: var(--path);
  offset-distance:0%;
  offset-rotate: var(--rot, auto 90deg);

  /* apply size here (no double scaling) */
  transform: translate(calc(-50% + var(--bx,0px)),
                       calc(-50% + var(--by,0px)))
             scale(var(--s,1));

  animation:
    travel var(--dur, 22s) linear infinite var(--delay, 0s),
    bob 6s ease-in-out infinite;
}

/* advance along the path */
@keyframes travel{ to{ offset-distance:100%; } }

/* gentle vertical bob using a variable */
@keyframes bob{
  0%,100%{ --by:-2px; }
  50%    { --by: 2px; }
}

/* keep pause behaviour */
.sky.paused .butterfly{ animation-play-state: paused; }

/* base sticker behaviour */
.note-window{ position:relative; }
.sticker{
  position:absolute; left:50%; top:50%;
  transform: translate(-50%,-50%) rotate(var(--r,0deg)) scale(var(--s,1));
  transform-origin:50% 50%;
  user-select:none; touch-action:none; cursor:grab;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.sticker:active{ cursor:grabbing; }

/* stickers (placed instances) */
.note-window .sticker{
  position:fixed;  /* absolute to viewport; we place with client px */
  left:0; top:0;
  width:auto; height:auto;
  transform-origin:50% 50%;
  user-select:none;
  touch-action:none;
  pointer-events:auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
}

/* visually mark “chosen” when on the card */
.note-window .sticker.on-card{
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.35));
}

/* palette around the modal */
.deco-dock{ position:fixed; inset:0; pointer-events:none; z-index:40; }
.deco-dock .dock{
  position:absolute; display:flex; gap:8px; pointer-events:auto;
  background: rgba(255,255,240,0);
  padding:6px; border-radius:8px;
  
}
.deco-dock .dock.left  { left:10px;  top:50%; transform: translateY(-50%); flex-direction:column; }
.deco-dock .dock.right { right:10px; top:50%; transform: translateY(-50%); flex-direction:column; }
.deco-dock .dock.top   { top:10px;   left:50%; transform: translateX(-50%); }

.deco-dock img.palette{
  width:64px; height:auto; cursor:grab; user-select:none; touch-action:none;
}
.deco-dock .dock-clear{ margin-left:6px; }

/* postcard clipping area */
.note-window .card-clip{
  position:absolute;
  border-radius:10px;             /* match your card corners */
  pointer-events:auto;
  z-index:2;
}

/* placed stickers (inside clip) */
.note-window .card-clip .sticker{
  position:absolute;               /* relative to card-clip */
  left:0; top:0;
  transform-origin:50% 50%;
  user-select:none;
  touch-action:none;
  will-change: transform, left, top;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.35));
}

/* dragging clone (lives on the modal root while dragging) */
.note-window .sticker.dragging{
  position:fixed;                  /* follows cursor by viewport */
  left:0; top:0;
  transform-origin:50% 50%;
  pointer-events:none;             /* ignore accidental hits */
  z-index:9999;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.35));
}


/* Defaults so we don't need var() fallbacks with commas */
:root{
  --xj: 0px;        /* palette jitter X */
  --yj: 0px;        /* palette jitter Y */
  --rotj: 0deg;     /* palette jitter rotation */
  --bobDur: 900ms;  /* palette bob duration */
}

/* ───────── Floating palette rails (no panel, gentle bob on pointers=fine) */
.deco-dock .dock{
  background: none;
  box-shadow: none;
  gap: 8px;
}

.deco-dock img.palette{
  /* no commas in translate; declare defaults above */
  transform: translateX(var(--xj)) translateY(var(--yj)) rotate(var(--rotj));
  filter:
    drop-shadow(0 8px 16px rgba(0,0,0,.28))
    drop-shadow(0 0 12px rgba(224,201,122,.20));
}

/* keyframes MUST live at top level for stricter parsers */
@keyframes paletteBob {
  from { transform: translateX(var(--xj)) translateY(calc(var(--yj) - 2px)) rotate(var(--rotj)); }
  to   { transform: translateX(var(--xj)) translateY(calc(var(--yj) + 2px)) rotate(var(--rotj)); }
}

/* only animate palette on precise pointers (not phones) */
@media (pointer: fine){
  .deco-dock img.palette{
    animation: paletteBob var(--bobDur) ease-in-out var(--delay, 0ms) infinite alternate;
  }
}

/* ───────── Placed stickers ON the card: static + no glow/bob */
.note-window .card-clip .sticker{
  animation: none !important;               /* absolutely no bob */
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.35)) !important; /* simple shadow only */
  transition: none;
}


/* ───────────────── Clear button (matches your theme) ────── */
.dock-clear{
  all: unset;
  display: inline-flex; align-items: center; justify-content: center;
  padding: .42rem .8rem;
  border-radius: 999px;
  border: 1px solid rgba(224,201,122,.45);
  color: var(--cream);
  background: rgba(224,201,122,.20);
  cursor: pointer;
  font: 500 0.95rem/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  letter-spacing:.02em;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 6px 18px rgba(0,0,0,.25);
  transition: filter .15s ease, transform .15s ease, background .2s ease;
}
.dock-clear:hover{ background: rgba(224,201,122,.28); filter: brightness(1.06); }
.dock-clear:active{ transform: translateY(1px) scale(.98); }
/* smaller on phone */
@media (pointer: coarse){ .dock-clear{ padding: .52rem .9rem; font-size: 1rem; } }


/* ============================================================
   Responsive & Mobile Add-ons (append after existing CSS)
   ============================================================ */

/* Touch ergonomics */
@media (pointer: coarse) {
  .btn, .pill { padding: .6rem .9rem; }
  .gb-swatch { width: 28px; height: 28px; }
  .deco-dock img.palette { width: 56px; }
  #gb-brush { width: 100%; }
}

/* <= 900px: keep runway hidden (already), tighten gaps a bit */
@media (max-width: 900px) {
  .controls { gap: .6rem; }
  .gb-tools { gap: .5rem .6rem; }
}

/* <= 760px: stack composer; soften sky height a touch */
@media (max-width: 760px) {
  .gb-grid { grid-template-columns: 1fr; }
  .sky { height: 60vh; } /* keep existing behaviour */
  .gb-fields { gap: .8rem; }
  .gb-field input, .gb-field textarea { padding: .5rem .65rem; }
}

/* <= 640px: smaller typography in modal; tighter card fit */
@media (max-width: 640px) {
  .note-body { font-size: 1rem; } /* you already set this; reaffirm for priority */
  .note-window { width: min(560px, 94vw); }
  .note-message { top: 9%; left: 6%; width: 86%; height: 68%; } /* give text more width */
  .note-sig { right: 6%; bottom: 8%; width: 70%; }
  .gb-canvas-wrap { border-radius: 12px; }
  .gb-swatch { width: 26px; height: 26px; }
}

/* <= 540px: shrink preview butterflies & inputs fit width */
@media (max-width: 540px) {
  /* preview butterflies (runway is hidden at <=900px, but keep size sane if shown) */
  #preview-sky .butterfly { width: 96px; height: 72px; }

  .controls { flex-wrap: wrap; }
  .gb-tool { flex-wrap: wrap; }
  #gb-brush { width: 100%; max-width: 420px; }
  .gb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .btn, .pill { width: 100%; text-align: center; }
}

/* <= 480px: scale sheet butterflies slightly; simplify spacing */
@media (max-width: 480px) {
  .sky { height: 56vh; }

  /* override the motion-path transform to add an extra downscale */
  .sky .butterfly {
    transform:
      translate(calc(-50% + var(--bx,0px)), calc(-50% + var(--by,0px)))
      scale(calc(var(--s,1) * .9));
  }

  .gb-palette { gap: .3rem; }
  .gb-swatch { width: 24px; height: 24px; }
  .deco-dock .dock { gap: 6px; padding: 5px; }
  .deco-dock img.palette { width: 48px; }
}

/* <= 400px: tighter sky, smaller butterflies, denser modal */
@media (max-width: 400px) {
  .sky { height: 52vh; }

  .sky .butterfly {
    transform:
      translate(calc(-50% + var(--bx,0px)), calc(-50% + var(--by,0px)))
      scale(calc(var(--s,1) * .82));
  }

  .note-window { width: 96vw; }
  .note-message { top: 8%; left: 6%; width: 88%; height: 66%; }
  .note-sig { width: 80%; font-size: .95rem; }
  .btn, .pill { padding: .55rem .75rem; }
}

/* Ultra-narrow: keep everything readable and tappable */
@media (max-width: 340px) {
  .sky { height: 48vh; }
  .gb-swatch { width: 22px; height: 22px; }
  .deco-dock img.palette { width: 42px; }
  .note-body { font-size: .95rem; line-height: 1.5; }
}

/* Orientation tweaks for short landscape phones */
@media (max-height: 460px) and (orientation: landscape) {
  .sky { height: 54vh; }
  .gb-grid { grid-template-columns: 1fr; }
  .gb-actions { grid-template-columns: 1fr 1fr; }
  .note-window { width: 92vw; }
}

/* Extra safety: reduce animation cost on low-end mobiles */
@media (pointer: coarse) and (max-width: 540px) {
  .butterfly { filter: drop-shadow(0 4px 10px rgba(0,0,0,.3)); }
  .butterfly .wing { filter: drop-shadow(0 1px 4px rgba(0,0,0,.22)); }
}


/* ============================================================
   Make the preview runway visible and well-placed on mobiles
   ============================================================ */

/* Re-enable the runway below 900px */
@media (max-width: 900px){
  /* Win over the earlier hide */
  .card.guestbook #preview-sky{
    display: block !important;
  }
}

/* Stack layout: put the runway under the composer/card on small screens */
@media (max-width: 760px){
  .card.guestbook{
    /* ensures the runway sits in normal flow under the card */
    display: block;
  }

  #preview-sky{
    position: static;             /* no absolute offsets on mobile */
    left: auto; right: auto; bottom: auto;
    height: 140px;                /* comfy runway height */
    margin-top: 10px;             /* breathing room below the card */
    overflow: visible;            /* wings can flap beyond the box */
    pointer-events: none;         /* matches desktop intent */
  }
  #preview-sky .butterfly{
    pointer-events: auto;         /* keep butterflies tappable */
    width: 96px;                  /* slightly smaller on phones */
    height: 72px;
  }
  #preview-sky .butterfly .wing{
    --flapDur: 650ms;             /* a touch slower for mobile */
  }
}

/* Extra-small phones: a bit tighter, but still readable */
@media (max-width: 480px){
  #preview-sky{
    height: 120px;
    margin-top: 8px;
  }
  #preview-sky .butterfly{
    width: 88px;
    height: 66px;
  }
}

/* Ultra-narrow safety net */
@media (max-width: 360px){
  #preview-sky{
    height: 110px;
  }
  #preview-sky .butterfly{
    width: 80px;
    height: 60px;
  }
}


/* phone-ish widths */
@media (max-width: 640px){
  .deco-dock { display:flex; align-items:center; justify-content:center; }

  /* stack the three docks into two rows: top (as-is) and bottom (merge left+right) */
  .deco-dock .dock { gap: 6px; padding: 6px; border-radius: 10px; }
  .deco-dock .dock.top {
    position: fixed;
    top: 8px; left: 50%; transform: translateX(-50%);
    flex-direction: row; flex-wrap: wrap;
  }
  /* turn left & right into two bottom rails */
  .deco-dock .dock.left,
  .deco-dock .dock.right {
    position: fixed;
    top: auto; bottom: 8px; transform: none;
    flex-direction: row; flex-wrap: nowrap;
  }
  .deco-dock .dock.left  { left: 8px; }
  .deco-dock .dock.right { right: 8px; }

  /* make palette thumbs a bit smaller on phones */
  .deco-dock img.palette { width: 52px; }
}

/* allow two-finger gestures to reach your handlers */
.note-window .card-clip,
.note-window .card-clip .sticker{
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

/* Phone layout: put preview to the right of the heading */
@media (max-width: 760px){
  /* make sure the guestbook card is a positioning context */
  .card.guestbook{ position: relative; }

  /* give the heading room so text doesn't overlap the preview */
  .guestbook h2{
    position: relative;
    padding-right: 130px;       /* matches preview width + gutter */
    min-height: 44px;           /* keeps a nice tap target line */
  }

  /* park the preview area to the right of the heading */
  #preview-sky{
    display: block !important;  /* re-enable on mobile */
    position: absolute;
    top: 6px;                   /* align with heading cap height */
    right: 12px;
    width: 116px;               /* fixed box: fully on-screen */
    height: 84px;
    overflow: hidden;           /* ensure it never spills */
    pointer-events: none;       /* taps go to the butterfly only */
  }
  #preview-sky .butterfly{
    pointer-events: auto;

    /* keep it inside the box: only bob, no flyAcross */
    position: absolute; left: 50%; top: 50%;
    width: 96px; height: 72px;
    transform: translate(-50%,-50%);
    animation: floatBob 650ms ease-in-out infinite !important;
    overflow: visible;
  }
}

/* extra-tight phones: shave sizes a bit more */
@media (max-width: 400px){
  .guestbook h2{ padding-right: 112px; }
  #preview-sky{ width: 100px; height: 74px; overflow: visible;}
  #preview-sky .butterfly{ width: 88px; height: 66px; }
}

/* Placed stickers: static + no glow */
.note-window .card-clip .sticker{
  animation: none !important;              /* no bob */
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.35)) !important;  /* remove warm glow */
}

/* Base golden glow for palette thumbs (desktop only bob still applies) */
.deco-dock img.palette{
  /* keep your jitter transform from earlier */
  transform: translateX(var(--xj)) translateY(var(--yj)) rotate(var(--rotj));
  filter:
    drop-shadow(0 10px 18px rgba(0,0,0,.28))
    drop-shadow(0 0 14px rgba(224,201,122,.28))
    drop-shadow(0 0 24px rgba(224,201,122,.18));
  transition: filter .18s ease, transform .14s ease;
}

/* Slightly stronger glow at night to “match the butterflies’ glow feel” */
body.night .deco-dock img.palette{
  filter:
    drop-shadow(0 10px 18px rgba(0,0,0,.28))
    drop-shadow(0 0 18px rgba(224,201,122,.36))
    drop-shadow(0 0 28px rgba(224,201,122,.24));
}

/* Flare on hover (and tap-focus via :focus-visible) */
@keyframes stickerFlare {
  0%   { filter: drop-shadow(0 10px 18px rgba(0,0,0,.28))
                 drop-shadow(0 0 16px rgba(224,201,122,.35))
                 drop-shadow(0 0 26px rgba(224,201,122,.22)); }
  55%  { filter: drop-shadow(0 10px 18px rgba(0,0,0,.28))
                 drop-shadow(0 0 28px rgba(224,201,122,.55))
                 drop-shadow(0 0 44px rgba(224,201,122,.38)); }
  100% { filter: drop-shadow(0 10px 18px rgba(0,0,0,.28))
                 drop-shadow(0 0 18px rgba(224,201,122,.36))
                 drop-shadow(0 0 28px rgba(224,201,122,.24)); }
}

.deco-dock img.palette:hover,
.deco-dock img.palette:focus-visible{
  transform: translateX(var(--xj)) translateY(var(--yj)) rotate(var(--rotj)) scale(1.06);
  animation: stickerFlare 420ms ease-out 1;
}

/* Keep placed stickers on-card static (no bob/no glow) */
.note-window .card-clip .sticker{
  animation: none !important;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.35)) !important;
}


/* ========== Quick Undo/Redo (icon-only) ========== */
.gb-canvas-wrap{ position: relative; }

.gb-quick {
  position:absolute;
  top:8px;
  right:-44px;                  /* tucks into the gutter, like your red box */
  display:flex; gap:10px;
  pointer-events:auto; z-index:5;
}
@media (max-width: 860px){
  .gb-quick{ right:8px; }       /* keep on-canvas on narrow screens */
}

/* icon buttons – no boxes */
.icon-btn{
  appearance:none; border:0; background:transparent; padding:0;
  width:26px; height:26px; display:inline-block; cursor:pointer;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
  opacity:.9; transition: opacity .15s ease, transform .08s ease;
}
.icon-btn:hover{ opacity:1; }
.icon-btn:active{ transform: translateY(1px); }

/* arrows */
#gb-undo, #gb-redo{
  width:26px; height:26px; background-size:contain; background-repeat:no-repeat; background-position:center;
}
/* icon sprites (MIT — Bootstrap Icons) */
:root{
  /* Brush */
  --ico-brush: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23e0c97a'>\
<path d='M15.825.12a.5.5 0 0 1 .056.706l-7.036 8.5c-.272.329-.55.558-.79.67-.308.144-.64.106-.95.023l-.02-.006a4.92 4.92 0 0 0-.573-.128 3.993 3.993 0 0 0-.497-.05c-.246 0-.532.041-.838.13-1.317.38-2.533 1.464-3.478 3.607a.75.75 0 0 1-1.39-.6C.41 10.71 1.93 9.29 3.66 8.79c.43-.125.83-.174 1.18-.174.203 0 .393.016.562.038l.132.02.03.005.02.004c.193.046.264.044.302.026.04-.02.134-.089.287-.274L14.999.064a.5.5 0 0 1 .826.056z'/>\
</svg>");

  /* Eraser (filled) */
  --ico-eraser: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23e0c97a' stroke-width='1.5'>\
<path d='M8.086 2.207a2 2 0 0 1 2.828 0l3.879 3.879a2 2 0 0 1 0 2.828l-5.5 5.5A2 2 0 0 1 7.879 15H5.12a2 2 0 0 1-1.414-.586l-2.5-2.5a2 2 0 0 1 0-2.828z'/>\
<path d='M8.746 13.547 3.453 8.254 1.914 9.793a1 1 0 0 0 0 1.414l2.5 2.5A1 1 0 0 0 5.12 14h2.759a1 1 0 0 0 .867-.453z'/>\
</svg>");

  /* Undo (arrow-counterclockwise) */
  --ico-undo: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23e0c97a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'>\
<path d='M8 3a5 5 0 1 0 4.546 2.914'/>\
<path d='M1 3.5h4v4'/>\
</svg>");

  /* Redo (arrow-clockwise) */
  --ico-redo: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23e0c97a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'>\
<path d='M8 3a5 5 0 1 1-4.546 2.914'/>\
<path d='M15 3.5h-4v4'/>\
</svg>");
}

/* apply the sprites */
#gb-tool-brush{  background-image: var(--ico-brush); }
#gb-erase{       background-image: var(--ico-eraser); }
#gb-undo{        background-image: var(--ico-undo);   }
#gb-redo{        background-image: var(--ico-redo);   }


/* ========== Brush / Eraser toggle (pictograms) ========== */
.tool-toggle{
  display:flex; align-items:center; gap:10px;
}
.icon-pill{
  appearance:none; border:0; background:transparent; padding:0;
  width:26px; height:26px; cursor:pointer; opacity:.85; transition: opacity .15s ease, transform .08s ease;
  background-size:contain; background-repeat:no-repeat; background-position:center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}
.icon-pill:hover{ opacity:1; }
.icon-pill:active{ transform: translateY(1px); }
.icon-pill.active{
  filter: drop-shadow(0 0 6px rgba(224,201,122,.45)) drop-shadow(0 1px 2px rgba(0,0,0,.45));
}


/* hide the old label word if it exists */
.gb-tools .brush-label{ display:none !important; }

/* keep this: the wrap is the positioning context */
.gb-canvas-wrap{ position: relative; }

/* put the arrows inside the canvas box, top-right */
.gb-quick{
  position:absolute;
  top:12px;
  right:12px;     /* ← was -44px; put them inside so overflow:hidden doesn’t clip */
  display:flex; gap:10px;
  pointer-events:auto;
  z-index:15;
}

@media (max-width: 860px){
  .gb-quick{ top:10px; right:10px; }
}


