/* Crowned. Four looks, one set of tokens. See design/DESIGN.md. */

/* ---------- tokens ---------- */

:root {
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --r-card: 20px;
  --r-ctl: 14px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

[data-theme="christmas"][data-mode="light"] {
  --bg: #FBF8F3; --surface: #FFFFFF; --surface-2: #F4EEE4;
  --ink: #1D2A23; --ink-2: #56625B; --line: #E4DBCC;
  --primary: #1F5A3D; --primary-ink: #FFFFFF; --primary-soft: #E6F0E9;
  --accent: #B3261E; --accent-ink: #FFFFFF; --accent-soft: #F9E7E4;
  --danger: #B3261E; --gold: #C9982E;
  --frame: #FFFFFF; --frame-line: #D9B65A;
  --ribbon: #C4342B; --ribbon-edge: #8E1F18;
  --snow: #BFD0DE; --focus: #1F5A3D; --scrim: rgba(24, 30, 26, 0.48);
  --shadow: 0 1px 2px rgba(70, 50, 20, 0.06), 0 8px 22px rgba(70, 50, 20, 0.07);
}
[data-theme="christmas"][data-mode="dark"] {
  --bg: #0E1B33; --surface: #17284C; --surface-2: #1F3360;
  --ink: #F3EFE6; --ink-2: #B7C1D6; --line: #2E4374;
  --primary: #6CCB98; --primary-ink: #072318; --primary-soft: #1B4250;
  --accent: #FF9A8D; --accent-ink: #3A0B07; --accent-soft: #4A2540;
  --danger: #FF9A8D; --gold: #E6C067;
  --frame: #1F3360; --frame-line: #D9B45A;
  --ribbon: #E0483D; --ribbon-edge: #8E1F18;
  --snow: #FFFFFF; --focus: #F0D68A; --scrim: rgba(4, 9, 20, 0.62);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 26px rgba(0, 0, 0, 0.26);
  color-scheme: dark;
}
[data-theme="classic"][data-mode="light"] {
  --font-display: var(--font-body);
  --bg: #F3F4F5; --surface: #FFFFFF; --surface-2: #ECEEF0;
  --ink: #1D2125; --ink-2: #59616A; --line: #DADEE3;
  --primary: #1B7046; --primary-ink: #FFFFFF; --primary-soft: #E3F1E9;
  --accent: #1B7046; --accent-ink: #FFFFFF; --accent-soft: #E3F1E9;
  --danger: #B42318; --gold: #C9982E;
  --frame: #FFFFFF; --frame-line: #CFD4DA;
  --ribbon: #2A8A5A; --ribbon-edge: #14553A;
  --snow: transparent; --focus: #1B7046; --scrim: rgba(20, 22, 25, 0.48);
  --shadow: 0 1px 2px rgba(20, 25, 30, 0.06), 0 6px 18px rgba(20, 25, 30, 0.06);
}
[data-theme="classic"][data-mode="dark"] {
  --font-display: var(--font-body);
  --bg: #17191C; --surface: #212428; --surface-2: #2B2F34;
  --ink: #ECEEF0; --ink-2: #A9B0B8; --line: #3A3F46;
  --primary: #58C08A; --primary-ink: #0A2015; --primary-soft: #1F3A2D;
  --accent: #58C08A; --accent-ink: #0A2015; --accent-soft: #1F3A2D;
  --danger: #FF9A8D; --gold: #E6C067;
  --frame: #2B2F34; --frame-line: #4A5058;
  --ribbon: #3FA873; --ribbon-edge: #1D6B45;
  --snow: transparent; --focus: #8FE0B4; --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 22px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
h1, h2, h3, p { margin: 0; }
h1, h2, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { display: inline-flex; line-height: 0; flex: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
:focus:not(:focus-visible) { outline: none; }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 400ms ease; }
#snow.on { opacity: 1; }
#app { position: relative; z-index: 1; }

/* Smooth change between looks. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 340ms; animation-timing-function: ease; }
html.look-fade, html.look-fade body, html.look-fade *, html.look-fade *::before, html.look-fade *::after {
  transition: background-color 340ms ease, color 340ms ease, border-color 340ms ease, box-shadow 340ms ease, fill 340ms ease !important;
}

/* ---------- shell ---------- */

.shell { min-height: 100dvh; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 24px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar-in { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: 16px; min-height: 40px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -0.015em; }
.brand .crown { line-height: 0; transform: translateY(-1px); }
.topnav { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px max(4px, env(safe-area-inset-right)) var(--safe-b) max(4px, env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.05);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: calc(var(--tab-h) - 8px); padding: 6px 2px; border-radius: 14px;
  color: var(--ink-2); text-decoration: none; font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
}
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -4px; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 3px 3px; background: var(--accent); }

.view { max-width: 720px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.view:focus { outline: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.page-head h1 { font-size: 30px; line-height: 1.1; }
.lede { color: var(--ink-2); margin: 6px 0 20px; max-width: 46ch; }
.section-title { font-family: var(--font-body); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin: 26px 0 10px; }
.backlink { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -8px 0 4px -6px; padding: 0 10px 0 4px; color: var(--ink-2); font-weight: 600; text-decoration: none; border-radius: 12px; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-ctl);
  border: 1.5px solid transparent; background: var(--surface-2); color: var(--ink);
  font-weight: 600; font-size: 16px; text-decoration: none; white-space: nowrap;
  transition: transform 120ms ease, filter 120ms ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-outline { background: transparent; border-color: var(--line); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); }
.icon-btn:active { background: var(--surface-2); }

.field { display: block; margin-bottom: 16px; }
.field > .label, .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.hint { display: block; font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.field-error { display: block; font-size: 14px; color: var(--danger); margin-top: 6px; font-weight: 600; }
.input, .textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.input::placeholder, .textarea::placeholder { color: var(--ink-2); opacity: 0.75; }
.input:focus-visible, .textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: transparent; border-radius: 12px; }
.money { position: relative; }
.money::before { content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); font-weight: 600; }
.money .input { padding-left: 28px; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); }
.stepper button { width: 48px; height: 48px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--ink); }
.stepper button[disabled] { opacity: 0.35; }
.stepper output { min-width: 44px; text-align: center; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--surface-2); }
.seg button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }

.switch { position: relative; flex: none; width: 54px; height: 44px; border: 0; background: transparent; padding: 0; }
.switch::before { content: ""; position: absolute; left: 2px; right: 2px; top: 8px; height: 28px; border-radius: 14px; background: var(--line); transition: background 160ms ease; }
.switch::after { content: ""; position: absolute; left: 5px; top: 11px; width: 22px; height: 22px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 160ms ease; }
.switch[aria-checked="true"]::before { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.switch[disabled] { opacity: 0.45; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 2px 10px; border-radius: 999px; font-size: 13.5px; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-muted { background: var(--surface-2); color: var(--ink-2); }

/* ---------- the image frame, the crown, the quantity ---------- */

.frame {
  position: relative; flex: none; width: 96px; height: 96px; padding: 5px;
  background: var(--frame); border: 1.5px solid var(--frame-line); border-radius: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.frame img, .frame .ph { display: block; width: 100%; height: 100%; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.frame .ph { display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.crown-slot { position: absolute; left: 50%; top: 0; transform: translate(-50%, -66%); line-height: 0; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.22)); }
.crown { display: inline-block; line-height: 0; }
.crown-drop { animation: crown-drop 440ms cubic-bezier(0.3, 1.3, 0.5, 1) both; transform-origin: 50% 100%; }
@keyframes crown-drop {
  0% { transform: translateY(-26px) rotate(-16deg); opacity: 0; }
  55% { transform: translateY(2px) rotate(4deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.qty {
  position: absolute; right: -7px; bottom: -7px; min-width: 32px; height: 25px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 13px; border: 2px solid var(--surface);
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ---------- lists of items ---------- */

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; position: relative; }
.item-card {
  position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 24px 6px 16px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow);
}
.item-body { min-width: 0; padding-top: 1px; }
.item-name { font-size: 17px; font-weight: 700; line-height: 1.25; }
.item-price { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin-top: 3px; }
.item-desc { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item-link { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; margin: 0 0 -12px -2px; padding: 0 6px 0 2px; font-weight: 600; font-size: 14.5px; text-decoration: none; border-radius: 10px; max-width: 100%; }
.item-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; flex-direction: column; align-items: center; margin-top: -6px; }
.drag-handle { touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.item-card.dragging { position: fixed; z-index: 40; margin: 0; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28); transform: scale(1.02) rotate(-0.6deg); transition: transform 140ms ease, box-shadow 140ms ease; cursor: grabbing; }
.item-card.dragging .drag-handle { cursor: grabbing; color: var(--primary); }
.item-card.settling { transition: top 160ms ease, transform 160ms ease; transform: none; }
.drag-ph { border: 2px dashed var(--line); border-radius: var(--r-card); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
body.is-dragging { -webkit-user-select: none; user-select: none; overscroll-behavior: contain; }

.giver-card { grid-template-columns: 96px minmax(0, 1fr); padding-right: 14px; }
.giver-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.giver-state { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 26px; }
.others { font-size: 14px; color: var(--ink-2); }
.giver-card.taken { background: var(--surface-2); box-shadow: none; }
.giver-card.taken .frame img { filter: grayscale(1); opacity: 0.6; }
.giver-card.taken .item-name, .giver-card.taken .item-price { color: var(--ink-2); }
.giver-card.mine { border-color: color-mix(in srgb, var(--ribbon) 55%, var(--line)); }
.giver-card.mine .item-name { padding-right: 46px; }

/* The signature: a ribbon and bow tie the card you tick. */
.sash-clip { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.sash { position: absolute; top: 25px; right: -34px; width: 132px; height: 13px; background: var(--ribbon); transform: rotate(45deg); box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.28), inset 0 -1.5px 0 var(--ribbon-edge); }
.bow { position: absolute; top: 12px; right: 12px; line-height: 0; pointer-events: none; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.25)); }
.wrap-in .sash { animation: sash-in 300ms cubic-bezier(0.4, 0, 0.2, 1) both; }
.wrap-in .bow { animation: bow-pop 280ms 230ms cubic-bezier(0.3, 1.7, 0.5, 1) both; }
@keyframes sash-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes bow-pop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- empty, skeleton ---------- */

.empty { text-align: center; padding: 34px 22px; }
.empty .crown { margin-bottom: 10px; }
.empty h2 { font-size: 22px; margin-bottom: 6px; }
.empty p { color: var(--ink-2); margin: 0 auto 18px; max-width: 34ch; }

.skel { border-radius: 14px; background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 50%, var(--surface-2) 70%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
.skel-card { height: 136px; border-radius: var(--r-card); margin-bottom: 14px; }
.skel-line { height: 18px; margin-bottom: 10px; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }

/* ---------- family ---------- */

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.person-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; min-height: 132px; text-decoration: none; color: var(--ink); }
.person-card:active { transform: scale(0.985); }
.avatar { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); font-family: var(--font-display); font-weight: 600; font-size: 22px; flex: none; }
.person-name { font-weight: 700; font-size: 17px; line-height: 1.2; }
.person-meta { color: var(--ink-2); font-size: 14.5px; display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: auto; }

/* ---------- purchases ---------- */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat { padding: 14px 16px; }
.stat-k { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.stat-v { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-v.small { font-size: 22px; }

.purchases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.purchase { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 8px 12px 12px; }
.purchase .frame { width: 64px; height: 64px; padding: 4px; border-radius: 13px; }
.purchase .frame img, .purchase .frame .ph { border-radius: 8px; }
.purchase-for { font-size: 13.5px; font-weight: 700; color: var(--accent); }
.purchase-name { font-weight: 700; line-height: 1.25; }
.purchase-name a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
.paid { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.paid .money { width: 104px; }
.paid .input { min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
.bought-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 60px; min-height: 60px; border: 0; background: transparent; border-radius: 14px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.bought-box { width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--ink-2); display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: background 160ms ease, border-color 160ms ease; }
.bought-btn[aria-checked="true"] .bought-box { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.purchase.bought { background: var(--surface-2); box-shadow: none; }
.purchase.bought .frame img { filter: grayscale(1); opacity: 0.6; }
.purchase.bought .purchase-name, .purchase.bought .purchase-for { color: var(--ink-2); }
.purchase.bought .purchase-name { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-2) 60%, transparent); }

/* ---------- history ---------- */

.season { margin-bottom: 18px; overflow: hidden; }
.season-head { padding: 18px 18px 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.season-head h2 { font-size: 24px; }
.season-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 10px; }
.season-stats > div { background: var(--surface); padding: 12px 18px; }
.note { margin: 12px 18px 0; padding: 10px 12px; border-radius: 12px; background: var(--primary-soft); color: var(--ink); font-size: 14.5px; display: flex; gap: 8px; align-items: flex-start; }
.note .icon { color: var(--primary); margin-top: 1px; }
.entries { list-style: none; margin: 0; padding: 6px 18px 12px; }
.entries li { padding: 11px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
.entries li:last-child { border-bottom: 0; }
.entry-who { font-size: 14px; color: var(--ink-2); grid-column: 1 / -1; }
.entry-who b { color: var(--ink); font-weight: 700; }
.entry-item { font-weight: 600; }
.entry-price { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- settings ---------- */

.hero-figure { padding: 22px 20px; margin-bottom: 14px; position: relative; overflow: hidden; }
.hero-figure .k { font-weight: 600; color: var(--ink-2); }
.hero-figure .v { font-family: var(--font-display); font-weight: 600; font-size: clamp(44px, 14vw, 64px); line-height: 1; margin: 6px 0 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero-figure .v small { font-family: var(--font-body); font-size: 17px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; margin-left: 4px; }
.hero-figure .sub { color: var(--ink-2); font-size: 14.5px; }
.hero-figure .so-far { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hero-figure .so-far b { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.rows > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; min-height: 60px; }
.row-stack { display: block; padding: 16px 18px; }
.row-stack .label { margin-bottom: 10px; }
.row-text b { display: block; font-weight: 600; }
.row-text span { display: block; font-size: 14px; color: var(--ink-2); }
.members { color: var(--ink-2); font-size: 14.5px; margin-top: 2px; }
.prose { color: var(--ink-2); font-size: 15px; }
.prose p + p { margin-top: 8px; }

/* ---------- sheets ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade-in 200ms ease both; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - var(--safe-t) - 28px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  animation: sheet-up 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.sheet::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 22px 10px 6px 20px; flex: none; }
.sheet-head h2 { font-size: 23px; line-height: 1.15; }
.sheet-body { padding: 8px 20px calc(20px + var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.root-closing .sheet { animation: sheet-down 180ms ease both; }
.root-closing .sheet-scrim { animation: fade-out 180ms ease both; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-down { to { transform: translateY(40px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
body.sheet-open { overflow: hidden; }

.menu { list-style: none; margin: 0; padding: 0; }
.menu button { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 0 8px; border: 0; background: transparent; font-weight: 600; font-size: 16.5px; text-align: left; border-radius: 12px; }
.menu button:active { background: var(--surface-2); }
.menu button[disabled] { opacity: 0.4; }
.menu .danger { color: var(--danger); }
.menu li + li { border-top: 1px solid var(--line); }

.disclaimer { padding: 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); font-size: 15px; display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; }
.disclaimer .icon { color: var(--accent); margin-top: 1px; }
.sheet-item { display: flex; gap: 14px; align-items: center; padding-top: 16px; }
.sheet-item .frame { width: 76px; height: 76px; }
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 4px; }

.picture-row { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.picture-row .frame { width: 104px; height: 104px; }
.picture-tools { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-width: 0; }
.finding { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--primary); margin-top: 8px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary); animation: spin 800ms linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }

/* ---------- toasts ---------- */

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { max-width: 440px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); animation: toast-in 220ms ease both; pointer-events: auto; }
.toast.out { animation: fade-out 200ms ease both; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- sign in ---------- */

.welcome { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 28px) 18px calc(var(--safe-b) + 28px); }
.welcome-in { width: 100%; max-width: 440px; }
.welcome-mark { text-align: center; margin-bottom: 22px; }
.welcome-mark h1 { font-size: 46px; line-height: 1; margin-top: 2px; letter-spacing: -0.02em; }
.welcome-mark p { color: var(--ink-2); margin-top: 10px; font-size: 17px; }
.choices { display: grid; gap: 10px; margin-bottom: 18px; }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px; text-align: left; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); }
.choice .icon { width: 40px; height: 40px; border-radius: 12px; align-items: center; justify-content: center; background: var(--surface-2); color: var(--ink-2); }
.choice b { display: block; font-weight: 700; }
.choice span.s { display: block; font-size: 14px; color: var(--ink-2); }
.choice[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1.5px var(--primary); }
.choice[aria-checked="true"] .icon { background: var(--primary); color: var(--primary-ink); }
.lock-note { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; color: var(--ink-2); margin: -4px 0 18px; }
.lock-note .icon { color: var(--accent); margin-top: 1px; }
.demo-note { margin-top: 18px; text-align: center; font-size: 14px; color: var(--ink-2); }

/* ---------- desktop ---------- */

@media (min-width: 900px) {
  .shell { padding-bottom: 48px; }
  .tabbar { display: none; }
  .topbar { padding-top: 12px; padding-bottom: 12px; }
  .topnav { display: flex; gap: 4px; margin-left: 20px; }
  .topnav a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px; }
  .topnav a:hover { background: var(--surface-2); color: var(--ink); }
  .topnav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  .view { max-width: 780px; padding-top: 34px; }
  .view.wide { max-width: 1040px; }
  .page-head h1 { font-size: 38px; }
  .frame { width: 116px; height: 116px; }
  .item-card { grid-template-columns: 116px minmax(0, 1fr) auto; gap: 18px; padding: 28px 10px 20px 20px; }
  .giver-card { grid-template-columns: 116px minmax(0, 1fr); padding-right: 20px; }
  .people { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 260px)); }
  .season-stats { grid-template-columns: repeat(4, 1fr); }
  .sheet-root { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; max-height: calc(100dvh - 48px); animation-name: dialog-in; }
  .sheet::before { display: none; }
  .sheet-actions { flex-direction: row-reverse; }
  .sheet-actions .btn { flex: 1; }
  #toasts { bottom: 28px; }
  .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; align-items: start; }
  .purchase .frame, .sheet-item .frame { width: 64px; height: 64px; }
  .picture-row .frame { width: 104px; height: 104px; }
  @keyframes dialog-in { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
}

@media (max-width: 359px) {
  .item-card { grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; }
  .item-card .frame { width: 84px; height: 84px; }
  .tab { font-size: 10.5px; }
}

/* ---------- calm mode ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  #snow { display: none; }
  .skel { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ---------- the logo: Harry, crowned ---------- */

.logo { position: relative; display: inline-block; width: var(--s); height: var(--s); flex: none; }
.logo img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px #E9B93C, 0 0 0 3px #8A5A07; background: var(--surface-2); }
.logo .crown { position: absolute; left: 50%; top: 0; transform: translate(-50%, -68%); filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.3)); }
.brand { gap: 11px; margin-top: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 20px; }
.brand-sub { font-size: 13px; font-weight: 600; color: var(--primary); }
.welcome-mark .logo { margin-top: 62px; }
.welcome-mark .logo img { box-shadow: 0 0 0 5px #E9B93C, 0 0 0 7px #8A5A07, 0 14px 30px rgba(0, 0, 0, 0.22); }
.welcome-mark h1 { margin-top: 18px; font-size: 42px; }
@media (min-width: 900px) {
  .brand-name { font-size: 22px; }
  .topnav { margin-left: auto; }
  .section-title.sg-first { margin-top: 0; }
  .settings-grid .hero-figure { margin-bottom: 0; }
}

/* ---------- small fixes after testing ---------- */

.paid > span { white-space: nowrap; }
.paid .money { flex: 0 1 104px; min-width: 76px; width: auto; }
.giver-card.taken .chip-muted { background: var(--surface); }
.seg button[aria-checked="true"] { background: var(--primary); color: var(--primary-ink); box-shadow: none; }
.tab[aria-current="page"]::before { top: -5px; }
