/* Layout: one centered column, 600px max, phone first. The family name in a soft serif is the only loud thing. One pine accent, spent on the claim pill. */
:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --fg: #1B241F;
  --muted: #68736D;
  --line: #E2E6E1;
  --line-strong: #C9D0CB;
  --field: #F0F2EE;
  --accent: #1E6B52;
  --accent-strong: #175743;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3EFE8;
  --shadow: rgba(20, 30, 25, 0.08);
  --font-display: 'Young Serif', Georgia, 'Times New Roman', serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614;
    --surface: #1A201C;
    --fg: #ECEFEA;
    --muted: #9AA59E;
    --line: #2A322D;
    --line-strong: #3C463F;
    --field: #1F2622;
    --accent: #7BD3B0;
    --accent-strong: #94DFC1;
    --accent-ink: #0E2A20;
    --accent-soft: #1C3A2E;
    --shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614;
  --surface: #1A201C;
  --fg: #ECEFEA;
  --muted: #9AA59E;
  --line: #2A322D;
  --line-strong: #3C463F;
  --field: #1F2622;
  --accent: #7BD3B0;
  --accent-strong: #94DFC1;
  --accent-ink: #0E2A20;
  --accent-soft: #1C3A2E;
  --shadow: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--bg);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
input { font: inherit; color: inherit; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg { display: inline-block; vertical-align: middle; }

.page {
  max-width: 600px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 96px;
}

/* Header */
.url-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.url { color: var(--muted); font-size: 0.9375rem; overflow-wrap: anywhere; }
.copy {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  font-weight: 700; font-size: 0.9375rem;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.copy svg { width: 16px; height: 16px; }
.copy.done { border-color: var(--accent); color: var(--accent); }
.family {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(2.375rem, 10vw, 3.25rem); line-height: 1.02;
  margin: 6px 0 0; letter-spacing: -0.01em; text-wrap: balance;
}

/* Role switcher (prototype stand-in for who opened the link) */
.you {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bg);
  margin-top: 24px; padding-block: 10px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
}
.you-label { color: var(--muted); font-size: 0.9375rem; }
.seg { display: inline-flex; background: var(--field); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  font-weight: 700; font-size: 0.9375rem; color: var(--muted); white-space: nowrap;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px var(--shadow); }
.you-blurb { color: var(--muted); font-size: 0.9375rem; margin: 12px 0 0; }

/* People */
.person { margin-top: 36px; }
.person-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-size: 1.25rem; line-height: 1;
  display: grid; place-items: center;
}
.person-meta { flex: 1 1 auto; min-width: 0; }
.person-name { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; line-height: 1.15; margin: 0; }
.occasion { margin: 2px 0 0; color: var(--muted); font-size: 0.9375rem; }
.occasion .soon { color: var(--accent); font-weight: 700; white-space: nowrap; }
.count { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; white-space: nowrap; align-self: flex-start; padding-top: 4px; }

