:root {
  --bg: #f7f2e9;
  --surface: #ffffff;
  --surface-2: #fbf8f2;
  --ink: #1e2a24;
  --muted: #66736b;
  --line: #e4dccd;
  --green: #1d6b47;
  --green-ink: #ffffff;
  --green-soft: #e3f1e8;
  --red: #b3352b;
  --red-soft: #fbe9e6;
  --gold: #b9892f;
  --gold-soft: #fbefcf;
  --gold-ink: #8a6210;
  --sky: #cfe1ea;
  --shadow: 0 1px 2px rgba(30, 42, 36, .06), 0 8px 24px rgba(30, 42, 36, .06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a16;
    --surface: #1b2620;
    --surface-2: #212e27;
    --ink: #eef2ee;
    --muted: #9caba2;
    --line: #2f3e35;
    --green: #4fb783;
    --green-ink: #0d1711;
    --green-soft: #213a2d;
    --red: #ef8a80;
    --red-soft: #3a2320;
    --gold: #d9b064;
    --gold-soft: #3b3117;
    --gold-ink: #e4bf74;
    --sky: #16334a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Make sure the hidden attribute always wins over display rules below. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

a { color: var(--green); }

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

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: var(--red-soft); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.wide { width: 100%; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent); outline-offset: 2px; }

.field { display: block; min-width: 0; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.field input::placeholder { color: var(--muted); opacity: .75; }
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
}
.hint { margin: 0; font-size: 14px; color: var(--muted); }

/* ----------------------------------------------------------------- auth -- */

/* A winter night: starry sky, fairy lights along the top, snowy hills below. */
.auth {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 60px 16px 150px;
  background:
    radial-gradient(2px 2px at 8% 22%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 17% 58%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 27% 14%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 36% 41%, #cfe6ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 9%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 27%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 62%, #cfe6ff 50%, transparent 51%),
    radial-gradient(2px 2px at 74% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 83% 44%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 20%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 95% 66%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 4% 72%, #cfe6ff 50%, transparent 51%),
    linear-gradient(180deg, #0a1b2c 0%, #12334a 55%, #1d4d60 100%);
}
.auth::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 36px;
  background: url(img/lights.svg) repeat-x center top;
  pointer-events: none;
}
.auth .scene { position: absolute; left: 0; right: 0; bottom: 0; }
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
  padding: 24px 28px 28px;
}
.brand { text-align: center; margin-bottom: 24px; }
.brand-mark { display: block; width: 96px; height: auto; margin: 0 auto 6px; }

/* Snowy hills and fir trees along the bottom of the page. */
.scene {
  height: 170px;
  background: url(img/scene.svg) repeat-x center bottom / auto 170px;
  pointer-events: none;
}
.brand h1 { font-size: 28px; }
.brand p { margin: 10px 0 0; color: var(--muted); font-size: 15px; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
}
.seg-btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.seg-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

#auth-form { display: grid; gap: 16px; }

/* ------------------------------------------------------------------ app -- */

#app { min-height: 100vh; display: flex; flex-direction: column; }
#app .scene {
  flex: none;
  margin-top: 8px;
  background:
    url(img/scene.svg) repeat-x center bottom / auto 170px,
    linear-gradient(180deg, transparent 15%, var(--sky));
}

.top {
  position: relative;
  z-index: 2;
  background: var(--green);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
/* Fairy lights strung along the underside of the header. */
.top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 36px;
  background: url(img/lights.svg) repeat-x center top;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .top { background: #173d2a; }
}
.top-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo { display: flex; align-items: center; gap: 8px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 600; margin-right: auto; white-space: nowrap; }
.logo img { display: block; flex: none; }
.who { font-size: 14px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .45); flex: none; }
.top .btn.ghost:hover { background: rgba(255, 255, 255, .12); border-color: #fff; }

.layout {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  flex: 1 0 auto;
  padding: 52px 16px 40px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

/* People */
.people { display: grid; gap: 6px; position: sticky; top: 16px; }
.person {
  font: inherit;
  text-align: left;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}
.person:hover { background: var(--surface); border-color: var(--line); }
.person.is-active { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.avatar {
  grid-row: span 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--green-soft);
  color: var(--green);
}
.person.is-me .avatar { background: var(--red-soft); color: var(--red); }
.person-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Panel */
.panel { min-width: 0; }
.list-head { margin-bottom: 16px; }
.list-head h2 { font-size: 28px; }
.list-head p { margin: 6px 0 0; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 20px;
  display: grid;
  gap: 14px;
  justify-items: start;
}
.card h3 { font-size: 18px; }
.card .error { justify-self: stretch; }

/* Organiser's settings page */
.person.is-settings .avatar { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* Children's lists sit indented under the parent who looks after them. */
.person.is-child { margin-left: 22px; }
.person.is-child .avatar { background: var(--gold-soft); color: var(--gold-ink); }
.person.is-add { margin-top: 10px; }
.person.is-add .avatar { background: transparent; color: var(--muted); border: 1.5px dashed var(--muted); font-size: 20px; font-weight: 400; }
.person.is-add .person-name { color: var(--green); }
.list-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.code-field { width: 100%; max-width: 320px; }
.section-title { font-size: 18px; margin: 4px 0 12px; }
.item.member { align-items: center; }
.item.member .avatar { flex: none; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.span-2 { grid-column: span 2; }

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.item-note { color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.item-link {
  display: inline-block;
  max-width: 100%;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.item-link:hover { text-decoration: underline; }
.item-actions { display: flex; gap: 6px; flex: none; }

/* Buying for someone else */
.check { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin: -3px 0 0 -4px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--green); cursor: pointer; }
.check input:disabled { cursor: not-allowed; }
.item.is-bought { background: var(--surface-2); }
.item.is-bought .item-title { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.item-status { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--green); }
.item-status.other { color: var(--muted); }
.item-status.warn { color: var(--red); }

/* Editing */
.item.is-editing { display: block; border-color: var(--green); }
.edit-form { display: grid; gap: 12px; }
.edit-actions { display: flex; gap: 8px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px 32px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty::before {
  content: "";
  display: block;
  height: 84px;
  margin-bottom: 10px;
  background: url(img/tree.svg) center / contain no-repeat;
}

@media (prefers-color-scheme: dark) {
  /* Snow by night: take the glare off the white hills. */
  #app .scene { filter: brightness(.82); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
  z-index: 10;
}

/* --------------------------------------------------------------- phones -- */

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 42px; padding-bottom: 32px; }
  .scene, #app .scene { height: 120px; background-size: auto 120px, 100% 100%; }
  .auth { padding-bottom: 110px; }
  .people {
    position: static;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -16px;
    padding: 2px 16px 8px;
    scrollbar-width: none;
  }
  .people::-webkit-scrollbar { display: none; }
  .person { flex: none; max-width: 200px; background: var(--surface); border-color: var(--line); }
  .person.is-active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
  .person.is-child, .person.is-add { margin: 0; }
  .item.member .item-body { flex: 1 1 60%; }
  .list-head h2 { font-size: 24px; }
  .add-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .who { display: none; }
  .item { flex-wrap: wrap; }
  .item-actions { width: 100%; }
}

/* ------------------------------------------------ sponsored family extras -- */
/* Everything above is shared with the family gift list. These few rules are
   for the things only this page has. */

.field textarea {
  display: block;
  width: 100%;
  min-height: 104px;
  resize: vertical;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.field textarea::placeholder { color: var(--muted); opacity: .75; }
.field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }

/* Sizes and interests: the part people shop from, so not greyed out. */
.list-head .details { color: var(--ink); font-size: 17px; white-space: pre-line; overflow-wrap: anywhere; }

#items { margin-bottom: 16px; }
#extras { margin-bottom: 12px; }
.section-title.spaced { margin-top: 32px; }
.section-hint { margin: -6px 0 14px; }

/* An extra is already bought, so it gets a tick mark instead of a tick box. */
.extra-mark {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--green-soft);
  color: var(--green);
}

/* The drop-off deadline, across the top of the list. */
.banner {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold-soft);
  color: var(--gold-ink);
  font-weight: 700;
  font-size: 17px;
  text-align: center;
}

/* The longer title must not push Sign out off a phone screen. */
.logo { min-width: 0; }
.logo span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .logo { font-size: 17px; }
}
