:root {
  --rot: #c8102e; --rot-dunkel: #9d0c24;
  --bg: #f4f4f6; --card: #ffffff; --text: #1c1c1e; --muted: #6b6b70; --line: #e2e2e6;
  --ok: #1b7f3b; --warn: #a15c00; --blau: #1d5fbf;
  --nav-h: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121214; --card: #1c1c1f; --text: #f2f2f7; --muted: #9a9aa1; --line: #2e2e33; --ok: #4cc26f; --warn: #f0a63a; --blau: #6aa5ff; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
a { color: var(--rot); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.hidden { display: none !important; }

/* Rahmen */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--rot); color: #fff; }
.topbar .title { font-weight: 700; flex: 1; }
.topbar button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 8px; min-height: 36px; padding: 0 12px; font-weight: 600; }
.topbar button.alarm { background: #fff; color: var(--rot); }
main { flex: 1; padding: 14px 12px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 880px; width: 100%; margin: 0 auto; }
.banner { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 0.95rem; }
.banner.stop { background: #fde7ea; color: #7a0a1c; border: 1px solid #f3b2bc; }
.banner.info { background: #fff6dd; color: #6b4a00; border: 1px solid #f0d58a; }
@media (prefers-color-scheme: dark) {
  .banner.stop { background: #3a1219; color: #ffb3bf; border-color: #6b2330; }
  .banner.info { background: #33290f; color: #f2d58c; border-color: #5c4a1c; }
}

/* Navigation: unten auf dem Handy, links am Desktop */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs a { flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 0.75rem; position: relative; }
nav.tabs a .ico { font-size: 1.35rem; line-height: 1; }
nav.tabs a.active { color: var(--rot); font-weight: 700; }
nav.tabs a .badge { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--rot); color: #fff; font-size: 0.7rem; text-align: center; }
.desk-only { display: none !important; }
@media (min-width: 900px) {
  .shell { flex-direction: row; flex-wrap: wrap; }
  .topbar { width: 100%; }
  nav.tabs { position: sticky; top: 52px; bottom: auto; align-self: flex-start; flex-direction: column; width: 210px; height: calc(100vh - 52px); border-top: 0; border-right: 1px solid var(--line); padding: 8px; }
  nav.tabs a { flex: 0; flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 8px; font-size: 0.95rem; }
  nav.tabs a.active { background: var(--bg); }
  nav.tabs a .badge { position: static; margin-left: auto; }
  .desk-only { display: flex !important; }
  .mobile-only { display: none !important; }
  main { padding: 20px 24px 40px; }
  .shell > main { flex: 1; min-width: 0; }
}

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 10px; }
.card.link { display: block; color: inherit; text-decoration: none; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.badge-s { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--line); color: var(--text); }
.badge-s.gelb { background: #fff1c2; color: #6b4a00; }
.badge-s.blau { background: #d9e8ff; color: #123f86; }
.badge-s.gruen { background: #d6f3df; color: #135c2b; }
.badge-s.rot { background: #fbd9de; color: #8a0f25; }
.badge-s.fmt { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button, .btn { font: inherit; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button.primary, .btn.primary { background: var(--rot); border-color: var(--rot); color: #fff; font-weight: 600; }
button.good { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
button.danger { color: var(--rot); border-color: var(--rot); }
button.small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 14px 0 4px; }
input, select, textarea { font: inherit; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
textarea { min-height: 110px; resize: vertical; }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.hint.over { color: var(--rot); font-weight: 600; }
.error { color: var(--rot); font-weight: 600; margin: 10px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.actions button { flex: 1 1 140px; }

/* Anmeldung */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { text-align: center; }
.login .logo { width: 64px; height: 64px; display: block; margin: 0 auto 12px; border-radius: 14px; }

/* Kalender */
.monthbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.monthbar .label { flex: 1; text-align: center; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 14px; }
.grid .dow { text-align: center; font-size: 0.72rem; color: var(--muted); }
.grid .day { position: relative; aspect-ratio: 1 / 1; max-height: 56px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.85rem; padding: 0; min-height: 0; }
.grid .day.empty { border: 0; background: none; }
.grid .day.today { border-color: var(--rot); font-weight: 700; }
.grid .day .dot { margin-top: 2px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--rot); color: #fff; font-size: 0.68rem; }
.dayhead { font-weight: 700; margin: 16px 0 6px; }
.post .t { font-weight: 600; }
.post .meta { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

/* Editor */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 8px; }
.thumb { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: var(--line); padding: 0; min-height: 0; }
.thumb img, .thumb .vid { width: 100%; height: 100%; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.thumb.sel { border-color: var(--rot); }
.thumb .nr { position: absolute; top: 4px; left: 4px; background: var(--rot); color: #fff; font-size: 0.75rem; border-radius: 999px; min-width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: 10px; background: var(--line); }
.approvebox { border-color: var(--blau); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 40; background: #222; color: #fff; padding: 12px 14px; border-radius: 10px; text-align: center; }
.toast.err { background: var(--rot-dunkel); }
@media (min-width: 900px) { .toast { left: auto; right: 24px; bottom: 24px; max-width: 420px; } }

table.log { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.log td, table.log th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }

.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
label input[type=checkbox] { width: auto; min-height: 0; margin-right: 6px; }
.hidden { display: none !important; }
