/* Flog It. Mobile first: most visitors arrive from a WhatsApp link on a mid-range phone. */

:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b655d;
  --border: #e6e0d6;
  --accent: #1f6f5c;          /* green: actions */
  --accent-text: #ffffff;
  --highlight: #c96a12;       /* amber: prices */
  --radius: 12px;
  --danger: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --danger: #f2b8b5;
    --bg: #1c1a17;
    --surface: #26231f;
    --text: #f1ece4;
    --muted: #a59d92;
    --border: #3a362f;
    --accent: #4fb89c;
    --accent-text: #10201b;
    --highlight: #f0a14a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
a, button, input, select, textarea { touch-action: manipulation; }
input, select, textarea { font-size: 16px; } /* smaller makes iOS zoom in on focus */
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.4em 0 0.5em; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner, main, .footer-inner {
  max-width: 960px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.topbar-inner { display: flex; align-items: center; min-height: 52px; }
.brand { font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }

main { flex: 1; width: 100%; padding-top: 16px; padding-bottom: 32px; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 12px; margin: -8px 0 0 -12px;
  text-decoration: none; font-weight: 500;
}
.back-link span { font-size: 1.4rem; line-height: 1; }
.back-link + h1 { margin-top: 0; }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.hero { padding: 24px 0 8px; max-width: 34rem; }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.02em; }
.lede { font-size: 1.1rem; color: var(--muted); }

.footer {
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  color: var(--muted); font-size: 0.85rem;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 14px; padding-bottom: 14px; }
.footer a { color: var(--muted); }

/* Top bar: the brand on the left, Log in or Me on the right. */
.topnav { margin-left: auto; display: flex; gap: 4px; }
.topnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; margin-right: -12px; font-weight: 600; text-decoration: none; }

h2 { font-size: 1.2rem; margin: 1.4em 0 0.4em; }
.muted { color: var(--muted); }

/* Forms: one column, labels above boxes, full width on a phone. */
.stack-form { display: grid; gap: 6px; max-width: 28rem; margin-bottom: 16px; }
.stack-form label { font-weight: 600; margin-top: 10px; }
.stack-form .button { margin-top: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel] {
  font: inherit; font-size: 16px; width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.help { margin: 0; color: var(--muted); font-size: 0.9rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400 !important; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--accent); }
.error { margin: 6px 0 0; color: #b3261e; font-weight: 600; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a80; } }
.plain-list { list-style: none; padding: 0; margin: 0 0 16px; }
.plain-list li { padding: 6px 0; }

/* The Show / Hide button sits inside the right-hand end of the password box (added by app.js). */
.password-field { position: relative; }
.password-field input { padding-right: 76px; }
.password-toggle {
  position: absolute; top: 0; right: 0; height: 100%; min-width: 68px; padding: 0 12px;
  background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer;
}

/* Garages (Phase 3) */
textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); resize: vertical;
}
.status { margin: -0.3em 0 1em; color: var(--muted); }
.status-public, .status-unlisted { color: var(--accent); font-weight: 600; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px dashed var(--border); }
.map-form { display: grid; gap: 10px; max-width: 40rem; margin-bottom: 16px; }
.map-form[hidden], .map-nojs[hidden] { display: none; }
.map { height: min(60vh, 420px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.map-form .button { justify-self: start; }
.button:disabled { opacity: 0.5; cursor: default; }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.garage-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.garage-list a { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); }
.garage-list strong { display: block; }
.garage-list .muted { font-size: 0.9rem; }

/* Items (Phase 4) */
select {
  font: inherit; font-size: 16px; width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.price-field { position: relative; }
.price-field span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.price-field input { padding-left: 32px; }
.chips { border: 0; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-actions { display: grid; gap: 10px; margin-top: 8px; }
.form-actions .button { margin-top: 0; }
@media (min-width: 641px) { .form-actions { display: flex; flex-wrap: wrap; } }
/* Photos (Phase 5). Without JavaScript the plain file input shows; app.js adds .enhanced, which swaps
   it for the "Add photos" button (the label, so it still opens the picker) and previews. */
.photos { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; justify-items: start; }
.photos legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.photo-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; width: 100%; }
.photo-grid li { display: grid; gap: 6px; align-content: start; }
.photo-grid img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--border); }
.photo-grid li:first-child img { outline: 3px solid var(--accent); outline-offset: -3px; }
.photo-grid .check { font-size: 0.95rem; align-items: center; min-height: 32px; }
.photo-grid .is-new img { opacity: 0.9; }
.photo-pick { display: none; margin-top: 0; }
.photos.enhanced .photo-pick { display: inline-flex; }
.photos.enhanced input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photos.enhanced input[type=file]:focus-visible + * { outline: 2px solid var(--accent); }
.small { font-size: 0.9rem; margin: 0; }
.autosave-status { margin: 0; min-height: 1.5em; font-size: 0.9rem; }

