:root {
  --bg: #fbf7f2; --card: #fff; --ink: #2a211b; --muted: #7a6c61; --line: #ece3d9;
  --accent: #c2410c; --accent-soft: #fde4d3; --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309;
  --radius: 14px; --shadow: 0 1px 2px rgba(60,40,20,.06), 0 4px 16px rgba(60,40,20,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1714; --card: #26201c; --ink: #f3ece6; --muted: #b3a597; --line: #3a312a;
    --accent: #f97316; --accent-soft: #4a2a17; --ok: #4ade80; --ok-soft: #173a24; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: .25rem 0; line-height: 1.35; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .tiny { font-size: .75rem; }
.center { text-align: center; } .grow { flex: 1; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); }
.brand img { width: 28px; height: 28px; }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; font-size: .95rem; }
.topbar nav a { color: var(--ink); }
.linklike { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.wrap.narrow { max-width: 460px; } .wrap.medium { max-width: 720px; }
.wrap.popup { padding-top: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card { padding: 1.75rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 1rem; } .center-row { justify-content: center; }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--accent-soft); color: var(--accent); }

label { display: block; font-weight: 600; font-size: .9rem; margin: .9rem 0 0; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .6rem .75rem; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row input { margin-top: 0; }
label .row { margin-top: .3rem; }
label.currency { width: 6rem; }
fieldset { border: 0; padding: 0; margin: .9rem 0 0; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .35rem .35rem 0; padding: .4rem .8rem;
  border: 1px solid var(--line); border-radius: 999px; font-weight: 500; cursor: pointer; }
.pill input { width: auto; margin: 0; accent-color: var(--accent); }
.pill:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
details summary { cursor: pointer; margin-top: .9rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .6rem 1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.full { width: 100%; margin-top: 1.25rem; }
.btn.small { padding: .4rem .75rem; font-size: .875rem; }
.btn.mine { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent;
  background: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.icon-btn:hover { background: var(--bg); border-color: var(--line); color: var(--ink); text-decoration: none; }

.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tag.hot { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* family */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.person { display: block; overflow: hidden; color: var(--ink); transition: transform .15s; }
.person:hover { transform: translateY(-2px); text-decoration: none; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 80px; background: #fff; border-bottom: 1px solid var(--line); }
.thumbs img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.thumbs img:only-child { grid-column: span 2; grid-row: span 2; }
.avatar { grid-column: span 2; grid-row: span 2; display: grid; place-items: center; font-size: 3rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.person-info { padding: .8rem 1rem; display: flex; flex-direction: column; }

/* filters */
.share { padding: .8rem 1rem; margin-bottom: 1rem; }
.share summary { margin: 0; font-weight: 600; font-size: .9rem; }
.filters { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip-label { font-size: .8rem; font-weight: 600; color: var(--muted); width: 4.5rem; }
.chip { padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: .875rem; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sort { position: absolute; right: 0; top: 0; }
.sort label { margin: 0; display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.sort select { width: auto; margin: 0; padding: .35rem .6rem; }
@media (max-width: 800px) { .sort { position: static; } .chip-label { width: auto; } }

/* items */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.item { display: flex; flex-direction: column; overflow: hidden; }
.item-img { display: grid; place-items: center; aspect-ratio: 4/3; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.item-img img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.noimg { font-size: 2.5rem; opacity: .7; } .noimg.sm { font-size: 1.5rem; width: 48px; text-align: center; }
.item-body { padding: .8rem 1rem 1rem; display: flex; flex-direction: column; flex: 1; }
.item-top { display: flex; gap: .35rem; flex-wrap: wrap; }
.item h3 a { color: var(--ink); }
.notes { font-size: .875rem; color: var(--muted); margin: .4rem 0 0; white-space: pre-line; }
.item-foot { margin-top: auto; padding-top: .75rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.item-foot > div:first-child { display: flex; flex-direction: column; }
.price { font-weight: 700; font-size: 1.1rem; }
.actions { display: flex; }
.actions form { margin: 0; }
.is-claimed { opacity: .6; }
.claimed-by { font-size: .8rem; color: var(--muted); font-style: italic; text-align: right; }
.empty { grid-column: 1 / -1; padding: 2.5rem; text-align: center; }

/* form */
.status { min-height: 1.3em; margin: .4rem 0 0; color: var(--muted); }
.status.warn { color: var(--warn); }
.preview { display: flex; gap: 1rem; align-items: flex-start; }
.preview img { width: 96px; height: 96px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-top: 1.1rem; padding: 4px; }
.big-check { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: var(--ok-soft); color: var(--ok); }

/* bookmarklet */
.howto { padding: 1.25rem 1.5rem; margin: 1rem 0; }
.howto li { margin-bottom: .6rem; }
.bm-wrap { margin: .75rem 0; }
.bookmarklet { display: inline-block; padding: .6rem 1.1rem; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; cursor: grab; border: 2px dashed rgba(255,255,255,.6); }
.bookmarklet:hover { text-decoration: none; }
textarea#bmcode { font: .75rem ui-monospace, monospace; }
kbd { font: .8rem ui-monospace, monospace; padding: .1rem .35rem; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); margin: 0 .1rem; }

/* shopping */
.shop-list { padding: 1rem 1.25rem; }
.shop-person { margin: 1rem 0 .25rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.shop-person:first-child { margin-top: 0; }
.shop-row { display: flex; align-items: center; gap: .9rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.shop-row:last-child { border-bottom: 0; }
.shop-row img { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 8px; }
.shop-row form { margin: 0; }
.item-img:has(img) { background: #fff; }
