:root {
  --navy: #10233f;
  --navy-2: #1b3a61;
  --gold: #c9a45c;
  --gold-soft: #f3e8d2;
  --cream: #f7f3ea;
  --card: #ffffff;
  --ink: #17223a;
  --muted: #667085;
  --line: #e6e1d6;
  --green: #2e7d5b;
  --green-soft: #e3f3ea;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --amber: #9a6700;
  --amber-soft: #fff4d6;
  --blue-soft: #e8eef7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 35, 63, .06), 0 6px 18px rgba(16, 35, 63, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --serif: "Newsreader", Georgia, serif;
  --sans: "Work Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(76px + var(--safe-b));
}
a { color: var(--navy-2); }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); line-height: 1.2; margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 .75em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; }

/* ---------- Topbar & Tabbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; font-size: 11px; color: #b9c6d8; letter-spacing: .08em; text-transform: uppercase; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.logo.big { width: 64px; height: 64px; border-radius: 18px; font-size: 20px; margin: 0 auto 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  color: #fff; text-decoration: none; font-size: 20px; background: rgba(255,255,255,.08);
}
.chip {
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 99px;
  background: rgba(255,255,255,.12); color: #fff; white-space: nowrap;
}
.chip.auto { background: var(--green); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 8px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none;
  min-height: 60px; justify-content: center;
}
.tabbar .ti { font-size: 20px; line-height: 1; }
.tabbar a[hidden] { display: none; }
.tabbar.six { grid-template-columns: repeat(6, 1fr); }
.tabbar.six a { font-size: 10.5px; }
.rate-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; }
.rate-grid .field input, .rate-grid .field select { margin-top: 6px; font-weight: 400; }
pre.snippet { background: #f1ede2; border-radius: 10px; padding: 12px; font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; margin: 6px 0 0; }
.tabbar a.on { color: var(--navy); }
.tabbar a.on::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold);
}
.tabbar em {
  position: absolute; top: 5px; left: calc(50% + 6px); font-style: normal; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ---------- Layout ---------- */
.view { max-width: 760px; margin: 0 auto; padding: 18px 16px 24px; outline: none; }
.stack > * + * { margin-top: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }

.hero {
  background: linear-gradient(140deg, var(--navy), #1d4677);
  color: #fff; border-radius: 20px; padding: 20px;
}
.hero h1, .hero h2 { color: #fff; }
.hero p { color: #d6e0ec; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.tight { padding: 12px 14px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  text-decoration: none; color: inherit; display: block;
}
.kpi b { display: block; font-family: var(--serif); font-size: 30px; color: var(--navy); line-height: 1.1; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi.alert b { color: var(--red); }
.kpi.good b { color: var(--green); }

/* ---------- Actions ---------- */
.actions { display: grid; gap: 10px; margin-top: 14px; }
.action {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px;
  background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); min-height: 68px;
}
.action .ai { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--gold-soft); border-radius: 12px; flex: none; }
.action b { display: block; color: var(--navy); font-size: 16px; }
.action span { font-size: 13px; color: var(--muted); }

/* ---------- Buttons & Inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--navy);
  font: 600 15px/1.2 var(--sans); padding: 12px 16px; border-radius: 12px; cursor: pointer;
  min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; touch-action: manipulation;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c7c2; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1 1 auto; }

label.field { display: block; font-weight: 600; color: var(--navy); margin: 14px 0 6px; font-size: 14px; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=datetime-local], input[type=date], input[type=time], input[type=email], input[type=tel], textarea, select {
  width: 100%; font: 16px/1.45 var(--sans); color: var(--ink);
  border: 1px solid #d8d2c4; border-radius: 12px; padding: 11px 12px; background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
textarea.big { min-height: 240px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; min-height: 42px; border-radius: 11px; border: 1px solid #d8d2c4; background: #fff;
  font: 600 14px var(--sans); color: var(--navy); cursor: pointer; padding: 8px 12px;
}
.seg button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 12px -16px 0; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 99px;
  padding: 8px 14px; font: 600 14px var(--sans); cursor: pointer; min-height: 38px;
}
.filters button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.filters button em { font-style: normal; opacity: .7; margin-left: 4px; }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--navy); flex: none; }

/* ---------- Badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px; background: var(--blue-soft); color: var(--navy);
}
.badge.ig { background: #fbe7f0; color: #9b1c56; }
.badge.li { background: #e3eefb; color: #0a4f96; }
.badge.lead-hoch { background: var(--red-soft); color: var(--red); }
.badge.lead-mittel { background: var(--amber-soft); color: var(--amber); }
.badge.lead-kein { background: #eef0f3; color: var(--muted); }
.badge.lead-spam { background: #2b2b2b; color: #fff; }
.badge.st-pruefung { background: var(--red-soft); color: var(--red); }
.badge.st-freigabe { background: var(--amber-soft); color: var(--amber); }
.badge.st-beantwortet, .badge.st-auto_beantwortet { background: var(--green-soft); color: var(--green); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.off { background: var(--red-soft); color: var(--red); }

/* ---------- Comment cards ---------- */
.comment-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.author { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--gold-soft); color: var(--navy);
  display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; font-size: 15px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.author b { display: block; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author small { color: var(--muted); font-size: 12px; }
.comment-text { font-size: 16px; margin: 12px 0 8px; white-space: pre-wrap; word-break: break-word; }
.post-ref { font-size: 13px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; margin-bottom: 10px; }
.analysis { background: #faf8f3; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.analysis dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 8px; font-size: 14px; }
.analysis dt { color: var(--muted); }
.analysis dd { margin: 0; font-weight: 600; color: var(--navy); }
.reasons { font-size: 13px; color: var(--muted); margin: 6px 0 0; padding-left: 18px; }
.reply-sent { background: var(--green-soft); border-radius: 12px; padding: 12px; margin-top: 10px; font-size: 15px; }
.error-text { color: var(--red); font-size: 14px; margin-top: 8px; }
.notice { background: var(--amber-soft); color: #5c4300; border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice.info { background: var(--blue-soft); color: var(--navy); }
.notice.bad { background: var(--red-soft); color: var(--red); }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .ei { font-size: 36px; display: block; margin-bottom: 6px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-plain li:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.slide { border: 1px dashed #d8d2c4; border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.sources a { display: block; padding: 4px 0; word-break: break-word; font-size: 14px; }
code { background: #eee9dc; padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card { display: flex; gap: 10px; align-items: center; color: var(--muted); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(86px + var(--safe-b)); z-index: 50;
  max-width: 520px; margin: 0 auto; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 15px; opacity: 0; transform: translateY(10px);
  transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--red); }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; z-index: 100; background: var(--navy); display: grid; place-items: center; padding: 20px; }
.login-card { background: #fff; border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 380px; text-align: center; }
.login-card input { margin: 14px 0 12px; }

@media (min-width: 900px) {
  .view { padding-top: 28px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .actions { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Bilder ---------- */
.big-seg button { min-height: 50px; font-size: 15px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 10px; }
.thumb { position: relative; margin: 0; border-radius: 12px; overflow: hidden; background: #eee9dc; aspect-ratio: 4 / 5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#photoSlot .thumbs { grid-template-columns: minmax(0, 220px); justify-content: center; }
.thumb-x {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(16, 35, 63, .8); color: #fff; font-size: 14px; cursor: pointer;
}
.thumb-tag { position: absolute; left: 6px; bottom: 6px; background: var(--gold); color: var(--navy); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.image-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.image-actions .btn { padding: 10px 6px; font-size: 14px; }
.gen-panel { margin-top: 14px; padding: 14px; border: 1px solid var(--gold); border-radius: 14px; background: #fffaf0; }
.gen-head { display: flex; align-items: center; gap: 10px; }
.gen-head .ai { font-size: 22px; }
.avatar-mini { width: 36px; height: 48px; object-fit: contain; background: #fff; border-radius: 8px; }
.avatar-preview { display: grid; place-items: center; margin: 12px 0 4px; }
.avatar-preview img { max-height: 220px; max-width: 100%; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.brand-preview { display: flex; align-items: center; gap: 14px; }
.brand-preview .logo.big { margin: 0; flex: none; }
.logo.has-img { background: #fff; padding: 3px; overflow: hidden; }
.logo.has-img img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 380px) { .image-actions { grid-template-columns: 1fr; } }

/* ---------- Leads ---------- */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpis .kpi b { font-size: 26px; }
details > summary { cursor: pointer; }

/* ---------- Rollen ---------- */
.chip.role { background: rgba(255,255,255,.2); }
.chip.role.admin { background: var(--gold); color: var(--navy); }
@media (max-width: 380px) { #modeChip { display: none; } }

/* ---------- Contentplan ---------- */
.plan-new summary { cursor: pointer; color: var(--navy); list-style: none; }
.plan-new summary::-webkit-details-marker { display: none; }
.plan-new[open] summary { margin-bottom: 4px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.row2 .field input, .plan-new > .field > input { margin-top: 6px; font-weight: 400; min-width: 0; width: 100%; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-height: 48px; }
.day-chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-chips .day { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 10px; padding: 9px 0; font: 600 14px var(--sans); cursor: pointer; }
.day-chips .day.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.week-head { font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 2px 0; }
.plan-head { display: flex; gap: 12px; align-items: flex-start; }
.plan-thumb { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; flex: none; background: #eee9dc; display: grid; place-items: center; font-size: 22px; }
.plan-when { font-size: 13px; color: var(--muted); font-weight: 600; }
.plan-topic { display: block; color: var(--navy); line-height: 1.3; margin-top: 2px; }
.plan-preview { margin: 10px 0 0; font-size: 14px; color: var(--ink); line-height: 1.45; }
.plan-item.veroeffentlicht { opacity: .8; }
.plan-item.verpasst, .plan-item.fehler { border-color: #f0c7c2; }
.spinner.dark { border-color: rgba(16,35,63,.2); border-top-color: var(--navy); }

.frame-preview { position: relative; max-width: 220px; margin: 0 auto; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #c9d3df, #e8e2d4); }
.frame-preview img { width: 100%; height: 100%; object-fit: contain; display: block; position: relative; }
