/* Stationery & wrapping paper.
   Pine, cranberry and brass on warm paper. Serif for voice, system sans for UI.
   Hairlines over shadows. One motif and one moving thing per screen.
   No gradients, no glass, no glow. */

/* Newsreader (Production Type, SIL OFL 1.1, see fonts/Newsreader-OFL.txt). Variable: wght + opsz. */
@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-roman.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-italic.woff2") format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }

:root {
  --paper: #f4efe4;
  --card: #fbf8f1;
  --ink: #1d211e;
  --ink-2: #57594f;
  --ink-3: #8c897f;
  --rule: rgba(29, 33, 30, 0.12);
  --rule-strong: rgba(29, 33, 30, 0.24);
  --fill: rgba(29, 33, 30, 0.05);
  --fill-strong: rgba(29, 33, 30, 0.09);

  /* Roles, not colours. */
  --action: #1c3d2e; /* pine: primary buttons */
  --action-press: #132c21;
  --on-action: #f6f1e6;
  --highlight: #a8262a; /* cranberry: the revealed name, the ribbon. Sparingly. */
  --danger: #a8262a;
  --on-danger: #ffffff;
  --positive: #2d5c45;
  --brass: #b08a3e; /* hairlines, ring, twine only: too light for text */
  --brass-text: #7a5c1e; /* 5.5:1 on paper */
  --focus: #2d5c45;

  /* Illustration */
  --wrap: #1c3d2e;
  --wrap-lid: #234a38;
  --ribbon: #a8262a;
  --knot: #8a1e22;
  --mark: #b08a3e;
  --seal: #8f1f26;
  --print-ink: #1c3d2e;
  --print-far: #3d6a52;
  --print-paper: #f1eadb;
  --print-star: #c9a45c;
  --print-lamp: #e0a63e;
  --tag-bg: var(--card);
  --tag-ink: var(--ink);
  --tag-name: var(--highlight);
  --tag-ink-2: var(--ink-2);
  --tag-ink-3: var(--ink-3);
  --tag-label: var(--brass-text);
  --seal-deep: #5e1217;
  --wire: rgba(29, 33, 30, 0.5);
  --bulb: #b08a3e;
  --bulb-red: #a8262a;

  /* People */
  --orn-0: #1c3d2e;
  --orn-1: #a8262a;
  --orn-2: #8a6a26;
  --orn-3: #2a3d57;
  --on-orn: #f6f1e6;

  --shadow-lift: 0 1px 1px rgba(29, 33, 30, 0.04), 0 12px 32px -20px rgba(29, 33, 30, 0.35);
  --shadow-sheet: 0 30px 80px -30px rgba(20, 24, 21, 0.5);
  --tag-shadow: drop-shadow(0 14px 18px rgba(29, 33, 30, 0.14));

  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 18px;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --serif: "Newsreader", "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --spring: cubic-bezier(0.2, 0.9, 0.25, 1.05);
  --spring-ms: 420ms;
  --bounce: cubic-bezier(0.34, 1.4, 0.5, 1);
  --bounce-ms: 520ms;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  color-scheme: light dark;
}

