/* ============================================================
   Contentflow — App Styles
   Komponenten + Layout (setzt tokens.css voraus)
   ============================================================ */

/* ----------------------------------------------------------
   Reset & Base
---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--text-base); }

body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------
   Typografie
---------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--c-text);
}
h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }

.text-muted  { color: var(--c-text-muted); font-size: var(--text-xs); }
.text-mono   { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ----------------------------------------------------------
   App Shell
---------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar content";
  min-height: 100vh;
}

/* ----------------------------------------------------------
   Topbar
---------------------------------------------------------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--e-1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__logo {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--c-primary);
  white-space: nowrap;
  margin-right: var(--s-4);
}

.topbar__profile-switcher {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  background: var(--c-surface);
  font-size: var(--text-xs);
  color: var(--c-text);
  transition: border-color .15s;
}
.topbar__profile-switcher:hover { border-color: var(--c-primary-border); }
.topbar__profile-switcher .mandant { color: var(--c-text-muted); }
.topbar__profile-switcher .profil  { font-weight: 600; }

.topbar__spacer { flex: 1; }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ----------------------------------------------------------
   Sidebar
---------------------------------------------------------- */
.sidebar {
  grid-area: sidebar;
  width: var(--sidebar-width);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
}

.sidebar__nav { padding: var(--s-3) 0; flex: 1; }

.sidebar__section-label {
  padding: var(--s-4) var(--s-4) var(--s-1);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-text-faint);
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--c-text-muted);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.sidebar__item:hover {
  background: var(--c-bg);
  color: var(--c-text);
  text-decoration: none;
}
.sidebar__item.active {
  background: var(--c-primary-subtle);
  color: var(--c-primary);
  border-left-color: var(--c-primary);
  font-weight: 600;
}
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar__item .icon {
  width: 18px;
  height: 18px;
}

.sidebar__divider {
  height: 1px;
  background: var(--c-border);
  margin: var(--s-2) var(--s-4);
}
.sidebar__badge {
  margin-left: auto;
  background: var(--c-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* Abdunkelung hinter dem aufgeklappten Handy-Menü (nur < 768px sichtbar, siehe Responsiv) */
.sidebar-backdrop { display: none; }

/* ----------------------------------------------------------
   Content
---------------------------------------------------------- */
.content {
  grid-area: content;
  padding: var(--s-8) var(--content-padding);
  max-width: calc(var(--content-max) + 2 * var(--content-padding));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-8);
}
.page-header h1 { font-size: var(--text-h1); }

/* ----------------------------------------------------------
   Buttons
---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  height: 38px;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, box-shadow .12s, opacity .12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.btn-primary:hover  { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn-primary:active { background: var(--c-primary-active); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn-secondary:hover { border-color: var(--c-border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }

.btn-danger {
  background: var(--c-danger);
  color: #fff;
  border-color: var(--c-danger);
}

.btn-icon {
  width: 38px;
  padding: 0;
  justify-content: center;
}

/* ----------------------------------------------------------
   Form-Elemente
---------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: var(--s-1); }

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 38px;
  padding: 0 var(--s-3);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-textarea {
  height: auto;
  min-height: 80px;
  padding: var(--s-2) var(--s-3);
  resize: vertical;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px var(--c-primary-border);
}
.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--c-danger);
}
.form-hint  { font-size: var(--text-xs); color: var(--c-text-muted); }
.form-error { font-size: var(--text-xs); color: var(--c-danger); }

/* ----------------------------------------------------------
   Card
---------------------------------------------------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--e-1);
}
.card-body   { padding: var(--s-6); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--c-border);
}
.card-header h3 { font-size: var(--text-h3); }

/* ----------------------------------------------------------
   Status-Pills
---------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.pill-entwurf         { background: var(--c-bg);             color: var(--c-text-muted); }
.pill-warte_freigabe  { background: var(--c-warning-subtle); color: var(--c-warning); }
.pill-geplant         { background: var(--c-info-subtle);    color: var(--c-info); }
.pill-in_arbeit       { background: var(--c-primary-subtle); color: var(--c-primary); }
.pill-veroeffentlicht,
.pill-erledigt        { background: var(--c-success-subtle); color: var(--c-success); }
.pill-fehlgeschlagen,
.pill-abgebrochen     { background: var(--c-danger-subtle);  color: var(--c-danger); }

.pill-ready           { background: var(--c-success-subtle); color: var(--c-success); }
.pill-remix           { background: var(--c-info-subtle);    color: var(--c-info); }
.pill-production      { background: var(--c-warning-subtle); color: var(--c-warning); }
.pill-watchlist       { background: var(--c-bg);             color: var(--c-text-muted); }

.pill-in_arbeit::before { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ----------------------------------------------------------
   Tabelle
---------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
th {
  background: var(--c-bg);
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-weight: 600;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
tr:hover td { background: var(--c-primary-subtle); }
tr:last-child td { border-bottom: none; }

/* ----------------------------------------------------------
   Toast
---------------------------------------------------------- */
#toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: 999;
  min-width: 320px;
  max-width: 480px;
  text-align: center;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--c-text);
  color: #fff;
  font-size: var(--text-xs);
  box-shadow: var(--e-3);
  animation: toast-in .2s ease;
}
.toast-success { background: var(--c-success); }
.toast-danger  { background: var(--c-danger); }
.toast-info    { background: var(--c-info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------------
   Empty State
---------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-16) var(--s-8);
  text-align: center;
  gap: var(--s-4);
  color: var(--c-text-muted);
}
.empty-state p { max-width: 320px; }

