/* The three houses use the same grid and individually painted window states. */
body[data-theme="midnight"] {
  --skin-sky-top: #081633;
  --skin-sky-bottom: #112955;
  --skin-wall: #8daed4;
  --skin-on-sky-muted: #e1e9f8;
  --skin-ink: #212e4d;
  --skin-card: #fffaf0;
  --skin-line: #d6dce8;
  --skin-accent: #233f6a;
  --skin-snow-floor: #a6c1ed;
  --skin-pill: #172d54;
  --skin-pill-border: #6a82a6;
  --skin-progress-track: #354b6b;
  --skin-panel: #f7f7f2;
  --skin-panel-ink: #455474;
  --art-night-sky: url("/art/midnight/night-sky.webp?v=2");
  --art-snowbank: url("/art/midnight/snowbank.webp?v=2");
  --art-christmas-tree-left: url("/art/midnight/christmas-tree-left.webp?v=2");
  --art-christmas-tree-right: url("/art/midnight/christmas-tree-right.webp?v=2");
  --art-distant-pines: url("/art/midnight/distant-pines.webp?v=2");
  --art-wreath: url("/art/midnight/wreath.webp?v=3");
  --art-roof: url("/art/midnight/roof.webp?v=2");
  --art-wall: url("/art/midnight/wall.webp?v=2");
  --art-eave-lights: url("/art/midnight/eave-lights.webp?v=2");
  --art-window-dark: url("/art/midnight/window-dark.webp?v=2");
  --art-window-lit: url("/art/midnight/window-lit.webp?v=2");
  --art-window-opened: url("/art/midnight/window-opened.webp?v=2");
  --art-pine-sprig: url("/art/midnight/pine-sprig.webp?v=2");
}

body[data-theme="gingerbread"] {
  --skin-sky-top: #291816;
  --skin-sky-bottom: #533023;
  --skin-wall: #ba825c;
  --skin-on-sky-muted: #f3dfcc;
  --skin-ink: #3d261e;
  --skin-card: #fff7e9;
  --skin-line: #e5d3be;
  --skin-accent: #784027;
  --skin-snow-floor: #d6ac8d;
  --skin-pill: #442923;
  --skin-pill-border: #927255;
  --skin-progress-track: #674b3c;
  --skin-panel: #fcf5eb;
  --skin-panel-ink: #644536;
  --art-night-sky: url("/art/gingerbread/night-sky.webp?v=2");
  --art-snowbank: url("/art/gingerbread/snowbank.webp?v=2");
  --art-christmas-tree-left: url("/art/gingerbread/christmas-tree-left.webp?v=2");
  --art-christmas-tree-right: url("/art/gingerbread/christmas-tree-right.webp?v=2");
  --art-distant-pines: url("/art/gingerbread/distant-pines.webp?v=2");
  --art-wreath: url("/art/gingerbread/wreath.webp?v=3");
  --art-roof: url("/art/gingerbread/roof.webp?v=2");
  --art-wall: url("/art/gingerbread/wall.webp?v=2");
  --art-eave-lights: url("/art/gingerbread/eave-lights.webp?v=2");
  --art-window-dark: url("/art/gingerbread/window-dark.webp?v=2");
  --art-window-lit: url("/art/gingerbread/window-lit.webp?v=2");
  --art-window-opened: url("/art/gingerbread/window-opened.webp?v=2");
  --art-pine-sprig: url("/art/gingerbread/pine-sprig.webp?v=2");
}

body[data-theme="blush"] {
  --skin-sky-top: #301a30;
  --skin-sky-bottom: #502942;
  --skin-wall: #c28ba1;
  --skin-on-sky-muted: #f5e0ea;
  --skin-ink: #432539;
  --skin-card: #fff7f4;
  --skin-line: #ebd5dd;
  --skin-accent: #883d5d;
  --skin-snow-floor: #e3b5c7;
  --skin-pill: #4e2b40;
  --skin-pill-border: #a77a92;
  --skin-progress-track: #71475c;
  --skin-panel: #fcf6f6;
  --skin-panel-ink: #694357;
  --art-night-sky: url("/art/blush/night-sky.webp?v=2");
  --art-snowbank: url("/art/blush/snowbank.webp?v=2");
  --art-christmas-tree-left: url("/art/blush/christmas-tree-left.webp?v=2");
  --art-christmas-tree-right: url("/art/blush/christmas-tree-right.webp?v=2");
  --art-distant-pines: url("/art/blush/distant-pines.webp?v=2");
  --art-wreath: url("/art/blush/wreath.webp?v=3");
  --art-roof: url("/art/blush/roof.webp?v=2");
  --art-wall: url("/art/blush/wall.webp?v=2");
  --art-eave-lights: url("/art/blush/eave-lights.webp?v=2");
  --art-window-dark: url("/art/blush/window-dark.webp?v=2");
  --art-window-lit: url("/art/blush/window-lit.webp?v=2");
  --art-window-opened: url("/art/blush/window-opened.webp?v=2");
  --art-pine-sprig: url("/art/blush/pine-sprig.webp?v=2");
}
body[data-theme="midnight"],
body[data-theme="gingerbread"],
body[data-theme="blush"] {
  --sky-top: var(--skin-sky-top);
  --sky-bottom: var(--skin-sky-bottom);
  --wall: var(--skin-wall);
  --on-sky: #fff4e2;
  --on-sky-muted: var(--skin-on-sky-muted);
  --glow: #ffc875;
  --ink: var(--skin-ink);
  --muted: var(--skin-panel-ink);
  --card: var(--skin-card);
  --line: var(--skin-line);
  --accent: var(--skin-accent);
  --snow-floor: var(--skin-snow-floor);
}

/* The two depths use the same painted crystals at different scales and speeds. */
body[data-theme] .sky {
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  /* clip, not hidden: a hidden box can be scrolled by scrollIntoView, which left a blank band under the house. */
  overflow: clip;
}

body[data-theme] .sky > .wrap {
  position: relative;
}

body[data-theme] .sky > .snow {
  inset: 0;
  width: auto;
  height: auto;
  overflow: hidden;
  border-radius: 0;
  background: none;
  box-shadow: none;
  animation: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000b 17%, #0003 37% 65%, #000b 84%, #000 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000b 17%, #0003 37% 65%, #000b 84%, #000 100%);
}

body[data-theme] .snow::before,
body[data-theme] .snow::after {
  content: "";
  --snow-step: 688px;
  position: absolute;
  inset: calc(0px - var(--snow-step)) -20px 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: url("/art/winter/snowfall.webp") 6px 0 / auto var(--snow-step) repeat;
  box-shadow: none;
  opacity: .84;
  animation: painted-snowfall 30s linear -9s infinite;
}

body[data-theme] .snow::after {
  --snow-step: 401px;
  background-position: 89px 47px;
  opacity: .38;
  animation-duration: 46s;
  animation-delay: -24s;
}

@keyframes painted-snowfall {
  0% { transform: translate(0, 0); }
  36% { transform: translate(9px, calc(var(--snow-step) * .36)); }
  72% { transform: translate(-5px, calc(var(--snow-step) * .72)); }
  100% { transform: translate(0, var(--snow-step)); }
}

body[data-theme="midnight"] .cal .sky:has(.roof),
body[data-theme="gingerbread"] .cal .sky:has(.roof),
body[data-theme="blush"] .cal .sky:has(.roof) {
  background:
    var(--art-night-sky) center top / 620px auto,
    linear-gradient(var(--sky-top), var(--sky-bottom));
}

body[data-theme="midnight"] .cal .sky,
body[data-theme="gingerbread"] .cal .sky,
body[data-theme="blush"] .cal .sky {
  padding-bottom: 7px;
}

body[data-theme="midnight"] .cal .sky > .wrap,
body[data-theme="gingerbread"] .cal .sky > .wrap,
body[data-theme="blush"] .cal .sky > .wrap {
  position: relative;
  isolation: isolate;
}

