:root {
  --bg: #f6f4ee; --panel: #fffdf8; --ink: #1f2a24; --muted: #66716a;
  --line: #ddd8cb; --accent: #2f6b4f; --accent-ink: #fff; --soft: #e6efe9;
  --warn: #9a5b13; --field: #fff; --soft-line: #c9dccf; --tag: #efeadd; --tag-approx: #f6e6cf;
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131815; --panel: #1a211d; --ink: #e6ebe7; --muted: #a0aba4;
    --line: #37413b; --accent: #6fbf94; --accent-ink: #0f1a14; --soft: #26332b;
    --warn: #e6b36a; --field: #222a25; --soft-line: #3d5245; --tag: #2b332e; --tag-approx: #46351c;
  }
  .leaflet-tile-pane { filter: brightness(.82); } /* dim the light map a little; tiles still come only from OpenStreetMap */
  .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); }
  .leaflet-bar a, .leaflet-bar a:hover { background: var(--panel); color: var(--ink); border-color: var(--line); }
  .leaflet-container .leaflet-control-attribution { background: rgba(26, 33, 29, .85); color: var(--muted); }
  .leaflet-container .leaflet-control-attribution a { color: var(--accent); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* layout rules like .row must not override it */
html, body { height: 100%; margin: 0; background: var(--bg); }
body { display: grid; grid-template-columns: minmax(340px, 430px) 1fr; }
#panel { height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 16px; }
#map { height: 100vh; }
/* The logo's wordmark: Outfit, served from the site itself (SIL OFL, see fonts/OFL.txt). */
@font-face { font-family: Outfit; font-weight: 600; font-display: swap; src: url(fonts/outfit-600-latin.woff2) format('woff2'); }
h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
h1 a { display: inline-flex; align-items: center; gap: 9px; font-family: Outfit, system-ui, sans-serif; font-weight: 600; text-transform: lowercase; }
h1 .logo { width: 28px; height: 28px; flex: none; }
/* The Om link opens the window about the project; it sits just right of the name. */
.titlerow { display: flex; align-items: center; gap: 10px; }
#about { flex: none; font-size: .85rem; }
dialog#aboutDialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 18px 20px; max-width: min(34rem, calc(100vw - 32px)); max-height: min(80vh, 80dvh); overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
dialog#aboutDialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog#aboutDialog h2 { margin: 0 0 8px; font-size: 1.1rem; }
dialog#aboutDialog p { margin: 0 0 8px; }
dialog#aboutDialog a { color: var(--accent); }
.about-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.tagline { margin: 2px 0 14px; color: var(--muted); }
.muted { color: var(--muted); font-size: .87rem; }

fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
legend { padding: 0; margin-bottom: 5px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 100%; }
/* Each filter group folds out and in (issue #22); folded, it shows a line with what is chosen. */
.grouphead { display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 32px; border: 0; background: none; padding: 4px 0; text-align: left; font: inherit; color: inherit; }
.grouphead::before { content: "▾"; font-size: .9em; width: 1em; flex: none; }
.grouphead[aria-expanded="false"]::before { content: "▸"; }
.gsum { font-size: .87rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grouphead[aria-expanded="true"] .gsum { display: none; }
fieldset:has(.grouphead[aria-expanded="false"]) { margin-bottom: 0; }
.row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.row > input[type=search] { flex: 1 1 120px; min-width: 0; }
input[type=search], select, button { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--field); padding: 7px 9px; }
select option { background: var(--field); color: var(--ink); } /* the open drop-down list */
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#addressGo { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#locate { font-size: 1.1rem; line-height: 1; padding: 6px 9px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
.check { display: flex; gap: 6px; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border-radius: 999px; padding: 4px 10px; font-size: .87rem; background: var(--field); }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip small { opacity: .65; margin-left: 3px; }

/* The name stays at the top of the panel, like a home button; the list's heading sticks just below it. */
#panel > header { position: sticky; top: -16px; z-index: 3; background: var(--panel); margin: -16px -16px 0; padding: 16px 16px 10px; }
#panel > header h1 a { color: inherit; text-decoration: none; }
#panel > header h1 a:hover { text-decoration: underline; }
.listhead { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0 8px; border-top: 1px solid var(--line); position: sticky; top: calc(var(--head-h, 0px) - 16px); background: var(--panel); z-index: 2; }
#shareMsg { margin: 0 0 8px; font-size: .85rem; overflow-wrap: anywhere; }
.seg { display: flex; }
.seg button { border-radius: 0; padding: 5px 10px; font-size: .87rem; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.seg button[aria-pressed=true] { background: var(--soft); border-color: var(--accent); font-weight: 600; }

.group > h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; display: flex; justify-content: space-between; gap: 8px; }
.group > h2 a { color: inherit; }
.ev { display: grid; grid-template-columns: 46px 1fr; gap: 10px; padding: 9px 8px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; }
.ev:hover, .ev.active { background: var(--soft); border-color: var(--soft-line); }
.ev.past { opacity: .6; }
.date { text-align: center; line-height: 1.05; padding-top: 2px; }
.date b { display: block; font-size: 1.25rem; }
.date span { font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.ev h3 { margin: 0 0 2px; font-size: .98rem; line-height: 1.25; }
.meta { font-size: .85rem; color: var(--muted); }
.tags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: var(--tag); }
.tag.fmt { background: var(--soft); }
.tag.approx { background: var(--tag-approx); color: var(--warn); }
.more { display: none; margin-top: 6px; font-size: .88rem; white-space: pre-line; }
.ev.open .more { display: block; }
.more a { color: var(--accent); font-weight: 600; margin-right: 10px; }
.empty { padding: 24px 8px; color: var(--muted); text-align: center; }
footer { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); }
footer a { color: inherit; }