/* Dark is its own palette, not an inversion: a winter night with cream stationery. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1713;
    --card: #17211b;
    --ink: #efe8da;
    --ink-2: #aaa596;
    --ink-3: #75736a;
    --rule: rgba(239, 232, 218, 0.11);
    --rule-strong: rgba(239, 232, 218, 0.22);
    --fill: rgba(239, 232, 218, 0.05);
    --fill-strong: rgba(239, 232, 218, 0.1);

    --action: #efe8da; /* cream button, pine ink */
    --action-press: #ffffff;
    --on-action: #13241b;
    --highlight: #ef8a7f; /* 7:1 on night */
    --danger: #ef7b70;
    --on-danger: #1a0c0b;
    --positive: #7fbf9c;
    --brass: #c9a75c;
    --brass-text: #d3b36d;
    --focus: #d3b36d;

    --wrap: #a8323a;
    --wrap-lid: #b63c43;
    --ribbon: #efe8da;
    --knot: #d9d0bd;
    --mark: #e0b96a;
    --seal: #b8343b;
    --tag-bg: #efe8da;
    --tag-ink: #1d211e;
    --tag-name: #a8262a;
    --tag-ink-2: #57594f;
    --tag-ink-3: #75736a;
    --tag-label: #7a5c1e;
    --seal-deep: #6d161b;
    --wire: rgba(239, 232, 218, 0.45);
    --bulb: #d3b36d;
    --bulb-red: #ef8a7f;

    --orn-0: #2f6a4e;
    --orn-1: #b13a3c;
    --orn-2: #9c7a33;
    --orn-3: #3c5476;
    --on-orn: #f6f1e6;

    --shadow-lift: 0 0 0 1px rgba(239, 232, 218, 0.04), 0 14px 30px -18px rgba(0, 0, 0, 0.8);
    --shadow-sheet: 0 30px 80px -30px rgba(0, 0, 0, 0.9);
    --tag-shadow: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.5));
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-optical-sizing: auto;
  background: var(--paper) var(--grain);
  color: var(--ink);
  font: 17px/1.45 var(--sans);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: color-mix(in srgb, var(--brass) 35%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

.app {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page { display: flex; flex-direction: column; gap: 22px; }

/* ---------- type ---------- */
.display { font: 400 46px/1.02 var(--serif); letter-spacing: -0.025em; }
.display em { font-style: italic; color: var(--highlight); }
.display-sm { font-size: 34px; line-height: 1.08; }
.title-serif { font: 400 28px/1.12 var(--serif); letter-spacing: -0.02em; }
.title-serif-sm { font: 500 20px/1.22 var(--serif); letter-spacing: -0.012em; }
.lede { color: var(--ink-2); font-size: 17px; line-height: 1.45; max-width: 34ch; }
.subtle { color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.footnote { color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.center { text-align: center; }
.narrow { max-width: 32ch; }
.num { font: 500 1.12em/1 var(--serif); color: var(--ink); font-variant-numeric: oldstyle-nums; }
.label, .kicker, .section-head, .field-label {
  font: 600 11.5px/1.2 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-text);
}
.center-label { text-align: center; }

.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.art { display: block; }
.art svg { display: block; overflow: visible; }

/* ---------- illustrations ---------- */
.gift-art svg { width: 100%; height: 100%; }
.gift-art .wrap { fill: var(--wrap); }
.gift-art .wrap-lid { fill: var(--wrap-lid); }
.gift-art .paper-mark { fill: none; stroke: var(--mark); stroke-width: 1.6; stroke-linecap: round; opacity: 0.75; }
.gift-art .ribbon { fill: var(--ribbon); }
.gift-art .knot { fill: var(--knot); }

.star-art { width: 44px; height: 44px; }
.star-art svg { width: 100%; height: 100%; }
.star-art .star { fill: var(--brass); }
.star-art .star-eye { fill: var(--paper); }

/* ---------- surfaces ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lift);
  padding: 22px;
}
.stack { display: flex; flex-direction: column; gap: 22px; }
.stack-sm { display: flex; flex-direction: column; gap: 14px; }

/* ---------- buttons ---------- */
.btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: var(--r-md);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform var(--spring-ms) var(--spring), background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: 90ms; }
.btn:disabled { opacity: 0.38; cursor: default; }
.btn-lg { min-height: 54px; padding: 0 22px; font-size: 17px; }
.btn-md { min-height: 44px; padding: 0 16px; font-size: 16px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: var(--r-sm); }
.btn-sm .icon { width: 17px; height: 17px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--action); color: var(--on-action); }
.btn-primary:hover:not(:disabled) { background: var(--action-press); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--fill); }
.btn-plain { background: transparent; color: var(--ink-2); min-width: 44px; min-height: 44px; padding: 0 10px; }
.btn-plain:hover:not(:disabled) { background: var(--fill); color: var(--ink); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; min-width: 0; }
.btn.is-busy { position: relative; color: transparent; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: var(--on-action);
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
.btn-secondary.is-busy::after { color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- fields ---------- */
.fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-label { color: var(--ink-2); letter-spacing: 0.12em; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--rule-strong);
  background: var(--card);
  outline: none;
  transition: border-color 160ms ease, box-shadow 200ms ease;
}
.field-input::placeholder { color: var(--ink-3); }
.field-input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.field-select { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
input[type="date"].field-input { min-width: 0; }

/* ---------- people: baubles at md/lg, a plain letter disc at sm ---------- */
.bauble {
  --tone: var(--orn-0);
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tone);
  color: var(--on-orn);
}
.bauble-md, .bauble-lg { margin-top: 4px; }
.bauble-md::before, .bauble-lg::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 32%;
  height: 6px;
  transform: translateX(-50%);
  background: var(--brass);
  border-radius: 2px 2px 1px 1px;
}
.bauble-mono { font: 500 15px/1 var(--serif); letter-spacing: 0.02em; }
.bauble-sm { width: 24px; height: 24px; }
.bauble-sm .bauble-mono { font: 600 11px/1 var(--sans); letter-spacing: 0; }
.bauble-md { width: 38px; height: 38px; }
.bauble-lg { width: 56px; height: 56px; }
.bauble-lg .bauble-mono { font-size: 21px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 4px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 5px;
  border-radius: var(--r-md);
  border: 1px solid var(--rule);
  background: var(--card);
  font-size: 15px;
  font-weight: 500;
}
.chip-x { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); cursor: pointer; }
.chip-x:hover { background: var(--fill-strong); color: var(--ink); }
.chip-x .icon { width: 14px; height: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 0; }
.meta-chip { font-size: 15px; color: var(--ink-2); }
.meta-chip + .meta-chip::before { content: "·"; margin: 0 10px; color: var(--ink-3); }

