/* Grenzbild — Anwendungs- und Seitenkomponenten auf den weltsein-Tokens.
   Lädt nach weltsein.css; nutzt ausschließlich deren Custom Properties. */

/* ---------------------------------------------------------------- Karten-App */

body.app { display: block; min-height: 100%; }

#app { display: flex; height: 100vh; font-size: 0.75rem; line-height: 1.5; }

#sidebar { width: 320px; padding: 1rem; overflow-y: auto; background: var(--bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.85rem; }
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.app-title { font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700;
  color: var(--text); display: flex; align-items: baseline; gap: 0.4rem; }
.app-title a { color: var(--text-muted); font-size: 0.6rem; text-decoration: none; }
.app-title a:hover { color: var(--brand); }
.app-title .spacer { margin-left: auto; }

#sidebar .hint { font-size: 0.68rem; color: var(--text-muted); line-height: 1.6; }
#sidebar .hint a { color: var(--brand); }

.section { display: flex; flex-direction: column; }
.section h2 { font-family: var(--font-mono); font-size: 0.55rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted);
  margin-bottom: 0.45rem; }

.selected { background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.5rem 0.6rem; }
.selected .nm { font-size: 0.78rem; font-weight: 700; }
.selected .lvl { color: var(--text-muted); font-size: 0.6rem; font-family: var(--font-mono);
  margin-top: 0.15rem; }
.selected { padding: 0; }
.sel-item { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border); }
.sel-item:last-child { border-bottom: none; }
.sel-text { flex: 1; min-width: 0; }
.sel-text .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-remove { flex: none; width: 1.4rem; height: 1.4rem; line-height: 1; padding: 0;
  background: transparent; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.sel-remove:hover { color: #cc3333; border-color: #cc3333; }
.section h2 { display: flex; align-items: baseline; gap: 0.5rem; }
.linkbtn { margin-left: auto; background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.linkbtn:hover { color: var(--brand); }

#sidebar label { display: block; font-family: var(--font-mono); font-size: 0.55rem;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0.25rem; }
#sidebar input[type=text], #sidebar input[type=number], #sidebar select {
  width: 100%; padding: 0.4rem 0.5rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; font-family: var(--font-body);
  font-size: 0.72rem; }
#sidebar input[type=color] { width: 100%; height: 1.9rem; padding: 2px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
#sidebar input[type=range] { width: 100%; accent-color: var(--brand); }
#sidebar input:focus, #sidebar select:focus { outline: none; border-color: var(--brand); }
.row { display: flex; gap: 0.45rem; }
.row > * { flex: 1; }
.field { margin-bottom: 0.55rem; }

.btn-row { display: grid; gap: 3px; }
.btn-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.btn-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.btn-row .chip { padding: 0.45rem 0.25rem; background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.6rem; }
.btn-row .chip:hover { border-color: var(--brand); color: var(--brand); }
.btn-row .chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.checkbox-row { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.45rem; }
.checkbox-row label { margin: 0; text-transform: none; letter-spacing: 0;
  color: var(--text); font-size: 0.72rem; font-family: var(--font-body); cursor: pointer; }
#sidebar input[type=checkbox] { accent-color: var(--brand); width: 0.8rem; height: 0.8rem; }

button.primary { width: 100%; padding: 0.6rem; background: var(--brand); color: #fff;
  border: 1px solid var(--brand); border-radius: 4px; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--brand-light); border-color: var(--brand-light); }
button.primary:disabled { background: transparent; color: var(--text-muted);
  border-color: var(--border); cursor: not-allowed; }

.status { font-size: 0.6rem; font-family: var(--font-mono); color: var(--text-muted);
  min-height: 0.9rem; margin-top: 0.3rem; }
.status.err { color: #cc3333; }
.status.ok  { color: var(--brand); }

.quick { display: flex; flex-wrap: wrap; gap: 4px; }
.quick a { font-size: 0.62rem; padding: 0.15rem 0.5rem; border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-muted); text-decoration: none;
  font-family: var(--font-mono); }
.quick a:hover { border-color: var(--brand); color: var(--brand); }

/* ------------------------------------------------- Suche über der Karte */

#mapwrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }
.leaflet-container { background: var(--bg-secondary); font-family: var(--font-body); }

#map-search { position: absolute; top: 0.6rem; left: 0.6rem; z-index: 1000;
  width: min(370px, calc(100% - 1.2rem)); display: flex; flex-direction: column; gap: 0.3rem; }
#search { width: 100%; padding: 0.55rem 0.7rem; font-size: 0.8rem; background: var(--bg);
  color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--font-body); }
#search:focus { outline: none; border-color: var(--brand); }
#search::placeholder { color: var(--text-muted); }

#results { background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  overflow: hidden auto; max-height: min(58vh, 430px); }
#results:empty { display: none; }
#results button { display: block; width: 100%; text-align: left; padding: 0.5rem 0.7rem;
  background: none; border: none; border-bottom: 1px solid var(--border); cursor: pointer;
  color: var(--text); font-family: var(--font-body); font-size: 0.75rem; }
#results button:last-child { border-bottom: none; }
#results button:hover, #results button.active { background: var(--bg-secondary); }
#results .ctx, #results .lvl { color: var(--text-muted); font-size: 0.6rem; margin-top: 1px; }
#results .lvl { font-family: var(--font-mono); }
#results .empty { padding: 0.55rem 0.7rem; color: var(--text-muted); font-size: 0.72rem; }