/* ----------------------------------------------------------
   Skeleton Loader
---------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--c-border) 25%, var(--c-bg) 50%, var(--c-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ----------------------------------------------------------
   Responsiv
---------------------------------------------------------- */
@media (max-width: 1279px) {
  :root { --sidebar-width: 200px; }
}
@media (max-width: 1023px) {
  :root { --sidebar-width: var(--sidebar-width-rail); }
  .sidebar__item span { display: none; }
  .sidebar__section-label { display: none; }
}
@media (max-width: 767px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "content";
  }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: min(260px, 85vw);
    height: calc(100vh - var(--topbar-height));
    z-index: 200;
    box-shadow: var(--e-3);
  }
  /* Schubladen-Menü braucht eigene Breite + Beschriftungen — die 1023px-Regeln
     oben (Symbol-Leiste fuer Tablet) sonst mitgeerbt: 64px breit, Text versteckt. */
  .sidebar.open .sidebar__item span { display: inline; }
  .sidebar.open .sidebar__section-label { display: block; }
  /* Tippflaeche: --text-xs + knapper Innenabstand ist auf dem Handy zu klein (Richtwert 44px) */
  .sidebar.open .sidebar__item { min-height: 44px; }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--c-text);
    opacity: .4;
    z-index: 199;
  }

  /* Schritt-Anzeige der Wizards (karussell.php: 6 Schritte) laeuft auf 390px sonst
     ueber und schiebt die ganze Seite in den horizontalen Scroll. */
  .flow-steps {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .flow-step { white-space: nowrap; flex-shrink: 0; }
}

/* ── Content-Type-Tiles (erstellen.php) ──────────────────── */
.content-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--s-4);
  max-width: 1000px;
}
.content-type-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-4) var(--s-6);
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  text-decoration: none;
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
a.content-type-tile:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-subtle);
  box-shadow: var(--e-2);
  text-decoration: none;
  color: var(--c-text);
}
.content-type-tile--soon { opacity: .5; cursor: not-allowed; }
.content-type-tile__icon  { width: 40px; height: 40px; color: var(--c-primary); }
.content-type-tile__label { font-weight: 700; font-size: 15px; }
.content-type-tile__desc  { font-size: 12px; color: var(--c-text-muted); text-align: center; }
.content-type-tile__badge {
  position: absolute; top: var(--s-2); right: var(--s-2);
  background: var(--c-info-subtle); color: var(--c-info);
  font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: var(--r-pill);
}

