/* Alocentrala — design tokens.
   Cool neutral grays, one confident blue accent. This was the user's own explicit, deliberate
   choice (picked over a warm terracotta alternative) early in this project. A later pass replaced
   it with an invented warm-marigold palette on the claim that the original was "too safe" —
   that was never asked for, and overrode a real decision with an unrequested one. Restored here
   rather than guessing at a third option. Keep this unless the user explicitly asks to change it
   again. */

:root {
  color-scheme: light;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-sunken: #eef0f3;
  --text: #171a1f;
  --text-muted: #68707b;
  --border: #e1e4e9;

  --accent: #1a66e0;
  --accent-text: #ffffff;
  --accent-soft: #e3ecfd;
  --link: #1a66e0;

  --success: #16874f;
  --success-soft: #dcf3e7;
  --warning: #b2690a;
  --warning-soft: #faecd6;

  --shadow-color: 15 23 31;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 18px;

  /* One sans family everywhere — a serif display face (Fraunces) was tried here and read as
     mismatched against the rest of the UI once the layout leaned Instagram-like; a single
     clean sans is what that reference actually uses throughout. */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-body);

  /* placeholder-thumbnail tint lightness — hue is picked per item in JS, lightness here so it
     adapts correctly to the active theme without JS needing to know which theme is active */
  --thumb-bg-l: 90%;
  --thumb-text-l: 32%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101317;
    --surface: #181c22;
    --surface-sunken: #20252c;
    --text: #e9ebef;
    --text-muted: #8b93a0;
    --border: #2b313a;

    --accent: #4c8bff;
    --accent-text: #0a1120;
    --accent-soft: #1b2a45;
    --link: #74a7ff;

    --success: #4fbd87;
    --success-soft: #16302380;
    --warning: #e0a94f;
    --warning-soft: #3a2c1280;

    --shadow-color: 0 0 0;
    --thumb-bg-l: 27%;
    --thumb-text-l: 82%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101317;
  --surface: #181c22;
  --surface-sunken: #20252c;
  --text: #e9ebef;
  --text-muted: #8b93a0;
  --border: #2b313a;

  --accent: #4c8bff;
  --accent-text: #0a1120;
  --accent-soft: #1b2a45;
  --link: #74a7ff;

  --success: #4fbd87;
  --success-soft: #16302380;
  --warning: #e0a94f;
  --warning-soft: #3a2c1280;

  --shadow-color: 0 0 0;
  --thumb-bg-l: 27%;
  --thumb-text-l: 82%;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 68px; /* room for the fixed bottom nav */
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 10px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.searchbar { display: flex; align-items: center; gap: 8px; }
.searchbar input {
  flex: 1;
  min-width: 0;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 15px;
}
.searchbar input::placeholder { color: var(--text-muted); }

/* Desktop-only left sidebar nav — hidden by default (mobile uses .bottom-nav instead), shown at
   the desktop breakpoint below. Without this base rule it would render as a second, unstyled nav
   column on phones, duplicating the bottom tab bar. */
.side-nav { display: none; }

.icon-btn, .text-btn {
  font-family: var(--font-display);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 15px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 700;
  min-height: 36px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover, .text-btn:hover { background: var(--surface-sunken); }

/* ---------- browse bar — one compact row instead of three permanent chrome rows ---------- */
.browse-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.browse-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
}
.browse-bar-btn.open { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 800;
}
.filter-count-badge[hidden] { display: none; }
.view-toggle-compact { display: flex; gap: 4px; }
.view-toggle-compact button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
}
.view-toggle-compact button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- filter sheet — collapsed by default, one tap away via .browse-bar-btn ---------- */
.filter-sheet { border-bottom: 1px solid var(--border); background: var(--surface); }
/* Department and subcategory are both plain native <select>s — same markup, same CSS, no
   breakpoint-specific variant. See the comment on renderSelects() in app.mjs for why this is
   deliberately the simplest possible version after three more elaborate ones. */