/* ---------- home ---------- */
.masthead { display: flex; flex-direction: column; gap: 10px; }
.masthead .print { margin: 0 0 18px; }
.print { margin: 0; padding: 10px 10px 12px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-xl); box-shadow: var(--shadow-lift); }
.print-mat { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; background: var(--fill-strong); }
.print-mat::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); pointer-events: none; }
.lino, .lino svg { display: block; width: 100%; height: 100%; }
.lino .lino-sky { fill: var(--print-ink); }
.lino .lino-far { fill: var(--print-far); }
.lino .lino-paper { fill: var(--print-paper); }
.lino .lino-hatch { fill: var(--print-far); opacity: 0.8; }
.lino .lino-star { fill: var(--print-star); }
.lino .lino-lamp { fill: var(--print-lamp); }
.print-plate { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 4px 0; }
.print-caption { font: italic 400 14.5px/1.3 var(--serif); color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tray { padding: 22px; }
.tray > * + * { margin-top: 16px; }
.step-head { display: flex; flex-direction: column; gap: 6px; }
.add-row { display: flex; gap: 8px; }
.add-row .btn { flex: none; width: 50px; min-height: 50px; padding: 0; }
.done { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.callout { border-top: 1px solid var(--rule); padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.link-field { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--rule-strong); border-radius: var(--r-md); padding: 6px 6px 6px 14px; }
.link-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 13px/1.4 var(--mono); color: var(--ink-2); }

/* ---------- sign-up ---------- */
.join-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.join-head { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.page-join .masthead { gap: 8px; }
.page-join .masthead .print { margin-bottom: 14px; }
.page-join .join-card { padding: 22px; gap: 16px; }

/* ---------- lists ---------- */
.section { display: flex; flex-direction: column; gap: 10px; }
.section-label { padding-left: 2px; }
.section-head { padding: 10px 2px 0; }
.list { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.list-foot { font-size: 13px; color: var(--ink-2); padding: 0 2px; margin-top: -10px; line-height: 1.45; }
.row { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 10px 10px 10px 16px; position: relative; width: 100%; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--rule); }
.row-button, .row-link { border: 0; background: transparent; cursor: pointer; transition: background-color 120ms ease; }
.row-button:hover, .row-link:hover { background: var(--fill); }
.row-button:active, .row-link:active { background: var(--fill-strong); }
.row-button > .icon { color: var(--ink-2); }
.row-button.is-danger, .row-button.is-danger > .icon { color: var(--danger); }
.row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.row-chevron { color: var(--ink-3); width: 18px; height: 18px; margin-right: 6px; }
.row-add .field-input { border: 0; background: transparent; min-height: 44px; padding: 0 4px; box-shadow: none; }
.add-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px dashed var(--rule-strong); color: var(--ink-2); flex: none; }
.add-icon .icon { width: 16px; height: 16px; }
.list > .row-button:has(.add-icon) .row-title { font-weight: 600; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--ink-3); }
.status-dot.is-on { background: var(--positive); border-color: var(--positive); }
.status-dot.is-done { background: var(--seal); border-color: var(--seal); }
.wish-tag { color: var(--brass-text); font-weight: 600; }
.wish-tag::before { content: "·"; margin-right: 6px; color: var(--ink-3); font-weight: 400; }

