@font-face { font-family: "Patrick Hand"; src: url("/fonts/patrick-hand-latin-400-normal.woff2") format("woff2"); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Patrick Hand"; src: url("/fonts/patrick-hand-latin-ext-400-normal.woff2") format("woff2"); font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Caveat"; font-weight: 700; src: url("/fonts/caveat-latin-700-normal.woff2") format("woff2"); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Caveat"; font-weight: 700; src: url("/fonts/caveat-latin-ext-700-normal.woff2") format("woff2"); font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #f3e8f5;
  --ink: #2d2440;
  --muted: #7a6b8a;
  --accent: #c2417e;
  --paper: #fffaf0;
  --line: #b9d3ee;
  --margin: #f2a3b3;
  --cover: #7b3f6e;
  --bar: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1724; --ink: #f1e9f7; --muted: #b6a7c4; --bar: #2a2133; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.top { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px 6px; }
.top h1 { font-family: "Caveat", cursive; font-size: 1.9rem; margin: 0; flex: 1; line-height: 1; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { border: 2px solid rgba(0,0,0,.08); background: var(--bar); border-radius: 999px; padding: 8px 12px; font-weight: 700; min-height: 42px; }
.pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.datepick { position: relative; }
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.status { font-size: .8rem; color: var(--muted); text-align: center; min-height: 1.1em; margin: 2px 0 0; }
.demo-band { background: #fde68a; color: #4a3500; text-align: center; font-weight: 700; padding: 6px 10px; display: flex; gap: 10px; justify-content: center; align-items: center; }
.demo-band button { border: 0; border-radius: 999px; padding: 4px 12px; background: #4a3500; color: #fde68a; font-weight: 700; }

/* ---------- The book ---------- */
.stage { display: flex; justify-content: center; padding: 0 12px; }
.book { position: relative; width: var(--pw, 360px); height: calc(var(--pw, 360px) * 4 / 3); perspective: calc(var(--pw, 360px) * 3); }
.page {
  position: absolute; inset: 0; container-type: inline-size; overflow: hidden;
  background: var(--paper); color: #2d2440; border-radius: 4px 14px 14px 4px;
  box-shadow: 0 10px 30px rgba(60, 20, 70, .25), inset 10px 0 18px -10px rgba(0,0,0,.25);
}
.page::before { /* spine shadow */ content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4cqw; background: linear-gradient(90deg, rgba(0,0,0,.12), transparent); pointer-events: none; z-index: 1; }
.lines { position: absolute; left: 0; right: 0; top: 25cqw; bottom: 0;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(6.6cqw - 1px), var(--line) calc(6.6cqw - 1px), var(--line) 6.6cqw); }
.margin-line { position: absolute; top: 0; bottom: 0; left: 11cqw; width: 2px; background: var(--margin); opacity: .8; }
.head { position: absolute; left: 13cqw; right: 5cqw; top: 3cqw; height: 21cqw; display: flex; align-items: flex-start; gap: 2cqw; z-index: 3; }
.head .dates { flex: 1; min-width: 0; }
.head .year { font-family: "Patrick Hand", cursive; font-size: 4cqw; color: #7a6b8a; letter-spacing: .1em; }
.head .day { font-family: "Caveat", cursive; font-weight: 700; font-size: 10cqw; line-height: .95; color: #c2417e; white-space: nowrap; }
.head .weekday { font-family: "Caveat", cursive; font-weight: 700; font-size: 6.5cqw; line-height: 1.1; color: #5b4a7a; }
.mood { font-size: 10cqw; line-height: 1; background: none; border: 2px dashed rgba(122,107,138,.35); border-radius: 50%; width: 15cqw; height: 15cqw; display: grid; place-items: center; padding: 0; }
.mood.set { border-color: transparent; }
.drawing { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.text {
  position: absolute; left: 13cqw; right: 5cqw; top: 25cqw; bottom: 4cqw; z-index: 4;
  font-family: "Patrick Hand", "Comic Sans MS", cursive; font-size: 4.7cqw; line-height: 6.6cqw; color: #2d2440;
  background: transparent; border: 0; outline: none; resize: none; padding: 0; margin: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden;
}
textarea.text { overflow-y: auto; }
.text::placeholder { color: #b5a8c4; }
.items { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.item { position: absolute; transform-origin: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.item.photo { background: #fff; padding: 2.5% 2.5% 9%; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.item.photo img { display: block; width: 100%; height: auto; pointer-events: none; }
.item.photo::after { /* tape */ content: ""; position: absolute; top: -6%; left: 35%; width: 30%; height: 12%; background: rgba(250, 230, 150, .75); transform: rotate(-4deg); }
.item.sticker { text-align: center; line-height: 1; }
.item.sticker span { display: block; font-size: calc(var(--w) * 0.85cqw); }
.page.decorate .items { pointer-events: auto; }
.page.decorate .item { cursor: grab; }
.item.selected { outline: 3px dashed #c2417e; outline-offset: 4px; }
.page.draw .drawing { pointer-events: auto; touch-action: none; cursor: crosshair; }
.page:not(.write) .text { pointer-events: none; }

/* page turning */
.leaf { position: absolute; inset: 0; transform-origin: left center; transform-style: preserve-3d; z-index: 20; pointer-events: none; }
.leaf .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .face.back { transform: rotateY(180deg); background: linear-gradient(90deg, #f6eedd, #efe4cf); border-radius: 14px 4px 4px 14px; box-shadow: inset -12px 0 20px -10px rgba(0,0,0,.25); }
.leaf .face .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,.25)); opacity: 0; z-index: 30; border-radius: inherit; }
.turn-shadow { position: absolute; inset: 0; background: rgba(40, 10, 50, .25); z-index: 19; pointer-events: none; opacity: 0; border-radius: 4px 14px 14px 4px; }
.nav { position: absolute; bottom: -2px; z-index: 25; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(194, 65, 126, .92); color: #fff; font-size: 1.4rem; font-weight: 800; box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.nav.prev { left: -6px; } .nav.next { right: -6px; }

/* cover */
.cover { position: absolute; inset: 0; z-index: 40; border-radius: 4px 14px 14px 4px; background:
  radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 50%), linear-gradient(135deg, #8e4a80, var(--cover));
  color: #fff3fb; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; text-align: center; container-type: inline-size;
  box-shadow: 0 12px 30px rgba(60,20,70,.35), inset 6px 0 0 rgba(0,0,0,.25); transform-origin: left center; }
.cover h2 { font-family: "Caveat", cursive; font-size: 15cqw; margin: 0; line-height: .9; }
.cover .yr { font-family: "Caveat", cursive; font-size: 9cqw; opacity: .9; }
.cover .deco { font-size: 12cqw; }
.cover .open { font-size: 5cqw; padding: 3cqw 8cqw; border-radius: 999px; border: 0; background: #fff3fb; color: var(--cover); font-weight: 800; }

/* ---------- Tools ---------- */
.tools { max-width: 560px; margin: 8px auto 0; padding: 0 12px max(12px, env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.modes button { border: 2px solid rgba(0,0,0,.08); background: var(--bar); border-radius: 16px; padding: 8px 4px; font-weight: 700; font-size: .85rem; display: grid; gap: 2px; justify-items: center; }
.modes button b { font-size: 1.35rem; }
.modes button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.sub { min-height: 56px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; background: var(--bar); border-radius: 16px; padding: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.swatch.on { box-shadow: 0 0 0 3px var(--accent); }
.size { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(0,0,0,.1); background: transparent; display: grid; place-items: center; }
.size.on { border-color: var(--accent); }
.size i { display: block; border-radius: 50%; background: currentColor; }
.tool { border: 2px solid rgba(0,0,0,.1); background: transparent; border-radius: 12px; padding: 6px 10px; font-weight: 700; min-height: 40px; }
.tool.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.stickers { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; width: 100%; }
.stickers button { font-size: 1.5rem; background: transparent; border: 0; padding: 4px 0; border-radius: 10px; }
.moods { position: absolute; z-index: 30; top: 19cqw; right: 3cqw; background: #fff; border-radius: 999px; padding: 1.5cqw 2cqw; display: flex; gap: 1cqw; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.moods button { font-size: 7cqw; background: none; border: 0; padding: 0 .5cqw; }

/* ---------- Cards (login / not owner) ---------- */
.card { max-width: 420px; margin: 8vh auto; background: var(--bar); border-radius: 24px; padding: 24px; text-align: center; display: grid; gap: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.card h2 { font-family: "Caveat", cursive; font-size: 2.4rem; margin: 0; color: var(--accent); }
.big { border: 0; border-radius: 16px; padding: 14px 18px; font-weight: 800; font-size: 1.1rem; background: var(--accent); color: #fff; text-decoration: none; display: block; }
.big.alt { background: transparent; color: var(--accent); border: 2px solid var(--accent); }

/* ---------- Demo tour bubble ---------- */
.bubble { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); width: min(92vw, 420px);
  background: #2d2440; color: #fff; border-radius: 18px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.35); display: grid; gap: 10px; }
.bubble p { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.bubble .row { display: flex; justify-content: space-between; align-items: center; }
.bubble button { border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 700; }
.bubble .skip { background: transparent; color: #cbb8dc; }
.spot { outline: 4px solid #fde047 !important; outline-offset: 3px; border-radius: 12px; transition: outline-color .3s; }
.finger { position: fixed; z-index: 99; width: 34px; height: 34px; margin: -6px 0 0 -6px; font-size: 30px; pointer-events: none; transition: left .45s ease, top .45s ease; }
