:root {
  --navy-900: #081a33;
  --navy-800: #0b1f3a;
  --navy-700: #13305a;
  --navy-600: #1d4373;
  --sky: #4ba9e6;
  --sky-strong: #1f7fc4;
  --sky-soft: #e6f3fc;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e1e6ed;
  --border-strong: #cbd3de;
  --text: #0f1b2d;
  --muted: #5d6b7e;

  --s-draft: #8a97a8;   --s-draft-bg: #eef1f5;
  --s-sched: #1f7fc4;   --s-sched-bg: #e3f1fb;
  --s-pub: #178a52;     --s-pub-bg: #e2f5ea;
  --s-fail: #c93636;    --s-fail-bg: #fde8e8;
  --s-busy: #b7791f;    --s-busy-bg: #fdf3e1;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 14px rgba(15, 27, 45, .05);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; margin-bottom: 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.muted { color: var(--muted); }
small { font-size: 12px; }
nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Form-Elemente ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; }
label small { font-weight: 400; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: -1px; border-color: transparent; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
form > label, form > .row3 { margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-600); border-color: var(--navy-600); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--s-fail); }
.btn-danger-ghost:hover { background: var(--s-fail-bg); border-color: transparent; }
.btn-icon { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--sky-strong); cursor: pointer; text-decoration: underline; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row.end { justify-content: flex-end; }
.chip { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.chip:hover { border-color: var(--sky-strong); color: var(--sky-strong); }
.chip:disabled { opacity: .5; cursor: progress; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.counter { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: auto; }
label:has(.counter) { position: relative; }
.form-error, .alert-error { color: var(--s-fail); }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }
.alert-error { background: var(--s-fail-bg); }
.alert-ok { background: var(--s-pub-bg); color: var(--s-pub); }
.alert-warn { background: var(--s-busy-bg); color: #7a5212; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.01em; }
.brand small { display: block; color: #8fa6c4; font-size: 11.5px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--sky); color: var(--navy-900); font-weight: 800; font-size: 18px; }
.brand-lg .brand-mark { width: 42px; height: 42px; font-size: 22px; }
.brand-lg strong { font-size: 20px; color: var(--text); }
.brand-lg small { color: var(--muted); }

/* ---------- Anmeldung ---------- */
.auth-screen {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(rgba(75, 169, 230, .06) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(75, 169, 230, .06) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(120deg, var(--navy-900), var(--navy-700) 70%, var(--navy-600));
}
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.auth-form h1 { font-size: 20px; }
.auth-form p { margin: -6px 0 0; }
.code-input { font-size: 26px; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
#authError { margin: 14px 0 0; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; position: sticky; top: 0; height: 100vh;
  background: var(--navy-800); color: #dbe6f3; padding: 22px 14px; display: flex; flex-direction: column; gap: 26px;
}
.sidebar .brand strong { color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #b9c9dd; text-decoration: none; font-weight: 550; }
.side-nav a:hover { background: var(--navy-700); color: #fff; }
.side-nav a.active { background: var(--navy-600); color: #fff; box-shadow: inset 3px 0 0 var(--sky); }
.sidebar-status { margin-top: auto; font-size: 12px; }
.sidebar-status a { display: flex; align-items: center; gap: 8px; color: #b9c9dd; text-decoration: none; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, .05); }
.sidebar-status .led { width: 8px; height: 8px; border-radius: 50%; background: #e05a5a; flex: none; }
.sidebar-status .led.ok { background: #3ccf86; }
.sidebar-status .led.warn { background: #f0b443; }
.sidebar-footer { font-size: 12px; color: #8fa6c4; display: flex; flex-direction: column; gap: 4px; word-break: break-all; }
.sidebar-footer .btn-link { color: #b9c9dd; text-align: left; }

.main { flex: 1; min-width: 0; padding: 26px 30px 40px; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card > h2 { margin-bottom: 12px; }
.card > p.muted { margin: -6px 0 14px; }

/* ---------- Kalender ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h1 { min-width: 190px; text-align: center; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .dot { margin-left: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.s-DRAFT { background: var(--s-draft); }
.dot.s-SCHEDULED { background: var(--s-sched); }
.dot.s-PUBLISHED { background: var(--s-pub); }
.dot.s-FAILED { background: var(--s-fail); }
.month-stats { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 12px; color: var(--muted); }
.stat b { font-size: 18px; color: var(--text); margin-right: 6px; font-variant-numeric: tabular-nums; }

.calendar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-weekdays div { padding: 8px 10px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(118px, auto); }
.cal-day { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0; transition: background .1s; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: #f6f9fc; }
.cal-day.weekend { background: #fafbfc; }
.cal-day.other { background: var(--surface-2); color: #a7b2c0; }
.cal-day.past { background-image: linear-gradient(rgba(244, 246, 249, .55), rgba(244, 246, 249, .55)); }
.cal-day.drop { background: var(--sky-soft); outline: 2px dashed var(--sky); outline-offset: -3px; }
.day-num { font-size: 12px; font-weight: 650; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.day-num .add { opacity: 0; font-size: 16px; color: var(--sky-strong); line-height: 1; }
.cal-day:hover .add { opacity: 1; }
.cal-day.today .day-num span:first-child { background: var(--navy-800); color: #fff; border-radius: 99px; min-width: 22px; height: 22px; display: inline-grid; place-items: center; padding: 0 6px; }

.badge {
  display: flex; gap: 6px; align-items: baseline; font-size: 12px; padding: 4px 7px; border-radius: 6px;
  border-left: 3px solid; cursor: grab; min-width: 0; line-height: 1.3;
}
.badge time { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.badge .ic { flex: none; opacity: .7; }
.badge.dragging { opacity: .4; }
.st-DRAFT { background: var(--s-draft-bg); border-color: var(--s-draft); color: #3d4a5c; }
.st-SCHEDULED { background: var(--s-sched-bg); border-color: var(--s-sched); color: #10507f; }
.st-PUBLISHING { background: var(--s-busy-bg); border-color: var(--s-busy); color: #7a5212; }
.st-PUBLISHED { background: var(--s-pub-bg); border-color: var(--s-pub); color: #105c37; cursor: pointer; }
.st-FAILED { background: var(--s-fail-bg); border-color: var(--s-fail); color: #8f2121; }

.unscheduled { margin-top: 18px; }
.unscheduled h2 { margin-bottom: 10px; }
.unscheduled-list { display: flex; gap: 8px; flex-wrap: wrap; }
.unscheduled-list .badge { max-width: 280px; padding: 7px 10px; }

/* ---------- Liste ---------- */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 12.5px; font-weight: 600; border: 0; background: none; padding: 6px 11px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--navy-800); color: #fff; }
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-item { display: grid; grid-template-columns: 130px 1fr auto; gap: 16px; align-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow); }
.post-item:hover { border-color: var(--border-strong); }
.post-when { font-size: 12px; color: var(--muted); }
.post-when b { display: block; font-size: 14px; color: var(--text); }
.post-body { min-width: 0; }
.post-body p { margin: 0; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { display: flex; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.post-err { color: var(--s-fail); font-size: 12px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-tag { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ---------- Generator ---------- */
.gen-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.ideas { display: flex; flex-direction: column; gap: 8px; }
.idea { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; background: var(--surface-2); }
.idea:hover { border-color: var(--sky-strong); background: var(--sky-soft); }
.idea strong { display: block; margin-bottom: 3px; }
.idea p { margin: 0; font-size: 12.5px; color: var(--muted); }
.idea .tags { display: flex; gap: 6px; margin-top: 6px; }
.idea .tags span { font-size: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; color: var(--muted); }

/* ---------- Einstellungen ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.li-state { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 8px; background: var(--surface-2); margin-bottom: 14px; }
.li-state .led { width: 10px; height: 10px; border-radius: 50%; background: var(--s-fail); flex: none; }
.li-state .led.ok { background: var(--s-pub); }
.li-state .led.warn { background: var(--s-busy); }
.li-state small { display: block; color: var(--muted); }
.manual-token { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.manual-token summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.manual-token p { font-size: 12.5px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; word-break: break-all; }
.qr { display: flex; gap: 16px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.qr svg { display: block; border: 1px solid var(--border); border-radius: 8px; }
.user-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }

/* ---------- Dialoge ---------- */
.modal { position: fixed; inset: 0; background: rgba(8, 26, 51, .55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { background: var(--surface); border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-wide { max-width: 1080px; }
.modal-small { max-width: 420px; padding: 22px; }
.modal-small p { margin: 0 0 6px; font-size: 15px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.btn-close { margin-left: auto; background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); overflow: auto; flex: 1; }
.editor-col { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; border-right: 1px solid var(--border); }
.editor-col > label, .editor-col .row2 { margin: 0; }
.preview-col { padding: 18px 22px; background: var(--bg); }
.preview-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.spacer { flex: 1; }
.ai-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; margin-top: -4px; }

.attach-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; transition: background .1s; }
.dropzone.over { background: var(--sky-soft); border-color: var(--sky); }
.media-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.media-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 6px; border: 1px solid var(--border); border-radius: 8px; }
.media-row img, .media-row .doc-ic { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--s-fail); }
.media-row .meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.media-row .meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.media-row input { padding: 5px 8px; font-size: 12.5px; }
.media-row .acts { display: flex; gap: 2px; }
.media-row .acts button { background: none; border: 0; cursor: pointer; font-size: 15px; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.media-row .acts button:hover { background: var(--surface-2); color: var(--text); }
.uploading { font-size: 12px; color: var(--muted); }

/* LinkedIn-Vorschau */
.li-preview { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
.li-head { display: flex; gap: 10px; padding: 12px 14px 6px; align-items: center; }
.li-avatar { width: 44px; height: 44px; border-radius: 4px; background: var(--navy-800); color: var(--sky); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.li-head strong { display: block; font-size: 14px; }
.li-head small { color: #666; }
.li-text { padding: 4px 14px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; color: rgba(0, 0, 0, .9); }
.li-text .more { color: #666; }
.li-text .tag { color: #0a66c2; font-weight: 600; }
.li-text.empty-pv { color: #aaa; font-style: italic; }
.li-media { display: grid; gap: 2px; }
.li-media img { width: 100%; display: block; object-fit: cover; max-height: 420px; }
.li-media.grid2 { grid-template-columns: 1fr 1fr; }
.li-media.grid2 img { aspect-ratio: 1; }
.li-doc { margin: 0 14px 14px; border: 1px solid var(--border); border-radius: 8px; padding: 30px 14px; text-align: center; background: var(--surface-2); color: var(--muted); }
.li-doc b { display: block; color: var(--text); margin-bottom: 4px; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--navy-800); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: 13px; max-width: 420px; animation: tin .18s ease-out; }
.toast.err { background: #8f2121; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .gen-grid, .settings-grid { grid-template-columns: 1fr; }
  .modal-body { grid-template-columns: 1fr; }
  .editor-col { border-right: 0; }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-status, .sidebar-footer { margin: 0; }
  .main { padding: 18px 16px; }
  .legend { display: none; }
  .cal-grid { grid-auto-rows: minmax(80px, auto); }
  .badge span, .badge time { display: none; }
  .badge { padding: 3px; justify-content: center; }
  .post-item { grid-template-columns: 1fr; gap: 6px; }
  .row3, .row2 { grid-template-columns: 1fr; }
}
