:root {
  --ink: #14213D;
  --tag: #FFD60A;
  --shelf: #F3F5F8;
  --paper: #FFFFFF;
  --sale: #C8102E;
  --mute: #566172;
  --line: #DCE1E8;
  --r: 10px;
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--shelf); color: var(--ink);
  font: 400 16px/1.4 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- barra alta ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--ink); color: #fff;
}
.zone {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; background: none; border: 0; color: #fff;
  font: 800 26px/1 var(--display); letter-spacing: .01em; max-width: 62vw;
}
.zone span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top :focus-visible { outline-color: var(--tag); }
.sort { display: flex; border: 2px solid rgba(255,255,255,.35); border-radius: 999px; overflow: hidden; }
.sort button { min-height: 40px; padding: 0 14px; background: none; border: 0; color: #fff; font-weight: 600; font-size: 14px; }
.sort button[aria-pressed="true"] { background: var(--tag); color: var(--ink); }

/* ---------- categorie ---------- */
.cats {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px; scrollbar-width: none;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.cats::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--paper);
  border: 2px solid var(--line); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.chip small { font-weight: 400; color: var(--mute); margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"] small { color: #C9D2E3; }

.tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px 4px; font-size: 14px; color: var(--mute); }
.only { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; }
.only input { width: 20px; height: 20px; accent-color: var(--ink); }

/* ---------- banner avvisi ---------- */
.banner { margin: 8px 14px 0; padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--r); background: var(--paper); display: flex; align-items: center; gap: 12px; }
.banner p { margin: 0; flex: 1; font-size: 14px; }

/* ---------- elenco offerte ---------- */
.list { padding: 8px 14px 0; display: grid; gap: 10px; }
.offer {
  display: grid; grid-template-columns: 76px 1fr; gap: 6px 12px; padding: 12px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r);
}
.offer .pic { width: 76px; height: 76px; border-radius: 6px; background: #fff; object-fit: contain; }
.offer .body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.who { font-size: 12px; color: var(--mute); font-weight: 600; }
.name { margin: 0; font-weight: 600; font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { font-size: 13px; color: var(--mute); }
.foot { grid-column: 1 / -1; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.when { font-size: 13px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plus { border: 1.5px solid var(--ink); border-radius: 4px; padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--ink); }

/* cartellino prezzo: l'elemento distintivo */
.price { display: flex; align-items: center; gap: 8px; flex: none; }
.was { text-align: right; line-height: 1.05; }
.was s { display: block; color: var(--mute); font-size: 14px; }
.was b { display: block; color: var(--sale); font: 800 20px/1 var(--display); }
.tagp {
  display: flex; align-items: baseline; gap: 2px; padding: 6px 12px 6px 22px; background: var(--tag); color: var(--ink);
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
  font-family: var(--display); font-weight: 800;
}
.tagp .n { font-size: 38px; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tagp .e { font-size: 20px; }

/* ---------- vuoti e bottoni ---------- */
.empty { margin: 32px 24px; text-align: center; color: var(--mute); }
.btn {
  min-height: 48px; padding: 0 20px; border: 2px solid var(--ink); border-radius: 999px; background: var(--tag); color: var(--ink);
  font-weight: 700;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
#more { display: block; margin: 16px auto 32px; }
.link { background: none; border: 0; padding: 10px 0; color: var(--mute); text-decoration: underline; font-size: 14px; text-align: left; }

/* ---------- impostazioni ---------- */
dialog {
  width: 100%; max-width: 560px; max-height: 100dvh; margin: 0 auto; padding: 0; border: 0; background: var(--shelf);
  inset: 0; height: 100dvh; overflow: auto;
}
dialog::backdrop { background: rgba(20,33,61,.5); }
#setupForm { padding: calc(24px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
#setupTitle { margin: 0 0 8px; font: 800 44px/1 var(--display); letter-spacing: -.005em; }
.field { font-weight: 600; margin-top: 8px; }
.combo { position: relative; }
#comune { width: 100%; min-height: 52px; padding: 0 14px; border: 2px solid var(--ink); border-radius: var(--r); background: var(--paper); font-size: 18px; }
#results { position: absolute; z-index: 2; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r); max-height: 46vh; overflow: auto; }
#results li { padding: 12px; border-radius: 6px; min-height: 44px; }
#results li[aria-selected="true"], #results li:hover { background: var(--tag); }
#results small { color: var(--mute); }
input[type=range] { width: 100%; accent-color: var(--ink); min-height: 40px; }
fieldset { border: 0; margin: 10px 0 0; padding: 0; }
legend { font-weight: 600; padding: 0; }
.hint { margin: 2px 0 10px; font-size: 14px; color: var(--mute); }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.err { margin: 0; padding: 10px 12px; border-left: 4px solid var(--sale); background: #fff; color: var(--sale); font-weight: 600; }
.actions { display: flex; gap: 10px; margin-top: 10px; }
.actions .btn:first-child { flex: 1; }
.danger { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 20;
  max-width: min(92vw, 440px); padding: 12px 16px; background: var(--ink); color: #fff; border-radius: var(--r); font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  #app { max-width: 720px; margin: 0 auto; }
  .list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
