:root {
  --nav-h: 60px;
  --side-w: 360px;
  --accent: #8c1d18;
  --accent-soft: #f6e9e7;
  --text: #222;
  --muted: #666;
  --line: #ddd;
  --bg: #fff;
  --panel: #fafafa;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---- navbar ---- */
.navbar {
  height: var(--nav-h);
  flex: 0 0 var(--nav-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  z-index: 1000;
}
.logo {
  height: 44px; width: auto; flex: 0 0 auto;
  background: #fff; border-radius: 6px; padding: 3px 8px;
}
.titles { min-width: 0; }
.titles h1 { font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p { font-size: 12px; margin: 2px 0 0; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: transparent; border: 1px solid rgba(255, 255, 255, .5); color: #fff;
  font-size: 20px; width: 38px; height: 38px; border-radius: 6px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .15); }

/* ---- layout ---- */
.main { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; min-width: 0; }
.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition: margin-left .2s ease;
  min-height: 0;
}
body.sidebar-collapsed .sidebar { margin-left: calc(-1 * var(--side-w)); }

/* ---- tabs ---- */
.tabs { display: flex; border-bottom: 1px solid var(--line); background: #fff; }
.tab {
  flex: 1; padding: 11px 6px; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel { flex: 1; overflow-y: auto; padding: 12px 16px 24px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 8px; }
.panel h2:first-child { margin-top: 4px; }

/* ---- lists and controls ---- */
.check-list { list-style: none; margin: 0 0 8px; padding: 0; }
.row { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.row input { margin: 0; accent-color: var(--accent); }
.swatch { width: 16px; height: 12px; border: 2px solid; border-radius: 2px; flex: 0 0 auto; }
.n { margin-left: auto; color: var(--muted); font-size: 12px; background: #eee; border-radius: 10px; padding: 0 7px; }
.hint { color: var(--muted); font-size: 12px; }
.count { font-weight: 600; margin: 10px 0 0; }
input[type="search"] {
  width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font: inherit;
}
input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-row { display: flex; gap: 6px; margin-bottom: 4px; }
button.small {
  font: inherit; font-size: 12px; padding: 3px 10px; border: 1px solid #ccc; border-radius: 4px;
  background: #fff; cursor: pointer;
}
button.small:hover { border-color: var(--accent); color: var(--accent); }

.site-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.site-list li { border-bottom: 1px solid var(--line); }
.site-list button {
  width: 100%; text-align: left; background: none; border: 0; padding: 7px 4px; font: inherit; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-list button:hover, .site-list li.current button { background: var(--accent-soft); }
.site-list b { color: var(--accent); margin-right: 4px; }

.legend { list-style: none; margin: 0 0 6px 24px; padding: 0; font-size: 12px; color: #444; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }

/* ---- info ---- */
#info h3 { font-size: 16px; margin: 4px 0 8px; color: var(--accent); }
.site-info { line-height: 1.45; }
.site-info ul { padding-left: 18px; }
.site-info li { margin-bottom: 8px; }
.site-info small { color: var(--muted); }
.site-info div { margin-bottom: 6px; }
.tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 2px 9px; font-size: 12px; }
table.attr { border-collapse: collapse; width: 100%; font-size: 13px; }
table.attr th, table.attr td { text-align: left; vertical-align: top; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.attr th { color: var(--muted); font-weight: 600; width: 38%; }
table.attr td { white-space: pre-line; }
.ext-link {
  display: inline-block; margin-top: 10px; padding: 6px 12px; border-radius: 5px;
  background: #466eb4; color: #fff; text-decoration: none; font-weight: 600; font-size: 13px;
}
.ext-link:hover, .ext-link:focus-visible { background: #34558d; }
.error { background: #fdecea; border: 1px solid #f5c2bd; padding: 10px; border-radius: 6px; }

/* ---- map labels ---- */
.leaflet-tooltip.site-label {
  background: transparent; border: 0; box-shadow: none; padding: 0;
  color: #7a0d0e; font-weight: 600; font-size: 11px;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
}
.leaflet-tooltip.site-label::before { display: none; }
body.hide-labels .leaflet-tooltip.site-label { display: none; }
.leaflet-tooltip.area-label {
  background: #3d4a4a; color: #fff; border: 2px solid #fff; border-radius: 50%;
  width: 24px; height: 24px; padding: 0; line-height: 20px; text-align: center;
  font-size: 11px; font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.leaflet-tooltip.area-label::before { display: none; }
.leaflet-tooltip.arch-label {
  background: transparent; border: 0; box-shadow: none; padding: 0;
  color: #0b5d2a; font-weight: 700; font-size: 11px; white-space: nowrap;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
}
.leaflet-tooltip.arch-label::before { display: none; }
body.hide-labels .leaflet-tooltip.arch-label { display: none; }

/* ---- document images in the info panel ---- */
.gallery-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 4px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.gallery figure { margin: 0; }
.gallery a { display: block; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #fff; }
.gallery a:hover, .gallery a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery figcaption { font-size: 11px; color: var(--muted); line-height: 1.35; margin-top: 4px; }

/* ---- small screens: sidebar overlays the map ---- */
@media (max-width: 760px) {
  :root { --side-w: min(88vw, 360px); }
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 900; box-shadow: 2px 0 8px rgba(0, 0, 0, .2); }
  .titles h1 { font-size: 15px; }
  .titles p { display: none; }
  .logo { height: 36px; padding: 2px 5px; }
}
