:root {
  color-scheme: light dark;
  --bg: #f4f4f2;
  --panel: #ffffff;
  --sunken: #e9e9e6;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #d9d9d6;
  --accent: #0a6cd6;
  --accent-text: #ffffff;
  --sel: #dcebfc;
  --ok: #1f8a3c;
  --warn: #b26b00;
  --bad: #c62828;
  --info: #0a6cd6;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 1px 8px rgb(0 0 0 / 4%);
  --c: #00a0e3; --m: #e5007e; --y: #f2d500; --k: #2b2b2e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1d;
    --panel: #252528;
    --sunken: #141416;
    --text: #ececee;
    --muted: #9c9ca3;
    --line: #3a3a3f;
    --accent: #3d8ef0;
    --sel: #1f3a5c;
    --ok: #4cc26b;
    --warn: #e7a33e;
    --bad: #ef6a6a;
    --info: #6aa8f5;
    --shadow: none;
    --k: #8d8d94;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
a.button {
  display: inline-block; text-decoration: none; border-radius: 6px; padding: 6px 12px;
  border: 1px solid var(--line); background: var(--panel); color: inherit;
}
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
a.button:hover { filter: brightness(1.08); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, li:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

main { flex: 1; min-height: 0; display: flex; }
main > section { flex: 1; min-width: 0; }

/* Anmeldung */
.login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; width: min(360px, 100%); display: grid; gap: 12px; box-shadow: var(--shadow);
}
.login h2 { margin: 0; font-size: 18px; }
.login label { display: grid; gap: 4px; }
.login input { padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }

/* Leerer Zustand */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; padding: 24px 16px; overflow: auto;
}
.dropzone {
  width: min(560px, 100%);
  border: 2px dashed var(--line); border-radius: 14px;
  padding: 40px 16px; text-align: center; color: var(--muted);
  background: var(--panel);
}
.dropzone .big { font-size: 20px; color: var(--text); margin: 8px 0 4px; }
.dropzone p { margin: 0; }
.intro { width: min(560px, 100%); color: var(--text); }
.intro p { margin: 0 0 10px; }

/* Arbeitsbereich */
.workspace { display: flex; min-height: 0; }
.list-pane {
  width: 320px; flex: none;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.file-list { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.file-list li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.file-list li:hover { background: var(--sunken); }
.file-list li.selected { background: var(--sel); }
.file-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-list .meta { grid-column: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.file-list .remove {
  grid-row: 1 / span 2; grid-column: 2;
  border: 0; background: none; color: var(--muted); padding: 2px 6px; font-size: 18px; line-height: 1;
}
.file-list .remove:hover { color: var(--bad); }
.summary { margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.st-checking, .st-uploading, .st-queued, .st-ready { color: var(--muted); }
.st-running { color: var(--info); }
.st-done { color: var(--ok); }
.st-warn, .st-needs_planes { color: var(--warn); }
.st-failed, .st-unsuitable, .st-upload_failed { color: var(--bad); }

.bar { height: 4px; background: var(--sunken); border-radius: 2px; overflow: hidden; flex: 1; min-width: 40px; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.bar.big { height: 6px; width: min(260px, 80%); flex: none; }

/* Detailbereich */
.detail-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; overflow: auto; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.detail-head .sub { font-size: 13px; color: var(--muted); }

.banner {
  border: 1px solid var(--line); border-left: 4px solid var(--muted);
  background: var(--panel); border-radius: 6px; padding: 8px 12px;
}
.banner.bad { border-left-color: var(--bad); }
.banner.warn { border-left-color: var(--warn); }
.banner p { margin: 0; }
.banner ul { margin: 4px 0 0; padding-left: 20px; }
.banner details { margin-top: 6px; font-size: 13px; }
.banner pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; font-size: 12px; max-height: 200px; overflow: auto; }

.planes { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.planes summary { cursor: pointer; }
.planes-grid { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 12px; align-items: center; margin-top: 8px; }
.planes-grid .why { font-size: 13px; color: var(--muted); }
.planes-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.planes-foot .error { font-size: 13px; margin-right: auto; }

.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; align-self: flex-start; }
.tabs button { border: 0; border-radius: 0; padding: 5px 14px; background: var(--panel); }
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.views { flex: 1; min-height: 360px; display: flex; gap: 12px; }
.thumbs { display: grid; gap: 10px; align-content: start; overflow: auto; }
.views.side .thumbs { width: 170px; flex: none; grid-template-columns: 1fr; }
.views.input .thumbs { flex: 1; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.thumb { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
canvas.pending { display: none !important; }
.thumb .loading { display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; color: var(--muted); font-size: 13px; }
.thumb canvas { display: block; width: 100%; height: auto; background: #fff; }
.thumb figcaption { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 4px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgb(0 0 0 / 15%); }
.sw-C { background: var(--c); } .sw-M { background: var(--m); } .sw-Y { background: var(--y); } .sw-K { background: var(--k); }

.result { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.stage {
  flex: 1; min-height: 300px; position: relative;
  background: var(--sunken); border-radius: 6px; overflow: auto;
}
.stage canvas { display: block; margin: 12px auto; background: #fff; box-shadow: 0 1px 6px rgb(0 0 0 / 20%); }
.stage .placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 16px;
}
.zoom {
  position: sticky; float: right; bottom: 8px; right: 8px; margin: -44px 8px 8px 0;
  display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; overflow: hidden;
}
.zoom button { border: 0; border-radius: 0; padding: 4px 10px; }
.result-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.result-foot label { display: inline-flex; align-items: center; gap: 6px; }
.result-foot .grow { flex: 1; }

/* Ziehen und Ablegen */
.drop-overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgb(10 108 214 / 14%); border: 3px dashed var(--accent);
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.drop-overlay p { background: var(--panel); padding: 12px 20px; border-radius: 8px; font-size: 18px; box-shadow: var(--shadow); }

/* Schmale Fenster und Telefone */
@media (max-width: 760px) {
  .workspace { flex-direction: column; overflow: auto; }
  .list-pane { width: auto; border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .detail-pane { overflow: visible; }
  .views { flex-direction: column; min-height: 0; }
  .views.side .thumbs { width: auto; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .stage { min-height: 60vh; }
  .planes-grid { grid-template-columns: auto 1fr; }
  .planes-grid .why { grid-column: 1 / -1; margin-top: -4px; }
}
