/* Layout concept: a stack of gift tags on a spruce-and-snow page. Open wishes
   are plain tags; a claimed wish gets wrapped in striped paper and ribbon. */
:root {
  --bg: #e9efeb;
  --surface: #fbfdfb;
  --ink: #12312d;
  --muted: #4f6863;
  --line: #c6d4cd;
  --spruce: #12413b;
  --on-spruce: #eef6f1;
  --on-spruce-muted: #a9c6bc;
  --berry: #b81f47;
  --on-berry: #ffffff;
  --gold: #7f5500;
  --edge: #748a83;
  --wrap-a: #f6e6ea;
  --wrap-b: #fbf1f3;
  --warn-bg: #fdf1d5;
  --warn-ink: #6b4a00;
  --shadow: rgba(18, 49, 45, 0.14);

  --font-display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-hand: "Caveat", "Segoe Print", cursive;

  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1a18;
    --surface: #162a27;
    --ink: #e6f0ec;
    --muted: #9fb7b0;
    --line: #2d4640;
    --spruce: #0f332e;
    --on-spruce: #eef6f1;
    --on-spruce-muted: #9dbdb2;
    --berry: #ee5f83;
    --on-berry: #2b0610;
    --gold: #e6b84d;
    --edge: #6d8880;
    --wrap-a: #33202a;
    --wrap-b: #291c24;
    --warn-bg: #3a2e12;
    --warn-ink: #f4d58a;
    --shadow: rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1a18;
  --surface: #162a27;
  --ink: #e6f0ec;
  --muted: #9fb7b0;
  --line: #2d4640;
  --spruce: #0f332e;
  --on-spruce: #eef6f1;
  --on-spruce-muted: #9dbdb2;
  --berry: #ee5f83;
  --on-berry: #2b0610;
  --gold: #e6b84d;
  --edge: #6d8880;
  --wrap-a: #33202a;
  --wrap-b: #291c24;
  --warn-bg: #3a2e12;
  --warn-ink: #f4d58a;
  --shadow: rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--spruce);
}
h1, h2, h3, p { margin: 0; }
h2:focus { outline: none; }
:root[data-text="large"] body { zoom: 1.2; }
:root[data-text="large"] dialog.sheet { max-height: calc(92dvh / 1.2); }
:root[data-text="large"] .auth { min-height: calc(100dvh / 1.2); }
h1, h2 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }

.wrap {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

/* Test-mode bar, only in the artifact build */
.demo-bar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 8;
  background: var(--ink);
  color: var(--bg);
  padding-block: 8px;
  font-size: 14px;
}
.demo-bar .wrap { display: grid; gap: 6px; }
.demo-label { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.demo-label b { font-weight: 700; }
.demo-reset {
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
  color: inherit;
  font-size: 14px;
  white-space: nowrap;
}
.demo-people { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.demo-chip {
  flex: none;
  min-height: 34px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: none;
  color: inherit;
  font-size: 14px;
  cursor: pointer;
}
.demo-chip[aria-pressed="true"] { background: var(--bg); color: var(--ink); border-color: var(--bg); font-weight: 700; }

/* Header */
.top { background: var(--spruce); color: var(--on-spruce); padding-block: 14px 16px; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { flex: none; width: 34px; height: 34px; }
.brand-name { font: 700 22px/1.1 var(--font-display); }
.brand-by { font-size: 15px; font-weight: 400; color: var(--on-spruce-muted); white-space: nowrap; }
.brand-family { font-size: 15px; color: var(--on-spruce-muted); overflow-wrap: anywhere; }
.head-actions { display: flex; flex: none; gap: 4px; }
.head-btn {
  min-width: 56px;
  min-height: 48px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: inherit;
  font-size: 14px;
  cursor: pointer;
}
.head-btn svg { width: 22px; height: 22px; }
.top .wrap.family-bar { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--on-spruce-muted); font-size: 16px; }
.family-bar span { min-width: 0; overflow-wrap: anywhere; }
.family-switch { flex: none; background: var(--on-spruce); border-color: var(--on-spruce); color: var(--spruce); }
.family-list { display: grid; gap: 8px; }
.family-choice { display: grid; justify-items: start; gap: 2px; width: 100%; padding-block: 10px; text-align: left; }
.family-choice small { font-size: 15px; font-weight: 400; }
.center { text-align: center; justify-self: center; }

/* Bottom tabs */
.tabs {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tabs-row { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 660px; margin: 0 auto; }
.tab {
  position: relative;
  height: var(--tabs-h);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--berry); font-weight: 700; }
.tab-count {
  position: absolute;
  top: 6px;
  left: calc(50% + 8px);
  min-width: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--berry);
  color: var(--on-berry);
  font-size: 13px;
  line-height: 20px;
  font-weight: 700;
  text-align: center;
}

/* Page */
main { padding-block: 20px calc(var(--tabs-h) + 32px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 18px; }
main.no-tabs { padding-bottom: 40px; }
.page-head { display: grid; gap: 6px; }
.page-head h1 { font-size: 30px; }
.lede { color: var(--muted); max-width: 60ch; }
.to-line { font: 700 40px/1 var(--font-hand); color: var(--berry); }
.to-line small { font: inherit; font-size: 26px; color: var(--muted); margin-right: 6px; }
.back {
  justify-self: start;
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.back svg { width: 18px; height: 18px; }
.section { display: grid; gap: 12px; }
.section-head { display: grid; gap: 2px; }
.section-head h2 { font-size: 20px; }
.section-head p { color: var(--muted); font-size: 16px; }

/* Gift tags */
.tag {
  position: relative;
  background: var(--surface);
  padding: 16px 16px 14px 34px;
  display: grid;
  gap: 8px;
  clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}
.tag::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 1px 2px var(--shadow);
}
.tag.wrapped {
  background: repeating-linear-gradient(135deg, var(--wrap-a) 0 12px, var(--wrap-b) 12px 24px);
  padding-right: 50px;
}
.tag.wrapped::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 18px;
  width: 12px;
  background: var(--berry);
}
.tag-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.thumb { display: block; width: 64px; height: 64px; object-fit: contain; border-radius: 8px; background: #fff; }
.tag-title { font: 700 18px/1.3 var(--font-body); overflow-wrap: anywhere; }
.tag-star { color: var(--gold); font-size: 16px; font-weight: 700; }
.tag-meta { display: flex; flex-wrap: wrap; gap: 0 14px; color: var(--muted); font-size: 16px; align-items: center; }
.tag-meta a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-weight: 700; }
.tag-notes { font-size: 16px; overflow-wrap: anywhere; }
.tag-status { font-weight: 700; font-size: 17px; color: var(--berry); }
.tag-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.kind { font-size: 15px; color: var(--muted); font-weight: 700; }
.givers { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 16px; }
.givers b { color: var(--berry); margin-right: 4px; }
.person-tag {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.person-tag .to-line { font-size: 32px; }
.person-tag .to-line small { font-size: 22px; }
.person-count { color: var(--muted); font-size: 16px; grid-column: 1; }
.person-tag svg { grid-column: 2; grid-row: 1 / span 2; width: 20px; height: 20px; color: var(--muted); }

/* Buttons and fields */
.btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
}
.btn.primary { background: var(--berry); border-color: var(--berry); color: var(--on-berry); }
.btn.spruce { background: var(--spruce); border-color: var(--spruce); color: var(--on-spruce); }
.btn.quiet { background: none; border-color: transparent; color: var(--muted); padding-inline: 8px; font-weight: 400; text-decoration: underline; }
.btn.danger { color: var(--berry); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }
.field { display: grid; gap: 4px; }
.field > span { font-weight: 700; font-size: 16px; }
.field small { color: var(--muted); font-size: 15px; }
.field input, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--bg);
  font-size: 17px;
}
.field textarea { min-height: 84px; resize: vertical; }
.check { display: flex; gap: 12px; align-items: center; min-height: 48px; cursor: pointer; }
.check input { width: 28px; height: 28px; accent-color: var(--berry); flex: none; }
.check small { display: block; color: var(--muted); font-size: 15px; }
.parent-choice { border: 0; padding: 0; margin: 0; display: grid; }
.parent-choice legend { font-weight: 700; font-size: 16px; padding: 0; }
.kind-choice { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; }
.kind-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 12px;
  border: 2px solid var(--edge);
  border-radius: 10px;
  cursor: pointer;
}
.kind-option input { grid-row: 1 / span 2; margin-top: 4px; width: 20px; height: 20px; accent-color: var(--berry); }
.kind-option b { font-size: 16px; }
.kind-option span { color: var(--muted); font-size: 16px; }
.kind-option:has(input:checked) { border-color: var(--berry); }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--spruce); color: var(--on-spruce); font-size: 16px; }
.notice-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--spruce);
  color: var(--on-spruce);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}
