* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; font: 400 16px/1.5 var(--font); color: var(--ink); overflow-x: hidden; }
.page { max-width: 460px; margin: 0 auto; padding: 0 16px 32px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; color: var(--wine-ink); line-height: 1.15; margin: 0 0 12px; text-wrap: balance; overflow-wrap: anywhere; }
h1 { font-size: 32px; text-align: center; }
h2 { font-size: 24px; }
p { margin: 0 0 12px; }
a { color: var(--wine-ink); }

.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 -16px 16px; padding: 14px 16px;
  background: var(--wine); color: var(--paper); font: 700 22px/1.1 var(--font-head); text-decoration: none; border-bottom: 3px solid var(--gold); }
.brand::before, .brand::after, .sprigged::before, .sprigged::after { content: ""; flex: none; width: 34px; height: 17px;
  background: var(--gold); -webkit-mask: var(--sprig) center / contain no-repeat; mask: var(--sprig) center / contain no-repeat; }
.brand::after, .sprigged::after { transform: scaleX(-1); }

.card { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: var(--sticker-shadow); }
.pill { display: inline-block; background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius-pill); padding: 4px 14px; margin: 0 0 12px; }
.small { font-size: 13px; color: var(--ink-soft); }
.error { color: var(--danger); min-height: 1.4em; margin: 6px 0; font-weight: 600; }
label { display: block; margin: 0 0 6px; }
input[type="text"], textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); padding: 13px 16px;
  border: 1px solid var(--gold); border-radius: var(--radius-small); margin: 0 0 10px; }
textarea { min-height: 100px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; padding: 4px 2px; margin: 0 0 10px; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--pine); }
.btn { display: block; width: 100%; min-height: 52px; font: 700 18px/1.2 var(--font-head); text-align: center; text-decoration: none; cursor: pointer;
  background: var(--surface); color: var(--wine-ink); border: 2px solid var(--gold); border-radius: var(--radius-pill); padding: 13px 18px; margin: 0 0 10px; box-shadow: var(--sticker-shadow); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--danger); }
.btn.oneline { white-space: nowrap; font-size: 16px; padding-left: 8px; padding-right: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 120px; width: auto; }

/* doors: arched wooden doors, red and green in a checker, gold numbers */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; padding: 12px; background: var(--pine-band); border-radius: var(--radius); }
.grid.preview { grid-template-columns: repeat(6, 1fr); gap: 8px; }
.door { position: relative; aspect-ratio: 4 / 5; display: grid; place-items: center; align-content: center; gap: 2px; padding: 0; cursor: pointer;
  font: 700 22px/1 var(--font-head); color: var(--door-ink); border: var(--sticker-border); border-radius: var(--radius-door);
  background: repeating-linear-gradient(90deg, transparent 0 11px, var(--plank) 11px 13px), var(--door-1); }
.door:nth-child(8n+2), .door:nth-child(8n+4), .door:nth-child(8n+5), .door:nth-child(8n+7) {
  background: repeating-linear-gradient(90deg, transparent 0 11px, var(--plank) 11px 13px), var(--door-2); }
.grid.preview .door { font-size: 16px; cursor: default; }
.door .sticker { position: absolute; top: 9%; width: 18px; height: 18px; fill: var(--door-ink); stroke: var(--wine-deep); stroke-width: 1; }
.note .sticker { float: right; width: 30px; height: 30px; margin: 0 0 6px 8px; fill: var(--gold); stroke: var(--wine-ink); stroke-width: 1; }
.stickers { display: flex; gap: 6px; margin: 0 0 10px; }
.stickers button { flex: 1; min-height: 48px; padding: 6px; background: var(--surface); border: 2px solid var(--card-line); border-radius: var(--radius-small); cursor: pointer; }
.stickers button[aria-pressed="true"] { background: var(--pine); border-color: var(--gold); }
.stickers .sticker { width: 26px; height: 26px; fill: var(--gold); stroke: var(--wine-ink); stroke-width: 1; }
.grid .door.s-checking { border: 2px dashed var(--gold); filter: saturate(0.6); }
.grid .door.s-empty { background: var(--cream); color: var(--wine-ink); border: 2px dashed var(--gold); }
.grid .door.s-ready { box-shadow: var(--glow); animation: wiggle 2.4s ease-in-out infinite; }
/* open: warm light inside, the leaf swung back on its hinge, an envelope waiting */
.grid .door.s-opened { background: radial-gradient(circle at 68% 62%, var(--snow), var(--gold) 75%); color: var(--wine-ink); perspective: 200px; }
.grid .door.s-opened::before { content: ""; position: absolute; left: -2px; top: -2px; bottom: -2px; width: 38%; border: var(--sticker-border);
  border-radius: 999px 0 0 4px; background: repeating-linear-gradient(90deg, transparent 0 7px, var(--plank) 7px 9px), var(--pine);
  transform-origin: left; transform: rotateY(-35deg); }