/* Wishes */
.wishes { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.wish { border-bottom: 1px solid var(--line); padding-block: 14px; }
.wish-row { display: flex; align-items: center; gap: 14px; }
.wish-main { flex: 1 1 auto; min-width: 0; }
.title { overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 0.9375rem; margin-top: 2px; }
.meta .price { color: var(--fg); font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 0.9375rem; font-style: italic; margin: 4px 0 0; }
.wish-side { flex: none; max-width: 46%; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.wish-side:empty { display: none; }
.claim-btn {
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; white-space: nowrap;
}
.claim-btn:hover { background: var(--accent-strong); }
.claimed { color: var(--muted); font-size: 0.9375rem; display: inline-flex; align-items: center; gap: 6px; }
.claimed svg, .mine svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.mine { color: var(--accent); font-weight: 700; font-size: 0.9375rem; display: inline-flex; align-items: center; gap: 6px; }
.undo { color: var(--muted); font-size: 0.9375rem; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; padding: 0 4px; }
.undo:hover { color: var(--fg); }
.just .mine svg path { stroke-dasharray: 20; stroke-dashoffset: 20; animation: draw 0.35s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.fresh { animation: fresh 1.4s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }

/* Claim form */
.claim-form { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.claim-form input {
  flex: 1 1 150px; min-width: 0; min-height: 44px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--surface); padding: 0 14px;
}
.claim-form input:focus { outline: none; border-color: var(--accent); }
.confirm { min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cancel, .ghost { min-height: 44px; padding: 0 12px; color: var(--muted); }
.cancel:hover, .ghost:hover { color: var(--fg); }
.help { flex: 1 0 100%; margin: 0; color: var(--muted); font-size: 0.875rem; }

/* Add a wish */
.add { margin-top: 12px; display: flex; gap: 8px; }
.add input {
  flex: 1 1 auto; min-width: 0; min-height: 48px; border-radius: 14px;
  border: 1.5px dashed var(--line-strong); background: transparent; padding: 0 14px;
}
.add input::placeholder, .claim-form input::placeholder, .field input::placeholder { color: var(--muted); opacity: 1; }
.add input:focus { outline: none; border-style: solid; border-color: var(--accent); }
.add button { min-height: 48px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line-strong); font-weight: 700; }
.add button:hover { border-color: var(--accent); color: var(--accent); }
.looking { display: flex; align-items: center; gap: 10px; color: var(--muted); min-height: 48px; margin-top: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 0.8s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 0.3; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
.draft {
  margin-top: 12px; padding: 14px 16px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
  display: grid; gap: 10px;
}
.draft-from { margin: 0; color: var(--muted); font-size: 0.875rem; }
.field { display: grid; gap: 2px; min-width: 0; }
.field span { color: var(--muted); font-size: 0.8125rem; }
.field input {
  min-width: 0; min-height: 40px; border: 0; border-bottom: 1.5px solid var(--line);
  background: transparent; padding: 0 2px; border-radius: 0;
}
.field input:focus { outline: none; border-bottom-color: var(--accent); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.draft-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.primary { min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.primary:hover { background: var(--accent-strong); }

.foot { margin-top: 56px; color: var(--muted); font-size: 0.875rem; }
.foot p { margin: 0; }

@media (min-width: 640px) {
  .page { padding-block: 44px 120px; }
  .person { margin-top: 44px; }
  .person-name { font-size: 1.625rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Additions for the real app ---- */
a { color: inherit; }
.title a { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.title a:hover { text-decoration-color: var(--accent); }
select { font: inherit; color: inherit; }

.you strong { font-weight: 700; }
.change { color: var(--muted); font-size: 0.9375rem; margin-left: auto; text-underline-offset: 3px; }
.family.small { font-size: clamp(1.75rem, 7vw, 2.25rem); }
.lede { font-size: 1.1875rem; margin: 20px 0 0; text-wrap: pretty; }
.notice {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--fg); font-size: 0.9375rem;
}
.empty { color: var(--muted); font-size: 0.9375rem; margin: 12px 0 0; }
.empty.first { margin-top: 32px; }

/* A wish is a two-column grid: details on the left, the claim control on the right. */
.wish { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; align-items: center; }
.wish:target { animation: fresh 1.6s ease-out; }
/* Keep a linked row or person clear of the sticky "You are" bar. */
.wish, .person { scroll-margin-top: 76px; }
.wish-side { max-width: none; }
.wish-side form { display: contents; }
.remove, .text-btn {
  color: var(--muted); font-size: 0.875rem; text-decoration: underline; text-underline-offset: 3px;
  min-height: 32px; padding: 0;
}
.remove:hover, .text-btn:hover { color: var(--fg); }
.invite { color: var(--muted); font-size: 0.875rem; margin: 10px 0 0; }

/* Claiming works without JavaScript: the button is the summary of a details element. */
.claim summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.claim summary::-webkit-details-marker { display: none; }
.claim .when-open { display: none; }
.claim[open] { grid-column: 1 / -1; margin-top: 4px; }
.claim[open] summary {
  background: none; color: var(--muted); font-weight: 400; min-height: 40px; padding: 0 4px;
  margin-left: auto; width: fit-content; display: flex;
}
.claim[open] .when-closed { display: none; }
.claim[open] .when-open { display: inline; }
.claim[open] .claim-form { margin-top: 4px; }

/* Forms that reuse the draft card */
.draft { margin-top: 24px; }
.add-person { margin-top: 48px; }
.draft-from { font-weight: 700; color: var(--fg); font-size: 0.9375rem; }
.field select {
  min-height: 40px; border: 0; border-bottom: 1.5px solid var(--line);
  background: transparent; padding: 0 2px; border-radius: 0; min-width: 0;
}
.field select:focus { outline: none; border-bottom-color: var(--accent); }
a.ghost { min-height: 44px; padding: 0 12px; color: var(--muted); display: inline-flex; align-items: center; text-decoration: none; }
a.ghost:hover { color: var(--fg); }
.ghost-link { color: var(--accent); font-weight: 700; text-underline-offset: 3px; }

/* Who are you */
.picker { margin-top: 20px; display: grid; gap: 10px; }
.pick {
  min-height: 56px; padding: 0 18px; border-radius: 16px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line-strong);
  font-family: var(--font-display); font-size: 1.25rem;
}
.pick:hover { border-color: var(--accent); }
.pick-giver { font-family: var(--font-body); font-size: 1.0625rem; font-weight: 700; color: var(--muted); border-style: dashed; }
.picker + .help { margin-top: 16px; color: var(--muted); font-size: 0.875rem; }

.notice.keep { margin-top: 32px; }
.notice .text-btn { color: var(--fg); font-size: inherit; min-height: 0; }
