:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --card2: #f8f9fc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e7ef;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #dc2626;

  --st-pending: #f59e0b;
  --st-approved: #2563eb;
  --st-posted: #16a34a;
  --st-partial: #ea580c;
  --st-failed: #dc2626;
  --st-rejected: #94a3b8;
  --st-sending: #9333ea;

  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card: #131b2e;
    --card2: #18223a;
    --text: #e8ecf5;
    --muted: #93a0b8;
    --line: #243049;
    --accent: #818cf8;
    --accent-soft: #1e2547;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-top: var(--safe-t);
  padding-bottom: calc(78px + var(--safe-b));
  -webkit-font-smoothing: antialiased;
}
body.no-tabs { padding-bottom: calc(24px + var(--safe-b)); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 28px; letter-spacing: -0.02em; margin: 6px 0 14px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 16px; }
.hidden { display: none !important; }

/* Modusleiste */
#modebar {
  position: sticky; top: 0; z-index: 30;
  text-align: center; font-size: 12.5px; font-weight: 700; letter-spacing: .04em;
  padding: 6px 10px; color: #fff;
}
#modebar.test { background: var(--st-pending); color: #3b2400; }
#modebar.live { background: var(--st-posted); }

/* Karten */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  border: 1px solid var(--line); margin-bottom: 12px;
}
.card.flat { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; }

/* Buttons */
button, .btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: 12px; padding: 12px 16px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; transition: transform .08s, opacity .2s;
}
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.block, .btn.block { width: 100%; }
button.secondary, .btn.secondary { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: transparent; color: var(--accent); min-height: 38px; padding: 8px 10px; }
button.danger { background: #fde8e8; color: var(--danger); }
@media (prefers-color-scheme: dark) { button.danger { background: #3a1820; } }
button.success { background: var(--st-posted); }
button.small { min-height: 36px; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* Formulare */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--card2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Schalter */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--st-posted); }
.switch input:checked + .track::after { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.toggle-row .txt small { display: block; }

/* Plattform-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--card2); color: var(--muted); font-weight: 600; font-size: 14px;
  min-height: 40px; cursor: pointer; user-select: none;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }

.pf { display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 800; border-radius: 6px; width: 24px; height: 20px; color: #fff; letter-spacing: -.02em; }
.pf.tiktok { background: #111; }
.pf.instagram { background: linear-gradient(45deg, #f59e0b, #ec4899, #8b5cf6); }
.pf.facebook { background: #1877f2; }
.pf.youtube { background: #ff0000; }
.pf.threads { background: #333; }
@media (prefers-color-scheme: dark) { .pf.tiktok, .pf.threads { background: #555; } }
.pfs { display: inline-flex; gap: 3px; flex-wrap: wrap; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-pending { color: var(--st-pending); background: color-mix(in srgb, var(--st-pending) 15%, transparent); }
.st-approved { color: var(--st-approved); background: color-mix(in srgb, var(--st-approved) 13%, transparent); }
.st-posted { color: var(--st-posted); background: color-mix(in srgb, var(--st-posted) 13%, transparent); }
.st-partial { color: var(--st-partial); background: color-mix(in srgb, var(--st-partial) 13%, transparent); }
.st-failed { color: var(--st-failed); background: color-mix(in srgb, var(--st-failed) 13%, transparent); }
.st-rejected { color: var(--st-rejected); background: color-mix(in srgb, var(--st-rejected) 18%, transparent); }
.st-sending, .st-posting { color: var(--st-sending); background: color-mix(in srgb, var(--st-sending) 13%, transparent); }
.st-overdue { color: var(--st-failed); background: color-mix(in srgb, var(--st-failed) 12%, transparent); }

.banner { border-radius: 14px; padding: 12px 14px; font-weight: 600; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: color-mix(in srgb, var(--st-pending) 18%, var(--card)); }
.banner.err { background: color-mix(in srgb, var(--st-failed) 14%, var(--card)); }
.banner.ok { background: color-mix(in srgb, var(--st-posted) 14%, var(--card)); }
.banner.info { background: var(--accent-soft); }

/* Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.cal-head h1 { margin: 0; font-size: 24px; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { min-height: 38px; min-width: 38px; padding: 6px 10px; }
.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; background: transparent; color: var(--muted); min-height: 34px; padding: 6px; border-radius: 9px; font-size: 14px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.sum { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; text-align: center; }
.sum b { display: block; font-size: 22px; line-height: 1.1; }
.sum span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.sum.posted b { color: var(--st-posted); }
.sum.approved b { color: var(--st-approved); }
.sum.pending b { color: var(--st-pending); }
.sum.failed b { color: var(--st-failed); }

.month { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; padding: 8px 0 4px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); }
.day {
  min-height: 74px; border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  padding: 4px 3px; cursor: pointer; position: relative; background: transparent; display: flex; flex-direction: column; gap: 2px;
}
.day:nth-child(7n+1) { border-left: 0; }
.day.out { opacity: .38; }
.day.past:not(.today) .num { color: var(--muted); }
.day .num { font-size: 13px; font-weight: 700; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; margin: 0 auto 1px; }
.day.today .num { background: var(--accent); color: #fff; }
.day.sel { background: var(--accent-soft); }
.day .bar { height: 15px; border-radius: 4px; font-size: 10px; font-weight: 700; color: #fff; padding: 0 3px; overflow: hidden; white-space: nowrap; line-height: 15px; }
.bar.pending { background: var(--st-pending); color: #3b2400; }
.bar.approved { background: var(--st-approved); }
.bar.posted { background: var(--st-posted); }
.bar.partial { background: var(--st-partial); }
.bar.failed, .bar.overdue { background: var(--st-failed); }
.bar.rejected { background: var(--st-rejected); }
.bar.sending, .bar.posting { background: var(--st-sending); }
.day .more { font-size: 10px; color: var(--muted); text-align: center; font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); margin: 10px 2px 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.daygroup h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 8px; display: flex; justify-content: space-between; }
.daygroup h3.today { color: var(--accent); }

/* Beitrag-Karte */
.post {
  display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px; margin-bottom: 8px; color: inherit; align-items: stretch; position: relative; overflow: hidden;
}
.post::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--line)); }
.post .thumb { width: 56px; height: 84px; border-radius: 9px; background: var(--card2) center/cover no-repeat; flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.post .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.post .top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.post .time { font-weight: 800; font-size: 15px; }
.post .cap { font-size: 14px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: auto; }
.post.c-pending { --c: var(--st-pending); }
.post.c-approved { --c: var(--st-approved); }
.post.c-posted { --c: var(--st-posted); }
.post.c-partial { --c: var(--st-partial); }
.post.c-failed, .post.c-overdue { --c: var(--st-failed); }
.post.c-rejected { --c: var(--st-rejected); }
.post.c-sending, .post.c-posting { --c: var(--st-sending); }
.post .quick { display: flex; gap: 6px; margin-top: 6px; }
.post .quick button { flex: 1; min-height: 36px; font-size: 14px; padding: 6px; }
.test-tag { font-size: 10px; font-weight: 800; background: var(--st-pending); color: #3b2400; padding: 1px 5px; border-radius: 5px; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* Detail */
.video-wrap { background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; display: flex; justify-content: center; max-height: 70vh; }
.video-wrap video, .video-wrap img { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.caption-box { white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.result { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.result:last-child { border-bottom: 0; }
.result .msg { color: var(--muted); font-size: 12.5px; }
.history { font-size: 13px; }
.history div { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; }
.history time { color: var(--muted); white-space: nowrap; }

/* Neu */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center;
  background: var(--card); cursor: pointer; display: block;
}
.drop .icon { font-size: 40px; }
.drop input { display: none; }
.preview { display: flex; gap: 12px; align-items: center; }
.preview video { width: 90px; height: 160px; object-fit: cover; border-radius: 12px; background: #000; flex: none; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Statistik */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; }
.pf-stat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pf-stat:last-child { border-bottom: 0; }
.pf-stat .nums { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); }
.pf-stat .nums b { color: var(--text); font-size: 17px; }

/* Codes */
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font: 600 16px ui-monospace, SFMono-Regular, Menlo, monospace; }
.codes div { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* Login */
.auth { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 14px; display: block; box-shadow: 0 10px 30px rgba(79,70,229,.3); }
.auth .card { text-align: left; }
.auth .links { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; align-items: center; }

/* Tabbar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: flex-end;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
}
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; position: relative; padding: 2px 0; }
#tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabbar a.on { color: var(--accent); }
#tabbar .tab-new .plus { width: 46px; height: 46px; border-radius: 15px; background: var(--accent); display: flex; align-items: center; justify-content: center; margin-top: -18px; box-shadow: 0 6px 18px rgba(79,70,229,.35); }
#tabbar .tab-new .plus svg { stroke: #fff; stroke-width: 2.6; }
#tabbar .badge { position: absolute; top: -2px; left: 50%; margin-left: 6px; background: var(--st-failed); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

/* Toast & Sheet */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + var(--safe-b)); z-index: 60;
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14.5px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.3); text-align: center;
}
#toast.err { background: var(--st-failed); }
#sheet { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
#sheet .panel {
  background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b)); max-height: 88vh; overflow: auto; animation: up .2s ease-out;
}
#sheet .panel h2 { margin-top: 4px; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

