/* ContainerSwap — mobile-first, high contrast, big tap targets.
   One stylesheet, no build step, no framework. Everything below assumes a small
   cheap phone on a slow connection is the primary device. */

:root {
  --green: #1b5e3f;
  --green-dark: #124430;
  --ink: #14181a;
  --ink-soft: #4a5459;
  --line: #d3dad7;
  --bg: #f6f8f6;
  --surface: #ffffff;
  --danger: #a4231b;
  --ok: #16663f;
  --radius: 14px;
  --tap: 48px;
  --pad: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --green: #4fc38a;
    --green-dark: #6fd6a2;
    --ink: #eef2f0;
    --ink-soft: #a4b0ac;
    --line: #2b3431;
    --bg: #101513;
    --surface: #18201d;
    --danger: #ff8b81;
    --ok: #6fd6a2;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 calc(72px + env(safe-area-inset-bottom));
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

img { max-width: 100%; height: auto; }
svg { width: 24px; height: 24px; fill: currentColor; }
a { color: var(--green); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: -999px;
  background: var(--surface); padding: 12px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* --- chrome --- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px var(--pad);
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; text-decoration: none; color: var(--ink);
}

main { padding: var(--pad); max-width: 900px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: var(--tap); padding: 8px 4px;
  font-size: 12px; text-decoration: none; color: var(--ink-soft);
}
.tab.is-active { color: var(--green); font-weight: 600; }
.tab-primary svg { fill: var(--green); }

/* --- type --- */

.hero h1 { font-size: 20px; line-height: 1.35; margin: 4px 0 16px; }
.page-title { font-size: 24px; margin: 0 0 12px; }

.hint { color: var(--ink-soft); font-size: 14px; margin: 6px 0; }
.hint.center { text-align: center; }

/* --- search + chips --- */

.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input {
  flex: 1; min-height: var(--tap); padding: 0 14px; font-size: 16px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.searchbar button {
  min-width: var(--tap); min-height: var(--tap);
  border: none; border-radius: var(--radius);
  background: var(--green); color: #fff;
}
.searchbar button svg { fill: #fff; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; }
.chip {
  flex: 0 0 auto; padding: 10px 14px; min-height: 44px;
  display: inline-flex; align-items: center;
  border: 2px solid var(--line); border-radius: 999px;
  text-decoration: none; color: var(--ink); font-size: 14px; background: var(--surface);
}
.chip.is-active { border-color: var(--green); color: var(--green); font-weight: 600; }

/* --- cards --- */

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.card-media { position: relative; aspect-ratio: 4 / 3; background: var(--bg); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  color: var(--line);
}
.card-media-empty svg { width: 48px; height: 48px; }
.card-body { padding: 10px; }
.card-title { font-size: 15px; margin: 0 0 6px; line-height: 1.3; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.card-date { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.pill {
  display: inline-block; padding: 3px 8px; font-size: 12px;
  border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
}
.pill-price { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }

.badge {
  position: absolute; top: 8px; left: 8px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.badge-done { background: var(--ink); color: var(--bg); }

/* --- forms --- */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; }
.field > span, .field > legend { font-weight: 600; font-size: 15px; }
.field em { font-style: normal; font-weight: 400; color: var(--ink-soft); font-size: 13px; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }

input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
textarea { min-height: 88px; resize: vertical; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

.photo-picker {
  display: block; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 24px 16px; text-align: center; cursor: pointer;
  min-height: 160px;
}
.photo-picker img { border-radius: var(--radius); }
.photo-picker-prompt { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-soft); }
.photo-picker-prompt strong { color: var(--ink); font-size: 17px; }
.photo-picker-prompt small { max-width: 30ch; }

/* Location picker on the new-listing form. Tall enough to actually aim at on a
   phone; nobody can place a pin accurately in a 200px strip. */
.manual-coords summary { min-height: 44px; display: flex; align-items: center; color: var(--green); }
.pick-map { height: 260px; border-radius: var(--radius); margin: 8px 0 4px; background: var(--bg); }
.pick-map .leaflet-container { border-radius: var(--radius); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 20px;
  border: 2px solid transparent; border-radius: var(--radius);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button-primary { background: var(--green); color: #fff; }
.button-secondary { background: var(--surface); color: var(--green); border-color: var(--green); }
.button-block { width: 100%; margin-top: 8px; }
.button svg { fill: currentColor; }

.link-button {
  background: none; border: none; font: inherit; color: var(--green);
  min-height: 44px; padding: 0 8px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
}
.inline-form { display: inline; }

/* --- panels, alerts, notes --- */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--pad); margin-top: 20px;
}
.panel h2 { font-size: 18px; margin: 0 0 8px; }
.panel > summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--green); }

.alert { padding: 12px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 15px; }
.alert-error { background: #fdeceb; color: var(--danger); border: 1px solid var(--danger); }
.alert-ok { background: #e8f5ee; color: var(--ok); border: 1px solid var(--ok); }
.alert-done { background: var(--bg); border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) {
  .alert-error, .alert-ok { background: var(--surface); }
}

.safety-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; font-size: 14px; color: var(--ink-soft);
  margin: 16px 0;
}
.safety-note svg { flex: 0 0 auto; fill: var(--green); }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty .button { margin-top: 12px; }

/* --- detail --- */

.detail-image { width: 100%; border-radius: var(--radius); background: var(--bg); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.detail-byline { color: var(--ink-soft); font-size: 14px; margin: 0 0 12px; }
.detail-body { white-space: pre-wrap; margin-bottom: 16px; }

.messages, .my-listings { list-style: none; padding: 0; margin: 0 0 16px; }
.message { border-top: 1px solid var(--line); padding: 12px 0; }
.message-head { display: flex; gap: 8px; font-size: 14px; margin: 0 0 4px; }
.message-head time { color: var(--ink-soft); }
.message-body { margin: 0; white-space: pre-wrap; }
.my-listings li { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.my-listings .badge { position: static; }

/* --- maps --- */

.map { height: 70vh; min-height: 320px; border-radius: var(--radius); background: var(--bg); }
.map-loading { padding: 20px; color: var(--ink-soft); text-align: center; }
.mini-map { height: 200px; border-radius: var(--radius); margin: 16px 0 4px; background: var(--bg); }
.map-hint { text-align: center; }
.leaflet-container { border-radius: var(--radius); font: inherit; }