.grid .door.s-opened > * { position: relative; left: 14%; }
.door svg { width: 22px; height: 22px; }
.door .tag { font: 600 11px/1.2 var(--font); }
.icon { fill: none; stroke: var(--paper); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.s-empty .icon, .s-opened .icon { stroke: var(--wine-ink); }
.icon .fill { fill: var(--gold); }
.icon .paper { fill: var(--surface); }
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-4deg); } 95% { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

dialog { width: 100%; max-width: 460px; max-height: 88vh; margin: auto auto 0; padding: 18px 16px 24px; border: 0; border-top: 4px solid var(--gold);
  border-radius: var(--radius) var(--radius) 0 0; background: var(--cream); color: var(--ink); overflow-y: auto; }
dialog::backdrop { background: var(--scrim); }
/* on a larger screen the sheet is a centred card, fully inside the window */
@media (min-width: 720px) {
  dialog { margin: auto; max-height: calc(100vh - 48px); border: 2px solid var(--gold); border-radius: var(--radius); }
}
.close { float: right; font: 700 22px/1 var(--font-head); color: var(--wine-ink); background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius-pill); width: 40px; height: 40px; cursor: pointer; }
.after { animation: rise 0.35s ease-out 0.45s both; }
@keyframes unwrap { from { opacity: 0; transform: perspective(500px) rotateX(-70deg); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.danger-zone { margin-top: 32px; padding-top: 16px; border-top: 2px dashed var(--danger); }
.btn.danger.solid { background: var(--danger); color: var(--paper); border-color: var(--danger); }
.status .btn { margin-bottom: 6px; }
.compact h2 { font-size: 18px; margin-bottom: 4px; }
.compact .row .btn, .compact > .btn { min-height: 44px; font-size: 15px; padding: 8px; }
.compact .row .btn { flex-basis: 90px; }
.compact p { margin-bottom: 8px; }
.idea-picks { margin: 0 0 10px; }
.idea-picks button { display: block; width: 100%; min-height: 44px; margin: 6px 0 0; padding: 8px 12px; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius-small); cursor: pointer; }
@media (min-width: 960px) {
  .brand { margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); }
}
@media (min-width: 1024px) {
  body.owner .page { max-width: 1080px; }
  body.owner #calendar { display: grid; grid-template-columns: 340px 1fr; grid-template-rows: auto 1fr; column-gap: 32px; align-items: start; }
  body.owner #side { grid-column: 1; grid-row: 1; }
  body.owner #grid { grid-column: 2; grid-row: 1 / span 2; grid-template-columns: repeat(6, 1fr); margin-top: 0; }
  body.owner #below { grid-column: 1; grid-row: 2; }
}
.note { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 14px; font: 400 20px/1.45 var(--font-head); }
/* an opened note is a sheet of ruled paper that unwraps */
.note.unwrap { transform-origin: top; animation: unwrap 0.55s ease-out both;
  line-height: 29px; box-shadow: var(--sticker-shadow);
  /* one rule per line of text, just under the baseline, inside the padding */
  background: repeating-linear-gradient(transparent 0 25px, var(--card-line) 25px 26px, transparent 26px 29px) content-box, var(--paper); }
.emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 0 0 10px; }
.emojis button { font-size: 26px; padding: 6px 0; background: var(--surface); border: 2px solid var(--card-line); border-radius: var(--radius-small); cursor: pointer; }
.emojis button[aria-pressed="true"] { background: var(--surface-soft); border-color: var(--pine); }
.big-emoji { font-size: 84px; line-height: 1.1; text-align: center; margin: 0; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 20px; max-width: 428px; margin: 0 auto; padding: 12px 16px; text-align: center;
  background: var(--wine-deep); color: var(--paper); border-radius: var(--radius-pill); }
dialog .toast { position: sticky; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--card-line); overflow-wrap: anywhere; }
footer { margin-top: 24px; font-size: 13px; text-align: center; color: var(--ink-soft); border-top: 1px solid var(--card-line); padding: 16px 0 0; }
footer p { margin: 0 0 4px; }
/* targets at least 44px tall */
footer a { display: inline-block; min-width: 44px; padding: 12px 8px; }
.check { min-height: 44px; }
.status strong, .status span { display: block; }
.status { text-align: center; }
a.tap { display: inline-flex; align-items: center; min-height: 44px; }
.linklike { min-height: 44px; font: 700 15px/1.2 var(--font); color: var(--wine); background: none; border: 0; text-decoration: underline; cursor: pointer; }
#title { font-size: 26px; }
#actions .row .btn { font-size: 15px; padding-left: 8px; padding-right: 8px; }
.ranks { list-style: none; padding: 0; margin: 0 0 8px; counter-reset: rank; }
.ranks li { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 6px 10px; background: var(--surface-soft); border-radius: var(--radius-small); overflow-wrap: anywhere; counter-increment: rank; }
.ranks li::before { content: counter(rank); flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--gold); color: var(--wine-deep); font: 700 14px/1 var(--font-head); }
.ranks li span:first-child { flex: 1; font-weight: 700; }
