/* Design tokens. Colours are defined once with light-dark(): they follow
   color-scheme, which is the system's unless the user chose a theme
   (data-theme on <html>, rendered by the server). */

:root {
  color-scheme: light dark;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.78rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.5rem;
  --text-2xl: clamp(1.6rem, 1.2rem + 1.5vw, 2.1rem);
  --text-hero: clamp(2rem, 1.2rem + 3.4vw, 3.4rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  --radius-sm: 3px;
  --radius: 5px;
  --radius-lg: 8px;
  --radius-control: 6px;

  --bg: light-dark(#f7f5f1, #20201e);
  --surface: light-dark(#ffffff, #2a2a27);
  --surface-sunken: light-dark(#efece6, #33322f);
  --fg: light-dark(#1f1d1a, #ecebe8);
  --muted: light-dark(#6c675f, #aeaaa2);
  --line: light-dark(#e4e0d8, #42403c);
  --field-border: light-dark(#bdb6a9, #5a5752);

  --accent: light-dark(#2f5d50, #7fb8a4);
  --accent-hover: light-dark(#264d42, #93c6b4);
  --accent-soft: light-dark(#e2ece8, #2a403a);
  --accent-fg: light-dark(#ffffff, #0f1714);

  --pop: light-dark(#c2510c, #ff8a3d);
  --pop-hover: light-dark(#a8460a, #ff9d5c);
  /* Orange as small text, darker than the fill to stay readable. */
  --pop-text: light-dark(#a8460a, #ff8a3d);
  --pop-soft: light-dark(#fdebdc, #47301e);
  --pop-fg: light-dark(#ffffff, #1d0f05);

  --free: light-dark(#2a64a0, #8bbcf0);
  --free-soft: light-dark(#e3eef9, #263749);
  --lend: light-dark(#8a5a1f, #e2b77a);
  --lend-soft: light-dark(#f6ead8, #433626);
  --danger: light-dark(#b3261e, #f2a49c);
  --danger-soft: light-dark(#fbe7e5, #472c29);

  --shadow-color: light-dark(rgb(31 29 26 / 0.07), rgb(0 0 0 / 0.3));
  --ring: light-dark(transparent, #45433f);
  --shadow-sm: 0 1px 2px var(--shadow-color);
  --shadow: 0 0 0 1px var(--ring), 0 1px 3px var(--shadow-color), 0 6px 18px var(--shadow-color);
  --shadow-lg: 0 0 0 1px var(--ring), 0 4px 10px var(--shadow-color), 0 16px 36px var(--shadow-color);
  --focus: 0 0 0 3px light-dark(rgb(47 93 80 / 0.35), rgb(127 184 164 / 0.4));

  --container: 72rem;

  font-family: var(--font);
  font-size: 100%;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--fg);
  background: var(--bg);
}

main {
  flex: 1;
  width: 100%;
  padding-block: var(--space-6) var(--space-7);
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

h1,
h2 {
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h1 {
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-2);
}

h2 {
  font-size: var(--text-xl);
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

img {
  max-width: 100%;
}

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
}

.lede {
  margin: 0;
  color: var(--muted);
}

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

/* Buttons */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1.2;
  padding: 0.6rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--accent-fg);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

button:hover,
.button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-fg);
}

button:active,
.button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button-pop {
  background: var(--pop);
  border-color: var(--pop);
  color: var(--pop-fg);
}

.button-pop:hover {
  background: var(--pop-hover);
  border-color: var(--pop-hover);
  color: var(--pop-fg);
}

button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--surface-sunken);
  color: var(--fg);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: light-dark(#ffffff, #1d0f0e);
}

.button-large {
  font-size: var(--text-md);
  padding: 0.8rem 1.4rem;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
}

.link-button:hover {
  background: none;
  border: 0;
  color: var(--fg);
  text-decoration: underline;
}

.icon-button {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.icon-button:hover {
  background: var(--surface-sunken);
  border-color: var(--line);
  color: var(--fg);
}

/* Theme toggle: a moon offers dark, a sun offers light. */

.theme-toggle {
  display: contents;
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: inline;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: inline;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

/* Header and footer */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: 3.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 750;
  font-size: var(--text-lg);
  color: var(--fg);
  text-decoration: none;
}

.brand:hover {
  color: var(--fg);
}

.wordmark {
  display: block;
  width: auto;
  height: 2rem;
}

.mark {
  width: auto;
  height: 1.75rem;
}

/* One image per theme where there are two (logos), following the theme
   toggle's rules. */
.only-dark {
  display: none;
}

:root[data-theme="dark"] .only-light {
  display: none;
}

:root[data-theme="dark"] .only-dark {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-light {
    display: none;
  }

  :root:not([data-theme="light"]) .only-dark {
    display: block;
  }
}

.community-logo {
  display: block;
  width: auto;
  max-width: 12rem;
  height: 2rem;
  object-fit: contain;
  object-position: left center;
}


.site-nav {
  display: flex;
  gap: var(--space-1);
}

.site-nav a {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-weight: 550;
  font-size: var(--text-sm);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--fg);
  background: var(--surface-sunken);
}

.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.account form {
  display: contents;
}

.user-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--muted);
  text-decoration: none;
}

.user-name:hover {
  color: var(--fg);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* On small screens the name and "Post a listing" become icons; their text
   stays for screen readers, as their only accessible name. */
@media (max-width: 52rem) {
  .user-name span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

@media (max-width: 40rem) {
  .header-inner {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    padding-block: var(--space-2);
  }

  .site-nav {
    order: 3;
    flex-wrap: wrap;
    width: 100%;
    margin-inline: calc(var(--space-3) * -1);
  }

  .post-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .post-button {
    padding: 0.55rem;
  }
}

/* Home */

.hero {
  padding-block: var(--space-7);
  max-width: 46rem;
  margin-inline: auto;
  text-align: center;
}

.hero-title {
  font-size: var(--text-hero);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin: 0 0 var(--space-4);
}

.highlight {
  color: var(--pop);
}

.hero-lede {
  max-width: 38rem;
  margin: 0 auto var(--space-5);
  font-size: var(--text-lg);
  color: var(--muted);
}

.hero-search {
  display: flex;
  gap: var(--space-2);
  max-width: 36rem;
  margin: 0 auto var(--space-3);
  text-align: start;
}

.hero-search .search-field {
  flex: 1;
  max-width: none;
}

.hero-count {
  margin: 0 0 var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
}

.hero-count strong {
  color: var(--fg);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.hero-browse {
  font-weight: 600;
  text-decoration: none;
}

.home-section {
  padding-block: var(--space-6);
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.section-head h2 {
  margin: 0;
}

.section-link {
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
}

/* Board */

.board-header {
  margin-bottom: var(--space-5);
}

.search {
  margin-bottom: var(--space-4);
}

.search-field {
  position: relative;
  max-width: 40rem;
}

.search-field .icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* As specific as it must be to win over the generic form inputs below. */
.search-field input[type="search"] {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  font-size: var(--text-md);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-sm);
}

.results-heading {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-1);
}

.clear {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
}

.filters {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.filter-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
}

.filter-row + .filter-row {
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.filter-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.count {
  min-width: 1.4rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* Type: one segmented bar, the current kind raised out of it. */
.kind-tabs {
  display: inline-flex;
  justify-self: start;
  max-width: 100%;
  gap: 2px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
}

.kind-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.kind-tab:hover {
  color: var(--fg);
}

.kind-tab[aria-current="page"] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}

.kind-tab .count {
  background: transparent;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
}

.kind-sale .dot {
  background: var(--pop);
}

.kind-free .dot {
  background: var(--free);
}

.kind-lend .dot {
  background: var(--lend);
}

/* Category: chips, the current one filled and clearable. */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.35rem 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  color: var(--fg);
  border-color: var(--muted);
}

.chip[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.chip[aria-current="page"] .count {
  background: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-fg) 45%, transparent);
  color: var(--accent-fg);
}

/* Categories past the first ten, behind a chip-like toggle. */
.more-categories {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.more-categories summary {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
}

.more-categories summary::-webkit-details-marker {
  display: none;
}

.more-categories summary:hover {
  color: var(--fg);
  border-color: var(--muted);
}

.more-categories summary::after {
  content: "\25BE";
  margin-left: 0.35rem;
}

.more-categories[open] summary::after {
  content: "\25B4";
}

.more-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.clear-option {
  padding-right: 0.15rem;
  font-size: var(--text-md);
  line-height: 1;
}

/* Options with nothing in them stay readable links, marked by a faded dot
   and the muted colour rather than by fading their text. */
.unavailable {
  color: var(--muted);
  font-weight: 400;
}

.unavailable .dot {
  opacity: 0.35;
}

@media (max-width: 40rem) {
  .filter-row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  /* Rows wider than the screen fade out at the edge, so it shows they
     scroll; the padding lets the last option scroll clear of the fade. */
  .filter-group,
  .kind-tabs {
    padding-right: 2rem;
    mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
  }

  .more-chips {
    flex-wrap: nowrap;
  }
}

#results {
  transition: opacity 0.15s ease;
}

#results[aria-busy="true"] {
  opacity: 0.55;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: var(--space-5) var(--space-4);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  color: var(--fg);
  text-decoration: none;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  /* Clipped, so a tall photo cannot stretch the box past its ratio. */
  overflow: hidden;
  background: var(--surface-sunken);
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-placeholder,
.gallery-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
}

.card-placeholder .icon {
  width: 2.25rem;
  height: 2.25rem;
  opacity: 0.5;
}

.price-tag {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 700;
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.price-tag.price-free {
  background: var(--free-soft);
  color: var(--free);
}

.price-tag.price-lend {
  background: var(--lend-soft);
  color: var(--lend);
}

.card-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.card-title {
  font-size: var(--text-md);
  font-weight: 650;
  margin: 0 0 var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.card-pickup {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.status {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Favorites: a heart over a card's photo, or beside the message button. */

.card-item {
  position: relative;
  display: flex;
}

.card-item > .card {
  flex: 1;
}

.card-favorite {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
}

.card-favorite .favorite-button {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-color: transparent;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.card-favorite .favorite-button:hover {
  background: var(--surface);
  color: var(--danger);
}

.favorite-button[aria-pressed="true"] {
  color: var(--danger);
}

.favorite-button[aria-pressed="true"] .icon-heart {
  fill: currentColor;
}

.listing-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.still-available {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.still-available p {
  margin: 0;
  font-weight: 600;
}

.save-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-4);
}

.save-search .field-note {
  margin: 0;
}

.changed {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--pop-text);
  font-size: var(--text-xs);
  font-weight: 700;
}

.changed::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.status-reserved {
  background: var(--accent-soft);
  color: var(--accent);
}

.cards > .more {
  grid-column: 1 / -1;
  text-align: center;
  margin: var(--space-3) 0 0;
}

.more a {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
}

.more a:hover {
  border-color: var(--muted);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-4);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.empty .icon,
.message > .icon {
  width: 2.5rem;
  height: 2.5rem;
  opacity: 0.6;
}

.empty p {
  margin: 0;
}

/* Listing page */

.listing {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 52rem) {
  .listing {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
  }
}

.gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.gallery-main {
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-sunken);
  box-shadow: var(--shadow);
}

.gallery-main img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.gallery-thumbs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: 2px;
}

.gallery-thumb {
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  opacity: 0.7;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: opacity 0.15s ease, outline-color 0.15s ease;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb:hover,
.gallery-thumb.active {
  opacity: 1;
}

.gallery-thumb.active {
  outline-color: var(--pop);
}

.gallery-empty {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
}

.gallery-empty .icon {
  width: 3rem;
  height: 3rem;
  opacity: 0.4;
}

.listing-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.listing-details h1 {
  margin: 0;
}

.listing-price-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.listing-price {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
}

.listing-price.price-free {
  color: var(--free);
}

.listing-price.price-lend {
  color: var(--lend);
}

#listing-status {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: flex-start;
}

.listing-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-5);
  margin: 0;
}

.listing-facts div {
  display: contents;
}

.listing-facts dt {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
}

.listing-facts dd {
  margin: 0;
  font-weight: 550;
}

.owner-actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
}

.owner-actions-title {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.owner-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.owner-links {
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-sm);
}

.danger-link,
.danger-link:hover {
  color: var(--danger);
}

.description {
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.listing-owner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.listing-owner > span,
.listing-date {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* Markdown */

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.markdown pre {
  overflow-x: auto;
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.markdown pre code {
  padding: 0;
  background: none;
}

.markdown blockquote {
  margin: 0;
  padding-left: var(--space-4);
  border-left: 3px solid var(--pop);
  color: var(--muted);
}

.markdown table {
  border-collapse: collapse;
}

.markdown th,
.markdown td {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
}

/* Forms */

.listing-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 40rem;
  padding: var(--space-5);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.listing-form label,
.listing-form legend {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  padding: 0;
}

.listing-form .choice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-1) 0 0;
  font-weight: 500;
  font-size: var(--text-md);
}

input:not([type]),
input[type="text"],
input[type="search"],
input[type="file"],
select,
textarea {
  font: inherit;
  width: 100%;
  color: inherit;
  background: var(--surface);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-control);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid transparent;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
}

textarea {
  resize: vertical;
  min-height: 8rem;
}

[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 500;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.listing-form button[type="submit"] {
  margin-top: var(--space-5);
  align-self: flex-start;
  font-size: var(--text-md);
  padding: 0.75rem 1.4rem;
}

/* Sell / give away / lend as one segmented control. The radios stay in the
   page (focusable, announced); only their look changes. */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
}

.segmented legend {
  width: 100%;
  margin-bottom: var(--space-2);
}

.listing-form .segmented .choice {
  position: relative;
  margin: 0;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.segmented .choice + .choice {
  margin-left: -1px;
}

.segmented .choice:first-of-type {
  border-radius: var(--radius-control) 0 0 var(--radius-control);
}

.segmented .choice:last-of-type {
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
}

.segmented .choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segmented .choice:has(input:checked) {
  z-index: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.segmented .choice:has(input:focus-visible) {
  z-index: 2;
  box-shadow: var(--focus);
}

.current-photos {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.current-photos legend {
  width: 100%;
}

.listing-form .current-photos .choice {
  flex-direction: column;
  align-items: flex-start;
  font-size: var(--text-sm);
}

.current-photos img {
  width: 7rem;
  height: 5.25rem;
  object-fit: cover;
  border-radius: var(--radius);
}

/* Messages: errors, confirmations */

.message {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 32rem;
  margin: var(--space-7) auto;
  padding: var(--space-6) var(--space-5);
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.message > .icon {
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.message p {
  color: var(--muted);
  margin: var(--space-2) 0 0;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.message-actions form {
  display: contents;
}

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

/* Messages */

.badge {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: var(--space-1);
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--pop);
  color: var(--pop-fg);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

.post-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
}

.post-chip.removed {
  background: var(--surface-sunken);
  color: var(--muted);
}

.threads {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 48rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.threads li + li {
  border-top: 1px solid var(--line);
}

.thread-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: inherit;
  text-decoration: none;
}

.thread-row:hover {
  background: var(--surface-sunken);
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.thread-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.thread-top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.thread-time,
.thread-post,
.thread-snippet {
  color: var(--muted);
  font-size: var(--text-sm);
}

.thread-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-row.unread .thread-subject,
.thread-row.unread .thread-other {
  font-weight: 700;
}

.posts {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 48rem;
  margin: 0 0 var(--space-5);
  padding: 0;
}

.post {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.post.mine {
  align-self: flex-end;
  background: var(--accent-soft);
}

.post-meta {
  display: flex;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
}

.post-body {
  margin: var(--space-1) 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 48rem;
}

.reply-form textarea {
  min-height: 5rem;
}

.reply-form button {
  align-self: flex-end;
}

/* Reports */

.report summary {
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
}

.report summary:hover {
  color: var(--fg);
}

.report form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.report label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.report textarea {
  min-height: 4rem;
}

.report button,
.report-actions button {
  align-self: flex-start;
}

.report-thanks {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.reports {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 48rem;
  margin: 0;
  padding: 0;
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.report-card h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.report-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
}

.report-reason {
  margin: var(--space-1) 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.report-reason.none {
  color: var(--muted);
  font-style: italic;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.report-actions form:first-child {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 16rem;
}

.report-actions label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.report-actions textarea {
  min-height: 3rem;
}

.removal-reason {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-5);
  text-align: left;
}

.removal-reason label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.removal-reason .message-actions {
  margin-top: var(--space-3);
}

.moderation-link {
  margin: 0;
  font-size: var(--text-sm);
}

.sign-in-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  max-width: 22rem;
  margin-top: var(--space-5);
}

.sign-in-form button {
  margin-top: var(--space-2);
}

/* Privacy */

.privacy {
  max-width: 44rem;
}

.privacy h2 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-lg);
}

/* Settings: your data */

.your-data {
  max-width: 40rem;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.your-data h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.thread-closed {
  color: var(--muted);
  font-style: italic;
}

/* Moderators' pages */

.moderation-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.moderation-nav a {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-weight: 550;
  font-size: var(--text-sm);
  text-decoration: none;
}

.moderation-nav a:hover,
.moderation-nav a[aria-current="page"] {
  color: var(--fg);
  background: var(--surface-sunken);
}

.choice-rename {
  display: flex;
  flex: 1 1 18rem;
  gap: var(--space-2);
  align-items: center;
  min-width: 0;
}

.choice-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  min-width: 9rem;
  margin-left: auto;
}

.choice-rename input {
  flex: 1;
  min-width: 0;
}

.member-list li > .field-error {
  flex-basis: 100%;
  margin: 0;
}

/* Who may sign in */

.members {
  max-width: 40rem;
  margin-bottom: var(--space-5);
}

.members h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.member-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.member-list li + li {
  border-top: 1px solid var(--line);
}

.member-meta {
  flex: 1;
  color: var(--muted);
  font-size: var(--text-sm);
}

.member-list form {
  margin-left: auto;
}

.members code,
.board-header code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.site-footer p {
  margin: 0;
}

.site-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-2);
}

.site-footer .powered-by {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
}

/* A form on its way (see layout/once): its button shows it. */
form[data-sent] [type="submit"] {
  opacity: 0.6;
  cursor: progress;
}

/* Long words and URLs in what members type wrap rather than overflow. */
.listing-details h1,
.description,
.thread-subject,
.card-title,
.board-header h1 {
  overflow-wrap: anywhere;
}
