:root {
  --bg: #1a1712;
  --panel: #242019;
  --panel-2: #2e2921;
  --ink: #f3ede1;
  --muted: #b3a894;
  --accent: #e0913a;
  --accent-ink: #1a1712;
  --border: #3a3428;
  --danger: #e0603a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.4rem; }
.tagline { margin: 0; color: var(--muted); flex: 1; font-size: 0.9rem; }

.nav { display: flex; gap: 0.25rem; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.9rem;
}
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.active { background: var(--panel-2); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

main {
  display: flex;
  height: calc(100vh - 64px);
}
#map { flex: 1; height: 100%; }

#sidebar {
  width: 340px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
}
.sidebar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.sidebar-header h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.count { color: var(--muted); font-size: 0.85rem; }

#sightings-list { list-style: none; margin: 0; padding: 0; }
#sightings-list li {
  padding: 0.7rem;
  border-radius: 8px;
  background: var(--panel-2);
  margin-bottom: 0.6rem;
  cursor: pointer;
  border: 1px solid transparent;
}
#sightings-list li:hover { border-color: var(--accent); }
.li-when { font-weight: 600; font-size: 0.9rem; }
.li-notes { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }
.li-meta { color: var(--muted); font-size: 0.75rem; margin-top: 0.35rem; }
.li-thumb { width: 100%; border-radius: 6px; margin-top: 0.5rem; max-height: 140px; object-fit: cover; }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-card h2 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0; }

#report-form label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
}
#report-form input,
#report-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
#report-form input[type="file"] { padding: 0.35rem; }

.loc-picked output {
  display: block;
  margin-top: 0.3rem;
  padding: 0.5rem;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-weight: 400;
}
.loc-picked output.set { color: var(--accent); border-style: solid; }

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}
.hidden { display: none; }

/* --- Feed page ------------------------------------------------------------ */
.feed-main {
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 1.25rem;
}
.feed-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.filter { color: var(--muted); font-size: 0.9rem; cursor: pointer; }
.filter input { vertical-align: middle; margin-right: 0.3rem; }

/* Single-column infinite scroll feed: centered, full-media width */
.feed-main { display: block; } /* override global main:flex to allow natural scrolling */
.feed-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  padding-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}
.feed-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: block;
  width: min(760px, 96%);
  max-width: 760px;
  /* normalize overall card height so cards align visually like Reddit */
  height: 560px; /* fixed card height for consistent layout */
}
.feed-media {
  position: relative; /* anchor play-badge inside media */
  display: block;
  background: var(--panel-2);
  line-height: 0;
  width: 100%;
  overflow: hidden;
  /* normalized preview area similar to common feed conventions */
  height: 360px;
}
/* images fill and are cropped to the preview area like Reddit-style previews */
.feed-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover; /* crop to fill the box */
  margin: 0;
}
/* feed body: fixed area below media; scroll internally if content overflows */
.feed-body {
  padding: 0.75rem;
  box-sizing: border-box;
  height: calc(560px - 360px);
  overflow-y: auto;
}

.media-broken .feed-media { display: none; } /* hide cards whose image 404s */

.play-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 50%;
  font-size: 1.2rem;
  padding-left: 4px;
  z-index: 20; /* sit above media */
  pointer-events: none; /* let clicks pass through to the link */
}
.src-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--ink);
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.feed-body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; }
.feed-notes { margin: 0; font-size: 0.9rem; line-height: 1.35; }
.feed-meta { color: var(--muted); font-size: 0.78rem; display: flex; gap: 0.4rem; }
.feed-links { display: flex; gap: 0.9rem; margin-top: 0.15rem; }
.feed-links a { color: var(--accent); text-decoration: none; font-size: 0.8rem; font-weight: 600; }
.feed-links a:hover { text-decoration: underline; }

.feed-empty { color: var(--muted); text-align: center; margin-top: 3rem; }
.feed-empty code { background: var(--panel-2); padding: 0.1rem 0.35rem; border-radius: 4px; }

.feed-load-more { width: 100%; display: flex; justify-content: center; padding: 0.75rem 0; }

/* Video marker in map popup */
.popup-media { position: relative; }
.popup-play {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 999px;
}

/* Raccoon map pin */
.leaflet-marker-icon { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45)); }

/* Leaflet popup tweaks */
.leaflet-popup-content { font-size: 0.85rem; }
.leaflet-popup-content img { width: 100%; border-radius: 6px; margin-top: 0.4rem; }