.search-hint { font-size: 0.6rem; color: var(--text-muted); font-family: var(--font-mono);
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.1rem 0.4rem; align-self: flex-start; }

@media (max-width: 640px) {
  #app { flex-direction: column; height: 100vh; height: 100dvh; align-items: stretch; }
  #sidebar { width: 100%; flex: 0 1 auto; border-right: none;
    border-bottom: 1px solid var(--border); }
  #mapwrap { flex: 1 1 55%; width: 100%; min-height: 220px; }
  #map-search { top: 0.4rem; left: 0.4rem; width: calc(100% - 0.8rem); }
  #results { max-height: 42vh; }
}

/* ---------------------------------------------------------------- Inhaltsseiten */

.crumbs { font-size: 0.7rem; font-family: var(--font-mono); color: var(--text-muted);
  margin-bottom: 1rem; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }

.lede { color: var(--text-muted); margin-bottom: 1rem; }
.small { font-size: 0.8rem; color: var(--text-muted); }

.hero { display: grid; grid-template-columns: 1fr 260px; gap: 1.6rem; align-items: start;
  margin-bottom: 1.6rem; }
figure.preview { border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem; }
figure.preview img { display: block; width: 100%; height: auto; }
figure.preview figcaption { font-size: 0.62rem; font-family: var(--font-mono);
  color: var(--text-muted); margin-top: 0.6rem; text-align: center; }

.cta { display: inline-block; margin: 0.4rem 0; padding: 0.55rem 1rem; background: var(--brand);
  color: #fff; border: 1px solid var(--brand); border-radius: 4px; text-decoration: none;
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; }
.cta:hover { background: var(--brand-light); border-color: var(--brand-light); }

.dl-table { width: 100%; border-collapse: collapse; margin-bottom: 0.8rem; }
.dl-table th { text-align: left; font-family: var(--font-mono); font-size: 0.6rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
  font-weight: 700; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--border); }
.dl-table td { padding: 0.4rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.dl-table td.size { font-family: var(--font-mono); color: var(--text-muted); font-size: 0.75rem; }
.dl-table a { display: inline-block; padding: 0.25rem 0.7rem; border: 1px solid var(--border);
  border-radius: 4px; text-decoration: none; font-family: var(--font-mono); font-size: 0.7rem; }
.dl-table a:hover { border-color: var(--brand); }

table.facts { border-collapse: collapse; margin-bottom: 1rem; }
table.facts th { text-align: left; font-weight: 400; color: var(--text-muted);
  font-size: 0.78rem; padding: 0.25rem 1.2rem 0.25rem 0; vertical-align: top; }
table.facts td { padding: 0.25rem 0; font-size: 0.8rem; font-family: var(--font-mono); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 0.6rem 0 1rem; }
.chips a { padding: 0.2rem 0.6rem; border: 1px solid var(--border); border-radius: 4px;
  text-decoration: none; font-size: 0.75rem; font-family: var(--font-mono);
  color: var(--text); }
.chips a:hover { border-color: var(--brand); color: var(--brand); }

details.faq { border-bottom: 1px solid var(--border); padding: 0.6rem 0; }
details.faq summary { cursor: pointer; font-family: var(--font-mono); font-size: 0.85rem; }
details.faq p { margin: 0.5rem 0 0.2rem; font-size: 0.9rem; color: var(--text-muted); }

.filter { width: 100%; padding: 0.6rem 0.7rem; font-size: 0.95rem; background: var(--bg);
  color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--font-body); margin: 1rem 0 0.3rem; }
.filter:focus { outline: none; border-color: var(--brand); }
.count { font-size: 0.7rem; font-family: var(--font-mono); color: var(--text-muted); }
.grp { margin-top: 1.2rem; }
.grp h3 { font-size: 0.7rem; font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin: 0 0 0.5rem; }
.links { display: flex; flex-wrap: wrap; gap: 5px; }
.links a { padding: 0.2rem 0.6rem; border: 1px solid var(--border); border-radius: 4px;
  text-decoration: none; font-size: 0.78rem; color: var(--text); }
.links a:hover { border-color: var(--brand); color: var(--brand); }
.empty-hint { color: var(--text-muted); display: none; }

/* SEO-Fließtext unter der Karten-App */
.seo { border-top: 1px solid var(--border); }
.seo .wrap { max-width: var(--max-width); margin: 0 auto; padding: 2.5rem 1.5rem 3rem; }
.seo details { border-bottom: 1px solid var(--border); padding: 0.6rem 0; }
.seo summary { cursor: pointer; font-family: var(--font-mono); font-size: 0.9rem; }
.seo details p { margin: 0.5rem 0 0.2rem; font-size: 0.9rem; color: var(--text-muted); }
.seo ul { margin: 0 0 0.8rem 1.2rem; }
.seo li { margin-bottom: 0.3rem; }
.seo .app-footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.seo .app-footer a { color: var(--text-muted); }

@media (max-width: 768px) {
  .hero { grid-template-columns: 1fr; }
}

/* Leaflet an das Farbschema angleichen */
html.dark .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.95)
  contrast(0.9) saturate(0.7); }
html.dark .leaflet-control-attribution { background: rgba(26, 27, 23, 0.85);
  color: var(--text-muted); }
html.dark .leaflet-control-attribution a { color: var(--brand); }
.leaflet-bar a { background: var(--bg); color: var(--text); border-bottom-color: var(--border); }
.leaflet-bar a:hover { background: var(--bg-secondary); color: var(--brand); }