.warn { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 16px; }
.form-error { flex-basis: 100%; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 700; }
.help-item { background: var(--surface); border-radius: 10px; }
.help-item summary { display: flex; align-items: center; min-height: 52px; padding: 12px 14px; font-weight: 700; cursor: pointer; }
.help-item summary::after { content: "+"; margin-left: auto; padding-left: 12px; font-size: 22px; line-height: 1; color: var(--muted); }
.help-item[open] summary::after { content: "\2212"; }
.help-answer { display: grid; gap: 10px; padding: 0 14px 14px; }
.help-answer .panel { padding: 0; }
.help-answer .panel h2 { display: none; }
.auth-card .help-item { background: var(--bg); }
.steps-title { font-size: 16px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.empty { padding: 20px 4px; color: var(--muted); display: grid; gap: 12px; justify-items: start; }
.progress { display: grid; gap: 6px; }
.progress-track { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--berry); }
.panel { background: var(--surface); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.panel h2 { font-size: 20px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.copy-box { padding: 10px 12px; border-radius: 10px; background: var(--bg); overflow-wrap: anywhere; font-size: 16px; user-select: all; }
.people { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.people li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-height: 44px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.badge { display: block; color: var(--muted); font-size: 15px; }

/* Sheets */
dialog.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 20px var(--gutter-r) calc(20px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
}
dialog.sheet::backdrop { background: rgba(5, 20, 17, 0.55); }
@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 16px; padding: 24px; }
}
.sheet-form { display: grid; gap: 14px; }
.sheet-form h2 { font-size: 24px; }
.sheet-actions {
  position: sticky;
  bottom: calc(-20px - env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
}

/* Sign-in pages */
.auth { min-height: 100dvh; display: grid; align-content: start; background: var(--spruce); color: var(--on-spruce); }
.auth .top { padding-block: 28px 8px; }
.auth-card { background: var(--surface); color: var(--ink); border-radius: 14px; padding: 20px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 28px; }
.auth main { padding-top: 12px; }
.auth-sub { color: var(--muted); }
.name-list { display: flex; flex-wrap: wrap; gap: 8px; }

.toast {
  position: fixed;
  z-index: 30;
  left: var(--gutter-l);
  right: var(--gutter-r);
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom, 0px));
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 6px 20px var(--shadow);
}
.alert {
  position: fixed;
  z-index: 40;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: var(--gutter-l);
  right: var(--gutter-r);
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-weight: 700;
  box-shadow: 0 6px 20px var(--shadow);
}
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }
.boot .btn { margin-top: 12px; }
