/* Black and white, like the app. */
:root {
  --text: #111;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --soft: #f3f3f3;
  --bg: #fff;
  --danger: #c62828;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin-top: .5rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { flex: 1; }
.hint { display: block; color: var(--muted); font-size: .85rem; font-weight: normal; margin: .15rem 0 .3rem; }

/* Inputs and buttons */
label { display: block; font-weight: 600; font-size: .9rem; margin: .7rem 0; }
input, textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: .3rem;
  font: inherit; font-weight: normal; padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--text); outline-offset: -1px; }
input:invalid.touched, textarea:invalid.touched { border-color: var(--danger); }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--soft); color: var(--text);
}
button:hover { border-color: var(--text); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--text); color: #fff; border-color: var(--text); }
button.danger { background: none; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; padding: 0; }
.message { color: var(--danger); min-height: 1.2em; }
.message.ok { color: var(--text); }

/* Log in */
.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .8rem 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 1000;
}
.page { max-width: 960px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar input[type=search] { flex: 1; min-width: 200px; margin: 0; }

/* The Draft / Review / Published switch */
.segmented { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 2px; }
.segmented button { border: none; background: none; border-radius: 999px; padding: .4rem .9rem; font-weight: 500; }
.segmented button.active { background: var(--bg); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.15); }

/* Status labels */
.badge { font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 0; background: var(--soft); text-transform: capitalize; }
.badge:empty { display: none; }
.badge.published { background: var(--text); color: #fff; }
.badge.review { border: 1px solid var(--text); background: none; }

/* The list */
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: .5rem; border-bottom: 1px solid var(--line); }
.list th button.sort { all: unset; cursor: pointer; }
.list th button.sort:hover, .list th button.sort.active { color: var(--text); }
.list th button.sort:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.list th button.sort::after { content: attr(data-arrow); margin-left: .3em; font-size: .7em; }
.list td { padding: .7rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.list td:nth-child(6) { white-space: nowrap; }   /* the date on one line */
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--soft); }
.list tbody tr.selected { background: var(--soft); }
/* The tick boxes in the first column */
.list .pick { width: 1.6rem; padding-right: 0; }
.list .pick input { width: auto; margin: 0; cursor: pointer; }
@media (max-width: 640px) {
  .list th:nth-child(3), .list td:nth-child(3), .list th:nth-child(6), .list td:nth-child(6) { display: none; }
}
/* The bar for the ticked buildings */
.selection-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem .8rem; margin-bottom: .6rem;
  border: 1px solid var(--text); border-radius: var(--radius); }
.selection-bar button { padding: .35rem .8rem; font-size: .85rem; }