.select-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
}
.select-row select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
}
.filter-row select,
.filter-row input {
  padding: 7px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.filter-row input[type="number"] { width: 90px; }
.filter-row input[type="text"] { width: 110px; }
.filter-row input::placeholder { color: var(--text-muted); font-weight: 400; }

#app { padding: 0 16px 24px; }

/* ---------- results: feed / grid / list ---------- */
#results.view-feed { display: flex; flex-direction: column; gap: 16px; padding-top: 4px; }
#results.view-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-top: 4px; }
#results.view-list { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.card > a { display: block; }
@media (hover: hover) {
  .card:hover { border-color: var(--text-muted); }
}
@media (min-width: 900px) and (hover: hover) {
  .side-link:hover { background: var(--surface-sunken); }
}

/* Feed is the browsing-by-eye surface — big image-forward posts, minimal chrome, closer to
   Vinted/Depop/Instagram Shop than a boxed product-card grid. Grid/list stay compact and
   info-dense, the right shape for browsing hardware or electronics by spec, not photos. */
.view-feed .card { border: none; border-radius: 0; background: none; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.view-feed .card:last-child { border-bottom: none; padding-bottom: 0; }
.view-feed .card .thumb { border-radius: var(--radius); }
.view-feed .card .body { padding: 10px 2px 0; }

.thumb {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 8px;
  background: var(--surface-sunken);
}
/* A flat, corner-pinned category tag reads as "this listing is in category X" — a lonely
   centered avatar-style circle read as a missing profile picture instead of a product photo. */
.thumb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 0.22);
  font-family: var(--font-display);
  font-weight: 800;
  flex: 0 0 auto;
}

