/* A Book, Wrapped — see book.js */
:root { --ink: #2b2724; --ink-2: #6f6862; --ink-3: #a7a09a; --line: #e7e2dc; --red: #b8282f; --panel: #faf8f5;
  --ease: cubic-bezier(0.22, 0.68, 0.16, 1); --hand: "Caveat", "Patrick Hand", cursive; --serif: "Fraunces", Georgia, serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #fff; color: var(--ink); font-family: "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.bk { position: fixed; inset: 0; display: grid; grid-template-columns: 1fr; }
.bk.is-make { grid-template-columns: 1fr minmax(340px, 400px); }

/* the table the books sit on */
.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.home { position: absolute; z-index: 3; top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); font-family: var(--serif); font-style: italic; font-size: 0.95rem; color: var(--ink-2); text-decoration: none; }
.snd { position: absolute; z-index: 3; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); border: 0; background: none; padding: 6px; color: var(--ink-3); display: grid; place-items: center; }
.snd svg { width: 18px; height: 18px; }
.snd:hover { color: var(--ink-2); }
.try { position: absolute; z-index: 3; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 16px; font-family: var(--hand); font-size: 1.15rem; line-height: 1; color: var(--ink); box-shadow: 0 2px 10px rgba(40, 30, 20, 0.06); }
.try:hover { border-color: var(--ink-3); }

