:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: #2b303b;
  --text: #e7e9ee;
  --muted: #9aa2b1;
  --accent: #ff5c39;
  --ok: #3ecf8e;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Author `display` rules below would otherwise beat the UA sheet. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- chrome */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand h1 { font-size: 16px; margin: 0; letter-spacing: .2px; }

.dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 92, 57, .18);
}

nav { display: flex; gap: 6px; }

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.tab-link { display: inline-flex; align-items: center; }

main { flex: 1 1 auto; min-height: 0; }

.view { height: 100%; }
#view-add { overflow-y: auto; }

/* ------------------------------------------------------------------- map */

#view-map { display: flex; min-height: 0; height: 100%; }

#map { flex: 1 1 auto; min-width: 0; background: #10131a; }

.panel {
  width: 330px;
  flex: 0 0 330px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }

.list li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list li:hover { background: var(--surface-2); }
.list img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.list .addr { font-weight: 600; font-size: 14px; }
.list .meta { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ form */

.form {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  display: grid;
  gap: 18px;
}

.form h2 { margin: 0; font-size: 22px; }

.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field > span, .field > legend { font-weight: 600; font-size: 14px; padding: 0; }
.field em { color: var(--muted); font-style: normal; font-weight: 400; }

input[type=text], input[type=search], input[type=file], select, textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; gap: 8px; }
.row input { flex: 1 1 auto; }

.btn, .btn-sec {
  border-radius: var(--radius);
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn { background: var(--accent); color: #14100e; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sec { background: var(--surface-2); border-color: var(--line); color: var(--text); }

.muted { color: var(--muted); font-size: 13px; }
.fineprint { color: var(--muted); font-size: 12.5px; margin: 0; }

.note {
  background: rgba(62, 207, 142, .12);
  border: 1px solid rgba(62, 207, 142, .35);
  color: var(--ok);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}

.status { min-height: 20px; font-size: 14px; margin: 0; }
.status.err { color: #ff8a70; }
.status.ok { color: var(--ok); }

#pickmap { height: 280px; border-radius: var(--radius); border: 1px solid var(--line); }

#preview-wrap img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }

.geo-results { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.geo-results li { padding: 8px 10px; cursor: pointer; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.geo-results li:last-child { border-bottom: 0; }
.geo-results li:hover { background: var(--surface-2); }

/* --------------------------------------------------------------- popups */

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content { margin: 10px 12px; width: 230px !important; }
.leaflet-popup-content img { width: 100%; border-radius: 6px; display: block; margin-bottom: 8px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pop-title { font-weight: 600; }
.pop-meta { color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- admin */

.admin { max-width: 900px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.card-grid { display: grid; grid-template-columns: 220px 1fr; gap: 14px; }
.card-grid img { width: 100%; border-radius: 6px; }
.card h3 { margin: 0; font-size: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.filters { display: flex; gap: 8px; align-items: center; }
.prose { max-width: 680px; margin: 0 auto; padding: 24px 16px 64px; }
.prose h2 { font-size: 20px; }
.prose a { color: var(--accent); }

@media (max-width: 760px) {
  #view-map { flex-direction: column; }
  .panel { width: auto; flex: 0 0 45%; border-left: 0; border-top: 1px solid var(--line); }
  #map { flex: 1 1 55%; }
  .card-grid { grid-template-columns: 1fr; }
}