/* ---------- admin ---------- */
.admin-head { display: flex; flex-direction: column; gap: 8px; padding-top: 20px; }
.title-row { display: flex; align-items: flex-start; gap: 4px; }
.title-row .display { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.page-admin.is-loading .status, .page-admin.is-loading .panel { min-height: 160px; background: var(--fill); border-color: transparent; box-shadow: none; animation: pulse 1.2s ease-in-out infinite; border-radius: var(--r-xl); }
@keyframes pulse { 50% { opacity: 0.55; } }

.status { display: flex; flex-direction: column; gap: 16px; }
.status-top { display: flex; flex-direction: column; gap: 4px; }
.progress { height: 3px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding-top: 2px; }
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-figure { display: flex; align-items: baseline; gap: 2px; }
.stat-num { font: 400 44px/0.95 var(--serif); letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums; }
.stat-of { font: italic 400 17px/1 var(--serif); color: var(--ink-2); margin-left: 6px; }
.progress-bought .progress-fill { background: var(--seal); }
.progress-fill { --p: 0; height: 100%; width: calc(var(--p) * 100%); min-width: 3px; background: var(--positive); transition: width 600ms var(--spring); }

/* Native segmented control, in stationery colours. */
.segmented { --i: 0; position: relative; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--fill); border: 1px solid var(--rule); border-radius: 11px; padding: 2px; isolation: isolate; }
.segmented-thumb {
  position: absolute;
  z-index: -1;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / 3);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--rule), 0 2px 6px -2px rgba(0, 0, 0, 0.12);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform var(--spring-ms) var(--spring);
}
.segment { border: 0; background: transparent; min-height: 38px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: color 200ms ease; }
.segment.is-active { color: var(--ink); }
.segment-badge { font: 500 14px/1 var(--serif); font-variant-numeric: oldstyle-nums; color: var(--brass-text); }
.panel { display: flex; flex-direction: column; gap: 16px; }

.pair { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.pair-a, .pair-b { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.pair-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.pair-glyph { color: var(--ink-3); width: 18px; height: 18px; }
.matches .pair-b.is-hideable { filter: blur(8px); transition: filter 260ms ease; user-select: none; }
.matches.is-visible .pair-b.is-hideable { filter: none; user-select: auto; }
.rig-badge { color: var(--highlight); margin-right: 6px; }
.rig-badge .icon { width: 16px; height: 16px; }
.rig-badge.is-empty { visibility: hidden; }
.card-row { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg); cursor: pointer; }
.card-row .row-title { flex: 1; }
.row-sub-text { font-size: 13px; color: var(--ink-2); }
.bought-row { width: min(340px, 88vw); text-align: left; }
.row-toggle { justify-content: space-between; padding-right: 14px; min-height: 56px; }
.list-actions .row { min-height: 54px; }
.rig-arrow { display: grid; place-items: center; color: var(--ink-3); margin: -6px 0; transform: rotate(90deg); }

.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--fill-strong); position: relative; cursor: pointer; flex: none; transition: background-color 220ms ease; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform var(--spring-ms) var(--spring), width 160ms ease; }
.switch:checked { background: var(--positive); }
.switch:checked::after { transform: translateX(20px); }
.switch:active::after { width: 32px; }
.switch:checked:active::after { transform: translateX(15px); }

.empty, .empty-page { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 16px; }
.empty .star-art, .empty-page .star-art { margin-bottom: 6px; }
.empty-page { min-height: 70dvh; justify-content: center; }
.empty-page .btn { margin-top: 10px; }

/* ---------- reveal ---------- */
.page-reveal { gap: 22px; padding-top: 12px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.scene { position: relative; width: min(300px, 84vw); display: grid; place-items: center; padding: 6px 0 10px; }
.gift { width: min(220px, 60vw); aspect-ratio: 220 / 200; }
.gift .gift-art { width: 100%; height: 100%; }
.gift-box, .gift-lid { transform-box: fill-box; transform-origin: 50% 100%; }
.gift.is-idle .gift-svg { animation: bob 3.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.gift.is-shaking .gift-svg { animation: shake 90ms linear infinite; }
.gift.is-shaking .gift-lid { transform: translateY(calc(var(--shake, 0) * -8px)); }
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(calc(var(--shake, 0) * 2.5px), 0) rotate(calc(var(--shake, 0) * 1.5deg)); }
  75% { transform: translate(calc(var(--shake, 0) * -2.5px), 0) rotate(calc(var(--shake, 0) * -1.5deg)); }
}
.hold { position: relative; padding-left: 10px; gap: 10px; touch-action: none; -webkit-touch-callout: none; min-width: 220px; }
.hold.is-holding { transform: scale(0.96); }
.hold-ring { width: 32px; height: 32px; transform: rotate(-90deg); }
.hold-track { fill: none; stroke: color-mix(in srgb, var(--on-action) 25%, transparent); stroke-width: 4; }
.hold-fill { fill: none; stroke: var(--brass); stroke-width: 4; stroke-linecap: round; }

