:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2b2118;
  --muted: #7a6a5a;
  --line: #f0e2cc;
  --accent: #f59e0b;
  --accent-ink: #3b2300;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1610;
    --card: #261f17;
    --ink: #f6eee3;
    --muted: #b3a390;
    --line: #3a3026;
    --accent: #fbbf24;
    --accent-ink: #2a1a00;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Buttons and pictures set their own display; hidden still has to hide them. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
.pad { padding: 0 16px 48px; max-width: 900px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }

button, .button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: .5rem .9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 40px;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font-weight: 500; }

input, select {
  font: inherit;
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  margin-top: .25rem;
}
label { display: block; margin: .8rem 0; font-weight: 500; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
label.check input { width: auto; margin: 0; }
details summary { cursor: pointer; color: var(--muted); margin: .6rem 0; }

/* ---- Top bar and tabs ---- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: 900px; margin: 0 auto;
}
.brand { font-weight: 700; font-size: 1.2rem; display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.brand small { font-weight: 400; color: var(--muted); font-size: .9rem; }
.jar { font-size: 1.4rem; }
.jar.big { font-size: 4rem; display: block; }
.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 0 16px 8px; max-width: 900px; margin: 0 auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs button { border: 0; background: none; border-radius: 999px; white-space: nowrap; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .45rem; font-weight: 700; }

/* ---- Lists and cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 1rem 0; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  flex-wrap: wrap;
}
.item.slim { padding: 8px 12px; }
.item .title { font-weight: 600; }
.actions { display: flex; gap: 6px; align-items: center; }
.actions.wrap { flex-wrap: wrap; }
.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; display: block; }
.thumb.none { display: grid; place-items: center; background: var(--bg); font-size: 1.8rem; }
.pts { display: flex; align-items: center; gap: 2px; margin: 0; font-weight: 700; }
.pts input { width: 72px; margin: 0; }
.pill { background: #fde68a; color: #5b3a00; font-weight: 700; border-radius: 999px; padding: .2rem .65rem; min-width: 3.2rem; text-align: center; }
.pill.minus { background: #fecaca; color: #7f1d1d; }
.avatar { font-size: 1.5rem; }
.avatar.big { font-size: 2.4rem; width: 56px; text-align: center; }
.code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .1em; background: var(--bg); padding: .1rem .4rem; border-radius: 6px; }

.kids-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 1rem; }
.kid-chip { display: flex; align-items: center; gap: .4rem; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem .3rem .4rem; white-space: nowrap; }
.kid-chip .points { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.reward { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.reward.archived { opacity: .6; }
.reward img, .reward .noimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.reward .noimg { display: grid; place-items: center; font-size: 3rem; font-weight: 800; color: var(--accent); background: var(--bg); }
.reward .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.reward .actions { margin-top: auto; }
.reward .actions button { padding: .3rem .7rem; min-height: 34px; font-size: .9rem; }
.archived summary { margin-top: 1.5rem; }

.empty { text-align: center; padding: 2.5rem 1rem 1rem; }
.empty .icon { font-size: 3rem; }
.empty h2 { margin-top: .5rem; }

/* ---- Sign in ---- */
.auth { max-width: 420px; margin: 0 auto; padding: 32px 16px; }
.hero { text-align: center; }
.hero h1 { margin: .2rem 0; }
.auth .primary { width: 100%; justify-content: center; margin-top: .6rem; min-height: 46px; }

/* ---- Dialogs ---- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(30, 20, 10, .45); }
.dlg { padding: 20px; }
.dlg h2 { margin-top: 0; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 1.2rem; }
.pair-code { font: 800 2.6rem/1 ui-monospace, monospace; letter-spacing: .12em; text-align: center; padding: 1rem; background: var(--bg); border-radius: 12px; }
.photo-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.photo-pick .preview { width: 100%; max-height: 220px; object-fit: contain; border-radius: 12px; background: var(--bg); }
.photo-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.photo-buttons .button { white-space: nowrap; }
.avatars { border: 0; padding: 0; margin: .8rem 0; display: flex; flex-wrap: wrap; gap: 6px; }
.avatars legend { font-weight: 500; margin-bottom: .3rem; }
.avatars label { margin: 0; }
.avatars input, .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.avatars span { display: grid; place-items: center; width: 44px; height: 44px; font-size: 1.5rem; border-radius: 12px; border: 2px solid transparent; background: var(--bg); cursor: pointer; }
.avatars input:checked + span { border-color: var(--accent); }
.avatars input:focus-visible + span, .seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: flex; gap: 6px; }
.seg label { margin: 0; flex: 1; }
.seg span { display: block; text-align: center; padding: .5rem; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 10;
}
#toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 560px) {
  .item .actions { width: 100%; justify-content: flex-end; }
}

/* ---- Sign in: parent or kid ---- */
.seg.who { margin: 1rem 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg.who button { flex: 1; border: 0; justify-content: center; background: none; color: var(--muted); }
.seg.who button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.code-input { font: 700 1.8rem/1 ui-monospace, monospace; letter-spacing: .2em; text-align: center; text-transform: uppercase; margin: .6rem 0; }
.faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 1rem 0; }
.face { flex-direction: column; justify-content: center; padding: 14px 8px; min-height: 120px; border-radius: 16px; text-align: center; }
.face .avatar { font-size: 2.6rem; }
.face small { color: var(--muted); font-size: .75rem; }
.pin-card { text-align: center; }
.avatar.huge { font-size: 4rem; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 1rem 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--accent); border-color: var(--accent); }
.pin-dots span.extra:not(.on) { opacity: .35; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; }
.pin-pad button { justify-content: center; font-size: 1.6rem; font-weight: 700; min-height: 64px; border-radius: 16px; }

