/* Prolongamento — design system
   Paleta clara, uma família tipográfica (Sora), acento lima nos tamanhos e preços. */
:root {
  --bg: #F6F8F5;
  --surface: #FFFFFF;
  --ink: #14213D;
  --ink-2: #4B5566;
  --muted: #7C8595;
  --line: #E3E7E1;
  --grass: #1B8A3B;
  --grass-deep: #146B2D;
  --grass-soft: #E4F3E8;
  --lime: #DCF343;
  --lime-ink: #2E3A00;
  --amber: #B45309;
  --amber-soft: #FEF3E2;
  --red: #C0392B;
  --red-soft: #FBEAE7;
  --r-sm: 8px; --r: 14px; --r-lg: 22px; --pill: 999px;
  --shadow: 0 1px 2px rgba(20,33,61,.05);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.55;
}
a { color: var(--grass-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Barra superior ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 18px; height: var(--nav-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--ink); white-space: nowrap; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--grass); color: var(--lime); display: grid; place-items: center; font-weight: 800; font-size: 1rem; }
.search { display: flex; flex: 1 1 240px; max-width: 520px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--pill); padding: 3px 4px 3px 14px; align-items: center; }
.search:focus-within { border-color: var(--grass); background: #fff; }
.search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: .95rem; padding: 7px 0; min-width: 0; }
.search input:focus { outline: none; }
.search button { border: 0; background: var(--ink); color: #fff; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.search button svg { width: 16px; height: 16px; }
.nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.nav a, .nav .linklike { padding: 8px 12px; border-radius: var(--pill); font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.nav a:hover, .nav .linklike:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.nav a.is-active { color: var(--ink); background: var(--grass-soft); }
.inline { display: inline; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--pill); background: var(--lime); color: var(--lime-ink); font-size: .75rem; font-weight: 700; vertical-align: 2px; }

/* Navegação inferior (telemóvel) */
.bottomnav { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .topbar-inner { gap: 12px; height: 58px; }
  .brand span.brand-text { display: none; }
  body { padding-bottom: 76px; }
  .bottomnav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font-size: .68rem; font-weight: 600; color: var(--muted); border-radius: var(--r-sm); position: relative; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.is-active { color: var(--grass-deep); }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav a.sell { color: var(--ink); }
  .bottomnav a.sell svg { background: var(--lime); border-radius: 50%; padding: 4px; width: 30px; height: 30px; margin-top: -6px; }
  .bottomnav .badge { position: absolute; top: 2px; right: calc(50% - 22px); }
}

/* ---------- Botões e formulários ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: var(--pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; transition: background .15s, transform .05s; }
.btn:hover { text-decoration: none; background: var(--bg); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--grass); border-color: var(--grass); color: #fff; }
.btn-primary:hover { background: var(--grass-deep); }
.btn-lime { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.btn-lime:hover { background: #d0ea2c; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-block { display: flex; width: 100%; }
.btn svg { width: 18px; height: 18px; }

form p { margin: 0 0 16px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r); font: inherit; font-size: 16px; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--grass); box-shadow: 0 0 0 3px var(--grass-soft); }
input[type=file] { font: inherit; font-size: .9rem; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--grass); vertical-align: -3px; margin-right: 6px; }
textarea { resize: vertical; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2314213D' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.helptext { display: block; color: var(--muted); font-size: .82rem; margin-top: 5px; font-weight: 400; }
.errorlist { color: var(--red); margin: 0 0 8px; padding-left: 18px; font-size: .88rem; }
form p label + .errorlist, form p .errorlist { margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow); }
.narrow { max-width: 460px; margin: 32px auto; }
@media (max-width: 560px) { .card { padding: 20px; border-radius: var(--r); } .narrow { margin: 12px auto; } }

/* Notificações (toasts): aparecem no topo, por cima de tudo, e desaparecem sozinhas */
.toasts { position: fixed; top: calc(var(--nav-h) + 12px); left: 0; right: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%; padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: #fff; font-weight: 600; font-size: .95rem; box-shadow: 0 10px 30px rgba(20,33,61,.25); animation: toast-in .3s ease-out; transition: opacity .4s, transform .4s; }
.toast.is-hiding { opacity: 0; transform: translateY(-8px); }
.toast-ico { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); color: var(--lime-ink); font-weight: 800; font-size: .85rem; }
.toast-error .toast-ico { background: var(--red); color: #fff; }
.toast-warning .toast-ico { background: var(--amber); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } }
@media (max-width: 760px) { .toasts { top: 68px; } }

/* ---------- Página inicial ---------- */
.hero { padding: 40px 0 8px; max-width: 640px; }
.hero h1 { margin-bottom: 10px; }
.hero p { margin: 0; color: var(--ink-2); font-size: 1.05rem; max-width: 52ch; }
.sizes { margin: 22px 0 10px; }
.sizes-label { font-size: .85rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.sizes-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sizes-row::-webkit-scrollbar { display: none; }
.size { flex: 0 0 auto; min-width: 46px; height: 46px; padding: 0 12px; border-radius: var(--pill); display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: .95rem; }
.size:hover { text-decoration: none; border-color: var(--ink); }
.size.is-active { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0 22px; }
.toolbar select { width: auto; padding: 9px 36px 9px 14px; border-radius: var(--pill); font-size: .9rem; font-weight: 600; }
.toolbar .spacer { flex: 1; }
.toolbar .count { color: var(--muted); font-size: .9rem; }
@media (max-width: 560px) { .toolbar select { flex: 1 1 40%; } .toolbar .spacer { display: none; } .toolbar .count { width: 100%; } }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; margin-top: 22px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 8px 14px; border-radius: var(--pill); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: .88rem; }
.chip:hover { text-decoration: none; border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Grelha de anúncios */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
.item { display: block; color: var(--ink); }
.item:hover { text-decoration: none; }
.item-img { aspect-ratio: 1; border-radius: var(--r); background: var(--grass-soft) center/cover no-repeat; position: relative; overflow: hidden; display: grid; place-items: center; }
.item-img svg { width: 40%; height: 40%; color: var(--grass); opacity: .5; }
.item:hover .item-img { outline: 2px solid var(--ink); outline-offset: -2px; }
.item-size { position: absolute; left: 10px; top: 10px; background: var(--lime); color: var(--lime-ink); font-weight: 800; font-size: .8rem; padding: 4px 9px; border-radius: var(--pill); }
.item-state { position: absolute; right: 10px; top: 10px; background: rgba(20,33,61,.85); color: #fff; font-weight: 700; font-size: .72rem; padding: 4px 9px; border-radius: var(--pill); }
.item-body { padding: 10px 2px 0; }
.item-price { font-weight: 800; font-size: 1.05rem; }
.item-title { margin: 2px 0 0; font-size: .9rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.item-meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-lg); }
.empty p { margin: 0 0 16px; color: var(--ink-2); }
.pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 32px 0; color: var(--muted); font-size: .9rem; }

/* ---------- Página do anúncio ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "gallery info" "desc info"; gap: 0 32px; margin-top: 24px; align-items: start; }
.detail .gallery { grid-area: gallery; } .detail .info { grid-area: info; } .detail .description { grid-area: desc; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; grid-template-areas: "gallery" "info" "desc"; margin-top: 10px; } .detail .info { margin-top: 16px; } }
.gallery-main { aspect-ratio: 1; max-height: 600px; border-radius: var(--r-lg); background: var(--grass-soft) center/contain no-repeat; display: grid; place-items: center; }
.gallery-main svg { width: 30%; color: var(--grass); opacity: .5; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--r-sm); cursor: pointer; opacity: .6; flex: 0 0 auto; }
.thumbs img.active { opacity: 1; outline: 2px solid var(--ink); outline-offset: -2px; }
.detail-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.pill { display: inline-block; padding: 6px 12px; border-radius: var(--pill); font-weight: 800; font-size: .9rem; }
.pill-lime { background: var(--lime); color: var(--lime-ink); }
.pill-grey { background: var(--line); color: var(--ink-2); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.detail h1 { font-size: 1.5rem; }
.detail .price { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 14px; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 18px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .92rem; }
.specs dt { color: var(--muted); } .specs dd { margin: 0; font-weight: 600; }
.seller { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--ink); color: var(--lime); display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.seller .name { font-weight: 700; }
.seller .sub { color: var(--muted); font-size: .85rem; }
.actions { display: grid; gap: 8px; }
.description { white-space: pre-line; margin: 24px 0 0; color: var(--ink-2); max-width: 70ch; }
.description h2 { color: var(--ink); }
details summary { cursor: pointer; font-weight: 700; padding: 11px 18px; border: 1px solid var(--line); border-radius: var(--pill); list-style: none; text-align: center; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { border-radius: var(--r) var(--r) 0 0; }
details .inner { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r) var(--r); padding: 16px; }
/* CTA fixo no telemóvel */
@media (max-width: 860px) {
  .sticky-cta { position: fixed; left: 0; right: 0; bottom: 76px; z-index: 19; padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 40%); }
}