/* The gift tag: two layers so the cut corners keep their hairline, a punched hole, twine. */
.tag { --cut: 22px; position: relative; filter: var(--tag-shadow); }
.tag-face {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  background: var(--rule-strong);
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%, 0 var(--cut));
  backface-visibility: hidden;
}
.tag-face::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--tag-bg);
  clip-path: polygon(calc(var(--cut) - 0.4px) 0, calc(100% - var(--cut) + 0.4px) 0, 100% calc(var(--cut) - 0.4px), 100% 100%, 0 100%, 0 calc(var(--cut) - 0.4px));
}
.tag-face > * { position: relative; }
.tag::before {
  /* twine, ending at the hole */
  content: "";
  position: absolute;
  z-index: 2;
  left: calc(50% - 0.75px);
  bottom: calc(100% - 20px);
  width: 1.5px;
  height: 46px;
  background: var(--brass);
  transform-origin: 50% 100%;
}
.tag-hole { position: absolute; top: 13px; left: 50%; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--brass); }
.tag-name { font: italic 400 var(--name-size, 48px) / 1.04 var(--serif); letter-spacing: -0.02em; color: var(--tag-name); overflow-wrap: anywhere; }
.tag-face .label { color: var(--tag-label); }
.tag-from { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--brass); font: italic 400 15px/1.3 var(--serif); color: var(--tag-ink-2); }
.tag-details { font-size: 12.5px; letter-spacing: 0.04em; color: var(--tag-ink-3); }

.tag.is-hanging { position: absolute; right: max(-6px, calc(50% - 170px)); bottom: 16px; width: 112px; --cut: 14px; transform-origin: 50% -40px; transform: rotate(calc(8deg + var(--tension, 0) * 5deg)); }
.tag.is-hanging::before { height: 60px; transform: rotate(-42deg); }
.tag.is-hanging .tag-face { padding: 30px 10px 14px; }
.tag.is-hanging .tag-hole { top: 10px; }
.tag.is-hanging .tag-name { font-size: 19px; color: var(--tag-ink); }
.tag.is-hanging .label { font-size: 10px; }

.tag.is-open { width: min(340px, 88vw); margin-top: 38px; }
.tag.is-open .tag-face { padding: 46px 22px 22px; min-height: 230px; justify-content: center; }

.note { width: min(340px, 88vw); text-align: left; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.note-text { font: 400 18px/1.5 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; }
.note-text.is-empty { color: var(--ink-2); font-style: italic; font-size: 16px; }

.wish-card { display: flex; flex-direction: column; gap: 10px; }
.wish-head { display: flex; flex-direction: column; gap: 6px; }
.wish-input { resize: vertical; min-height: 96px; line-height: 1.45; font-family: var(--serif); font-size: 17px; }
.wish-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Wax seal pressed onto the opened tag. */
.tag-seal { position: absolute; z-index: 3; right: -10px; bottom: -14px; width: 58px; height: 58px; transform: rotate(-12deg); filter: drop-shadow(0 3px 4px rgba(60, 10, 12, 0.25)); }
.tag-seal svg { width: 100%; height: 100%; }
.tag-seal .wax { fill: var(--seal); }
.tag-seal .seal-ring { fill: none; stroke: var(--seal-deep); stroke-width: 1.6; }
.tag-seal .seal-mark { fill: none; stroke: var(--seal-deep); stroke-width: 2; stroke-linecap: round; }

/* ---------- sheet ---------- */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px; background: transparent; color: var(--ink); overflow: visible; }
.sheet::backdrop { background: rgba(14, 18, 15, 0.42); animation: fade 220ms ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet-panel { background: var(--card); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-sheet); padding: 8px 20px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; max-height: 88dvh; overflow: auto; }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--fill-strong); margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title { font: 400 24px/1.15 var(--serif); letter-spacing: -0.015em; }
.sheet-text { color: var(--ink-2); }
.sheet-body .list { background: transparent; }
.sheet-foot { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 640px) {
  .sheet { margin: auto; }
  .sheet-panel { border-radius: var(--r-xl); padding-bottom: 20px; border: 1px solid var(--rule); }
  .sheet-grabber { display: none; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 0);
  z-index: 50;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 12px 14px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 32px);
}
.toast.is-visible { display: inline-flex; }
.toast .icon { width: 17px; height: 17px; color: var(--brass); }
.toast-error .icon { color: var(--danger); }

@media (max-width: 380px) {
  .field-pair { grid-template-columns: 1fr; }
  .display { font-size: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