/* ── Posts-Übersicht (posts.php) ─────────────────────────── */
.posts-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--c-border);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.posts-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .12s, border-color .12s;
}
.posts-tab:hover { color: var(--c-text); text-decoration: none; }
.posts-tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }
.posts-tab__count {
  background: var(--c-bg);
  color: var(--c-text-muted);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
}
.posts-tab.active .posts-tab__count {
  background: var(--c-primary-subtle);
  color: var(--c-primary);
}

.post-list { display: flex; flex-direction: column; gap: var(--s-3); }
.post-card {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  transition: box-shadow .12s;
}
.post-card:hover { box-shadow: var(--e-1); }
.post-card__thumb {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.post-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-card__thumb-placeholder { color: var(--c-text-faint); }
.post-card__thumb-placeholder .icon { width: 32px; height: 32px; }
.post-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.post-card__meta { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.post-card__text {
  font-size: 13px;
  color: var(--c-text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.post-card__date { font-size: 11px; color: var(--c-text-muted); }
.post-card__id   { margin-left: var(--s-2); color: var(--c-text-faint); cursor: pointer; user-select: none; }
.post-card__id:hover { color: var(--c-text-muted); }
.post-card__actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: flex-end;
}
.agent-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--c-info-subtle);
  color: var(--c-info);
}

/* ── Entwurf-Liste (erstellen.php) ───────────────────────── */
.draft-list-item {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-border);
  text-decoration: none;
  color: var(--c-text);
  transition: background .1s;
}
.draft-list-item:hover { background: var(--c-bg); text-decoration: none; }
.draft-list-item__meta { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.draft-list-item__text { font-size: 13px; color: var(--c-text-muted); }
.draft-list-item__date { font-size: 11px; color: var(--c-text-faint); }

/* ── Plattform-Tabs + Workspace (beitrag.php Schritt 3) ─── */
.plt-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--c-border);
  padding: 0 var(--s-4);
  overflow-x: auto;
}
.plt-tab-btn {
  padding: var(--s-2) var(--s-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.plt-tab-btn:hover { color: var(--c-text); }
.plt-tab-btn.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }

.plt-workspace { padding: var(--s-4); }
.plt-panel { display: none; gap: var(--s-4); }
.plt-panel.active { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 767px) {
  .plt-panel.active { grid-template-columns: 1fr; }
  .plt-preview-side { display: none; }
}
.plt-editor-side { display: flex; flex-direction: column; }
.plt-preview-side {
  display: flex;
  flex-direction: column;
}
.plt-editor__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--s-2);
  color: var(--c-text);
}
.plt-editor__count { font-size: 11px; font-weight: 400; color: var(--c-text-muted); }

/* ── Social-Preview-Cards ────────────────────────────────── */
.social-preview {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #222;
  overflow: hidden;
}
.sp-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sp-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-hover, #6366f1) 100%);
  flex-shrink: 0;
}
.sp-name { font-weight: 700; font-size: 13px; }
.sp-meta { font-size: 11px; color: #666; }
.sp-text { white-space: pre-line; word-break: break-word; }
.sp-img-placeholder {
  background: var(--c-bg);
  border-radius: 4px;
  margin-top: 8px;
  min-height: 120px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-faint);
  font-size: 11px;
}

/* LinkedIn */
.social-preview--linkedin .sp-avatar { border-radius: 4px; }

/* Instagram */
.social-preview--instagram .sp-header { margin-bottom: 8px; }
.social-preview--instagram .sp-name { font-size: 13px; font-weight: 700; }
.social-preview--instagram .sp-text { margin-top: 8px; }