body[data-theme="midnight"] .cal .sky > .wrap:has(.roof)::before,
body[data-theme="gingerbread"] .cal .sky > .wrap:has(.roof)::before,
body[data-theme="blush"] .cal .sky > .wrap:has(.roof)::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  width: var(--scene-width);
  transform: translateX(-50%);
  pointer-events: none;
  --scene-width: 100vw;
  --snow-depth: 102px;
  top: calc(100% - 54px);
  height: max(65vh, var(--snow-depth));
  background:
    var(--art-snowbank) center top / 100% var(--snow-depth) no-repeat,
    linear-gradient(transparent calc(var(--snow-depth) - 2px), var(--snow-floor) 0);
}

body[data-theme="midnight"] .cal .house,
body[data-theme="gingerbread"] .cal .house,
body[data-theme="blush"] .cal .house {
  --tree-left-width: 65px;
  --tree-right-width: 59px;
  --tree-overlap: 9px;
  isolation: isolate;
}

body[data-theme="midnight"] .cal .house:has(> .roof)::before,
body[data-theme="gingerbread"] .cal .house:has(> .roof)::before,
body[data-theme="blush"] .cal .house:has(> .roof)::before,
body[data-theme="midnight"] .cal .house:has(> .roof)::after,
body[data-theme="gingerbread"] .cal .house:has(> .roof)::after,
body[data-theme="blush"] .cal .house:has(> .roof)::after {
  content: "";
  position: absolute;
  z-index: -1;
  bottom: -24px;
  width: 82px;
  height: 152px;
  pointer-events: none;
}

body[data-theme="midnight"] .cal .house:has(> .roof)::before,
body[data-theme="gingerbread"] .cal .house:has(> .roof)::before,
body[data-theme="blush"] .cal .house:has(> .roof)::before {
  left: -20px;
  background: var(--art-distant-pines) right 9px top 12px / var(--pine-width, 40px) auto no-repeat;
}

body[data-theme="midnight"] .cal .house:has(> .roof)::after,
body[data-theme="gingerbread"] .cal .house:has(> .roof)::after,
body[data-theme="blush"] .cal .house:has(> .roof)::after {
  right: -19px;
  background: var(--art-distant-pines) left 8px top 22px / var(--pine-width, 38px) auto no-repeat;
}

/* The wall positions these foreground trees. Its outer margin leaves the windows clear. */
body[data-theme] .cal .wall > .grid::before,
body[data-theme] .cal .wall > .grid::after {
  content: "";
  position: absolute;
  z-index: 0;
  bottom: -22px;
  width: min(var(--tree-width), calc((100vw - 100%) / 2 + var(--tree-overlap) - 2px));
  background: var(--tree-art) center bottom / contain no-repeat;
  pointer-events: none;
}

body[data-theme] .cal .wall > .grid::before {
  --tree-width: var(--tree-left-width);
  --tree-art: var(--art-christmas-tree-left);
  right: calc(100% - var(--tree-overlap));
  aspect-ratio: 221 / 404;
}

body[data-theme] .cal .wall > .grid::after {
  --tree-width: var(--tree-right-width);
  --tree-art: var(--art-christmas-tree-right);
  left: calc(100% - var(--tree-overlap));
  aspect-ratio: 218 / 394;
}

body[data-theme="midnight"] .cal .hill,
body[data-theme="gingerbread"] .cal .hill,
body[data-theme="blush"] .cal .hill {
  display: none;
}

body[data-theme="midnight"] .cal .top,
body[data-theme="gingerbread"] .cal .top,
body[data-theme="blush"] .cal .top {
  padding: 9px 0 3px;
}

body[data-theme="midnight"] .cal .top .pill,
body[data-theme="gingerbread"] .cal .top .pill,
body[data-theme="blush"] .cal .top .pill {
  padding: 4px 11px;
  background: var(--skin-pill);
  border-color: var(--skin-pill-border);
}

body[data-theme="midnight"] .cal .calhead,
body[data-theme="gingerbread"] .cal .calhead,
body[data-theme="blush"] .cal .calhead {
  padding: 6px 0 13px;
}

