:root {
  --bg: #eef2ec; --surface: #ffffff; --raised: #ffffff; --ink: #14201b; --muted: #5d6b65; --line: #dbe2da;
  --brand: #0f5a45; --brand-ink: #ffffff; --brand-soft: #dcebe4; --warn: #a52a3f; --warn-soft: #f6dfe3;
  --shadow: 0 1px 2px rgba(20,32,27,.06), 0 6px 18px rgba(20,32,27,.06);
  --r-s: 12px; --r-m: 18px; --r-l: 26px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101614; --surface: #1a2320; --raised: #212c28; --ink: #e9efeb; --muted: #94a39c; --line: #2c3934;
  --brand: #58c9a3; --brand-ink: #06231a; --brand-soft: #1d3a31; --warn: #ff8fa0; --warn-soft: #3c1f25;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--brand); }

/* przyciski i pola */
.btn { border-radius: var(--r-m); padding: 14px 18px; font-weight: 700; background: var(--surface); border: 1.5px solid var(--line); width: 100%; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.danger { color: var(--warn); border-color: var(--warn-soft); }
.btn:active { transform: scale(.98); }
.link { color: var(--brand); font-weight: 700; padding: 8px 6px; }
.round { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface); box-shadow: var(--shadow); }
.round:active { transform: scale(.94); }
input, select { width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: var(--r-s); background: var(--surface); font-size: 16px; }
label, .field { display: grid; gap: 7px; }
label, .flabel { font-size: 14px; color: var(--muted); font-weight: 600; }
label input, label select { color: var(--ink); font-weight: 400; }

/* powitanie */
#welcome { max-width: 460px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 18px 40px; display: grid; gap: 14px; }
.hero { display: grid; gap: 6px; padding: 8px 4px 10px; }
.hero img { border-radius: 18px; margin-bottom: 8px; }
.hero h1 { font-size: 40px; line-height: 1; letter-spacing: -1.2px; font-weight: 800; }
.hero p { color: var(--muted); font-size: 17px; max-width: 26ch; }
.card { background: var(--surface); border-radius: var(--r-l); padding: 20px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.card h2, .sheet h2 { font-size: 21px; letter-spacing: -.3px; }
#jCode { letter-spacing: 4px; text-transform: uppercase; font-weight: 700; }

/* nagłówek */
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 0 8px; }
.top { display: flex; align-items: center; gap: 6px; padding: 0 14px 0 18px; min-height: 52px; }
.title { display: flex; align-items: center; gap: 4px; font-size: 30px; font-weight: 800; letter-spacing: -.8px; min-width: 0; flex: 1; text-align: left; padding: 4px 0; }
.title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title svg { flex: none; color: var(--muted); margin-top: 4px; }
.net { font-size: 13px; background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 5px 11px; font-weight: 700; flex: none; }

/* metki sklepów */
.stores { display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px 4px; scrollbar-width: none; }
.stores::-webkit-scrollbar { display: none; }
.tag { --c: var(--muted); flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px 0 11px;
  border-radius: 8px 20px 20px 8px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 650; font-size: 15px; white-space: nowrap; }
.tag::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.tag b { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag.on { background: var(--c); border-color: var(--c); color: #fff; }
.tag.on::before { background: #fff; }
.tag.on b { color: rgba(255,255,255,.85); }
.tag.plain { border-radius: 20px; padding: 0 15px; }
.tag.plain::before { display: none; }
.tag.plain.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tag.new { border-style: dashed; color: var(--muted); background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* lista */
#listView { padding: 0 14px; }
.sechead { display: flex; align-items: center; gap: 12px; margin: 6px 4px 10px; min-height: 40px; }
.sechead h3 { font-size: 15px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.pillbtn { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 15px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: 15px; }
.pillbtn:active { transform: scale(.96); }
.sheet h3, .blocktitle { font-size: 15px; font-weight: 700; color: var(--muted); }
.blocktitle { margin: 0 4px 10px; }
.block { margin-top: 26px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }

/* kafelek: tło w kolorze kategorii, w środku biała pastylka z ikoną */
.tile { --c: #6b7480; position: relative; background: var(--c); color: #fff; border-radius: var(--r-m); min-height: 132px;
  padding: 14px 6px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-align: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .1s; cursor: pointer; }
.tile:active { transform: scale(.95); }
.emo { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 31px; line-height: 1; flex: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.14); margin-bottom: 3px; }
.emo svg { width: 40px; height: 40px; display: block; }
.emo.letter { font-size: 24px; font-weight: 800; color: var(--c); }
.tile .nm { font-size: 14.5px; font-weight: 700; line-height: 1.18; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .qt { font-size: 13px; font-weight: 600; opacity: .95; }
.tile .st { --sc: #fff; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; font-size: 11.5px; font-weight: 700; padding: 2px 8px 2px 6px; border-radius: 99px;
  background: rgba(255,255,255,.92); color: #1c2622; margin-top: 2px; }
.tile .st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sc); flex: none; }
.tile .st span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .more { position: absolute; top: 0; right: 0; width: 38px; height: 36px; color: rgba(255,255,255,.9); font-size: 19px; line-height: 1; display: grid; place-items: center; border-radius: 0 var(--r-m) 0 14px; }
.tile.pop { animation: pop .28s ease; }
@keyframes pop { 0% { transform: scale(.8); opacity: .3; } 100% { transform: none; opacity: 1; } }

/* kafelek "do dodania": jasny, z kolorową obwódką pastylki */
.tile.offer { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); min-height: 118px; }
.tile.offer .emo { box-shadow: inset 0 0 0 2.5px var(--c); width: 52px; height: 52px; font-size: 28px; }
.tile.offer .emo svg { width: 36px; height: 36px; }
.tile.offer.first { box-shadow: inset 0 0 0 2px var(--brand), var(--shadow); }
.tile.offer.onlist { opacity: .45; }
.tile.offer .st { background: var(--bg); color: var(--ink); }
.tile .hintline { font-size: 11.5px; font-weight: 650; color: var(--muted); }

/* widok listy */
.rowlist { display: grid; gap: 8px; }
.rowlist h4 { margin: 10px 4px 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.rowlist h4:first-child { margin-top: 0; }
.rowitem { --c: #6b7480; display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--r-m); padding: 8px 4px 8px 8px; min-height: 64px;
  box-shadow: var(--shadow); border-left: 6px solid var(--c); cursor: pointer; user-select: none; -webkit-user-select: none; }
.rowitem:active { transform: scale(.985); }
.rowitem .emo { width: 46px; height: 46px; font-size: 25px; margin: 0; box-shadow: inset 0 0 0 2px var(--c); }
.rowitem .emo svg { width: 32px; height: 32px; }
.rowitem .txt { flex: 1; min-width: 0; display: grid; gap: 1px; }
.rowitem .nm { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowitem .sub { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; gap: 8px; align-items: center; }
.rowitem .sub .st { --sc: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.rowitem .sub .st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sc); }
.rowitem .more { width: 44px; height: 44px; color: var(--muted); font-size: 20px; flex: none; }
.empty { text-align: center; color: var(--muted); padding: 44px 30px 6px; font-size: 17px; }

/* zwijane sekcje */
.foldhead { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.fold { display: flex; align-items: center; gap: 6px; font-size: 19px; font-weight: 800; letter-spacing: -.2px; padding: 8px 4px; min-height: 44px; text-align: left; }
.fold .chev { transition: transform .18s; flex: none; color: var(--muted); }
.fold[aria-expanded="true"] .chev { transform: rotate(90deg); }
.catalog { background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden; }
.catrow + .catrow { border-top: 1.5px solid var(--line); }
.catrow .fold { width: 100%; padding: 14px 14px; font-size: 17px; font-weight: 700; }
.catrow .fold .dot { width: 14px; height: 14px; border-radius: 5px; background: var(--c); flex: none; margin-right: 6px; }
.catrow .fold span.n { flex: 1; }
.catrow .fold .chev { order: 3; }
.catrow .grid { padding: 2px 10px 14px; }
.catrow .tile.offer { box-shadow: none; background: var(--bg); }
#app { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

/* dolny pasek: rozwijany panel z produktami pierwszej potrzeby i wynikami wpisywania */
.scrim { position: fixed; inset: 0; z-index: 7; background: rgba(8,14,12,.35); }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--raised); border-radius: var(--r-l) var(--r-l) 0 0;
  box-shadow: 0 -2px 6px rgba(20,32,27,.08), 0 -10px 30px rgba(20,32,27,.14); padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; max-height: 78dvh; }
.handle { width: 100%; height: 26px; display: grid; place-items: center; flex: none; }
.handle i { width: 44px; height: 5px; border-radius: 99px; background: var(--line); }
.dockpanel { overflow-y: auto; padding: 4px 2px 12px; min-height: 0; overscroll-behavior: contain; }
#addForm { display: flex; gap: 10px; align-items: center; flex: none; }
#addInput { flex: 1; min-width: 0; height: 54px; border-radius: 16px; padding: 0 16px; font-size: 17px; background: var(--bg); border: 1.5px solid var(--line); }
.inbtn { width: 46px; height: 54px; border-radius: 14px; display: grid; place-items: center; flex: none; color: var(--muted); }
.inbtn:active { background: var(--brand-soft); }
.plus { width: 54px; height: 54px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; flex: none; }
.plus:active { transform: scale(.94); }

/* przełącznik segmentowy */
.seg { display: flex; background: var(--surface); border-radius: var(--r-s); padding: 4px; gap: 4px; box-shadow: var(--shadow); }
.seg button { flex: 1; min-height: 44px; border-radius: 9px; font-weight: 700; font-size: 15px; padding: 0 8px; }
.seg button.on { background: var(--ink); color: var(--bg); }

/* arkusze */
.backdrop { position: fixed; inset: 0; background: rgba(8,14,12,.5); z-index: 10; animation: fade .18s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--bg); border-radius: var(--r-l) var(--r-l) 0 0;
  padding: 26px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 16px; max-height: 90dvh; overflow-y: auto;
  max-width: 560px; margin: 0 auto; animation: rise .22s cubic-bezier(.2,.8,.2,1); }
.sheet::before { content: ""; position: absolute; top: 9px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 99px; background: var(--line); }
.sheet.tall { min-height: 52dvh; align-content: start; }
.sheet h3 { margin: 4px 4px 0; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hint { color: var(--muted); font-size: 15px; }
.bigname { font-size: 24px; font-weight: 800; letter-spacing: -.4px; border: 0; background: transparent; padding: 4px 2px; border-bottom: 2px solid var(--line); border-radius: 0; }
.bigname:focus-visible { border-bottom-color: var(--brand); }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; }
.stepper button { height: 60px; border-radius: var(--r-m); background: var(--surface); box-shadow: var(--shadow); font-size: 30px; font-weight: 500; line-height: 1; }
.stepper button:active { background: var(--brand-soft); transform: scale(.96); }
.stepper input { height: 60px; text-align: center; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; border-radius: var(--r-m); }
.unit { min-height: 40px; padding: 0 15px; border-radius: 99px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 650; font-size: 15px; }
.unit.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.inline { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.inline .btn { width: auto; }
.qr { background: #fff; border-radius: var(--r-m); padding: 14px; width: 220px; height: 220px; margin: 0 auto; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; }
.code { text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 6px; color: var(--brand); font-variant-numeric: tabular-nums; }
.rows { list-style: none; padding: 0; display: grid; gap: 7px; }
.rows:empty { display: none; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: var(--r-s); padding: 4px 8px 4px 14px; min-height: 52px; border: 1.5px solid transparent; }
.rows li.cur { border-color: var(--brand); }
.rows li .pick { flex: 1; text-align: left; padding: 12px 0; font-weight: 650; }
.rows li .dot { --c: var(--muted); display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 9px; }
.rows small { color: var(--muted); font-weight: 400; }
.scanitems { list-style: none; margin: 4px 0 16px; padding: 0; display: grid; gap: 8px; }
.scanitems li { display: grid; grid-template-columns: 30px 1fr 86px; gap: 8px; align-items: center; }
.scanitems input[type=checkbox] { width: 26px; height: 26px; padding: 0; accent-color: var(--brand); }
.scanitems input[type=text] { padding: 11px 12px; }
#scanResult { display: grid; gap: 12px; }
.busy { display: grid; justify-items: center; gap: 14px; padding: 50px 0; color: var(--muted); }
.spinner { width: 40px; height: 40px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(120px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 99px; font-size: 15px; font-weight: 600; max-width: 88vw; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .sheet, .backdrop, .tile.pop { animation: none; }
  .spinner { animation-duration: 3s; }
  .tile, .btn, .round, .fold .chev { transition: none; }
}

/* zdjęcie przypięte do pozycji */
.thumb { position: absolute; top: 6px; left: 6px; width: 38px; height: 38px; border-radius: 10px; overflow: hidden; background: rgba(255,255,255,.9);
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0,0,0,.25); display: grid; place-items: center; font-size: 17px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rowitem .thumb { position: static; flex: none; width: 44px; height: 44px; box-shadow: 0 0 0 1.5px var(--line); }
.photofield { display: flex; gap: 10px; align-items: center; }
.photofield .btn { width: auto; flex: 1; }
.photofield .pv { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--surface); flex: none; }
.photobig { width: 100%; max-height: 62dvh; object-fit: contain; border-radius: var(--r-m); background: var(--surface); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast button { color: var(--bg); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; padding: 4px 2px; white-space: nowrap; }

.dockstores { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 0 12px; }
.dockstores::-webkit-scrollbar { display: none; }
.dockstores .tag { min-height: 38px; }

/* osoby: awatary w nagłówku służą też jako filtr "kto dodał" */
.people { display: flex; align-items: center; padding-left: 8px; flex: none; }
.av { --ac: #6b7480; width: 38px; height: 38px; border-radius: 50%; background: var(--ac); color: #fff; font-weight: 800; font-size: 15px; display: grid; place-items: center;
  border: 2.5px solid var(--bg); margin-left: -9px; flex: none; position: relative; transition: transform .12s, opacity .12s; }
.people .av:first-child { margin-left: 0; }
.people.filtering .av:not(.on) { opacity: .38; }
.av.on { transform: scale(1.08); box-shadow: 0 0 0 2.5px var(--ink); z-index: 1; }
.av.more { background: var(--surface); color: var(--muted); font-size: 13px; }
.avadd { width: 38px; height: 38px; border-radius: 50%; border: 2px dashed var(--muted); color: var(--muted); display: grid; place-items: center; flex: none; margin-left: 4px; }
.avadd:active, .av:active { transform: scale(.94); }
.fchip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px 0 4px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 700; }
.fchip .av { width: 26px; height: 26px; font-size: 11px; border: 0; margin: 0; }
.fchip .x { color: var(--muted); font-size: 16px; line-height: 1; margin-left: 2px; }
.empty .btn { width: auto; margin-top: 14px; padding: 12px 22px; }
.rowitem .av { width: 28px; height: 28px; font-size: 11px; border: 0; margin: 0; }
.byline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
.byline:empty { display: none; }
.byline .av { width: 26px; height: 26px; font-size: 11px; border: 0; margin: 0; }

.people-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px; }
.people-list li + li { border-top: 1.5px solid var(--line); }
.people-list .av { width: 44px; height: 44px; font-size: 17px; border: 0; margin: 0; }
.people-list .who { flex: 1; min-width: 0; display: grid; gap: 2px; }
.people-list .nm { font-weight: 700; font-size: 16px; }
.people-list .nm small { font-weight: 600; color: var(--muted); margin-left: 6px; }
.people-list .dev { font-size: 13px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-list .state { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.people-list .state.live { color: var(--brand); }
.people-list .state.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.people-list .kick { width: 44px; height: 44px; border-radius: 50%; color: var(--muted); display: grid; place-items: center; flex: none; }
.people-list .kick:active { background: var(--warn-soft); color: var(--warn); }
.invite { display: grid; gap: 12px; }
.center { text-align: center; }
.sechead h3 { white-space: nowrap; }
.sechead { gap: 8px; }
.fchip { min-width: 0; }
.fchip span:not(.av):not(.x) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9ch; }

/* notatka do pozycji */
.tile .nt { font-size: 12.5px; font-weight: 500; font-style: italic; opacity: .95; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowitem .sub .nt { font-style: italic; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