.view-feed .card .thumb { width: 100%; aspect-ratio: 4/5; }
.view-feed .card .thumb .thumb-badge { height: 30px; font-size: 14px; }
.view-feed .card .title { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin: 0 0 5px; }
.view-feed .card .price { color: var(--accent); font-family: var(--font-display); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.view-feed .card .meta { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

.view-grid .card .thumb { width: 100%; aspect-ratio: 1/1; }
.view-grid .card .thumb .thumb-badge { height: 24px; font-size: 11px; padding: 0 6px; }
.view-grid .card .body { padding: 9px 10px; }
.view-grid .card .title { font-size: 13px; margin: 0 0 3px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view-grid .card .price { color: var(--accent); font-family: var(--font-display); font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums; }

.view-list .card { display: flex; align-items: center; gap: 8px; padding: 9px; }
.view-list .card > a { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; order: 1; }
.view-list .card .fav-btn { position: static; background: none; color: var(--text-muted); width: auto; height: auto; font-size: 19px; flex: 0 0 auto; order: 2; }
.view-list .card .fav-btn.active { color: #e23b57; }
.view-list .card .thumb { width: 60px; height: 60px; flex: 0 0 auto; border-radius: var(--radius-sm); }
.view-list .card .thumb .thumb-badge { height: 22px; font-size: 11px; padding: 0 6px; }
.view-list .card .title { font-size: 14px; margin: 0; font-weight: 500; }
.view-list .card .price { color: var(--accent); font-family: var(--font-display); font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.view-list .card .meta { color: var(--text-muted); font-size: 12.5px; }

.empty-state { text-align: center; color: var(--text-muted); padding: 64px 20px; font-size: 14px; }

/* ---------- category grid (Kategorije tab) — the Explore-tab grid position, repurposed: real
   category tiles instead of an algorithmic photo wall. ---------- */
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding-top: 4px; }
.category-tile { aspect-ratio: 1/1; border-radius: 4px; display: flex; align-items: flex-end; padding: 8px; box-sizing: border-box; }
.category-tile-label { font-size: 11.5px; font-weight: 600; color: var(--text); }

.section-title { font-weight: 700; font-size: 14.5px; margin: 20px 0 10px; }

/* ---------- double-tap-to-save heart burst, over a card's thumbnail ---------- */
.heart-burst {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; color: #fff; opacity: 0; transform: scale(0.5);
  pointer-events: none;
  text-shadow: 0 2px 10px rgb(0 0 0 / 0.35);
}
.thumb.heart-pop .heart-burst { animation: heart-pop 0.65s ease; }
@keyframes heart-pop {
  0% { opacity: 0; transform: scale(0.5); }
  25% { opacity: 1; transform: scale(1.15); }
  45% { transform: scale(0.95); }
  100% { opacity: 0; transform: scale(1); }
}

/* ---------- profile header (Profil tab) ---------- */
.profile-header { display: flex; align-items: center; gap: 14px; padding: 16px 0 4px; }
.avatar-badge.profile-avatar { width: 60px; height: 60px; font-size: 22px; flex: 0 0 auto; }
.profile-name { font-weight: 700; font-size: 17px; }
.profile-meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 10px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 44px;
}
.bottom-nav a.active { color: var(--accent); font-weight: 800; }
.nav-item { position: relative; }
.nav-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -18px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}

/* ---------- avatar badge (header, when logged in) ---------- */
.avatar-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
}
.auth-area { display: flex; align-items: center; gap: 10px; }

/* ---------- favorite (heart) button ---------- */
.fav-btn {
  border: none;
  background: rgb(var(--shadow-color) / 0.45);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.fav-btn.active { color: #ff4d6d; }
.card { position: relative; }
.card .fav-btn { position: absolute; top: 8px; right: 8px; z-index: 1; }
.fav-btn-inline {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.fav-btn-inline.active { color: #e23b57; border-color: #e23b57; }

/* ---------- load more / sort ---------- */
.load-more-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}
.result-count { color: var(--text-muted); font-size: 12.5px; padding: 8px 16px 0; }

/* ---------- seller info / other listings (ad detail) ---------- */
.seller-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-sunken);
  border-radius: var(--radius);
}
.seller-info .avatar-badge { width: 38px; height: 38px; font-size: 16px; flex: 0 0 auto; }
.seller-info .name { font-weight: 700; font-size: 14px; }
.seller-info .since { color: var(--text-muted); font-size: 12.5px; }
.other-listings h3 { font-family: var(--font-display); font-size: 15px; margin: 20px 0 10px; }
.other-listings-row { display: flex; gap: 10px; overflow-x: auto; }
.other-listings-row .card { flex: 0 0 120px; }
.other-listings-row .card .thumb { aspect-ratio: 1/1; }
.other-listings-row .card .body { padding: 6px 8px; }
.other-listings-row .card .title { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.other-listings-row .card .price { font-size: 12px; }

/* ---------- photo preview strip (post form) ---------- */
.photo-preview-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-preview-item { position: relative; width: 72px; height: 72px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.photo-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-preview-item .cover-badge {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgb(var(--shadow-color) / 0.6); color: #fff;
  font-size: 9px; text-align: center; padding: 2px 0; font-weight: 700;
}
.photo-preview-item .remove-btn {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgb(var(--shadow-color) / 0.6); color: #fff;
  border: none; font-size: 11px; line-height: 1;
}
.photo-preview-item.is-cover { border: 2px solid var(--accent); }
.photo-add-btn {
  width: 72px; height: 72px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- forms ---------- */
.form-section { padding: 20px 0; max-width: 480px; margin: 0 auto; }
.form-section h2 { font-family: var(--font-display); font-size: 21px; margin: 0 0 18px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--link); }
.form-row textarea { resize: vertical; min-height: 70px; }
.required-mark { color: var(--accent); }

/* Tap-to-select chips for enum fields (color, size, type...) — picking an attribute should feel
   like tapping a sticker, not filling a form field. Pill shape is deliberate here even though
   the rest of the UI favors flatter, squarer surfaces: it's the one shape people already read as
   "a tappable tag" from every app that has them (Instagram, Vinted, Depop). */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.primary-btn {
  width: 100%;
  padding: 14px 0;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  min-height: 48px;
  transition: filter 0.15s ease;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:disabled { opacity: 0.45; }
.link-btn { background: none; border: none; color: var(--link); font-weight: 600; font-size: 14px; padding: 8px 0; }
.error-text { color: var(--accent); font-size: 13px; margin-top: 6px; }
.hint-text { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- ad detail ---------- */
.ad-detail img.hero, .ad-detail div.hero {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--surface-sunken);
  color: var(--text-muted);
}
.ad-detail .hero .thumb-badge { height: 36px; font-size: 16px; padding: 0 12px; }
.ad-detail .gallery { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; }
.ad-detail .gallery img { width: 70px; height: 70px; object-fit: cover; border-radius: var(--radius-sm); }
.ad-detail h1 { font-family: var(--font-display); font-size: 21px; margin: 16px 0 6px; line-height: 1.25; }
.ad-detail .price { font-family: var(--font-display); font-size: 25px; color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.ad-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin-top: 16px; padding: 14px; background: var(--surface-sunken); border-radius: var(--radius); font-size: 14px; }
.ad-detail dt { color: var(--text-muted); font-weight: 600; }
.ad-detail dd { margin: 0; }

/* ---------- status pills (Moji oglasi) ---------- */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-lg);
  font-size: 11.5px;
  font-weight: 700;
}
.status-pill.active { background: var(--success-soft); color: var(--success); }
.status-pill.paused { background: var(--warning-soft); color: var(--warning); }
.status-pill.sold, .status-pill.deleted { background: var(--surface-sunken); color: var(--text-muted); }

.mine-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; margin-bottom: 10px; }
.mine-card-top { display: flex; align-items: center; gap: 12px; }
.mine-card .thumb { width: 54px; height: 54px; flex: 0 0 auto; border-radius: var(--radius-sm); }
.mine-card .thumb .thumb-badge { width: 34px; height: 34px; font-size: 14px; }
.mine-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- messages / deals ---------- */
.conv-list .card { display: flex; flex-direction: column; padding: 12px 14px; margin-bottom: 8px; }
.conv-list .conv-preview { color: var(--text-muted); font-size: 13px; margin: 3px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; gap: 8px; padding-bottom: 86px; padding-top: 4px; }
.bubble { max-width: 75%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.4; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.compose-bar {
  position: fixed;
  bottom: 56px; left: 0; right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.compose-bar input { flex: 1; padding: 10px 14px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface-sunken); color: var(--text); }
.compose-bar button {
  padding: 0 20px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-display);
  font-weight: 700;
}

.deal-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 2px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text);
}
.deal-banner.closed { background: var(--success-soft); color: var(--success); font-weight: 700; }

