:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2329;
  --muted: #6b7480;
  --line: #e4e0d8;
  --accent: #0f8a6c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3ee;
  --danger: #c23b3b;
  --check-a: #ffffff;
  --check-b: #ece9e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .05), 0 6px 24px rgba(20, 24, 28, .06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --panel: #1c2024; --ink: #e9ecef; --muted: #98a2ad; --line: #2c3238;
    --accent: #34c39e; --accent-ink: #0b1a15; --accent-soft: #173a30;
    --check-a: #2a2f34; --check-b: #23272b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 38px; height: 38px; color: var(--accent); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1; }
.brand h1 span { color: var(--accent); }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
select, input[type=number], input[type=text] {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, .drop:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Layout */
.layout {
  flex: 1; display: grid; gap: 16px; padding: 0 22px 16px;
  grid-template-columns: 260px minmax(0, 1fr) 320px; min-height: 0;
}
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Dateien */
.files { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.drop {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  border: 2px dashed var(--line); border-radius: 12px; padding: 22px 12px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 6px; }
.drop span { color: var(--muted); }
.drop small { color: var(--muted); font-size: 10.5px; margin-top: 8px; letter-spacing: .02em; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.filelist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.filelist li {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  padding: 6px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.filelist li:hover { background: var(--bg); }
.filelist li.active { border-color: var(--accent); background: var(--accent-soft); }
.filelist img { width: 44px; height: 44px; object-fit: contain; border-radius: 7px; background: var(--check-b); }
.filelist .meta { min-width: 0; }
.filelist .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.filelist .sub { color: var(--muted); font-size: 11.5px; }
.filelist .rm { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 2px 6px; border-radius: 6px; }
.filelist .rm:hover { color: var(--danger); background: var(--bg); }
.filelist li.loading .sub::after { content: " …"; }
.filelist li.failed .sub { color: var(--danger); }
.files-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Bühne */
.stage { display: flex; flex-direction: column; min-height: 420px; overflow: hidden; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.canvas {
  position: relative; flex: 1; overflow: auto; min-height: 320px;
  background-color: var(--check-a);
  background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%), linear-gradient(-45deg, var(--check-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check-b) 75%), linear-gradient(-45deg, transparent 75%, var(--check-b) 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.art { position: absolute; inset: 0; display: grid; place-items: center; padding: 28px; min-width: max-content; min-height: max-content; }
.frame { position: relative; }
.frame img { position: absolute; max-width: none; transition: opacity .2s; user-select: none; -webkit-user-drag: none; }
#imgResult { left: 0; top: 0; width: 100%; height: 100%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); }
.art.view-result #imgOriginal { opacity: 0; }
.art.view-original #imgResult { opacity: 0; }
.art.view-overlay #imgOriginal { opacity: .35; }
.art.view-overlay #imgResult { opacity: .85; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 20px; }
.empty svg { width: 120px; margin: 0 auto 10px; opacity: .6; }
.busy { position: absolute; top: 12px; right: 12px; background: var(--panel); border-radius: 999px; padding: 8px; box-shadow: var(--shadow); }
.busy span { display: block; width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { position: absolute; left: 12px; right: 12px; bottom: 12px; background: var(--danger); color: #fff; padding: 10px 14px; border-radius: 10px; }
.hint { position: absolute; left: 12px; right: 12px; top: 12px; background: var(--accent-soft); color: var(--ink); border: 1px solid var(--accent); padding: 10px 14px; border-radius: 10px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; min-height: 40px; }
.stats b { color: var(--ink); font-weight: 600; }

/* Segment-Schalter */
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.zoom { display: flex; gap: 4px; }
.icon { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; min-width: 32px; height: 32px; font-size: 16px; }
.icon.wide { font-size: 13px; padding: 0 10px; }

/* Einstellungen */
.settings { padding: 6px 16px 16px; overflow: auto; display: flex; flex-direction: column; }
.group { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.group h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; }
.chips button:hover, .chips button.on { border-color: var(--accent); background: var(--accent-soft); }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.slider output { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { accent-color: var(--accent); margin-top: 3px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row input[type=number] { width: 80px; }
input[type=color] { width: 44px; height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--panel); }
.size-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.size-row label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.size-row input { width: 100%; color: var(--ink); font-size: 15px; }
.size-row .x { padding-bottom: 8px; color: var(--muted); }
.layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.layers li { display: grid; grid-template-columns: auto 36px 1fr auto; gap: 8px; align-items: center; }
.layers li.off { opacity: .45; }
.layers input[type=color] { width: 36px; height: 26px; }
.layers .ln { font-weight: 500; }
.layers .nodes { color: var(--muted); font-size: 11.5px; }
.export { position: sticky; bottom: -16px; background: var(--panel); padding: 14px 0 16px; display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 600; font-size: 15px;
}
.primary svg { width: 20px; height: 20px; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.ghost { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 12px; }
.ghost.small { font-size: 12.5px; padding: 5px 10px; }
.ghost:hover { border-color: var(--accent); }

/* Sichtbarkeit je Modus */
.settings.is-vector .trace-only { display: none; }
.settings:not(.is-vector) .vec-only { display: none; }
.settings:not(.mode-mono) .mono-only { display: none; }
.settings:not(.mode-color) .color-only { display: none; }
.settings.mode-color .not-color { display: none; }

dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 520px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 12, 14, .45); }
dialog h2 { margin-top: 0; font-size: 18px; }
dialog li { margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 12.5px; }
.foot { text-align: center; color: var(--muted); font-size: 11.5px; padding: 0 0 12px; }

/* Tablet / Handy */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 320px; }
  .files { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .files .drop { flex: 1 1 240px; }
  .filelist { flex: 2 1 300px; max-height: 160px; }
}
@media (max-width: 760px) {
  .topbar { padding: 12px 14px; }
  .layout { grid-template-columns: 1fr; padding: 0 12px 12px; flex: none; }
  .files { min-height: auto; flex-direction: column; }
  .files .drop { flex: none; padding: 16px 12px; }
  .filelist { flex: none; }
  .stage { min-height: 380px; }
  .settings { overflow: visible; }
  .export { position: static; }
  .brand p { display: none; }
}