/* Video (TikTok/YouTube) */
.social-preview--video { background: #111; color: #fff; border-color: #333; position: relative; }
.social-preview--video .sp-img-placeholder { background: #222; color: #555; aspect-ratio: 9/16; }
.social-preview--video img { border-radius: 4px; width: 100%; }
.sp-video-caption {
  margin-top: 10px;
  font-size: 13px;
  color: #fff;
  white-space: pre-line;
  word-break: break-word;
}
.sp-video-label {
  margin-top: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #888;
}

/* WordPress */
.social-preview--wordpress { border-left: 4px solid #21759B; }
.sp-wp-title { font-weight: 700; font-size: 15px; margin-bottom: 8px; color: #21759B; }

/* ── Beitrag-Flow ─────────────────────────────────────────── */
.flow-steps {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-6);
  align-items: center;
}
.flow-step {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 13px;
  color: var(--c-text-muted);
}
.flow-step__num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--c-border);
  color: var(--c-text-muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.flow-step.active .flow-step__num { background: var(--c-primary); color: #fff; }
.flow-step.active { color: var(--c-text); font-weight: 600; }
.flow-step.done .flow-step__num { background: var(--c-success); color: #fff; }
.flow-step__sep { color: var(--c-border); margin: 0 var(--s-1); }

.platform-checks { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.platform-check-label {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border: 2px solid var(--c-border); border-radius: var(--r-pill);
  cursor: pointer; font-size: 13px; font-weight: 500; user-select: none;
  transition: border-color .12s, background .12s;
}
.platform-check-label:has(input:checked) {
  border-color: var(--c-primary); background: var(--c-primary-subtle); color: var(--c-primary);
}
.platform-check-label input[type=checkbox], .platform-check-label input[type=radio] { display: none; }

.media-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--c-border); margin-bottom: var(--s-4); }
.media-tab {
  padding: var(--s-2) var(--s-4); font-size: 13px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; color: var(--c-text-muted);
}
.media-tab.active { border-bottom-color: var(--c-primary); color: var(--c-primary); }

.media-preview {
  display: none; align-items: center; gap: var(--s-3);
  padding: var(--s-3); background: var(--c-bg);
  border: 1px solid var(--c-border); border-radius: var(--r-sm); margin-top: var(--s-3);
}
.media-preview.visible { display: flex; }
.media-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--r-sm); }
.media-preview__remove { margin-left: auto; }

.media-library-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: var(--s-2); max-height: 300px; overflow-y: auto; padding: var(--s-2);
  background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--r-sm);
}
.media-library-item {
  position: relative;
  aspect-ratio: 1; cursor: pointer; border-radius: var(--r-sm); overflow: hidden;
  border: 2px solid transparent; transition: border-color .12s;
}
.media-library-item:hover { border-color: var(--c-primary); }
.media-library-item.selected { border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-border); }
.media-library-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-library-item--video { position: relative; background: #000; }
.media-library-item--video::after {
  content: '▶'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px;
}
.media-library-item__dauer {
  position: absolute; bottom: 4px; right: 4px; z-index: 1;
  background: rgba(0,0,0,.65); color: #fff; font-size: 10px; line-height: 1.4;
  padding: 1px 5px; border-radius: 4px;
}
.media-library-item__ki {
  position: absolute; top: 4px; right: 4px; z-index: 1;
  background: var(--c-primary); color: #fff; font-size: 10px; font-weight: 600;
  line-height: 1.4; padding: 1px 5px; border-radius: 4px;
}

.ki-loading {
  display: none; flex-direction: column; align-items: center;
  justify-content: center; gap: var(--s-4); padding: var(--s-12) var(--s-6); text-align: center;
}
.ki-loading.active { display: flex; }
.ki-loading__spinner {
  width: 48px; height: 48px; border: 4px solid var(--c-border);
  border-top-color: var(--c-primary); border-radius: 50%; animation: ki-spin 0.8s linear infinite;
}
@keyframes ki-spin { to { transform: rotate(360deg); } }
.ki-loading__funny { font-size: 17px; font-weight: 600; color: var(--c-text); min-height: 28px; transition: opacity .3s; }
.ki-loading__real  { font-size: 12px; color: var(--c-text-muted); }

.varianten-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); margin-top: var(--s-4); }
.variante-card {
  border: 2px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface);
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.variante-card:hover { border-color: var(--c-primary-border); box-shadow: var(--e-2); }
.variante-card__header {
  padding: var(--s-3) var(--s-4); background: var(--c-bg);
  border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: var(--s-2);
}
.variante-card__nr {
  width: 24px; height: 24px; border-radius: 50%; background: var(--c-primary); color: #fff;
  font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.variante-card__ton { font-weight: 700; font-size: 14px; }
.variante-card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.variante-plt-block__label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--c-text-muted); margin-bottom: var(--s-1);
}
.variante-plt-block__text {
  font-size: 12px; line-height: 1.6; white-space: pre-wrap;
  max-height: 120px; overflow-y: auto; background: var(--c-bg);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
}
.variante-card__footer { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-border); }

