:root {
  --bg: #FBF6EE;
  --surface: #FFFDF9;
  --surface-2: #F4EDE2;
  --ink: #2F2A25;
  --muted: #8A7F73;
  --line: #E9DFD1;
  --accent: #C8643B;
  --accent-ink: #FFFFFF;
  --accent-soft: #F6E2D6;
  --sage: #6F8F73;
  --sage-soft: #E3EBDD;
  --honey: #F6E7B8;
  --lilac: #E8DDF0;
  --shadow: 0 1px 2px rgba(80, 60, 40, .06), 0 6px 20px rgba(80, 60, 40, .06);
  --radius: 18px;
  --serif: 'Lora', Georgia, serif;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1B17;
    --surface: #2A251F;
    --surface-2: #332D26;
    --ink: #F2EADF;
    --muted: #A99D8F;
    --line: #3D362E;
    --accent: #E07A50;
    --accent-soft: #4A3125;
    --sage: #9DBBA0;
    --sage-soft: #2F3A2F;
    --honey: #4A4026;
    --lilac: #3B3245;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
  .thumb { filter: saturate(.85) brightness(.92); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h3 { font-family: var(--sans); font-weight: 700; font-size: 15px; }
p { margin: 0 0 .6em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* shell */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; max-width: 980px; margin: 0 auto;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.logo { display: flex; align-items: center; gap: 8px; font: 600 22px var(--serif); }
.logo img { width: 30px; height: 30px; }
.main { max-width: 980px; margin: 0 auto; padding: 4px 16px 110px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 12px; color: var(--muted); padding: 4px 14px; border-radius: 12px; }
.tab-icon { font-size: 20px; line-height: 1.3; }
.tab.on { color: var(--ink); font-weight: 700; }
.tab-give .tab-icon { background: var(--accent); color: var(--accent-ink); width: 32px; height: 28px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
.top .top-give { display: none; }
@media (min-width: 760px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); bottom: 16px; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); gap: 6px; padding: 6px 10px; }
  .top .top-give { display: inline-flex; }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; font: 700 15px var(--sans);
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 20px; border-radius: 14px;
  transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-wide { width: 100%; margin: 10px 0 6px; }
.btn-sm { padding: 7px 14px; font-size: 14px; border-radius: 11px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-soft { background: var(--accent-soft); color: var(--ink); }
.back { background: none; border: 0; font: 600 15px var(--sans); color: var(--muted); padding: 8px 0; cursor: pointer; }

/* hero + search */
.hero { padding: 18px 0 10px; }
.hero h1 { font-size: clamp(26px, 6vw, 38px); max-width: 16ch; }
.hero em { font-style: italic; color: var(--accent); }
.hero p { color: var(--muted); max-width: 46ch; }
.search { display: flex; gap: 8px; margin: 10px 0 12px; }
.search input { flex: 1; min-width: 0; }


input, select, textarea {
  width: 100%; font: 16px var(--sans); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 14px; padding: 11px 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 600 14px var(--sans); padding: 7px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-2px); }
.card-media { position: relative; }
.card-body { padding: 10px 12px 12px; }
.card-body h3 { margin: 6px 0 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.ribbon { position: absolute; top: 8px; left: 8px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; }

.thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center; }
.thumb-emoji { font-size: 56px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.08)); }
.thumb-big { border-radius: var(--radius); aspect-ratio: 4/3; }
.thumb-big .thumb-emoji { font-size: 110px; }

