:root {
  --bg: #f6f3ee; --surface: #ffffff; --surface-2: #f0ebe3; --line: #e3dcd0;
  --text: #1f1c18; --muted: #6f675c; --faint: #9a9184;
  --accent: #2f5d50; --accent-ink: #ffffff; --accent-soft: #e2ece8;
  --sell: #8a5a14; --sell-bg: #f6ead6; --give: #2f5d50; --give-bg: #e2ece8;
  --donate: #4b5d8a; --donate-bg: #e4e8f3; --leave: #6f675c; --leave-bg: #ece7df;
  --dispose: #8a3b2f; --dispose-bg: #f4e1dd; --keep: #5b4a86; --keep-bg: #e9e4f3;
  --undecided: #8a6d00; --undecided-bg: #fbf1c9;
  --open: #6f675c; --listed: #1d6fa3; --reserved: #b0620a; --done: #2f7d4f;
  --danger: #b3261e; --shadow: 0 1px 2px rgba(31,28,24,.06), 0 4px 16px rgba(31,28,24,.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151412; --surface: #1f1d1a; --surface-2: #2a2723; --line: #37332d;
    --text: #f1ece4; --muted: #b0a799; --faint: #847b6f;
    --accent: #7fb8a6; --accent-ink: #10201b; --accent-soft: #233630;
    --sell: #e8b86a; --sell-bg: #3a2d18; --give: #7fb8a6; --give-bg: #233630;
    --donate: #9fb1e0; --donate-bg: #262d40; --leave: #b0a799; --leave-bg: #2e2b26;
    --dispose: #e49a8d; --dispose-bg: #3d2420; --keep: #c0b0ea; --keep-bg: #2e2840;
    --undecided: #e6c85a; --undecided-bg: #3a3214;
    --open: #b0a799; --listed: #73b7e6; --reserved: #f0a456; --done: #7fcf9c;
    --danger: #ff8a80; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151412; --surface: #1f1d1a; --surface-2: #2a2723; --line: #37332d;
  --text: #f1ece4; --muted: #b0a799; --faint: #847b6f;
  --accent: #7fb8a6; --accent-ink: #10201b; --accent-soft: #233630;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; } .wrap-row { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 11px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 72px; resize: vertical; }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .04em; }

/* chips / segmented */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 4px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.p-undecided { color: var(--undecided); background: var(--undecided-bg); }
.p-sell { color: var(--sell); background: var(--sell-bg); } .p-give { color: var(--give); background: var(--give-bg); }
.p-donate { color: var(--donate); background: var(--donate-bg); } .p-leave { color: var(--leave); background: var(--leave-bg); }
.p-dispose { color: var(--dispose); background: var(--dispose-bg); } .p-keep { color: var(--keep); background: var(--keep-bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.s-open { background: var(--open); } .s-listed { background: var(--listed); } .s-reserved { background: var(--reserved); } .s-done { background: var(--done); }
.flag { font-size: 11px; color: var(--muted); border: 1px dashed var(--line); padding: 1px 6px; border-radius: 6px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card .ph { aspect-ratio: 4/3; background: var(--surface-2) center/cover no-repeat; position: relative; }
.card .ph .count { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.card .bd { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.card h3 { font-size: 14.5px; margin: 0; line-height: 1.25; }
.card.done { opacity: .55; }
.card.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.card .check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.9); border: 2px solid var(--faint); display: none; place-items: center; font-size: 14px; color: #fff; z-index: 2; }
.selecting .card .check { display: grid; }
.card.sel .check { background: var(--accent); border-color: var(--accent); }
.price { font-weight: 700; }
.group-h { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 10px; }
.group-h h2 { font-size: 15px; margin: 0; }

/* sheet (opens from top on phones, sticky action header) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; min-height: 100%; position: relative; }
@media (min-width: 700px) { .sheet { margin: 32px 0; min-height: 0; border-radius: 18px; overflow: hidden; } }
.sheet-h { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; align-items: center; padding-top: max(10px, env(safe-area-inset-top)); }
.sheet-h h2 { font-size: 16px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-b { padding: 4px 16px 40px; }
.photos { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scroll-snap-type: x mandatory; }
.photos .p { flex: 0 0 auto; width: 74%; max-width: 380px; aspect-ratio: 4/3; border-radius: 12px; background: var(--surface-2) center/cover; position: relative; scroll-snap-align: start; cursor: zoom-in; }
.photos .p .acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.photos .p .acts button { background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 8px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.photos .add { flex: 0 0 auto; width: 130px; aspect-ratio: 3/4; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; text-align: center; color: var(--muted); cursor: pointer; font-size: 13px; background: var(--surface); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 14px; margin-top: 14px; }
.panel > h4 { margin: 12px 0 0; font-size: 13px; }

/* top bar + nav */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top .wrap { padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 750; font-size: 17px; letter-spacing: -.01em; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.stat b { display: block; font-size: 20px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .stat b { font-size: 17px; } .stat { padding: 7px 8px; } }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; position: relative; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs .n { background: var(--danger); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
.fab { position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 25; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 30px; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer; }
.list-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; gap: 12px; margin-bottom: 10px; }
.thumb { width: 60px; height: 60px; border-radius: 10px; background: var(--surface-2) center/cover; flex: 0 0 auto; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 60; font-size: 14px; box-shadow: var(--shadow); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 70; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.menu { position: absolute; right: 0; top: 100%; margin-top: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 50; min-width: 200px; padding: 6px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.linkbox { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 9px 10px; border-radius: 10px; word-break: break-all; }
