:root {
  --bg: #f4f4f1; --panel: #ffffff; --ink: #1d1f22; --muted: #6b7078; --line: #e2e2dc;
  --accent: #0086d6; --accent-ink: #fff; --soft: #eef5fb;
  --c: #0086d6; --m: #ec008c; --y: #f4ee2a; --k: #1d1f22;
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171a; --panel: #1f2226; --ink: #e9eaec; --muted: #9aa0a8; --line: #30343a; --soft: #1b2a36; --k: #e9eaec; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.dots { display: grid; grid-template-columns: repeat(2, 12px); gap: 3px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.dots .c { background: var(--c); } .dots .m { background: var(--m); } .dots .y { background: var(--y); } .dots .k { background: #1d1f22; outline: 1px solid var(--line); }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

main { padding: 20px 24px 8px; }
.panel { display: none; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.panel.active { display: grid; }
@media (max-width: 860px) { .panel.active { grid-template-columns: 1fr; } }

.controls { display: flex; flex-direction: column; gap: 12px; }
fieldset { margin: 0; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 12px 14px 14px; }
legend { padding: 0 4px; font-weight: 600; font-size: 13px; }
.row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 8px; margin-top: 8px; }
.row label { color: var(--muted); }
.row input[type=number], .row select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.row output { min-width: 40px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.u { color: var(--muted); font-size: 12px; min-width: 20px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 22px 12px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.drop span { color: var(--muted); font-size: 12px; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--soft); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); padding: 3px; border-radius: 9px; gap: 3px; }
.seg button { border: 0; background: none; padding: 7px 6px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

table.fil { width: 100%; border-collapse: collapse; }
table.fil td { padding: 3px 2px; }
table.fil th { font-weight: 500; color: var(--muted); font-size: 11px; text-align: left; padding: 0 2px 2px; }
table.fil input[type=text] { width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
table.fil input[type=number] { width: 52px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
table.fil input[type=color] { width: 30px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.slot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); font-size: 11px; color: var(--muted); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; margin-top: 6px; cursor: pointer; font-size: 12px; }

.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .compare { grid-template-columns: 1fr; } }
.compare figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.compare figcaption { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.compare canvas { width: 100%; height: auto; display: block; image-rendering: pixelated; border-radius: 6px; background: repeating-conic-gradient(var(--bg) 0 25%, var(--panel) 0 50%) 0 0 / 16px 16px; }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.has-image .empty#empty-bild { display: none; }
#tab-bild:not(.has-image) .compare { display: none; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stats:empty { display: none; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.warn { border-color: #e0a100; }
.order { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.order i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions button, button.primary { padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.wide { width: 100%; margin-top: 12px; }
button:disabled { opacity: 0.45; cursor: default; }

.howto { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto li { margin: 4px 0; }

.viewer { position: relative; height: min(62vh, 560px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer .empty { position: absolute; inset: 20px; display: grid; place-items: center; }

.busy { position: fixed; right: 20px; bottom: 20px; display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.12); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: #c0392b; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 16px; }

[hidden] { display: none !important; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.slots .s { display: grid; grid-template-columns: 22px 18px 1fr auto; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.slots .s i { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line); display: block; }
.slots .s .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.slots .s.mix { border-style: dashed; }
.slots:empty { display: none; }

.explain { margin-top: 10px; font-size: 13px; }
.explain summary { cursor: pointer; color: var(--accent, inherit); font-weight: 600; }
.explain dl { margin: 8px 0 0; }
.explain dt { font-weight: 600; margin-top: 8px; }
.explain dd { margin: 2px 0 0; color: var(--muted); line-height: 1.45; }

/* Fortschritt und Speichern */
dialog.job { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); width: min(440px, 92vw); padding: 20px 22px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); }
dialog.job::backdrop { background: rgb(0 0 0 / 0.45); }
dialog.job h3 { margin: 0 0 14px; font-size: 16px; }
dialog.job .bar { height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; }
dialog.job .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
dialog.job #job-text { margin: 12px 0 0; font-variant-numeric: tabular-nums; }
dialog.job #job-done { margin-top: 14px; }
dialog.job a.button { display: inline-block; padding: 10px 18px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
dialog.job .job-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
dialog.job .job-actions button { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }

.printer { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-left: auto; }
.printer select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