/* ---------- Mensagens ---------- */
.inbox-row { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); margin-bottom: 10px; color: var(--ink); }
.inbox-row:hover { text-decoration: none; border-color: var(--ink); }
.inbox-row .thumb { width: 60px; height: 60px; border-radius: var(--r-sm); background: var(--grass-soft) center/cover; flex-shrink: 0; }
.inbox-row .who { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.inbox-row .what { font-size: .9rem; color: var(--ink-2); }
.inbox-row .snippet { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row.unread .snippet { color: var(--ink); font-weight: 600; }
.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-h) - 24px); max-height: 820px; }
@media (max-width: 760px) { .chat { height: calc(100dvh - 58px - 76px - 8px); } body.chat-page { padding-bottom: 0; } body.chat-page .bottomnav { display: none; } body.chat-page .chat { height: calc(100dvh - 58px); } }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.chat-head .thumb { width: 48px; height: 48px; border-radius: var(--r-sm); background: var(--grass-soft) center/cover; flex-shrink: 0; }
.chat-head .name { font-weight: 700; }
.chat-head .what { font-size: .85rem; color: var(--ink-2); }
.chat-box { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); white-space: pre-line; font-size: .95rem; }
.msg.mine { align-self: flex-end; background: var(--ink); color: #fff; border-color: var(--ink); }
.msg .time { display: block; font-size: .68rem; opacity: .6; margin-top: 3px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 12px; border-top: 1px solid var(--line); background: var(--bg); }
.chat-form textarea { flex: 1; border-radius: var(--r-lg); min-height: 46px; max-height: 140px; padding: 12px 16px; }
.chat-form button { width: 46px; height: 46px; border-radius: 50%; padding: 0; flex-shrink: 0; }
.chat-hint { text-align: center; color: var(--muted); font-size: .9rem; padding: 30px 20px; }

/* ---------- Formulários de anúncio / perfil ---------- */
.form-card { max-width: 620px; margin: 24px auto; }
.photo-list { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.photo-list figure { margin: 0; position: relative; }
.photo-list img { width: 88px; height: 88px; object-fit: cover; border-radius: var(--r-sm); }
.photo-list button { position: absolute; top: -6px; right: -6px; border-radius: 50%; width: 24px; height: 24px; border: 2px solid #fff; background: var(--ink); color: #fff; cursor: pointer; font-size: .8rem; line-height: 1; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; background: var(--surface); }
.dropzone input { margin-top: 8px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 480px) { .row-2 { grid-template-columns: 1fr; } }

/* Lista "os meus anúncios" */
.mine-list { display: grid; gap: 10px; }
.mine-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px 10px 10px; }
.mine-row img, .mine-row .ph { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--grass-soft); }
.mine-row .t { font-weight: 700; font-size: .95rem; }
.mine-row .m { color: var(--muted); font-size: .82rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
.profile-head { padding: 32px 0 16px; display: flex; gap: 16px; align-items: center; }
.profile-head .avatar { width: 64px; height: 64px; font-size: 1.4rem; }
.profile-head h1 { margin: 0; font-size: 1.6rem; }
.profile-head .sub { color: var(--muted); }

.footer { color: var(--muted); font-size: .82rem; padding: 48px 20px 28px; text-align: center; }
.footer a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
