:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1d1c1a; --muted: #6b675f; --line: #e4e0d6;
  --accent: #c2410c; --accent-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px -12px rgba(0,0,0,.15);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15140f; --card: #211f19; --ink: #f1ede4; --muted: #a39d90; --line: #332f27; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: .5rem .9rem; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: .3rem .6rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
textarea { min-height: 5rem; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .25rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1rem 4rem; }
header.top { display: flex; align-items: center; gap: .75rem; padding: 1rem 0; flex-wrap: wrap; }
header.top h1 { font-size: 1.25rem; margin: 0; flex: 1; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.chip { border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; border: 1px solid var(--line); background: var(--card); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; position: relative; border: 1px solid var(--line); }
.card .ph { aspect-ratio: 1; background: var(--line); width: 100%; object-fit: cover; display: block; }
.card .body { padding: .6rem .7rem .7rem; }
.card .t { font-weight: 600; font-size: .95rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .m { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.card.taken .ph { filter: grayscale(1) opacity(.55); }
.badge { display: inline-block; font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: var(--line); font-weight: 600; }
.badge.free { background: #dcfce7; color: #166534; }
.badge.price { background: #fef3c7; color: #92400e; }
.badge.reserved { background: #dbeafe; color: #1e40af; }
.badge.gone { background: #e5e7eb; color: #374151; }
.badge.new { background: #f3e8ff; color: #6b21a8; }
.badge.sell { background: #fef3c7; color: #92400e; }
.badge.give { background: #dcfce7; color: #166534; }
.badge.keep { background: #e0f2fe; color: #075985; }
.badge.store { background: #ede9fe; color: #5b21b6; }
.badge.trash { background: #fee2e2; color: #991b1b; }
.badge.top { position: absolute; top: .5rem; left: .5rem; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: flex-end; justify-content: center; z-index: 50; }
.modal.open { display: flex; }
.sheet { background: var(--card); width: 100%; max-width: 720px; max-height: 94vh; overflow: auto; border-radius: var(--radius) var(--radius) 0 0; padding: 1rem 1rem 2rem; }
@media (min-width: 640px) { .modal { align-items: center; } .sheet { border-radius: var(--radius); } }
.gallery { display: flex; gap: .5rem; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -1rem; padding: 0 1rem; }
.gallery img { height: 260px; max-width: 90%; border-radius: 10px; scroll-snap-align: start; object-fit: cover; flex: none; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: .9rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; min-width: 110px; }
.stat b { font-size: 1.4rem; display: block; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 999px; font-size: .9rem; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { border: 0; background: none; border-radius: 0; padding: .6rem .8rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { border-bottom-color: var(--accent); font-weight: 600; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--accent); }
.thumbs { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.list > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .5rem; }
pre.digest { white-space: pre-wrap; font: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.status-btns button { padding: .35rem .6rem; font-size: .85rem; }
.status-btns button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.login { max-width: 360px; margin: 15vh auto; }
.copy { font-size: .8rem; }
.thumb-ph { height: 64px; min-width: 64px; max-width: 120px; border-radius: 8px; border: 1px dashed var(--line); background: var(--card); color: var(--muted); font-size: .75rem; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: .3rem; overflow: hidden; flex: none; }
.thumb-ph small { font-size: .65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Inbox / Foto-Dump */
.dump { background: var(--card); border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.dump.over { border-color: var(--accent); }
.filebtn { display: inline-block; cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: .55rem 1rem; font-weight: 600; }
.filebtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.thumbs .th { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.thumbs .th.primary { outline: 3px solid var(--accent); outline-offset: -3px; }
.batch { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .8rem; box-shadow: var(--shadow); }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; margin: .6rem 0; }
.group { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; }
.q { border-left: 3px solid var(--accent); padding: .4rem .7rem; margin: .5rem 0; }
.q .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge.queued, .badge.grouping, .badge.creating, .badge.uploading { background: #e0e7ff; color: #3730a3; }
.badge.needs_input { background: #fef3c7; color: #92400e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.error { background: #fee2e2; color: #991b1b; }