/* The editor */
section { border-top: 1px solid var(--line); padding: .8rem 0; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row label { flex: 1; min-width: 180px; }
/* An extra renovation: year, architect and a ✕ to remove it, on one line. */
.renovation-row { align-items: flex-end; }
.renovation-row .remove-renovation { margin-bottom: .8rem; }
#map { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); }
#map .leaflet-tile-pane { filter: grayscale(1); }   /* a black and white map, like the app */
#map .leaflet-marker-pane img { filter: grayscale(1) brightness(.35); }   /* a black pin; blue is only for "your location" */
.photo-preview img { display: block; max-width: 100%; max-height: 260px; border-radius: var(--radius); }
.photo-preview p { margin: 0; }
/* Wikidata search */
.search-row { display: flex; gap: .6rem; }
.search-row input { margin: 0; }
.results { list-style: none; padding: 0; margin: .5rem 0 0; }
.results li { padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .4rem; cursor: pointer; }
.results li:hover { border-color: var(--text); }
.results small { display: block; color: var(--muted); }
.sources ul { margin: .3rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.sources a { color: var(--text); word-break: break-all; }

/* Routes */
select {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%; margin-top: .3rem;
}
.search-row select { margin: 0; flex: 1; }
#city-filter { width: auto; margin: 0; }
fieldset.route-type { border: none; padding: 0; margin: .7rem 0; }
fieldset.route-type legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
label.choice { display: flex; gap: .6rem; align-items: flex-start; font-weight: normal; margin: .4rem 0;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
label.choice input { width: auto; margin: .2rem 0 0; }
label.choice:has(input:checked) { border-color: var(--text); }
ol.stops { list-style: none; padding: 0; margin: 0 0 .6rem; }
ol.stops li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
ol.stops .number { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--text); color: #fff;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; }
ol.stops .stop-name { flex: 1; }
ol.stops button { padding: .3rem .6rem; }
#route-map { height: 300px; border-radius: var(--radius); border: 1px solid var(--line); margin-top: .8rem; }
#route-map .leaflet-tile-pane { filter: grayscale(1); }
.stop-marker { width: 24px; height: 24px; border-radius: 50%; background: var(--text); color: #fff;
  display: grid; place-items: center; font: 700 12px/1 -apple-system, sans-serif; border: 2px solid #fff; box-sizing: border-box; }

details summary { cursor: pointer; font-weight: 600; font-size: .9rem; margin: .5rem 0; }
.actions {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; border-top: 1px solid var(--line);
  z-index: 1001;   /* above the maps (Leaflet uses up to 1000) */
}

/* Typology: a dropdown with tick boxes */
.field { margin: .7rem 0; }
.field-label { display: block; font-weight: 600; font-size: .9rem; }
details.multi-select { margin-top: .3rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
details.multi-select[open] { border-color: var(--text); }
details.multi-select summary {
  list-style: none; cursor: pointer; padding: .55rem .7rem;
  display: flex; justify-content: space-between; gap: .5rem;
}
details.multi-select summary::-webkit-details-marker { display: none; }
details.multi-select summary::after { content: "▾"; color: var(--muted); }
details.multi-select[open] summary::after { content: "▴"; }
details.multi-select summary.empty { color: var(--muted); }
.multi-select-panel { border-top: 1px solid var(--line); padding: .3rem .7rem .7rem; max-height: 320px; overflow: auto; }
.typology-row { display: flex; align-items: center; gap: .3rem; }
.typology-row label { flex: 1; display: flex; align-items: center; gap: .55rem; font-weight: normal; margin: .25rem 0; cursor: pointer; }
.typology-row input[type=checkbox] { width: auto; margin: 0; }
.typology-row button { padding: .15rem .5rem; font-weight: normal; background: none; border-color: transparent; color: var(--muted); }
.typology-row button:hover { border-color: var(--line); color: var(--text); }
.add-row { display: flex; gap: .4rem; margin-top: .5rem; }
.add-row input { margin: 0; }

/* Tasks */
details.task-group { border-top: 1px solid var(--line); padding: .4rem 0 .8rem; }
details.task-group > summary { display: flex; align-items: center; gap: .6rem; font-size: 1rem; margin: .4rem 0; }
.task-group-title { font-weight: 700; }
.task-group > summary .muted { font-weight: normal; font-size: .85rem; }
ul.task-list { list-style: none; padding: 0; margin: 0; }
li.task { display: flex; align-items: flex-start; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
li.task .badge { margin-top: .45rem; flex: none; }
.task-status { background: none; border: none; padding: .25rem .4rem; font-size: 1.15rem; line-height: 1; flex: none; }
.task-text { all: unset; flex: 1; cursor: pointer; padding: .35rem .3rem; border-radius: 6px; }
.task-text:hover { background: var(--soft); }
.task-text:focus-visible { outline: 2px solid var(--text); }
.task-text small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 640px; }
li.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.version-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .7rem; }
.version-actions button { padding: .35rem .8rem; font-size: .85rem; }
dialog#task-dialog, dialog#change-dialog { border: none; border-radius: var(--radius); padding: 1.2rem 1.4rem;
  width: min(560px, calc(100vw - 32px)); box-sizing: border-box; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog#task-dialog::backdrop, dialog#change-dialog::backdrop { background: rgba(0,0,0,.35); }

/* Changelog: uses the task styles above; the date sits on the right of each change. */
li.change .change-date { color: var(--muted); font-size: .85rem; margin-top: .45rem; flex: none; }
li.change .badge { min-width: 4.6rem; text-align: center; }
.dialog-actions { display: flex; gap: .6rem; align-items: center; margin-top: .6rem; }

/* Buildings as a photo grid (List / Grid switch) */
.grid-sort { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.grid-sort select { width: auto; margin: 0; padding: .4rem .6rem; }
.grid-sort button { padding: .4rem .7rem; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.tile { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.tile:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.tile-photo { position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  background: var(--soft); display: grid; place-items: center; margin-bottom: .35rem; }
.tile-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.tile:hover .tile-photo img { transform: scale(1.04); }
.tile-photo > span:not(.badge):not(.tile-star) { color: var(--muted); font-size: .85rem; }
.tile-photo .badge { position: absolute; top: .5rem; left: .5rem; }
.tile-photo .badge.draft { background: var(--bg); }
.tile-star { position: absolute; bottom: .4rem; right: .55rem; color: #fff; font-size: 1.1rem; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
/* The tick box in a tile's top right corner; a ticked tile gets a dark frame. */
.tile-wrap { position: relative; min-width: 0; }
.tile-wrap > .tile { width: 100%; box-sizing: border-box; }
.tile-pick { position: absolute; top: .5rem; right: .5rem; width: 1.15rem; height: 1.15rem; margin: 0; cursor: pointer; accent-color: var(--text); }
.tile-wrap.selected .tile-photo { outline: 3px solid var(--text); outline-offset: -3px; }
.tile strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; } }

/* Photos: choosing from Wikimedia Commons and cropping */
.photo-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: .5rem 0; }
dialog.wide-dialog { border: none; border-radius: var(--radius); padding: 1.2rem 1.4rem;
  width: min(960px, calc(100vw - 32px)); box-sizing: border-box; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.wide-dialog::backdrop { background: rgba(0,0,0,.35); }
label.inline-check { display: flex; gap: .5rem; align-items: center; font-weight: normal; }
label.inline-check input { width: auto; margin: 0; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: .8rem;
  max-height: 60vh; overflow-y: auto; padding: 2px; }
.picker-tile { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: .2rem; min-width: 0; font-size: .8rem; }
.picker-tile:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: var(--radius); }
.picker-tile img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--radius); background: var(--soft); }
.picker-tile:hover img { outline: 3px solid var(--text); }
.picker-tile[aria-disabled=true] { cursor: not-allowed; opacity: .45; }
.picker-tile[aria-disabled=true]:hover img { outline: none; }
.picker-tile .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-tile .tag { align-self: flex-start; background: var(--soft); border-radius: 999px; padding: 0 .5rem; font-weight: 600; }
.crop-area { margin: .8rem 0 .3rem; height: min(60vh, 520px); background: var(--soft); }
.crop-area img { display: block; max-width: 100%; }
