* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
/* Full width: logo at the far left, icons at the far right (every page) */
.topbar-inner {
  max-width: none; margin: 0 auto;
  padding: 16px 21px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; flex: none; }
.mark { width: 32px; height: 32px; stroke: none; }
.mark path:first-child { stroke: #14A35E; }
.mark path:nth-child(2) { stroke: #14A35E; }
.wordmark { font-size: 18px; font-weight: 700; letter-spacing: 0.06em; }
.wordmark span { color: var(--green-dark); }

.search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 16px;
  border-radius: 8px; background: var(--soft); color: var(--muted);
}
.search-form { flex: 1; min-width: 0; display: flex; }
.search-form .search { flex: 1; }
.search:focus-within { box-shadow: 0 0 0 2px var(--green-dark); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 15px; color: var(--ink);
}
.search input::placeholder { color: var(--placeholder); }

.actions { display: flex; align-items: center; gap: 10px; flex: none; margin-left: auto; }
.top-links { display: flex; gap: 4px; flex: none; }
.top-links a {
  height: 40px; padding: 0 14px; border-radius: 8px;
  display: inline-flex; align-items: center;
  text-decoration: none; color: var(--muted); font-size: 15px; font-weight: 500;
}
.top-links a:hover { color: var(--ink); background: var(--soft); }
.top-links a[aria-current="page"] { color: var(--ink); background: var(--soft); font-weight: 600; }
.header-avatar { overflow: hidden; background-size: cover; background-position: center; }
.header-avatar[aria-current="page"] { box-shadow: 0 0 0 2px var(--green-dark); }
.sell {
  height: 46px; padding: 0 20px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600;
}
.sell:hover { background: var(--accent-hover); }
.sell svg { width: 18px; height: 18px; stroke-width: 2.4; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; text-decoration: none;
}

.icon-btn {
  width: 46px; height: 46px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--soft); color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--soft-hover); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-current="page"] { background: var(--ink); color: var(--bg); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px 0 10px; margin-bottom: 12px; border-radius: 8px;
  background: var(--soft); color: var(--ink); text-decoration: none;
  font-size: 15px; font-weight: 600;
}
.back-link:hover { background: var(--soft-hover); }
.back-link svg { width: 18px; height: 18px; }

/* Content */
.content { max-width: none; margin: 0 auto; padding: 24px 21px 64px; }
/* Laptop and up: Back gets its own column on the left, the page uses the rest of the width */
@media (min-width: 761px) {
  .content:has(> .back-link) { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 24px; align-items: start; }
  .content:has(> .back-link) > * { grid-column: 2; }
  .content:has(> .back-link) > .back-link { grid-column: 1; grid-row: 1; margin: 0; position: sticky; top: 104px; }
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button {
  height: 40px; padding: 0 18px; border-radius: 8px; border: 0;
  background: var(--soft); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  flex: none;
}
.chips button:hover { background: var(--soft-hover); }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }

.list-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 0 0 16px;
}
.list-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.2px; }
.filters { display: flex; gap: 8px; }
.select select {
  height: 40px; padding: 0 34px 0 14px;
  border-radius: 6px; border: 1.5px solid var(--border-soft); background: var(--surface);
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2316181D' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols-d, 4), minmax(0, 1fr));
  gap: 32px 24px;
}
.card { position: relative; }
.card a { display: block; text-decoration: none; color: var(--ink); }
.card img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  border-radius: 10px; background: var(--soft);
  transition: transform .2s ease;
}
.card a:hover img { transform: scale(1.015); }
.price { margin-top: 12px; font-size: 18px; font-weight: 700; }
.title { margin-top: 2px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { margin-top: 4px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; min-width: 0; }
.meta span, .svc-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin { width: 14px; height: 14px; flex: none; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.area-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; font-weight: 600; color: var(--green-dark);
}
.area-chip svg { width: 16px; height: 16px; }
.save {
  position: absolute; top: 10px; right: 10px;
  width: 40px; height: 40px; border-radius: 8px; border: 0;
  background: var(--surface); color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.save svg { width: 20px; height: 20px; }
.save[aria-pressed="true"] { color: var(--green-dark); }
.save[aria-pressed="true"] svg { fill: currentColor; }

.empty { color: var(--muted); padding: 48px 0; text-align: center; }

.bottom-nav { display: none; }

/* Phone */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; padding: 16px 16px 12px; gap: 12px; }
  .brand { order: 1; }
  .actions { order: 2; margin-left: auto; gap: 8px; }
  .sell { display: none; }
  .icon-btn { display: none; }
  .icon-btn.saved-btn { display: inline-flex; width: 44px; height: 44px; }
  .theme-toggle { width: 44px; height: 44px; }
  .top-links { display: none; }
  .back-link { display: none; }
  .avatar { width: 44px; height: 44px; }
  .search, .search-form { order: 3; flex-basis: 100%; }
  .search input { font-size: 16px; }

  .content { padding: 12px 16px 110px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { height: 38px; padding: 0 16px; }
  .list-head { margin: 0 0 16px; }
  .list-head h1 { font-size: 20px; }
  .list-head { flex-wrap: wrap; gap: 10px; }
  .filters { width: 100%; flex-wrap: wrap; }
  .filters .select { flex: 1 1 0; min-width: 0; }
  .filters .select select { width: 100%; padding: 0 24px 0 10px; font-size: 14px; background-position: right 8px center; }
  .filters .density { flex: none; }

  .grid { grid-template-columns: repeat(var(--cols-m, 2), minmax(0, 1fr)); gap: 20px 12px; }
  .card img { border-radius: 8px; }
  .price { margin-top: 8px; font-size: 16px; }
  .title { font-size: 14px; margin-top: 0; }
  .meta { font-size: 12px; margin-top: 2px; }
  .pin { width: 12px; height: 12px; }
  .area-chip { font-size: 13px; }
  .save { top: 8px; right: 8px; width: 36px; height: 36px; }
  .save svg { width: 18px; height: 18px; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    height: 76px; padding: 0 8px 8px;
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500;
  }
  .bottom-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
  .bottom-nav svg { width: 24px; height: 24px; }
  .bottom-nav .bottom-sell {
    justify-self: center; width: 54px; height: 54px; margin-top: -18px;
    border-radius: 12px; background: var(--accent); color: var(--on-accent);
    justify-content: center;
  }
  .bottom-nav .bottom-sell svg { width: 26px; height: 26px; stroke-width: 2.4; }
}

#chips + .grid { margin-top: 28px; }
/* Items-per-row menu */
.density { position: relative; }
.density svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.dens-btn {
  height: 40px; padding: 0 10px 0 12px; display: inline-flex; align-items: center; gap: 6px;
  border-radius: 6px; border: 1.5px solid var(--border-soft); background: var(--surface); color: var(--ink); cursor: pointer;
}
.dens-btn > svg:first-child { width: 18px; height: 18px; }
.dens-chev { width: 14px; height: 14px; stroke-width: 2.2 !important; }
.dens-btn[aria-expanded="true"] { border-color: var(--border); }
.dens-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 176px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow);
}
.dens-menu[hidden] { display: none; }
.dens-head { padding: 6px 10px 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.dens-menu [data-n] {
  width: 100%; height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 10px;
  border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.dens-menu [data-n] > svg:first-child { width: 18px; height: 18px; color: var(--muted); }
.dens-menu [data-n] span { flex: 1; }
.dens-menu [data-n]:hover, .dens-menu [data-n]:focus-visible { background: var(--soft); outline: none; }
.dens-tick { width: 16px; height: 16px; stroke-width: 2.2 !important; visibility: hidden; }
.dens-menu [aria-checked="true"] { font-weight: 600; }
.dens-menu [aria-checked="true"] > svg:first-child { color: var(--ink); }
.dens-menu [aria-checked="true"] .dens-tick { visibility: visible; }
@media (max-width: 1100px) and (min-width: 761px) { .grid { grid-template-columns: repeat(min(var(--cols-d, 4), 4), minmax(0, 1fr)); } }
@media (max-width: 760px) { #chips + .grid { margin-top: 16px; } }

/* Campus picker */
.campus { position: relative; }
.campus svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cp-btn {
  height: 40px; padding: 0 10px 0 12px; display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border-radius: 6px; border: 1.5px solid var(--border-soft); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.cp-btn span { overflow: hidden; text-overflow: ellipsis; }
.cp-btn .cp-pin { width: 16px; height: 16px; flex: none; color: var(--green-dark); }
.cp-chev { width: 14px; height: 14px; flex: none; stroke-width: 2.2 !important; }
.cp-btn[aria-expanded="true"] { border-color: var(--border); }
.cp-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; width: 260px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow);
}
.cp-menu[hidden] { display: none; }
.cp-head { margin: 4px 10px 6px; padding-bottom: 8px; border-bottom: 1.5px solid var(--ink); font-size: 15px; font-weight: 700; }
.cp-list { max-height: min(360px, 60vh); overflow-y: auto; }
.cp-list [data-c] {
  width: 100%; height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.cp-list [data-c] span { flex: 1; min-width: 0; }
.cp-list [data-c] small { font-size: 12px; color: var(--muted); }
.cp-list [data-c]:hover, .cp-list [data-c]:focus-visible { background: var(--soft); outline: none; }
.cp-tick { width: 16px; height: 16px; flex: none; stroke-width: 2.2 !important; visibility: hidden; }
.cp-list [aria-checked="true"] { font-weight: 600; }
.cp-list [aria-checked="true"] .cp-tick { visibility: visible; }
.svc-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 760px) {
  .filters .campus { flex: 1 1 100%; order: -1; }
  .filters .campus .cp-btn { width: 100%; }
  .filters .campus .cp-btn span { flex: 1; text-align: left; }
  .cp-menu { left: 0; right: auto; width: min(320px, calc(100vw - 32px)); }
  .svc-head { flex-wrap: wrap; }
  .svc-actions { width: 100%; flex-wrap: wrap; }
  .svc-actions .campus { flex: 1 1 100%; order: -1; }
  .svc-actions .campus .cp-btn { width: 100%; }
  .svc-actions .campus .cp-btn span { flex: 1; text-align: left; }
  .svc-actions .select { flex: 1 1 0; }
  .svc-actions .select select { width: 100%; }
}
.cp-state { margin: 10px 10px 2px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.cp-list .cp-state:first-child { margin-top: 4px; }
.cp-list [data-c] { padding-left: 18px; }

/* Title on top, then categories (left) and filters (right) on one row */
.list-head, .svc-head { flex-wrap: wrap; row-gap: 16px; }
.list-head > .title-row, .svc-head > .title-row { flex: 1 1 100%; }
.list-head > .chips, .svc-head > .chips { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.list-head > .chips::-webkit-scrollbar, .svc-head > .chips::-webkit-scrollbar { display: none; }
.list-head > .filters, .svc-head > .svc-actions { flex: none; margin-left: auto; }
.list-head + .grid { margin-top: 28px; }
@media (max-width: 760px) {
  .list-head > .chips, .svc-head > .chips { order: 3; flex: 1 1 100%; }
  .list-head > .filters, .svc-head > .svc-actions { margin-left: 0; }
  .list-head + .grid { margin-top: 16px; }
}