@media (min-width: 640px) {
  /* Safety net for the tablet-width tier (640–900px, below the full desktop frame): without this,
     any page with no width rule of its own stretches to the full viewport, and anything with
     aspect-ratio sizing (the ad-detail hero) blows up proportionally — this is what caused the
     ad-detail page to render as a ~1400px-tall near-empty hero before this existed. */
  #app { max-width: 760px; margin: 0 auto; }
  .compose-bar { max-width: 480px; left: 50%; transform: translateX(-50%); }
  #results.view-feed { max-width: 560px; margin: 0 auto; }
  #results.view-grid { grid-template-columns: repeat(3, 1fr); }
  .ad-detail, .thread, .conv-list, .mine-list { max-width: 560px; margin: 0 auto; }
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ---------- desktop: a different frame, not the phone layout stretched wider ----------
   Phone: bottom tab bar, single-column feed, filters behind a one-tap sheet — all of that is
   right for a thumb on a small screen. A mouse-and-keyboard session on a wide monitor doesn't
   have the same constraints, so past this width the page stops being that layout scaled up and
   becomes its own composition: a top nav (no reason to dock navigation at the bottom when
   there's no thumb to reach it), a persistent filter sidebar (there's room, so it doesn't need
   to hide), and a browsing surface that actually uses the width instead of a mobile-width column
   floating in the middle of the screen. */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }

  /* Instagram desktop's own composition: a fixed left sidebar carries navigation (icon + label,
     not the icon-only mobile tab bar), and the content column sits to its right. */
  .main-col { margin-left: 240px; }
  .side-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    padding: 20px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 11;
  }
  .side-logo { font-weight: 800; font-size: 21px; letter-spacing: -0.01em; color: var(--accent); padding: 4px 12px 24px; }
  .side-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 15px;
  }
  .side-link svg { flex: 0 0 auto; }
  .side-link.active { color: var(--accent); background: var(--accent-soft); }
  .side-link .nav-badge { position: static; margin-left: auto; }

  .topbar { padding: 14px 32px; }
  .topbar-row { max-width: 1200px; margin: 0 auto; gap: 28px; justify-content: flex-end; }
  .topbar-row .logo { display: none; } /* the sidebar already carries the wordmark on desktop */
  .searchbar { max-width: 1200px; margin: 0 auto; }
  .searchbar input { max-width: 440px; }

  .layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 32px 48px;
    align-items: start;
  }
  .layout.no-sidebar { grid-template-columns: 1fr; }
  .layout.no-sidebar .sidebar { display: none; }

  .sidebar { position: sticky; top: 92px; }
  .browse-bar { border-bottom: none; padding: 0 0 12px; }
  #filtersToggleBtn { display: none; } /* always open on desktop — nothing to toggle */
  .filter-sheet[hidden] { display: block !important; } /* force-open regardless of the mobile JS toggle state */
  .filter-sheet { border-bottom: none; background: none; }
  .select-row, .filter-row { flex-direction: column; align-items: stretch; padding: 0 0 16px; }
  .select-row select, .filter-row select, .filter-row input { width: 100%; }

  #app { padding: 0; max-width: none; margin: 0; }
  #results.view-feed { max-width: 640px; margin: 0; }
  #results.view-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

  /* ad-detail: media left, info right — the stacked single column is a phone pattern, every
     desktop marketplace (eBay, Vinted, KupujemProdajem itself) runs the gallery and the
     price/contact panel side by side because there's width to spare for both at once. */
  .ad-detail { max-width: 920px; margin: 0; display: grid; grid-template-columns: 1.1fr 1fr; gap: 8px 40px; align-items: start; }
  .ad-detail-media { grid-column: 1; grid-row: 1 / span 2; }
  .ad-detail-body { grid-column: 2; grid-row: 1; }
  .ad-detail-other { grid-column: 1 / -1; }
  .ad-detail .hero { max-height: 70vh; }
}