.plt-editor { display: flex; flex-direction: column; gap: var(--s-1); }
.plt-editor__label { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: var(--s-2); }
.plt-editor__count { font-size: 11px; color: var(--c-text-muted); margin-left: auto; font-weight: 400; }

[data-step] { display: none; }
[data-step].visible { display: block; }

/* ── Planung: Kalender ──────────────────────────────────── */
.plan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.plan-header__title { margin: 0; }
.plan-header__sub { font-size: 13px; color: var(--c-text-muted); margin: 4px 0 0; }
.plan-controls {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
}
.plan-toggle {
  display: flex;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.plan-toggle__btn {
  height: 34px;
  padding: 0 14px;
  border: none;
  background: none;
  color: var(--c-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s, color .1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.plan-toggle__btn.active {
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
}
.plan-nav {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.plan-nav__month {
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 15px;
  min-width: 140px;
  text-align: center;
}

/* Kalender-Grid */
.cal-wrap {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
}
.cal-wrap--open .cal-grid-outer { flex: 1 1 0; min-width: 0; }
.cal-grid-outer { flex: 1 1 0; min-width: 0; }
.cal-grid {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}
.cal-weekday {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--c-bg);
}
.cal-week:last-child { border-bottom: none; }
.cal-day {
  min-height: 100px;
  padding: 6px;
  border-right: 1px solid var(--c-bg);
  vertical-align: top;
}
.cal-day:last-child { border-right: none; }
.cal-day--other-month { background: var(--c-bg); opacity: .6; }
.cal-day--today .cal-day__num {
  background: var(--c-primary);
  color: #fff;
}
.cal-day__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
  margin-bottom: 4px;
}
.cal-chips { display: flex; flex-direction: column; gap: 2px; }
.cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  background: var(--c-bg);
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .1s, border-color .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cal-chip:hover { opacity: .85; border-color: rgba(0,0,0,.1); }
.cal-chip.active { outline: 2px solid var(--c-primary); }
.cal-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-more {
  font-size: 10px;
  color: var(--c-primary);
  font-weight: 600;
  padding: 2px 5px;
  cursor: default;
}

/* Detail-Panel */
.cal-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  position: sticky;
  top: calc(var(--topbar-height, 60px) + var(--s-4));
  display: none;
}
.cal-panel.open { display: block; }
.cal-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
}
.cal-panel__title { font-weight: 700; font-size: 14px; }
.cal-panel__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.cal-panel__profil {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 600;
  font-size: 13px;
}
.cal-panel__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cal-panel__meta { font-size: 12px; color: var(--c-text-muted); }
.cal-panel__text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-text);
  white-space: pre-line;
  word-break: break-word;
  max-height: 150px;
  overflow: hidden;
}
.cal-panel__actions { display: flex; flex-direction: column; gap: var(--s-2); }

/* Listen-Ansicht */
.plan-list-table { width: 100%; }

/* Zu planen */
.zu-planen-card { margin-bottom: var(--s-5); }

/* ── Studio (D0 Karussell-Studio, Task 5) — WYSIWYG-Slide-Editor ─────────── */
.st-studio {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
}
@media (max-width: 900px) {
  .st-studio { flex-direction: column; }
}

/* Slide-Leiste (links) */
.st-slides {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 84px;
  flex-shrink: 0;
  max-height: 520px;
  overflow-y: auto;
}
.st-slide {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--c-bg);
  transition: border-color .12s;
}
.st-slide:hover { border-color: var(--c-primary-border); }
.st-slide--active { border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-border); }
.st-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-slide__nr {
  position: absolute; top: 4px; left: 4px;
  background: var(--c-primary); color: #fff;
  border-radius: 50%; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}