body[data-theme="midnight"] .cal .calhead h1,
body[data-theme="gingerbread"] .cal .calhead h1,
body[data-theme="blush"] .cal .calhead h1 {
  margin: 3px 0 5px;
  font-size: clamp(22px, 6.7vw, 27px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

body[data-theme="midnight"] .cal .calhead p,
body[data-theme="gingerbread"] .cal .calhead p,
body[data-theme="blush"] .cal .calhead p {
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

body[data-theme="midnight"] .cal .progress,
body[data-theme="gingerbread"] .cal .progress,
body[data-theme="blush"] .cal .progress {
  max-width: 182px;
  height: 5px;
  margin-top: 10px;
  background: var(--skin-progress-track);
}

body[data-theme="midnight"] .house > .roof,
body[data-theme="gingerbread"] .house > .roof,
body[data-theme="blush"] .house > .roof {
  position: relative;
  z-index: 1;
  aspect-ratio: 1120 / 336;
  overflow: visible;
  margin-bottom: -6px;
  background:
    var(--art-wreath) center 92% / 11.4% auto no-repeat,
    var(--art-roof) center / 100% 100% no-repeat;
  pointer-events: none;
}

body[data-theme="midnight"] .house > .roof > *,
body[data-theme="gingerbread"] .house > .roof > *,
body[data-theme="blush"] .house > .roof > * {
  display: none;
}

/* The tail stays over the flue while the loose end moves with the breeze. */
body[data-theme] .house > .roof > .chimney-plume {
  display: block;
  x: var(--plume-left, 277px);
  opacity: .55;
  transform-box: fill-box;
  transform-origin: 20% 100%;
  pointer-events: none;
  animation: chimney-breeze 8.6s ease-in-out -2.7s infinite alternate;
}

body[data-theme="gingerbread"] { --plume-left: 270px; }
body[data-theme="blush"] { --plume-left: 281px; }

/* Keep the wisp clear of the adjacent code button in the wide home header. */
@media (min-width: 900px) {
  body[data-theme] .home .chimney-plume { y: -22px; width: 21px; height: 30px; }
}

@media (max-width: 600px) {
  body[data-theme] .chimney-plume { y: -21px; height: 29px; }
}

@keyframes chimney-breeze {
  0% { transform: skewX(-6deg) scaleY(.89); opacity: .38; }
  55% { transform: skewX(2deg) scaleY(1.03); opacity: .57; }
  100% { transform: skewX(9deg) scaleY(.97); opacity: .45; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-theme] .snow::before,
  body[data-theme] .snow::after,
  body[data-theme] .house > .roof > .chimney-plume {
    animation: none;
  }
}

body[data-theme="midnight"] .house .wall,
body[data-theme="gingerbread"] .house .wall,
body[data-theme="blush"] .house .wall {
  background: var(--wall) var(--art-wall) center / 100% 100%;
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 8px 9px -8px #1e365d;
  isolation: isolate;
}

/* Bank the painted snow against the siding, behind the trees and donor sign. */
body[data-theme] .cal .wall::after {
  --drift-rise: 15px;
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  inset: calc(100% - var(--drift-rise)) -7% auto;
  height: calc(var(--drift-rise) * 2);
  background: var(--art-snowbank) 62% top / 129% calc(var(--drift-rise) * 2.9) no-repeat;
  mask-image: linear-gradient(to bottom, #000 50%, transparent),
    linear-gradient(to right, transparent, #000 6.5% 93.5%, transparent);
  mask-composite: intersect;
}

body[data-theme="midnight"] .house .wall::before,
body[data-theme="gingerbread"] .house .wall::before,
body[data-theme="blush"] .house .wall::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 4px 2% auto;
  height: clamp(9px, 3vw, 17px);
  background: var(--art-eave-lights) center / 100% 100% no-repeat;
  pointer-events: none;
}

body[data-theme="midnight"] .cal .wall,
body[data-theme="gingerbread"] .cal .wall,
body[data-theme="blush"] .cal .wall {
  padding: 18px 13px 16px;
}

body[data-theme="midnight"] .cal .grid,
body[data-theme="gingerbread"] .cal .grid,
body[data-theme="blush"] .cal .grid {
  gap: 8px 5px;
}

body[data-theme="midnight"] .house .win,
body[data-theme="gingerbread"] .house .win,
body[data-theme="blush"] .house .win {
  container-type: inline-size;
  border: 0;
  background: var(--art-window-dark) center / 100% 100% no-repeat;
  color: #fff1dc;
}

body[data-theme="midnight"] .house .win.lit,
body[data-theme="gingerbread"] .house .win.lit,
body[data-theme="blush"] .house .win.lit {
  background-image: var(--art-window-lit);
  color: #261507;
  box-shadow: none;
}

body[data-theme="midnight"] .house .win.opened,
body[data-theme="gingerbread"] .house .win.opened,
body[data-theme="blush"] .house .win.opened {
  background-image: var(--art-window-opened);
  color: #261507;
  box-shadow: none;
}

/* The window the owner can open today has to stand out from the other lit ones: it glows in and out and its sticker rocks. */
body[data-theme="midnight"] .house .win.ready,
body[data-theme="gingerbread"] .house .win.ready,
body[data-theme="blush"] .house .win.ready {
  animation: midnight-ready 1.7s ease-in-out infinite;
  filter: drop-shadow(0 0 6px #ffc56f) brightness(1.08);
  z-index: 1;
}

@keyframes midnight-ready {
  0%, 100% { filter: drop-shadow(0 0 3px #ffc56f) brightness(1); transform: scale(1); }
  50% { filter: drop-shadow(0 0 10px #ffe3a6) drop-shadow(0 0 4px #ffc56f) brightness(1.14); transform: scale(1.06); }
}

body[data-theme="midnight"] .house .win::before,
body[data-theme="gingerbread"] .house .win::before,
body[data-theme="blush"] .house .win::before,
body[data-theme="midnight"] .house .win::after,
body[data-theme="gingerbread"] .house .win::after,
body[data-theme="blush"] .house .win::after {
  content: none;
}

body[data-theme="midnight"] .cal .win:is(:nth-child(7n + 2), :nth-child(9n + 4))::after,
body[data-theme="gingerbread"] .cal .win:is(:nth-child(7n + 2), :nth-child(9n + 4))::after,
body[data-theme="blush"] .cal .win:is(:nth-child(7n + 2), :nth-child(9n + 4))::after {
  content: "";
  inset: auto 2% -2% auto;
  width: 67%;
  height: 20%;
  z-index: 2;
  background: var(--art-pine-sprig) right bottom / contain no-repeat;
  box-shadow: none;
  pointer-events: none;
}

body[data-theme="midnight"] .house .win .n,
body[data-theme="gingerbread"] .house .win .n,
body[data-theme="blush"] .house .win .n {
  top: 12.5%;
  left: 18%;
  right: 18%;
  color: inherit;
  text-shadow: none;
  line-height: 1;
}

body[data-theme="midnight"] .house .win .st,
body[data-theme="gingerbread"] .house .win .st,
body[data-theme="blush"] .house .win .st,
body[data-theme="midnight"] .house .win .plus,
body[data-theme="gingerbread"] .house .win .plus,
body[data-theme="blush"] .house .win .plus {
  position: absolute;
  inset: 49% 0 auto;
  margin: 0;
  transform: translateY(-50%);
  line-height: 1;
  text-align: center;
}

body[data-theme="midnight"] .house .win .plus,
body[data-theme="gingerbread"] .house .win .plus,
body[data-theme="blush"] .house .win .plus {
  opacity: .83;
}

/* Center the visitor's mark between the date and the sill. The whole window is the button. */
body[data-theme] .house .win.writable .plus {
  --plus-size: clamp(15px, 40cqw, 21px);
  --plus-stroke: 2px;
  inset: 63% auto auto 50%;
  transform: translate(-50%, -50%);
  width: var(--plus-size); height: var(--plus-size);
  border: 1px solid #f7deac66; border-radius: 50%;
  background: #261b2038; color: #ffe6bb;
  font-size: 0; opacity: 1; pointer-events: none;
}
/* Two rounded brush marks keep the small plus centered regardless of font metrics. */
body[data-theme] .house .win.writable .plus::before,
body[data-theme] .house .win.writable .plus::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: 56%; height: var(--plus-stroke); border-radius: 2px;
  background: currentColor; forced-color-adjust: none;
}
body[data-theme] .house .win.writable .plus::after { transform: rotate(90deg); }

body[data-theme] .house .win.write-start .plus {
  --plus-size: clamp(18px, 52cqw, 26px);
  --plus-stroke: 3px;
  /* Reserve a little space below the date even at the top of the nudge. */
  top: max(63%, calc(12.5% + 15px + var(--plus-size) / 2));
  color: #49301b; border-color: #ffe8ae;
  border-radius: 48% 52% 50% 49%;
  background: #f4c56a linear-gradient(145deg, #ffe7a6, #edb857);
  box-shadow: 0 0 0 1px #54331ee0, 0 1px 3px #27172973;
}
@media (prefers-reduced-motion: no-preference) {
  body[data-theme] .house .win.write-nudge .plus {
    animation: write-invitation 3.8s ease-in-out infinite;
  }
  @keyframes write-invitation {
    0%, 24%, 100% { transform: translate(-50%, -50%); }
    8% { transform: translate(calc(-50% - 1.5px), calc(-50% - 0.5px)) rotate(-10deg) scale(1.06); }
    16% { transform: translate(calc(-50% + 1px), -50%) rotate(7deg) scale(1.03); }
  }
}

body[data-theme="midnight"] .cal .win .st,
body[data-theme="gingerbread"] .cal .win .st,
body[data-theme="blush"] .cal .win .st {
  /* Keep the artwork between the date and the two padded edges of the name label. */
  top: max(32%, calc(12.5% + 11px));
  bottom: max(32%, calc(10% + 12.5px));
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

body[data-theme] .sticker-art {
  width: 1.25em;
  height: 1.25em;
  object-fit: contain;
  vertical-align: -.25em;
}

body[data-theme] .house .st .sticker-art {
  height: 100%;
  width: auto;
}

body[data-theme] .stickers button {
  position: relative;
}

body[data-theme] .stickers .sticker-art {
  position: absolute;
  inset: 0;
  width: 76%;
  height: 76%;
  margin: auto;
}

body[data-theme] .letter .big .sticker-art {
  display: block;
  margin: 0 auto;
}

body[data-theme="midnight"] .house .win .who,
body[data-theme="gingerbread"] .house .win .who,
body[data-theme="blush"] .house .win .who {
  left: 50%;
  right: auto;
  bottom: 10%;
  width: max-content;
  min-width: 100%;
  max-width: calc(100% + var(--byline-extra, 3px));
  transform: translateX(-50%);
  padding: 1px 0;
  border-radius: 3px;
  background: #ffe4a9;
  color: #261507;
  font-size: clamp(9.5px, 24cqi, 12px);
  font-weight: 750;
  line-height: 1.1;
}

body[data-theme="midnight"] .cal button.win:focus-visible,
body[data-theme="gingerbread"] .cal button.win:focus-visible,
body[data-theme="blush"] .cal button.win:focus-visible {
  z-index: 3;
  outline: 2px solid #182e56;
  outline-offset: 1px;
  box-shadow: 0 0 0 4px #fff1d1;
}

body[data-theme="midnight"] .cal .panel,
body[data-theme="gingerbread"] .cal .panel,
body[data-theme="blush"] .cal .panel {
  background: var(--skin-panel);
}

body[data-theme="midnight"] .cal .panel p,
body[data-theme="gingerbread"] .cal .panel p,
body[data-theme="blush"] .cal .panel p {
  color: var(--skin-panel-ink);
}

body[data-theme="midnight"] main.cal + .dock,
body[data-theme="gingerbread"] main.cal + .dock,
body[data-theme="blush"] main.cal + .dock {
  background: var(--card);
}

@media (max-width: 430px) and (min-height: 620px) {
  body[data-theme="midnight"] .cal .sky > .wrap:has(.roof),
  body[data-theme="gingerbread"] .cal .sky > .wrap:has(.roof),
  body[data-theme="blush"] .cal .sky > .wrap:has(.roof) {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: min(calc(100svh - 67px), calc(563.5px + max(0px, (100vw - 375px) * .8)));
    container-type: inline-size;
  }

  body[data-theme="midnight"] .cal .sky > .wrap > :not(.house),
  body[data-theme="gingerbread"] .cal .sky > .wrap > :not(.house),
  body[data-theme="blush"] .cal .sky > .wrap > :not(.house) {
    flex-shrink: 0;
  }

  /* Each pixel of house width adds .30px of roof and .76px of window grid.
     With long names, this keeps the same proportions while giving the header room. */
  body[data-theme="midnight"] .cal .house,
  body[data-theme="gingerbread"] .cal .house,
  body[data-theme="blush"] .cal .house {
    --height-per-width: 1.05947;
    --vertical-padding: 8.48px;
    min-height: 0;
    flex: 0 1 calc(100cqw * var(--height-per-width) + var(--vertical-padding));
    container-type: size;
  }

  body[data-theme="midnight"] .cal .house > :is(.roof, .wall),
  body[data-theme="gingerbread"] .cal .house > :is(.roof, .wall),
  body[data-theme="blush"] .cal .house > :is(.roof, .wall) {
    --art-width: calc((100cqh - var(--vertical-padding)) / var(--height-per-width));
    margin-inline: auto;
  }

  body[data-theme="midnight"] .cal .house > .roof,
  body[data-theme="gingerbread"] .cal .house > .roof,
  body[data-theme="blush"] .cal .house > .roof {
    width: min(100%, var(--art-width));
  }

  body[data-theme="midnight"] .cal .house > .wall,
  body[data-theme="gingerbread"] .cal .house > .wall,
  body[data-theme="blush"] .cal .house > .wall {
    width: min(89%, var(--art-width) * .89);
  }

  body[data-theme="midnight"] .cal .panel,
  body[data-theme="gingerbread"] .cal .panel,
  body[data-theme="blush"] .cal .panel {
    padding-top: 10px;
  }

  body[data-theme="midnight"] .cal .panel .card,
  body[data-theme="gingerbread"] .cal .panel .card,
  body[data-theme="blush"] .cal .panel .card {
    padding: 12px 14px;
  }

  body[data-theme="midnight"] .cal .panel .card h2,
  body[data-theme="gingerbread"] .cal .panel .card h2,
  body[data-theme="blush"] .cal .panel .card h2 {
    line-height: 1.2;
  }
}

@media (min-width: 900px) {
  body[data-theme="midnight"] .cal .sky,
  body[data-theme="gingerbread"] .cal .sky,
  body[data-theme="blush"] .cal .sky {
    padding-bottom: 0;
  }

  body[data-theme="midnight"] .cal .sky > .wrap:has(.roof)::before,
  body[data-theme="gingerbread"] .cal .sky > .wrap:has(.roof)::before,
  body[data-theme="blush"] .cal .sky > .wrap:has(.roof)::before {
    --scene-width: 55vw;
    --snow-depth: var(--desktop-drift, 200px);
    top: calc(100% - var(--snow-overlap, 78px));
  }

  body[data-theme="midnight"] .cal .house:has(> .roof)::before,
  body[data-theme="gingerbread"] .cal .house:has(> .roof)::before,
  body[data-theme="blush"] .cal .house:has(> .roof)::before,
  body[data-theme="midnight"] .cal .house:has(> .roof)::after,
  body[data-theme="gingerbread"] .cal .house:has(> .roof)::after,
  body[data-theme="blush"] .cal .house:has(> .roof)::after {
    --pine-width: clamp(64px, 7.45vw, 110px);
    width: clamp(111px, 13vw, 177px);
    height: clamp(215px, 21vw, 313px);
    bottom: -28px;
  }

  body[data-theme="midnight"] .cal .house:has(> .roof)::before,
  body[data-theme="gingerbread"] .cal .house:has(> .roof)::before,
  body[data-theme="blush"] .cal .house:has(> .roof)::before {
    left: calc(22px - var(--tree-left-width));
  }

  body[data-theme="midnight"] .cal .house:has(> .roof)::after,
  body[data-theme="gingerbread"] .cal .house:has(> .roof)::after,
  body[data-theme="blush"] .cal .house:has(> .roof)::after {
    right: calc(22px - var(--tree-right-width));
    height: clamp(190px, 19.5vw, 286px);
    bottom: -24px;
  }

  body[data-theme="midnight"] .cal .calhead h1,
  body[data-theme="gingerbread"] .cal .calhead h1,
  body[data-theme="blush"] .cal .calhead h1 {
    font-size: 35px;
  }

  body[data-theme="midnight"] .cal .calhead p,
  body[data-theme="gingerbread"] .cal .calhead p,
  body[data-theme="blush"] .cal .calhead p {
    font-size: 15px;
  }

  body[data-theme="midnight"] .cal .progress,
  body[data-theme="gingerbread"] .cal .progress,
  body[data-theme="blush"] .cal .progress {
    max-width: 232px;
  }

  body[data-theme="midnight"] .cal .wall,
  body[data-theme="gingerbread"] .cal .wall,
  body[data-theme="blush"] .cal .wall {
    padding: 25px 16px 26px;
  }

  body[data-theme] .cal .wall::after { --drift-rise: 24px; }

  body[data-theme="midnight"] .cal .grid,
  body[data-theme="gingerbread"] .cal .grid,
  body[data-theme="blush"] .cal .grid {
    gap: 13px 9px;
    --byline-extra: 6px;
  }

  body[data-theme="midnight"] .cal .win .st,
  body[data-theme="gingerbread"] .cal .win .st,
  body[data-theme="blush"] .cal .win .st {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-theme="midnight"] .house .win,
  body[data-theme="gingerbread"] .house .win,
  body[data-theme="blush"] .house .win,
  body[data-theme="midnight"] .house .win.pop,
  body[data-theme="gingerbread"] .house .win.pop,
  body[data-theme="blush"] .house .win.pop,
  body[data-theme="midnight"] .house .win.ready,
  body[data-theme="gingerbread"] .house .win.ready,
  body[data-theme="blush"] .house .win.ready,
  body[data-theme="midnight"] .cal .progress i,
  body[data-theme="gingerbread"] .cal .progress i,
  body[data-theme="blush"] .cal .progress i,
  body[data-theme="midnight"] main.cal + .dock,
  body[data-theme="gingerbread"] main.cal + .dock,
  body[data-theme="blush"] main.cal + .dock {
    animation: none;
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* No pulsing, so the steady glow is stronger. */
  body[data-theme="midnight"] .house .win.ready,
  body[data-theme="gingerbread"] .house .win.ready,
  body[data-theme="blush"] .house .win.ready {
    filter: drop-shadow(0 0 9px #ffe3a6) drop-shadow(0 0 3px #ffc56f) brightness(1.12);
  }
}


body[data-theme="midnight"] .sheet .letter,
body[data-theme="gingerbread"] .sheet .letter,
body[data-theme="blush"] .sheet .letter {
  position: relative;
  isolation: isolate;
  padding: 29px 24px 23px;
  border: 1px solid #d6bd99;
  border-radius: 9px 12px 8px 11px;
  color: var(--skin-ink);
  background:
    radial-gradient(ellipse at 48% 25%, #fffdf4 10%, transparent 75%),
    repeating-linear-gradient(8deg, #e8d8b81a 0 1px, transparent 1px 4px),
    linear-gradient(130deg, #f9ecd5, #fff7e8 42%, #f1dfc3);
  box-shadow: inset 0 0 16px #d3b58938, 0 3px 0 -1px #f7ead4, 0 4px 0 -1px #cdb693, 0 9px 18px #432a1c20;
}

body[data-theme="midnight"] .sheet .letter::before,
body[data-theme="gingerbread"] .sheet .letter::before,
body[data-theme="blush"] .sheet .letter::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  border: 1px solid #c3a27970;
  border-radius: 5px 8px 5px 7px;
  pointer-events: none;
}

body[data-theme="midnight"] .sheet .letter::after,
body[data-theme="gingerbread"] .sheet .letter::after,
body[data-theme="blush"] .sheet .letter::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 12px;
  width: 49px;
  height: 16px;
  background: var(--art-pine-sprig) center / contain no-repeat;
  transform: rotate(12deg);
  pointer-events: none;
}

body[data-theme="midnight"] .sheet .letter .text,
body[data-theme="gingerbread"] .sheet .letter .text,
body[data-theme="blush"] .sheet .letter .text {
  margin: 11px 0 17px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

body[data-theme="midnight"] .sheet .letter .from,
body[data-theme="gingerbread"] .sheet .letter .from,
body[data-theme="blush"] .sheet .letter .from {
  color: var(--skin-panel-ink);
  overflow-wrap: anywhere;
}

.home .chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(5px, 1.4vw, 9px);
}

.home .chip {
  position: relative;
  min-width: 0;
  gap: 5px;
  padding: 3px 3px 6px;
  border: 1px solid #cfbfae;
  border-radius: 9px;
  background: #fffaf0;
  color: #382e29;
  font-size: clamp(11px, 3.4vw, 13px);
  line-height: 1.35;
}

.home .chip[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, #fffaf0);
  color: var(--ink);
}

.home .chip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

body[data-theme] .home .swatch {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2;
  border-radius: 5px 5px 0 0;
  background: var(--swatch-art) center / cover no-repeat;
  mask: radial-gradient(circle at 50% 100%, transparent 1.2px, #000 1.8px) 0 0 / 7px 100% repeat-x;
}

body[data-theme] .home .swatch::after { content: none; }
.home .swatch.midnight { --swatch-art: url("/art/midnight/swatch.webp?v=2"); }
.home .swatch.gingerbread { --swatch-art: url("/art/gingerbread/swatch.webp?v=2"); }
.home .swatch.blush { --swatch-art: url("/art/blush/swatch.webp?v=2"); }

/* The badge and tick share one square. The tick is centered in its own 20 × 20 drawing. */
.home .chip[aria-pressed="true"]::before,
.home .chip[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 7px 7px auto auto;
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.home .chip[aria-pressed="true"]::before {
  border-radius: 50%;
  background: #fff9ed;
  box-shadow: 0 0 0 1px #362a2533;
}

.home .chip[aria-pressed="true"]::after {
  background: var(--ink);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.1l3.2 3.3L15 6.6' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

@media (forced-colors: active) {
  .home .chip[aria-pressed="true"] { border-color: Highlight; }
  .home .chip[aria-pressed="true"]::before { forced-color-adjust: none; background: ButtonFace; outline: 1px solid ButtonText; }
  .home .chip[aria-pressed="true"]::after { forced-color-adjust: none; background: ButtonText; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-theme="midnight"] .shade:has(.letter),
  body[data-theme="midnight"] .sheet:has(.letter),
  body[data-theme="midnight"] .sheet .letter,
  body[data-theme="gingerbread"] .shade:has(.letter),
  body[data-theme="gingerbread"] .sheet:has(.letter),
  body[data-theme="gingerbread"] .sheet .letter,
  body[data-theme="blush"] .shade:has(.letter),
  body[data-theme="blush"] .sheet:has(.letter),
  body[data-theme="blush"] .sheet .letter {
    animation: none;
  }
}

/* Stack the date, full-size sticker and byline over the painted window. */
body[data-theme] .cal .win:is(.lit, .opened) {
  --date-size: clamp(11px, 24cqi, 14px);
  --sticker-top: calc(var(--date-size) + 2px);
  --sill-gap: 1px;
  --sticker-height: calc(84% - 13px);
}

body[data-theme] .cal .win:is(.lit, .opened) .n {
  top: 1px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  padding: 0 3px;
  border-radius: 999px;
  background: #ffe6b4;
  color: #2e1b0c;
  font-family: var(--font-display);
  font-size: var(--date-size);
  font-variant-numeric: lining-nums;
  line-height: 1;
  pointer-events: none;
}

body[data-theme] .cal .win:is(.lit, .opened) .st {
  top: var(--sticker-top);
  bottom: auto;
  height: var(--sticker-height);
}

body[data-theme] .cal .win:is(.lit, .opened) .who {
  top: calc(var(--sticker-top) + var(--sticker-height) + var(--sill-gap));
  bottom: auto;
  padding-block: 0 1px;
  z-index: 3; /* Above the sprigs painted on some sills. */
}

/* A gentle rock stays between the date and the name, including at its extremes. */
@media (prefers-reduced-motion: no-preference) {
  body[data-theme] .cal .win.ready {
    --sticker-top: calc(var(--date-size) + 3px);
    --sill-gap: 2px;
  }
  body[data-theme] .cal .win.ready .st { animation-name: window-sticker-rock; }
  @keyframes window-sticker-rock {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
  }
}

@media (min-width: 900px) {
  body[data-theme] .cal .win:is(.lit, .opened) { --sticker-height: calc(84% - 16px); }
}

/* Six stickers are painted almost edge to edge (star, cookie, envelope, bow, gift, snowflake).
   At full height they spill over the window frame, so they are drawn a little smaller than the tall, narrow ones. */
body[data-theme] .house .win .st .sticker-art[src$="/02.webp"],
body[data-theme] .house .win .st .sticker-art[src$="/06.webp"],
body[data-theme] .house .win .st .sticker-art[src$="/11.webp"],
body[data-theme] .house .win .st .sticker-art[src$="/12.webp"] { height: 84%; }
body[data-theme] .house .win .st .sticker-art[src$="/03.webp"],
body[data-theme] .house .win .st .sticker-art[src$="/04.webp"] { height: 90%; }

/* The envelope is the brand; show it larger without making the top row taller. */
body[data-theme] .brand img {
  width: 36px;
  height: 36px;
  margin: -5px 0;
}

@media (min-width: 900px) {
  body[data-theme] .brand { font-size: 23px; gap: 10px; }
  body[data-theme] .brand img { width: 46px; height: 46px; margin: -8px 0; }
}

/* ---------- wide screens: a larger house ----------
   The painted house is what sets the site apart, so on a computer it gets three fifths of the width.
   On the home page the brand row no longer pushes the house down: it sits in the empty sky beside the roof. */
@media (min-width: 900px) {
  body[data-theme] main.cal { grid-template-columns: minmax(0, 1.2fr) minmax(400px, .8fr); }
  body[data-theme] main.cal .sky > .wrap { max-width: none; padding: 0 32px; }
  body[data-theme] main.cal:not(.home) .sky {
    --snow-overlap: 78px;
    --desktop-drift: 200px;
    padding-top: clamp(10px, 1.3vw, 20px);
  }
  /* Continue the snow below the artwork if the controls make the grid row taller. */
  body[data-theme] main.cal:not(.home) .sky:has(.roof)::after {
    content: ""; flex: 1 0 0;
    background: linear-gradient(transparent calc(var(--desktop-drift) - var(--snow-overlap)), var(--snow-floor) 0);
  }
  /* Reserve space on both sides of the facade for the painted trees. */
  body[data-theme] main.cal .house {
    --tree-left-width: clamp(72px, 9.45vw, 143px);
    --tree-right-width: clamp(66px, 8.65vw, 132px);
    max-width: min(
      clamp(300px, calc((100vh - var(--above-house, 215px)) / 1.1), 680px),
      calc(100% - 2 * var(--tree-left-width) + 92px)
    );
  }

  /* Home: the brand row is pinned to the top corners of the sky and the house stands on the snow at the bottom,
     so the row no longer pushes the house down and extra height becomes sky. */
  body[data-theme] main.cal.home { --above-house: 105px; }
  /* The scene is exactly one screen tall even when the form beside it is taller, so the house is never cut off. */
  body[data-theme] main.cal.home .sky { justify-content: flex-start; }
  body[data-theme] main.cal.home .sky > .wrap { flex: none; box-sizing: border-box; height: 100vh; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 8px; }
  body[data-theme] main.cal.home .top { position: absolute; top: 14px; left: 32px; right: 32px; z-index: 2; padding: 0; }

  /* Calendar page: breathing room between the brand row and the calendar's name.
     The house allowance grows by the same 16px so the house still ends on the first screen. */
  body[data-theme] main.cal:not(.home) { --above-house: 231px; }
  body[data-theme] main.cal:not(.home) .calhead { padding-top: 22px; }

  body[data-theme="midnight"] .cal .sky > .wrap:has(.roof)::before,
  body[data-theme="gingerbread"] .cal .sky > .wrap:has(.roof)::before,
  body[data-theme="blush"] .cal .sky > .wrap:has(.roof)::before {
    --scene-width: 60vw;
  }
}

/* Calendar page: when the controls beside the house are taller than the screen, the scene stays in view
   while they scroll, so a flat stretch of snow never appears under the house.
   Only on screens tall enough to show the whole house; shorter ones keep the plain fill. */
@media (min-width: 900px) and (min-height: 560px) {
  body[data-theme] main.cal:not(.home) .sky { position: sticky; top: 0; align-self: start; min-height: 100vh; }
}

/* Allow the roof to rise beside a lone code link. A returning owner's longer
   navigation shares the width above the chimney and needs the full header space. */
@media (min-width: 1100px) {
  body[data-theme] main.cal.home:has(#home-return[hidden]) { --above-house: 66px; }
}

/* Home: the sample house can be tapped. A lit window opens its sample note. */
body[data-theme] .home .house .win { pointer-events: auto; cursor: pointer; }
body[data-theme] .sheet .pair { display: flex; gap: 8px; margin-top: 8px; }
body[data-theme] .sheet .pair .btn { flex: 1; }

/* The opened note is the picture people screenshot: show the sticker at a size where the painting reads. */
body[data-theme] .sheet .letter .big .sticker-art { width: 84px; height: 84px; }

/* Home navigation: the code link is secondary to the owner's way back. */
.home .top { gap: 12px; }
.home .top .brand { flex: none; }
.home-links {
  display: flex; align-items: center; justify-content: flex-end;
  gap: clamp(12px, 1.4vw, 22px); min-width: 0;
  font: 600 14px/1.25 var(--font-display);
}
.home-links a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; text-align: center;
}
.home-links #codelink {
  flex: none; padding-inline: 4px; color: var(--on-sky-muted);
  text-decoration: underline; text-decoration-thickness: 1px;
  text-decoration-color: var(--skin-pill-border); text-underline-offset: .27em;
}
.home-links #home-return {
  padding: 7px 14px; color: var(--skin-ink);
  background: color-mix(in srgb, var(--skin-card) 89%, var(--skin-accent));
  border: 1px solid var(--skin-pill-border); border-radius: 7px 10px 8px 9px;
  text-decoration: none; overflow-wrap: anywhere;
}
.home-links #codelink:hover { color: var(--on-sky); text-decoration-color: currentColor; }
.home-links #home-return:hover { background: var(--skin-card); }
.home-links a:focus-visible { outline: 2px solid var(--on-sky); outline-offset: 3px; }
#dock-return, .home #form-return { overflow-wrap: anywhere; }
@media (max-width: 899px) {
  .home-links #home-return { display: none; }
  .home #form-return { margin-bottom: 12px; }
}
@media (min-width: 900px) {
  .home #form-return { display: none; }
  body[data-theme] main.cal.home:has(#home-return:not([hidden])) { --above-house: 132px; }
  /* Let long owner names use a second line without painting over the chimney. */
  body[data-theme] main.cal.home .sky > .wrap:has(#home-return:not([hidden])) {
    height: auto; min-height: 100vh; padding-top: 14px;
  }
  body[data-theme] main.cal.home .top:has(#home-return:not([hidden])) {
    position: relative; inset: auto; flex-wrap: wrap; row-gap: 4px;
    margin-bottom: auto; padding-bottom: clamp(26px, 3vw, 44px);
  }
  .home-links { max-width: 100%; margin-inline-start: auto; }
}

/* ---------- paid gifts ----------
   Two looks each: lights (starfall, market) and keepsake letters (seal, aurora).
   The painted layers live in /art/paid/<gift>/<look>/<theme>/ and cal.js picks the folder. */
body[data-theme] .house .win.gift-delivered { outline: 3px solid #fff1cb; outline-offset: 2px; box-shadow: 0 0 0 7px #975d22; }
body[data-theme] .story-code { width: 100%; margin: 12px 0 0; text-align: left; }
body[data-theme] .story-picture {
  display: block; width: auto; max-width: 100%; max-height: min(62vh, 620px); max-height: min(62dvh, 620px);
  -webkit-touch-callout: default;
  margin: 0 auto 12px; border-radius: 8px;
}

/* Lights: a resting layer on the roof plus two glow layers that take turns. */
body[data-theme] .house > .roof > .gl { display: block; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  #layer .shade, #layer .sheet { animation: none; }
}

/* The roof's own outline filled with one warm tone and multiplied in: white snow turns to candlelight, colours underneath keep their hue. */
body[data-theme] .house > .roof > .wash { mix-blend-mode: multiply; filter: brightness(0) invert(1) sepia(1) saturate(4.2) hue-rotate(-14deg); opacity: .85; }
body[data-theme] .house > .roof > .roof-lights { filter: brightness(1.05); }
body[data-theme] .house > .roof > :is(.glow-a, .glow-b) { filter: drop-shadow(0 0 6px rgba(255, 226, 150, 1)) brightness(1.35); }
body[data-theme] .house.lights > .roof { filter: drop-shadow(0 -3px 16px rgba(255, 214, 140, .55)); }
body[data-theme] .house.lights .wall::before { filter: drop-shadow(0 0 4px rgba(255, 214, 130, 1)) brightness(1.15); }
body[data-theme] .house.lights .win:is(.lit, .opened) { filter: drop-shadow(0 0 2px #fff2c4) drop-shadow(0 0 7px rgba(255, 205, 112, .85)); }

/* The sky behind the house glows, and a few sparkles hang in it. */
/* Transparent edges and snow reflection extend beyond the wall. Keep window labels and hit targets on top. */
body[data-theme] .house .facade-lights {
  position: absolute; z-index: 0; pointer-events: none; max-width: none;
  left: -10.9375%; top: -4%; width: 121.875%; height: 119%;
}
body[data-theme] .house.lights .win { z-index: 1; }
body[data-theme] .house .halo {
  position: absolute; z-index: -1; left: -18%; right: -18%; top: -16%; height: 66%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 246, 220, .62), rgba(255, 220, 150, .3) 46%, rgba(255, 196, 104, 0) 76%);
  animation: paid-halo 5.4s ease-in-out infinite alternate;
}
@keyframes paid-halo { from { opacity: .7; transform: scale(.97); } to { opacity: 1; transform: scale(1.04); } }
body[data-theme] .house .halo i {
  position: absolute; width: 11px; height: 11px; background: #fff6d8;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  filter: drop-shadow(0 0 3px #ffe7a6);
  animation: paid-spark 3.2s ease-in-out infinite;
}
body[data-theme] .house .halo i:nth-child(1) { left: 16%; top: 30%; }
body[data-theme] .house .halo i:nth-child(2) { left: 30%; top: 12%; width: 8px; height: 8px; animation-delay: -1.1s; }
body[data-theme] .house .halo i:nth-child(3) { left: 47%; top: 3%; width: 14px; height: 14px; animation-delay: -2.2s; }
body[data-theme] .house .halo i:nth-child(4) { left: 62%; top: 13%; animation-delay: -.6s; }
body[data-theme] .house .halo i:nth-child(5) { left: 84%; top: 27%; width: 9px; height: 9px; animation-delay: -1.7s; }
body[data-theme] .house .halo i:nth-child(6) { left: 9%; top: 58%; width: 8px; height: 8px; animation-delay: -2.7s; }
body[data-theme] .house .halo i:nth-child(7) { left: 90%; top: 60%; animation-delay: -.9s; }
@keyframes paid-spark { 0%, 100% { opacity: .15; transform: scale(.6) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(20deg); } }
body[data-theme] .house > .roof > .glow-a { animation: paid-twinkle 2.8s ease-in-out infinite; }
body[data-theme] .house > .roof > .glow-b { animation: paid-twinkle 2.8s ease-in-out -1.4s infinite; }
@keyframes paid-twinkle { 0%, 100% { opacity: .12; } 50% { opacity: 1; } }

body[data-theme] .house .lantern {
  position: absolute; z-index: 3; width: 13%; height: auto; pointer-events: none;
  transform-origin: 50% 4%;
  filter: drop-shadow(0 0 7px rgba(255, 214, 130, 1)) drop-shadow(0 0 18px rgba(255, 190, 90, .6));
  animation: paid-lantern 3.6s ease-in-out infinite alternate;
}
body[data-theme] .house .lantern.l { left: -9%; top: 15%; }
body[data-theme] .house .lantern.r { right: -9%; top: 41%; animation-delay: -1.8s; }
@keyframes paid-lantern {
  from { transform: rotate(-3deg); filter: drop-shadow(0 0 5px rgba(255, 214, 130, .8)) drop-shadow(0 0 12px rgba(255, 190, 90, .4)); }
  to { transform: rotate(3deg); filter: drop-shadow(0 0 9px rgba(255, 226, 150, 1)) drop-shadow(0 0 24px rgba(255, 196, 100, .7)); }
}

body[data-theme] .house .plaque {
  position: absolute; z-index: 3; right: 1.5%; bottom: -15px; width: 41%; aspect-ratio: 800 / 192;
  background: var(--plaque) center / 100% 100% no-repeat; container-type: inline-size; pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)) drop-shadow(0 0 7px rgba(255, 220, 140, .85));
  animation: paid-plaque 3.8s ease-in-out infinite alternate;
}
@keyframes paid-plaque {
  from { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)) drop-shadow(0 0 4px rgba(255, 214, 130, .55)); }
  to { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)) drop-shadow(0 0 12px rgba(255, 228, 160, 1)); }
}
/* A highlight sweeps across the sign now and then, clipped to its painted shape. */
body[data-theme] .house .plaque::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 250, 225, 0) 40%, rgba(255, 250, 225, .8) 50%, rgba(255, 250, 225, 0) 60%) 120% 0 / 300% 100% no-repeat;
  -webkit-mask: var(--plaque) center / 100% 100% no-repeat; mask: var(--plaque) center / 100% 100% no-repeat;
  animation: paid-shine 5s ease-in-out infinite;
}
@keyframes paid-shine { 0%, 55% { background-position: 120% 0; } 100% { background-position: -20% 0; } }
body[data-theme] .house .plaque > span {
  position: absolute; left: 21.5%; top: 38%; width: 71.2%; height: 34%;
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center;
  font-size: 7.6cqw; line-height: 8.2cqw; font-weight: 800; color: #4a2a10; letter-spacing: .01em;
}
body[data-theme] .house.lights-market .plaque > span { left: 30%; top: 42.7%; width: 62.5%; }

/* Keepsake letters: the window keeps its shape and trades the frame. */
body[data-theme] .house .win.prem-seal { background-image: var(--paid-win-seal); }
body[data-theme] .house .win.prem-aurora { background-image: var(--paid-win-aurora); }

/* The offers under a freshly sealed note. */
body[data-theme] .delivery { text-align: center; }
body[data-theme] .delivery-window {
  display: inline-grid; place-items: center; width: 59px; height: 76px; margin-bottom: 4px;
  background: var(--art-window-lit) center / 100% 100% no-repeat;
}
body[data-theme] .delivery-window .sticker-art { width: 42px; height: 42px; }
body[data-theme] .sheet .gifts {
  margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
body[data-theme] .sheet .gifts .fine { grid-column: 1 / -1; margin: 0 0 3px; text-align: center; }
/* Each extra shows a small painting of what it buys, with the price on the picture's corner. */
body[data-theme] .sheet .gift {
  position: relative; display: grid; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; gap: 6px;
  padding: 8px 8px 10px; border-radius: 14px; border: 1px solid #d9bf8e; background: #fff9eb;
  color: #342637; text-align: left; font: inherit; cursor: pointer;
}
body[data-theme] .sheet .gift:only-of-type { grid-column: 1 / -1; }
body[data-theme] .sheet .gift img { width: 100%; height: auto; aspect-ratio: 5 / 4; object-fit: cover; object-position: center top; border-radius: 9px; }
body[data-theme] .sheet .gift[data-gift="letter"] img { object-position: center 38%; }
body[data-theme] .sheet .gift i {
  position: absolute; top: 13px; right: 13px; padding: 2px 8px; border-radius: 999px; background: #fff9eb;
  box-shadow: 0 1px 4px rgba(20, 12, 30, .35); font-size: 14px; font-style: normal; font-weight: 800; color: #64401e;
}
body[data-theme] .sheet .gift b { padding: 0 2px; font-size: 15px; line-height: 1.18; }
body[data-theme] .sheet .gift span { padding: 0 2px; font-size: 13px; line-height: 1.3; color: var(--muted); }

/* Look picker and shared bits of the two previews. */
body[data-theme] .styles { display: flex; gap: 8px; }
body[data-theme] .styles button {
  flex: 1; min-height: 38px; border-radius: 999px; border: 2px solid #dccdaa; background: #fff; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
body[data-theme] .styles button[aria-pressed="true"] { border-color: #b57b1f; background: #ffefc4; }
body[data-theme] :is(.below, .giftbar) .pair { display: flex; gap: 8px; }
body[data-theme] :is(.below, .giftbar) .pair .btn { flex: 1; }
body[data-theme] :is(.below, .giftbar) .pair .btn.ghost { flex: 0 0 auto; width: auto; padding-inline: 16px; }
body[data-theme] :is(.below, .giftbar) :is(.fine, .cap) { margin: 0; text-align: center; }

/* Lights preview: the real house wears the lights; this bar holds a close-up and the button. */
body[data-theme] .giftbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-width: 480px; margin: 0 auto;
  display: grid; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 26px rgba(8, 10, 34, .35);
  animation: rise .28s cubic-bezier(.2, .9, .3, 1);
}
body[data-theme] .giftbar .cap { font-size: 13.5px; font-weight: 700; color: var(--ink); }
/* On wide screens the house keeps the left column to itself and the bar sits over the right one. */
@media (min-width: 900px) {
  body[data-theme] .giftbar { left: 60vw; bottom: 24px; max-width: 428px; border-radius: 20px; padding-bottom: 12px; }
}
body[data-theme] .giftbar .compare-lights {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
body[data-theme] .giftbar .compare-lights .cap { margin: 0; text-align: left; }
body[data-theme] .giftbar [data-compare] {
  flex: none; min-height: 36px; padding: 4px 8px; color: var(--accent);
  font: 650 14px var(--font-ui); text-underline-offset: 3px;
}

/* A keepsake letter fills the screen. Sizes inside the paper follow its width. */
body[data-theme] .shade.paperview { align-items: center; overflow: auto; background: radial-gradient(120% 80% at 50% 40%, var(--sky-bottom), color-mix(in srgb, var(--sky-top) 76%, black) 75%); }
body[data-theme] .paperview .stage { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; }
body[data-theme] .paperview .paper {
  position: relative; flex: none; container-type: inline-size;
  width: min(100vw, calc((100vh - var(--below, 180px)) * .5622), 440px);
  width: min(100vw, calc((100dvh - var(--below, 180px)) * .5622), 440px);
  aspect-ratio: 750 / 1334; background: center / 100% 100% no-repeat;
  transition: opacity .45s ease, transform .55s cubic-bezier(.2, .9, .3, 1.1);
}
body[data-theme] .paperview .pin {
  --type: 5.6cqw;
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; justify-content: safe center;
  overflow: hidden; text-align: center;
}
body[data-theme] .paperview .paper-seal .pin { left: 20.8%; top: 15.6%; width: 64.3%; height: 60.9%; }
body[data-theme] .paperview .paper-aurora .pin { left: 12.4%; top: 33%; width: 75.2%; height: 52%; }
body[data-theme] .paperview .short-note .pin { --type: 7.8cqw; }
body[data-theme] .paperview .short-note .pin .big .sticker-art { width: 27cqw; height: 27cqw; }
body[data-theme] .paperview .pin .big { line-height: 0; flex: none; }
body[data-theme] .paperview .pin .big .sticker-art { width: 22.4cqw; height: 22.4cqw; }
body[data-theme] .paperview .pin .text {
  flex: none; max-width: 100%; margin: 3cqw 0 2.6cqw; font-family: var(--font-display); font-size: var(--type); line-height: 1.34;
  color: #3a2314; overflow-wrap: anywhere; white-space: pre-wrap;
}
body[data-theme] .paperview .pin .from { flex: none; font-size: max(12px, 3.5cqw); font-weight: 700; color: #7b5a3c; }
body[data-theme] .paperview .paper-aurora .pin .text { color: #213745; }
body[data-theme] .paperview .paper-aurora .pin .from { color: #475a60; }
body[data-theme] .paperview .below {
  width: min(100vw, 440px); display: grid; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  transition: opacity .45s ease;
}
body[data-theme] .paperview .below :is(.fine, .cap) { color: #e9dcc4; font-size: 13px; }
body[data-theme] .paperview .below .fine :is(a, .link) { color: #ffe2a3; }
body[data-theme] .paperview .below .reacts { margin: 0; }
body[data-theme] .paperview .below .btn.ghost { background: #fffaf0; }

/* Reader controls sit over the unused foot of the stationery. Buying has a separate layout. */
body[data-theme] .paperview.reader .stage { --overlap: min(9vh, 64px); }
body[data-theme] .paperview.reader .paper {
  width: min(100%, calc((100vh - var(--below, 90px) + var(--overlap)) * .5622), 480px);
  width: min(100%, calc((100dvh - var(--below, 90px) + var(--overlap)) * .5622), 480px);
}
body[data-theme] .paperview.reader .stage:has(.below[hidden]) { --overlap: 0px; }
body[data-theme] .paperview.reader .pin .from { font-size: max(12px, 3.7cqw); overflow-wrap: anywhere; }
body[data-theme] .paperview .paper-toggle { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; cursor: pointer; }
body[data-theme] .paperview .paper-toggle:focus-visible { outline: 3px solid #ffe2a3; outline-offset: -5px; }
body[data-theme] .paperview.reader .below {
  position: relative; margin-top: calc(0px - var(--overlap)); width: min(100%, 480px);
  gap: 3px; padding: 8px 8px calc(5px + env(safe-area-inset-bottom)); border-radius: 14px 14px 0 0;
  background: var(--sky-top);
}
body[data-theme] .paperview.reader .below[hidden] { display: none; }
body[data-theme] .paperview .reader-actions { display: flex; justify-content: center; align-items: center; gap: 8px; }
body[data-theme] .paperview .reader-actions .reacts { gap: clamp(2px, 1vw, 6px); }
body[data-theme] .paperview .reader-actions .reacts button { width: clamp(34px, 10.9vw, 44px); height: 44px; }
body[data-theme] .paperview .reader-actions .btn { width: auto; padding: 8px 12px; }

@media (prefers-reduced-motion: reduce) {
  body[data-theme] .shade.paperview, body[data-theme] .shade.mid:has(.delivery),
  body[data-theme] .shade.mid:has(.delivery) .sheet { animation: none; }
  body[data-theme] .paperview :is(.paper, .below) { transition: none; }
}

/* The wrapping opens in three pictures before the paper shows. */
body[data-theme] .paperview .stage.wrapped .paper { opacity: 0; transform: scale(.9); }
body[data-theme] .paperview.reader .stage.wrapped .below { opacity: 0; pointer-events: none; }
body[data-theme] .paperview:not(.reader) .unwrap { bottom: var(--below); }
body[data-theme] .paperview .unwrap {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; cursor: pointer; transition: opacity .4s ease;
}
body[data-theme] .paperview .unwrap img {
  grid-area: 1 / 1; width: min(84vw, 380px); height: auto; opacity: 0; transform: scale(.94);
  transition: opacity .35s ease, transform .6s cubic-bezier(.2, .9, .3, 1.15);
}
body[data-theme] .paperview .unwrap img.on { opacity: 1; transform: scale(1); }
body[data-theme] .paperview .unwrap.gone { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  body[data-theme] .house > .roof > :is(.glow-a, .glow-b) { animation: none; opacity: .6; }
  body[data-theme] .house .lantern, body[data-theme] .house .halo, body[data-theme] .house .halo i,
  body[data-theme] .house .plaque, body[data-theme] .house .plaque::after { animation: none; }
}

/* A friend can invite the owner back after sealing a note. */
.return-choice { display: flex; align-items: center; gap: 9px; margin: 6px 0 10px; min-height: 36px; font-size: 14px; line-height: 1.3; cursor: pointer; }
.return-choice input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--accent); }
.return-note { margin: 2px 0 10px; text-align: center; font-size: 14.5px; line-height: 1.4; color: var(--ink); }
.return-visit { display: grid; place-items: center; min-height: 42px; color: var(--accent); font-weight: 700; }

/* Keep the message and its delivery action together on a small phone. */
body[data-theme] .write-sheet { max-height: 95vh; max-height: 95dvh; }
.write-sheet h2 { padding-right: 38px; }
.write-sheet .sub { margin-bottom: 10px; }
.write-sheet .field { margin: 0; min-width: 0; }
body[data-theme] .write-sheet textarea.input { min-height: 76px; height: 76px; font-size: 16px; }
.note-ideas { display: flex; gap: 5px 10px; flex-wrap: wrap; margin: 2px 0 8px; }
.note-ideas button { padding: 3px 0; min-height: 30px; border: 0; background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.note-byline { display: grid; grid-template-columns: minmax(0, 1fr) 80px; gap: 10px; align-items: end; }
.note-byline input, .sticker-trigger { height: 44px; }
.sticker-trigger { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: white; }
/* The base sticker rule (1.25em) is more specific than a bare class pair, so name the theme here too. */
body[data-theme] .sticker-trigger .sticker-art { width: 34px; height: 34px; vertical-align: middle; }
.sticker-trigger span { margin: 0; }
.write-sheet .stickers { margin: 8px 0 0; }
.write-sheet .stickers[hidden] { display: none; }
.note-paper { min-width: 0; margin: 0 0 3px; padding: 0; border: 0; }
.paper-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 3px; font-size: 14px; }
.paper-peek { border: 0; padding: 5px 0 5px 9px; min-height: 30px; background: transparent; color: var(--accent); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.note-paper .paper-sample { display: block; grid-column: 1 / -1; height: clamp(55px, 10dvh, 84px); margin-bottom: 5px; border-radius: 5px; background-repeat: no-repeat; background-color: var(--card); }
.note-paper .sample-seal { background-size: 148% auto; background-position: left bottom; }
.note-paper .sample-aurora { background-size: 110% auto; background-position: center top; }
body[data-theme] .write-sheet .note-paper .paper-sample.letter { padding: 0; box-shadow: none; animation: none; }
body[data-theme] .write-sheet .note-paper .paper-sample.letter::after { width: 35px; right: 8px; }
.sheet > [data-back-to-note] { margin-top: 14px; }
.note-paper > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.note-paper label { position: relative; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; column-gap: 5px; padding: 6px 5px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.note-paper input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.note-paper label:has(:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.note-paper label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-paper span { color: var(--ink); font-size: 15px; line-height: 1.2; font-weight: 700; }
.note-paper small { grid-column: 2; color: var(--muted); font-size: 14px; line-height: 1.3; }
@media (max-height: 540px) {
  .write-sheet #f-go { position: sticky; bottom: 0; }
}
