:root {
  color-scheme: dark;
  --page: #101216;
  --surface: #181c22;
  --raised: #222831;
  --line: #30363f;
  --text: #f0f1f3;
  --muted: #a7afb9;
  --blue: #3378ff;
  --link: #a8c7ff;
  --ease: cubic-bezier(.22, 1, .36, 1);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page);
}

* { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
body { min-height: 100svh; }
button, input, textarea { font: inherit; }
button {
  color: inherit;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; }
header, main, footer { max-width: 1440px; margin: auto; padding-inline: 32px; }
header, .brand, .bar, .controls, .scene-foot, .tally { display: flex; align-items: center; }
header { gap: 16px; min-height: 72px; border-bottom: 1px solid var(--line); }
.brand { gap: 8px; font-size: 24px; font-weight: 600; }
.brand img { width: 32px; }
.rule { height: 24px; width: 1px; background: var(--line); }
.house, p, .tally span { color: var(--muted); }
.house { font-size: 14px; }
.archive, .share-trigger, .close, #cancel, .controls button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 400;
}
.archive:hover, .share-trigger:hover, .close:hover, #cancel:hover, .controls button:hover {
  background: var(--raised);
  border-color: #505b69;
}
header .archive { margin-left: auto; }
main { padding-block: 24px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: 24px; align-items: start; }
.card, .tree-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.bar, .scene-foot { justify-content: space-between; gap: 16px; padding: 16px 24px; }
.bar { flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.controls { gap: 8px; flex-wrap: wrap; }
#music[aria-pressed=true] { color: var(--link); background: var(--raised); }
h1 { font-size: clamp(24px, 2.5vw, 32px); font-weight: 500; line-height: 1.25; }
h2 { font-size: 20px; font-weight: 500; line-height: 1.4; }
.scene-foot { min-height: 56px; color: var(--muted); font-size: 13px; }
aside { display: grid; gap: 24px; }
.card { padding: 24px; }
.tray > p { margin: 8px 0 24px; font-size: 14px; }
.heart-button {
  display: grid;
  place-items: center;
  width: 100%;
  gap: 16px;
  padding: 24px 16px;
  background: var(--raised);
  border: 1px solid #465467;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  touch-action: none;
}
.heart-button:hover { background: #2b333e; border-color: var(--link); }
.heart-art, .modal-art, .wish-heart { display: block; flex-shrink: 0; }
.tally { gap: 8px; align-items: baseline; margin: 16px 0; font-variant-numeric: tabular-nums; }
.tally strong { font-size: 36px; line-height: 1; font-weight: 500; }
.tally span { font-size: 14px; }
progress { display: block; width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden; background: var(--raised); accent-color: var(--blue); }
progress::-webkit-progress-bar { background: var(--raised); }
progress::-webkit-progress-value { background: var(--blue); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 4px; }
#recent:not(:empty) { margin-top: 24px; }
.wishrow { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; background: transparent; border: 0; border-top: 1px solid var(--line); padding: 12px 4px; border-radius: 4px; }
.wishrow:hover { background: var(--raised); }
.wishrow span { min-width: 0; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wishrow small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.primary { background: var(--text); color: var(--page); border: 1px solid transparent; border-radius: 8px; font-weight: 500; padding: 12px 16px; }
.primary:hover { background: #d4dbe4; }
.full { width: 100%; margin-top: 24px; }

/* The winter room is the product scene; surrounding controls stay neutral. */
.room {height:clamp(220px,calc(100svh - 200px),680px);position:relative;isolation:isolate;overflow:hidden;background:radial-gradient(ellipse at 54% 50%,#304155 0,#172638 33%,#101c2a 56%,#0a1421 95%)}
.panels{position:absolute;inset:8% 0 17%;opacity:.35;background:repeating-linear-gradient(90deg,transparent 0 19%,#4c5967 19.15%,#0b1520 19.5%,transparent 19.8% 20%);border-top:4px double #536070;border-bottom:5px double #66717c}
.window{position:absolute;right:7%;top:8%;width:19%;height:71%;border:10px double #354151;border-radius:52% 52% 2% 2% / 29% 29% 1% 1%;overflow:hidden;background:radial-gradient(circle at 72% 29%,#e0eaf0 0 4%,#8dacc3 4.5%,transparent 15%),linear-gradient(#1b2c45,#627b90 70%,#27394d);box-shadow:0 0 0 5px #111d2b}
.window i{position:absolute;inset:58% 0 0;background:linear-gradient(#405466,#0e1e2b);clip-path:polygon(0 50%,7% 32%,6% 38%,13% 17%,21% 43%,18% 40%,25% 60%,36% 28%,34% 32%,42% 5%,49% 30%,47% 28%,58% 65%,68% 35%,66% 38%,74% 12%,87% 55%,95% 29%,100% 48%,100% 100%,0 100%)}
.window:after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 48%,#233141 49% 51%,transparent 52%),linear-gradient(transparent 39%,#243242 40% 41%,transparent 42% 72%,#243242 73% 74%,transparent 75%)}
.floor{position:absolute;inset:82% -20% 0;background:repeating-conic-gradient(from 267deg at 50% -30%,#202b37 0deg,#202a37 11deg,#141e29 11.5deg,#28333d 12deg);border-top:5px double #303c48}

canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
canvas:focus-visible { outline-offset: -4px; }
.room.placing canvas { cursor: crosshair; touch-action: none; }
.placing + .scene-foot { background: var(--raised); color: var(--text); }
.drag-orb { position: fixed; pointer-events: none; z-index: 6; transform: translate(-50%, -75%); }
.drag-orb img { width: 40px; height: 40px; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; width: 440px; max-width: calc(100vw - 32px); padding: 40px 24px 24px; max-height: 86svh; }
dialog[open] { animation: reveal 180ms var(--ease); }
dialog::backdrop { background: #05080dbb; }
.close { position: absolute; right: 8px; top: 8px; width: 40px; padding: 0; font-size: 24px; border-color: transparent; }
.modal-art { margin: 0 auto 16px; }
.center { text-align: center; }
dialog h2 { font-size: 28px; line-height: 1.25; margin: 8px 0 24px; }
label { display: block; font-size: 14px; margin: 16px 0 8px; }
input, textarea { width: 100%; border-radius: 8px; border: 1px solid #505b69; background: var(--page); color: var(--text); padding: 12px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { min-height: 104px; resize: vertical; }
form small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
form .error { color: #ffc4bf; margin-top: 8px; }
.author { margin: 8px 0 24px; }
blockquote { font-size: 24px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; margin: 24px 0; }
.kicker { font-size: 13px; color: var(--muted); }
.author a, footer a { color: var(--link); text-underline-offset: 4px; }
footer { color: var(--muted); font-size: 13px; padding-block: 0 24px; }
#toast:not(:empty) { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 12px 24px; text-align: center; z-index: 5; }
.share-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.share-status:not(:empty) { margin-top: 16px; font-size: 14px; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 760px) {
  header, main, footer { padding-inline: 16px; }
  header { min-height: 64px; gap: 8px; }
  .brand { font-size: 20px; }
  .brand img { width: 24px; }
  .house, .rule { display: none; }
  main { padding-block: 16px; }
  .workspace { grid-template-columns: 1fr; gap: 16px; }
  aside { gap: 16px; }
  .bar, .scene-foot { padding: 16px; }
  .bar { gap: 12px; }
  .room { height: clamp(280px, 55svh, 540px); }
  .window { right: 1%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