/* Canvas (Mitte) — Vorschau, masstabsgetreu via aspect-ratio + %-Werte */
.st-canvas-wrap { flex: 1; display: flex; justify-content: center; min-width: 0; }
.st-canvas {
  position: relative;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  border-radius: var(--r-md);
  background: #000;
  touch-action: none;
}
.st-bild { position: absolute; inset: 0; }
.st-bild img { position: absolute; inset: 0; width: 100%; height: 100%; }
.st-bild--crop .st-bild__back  { display: none; }
.st-bild--crop .st-bild__front { object-fit: cover; }
.st-bild--blur .st-bild__back  {
  display: block;
  object-fit: cover;
  filter: blur(18px);
  transform: scale(1.15);
}
.st-bild--blur .st-bild__front { object-fit: contain; }

.st-zones { position: absolute; inset: 0; pointer-events: none; }
.st-zone {
  position: absolute;
  background: rgba(15, 23, 42, .35);
  outline: 1px dashed rgba(255, 255, 255, .5);
  outline-offset: -4px;
}

.st-textbox {
  position: absolute;
  cursor: move;
  font-weight: 700;
  /* text-align kommt dynamisch aus bauplan.ausrichtung (studio.js render()) */
  box-sizing: border-box;
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  user-select: none;
}
/* Text lebt in einem eigenen Kind — textContent-Updates loeschen so nie die Griff-Geschwister */
.st-textbox__text { white-space: pre-line; outline: none; min-height: 1em; }
.st-textbox.st-editing { cursor: text; user-select: text; outline-style: dashed; }
.st-textbox.st-editing .st-textbox__text { cursor: text; user-select: text; }
.st-textbox.st-warn { outline-color: var(--c-warning); }

.st-griff {
  position: absolute;
  width: 10px; height: 10px;
  background: #fff;
  border: 2px solid var(--c-primary);
  border-radius: 2px;
  transform: translate(-50%, -50%);
}
.st-griff--tl { left: 0;   top: 0;   cursor: nwse-resize; }
.st-griff--tr { left: 100%; top: 0;   cursor: nesw-resize; }
.st-griff--bl { left: 0;   top: 100%; cursor: nesw-resize; }
.st-griff--br { left: 100%; top: 100%; cursor: nwse-resize; }
.st-griff--l  { left: 0;   top: 50%;  cursor: ew-resize; }
.st-griff--r  { left: 100%; top: 50%;  cursor: ew-resize; }

/* Stil-Panel (rechts) */
.st-panel {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.st-panel__group { display: flex; flex-direction: column; gap: var(--s-2); }
.st-segment { display: flex; gap: var(--s-2); }
.st-segment__btn {
  flex: 1;
  height: 34px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.st-segment__btn:hover { border-color: var(--c-primary-border); }
.st-segment__btn.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.st-reset-link { font-size: 12px; color: var(--c-text-muted); text-decoration: underline; }
.st-reset-link:hover { color: var(--c-primary); }
.st-panel input[type="color"] {
  width: 44px; height: 34px; padding: 2px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  background: var(--c-surface); cursor: pointer;
}

/* Warnkasten "kein passender Kanal" - siehe kanal_warnung_html() in helpers.php.
   Bewusst groesser als die uebrigen Hinweise: die blasse form-hint-Variante wurde
   im Livetest uebersehen. */
.kanal-warnung {
  display: flex; flex-direction: column; gap: var(--s-1);
  background: var(--c-warning-subtle); border: 2px solid var(--c-warning);
  border-radius: var(--r-md); padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-4); max-width: 1000px;
}
.kanal-warnung strong { font-size: 16px; color: var(--c-warning); }
.kanal-warnung span   { font-size: 14px; color: var(--c-text); }
.kanal-warnung a      { font-size: 14px; font-weight: 600; align-self: flex-start; margin-top: var(--s-1); }
