/* Kiez-CMS – schlichtes, freundliches Design */
:root {
  --brand: #1e6b52;
  --brand-dark: #14513d;
  --brand-light: #e8f3ee;
  --accent: #e9c46a;
  --ink: #22303a;
  --muted: #6b7a85;
  --bg: #f7f9f8;
  --card: #ffffff;
  --border: #dde5e1;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}
img { max-width: 100%; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.25; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.section { padding: 1.6rem 0; }
.narrow { max-width: 640px; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: .92em; }
.lead { font-size: 1.15em; }

/* Header */
.site-header, .admin-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1000;
}
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.brand {
  font-weight: 800; font-size: 1.15rem; text-decoration: none;
  color: var(--brand);
}
.main-nav, .admin-nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.main-nav a, .admin-nav a {
  text-decoration: none; color: var(--ink);
  padding: .45rem .7rem; border-radius: 8px; font-size: .95rem;
}
.main-nav a:hover, .admin-nav a:hover { background: var(--brand-light); }
.main-nav a.active, .admin-nav a.active { background: var(--brand); color: #fff; }
.header-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.search-form input {
  border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; font-size: .9rem;
}
.nav-toggle { display: none; font-size: 1.3rem; background: none; border: 0; cursor: pointer; }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .main-nav { display: none; width: 100%; flex-direction: column; padding-bottom: .6rem; }
  .main-nav.open { display: flex; }
}

/* Buttons, Badges, Chips */
.btn {
  display: inline-block; background: var(--brand); color: #fff; text-decoration: none;
  border: 0; border-radius: 8px; padding: .55rem 1rem; font-size: .95rem; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn-outline:hover { background: var(--brand-light); color: var(--brand-dark); }
.btn-danger { background: #b23a3a; }
.btn-danger:hover { background: #8f2c2c; }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.badge {
  display: inline-block; background: var(--brand-light); color: var(--brand-dark);
  font-size: .75rem; border-radius: 999px; padding: .15rem .6rem; margin: 0 .3rem .3rem 0;
}
.badge.ok { background: #e3f2e8; color: #1e6b52; }
a.badge:hover { text-decoration: underline; }
.chip {
  display: inline-block; border: 1px solid var(--border); background: #fff;
  border-radius: 999px; padding: .3rem .8rem; margin: 0 .4rem .5rem 0;
  text-decoration: none; font-size: .9rem;
}
.chip:hover { border-color: var(--brand); background: var(--brand-light); }
.chip-count { color: var(--muted); font-size: .8em; }
.chip-cloud { margin: 1rem 0 2rem; }

.tag {
  display: inline-block; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; padding: .2rem .55rem; margin: 0 .3rem .4rem 0;
  font-size: .82rem; text-decoration: none; color: var(--ink);
}
.tag:hover, .tag-active { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-light); }
.tag-cloud { margin: .6rem 0 1.4rem; }

/* Schlagwort-Auswahl im Admin (Issue #3): Tags wie auf der Seite als Buttons,
   die per Klick zu-/abgewählt werden. Die eigentliche Checkbox bleibt im DOM
   (Formular-Wert) und wird nur optisch versteckt. */
.tag-select { margin: .4rem 0 .8rem; }
.tag-select input.tag-check { position: absolute; opacity: 0; width: 0; height: 0; }
/* .form label (display:block, fett) darf die Bubble-Optik nicht zerschießen */
.form .tag-select label.tag { display: inline-block; font-weight: 400; font-size: .82rem; }
.form .tag-select input.tag-check + label.tag { cursor: pointer; user-select: none; }
.form .tag-select input.tag-check:checked + label.tag { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-light); }
.tag-select input.tag-check:focus-visible + label.tag { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Karten & Listen */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.card-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card-body { padding: .9rem 1rem 1.1rem; }
.card-body h2, .card-body h3 { margin: .2rem 0 .4rem; font-size: 1.1rem; }
.card-body h2 a, .card-body h3 a { text-decoration: none; color: var(--ink); }
.card-body h2 a:hover, .card-body h3 a:hover { color: var(--brand); }
.card-meta { color: var(--muted); font-size: .82rem; margin: .2rem 0; }
.card-img { width: 100%; height: 160px; object-fit: cover; display: block; }

.news-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.news-item { display: flex; }
.news-item .news-img { flex: 0 0 220px; }
.news-item .news-img img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 640px) { .news-item { flex-direction: column; } .news-item .news-img { flex: none; } }
.readmore { text-decoration: none; font-weight: 600; }

.article { max-width: 780px; }
.article-img { border-radius: var(--radius); margin: 1rem 0; }
.article-body a { text-decoration: underline; }

/* Gerenderte Markdown-Inhalte (Artikel, Akteure, Seiten) – einheitliches Aussehen */
.article-body { line-height: 1.65; overflow-wrap: break-word; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  line-height: 1.25; margin: 1.4em 0 .5em; color: var(--ink);
}
.article-body h1 { font-size: 1.55rem; }
.article-body h2 { font-size: 1.3rem; }
.article-body h3 { font-size: 1.12rem; }
.article-body h4 { font-size: 1rem; }
.article-body p { margin: .8em 0; }
.article-body ul, .article-body ol { margin: .8em 0; padding-left: 1.4em; }
.article-body li { margin: .25em 0; }
.article-body blockquote {
  margin: 1em 0; padding: .2em 1em; border-left: 4px solid var(--brand);
  background: var(--brand-light); border-radius: 0 var(--radius) var(--radius) 0;
}
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.article-body table { max-width: 100%; border-collapse: collapse; margin: 1em 0; }
.article-body td { padding: .25rem .5rem; }
.article-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }

.contact-box {
  background: var(--brand-light); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: 1.2rem 0;
}
.contact-box ul { list-style: none; margin: 0; padding: 0; }
.contact-box li { padding: .15rem 0; }

/* Hero */
.hero {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff; padding: 2.4rem 0 2.8rem;
}
.hero h1 { margin: 0 0 .4rem; }
.hero-text { max-width: 720px; }
.hero a { color: var(--accent); }

/* Karte */
.map { border-radius: var(--radius); border: 1px solid var(--border); margin: 1rem 0 1.5rem; z-index: 1; }

/* Formulare */
.form label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .93rem; }
.form input[type=text], .form input[type=email], .form input[type=search],
.form input[type=password], .form input[type=url], .form input[type=number],
.form input[type=datetime-local], .form select, .form textarea, .filter-bar input, .filter-bar select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: #fff; margin-top: .25rem;
}
.form label.check, .hp { font-weight: 400; }
.hp { position: absolute; left: -9999px; }
#message-counter { margin: .25rem 0 0; }
#message-counter.warn { color: #8f2c2c; font-weight: 600; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
.form legend { font-weight: 700; font-size: .9rem; padding: 0 .4rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.admin-form { max-width: 760px; }
/* Konsolen-Ausgaben (Backup-Seite, Issue #24) */
.log-box { background: var(--bg); border: 1px solid var(--brand-light); border-radius: 8px; padding: .75rem 1rem; overflow-x: auto; font-size: .85rem; line-height: 1.5; max-width: 760px; }

/* Markdown-Editor (Schreiben/Vorschau + Spickzettel) */
textarea.markdown {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .92rem; line-height: 1.55;
}
.md-toolbar { display: flex; gap: .3rem; margin: .2rem 0 0; }
.md-tab {
  border: 1px solid var(--border); background: #fff; border-radius: 8px 8px 0 0;
  padding: .3rem .9rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.md-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.md-preview {
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  padding: .9rem 1rem; min-height: 8rem; margin-top: .3rem;
}
.md-help { margin: -.4rem 0 1rem; font-weight: 400; font-size: .9rem; }
.md-help summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.md-help-grid { border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: .6rem .9rem; margin-top: .5rem; }
.md-help-row { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 1rem; padding: .28rem 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.md-help-row:last-of-type { border-bottom: 0; }
.md-help-row code { background: var(--brand-light); border-radius: 4px; padding: .1rem .35rem; font-size: .84rem; }
.md-help-note { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }
.md-demo-link { color: var(--brand); text-decoration: underline; cursor: default; }
@media (max-width: 640px) { .md-help-row { grid-template-columns: 1fr; gap: .1rem; } }
.inline-form { display: flex; align-items: end; gap: .6rem; flex-wrap: wrap; }
.inline-form label { margin-bottom: 0; }
.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.filter-bar input[type=search] { flex: 1 1 240px; width: auto; }
.filter-bar select { width: auto; min-width: 180px; }

/* Tabellen (Admin) */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--brand-light); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.table tr.unread td { background: #fffbe8; }
.row-actions { display: flex; gap: .4rem; align-items: center; }
.row-actions form { display: inline; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--ink); text-align: center; }
.stat strong { display: block; font-size: 1.8rem; color: var(--brand); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }

/* Flash */
.flash {
  margin: .8rem 0; padding: .7rem 1rem; border-radius: 8px;
  border: 1px solid transparent; font-size: .95rem;
}
.flash-success { background: #e3f2e8; border-color: #bcd9c5; color: #1d5c3a; }
.flash-error { background: #fbe9e9; border-color: #e6bcbc; color: #8f2c2c; }
.flash-info { background: #e8f0fb; border-color: #c2d4ee; color: #2b527f; }

/* Pager */
.pager { display: flex; gap: .4rem; margin-top: 1.4rem; flex-wrap: wrap; }
.pager a, .pager-current {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: .35rem .75rem; text-decoration: none;
}
.pager-current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Footer */
.site-footer { background: #22303a; color: #cdd8d3; margin-top: 2.5rem; }
.site-footer a { color: #9fd0bc; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.4rem; padding: 1.8rem 1rem; }
.site-footer h3 { color: #fff; margin: 0 0 .4rem; font-size: 1rem; }
.site-footer p { margin: .2rem 0; }
.footer-bottom { border-top: 1px solid #3a4a55; padding: .8rem 1rem; font-size: .85rem; }

body.admin main { min-height: 70vh; }

/* Koordinaten-Auswahl per Karte (Admin, Akteur-Formular) */
.coords-dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.2rem; max-width: 640px; width: calc(100% - 2rem);
  box-shadow: 0 12px 40px rgba(34, 48, 58, .25);
}
.coords-dialog::backdrop { background: rgba(34, 48, 58, .55); }
.coords-dialog h2 { margin: 0 0 .7rem; font-size: 1.1rem; }
.coords-map {
  height: 320px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: .8rem; z-index: 0; cursor: crosshair;
}

/* Medien-Verwaltung (Admin, Issue #18) */
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.media-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.media-thumb {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; background: #eef2f0; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-nopreview { color: #7a8a83; font-size: .85rem; padding: 1rem; text-align: center; }
.media-meta { padding: .6rem .7rem; display: flex; flex-direction: column; gap: .35rem; }
.media-path {
  font-size: .72rem; word-break: break-all; background: #f2f5f4;
  padding: .2rem .35rem; border-radius: 4px;
}
.media-refs { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.media-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .2rem; }
.media-resize { display: flex; gap: .3rem; align-items: center; }
.media-resize input[type="number"] {
  width: 90px; padding: .3rem .4rem; border: 1px solid var(--border); border-radius: 6px;
}
.media-delete { margin-left: auto; }
.media-rename { display: flex; gap: .3rem; align-items: center; }
.media-rename input[type="text"] {
  width: 110px; padding: .3rem .4rem; border: 1px solid var(--border); border-radius: 6px;
  font-size: .8rem;
}

/* Media-Picker (Admin, Issue #21): ohne JS, CSP-konform */
.media-picker { margin-top: .6rem; }
.media-picker summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.media-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .6rem; margin-top: .6rem; max-height: 320px; overflow-y: auto;
  padding: .4rem; border: 1px solid var(--border); border-radius: var(--radius);
}
.media-picker-item {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  border: 2px solid transparent; border-radius: var(--radius); padding: .3rem;
  cursor: pointer; text-align: center;
}
.media-picker-item:hover { border-color: var(--border); }
.media-picker-item:has(input[type="radio"]:checked) { border-color: var(--brand); }
.media-picker-item img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; }
.media-picker-item input[type="radio"] { width: auto; }
.media-picker-path { font-size: .7rem; word-break: break-all; color: var(--muted); }
