:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --field: #ffffff;
  --line: #d9dde3;
  --text: #1c2026;
  --muted: #667085;
  --accent: #3b6ef5;
  --accent-soft: #e6edff;
  --accent-text: #ffffff;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --stage-a: #e4e6ea;
  --stage-b: #eaecef;
  --shadow: 0 6px 30px rgba(20, 24, 31, .22);
  --radius: 8px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15171a;
  --surface: #1e2125;
  --surface-2: #2a2e34;
  --field: #14161a;
  --line: #343941;
  --text: #e8eaed;
  --muted: #98a1ad;
  --accent: #5b8cff;
  --accent-soft: #263553;
  --accent-text: #ffffff;
  --warn: #f0b429;
  --warn-bg: #3a3014;
  --stage-a: #1b1e22;
  --stage-b: #17191d;
  --shadow: 0 6px 30px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1e2125;
    --surface-2: #2a2e34;
    --field: #14161a;
    --line: #343941;
    --text: #e8eaed;
    --muted: #98a1ad;
    --accent: #5b8cff;
    --accent-soft: #263553;
    --accent-text: #ffffff;
    --warn: #f0b429;
    --warn-bg: #3a3014;
    --stage-a: #1b1e22;
    --stage-b: #17191d;
    --shadow: 0 6px 30px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 11px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.wide { width: 100%; padding: 8px; }
button.ghost { background: none; border-color: transparent; }
button.ghost:hover { background: var(--surface-2); border-color: transparent; }
button.icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font-size: 16px; }
button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button:disabled { opacity: .4; cursor: default; }
input[type=text], input[type=number], select, textarea {
  background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; min-width: 0;
}
input[type=number] { width: 74px; }
input[type=color] { width: 44px; height: 26px; padding: 0; background: none; border: 1px solid var(--line); border-radius: 6px; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Kopfleiste */
.bar {
  display: flex; align-items: center; gap: 12px; padding: 7px 12px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-right: 6px; }
.logo { width: 18px; height: 22px; border-radius: 3px; background: linear-gradient(135deg, var(--accent), #9b6bff); }
.group { display: flex; gap: 2px; }
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; gap: 2px; }
.segmented button, .segmented select { border: none; background: none; border-radius: 6px; padding: 4px 10px; }
.segmented button.on, .segmented select.on { background: var(--accent); color: var(--accent-text); }
.segmented select.on option { color: var(--text); background: var(--surface); }
.status { color: var(--muted); margin-left: auto; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

/* Arbeitsbereich */
main { flex: 1; display: flex; min-height: 0; }
.tools {
  width: 68px; flex: none; display: flex; flex-direction: column; gap: 4px; padding: 8px 6px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.tools button {
  display: grid; justify-items: center; gap: 2px; padding: 8px 2px; font-size: 10.5px;
  background: none; border-color: transparent; color: var(--text);
}
.tools button:hover { background: var(--accent-soft); border-color: transparent; }
.tools hr { width: 100%; border: none; border-top: 1px solid var(--line); margin: 4px 0; }

#stage {
  flex: 1; position: relative; min-width: 0; display: grid; place-items: center; overflow: hidden;
  background: repeating-conic-gradient(var(--stage-a) 0% 25%, var(--stage-b) 0% 50%) 0 0 / 24px 24px;
}
#stage.drag { outline: 3px dashed var(--accent); outline-offset: -8px; }
#wrap { position: relative; box-shadow: var(--shadow); }
#wrap canvas { display: block; touch-action: none; }
#ov { position: absolute; pointer-events: none; }
.hint { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; color: var(--muted); margin: 0; pointer-events: none; }

/* Inspector */
#side { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); min-height: 0; }
.tabs { display: flex; padding: 8px 8px 0; gap: 2px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; background: none; border: none; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
  padding: 7px 4px; color: var(--muted); font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.pane { flex: 1; overflow-y: auto; padding: 10px; display: grid; gap: 10px; align-content: start; background: var(--bg); }
.pane[hidden] { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; }
.card h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.panel { display: grid; gap: 7px; }
.panel h4 { margin: 8px 0 0; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
.row { display: flex; align-items: center; gap: 6px; }
.row > span:first-child { width: 86px; flex: none; color: var(--muted); }
.row input[type=text], .row select { flex: 1; }
.row input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.row.check { gap: 8px; }
.row.check > span:first-child { width: auto; color: var(--text); }
.row.btns { flex-wrap: wrap; }
.row.btns > button { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.note { margin: 0; color: var(--muted); font-size: 12px; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn); color: var(--warn); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.warn[hidden] { display: none; }

.layers, .fontlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.layers:empty { display: none; }
.layer, .fontlist li {
  display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid transparent; cursor: pointer;
}
.layer:hover { border-color: var(--line); }
.layer.sel { border-color: var(--accent); background: var(--accent-soft); }
.layer.over { border-color: var(--warn); }
.layer .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .kind { color: var(--muted); width: 16px; text-align: center; }
.layer.hidden .name { opacity: .45; }
.ico { padding: 1px 5px; background: none; border: none; opacity: .85; }
.fontlist li { cursor: default; justify-content: space-between; }

.hex { width: 78px; font-family: ui-monospace, Menlo, monospace; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; padding-left: 92px; }
.sw { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--muted); }

.eblist { display: grid; gap: 6px; }
.eb { background: var(--surface-2); border: 1px solid transparent; border-radius: 8px; padding: 7px; display: grid; gap: 5px; cursor: pointer; }
.eb.active { border-color: var(--accent); }
.eb .row input[type=text] { flex: 1; }
.eb .row input[type=number] { width: 70px; }
.eb .note { font-size: 11px; }
.eb .note.bad { color: var(--warn); }

@media (max-width: 860px) {
  main { flex-direction: column; }
  .tools { width: auto; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .tools hr { width: 1px; height: auto; border-top: none; border-left: 1px solid var(--line); margin: 0 4px; }
  .tools button { min-width: 64px; }
  #side { width: auto; max-height: 45%; border-left: none; border-top: 1px solid var(--line); }
}

/* Assistent */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(10, 12, 16, .55); }
#wzForm { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.wz-head { padding: 18px 20px 8px; }
.wz-head h2 { margin: 10px 0 4px; font-size: 18px; }
.wz-steps { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.wz-steps li { padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.wz-steps li.on { background: var(--accent-soft); color: var(--accent); }
.wz-body { padding: 8px 20px 12px; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.choice {
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg);
}
.choice:hover { border-color: var(--muted); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.choice input { grid-row: 1 / 3; margin: 0; accent-color: var(--accent); }
.choice-main { font-weight: 600; }
.choice-sub { grid-column: 2; color: var(--muted); font-size: 12px; }
.wz-custom { flex-wrap: wrap; }
.wz-custom .unit { color: var(--muted); width: auto !important; }
.wz-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
[hidden] { display: none !important; }