.pin { background: #2f6b4f; color: #fff; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.4); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.pin.approx { background: #c98a2b; border-style: dashed; }
.pin.active { background: #12382a; transform: scale(1.2); }
#map.placing { cursor: crosshair; }
#pin[aria-pressed=true] { background: var(--soft); border-color: var(--accent); }
.origin { cursor: grab; }
.me { background: #1d6fd6; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px #1d6fd6; }
.leaflet-popup-content { margin: 10px 12px; font: inherit; font-size: .88rem; }
.leaflet-popup-content h4 { margin: 0 0 4px; font-size: .9rem; }
.leaflet-popup-content ul { margin: 0; padding: 0; list-style: none; max-height: min(55vh, 420px); overflow-y: auto; }
.leaflet-popup-content li { padding: 6px 0; border-top: 1px solid var(--line); }
.leaflet-popup-content li:first-child { border-top: 0; }
.leaflet-popup-content .tags { margin: 4px 0 2px; }
.leaflet-popup-content details { margin: 4px 0; }
.leaflet-popup-content summary { cursor: pointer; color: var(--muted); }
.leaflet-popup-content .summary { white-space: pre-line; margin-top: 4px; }
.leaflet-popup-content .links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 14px; margin-top: 2px; }
.leaflet-popup-content button { border: 0; background: none; padding: 0; text-align: left; color: var(--accent); font-weight: 600; }
.leaflet-popup-content li a { color: var(--accent); white-space: nowrap; display: inline-block; padding: 4px 0; }

/* Phones, upright or on their side (#22, #20): the map fills the screen and the panel is a
   sheet over it, folded (peek), showing the list (list) or the search and filters (search). */
.sheetnav { display: none; }
@media (max-width: 760px), (max-height: 520px) {
  body { display: block; }
  #map { position: fixed; inset: 0; height: auto; z-index: 0; }
  #panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; border-right: 0;
    border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, .18);
  }
  body[data-sheet="peek"] #panel { height: auto; overflow: hidden; }
  body[data-sheet="peek"] #panel > :not(header) { display: none; }
  body[data-sheet="peek"] .tagline { display: none; }
  body[data-sheet="list"] #panel { height: 55vh; height: 55dvh; }
  body[data-sheet="search"] #panel { height: calc(100vh - 48px); height: calc(100dvh - 48px); }
  #panel > header { border-radius: 14px 14px 0 0; }
  .tagline { margin-bottom: 8px; }
  .sheetnav { display: flex; gap: 8px; margin-top: 8px; }
  .sheetnav button { flex: 1; padding: 9px 10px; font-weight: 600; }
  /* On the left Lista or Kartan; on the right always Sök och filter, marked while it shows. */
  body:not([data-sheet="list"]) #toMap, body[data-sheet="list"] #toList { display: none; }
  body[data-sheet="list"] #toMap { order: -1; }
  #toSearch[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); }
}
/* A phone on its side: the panel is a column on the left, folded to a card in the corner. */
@media (max-height: 520px) and (orientation: landscape) {
  #panel {
    top: 0; right: auto; width: min(46vw, 400px); border-top: 0; border-right: 1px solid var(--line);
    border-radius: 0 14px 14px 0; box-shadow: 4px 0 16px rgba(0, 0, 0, .18);
  }
  body[data-sheet="peek"] #panel { bottom: auto; border-radius: 0 0 14px 0; }
  body[data-sheet="list"] #panel, body[data-sheet="search"] #panel { height: 100vh; height: 100dvh; }
  #panel > header { border-radius: 0; }
}

.morebtn { display: block; width: 100%; margin-top: 12px; }

#license { margin: 6px 0 0; }
#license a { color: inherit; }

.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.date-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.date-field label { font-size: .87rem; }
.date-field input[type=date] { width: 100%; min-width: 0; font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--field); padding: 6px 8px; }
#fits { flex: 1 1 auto; min-width: 0; }