/* ---- Kid home ---- */
.kid { padding-bottom: 140px; }
.banner { background: #fde68a; color: #5b3a00; border-radius: 22px; padding: 18px; text-align: center; margin: .5rem 0 1rem; }
.big-points { font-size: 2.8rem; font-weight: 800; line-height: 1.1; }
.banner-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin-top: .5rem; font-weight: 600; font-size: .95rem; }
.nudge { margin-top: .6rem; font-size: .9rem; background: rgba(255,255,255,.55); border-radius: 999px; padding: .3rem .8rem; display: inline-block; }
.cost { font-weight: 800; color: var(--accent); }
.bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.reward .body > button.primary { justify-content: center; }
.reward.wish { border-style: dashed; }
.big-title { font-size: 1.1rem; }
.small-thumb { width: 48px; height: 48px; }
.status { font-weight: 700; white-space: nowrap; }
.status.approved { color: var(--good); }
.status.rejected { color: var(--bad); }
.status.pending { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; text-align: center; display: flex; flex-direction: column; }
.stat b { font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.fab { position: fixed; right: 16px; bottom: 92px; z-index: 5; box-shadow: 0 6px 20px rgba(0,0,0,.2); min-height: 52px; border-radius: 16px; padding: .6rem 1.1rem; }
.kid-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.kid-tabs button { flex: 1; max-width: 180px; flex-direction: column; gap: 0; border: 0; background: none; color: var(--muted); font-size: .8rem; justify-content: center; }
.kid-tabs button span { font-size: 1.4rem; border-radius: 999px; padding: 0 .9rem; }
.kid-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 700; }
.kid-tabs button[aria-selected="true"] span { background: #fde68a; }

/* ---- Photo picker: camera, file, paste, drop ---- */
.drop {
  width: 100%; min-height: 160px; border: 2px dashed var(--line); border-radius: 14px; background: var(--bg);
  display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden;
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
.drop.busy::after { content: '…'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; background: rgba(0,0,0,.25); color: #fff; }
.drop .preview { width: 100%; max-height: 240px; object-fit: contain; display: block; }
.drop-hint { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 1rem; }
.drop-hint .icon { font-size: 2rem; }
.drop-hint small { color: var(--muted); }
/* Pasting and dropping need a keyboard and mouse. */
@media (hover: none) { .paste-hint { display: none; } }

/* ---- Parent: ways to earn, settings, invite ---- */
.category { margin-top: 1.2rem; }
.category h3 { margin: .4rem 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two label { margin: .6rem 0; }
.units { border: 0; padding: 0; margin: .8rem 0; display: flex; flex-wrap: wrap; gap: 6px; }
.units legend { font-weight: 500; margin-bottom: .3rem; }
.units label { margin: 0; }
.units input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.units span { display: block; padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.units input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.units input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { margin: 0; font-size: .85rem; }
.copy-row button { flex-shrink: 0; }

/* Two rewards side by side on a phone. */
.kid .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kid .reward .body { padding: 8px 10px 10px; }

/* Collectible picker, in groups. */
.unit-group { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-bottom: 6px; }
.unit-group small { width: 100%; color: var(--muted); }
.units { max-height: 340px; overflow-y: auto; }
details > summary { cursor: pointer; margin: .6rem 0; font-weight: 500; }

/* Momentum combo settings. */
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.three label { margin: .6rem 0; font-size: .9rem; }
@media (max-width: 480px) { .three { grid-template-columns: 1fr; } }
.combo-preview { display: flex; flex-wrap: wrap; gap: 6px; margin: .4rem 0; }
.combo-preview span { display: flex; flex-direction: column; align-items: center; min-width: 44px; padding: .3rem .5rem;
  border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-weight: 600; }
.combo-preview small { font-weight: 400; color: var(--muted); font-size: .75rem; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
.kids-strip.grownups { margin: 0 0 12px; }
.banner { position: relative; }
.banner-edit { position: absolute; top: 8px; right: 12px; font-size: .85rem; color: inherit; }
.kid-chip small { font-weight: 400; opacity: .75; }