.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge-sm { font-size: 11.5px; padding: 2px 8px; }
.m-free { background: var(--accent-soft); color: var(--accent); }
.m-swap { background: var(--sage-soft); color: var(--sage); }
.m-service { background: var(--lilac); color: #7A5C94; }
.m-charity { background: var(--honey); color: #8D6A12; }
@media (prefers-color-scheme: dark) { .m-service { color: #CDB5E3; } .m-charity { color: #EBCB73; } }

/* item page */
.item { display: grid; gap: 20px; }
@media (min-width: 760px) { .item { grid-template-columns: 1.1fr 1fr; align-items: start; } .item-media { position: sticky; top: 70px; } }
.item h1 { font-size: 28px; margin-top: 10px; }
.item-photos { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.item-photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; }
.desc { font-size: 17px; margin: 14px 0; white-space: pre-line; }
.facts { display: flex; gap: 24px; margin: 0 0 14px; }
.facts dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 700; }
.wish { background: var(--sage-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; }
.wish-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--sage); font-weight: 800; margin-bottom: 4px; }
.wish p { margin: 0; }
.delivery { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pill { background: var(--surface-2); padding: 5px 11px; border-radius: 999px; font-size: 14px; }
.owner { display: flex; gap: 12px; align-items: center; padding: 14px 0; margin: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.avatar { flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.note { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; margin: 8px 0; }
.note.ok { background: var(--sage-soft); }
.card-like { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* forms */
.page-title { font-size: 30px; margin-top: 10px; }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
.form .muted { font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row-end { display: flex; justify-content: flex-end; gap: 16px; margin-top: 8px; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.option { display: flex; align-items: center; gap: 8px; text-align: left; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 600 14px var(--sans); padding: 11px 12px; border-radius: 14px; cursor: pointer; }
.option.on { border-color: var(--accent); background: var(--accent-soft); }
.option-emoji { font-size: 18px; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photo, .photo-add { width: 92px; height: 92px; border-radius: 14px; position: relative; }
.photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.photo button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); cursor: pointer; font-size: 15px; line-height: 1; }
.photo-add { border: 2px dashed var(--line); background: var(--surface); color: var(--muted); font: 600 12px var(--sans); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.photo-add span { font-size: 24px; }

/* funds */
.demo-note { font-size: 13px; background: var(--honey); border-radius: 12px; padding: 8px 12px; }
.orgs { display: grid; gap: 14px; margin-top: 14px; }
@media (min-width: 760px) { .orgs { grid-template-columns: repeat(2, 1fr); } }
.org { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.org-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.org-head h3 { margin: 0; font-size: 16px; }
.org-head p { margin: 0; }
.org-emoji { font-size: 30px; width: 52px; height: 52px; display: grid; place-items: center; background: var(--surface-2); border-radius: 14px; flex: none; }
.needs-title { font-weight: 800; font-size: 13px; margin-top: 4px; }
.needs { margin: 6px 0 14px; padding-left: 20px; flex: 1; }
.org .btn { align-self: flex-start; }

/* profile */
.profile-head { display: flex; gap: 14px; align-items: center; margin: 10px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stats div { background: var(--surface); border-radius: 16px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.stats strong { display: block; font: 600 26px var(--serif); }
.stats span { font-size: 13px; color: var(--muted); }
.mini { display: flex; gap: 12px; align-items: center; background: var(--surface); padding: 10px; border-radius: 16px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.mini .thumb { width: 56px; height: 56px; border-radius: 12px; flex: none; }
.mini .thumb-emoji { font-size: 28px; }
.my-item { margin-bottom: 8px; }
.my-item > .mini { margin-bottom: 0; }
.requests { background: var(--surface); margin: -8px 0 0; padding: 18px 12px 12px; border-radius: 0 0 16px 16px; border-top: 1px dashed var(--line); }
.req { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; }
.req + .req { border-top: 1px solid var(--line); }
.req p { margin: 4px 0 0; }
.req-chosen { background: var(--sage-soft); }
.offer { font-size: 14px; color: var(--sage); font-weight: 700; }
.link-small { background: none; border: 0; font: 600 14px var(--sans); color: var(--muted); cursor: pointer; padding: 0; }
.link-small.danger { color: var(--accent); }
.link-reset { display: block; margin: 30px auto 0; background: none; border: 0; color: var(--muted); font: 13px var(--sans); text-decoration: underline; cursor: pointer; }

/* empty + toast */
.empty { text-align: center; padding: 40px 16px; }
.empty-emoji { font-size: 48px; margin-bottom: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px;
  font-weight: 700; box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px);
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

/* auth */
.auth { max-width: 420px; margin: 24px auto; text-align: center; }
.auth .form { text-align: left; }
.search-city { width: 40%; flex: none; }
.auth-buttons { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.auth-buttons .btn { margin: 4px 0; }
.btn-social { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.btn-tg { background: #2AABEE; color: #fff; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
