/* Mobile-first, no framework. Colours are tokens so the theme is easy to rebrand. */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #171a2b;
  --muted: #6a7088;
  --line: #e3e6ef;
  --primary: #4f46e5;
  --primary-dark: #4038c7;
  --primary-soft: #eef0ff;
  --accent: #f59e0b;
  --accent-dark: #d98805;
  --accent-text: #201400;
  --ok: #0f8a4f;
  --ok-soft: #e5f6ed;
  --warn: #9a6200;
  --warn-soft: #fff4d9;
  --bad: #c62828;
  --bad-soft: #fdeaea;
  --wa: #128c4a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 4px 14px rgba(20, 24, 50, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1120;
    --surface: #191c30;
    --text: #eceefa;
    --muted: #9aa0bd;
    --line: #2b2f4a;
    --primary: #8b85ff;
    --primary-dark: #a29dff;
    --primary-soft: #23264a;
    --accent: #fbbf24;
    --accent-dark: #ffd15c;
    --ok: #4cd08f;
    --ok-soft: #133324;
    --warn: #ffcf70;
    --warn-soft: #3a2e10;
    --bad: #ff8a80;
    --bad-soft: #3d1a1a;
    --wa: #2bbf6d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: 64px; /* room for the mobile tab bar */
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .6em 0 .4em; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .7em; }
h3 { font-size: 1rem; margin: 0 0 .5em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 14px; }
.narrow { max-width: 720px; margin: 0 auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1 1 0; min-width: 0; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0f1120; } }
.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost.on { color: var(--bad); border-color: var(--bad); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: var(--line); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.btn-lg { min-height: 50px; font-size: 1.05rem; padding: 10px 22px; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .88rem; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { font-weight: 800; font-size: 1.25rem; color: var(--text); display: flex; align-items: center; gap: 6px; text-decoration: none !important; }
.logo-mark { color: var(--accent); }
.topbar-gap { flex: 1; }
.topsearch { display: flex; gap: 6px; flex: 1 1 100%; order: 3; }
.topsearch .suggest-wrap { flex: 1; }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.navlink { display: none; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; position: relative; }
.navlink:hover { background: var(--primary-soft); text-decoration: none; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; font-weight: 700; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; }
.avatar-lg { width: 48px; height: 48px; font-size: 1.2rem; flex: none; }
.usermenu { position: relative; display: none; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; padding: 4px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu img { border-radius: 50%; }
.menu { position: absolute; right: 0; top: 46px; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 60; }
.menu-name { padding: 8px 10px; font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; font: inherit; color: var(--text); border-radius: 8px; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--primary-soft); text-decoration: none; }
.topnav .btn-accent { display: none; }

/* ---------- inputs ---------- */
input[type="text"], input[type="search"], input[type="tel"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
textarea { resize: vertical; }
input[disabled] { opacity: .65; }

.suggest-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 70; overflow: hidden; text-align: left; }
.suggest a { display: block; padding: 10px 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest a:hover, .suggest a.on { background: var(--primary-soft); text-decoration: none; }

/* ---------- hero ---------- */
.hero { margin: 14px 0 6px; padding: 26px 16px; border-radius: 18px; text-align: center; color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed 60%, #9333ea); }
.hero h1 { margin: 0 0 6px; font-size: 1.55rem; }
.hero p { margin: 0 0 16px; opacity: .92; }
.hero-search { display: flex; flex-wrap: wrap; gap: 8px; max-width: 760px; margin: 0 auto; }
.hero-search .grow { flex: 1 1 100%; }
.hero-search select { flex: 1 1 0; }
.hero-search input, .hero-search select { border-color: transparent; min-height: 48px; }
.hero-search .btn { min-height: 48px; }
.hero-links { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: .92rem; }
.hero-links a { color: #fff; text-decoration: underline; }
.muted-light { opacity: .8; }

/* ---------- categories ---------- */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; color: var(--text); }
.cat:hover { border-color: var(--primary); text-decoration: none; box-shadow: var(--shadow); }
.cat-icon { font-size: 1.8rem; line-height: 1.2; }
.cat-name { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.cat-count { font-size: .76rem; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills a { padding: 6px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: .92rem; }
.pills a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* ---------- ad cards ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-featured { border-color: var(--accent); }
.card-img { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--primary-soft); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.noimg { display: grid; place-items: center; width: 100%; height: 100%; font-size: 2.4rem; background: var(--primary-soft); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.card-img .chip { position: absolute; top: 8px; left: 8px; background: rgba(15, 17, 32, .78); color: #fff; }
.card-img .chip-count { left: auto; right: 8px; top: auto; bottom: 8px; font-weight: 500; }
.card-img .chip-featured, .chip-featured { background: var(--accent); color: var(--accent-text); }
.card-img .chip-sold { background: var(--bad); }
.chip-cond { background: var(--ok-soft); color: var(--ok); }
.card-body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { color: var(--text); font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-price { color: var(--primary); font-weight: 800; }
.card-price small { font-weight: 500; color: var(--muted); font-size: .76rem; }
.card-meta { margin-top: auto; display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); }
.card-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.recent-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.recent { flex: 0 0 140px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); font-size: .85rem; display: flex; flex-direction: column; }
.recent img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.recent span { padding: 6px 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent strong { padding: 0 8px 8px; color: var(--primary); }

.cta { margin: 28px 0; padding: 22px; border-radius: 18px; background: var(--primary-soft); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.cta h2 { margin: 0 0 4px; }
.cta p { margin: 0; color: var(--muted); }

.empty { text-align: center; padding: 40px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); margin: 16px 0; }
.empty .btn { margin: 4px; }

.notice { padding: 10px 14px; border-radius: 10px; background: var(--primary-soft); margin: 12px 0; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- search page ---------- */
.crumbs { font-size: .88rem; color: var(--muted); margin: 12px 0 4px; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.results-head h1 { margin: 0; font-size: 1.3rem; }
.results-head small { color: var(--muted); font-weight: 400; }
.results-tools { display: flex; gap: 8px; }
.layout-2 { display: block; }
.filters { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.filters.open { display: block; }
.filters form { display: grid; gap: 12px; }
.filters label, .form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.range { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.range legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 4px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; flex: none; }
.reset { text-align: center; font-size: .9rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 22px 0; }
.pager a { padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

.map { height: 300px; border-radius: var(--radius); border: 1px solid var(--line); margin: 10px 0; z-index: 1; background: var(--primary-soft); }
.map-results { height: 380px; }
.map-pop { display: flex; flex-direction: column; width: 160px; color: #171a2b; font-size: .85rem; }
.map-pop img { border-radius: 6px; margin-bottom: 4px; }
.map-pop strong { color: #4f46e5; }

/* ---------- ad page ---------- */
.ad { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 8px; }
.gallery-main { display: block; background: #0d0f1c; border-radius: var(--radius); overflow: hidden; }
.gallery-main img { width: 100%; max-height: 520px; object-fit: contain; margin: 0 auto; }
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.gallery-thumbs button { flex: none; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; cursor: pointer; opacity: .7; }
.gallery-thumbs button.on, .gallery-thumbs button:hover { border-color: var(--primary); opacity: 1; }
.gallery-thumbs img { width: 96px; height: 72px; object-fit: cover; }
.ad-head h1 { margin: 8px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ad-price { font-size: 1.7rem; font-weight: 800; color: var(--primary); }
.ad-price small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.ad-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: .9rem; margin: 6px 0 12px; }
.ad-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.tags a { margin-right: 6px; font-size: .9rem; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.box h2 { margin-top: 0; }
.seller { display: grid; gap: 10px; }
.seller-head { display: flex; align-items: center; gap: 12px; color: var(--text); }
.seller-head img { border-radius: 50%; }
.seller-head span { display: flex; flex-direction: column; }
.chat-start { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-start label { font-weight: 600; font-size: .9rem; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 99px; padding: 4px 10px; font: inherit; font-size: .8rem; cursor: pointer; }
.quick button:hover { border-color: var(--primary); }
.tips { margin: 0 0 8px; padding-left: 18px; font-size: .9rem; color: var(--muted); }
.tips li { margin-bottom: 4px; }
.report summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.report form { display: grid; gap: 10px; margin-top: 12px; }
.report label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
.contactbar { position: fixed; left: 0; right: 0; bottom: 60px; z-index: 45; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--line); }

.card { position: relative; }
.card-fav { position: absolute; top: 8px; right: 8px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); color: #171a2b; font-size: 1.15rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.card-fav.on { color: #e11d48; }
.share { position: relative; }
.share summary { list-style: none; }
.share summary::-webkit-details-marker { display: none; }
.share .menu { left: 0; right: auto; top: 48px; }
.map-links { display: flex; flex-wrap: wrap; gap: 8px; }
.extend { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding: 8px; border-radius: 10px; background: var(--warn-soft); }
.extend label { display: grid; gap: 2px; font-size: .82rem; font-weight: 600; }
.extend input { min-height: 34px; padding: 4px 8px; }
.expiring { color: var(--bad); font-weight: 700; }
input[type="date"] { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }

/* ---------- forms ---------- */
.form { display: grid; gap: 18px; margin-bottom: 30px; }
.form fieldset { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 0; display: grid; gap: 14px; min-width: 0; }
.form legend { font-weight: 700; padding: 0 6px; }
.form .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.form .row .grow { flex: 1 1 200px; }
.form p { margin: 0; font-size: .88rem; }
.err { color: var(--bad); font-weight: 500; font-size: .85rem; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label { display: block; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-weight: 500; background: var(--bg); }
.segmented input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; font-size: .85rem; color: var(--muted); }
.photo-grid img { width: 104px; height: 78px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photo-keep { display: grid !important; gap: 2px; font-weight: 500 !important; }
.photo-keep span { display: flex; align-items: center; gap: 4px; }
.agree { align-items: flex-start !important; }
.login { display: grid; gap: 14px; margin-top: 30px; padding: 26px 20px; }
.login h1 { margin: 0; }
.devlogin { text-align: left; border-top: 1px solid var(--line); padding-top: 14px; gap: 10px; margin: 0; }

/* ---------- account ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: .85rem; color: var(--muted); }
.tile span { display: block; font-size: 1.5rem; font-weight: 800; color: var(--text); }
.myads { display: grid; gap: 10px; }
.myad { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.myad-img { flex: 0 0 96px; height: 72px; border-radius: 8px; overflow: hidden; }
.myad-img img { width: 100%; height: 100%; object-fit: cover; }
.myad-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.myad-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.state { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; font-size: .74rem; font-weight: 700; text-transform: uppercase; background: var(--ok-soft); color: var(--ok); }
.state-sold, .state-expired { background: var(--warn-soft); color: var(--warn); }
.state-hidden { background: var(--bad-soft); color: var(--bad); }
.state-featured { background: var(--accent); color: var(--accent-text); }
.chart { width: 100%; height: auto; }
.chart .bar { fill: var(--primary); }
.chart .axis { stroke: var(--line); }
.chart text { font-size: 10px; text-anchor: middle; fill: var(--muted); }
.chart .val { fill: var(--text); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.seller-page { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 14px; }
.seller-page img { border-radius: 50%; }
.seller-page h1 { margin: 0; }
.seller-page p { margin: 0; }
.seller-page div { flex: 1; min-width: 200px; }

/* ---------- chat ---------- */
.convs { display: grid; gap: 8px; }
.conv { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; color: var(--text); }
.conv:hover { border-color: var(--primary); text-decoration: none; }
.conv.unread { border-left: 4px solid var(--primary); }
.conv img, .conv .noimg { width: 64px; height: 48px; flex: none; border-radius: 8px; object-fit: cover; font-size: 1.4rem; }
.conv-body { flex: 1; min-width: 0; display: grid; }
.conv-body > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { color: var(--muted); font-size: .9rem; }
.conv.unread .conv-last { color: var(--text); font-weight: 600; }
.conv-side { display: grid; justify-items: end; gap: 4px; flex: none; }
.chat { max-width: 760px; margin: 10px auto 0; display: flex; flex-direction: column; height: calc(100dvh - 215px); min-height: 380px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.chat-head img { border-radius: 8px; object-fit: cover; }
.chat-head div { display: grid; min-width: 0; }
.chat-ad { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 1.4rem; padding: 0 6px; color: var(--text); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; background: var(--surface); border-left: 1px solid var(--line); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; align-self: flex-start; background: var(--bg); border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.msg.mine { align-self: flex-end; background: var(--primary); color: #fff; border-radius: 14px 14px 4px 14px; }
@media (prefers-color-scheme: dark) { .msg.mine { color: #0f1120; } }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg time { display: block; font-size: .7rem; opacity: .7; text-align: right; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.chat-form textarea { resize: none; }

/* ---------- prose ---------- */
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 20px 20px; margin-top: 14px; }
.prose li { margin-bottom: 6px; }

/* ---------- footer, tab bar, toast ---------- */
.footer { margin-top: 40px; padding: 24px 0 16px; background: var(--surface); border-top: 1px solid var(--line); font-size: .92rem; }
.footer-in { display: grid; gap: 18px; grid-template-columns: 1fr; }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer p { margin: 4px 0 0; }
.copy { margin-top: 16px; font-size: .82rem; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: 60px; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .7rem; color: var(--muted); position: relative; text-decoration: none; }
.tabbar a span { font-size: 1.25rem; line-height: 1.2; }
.tabbar a.on { color: var(--primary); font-weight: 700; }
.tabbar .tab-post span { display: grid; place-items: center; width: 38px; height: 38px; margin-top: -16px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 800; box-shadow: var(--shadow); }
.tabbar .dot { position: absolute; top: 8px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
.toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 90; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 99px; background: #171a2b; color: #fff; font-size: .92rem; box-shadow: var(--shadow); }

/* ---------- tablet ---------- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .hero { padding: 40px 24px; }
  .hero h1 { font-size: 2rem; }
  .hero-search .grow { flex: 2 1 0; }
  .footer-in { grid-template-columns: 1.2fr 1fr 1fr; }
  .footer nav { flex-direction: column; }
}

/* ---------- desktop ---------- */
@media (min-width: 960px) {
  body { padding-bottom: 0; }
  h1 { font-size: 1.8rem; }
  .tabbar, .contactbar, .filters-toggle { display: none; }
  .toast { bottom: 24px; }
  .topbar-in { flex-wrap: nowrap; }
  .topsearch { order: 0; flex: 1 1 auto; max-width: 520px; margin: 0 auto; }
  .navlink, .usermenu, .topnav .btn-accent { display: inline-flex; }
  .usermenu { display: block; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .layout-2 { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
  .filters { display: block; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
  .ad { grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
  .ad-side { position: sticky; top: 76px; }
  .chat { height: calc(100vh - 190px); }
}

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