:root {
  --navy: #091c3e;
  --blue: #2765ad;
  --ice: #9cc4f0;
  --light: #f1f5fc;
  --line: #d9e2f0;
  --ink: #0d1424;
  --grey: #5f6b80;
  --ok: #1f9d55;
  --ok-dark: #17804a;
  --bad: #d64545;
  --bad-dark: #b53636;
  --warn: #c98a12;
  --card: #ffffff;
  --head: "Space Grotesk", system-ui, sans-serif;
  --body: "Source Sans 3", system-ui, sans-serif;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--light); color: var(--ink); font-family: var(--body); font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
[hidden] { display: none !important; }

/* Kopfzeile */
.top { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-weight: 700; font-size: 20px; text-decoration: none; color: #fff; }
.brand img { width: 34px; height: 34px; background: #fff; border-radius: 8px; padding: 3px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tabs a { color: #c7d3e6; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.tabs a.on { background: rgba(255,255,255,.14); color: #fff; }
.tabs .count { background: var(--blue); color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 7px; min-width: 22px; text-align: center; }
.top .ghost { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 999px; padding: 6px 12px; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 80px; }
h1.view-title { font-family: var(--head); font-size: 28px; margin: 0 0 6px; }
.view-sub { color: var(--grey); margin: 0 0 22px; }
.empty { text-align: center; color: var(--grey); padding: 60px 16px; border: 2px dashed var(--line); border-radius: var(--radius); }

/* Karten */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 4px 18px rgba(9,28,62,.06); }
.card.focus { outline: 3px solid var(--blue); }
.card-head { padding: 14px 16px 10px; display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.card-title { font-family: var(--head); font-weight: 700; font-size: 18px; line-height: 1.2; margin: 0; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--light); color: var(--grey); white-space: nowrap; }
.badge.geplant { background: #e6efff; color: var(--blue); }
.badge.erledigt { background: #e3f6ea; color: var(--ok-dark); }
.badge.fehler { background: #fde8e8; color: var(--bad-dark); }

.variant-tabs { display: flex; gap: 6px; padding: 0 16px 10px; }
.variant-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; color: var(--grey); }
.variant-tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.preview { position: relative; background: #e6ebf3; display: flex; align-items: center; justify-content: center; }
.preview img { display: block; width: 100%; height: auto; }
.preview.vertical img { width: auto; max-height: 520px; max-width: 100%; }
.preview .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(9,28,62,.7); color: #fff; font-size: 20px; }
.preview .nav.prev { left: 8px; }
.preview .nav.next { right: 8px; }
.preview .pos { position: absolute; bottom: 8px; right: 10px; background: rgba(9,28,62,.7); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }

.card-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.caption { color: var(--grey); font-size: 14px; line-height: 1.4; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 600; color: var(--grey); }
.chip.on { border-color: var(--blue); color: var(--blue); background: #eef4fc; }
.chip.disabled { opacity: .45; cursor: not-allowed; }
.chip .mode { font-weight: 400; font-size: 12px; border-left: 1px solid var(--line); padding-left: 6px; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--grey); }
.toggles label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.when { font-size: 14px; font-weight: 600; color: var(--blue); }

.results { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.result { display: flex; gap: 8px; align-items: baseline; }
.result .st { font-weight: 700; }
.result.ok .st { color: var(--ok-dark); }
.result.bad .st { color: var(--bad-dark); }
.result.manual .st { color: var(--warn); }
.result .err { color: var(--bad-dark); font-size: 13px; }

/* Aktionsknöpfe */
.actions { display: flex; justify-content: space-around; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); margin-top: auto; }
.act { width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; transition: transform .1s ease, background .15s ease; }
.act:hover { transform: scale(1.06); }
.act:focus-visible { outline: 3px solid var(--ice); outline-offset: 2px; }
.act svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.act.yes { background: var(--ok); color: #fff; }
.act.yes:hover { background: var(--ok-dark); }
.act.no { background: var(--bad); color: #fff; }
.act.no:hover { background: var(--bad-dark); }
.act.later, .act.edit, .act.back { background: var(--light); color: var(--navy); border: 1px solid var(--line); }
.act-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--grey); font-weight: 600; }

/* Dialog */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(9,28,62,.35); }
dialog::backdrop { background: rgba(9,28,62,.45); }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { font-family: var(--head); margin: 0; font-size: 22px; }
.dlg p { margin: 0; color: var(--grey); }
.dlg .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn { border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 700; background: var(--light); color: var(--navy); border: 1px solid var(--line); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field input, .field textarea, .field select { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; font-weight: 400; }
.field textarea { min-height: 160px; resize: vertical; line-height: 1.4; }
.choice { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--blue); background: #eef4fc; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad-dark); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login form { background: #fff; padding: 30px; border-radius: var(--radius); width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-family: var(--head); margin: 0; }
.err-text { color: var(--bad-dark); font-size: 14px; min-height: 1em; }

/* Einstellungen */
.settings { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { font-family: var(--head); margin: 0; font-size: 20px; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); margin-right: 6px; }
.status-dot.on { background: var(--ok); }

/* Selbst posten */
.manual-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.manual-list img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .top-inner { flex-wrap: nowrap; gap: 10px; padding: 10px 12px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; padding: 8px 10px; }
  .top .ghost { padding: 6px 10px; font-size: 13px; }
}

/* Editor */
.editor { display: flex; flex-direction: column; gap: 14px; }
.ed-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ed-title { font-family: var(--head); font-size: 20px; flex: 1; min-width: 160px; }
.ed-vtabs { padding: 0; }
.ed-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ed-main { display: grid; grid-template-columns: 110px 1fr 320px; gap: 14px; height: calc(100vh - 170px); min-height: 520px; }
.ed-strip { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.ed-thumb { position: relative; padding: 0; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.ed-thumb.on { border-color: var(--blue); }
.ed-thumb img { display: block; width: 100%; }
.ed-thumb span { position: absolute; top: 4px; left: 4px; background: rgba(9,28,62,.75); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 999px; }
.ed-stage { background: #dfe5ee; border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; }
.ed-frame-wrap { position: relative; box-shadow: 0 20px 50px rgba(9,28,62,.25); }
.ed-frame { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #fff; }
.ed-side { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.ed-tools { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ed-tools h3 { margin: 0; font-family: var(--head); font-size: 17px; }
.ed-selinfo { font-size: 13px; color: var(--grey); }
.ed-num { width: 72px; border: 1px solid var(--line); border-radius: 10px; padding: 9px; text-align: center; }
.ed-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); }
.ed-swatch:disabled, .ed-tools button:disabled, .ed-tools select:disabled, .ed-tools input:disabled { opacity: .45; cursor: default; }
.ed-hint { font-size: 12px; color: var(--grey); margin: 0; }
.ed-tools .field textarea { min-height: 200px; }
@media (max-width: 1000px) {
  .ed-main { grid-template-columns: 1fr; height: auto; }
  .ed-strip { flex-direction: row; overflow-x: auto; }
  .ed-thumb { width: 80px; flex: none; }
  .ed-stage { height: 70vh; }
}