/* the words under the book */
.under { position: absolute; z-index: 2; left: 0; width: 100%; top: 80%; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 16px; pointer-events: none; }
.under > * { pointer-events: auto; }
.cap { margin: 0 0 4px; font-family: var(--hand); font-size: 1.1rem; color: var(--ink-2); }
.hint { margin: 0; font-family: var(--hand); font-size: 1.32rem; line-height: 1.15; color: var(--ink); min-height: 1.15em; transition: opacity 0.3s; }
.hint.is-nudge { animation: nudge 0.5s var(--ease); }
@keyframes nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px; margin-top: 2px; }
.links button, .links a { border: 0; background: none; padding: 2px 0; font-family: var(--hand); font-size: 1.12rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.links button:hover, .links a:hover { color: var(--ink); }
.done { display: flex; flex-direction: column; align-items: center; animation: rise 0.6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.done__t { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(1.15rem, 2.4vw, 1.5rem); letter-spacing: -0.01em; line-height: 1.15; max-width: 26em; }
.done__a { margin: 3px 0 10px; font-family: var(--serif); font-style: italic; font-size: 0.92rem; color: var(--ink-2); }
.next { border: 1.5px solid var(--ink); background: #fff; border-radius: 999px; padding: 6px 16px 7px; font-family: var(--hand); font-size: 1.2rem; line-height: 1; margin-bottom: 8px; }
.next:hover { background: var(--ink); color: #fff; }
.links button:focus-visible, .links a:focus-visible, .next:focus-visible, .try:focus-visible, .snd:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 4px; }

/* the note found with the book */
.note { position: absolute; z-index: 4; width: min(300px, calc(100% - 40px)); padding: 18px 20px 16px; background: #fffdf7; border-radius: 3px;
  box-shadow: 0 14px 34px rgba(40, 28, 18, 0.18), 0 1px 0 rgba(0, 0, 0, 0.04); transform: rotate(2.4deg); animation: noteIn 0.9s var(--ease) both;
  cursor: pointer; }
@keyframes noteIn { from { opacity: 0; transform: translateY(26px) rotate(-3deg); } }
.note__k { margin: 0 0 6px; font-family: var(--serif); font-style: italic; font-size: 0.78rem; color: var(--ink-3); }
.note__t { margin: 0; font-family: var(--hand); font-size: 1.45rem; line-height: 30px; background: repeating-linear-gradient(180deg, transparent 0 28px, rgba(120, 140, 190, 0.2) 28px 29px, transparent 29px 30px); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.note__f { margin: 4px 0 0; font-family: var(--hand); font-size: 1.3rem; text-align: right; color: var(--ink-2); }

/* the panel he wraps them with */
.panel { position: relative; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 22px 22px 0; display: flex; flex-direction: column; }
.panel.is-inert { opacity: 0.5; pointer-events: none; }
.p__head h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.6rem; letter-spacing: -0.02em; }
.p__head p { margin: 6px 0 4px; font-size: 0.86rem; line-height: 1.45; color: var(--ink-2); }
.sec { padding: 16px 0 14px; border-bottom: 1px solid var(--line); }
.sec:last-of-type { border-bottom: 0; }
.sec__h { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 0.88rem; font-weight: 600; }
.sec__h b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 0.7rem; flex: none; transform: translateY(-1px); }
.sec__h small { font-weight: 400; color: var(--ink-3); font-size: 0.8rem; }
.sec__h .sp { flex: 1; }
.sec__h button { border: 0; background: none; padding: 0; font-size: 0.78rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.small { margin: 8px 0 0; font-size: 0.76rem; line-height: 1.45; color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px 4px 4px; font-size: 0.78rem; }
.chip i { width: 18px; height: 18px; border-radius: 50%; flex: none; background-size: cover; background-position: center; border: 1px solid rgba(0, 0, 0, 0.08); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12em; }
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.chip--add { padding: 4px 12px; color: var(--ink-2); border-style: dashed; }

.find { display: flex; gap: 6px; }
.find input, .field input, .field textarea { flex: 1; min-width: 0; width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 0.88rem; color: var(--ink); }
.find input:focus, .field input:focus, .field textarea:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: transparent; }
.btn { border: 0; border-radius: 10px; background: var(--ink); color: #fff; padding: 0 14px; font-size: 0.85rem; font-weight: 600; min-height: 38px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.res { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.res button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid transparent; background: #fff; border-radius: 10px; padding: 6px 8px; }
.res button:hover, .res button:focus-visible { border-color: var(--line); outline: none; }
.res img, .res .nocover { width: 30px; height: 44px; object-fit: cover; border-radius: 2px; flex: none; background: #eee7dd; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.res b { display: block; font-size: 0.84rem; font-weight: 600; line-height: 1.25; }
.res small { display: block; font-size: 0.75rem; color: var(--ink-2); }
.msg { margin: 6px 0 0; min-height: 1em; font-size: 0.78rem; color: var(--ink-2); }
.msg.is-bad { color: #b0452f; }
.chosen { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.chosen .cov { width: 46px; height: 68px; flex: none; border-radius: 2px; background: #eee7dd center / cover; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); }
.chosen b { display: block; font-family: var(--serif); font-weight: 400; font-size: 1rem; line-height: 1.2; }
.chosen small { display: block; margin-top: 2px; font-size: 0.78rem; color: var(--ink-2); }
.chosen .acts { display: flex; gap: 12px; margin-top: 6px; }
.chosen .acts button { border: 0; background: none; padding: 0; font-size: 0.76rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.row > button { border: 0; background: none; padding: 0; font-size: 0.8rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.hand { margin-top: 10px; display: grid; gap: 8px; }
.field { display: block; }
.field span { display: block; margin: 0 0 4px; font-size: 0.76rem; font-weight: 600; color: var(--ink-2); }
.field textarea { resize: vertical; font-family: var(--hand); font-size: 1.25rem; line-height: 1.2; }
.count { display: block; text-align: right; font-size: 0.72rem; color: var(--ink-3); margin-top: 2px; }

.sw { display: flex; flex-wrap: wrap; gap: 7px; }
.sw button { position: relative; width: 40px; height: 40px; padding: 0; border-radius: 9px; border: 1.5px solid rgba(0, 0, 0, 0.08); overflow: hidden; background: #fff; }
.sw button canvas { width: 100%; height: 100%; display: block; }
.sw button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.sw .own { display: grid; place-items: center; font-size: 0.66rem; color: var(--ink-2); border-style: dashed; background: #fff center / cover; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: #fff; margin: 0 0 10px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 4px 12px; font-size: 0.78rem; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.rb { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.rb button { height: 26px; padding: 0; border-radius: 6px; border: 1.5px solid rgba(0, 0, 0, 0.06); overflow: hidden; background: #fff; }
.rb button canvas { width: 100%; height: 100%; display: block; }
.rb button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.rb.is-off { opacity: 0.35; pointer-events: none; }
.st { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.st button { aspect-ratio: 1; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; display: grid; place-items: center; }
.st button:hover { border-color: var(--ink-3); }
.st button canvas { width: 100%; height: 100%; display: block; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

.make { position: sticky; bottom: 0; margin: auto -22px 0; padding: 14px 22px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(250, 248, 245, 0), var(--panel) 30%); }
.make .btn { width: 100%; min-height: 46px; border-radius: 999px; font-size: 0.95rem; }
.make p { margin: 6px 0 0; text-align: center; font-size: 0.74rem; color: var(--ink-3); }

/* the link, once it's made */
.ed { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 20px 14px; overflow-y: auto; background: rgba(30, 24, 20, 0.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.ed__box { position: relative; width: min(480px, 100%); margin: auto 0; background: #fff; border-radius: 18px; padding: 24px 22px 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.ed__x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f2efea; }
.ed__kicker { margin: 0; font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.ed__title { margin: 6px 40px 6px 0; font-family: var(--serif); font-weight: 400; font-size: 1.7rem; }
.ed__sub { margin: 0 0 16px; font-size: 0.9rem; color: var(--ink-2); line-height: 1.5; }
.ed__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.ed__btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--ink); color: #fff; font-weight: 600; font-size: 0.92rem; text-decoration: none; }
.ed__btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.share__link { width: 100%; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 0.85rem; }
.share__size { margin: 0 0 14px; font-size: 0.76rem; color: var(--ink-3); }

.broken { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: #fff; z-index: 50; }
.broken h2 { font-family: var(--serif); font-weight: 400; font-size: 1.8rem; margin: 0 0 10px; }
.broken p { max-width: 36ch; margin: 0 auto; color: var(--ink-2); line-height: 1.5; }

/* phones: the stage on top, the panel under it, the page scrolls */
@media (max-width: 760px) {
  body.is-make { overflow: auto; }
  .bk.is-make { position: static; display: block; }
  .bk.is-make .stage { height: 64svh; min-height: 420px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); padding: 18px 16px 0; overflow: visible; }
  .make { margin: 0 -16px; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }
  .hint { font-size: 1.22rem; }
  .links button, .links a { font-size: 1.06rem; }
  .note { left: 50% !important; top: auto !important; margin-left: max(-150px, calc(-50% + 20px)); }
}
@media (prefers-reduced-motion: reduce) { .done, .note { animation: none; } }
