:root {
  --page: #efe7da;
  --page-2: #f7f2ea;
  --card: #fffdf9;
  --ink: #2a211c;
  --ink-2: #6b5e53;
  --ink-3: #9a8c7e;
  --walnut: #4a2f22;
  --walnut-2: #6d4632;
  --line: #e3d8c8;
  --plum: #7b3f5e;
  --sage: #7f9a7d;
  --ghost: #6d62b5;
  --ghost-wash: #eeebfb;
  --danger: #a3332a;
  --display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --sans: 'Inter', system-ui, sans-serif;
  --hand: 'Caveat', 'Bradley Hand', cursive;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: 0 1px 0 rgba(74,47,34,.06), 0 10px 30px -12px rgba(74,47,34,.22);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 var(--sans); }
body {
  background:
    radial-gradient(1200px 600px at 30% -10%, #f8f2e8 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 20%, #ece4f4 0%, transparent 55%),
    var(--page);
  min-height: 100vh;
}
h1, h2 { font-family: var(--display); margin: 0; color: var(--ink); }
h1 { font-size: clamp(32px, 4.4vw, 54px); font-weight: 800; letter-spacing: -.035em; line-height: 1.02; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 10px; }
button { font: inherit; cursor: pointer; }
a { color: var(--ghost); }

/* ---------- buttons ---------- */
.pill { border: 0; border-radius: 999px; padding: 10px 18px; background: var(--walnut); color: #fbf4ea; font-weight: 600; font-size: 14px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); transition: transform .15s, background .15s; }
.pill:hover { background: var(--walnut-2); transform: translateY(-1px); }
.pill:active { transform: translateY(1px); }
.pill.small { padding: 6px 12px; font-size: 12.5px; }
.pill.light { background: #fbf4ea; color: var(--walnut); }
.pill.danger { background: var(--danger); }
.pill.danger:hover { background: #bd3d31; }
.pill:disabled { opacity: .5; cursor: default; transform: none; }

/* ---------- header ---------- */
.top { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand ghost" "stats ghost"; gap: 18px 24px; padding: 30px 36px 6px; max-width: 1480px; margin: 0 auto; }
.brand { grid-area: brand; }
.kicker { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; font: 600 12.5px/1 var(--sans); color: var(--walnut); background: #fffaf2; border: 1px solid var(--line); padding: 7px 12px; border-radius: 999px; }
.kicker .dot { width: 8px; height: 8px; border-radius: 50%; background: #3f9b62; box-shadow: 0 0 0 0 rgba(63,155,98,.5); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(63,155,98,0); } 100% { box-shadow: 0 0 0 0 rgba(63,155,98,0); } }
.lede { max-width: 640px; margin: 14px 0 0; color: var(--ink-2); font-size: 17px; line-height: 1.5; }
.hero-ghost { grid-area: ghost; align-self: end; width: 190px; position: relative; }
.hero-ghost img { width: 100%; display: block; filter: drop-shadow(0 18px 22px rgba(109,98,181,.28)); animation: bob 4.5s ease-in-out infinite; }
.stats { grid-area: stats; display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 16px; min-width: 150px; box-shadow: var(--shadow); }
.stat dt { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.stat dd { margin: 2px 0 0; font: 700 19px/1.2 var(--display); letter-spacing: -.01em; }
.stat.big { background: var(--walnut); border-color: var(--walnut); }
.stat.big dt { color: #d9c3b0; }
.stat.big dd { color: #fff6ea; font-size: 30px; font-variant-numeric: tabular-nums; }
.stat.bump dd { animation: bump .9s ease; }
@keyframes bump { 30% { transform: scale(1.25); color: #ffd9a8; } }

.pastbar { position: sticky; top: 0; z-index: 30; background: var(--walnut); color: #fbf4ea; padding: 12px 36px; display: flex; gap: 16px; align-items: center; justify-content: space-between; font-weight: 500; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; padding: 18px 36px 56px; max-width: 1480px; margin: 0 auto; align-items: start; }
@media (max-width: 1080px) { .layout { grid-template-columns: 1fr; } .top { grid-template-columns: 1fr; grid-template-areas: "brand" "stats"; } .hero-ghost { display: none; } }
@media (max-width: 640px) { .top, .layout { padding-left: 14px; padding-right: 14px; } .pastbar { padding: 10px 14px; } }

/* ---------- the dollhouse ---------- */
.house-wrap { position: relative; }
.house { position: relative; }
.attic { position: relative; width: 64%; margin: 0 auto -2px; aspect-ratio: 1100 / 671; z-index: 2; }
.attic-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; filter: drop-shadow(0 -2px 0 rgba(74,47,34,.15)); }
.attic-label { position: absolute; left: 50%; top: 58%; transform: translate(-50%, 0); text-align: center; color: #fff8ec; text-shadow: 0 1px 8px rgba(0,0,0,.6); font-size: 12px; line-height: 1.35; width: 60%; }
.attic-label b { display: block; font: 800 18px/1.1 var(--display); letter-spacing: -.01em; margin-bottom: 2px; }
.attic-floor { position: absolute; left: 14%; right: 40%; bottom: 6%; display: flex; justify-content: center; align-items: flex-end; gap: 4px; flex-wrap: wrap; min-height: 10%; }
.attic-floor img { height: clamp(26px, 4.2vw, 54px); filter: drop-shadow(0 4px 4px rgba(0,0,0,.35)); }
.attic-diary { position: absolute; right: 9%; bottom: 7%; z-index: 3; }

.storeys {
  position: relative;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--walnut);
  padding: 10px; gap: 10px;
  border-radius: 6px 6px 10px 10px;
  box-shadow: 0 30px 60px -30px rgba(74,47,34,.55), inset 0 0 0 2px rgba(255,255,255,.06);
}
.storey-label { grid-column: 1 / -1; color: #e6d3c0; font: 600 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; opacity: .75; padding: 4px 4px 0; }
.room {
  position: relative; container-type: inline-size; overflow: hidden;
  aspect-ratio: 1100 / 760; border-radius: 3px;
  background: #3a2a20 center / cover no-repeat;
  transition: box-shadow .4s, filter .6s;
}
.room.span2 { grid-column: span 2; }
.room.span3 { grid-column: span 3; }
.room.span6 { grid-column: span 6; aspect-ratio: 1100 / 400; }
.room.here { box-shadow: 0 0 0 3px #cfc6ff, 0 0 40px 4px rgba(207,198,255,.55); }
.room.here::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 60%, rgba(214,206,255,.28), transparent 70%); pointer-events: none; }
.room-tag { position: absolute; left: 4.5%; top: 6%; z-index: 2; display: inline-flex; flex-direction: column; background: rgba(255,250,242,.92); backdrop-filter: blur(4px); border-radius: 10px; padding: 4px 9px 5px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.room-tag b { font: 700 clamp(11px, 4.6cqw, 15px)/1.15 var(--display); text-transform: capitalize; }
.room-tag code { font: 400 clamp(8.5px, 3cqw, 11px)/1.2 var(--mono); color: var(--ink-3); }
.span6 .room-tag b { font-size: 15px; } .span6 .room-tag code { font-size: 11px; }

/* objects stand on the floor */
.floor { position: absolute; left: 5%; right: 5%; bottom: 4.5%; display: flex; flex-wrap: wrap-reverse; justify-content: center; align-items: flex-end; gap: 0 1.5%; z-index: 1; }
.span6 .floor { bottom: 6%; left: 18%; right: 8%; }
.obj { position: relative; border: 0; background: none; padding: 0; line-height: 0; transform-origin: 50% 100%; transition: transform .2s; }
.obj img { height: clamp(30px, 23cqw, 120px); max-width: 30cqw; object-fit: contain; filter: drop-shadow(0 6px 5px rgba(30,18,10,.38)); }
.span6 .obj img { height: clamp(30px, 9cqw, 110px); max-width: 14cqw; }
.obj.tall img { height: clamp(36px, 31cqw, 160px); }
.span6 .obj.tall img { height: clamp(36px, 12cqw, 140px); }
.obj.flat img { height: clamp(18px, 12cqw, 70px); }
.obj:hover { transform: translateY(-4px) scale(1.05); }
.obj .name { position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); white-space: nowrap; font: 500 11px/1 var(--sans); background: rgba(42,33,28,.86); color: #fff; padding: 4px 7px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.obj:hover .name, .obj:focus-visible .name { opacity: 1; }
.obj.chip { line-height: 1.2; background: #fffaf2; border-radius: 8px; padding: 4px 8px; font-size: 11px; box-shadow: 0 3px 6px rgba(0,0,0,.25); margin-bottom: 4px; }
.obj.fresh { animation: shiver .9s ease 2; }
@keyframes shiver { 15% { transform: rotate(-6deg) translateY(-3px); } 35% { transform: rotate(5deg); } 55% { transform: rotate(-3deg) translateY(-2px); } 75% { transform: rotate(2deg); } }

/* notes are pinned on the wallpaper */
.wall { position: absolute; left: 26%; right: 4%; top: 7%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; z-index: 2; max-height: 48%; overflow: hidden; }
.span6 .wall { left: 40%; }
.span2 .wall { left: 5%; right: 5%; top: 31%; justify-content: center; }
@media (max-width: 640px) { .span2 .wall { left: 26%; right: 4%; top: 7%; justify-content: flex-end; } .span2 .note { max-width: min(48cqw, 190px); } }
.span2 .note { max-width: 46%; font-size: clamp(11px, 5.4cqw, 15px); padding: 6px 7px 5px; }
.note { position: relative; border: 0; text-align: left; max-width: min(48cqw, 190px); padding: 9px 10px 7px; font: 600 clamp(12px, 5.2cqw, 17px)/1.05 var(--hand); color: #3b2c22; background: #fff9e8; box-shadow: 0 4px 10px rgba(0,0,0,.28); transform: rotate(-2deg); transition: transform .2s; }
.note:nth-child(2n) { transform: rotate(2.5deg); }
.note::before { content: ""; position: absolute; top: -4px; left: 50%; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #e98d7a, #9c3326); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.note.wren { background: #efeaff; color: #3d3470; }
.note.wren::before { background: radial-gradient(circle at 35% 35%, #b8acff, #5c50a8); }
.note .who { display: block; font: 500 9.5px/1.2 var(--sans); color: var(--ink-3); margin-top: 4px; }
.note:hover { transform: rotate(0) scale(1.04); z-index: 3; }
.note.fresh { animation: pinin .7s cubic-bezier(.2,1.6,.4,1); }
@keyframes pinin { from { transform: translateY(-14px) rotate(-12deg) scale(.7); opacity: 0; } }

/* ghost */
.ghost { position: absolute; left: 0; top: 0; width: 100px; pointer-events: none; z-index: 20; transition: left 1.4s cubic-bezier(.45,.05,.2,1), top 1.4s cubic-bezier(.45,.05,.2,1), width 1.4s ease, opacity .6s; }
.ghost img { width: 100%; display: block; filter: drop-shadow(0 14px 16px rgba(80,66,170,.35)); animation: bob 3.6s ease-in-out infinite; }
.ghost.pose-creak img { animation: bob 3.6s ease-in-out infinite, jitter .18s linear 8; }
.ghost.pose-rest img { animation: none; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes jitter { 25% { translate: -2px 0; } 75% { translate: 2px 0; } }
.bubble { position: absolute; bottom: calc(100% - 6px); left: 50%; transform: translateX(-84%); width: max-content; max-width: 230px; background: #fff; color: var(--ink); font: 600 17px/1.15 var(--hand); padding: 8px 12px; border-radius: 14px; box-shadow: 0 8px 20px rgba(42,33,28,.22); animation: pop .4s cubic-bezier(.2,1.6,.4,1); }
.bubble::after { content: ""; position: absolute; left: 80%; bottom: -7px; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
@keyframes pop { from { transform: translateX(-84%) scale(.6); opacity: 0; } }
body.past .ghost { opacity: .55; }
body.past .room { filter: sepia(.45) saturate(.8); }

.plan-foot { color: var(--ink-3); font-size: 13px; margin: 12px 4px 0; }

/* ---------- side ---------- */
.side { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px 18px 16px; box-shadow: var(--shadow); position: relative; }
.hint { color: var(--ink-2); font-size: 13px; margin: 8px 0 0; }
.hint.small { font-size: 12px; color: var(--ink-3); }

.feed-card { max-height: 470px; display: flex; flex-direction: column; }
.feed { list-style: none; margin: 0 -6px; padding: 0 6px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.feed li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 8px 6px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; }
.feed li:first-child { background: var(--ghost-wash); }
.feed .av { width: 34px; height: 34px; object-fit: contain; margin-top: 2px; }
.feed .when { font-size: 11.5px; color: var(--ink-3); }
.feed .thought { display: block; font: 600 17px/1.1 var(--hand); color: var(--ghost); margin: 2px 0 3px; }
.feed code.proof { display: block; margin-top: 5px; font: 11px/1.45 var(--mono); background: #f5efe6; color: #4d4036; border-radius: 6px; padding: 4px 7px; white-space: pre-wrap; word-break: break-all; }
.feed .k-refused, .feed .k-error { color: #7d4a2e; }
.feed .k-exorcism, .feed .k-return { background: #fbeee9; }

form label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
select, input, textarea { display: block; width: 100%; margin-top: 4px; font: 15px var(--sans); color: var(--ink); background: var(--page-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
select:focus, input:focus, textarea:focus { outline: 2px solid #cfc6ff; border-color: var(--ghost); }

.exorcise { background: linear-gradient(180deg, #fff6f1, var(--card)); overflow: hidden; }
.exorcise p { font-size: 14px; color: var(--ink-2); margin: 0 0 8px; max-width: 78%; }
.exorcise .hint { max-width: 100%; }
.exo-art { position: absolute; right: -14px; top: 10px; width: 96px; transform: rotate(8deg); opacity: .95; }
.exorcise .pill { margin-top: 6px; width: 100%; padding: 12px; font-size: 15px; }

.nights { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nights button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: var(--page-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; color: var(--ink); }
.nights button:hover { border-color: var(--walnut-2); }
.nights .id { font: 500 11.5px var(--mono); background: var(--walnut); color: #fbf4ea; border-radius: 6px; padding: 2px 6px; }

/* ---------- lights out ---------- */
.lights { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(60% 60% at 50% 45%, #1d1830, #07060b); color: #e9e4ff; text-align: center; animation: fade .5s; }
@keyframes fade { from { opacity: 0; } }
.lights-inner { max-width: 520px; padding: 24px; }
.lights-inner img { width: 170px; filter: drop-shadow(0 0 40px rgba(170,155,255,.45)); opacity: .9; }
.lights-big { font: 800 48px/1 var(--display); letter-spacing: -.03em; margin: 14px 0 10px; }
.lights-time { font: 500 16px var(--mono); opacity: .7; }
.lights.back .lights-inner img { animation: bob 3s ease-in-out infinite; opacity: 1; }

/* ---------- dialogs ---------- */
dialog.paper { border: 0; border-radius: 20px; padding: 24px; max-width: min(560px, 92vw); background: #fffaf1; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog.confirm { text-align: center; max-width: min(440px, 92vw); }
dialog.confirm img { width: 96px; height: auto; display: block; margin: -4px auto 6px; }
dialog.confirm h2 { margin: 0 0 8px; }
dialog.confirm p { margin: 0 0 18px; color: #5b4a40; line-height: 1.5; }
dialog.confirm .row { display: flex; gap: 10px; justify-content: center; }
dialog::backdrop { background: rgba(30,22,18,.45); backdrop-filter: blur(3px); }
#obj-img { display: block; height: 120px; margin: 0 auto 10px; filter: drop-shadow(0 8px 8px rgba(0,0,0,.25)); }
.obj-path { font: 12px var(--mono); color: var(--ink-3); margin: 0 0 8px; }
#obj-text { white-space: pre-wrap; font: 600 22px/1.2 var(--hand); color: var(--ink); margin: 0 0 16px; }
.diary { max-width: min(640px, 92vw); }
.diary-wren { float: right; width: 90px; margin: -6px -4px 0 8px; }
#diary-text { max-height: 50vh; overflow: auto; margin: 12px 0 16px; clear: both; }
#diary-text p { font: 600 19px/1.2 var(--hand); margin: 0 0 10px; color: #3d3470; }
#diary-text b { font: 500 11px var(--mono); color: var(--ink-3); display: block; }

/* ---------- phones: one room per row, a smaller attic ---------- */
@media (max-width: 640px) {
  .storeys { padding: 7px; gap: 7px; }
  .room.span2, .room.span3 { grid-column: span 6; }
  .attic { width: 92%; }
  .attic-label { top: 60%; width: 70%; }
  .attic-label span { display: none; }
  .attic-label b { font-size: 15px; }
  .attic-diary { right: 6%; bottom: 5%; font-size: 11px; padding: 5px 9px; }
  .attic-floor { left: 12%; right: 46%; }
  .bubble { max-width: 170px; font-size: 15px; }
  .lights-big { font-size: 36px; }
}
