:root {
  --navy: #01315a; --sea: #00838c; --teal: #00a5af; --orange: #f5840b; --sky: #e6f6f7; --sand: #f4f7f9;
  --red: #d64545; --green: #2e8b57; --text: #1d2733; --muted: #6b7785; --line: #dde4ea;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--sand);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--sea); }
h1 { font-size: 1.5rem; margin: .2em 0 .5em; color: var(--navy); }
h2 { font-size: 1.15rem; color: var(--navy); margin: 1em 0 .4em; }
h3 { font-size: 1rem; margin: 0 0 .4em; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: .4rem 1rem; background: #fff; color: var(--navy); border-bottom: 4px solid var(--teal); box-shadow: 0 2px 8px #01315a1a; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; min-width: 0; flex: 1 1 320px; }
.tagline { color: var(--navy); font-size: .95rem; font-weight: 600; line-height: 1.25; max-width: 340px;
  padding-left: .8rem; border-left: 3px solid var(--orange); }
@media (max-width: 560px) { .tagline { font-size: .8rem; max-width: none; } }
.brand img { height: 52px; width: auto; display: block; }
.hero-logo { display: block; width: 230px; max-width: 70%; height: auto; margin: 0 auto .6rem; }
.card.narrow > .hero-logo + h1 { text-align: center; }
#nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
#nav a { color: var(--navy); text-decoration: none; font-size: .95rem; font-weight: 600; }
#nav a:hover { color: var(--sea); }
#nav a.btn { color: #fff; }
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem; }
.footer { text-align: center; padding: 1.5rem 1rem; font-size: .85rem; color: var(--muted); }

.card { background: #fff; border-radius: var(--radius); padding: 1.2rem; box-shadow: 0 1px 4px #01315a14; }
.narrow { max-width: 640px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; margin-top: 1rem; }
.grow { flex: 1; }
.center { text-align: center; } .muted { color: var(--muted); } .small { font-size: .85rem; }
.hidden { display: none !important; }
.error-text { color: var(--red); }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .92rem; }
label.check { display: block; font-weight: 400; }
label.check input { margin: 0 .45rem 0 0; vertical-align: middle; }
.label { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.hint { font-weight: 400; font-size: .8rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sea); border-color: transparent; }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--sea); border-color: var(--sea); color: #fff; }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.modal .btn.danger { background: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.small { padding: .35rem .7rem; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: wait; }

.filters { display: grid; grid-template-columns: 2fr auto 1fr 1fr; gap: .6rem; align-items: center; margin-bottom: 1rem; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } .filters #q, .filters .chips { grid-column: 1 / -1; } }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .4rem .9rem; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600; flex-direction: row; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chips.big .chip { padding: .6rem 1.4rem; font-size: 1rem; }
.chip input { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.listing { background: #fff; border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit;
  box-shadow: 0 1px 4px #01315a14; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.listing:hover { transform: translateY(-2px); box-shadow: 0 6px 16px #01315a22; }
.thumb { position: relative; aspect-ratio: 4/3; background: var(--sky); display: grid; place-items: center; font-size: 3rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.listing .body { padding: .8rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.tag { position: absolute; top: .5rem; left: .5rem; padding: .2rem .6rem; border-radius: 6px; font-size: .75rem; font-weight: 800;
  text-transform: uppercase; color: #fff; background: var(--sea); }
.tag.cerco { background: var(--orange); }
.listing.closed .thumb img, .listing.closed .thumb > span:first-child { filter: grayscale(.7); opacity: .65; }
.sold { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-8deg); background: var(--orange); color: #fff;
  font-weight: 900; font-size: 1.1rem; letter-spacing: 2px; text-transform: uppercase; padding: .35rem 1.1rem; border-radius: 8px;
  box-shadow: 0 3px 10px #0003; border: 2px solid #fff; }
.pill.sold-pill { background: var(--orange); color: #fff; text-transform: uppercase; letter-spacing: .5px; }
.tag.inline { position: static; vertical-align: middle; font-size: .7rem; }
.meta { display: flex; gap: .35rem; flex-wrap: wrap; }
.pill { font-size: .75rem; padding: .15rem .55rem; border-radius: 999px; background: var(--sky); color: var(--navy); font-weight: 600; }
.pill.place { background: #fff1e2; color: #8a4500; }
.pill.alt { background: #eef0e4; color: #4c5a1e; } .pill.closed { background: #eee; color: #777; }

.detail .gallery img#big { width: 100%; max-height: 480px; object-fit: contain; background: var(--sky); border-radius: 10px; }
.thumbs { display: flex; gap: .4rem; margin-top: .4rem; }
.thumbs img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.price { font-size: 1.4rem; font-weight: 800; color: var(--navy); }
.desc { white-space: pre-wrap; line-height: 1.5; }

.previews { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.pv { position: relative; } .pv img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; }
.pv button { position: absolute; top: -6px; right: -6px; border: 0; background: var(--red); color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }

.convs { list-style: none; padding: 0; margin: 0; }
.convs li { border-bottom: 1px solid var(--line); }
.convs li a, .convs li > div { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .7rem .2rem; color: inherit; text-decoration: none; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; padding: .05rem .45rem; font-weight: 700; }

.chat { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; }
.chat-head h2 { margin: .2rem 0; }
.notice { background: #fff6e0; border: 1px solid #f1d27a; border-radius: 10px; padding: .6rem .8rem; font-size: .85rem; margin: .6rem 0; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; padding: .4rem; background: var(--sky); border-radius: 10px; }
.msg { max-width: 78%; background: #fff; padding: .5rem .7rem; border-radius: 12px 12px 12px 2px; align-self: flex-start; box-shadow: 0 1px 2px #0001; }
.msg.mine { align-self: flex-end; background: var(--sea); color: #fff; border-radius: 12px 12px 2px 12px; }
.msg .time { font-size: .7rem; opacity: .7; margin-top: .2rem; }
.composer { display: flex; gap: .5rem; margin-top: .6rem; }
.composer textarea { resize: none; }

.modal { position: fixed; inset: 0; background: #01315a88; display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 1.3rem; max-width: 460px; width: 100%; }
.modal-box code { background: #fde8e8; padding: 0 .3rem; border-radius: 4px; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: .7rem 1.1rem; border-radius: 10px; z-index: 60; box-shadow: 0 4px 14px #0004; max-width: 90vw; }
.toast.error { background: var(--red); }
.prose { line-height: 1.55; } .prose li { margin-bottom: .3rem; }

/* Barra sponsor fissa in basso */
.sponsor-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--navy); border-top: 3px solid var(--orange);
  padding: .45rem 1rem calc(.45rem + env(safe-area-inset-bottom)); box-shadow: 0 -2px 10px #01315a33; }
.sponsor-bar a { display: flex; align-items: center; justify-content: center; gap: .6rem; color: #fff; text-decoration: none;
  font-size: .9rem; font-weight: 600; max-width: 1100px; margin: 0 auto; text-align: center; line-height: 1.25; }
.sponsor-bar a:hover span:last-child { text-decoration: underline; }
.sponsor-bar img { height: 32px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px 4px; }
.sponsor-ico { font-size: 1.2rem; }
body.has-sponsor { padding-bottom: 64px; }
body.has-sponsor .toast { bottom: 76px; }
@media (max-width: 560px) { .sponsor-bar a { font-size: .8rem; } }