.item-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; max-width: 40rem; }
.item-row { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.item-row.is-draft { border-style: dashed; }
.item-main { flex: 1; min-width: 0; padding: 10px 14px; text-decoration: none; color: var(--text); display: flex; gap: 12px; align-items: center; }
.item-text { min-width: 0; }
.item-thumb { width: 56px; height: 56px; flex: none; object-fit: cover; border-radius: 8px; background: var(--border); }
.item-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main .muted { font-size: 0.9rem; }
.item-actions { display: flex; align-items: center; padding-right: 4px; }
.icon-button {
  min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--accent);
  font: inherit; font-size: 1.15rem; cursor: pointer; border-radius: 8px;
}
.icon-button:disabled { color: var(--border); cursor: default; }
.icon-button.danger { color: var(--muted); }
.flash { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.inline-form { display: inline; }
.link-button { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 32px; }

/* The public garage (Phase 6). Every image box is square and sized before the photo arrives: no jumps. */
.owner-note { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px dashed var(--border); }
.garage-meta { color: var(--muted); margin-top: -0.4em; }
.filters { display: grid; gap: 8px; margin: 12px 0 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.95rem;
}
.chip-link.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.public-grid { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.public-grid a { display: grid; gap: 6px; text-decoration: none; color: var(--text); }
.public-grid img, .no-photo { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--border); }
.no-photo { display: grid; place-items: center; color: var(--muted); font-size: 0.9rem; }
.card-text { display: grid; gap: 2px; }
.card-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-text .muted { font-size: 0.85rem; }
.price { font-weight: 700; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--border); font-size: 0.8rem; font-weight: 600; }
.item-price { font-size: 1.25rem; margin-top: -0.3em; }
.item-photos { display: grid; gap: 10px; margin: 12px 0; }
.item-photos img { width: 100%; height: auto; max-height: 80vh; object-fit: contain; border-radius: 10px; background: var(--border); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.description { white-space: pre-line; }
.share { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; max-width: 40rem; }
.share h2 { margin: 0 0 4px; }
.share-links { display: flex; flex-wrap: wrap; gap: 8px; }
.share-links .button { margin-top: 0; }
.share input { width: 100%; }
.copy-row { display: flex; gap: 8px; }
.copy-row .button { margin-top: 0; flex: none; }

/* Share page (Phase 7): the preview drawn like a WhatsApp link card. */
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row .button { margin-top: 0; }
.og-card { max-width: 30rem; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); margin: 8px 0 16px; }
.og-card img, .og-none { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; background: var(--border); }
.og-none { display: grid; place-items: center; color: var(--muted); font-size: 0.9rem; text-align: center; padding: 0 16px; }
.og-text { display: grid; gap: 2px; padding: 8px 12px 10px; font-size: 0.9rem; }
.og-text span { color: var(--muted); }
.cover-choices { border: 0; padding: 0; margin: 0; }
.cover-choices legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.cover-choice { display: grid; gap: 4px; cursor: pointer; font-weight: 400 !important; font-size: 0.9rem; }
.cover-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cover-choice img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 3px solid transparent; }
.cover-choice input:checked + img { border-color: var(--accent); }
.cover-choice input:focus-visible + img { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Messages (Phase 8) */
.safety-note { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 0.9rem; }
.thread-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-width: 40rem; }
.thread-list a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); }
.thread-list a.unread { border-color: var(--accent); }
.thread-list .badge { justify-self: start; background: var(--accent); color: var(--accent-text); }
.messages { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; max-width: 40rem; }
.messages li { max-width: 85%; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.messages li.mine { justify-self: end; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.messages li.mine .muted { color: inherit; opacity: 0.8; }
.messages p { margin: 0 0 4px; white-space: pre-line; overflow-wrap: anywhere; }
.phone-shared { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--accent); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.inline-actions .button { margin-top: 0; }
.item-status { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); max-width: 40rem; }
.item-status .button-row form { display: inline; }
.sold-form { margin-top: 12px; }
.block-form { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.danger-text { color: var(--muted); }
.item-row.is-sold { opacity: 0.7; }
.interest { font-size: 1.05rem; }

/* Safety, reports, admin (Phase 9) */
.prose { max-width: 40rem; }
.prose h1 { margin-top: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.report-link { margin-top: 24px; font-size: 0.9rem; }
.report-link a { color: var(--muted); }
.reasons { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.reasons legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.report-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 48rem; }
.report-list > li { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.report-list blockquote { margin: 0 0 8px; padding-left: 12px; border-left: 3px solid var(--border); white-space: pre-line; }
.report-list .button-row form { display: inline; }
.button.danger { border-color: var(--danger); color: var(--danger); }
.numbers { border-collapse: collapse; width: 100%; max-width: 48rem; margin-bottom: 16px; }
.numbers th, .numbers td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.numbers td:nth-child(2) { font-weight: 700; white-space: nowrap; }
.numbers td.muted { font-size: 0.85rem; }