.splash { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; margin: 2px 0 6px; padding: 6px 0; }
.storage-bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.storage-bar > div { height: 100%; background: var(--accent); }

@media (min-width: 700px) {
  .day { min-height: 92px; }
  .day .bar { font-size: 11px; }
  .post .thumb { width: 64px; height: 96px; }
}

/* Statistik v2 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.tile { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; }
.tile b { display: block; font-size: 17px; line-height: 1.2; word-break: break-word; }
.tile span { font-size: 12px; color: var(--muted); }
.data .sub { margin-top: 10px; }
.data .sub .sub { margin-left: 4px; }
.data h4, .chart-title { font-size: 13px; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.kv.small { font-size: 13px; padding: 6px 0; }
.chart-wrap { width: 100%; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .ax { font-size: 10px; fill: var(--muted); font-family: inherit; }
.barlist { display: flex; flex-direction: column; gap: 6px; }
.bl-row { display: grid; grid-template-columns: minmax(60px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-bar { background: var(--card2); border-radius: 99px; height: 10px; overflow: hidden; }
.bl-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bl-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.deltas { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.delta { font-size: 12.5px; font-weight: 700; padding: 4px 9px; border-radius: 99px; background: var(--card2); }
.delta.up { color: var(--st-posted); background: color-mix(in srgb, var(--st-posted) 13%, transparent); }
.delta.down { color: var(--st-failed); background: color-mix(in srgb, var(--st-failed) 12%, transparent); }
.delta.flat, .delta.none { color: var(--muted); }
details.all-values { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.all-values summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 6px 0; display: flex; align-items: center; list-style: none; }
details.all-values summary::-webkit-details-marker { display: none; }
details.all-values summary::after { content: '›'; margin-left: auto; transition: transform .2s; font-size: 20px; }
details.all-values[open] summary::after { transform: rotate(90deg); }
.metrics { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.metrics .m.on { font-weight: 800; color: var(--accent); }
.pfv { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
