/* Bildkonfigurator der Heinrich Kimmle Stiftung – CI der Website: Grün #4a6b0c (Aktion), CI-Grün #94c11f, Braun #5b3f35, Tinte #1f1b18, Papier #faf7f2 */
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url(/ui-fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2) format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url(/ui-fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2) format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Poppins"; src: url(/fonts/Poppins-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "Poppins"; src: url(/fonts/Poppins-Bold.ttf); font-weight: 600 700; font-display: swap; }

:root {
  --brand: #4a6b0c;
  --brand-press: #3d5a0a;
  --brand-soft: #eef5d8;
  --on-brand: #ffffff;
  /* Grün auf dunklen Flächen (Werkzeugleiste, Toast, 3D-Knopf): Hellgrün aus dem Logo, Kontrast 8,1 : 1 zu --ink */
  --brand-on-dark: #94c11f;
  --ink: #1f1b18;
  --ink-soft: #5c534d;
  --line: #e4d9c8;
  --paper: #FFFFFF;
  --work: #f1ebe1;
  --good: #2e6b1f;
  --warn: #8a5300;
  --bad: #b3261e;
  --bar-h: 64px;
  --tools-w: 92px;
  --sheet-w: 340px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow-float: 0 2px 10px rgba(59, 41, 34, .14);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 400 15px/1.45 "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--work);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Icons */
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-slot { display: inline-flex; }

/* ---------- App-Gerüst (Desktop) ---------- */
.app {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: var(--tools-w) var(--sheet-w) minmax(0, 1fr);
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "tools sheet work";
}

.bar {
  grid-area: bar; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 3;
}
.logo { display: flex; align-items: center; flex: none; }
.logo img { height: 34px; width: auto; display: block; }
.product-btn {
  display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px;
  padding: 6px 12px 6px 14px; margin-left: 12px;
  background: none; border: 1px solid var(--line); border-radius: 10px; text-align: left;
}
.product-btn:hover { border-color: #BDBDBD; }
.product-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-size { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.product-btn .chev { width: 18px; height: 18px; color: var(--ink-soft); }
.bar .cta { margin-left: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); font-weight: 600; font-size: 15px;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: #BDBDBD; }
.btn.cta { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.cta:hover { background: var(--brand-press); border-color: var(--brand-press); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.big { white-space: nowrap; min-height: 54px; padding: 0 26px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: progress; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px; border: 0; background: none; color: var(--ink);
}
.icon-btn:hover { background: rgba(52, 52, 52, .07); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- Werkzeugleiste ---------- */
.tools {
  grid-area: tools; background: var(--ink); display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; z-index: 2;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px; border: 0; border-radius: 12px; background: none; color: #D6D6D6; font-size: 12px; line-height: 1.2;
  position: relative;
}
.tool:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.tool[aria-current="true"] { color: var(--brand-on-dark); background: rgba(148, 193, 31, .16); }
.tool .ic { width: 24px; height: 24px; }
.tool .dot { position: absolute; top: 6px; right: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-on-dark); }

/* ---------- Seitenbereich / Bottom-Sheet ---------- */
.sheet { grid-area: sheet; background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; z-index: 1; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 20px; position: relative; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 600; flex: 1; }
.grabber { display: none; }
.sheet-close { display: none; }
.panel { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px 24px; display: flex; flex-direction: column; gap: 22px; }

.group { display: flex; flex-direction: column; gap: 10px; }
.group > h3 { margin: 0; font-size: 14px; font-weight: 600; }
.hint { margin: 0; color: var(--ink-soft); font-size: 13px; }
.hint strong { color: var(--ink); font-weight: 600; }

/* Fotobibliothek */
.lib { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lib-item { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: #EEE; }
.lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-item .used {
  position: absolute; right: 6px; bottom: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.lib-item:hover img { opacity: .85; }
.lib-item.pending { display: flex; align-items: flex-end; padding: 8px; }
.lib-item.pending .bar-p { height: 6px; border-radius: 3px; background: #D9D9D9; width: 100%; overflow: hidden; }
.lib-item.pending .bar-p i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.lib-add { aspect-ratio: 1; border: 2px dashed #C9C9C9; border-radius: 10px; background: none; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; }
.lib-add:hover { border-color: var(--brand); color: var(--ink); }

/* Kacheln (Layouts, Sticker, Filter) */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 12px; line-height: 1.25; text-align: center;
}
.tile:hover { border-color: #BDBDBD; }
.tile[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tile svg { width: 100%; height: 42px; flex: none; }
.tile > span { max-width: 100%; hyphens: auto; overflow-wrap: anywhere; }
.tile.filter { padding: 0 0 8px; overflow: hidden; }
.tile.filter .fimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }

/* Regler */
.field { display: grid; grid-template-columns: 84px 1fr 56px; align-items: center; gap: 10px; min-height: 40px; }
.field > label { font-size: 14px; color: var(--ink-soft); }
.field output { text-align: right; font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: none; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #DCDCDC; }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #DCDCDC; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--paper); border: 3px solid var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--paper); border: 3px solid var(--brand); }

textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper);
  font-size: 16px; /* verhindert Auto-Zoom auf iOS */
}
textarea { resize: vertical; min-height: 76px; line-height: 1.35; }
textarea:focus, select:focus { border-color: var(--brand); outline: none; }

.fonts { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--paper); font-size: 15px; }
.chip-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }

.seg { display: flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 42px; border: 0; border-right: 1.5px solid var(--line); background: var(--paper); font-size: 14px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); padding: 0; position: relative; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.sw.custom { background: conic-gradient(#f44, #fd0, #4c4, #0bf, #85f, #f4c, #f44); overflow: hidden; }
.sw.none { background: linear-gradient(135deg, transparent 46%, #c62828 46%, #c62828 54%, transparent 54%), repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

.list { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); text-align: left; }
.list-item[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.list-item span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.empty-panel { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }

/* ---------- Arbeitsfläche ---------- */
.work { grid-area: work; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.work-top { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; align-items: center; gap: 12px; z-index: 2; pointer-events: none; }
.work-top > * { pointer-events: auto; }
.status {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 18px;
  border: 0; background: var(--paper); box-shadow: var(--shadow-float); font-size: 13px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status { min-width: 0; flex: 0 1 auto; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #9E9E9E; flex: none; }
.status.good::before { background: var(--good); }
.status.ok::before { background: var(--brand); }
.status.bad::before { background: var(--bad); }
.btn-3d {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 12px;
  border: 0; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-float);
}
.btn-3d:hover { background: #222; }
.btn-3d .ic { color: var(--brand-on-dark); }
.history { display: flex; gap: 2px; padding: 2px; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-float); }
.history .icon-btn { width: 40px; height: 40px; }

.stage-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; touch-action: none; }
#stage { line-height: 0; }
#stage .konvajs-content { box-shadow: 0 4px 22px rgba(52, 52, 52, .22); }
.app.previewing #stage .konvajs-content { box-shadow: none; }

.empty {
  position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; z-index: 1; pointer-events: none;
}
.empty > * { pointer-events: auto; }
.empty .btn { box-shadow: 0 6px 18px rgba(52, 52, 52, .25); }
.empty-hint { margin: 0; font-size: 13px; color: var(--ink); background: rgba(255,255,255,.88); padding: 4px 12px; border-radius: 12px; }
.dropzone {
  position: absolute; inset: 12px; border: 3px dashed var(--brand); border-radius: 18px; background: rgba(74, 107, 12, .12);
  display: flex; align-items: center; justify-content: center; z-index: 4; pointer-events: none; font-weight: 600; font-size: 18px;
}
.dropzone span { background: var(--paper); padding: 10px 18px; border-radius: 12px; }

.progress { position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 5; background: rgba(74, 107, 12, .2); }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s; }

/* Kontextleiste für das gewählte Element */
.ctx {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3; width: max-content;
  display: flex; gap: 2px; padding: 4px; max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none;
  background: var(--paper); border-radius: 14px; box-shadow: 0 4px 16px rgba(52, 52, 52, .2);
}
.ctx::-webkit-scrollbar { display: none; }
.ctx button {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; height: 56px; padding: 0 8px; border: 0; border-radius: 10px; background: none; font-size: 11.5px; line-height: 1.15;
}
.ctx button:hover { background: rgba(52, 52, 52, .07); }
.ctx button.danger { color: var(--bad); }
.ctx .sep { width: 1px; margin: 10px 2px; background: var(--line); flex: none; }
.ctx.lift { bottom: 70px; }

/* ---------- Dialoge ---------- */
.dlg {
  border: 0; padding: 0; border-radius: 18px; width: min(640px, calc(100vw - 32px)); max-height: min(86dvh, 760px);
  background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.dlg::backdrop { background: rgba(30, 30, 30, .55); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 16px 12px 4px 24px; }
.dlg-head h2 { margin: 0; font-size: 20px; font-weight: 600; flex: 1; }
.dlg-sub { margin: 0 24px 12px; color: var(--ink-soft); font-size: 14px; }
.products { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 4px 24px 24px; overflow-y: auto; }
.prod {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper); text-align: left;
}
.prod:hover { border-color: #BDBDBD; }
.prod[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.prod .shape { height: 92px; display: flex; align-items: center; justify-content: center; background: #F4F4F4; border-radius: 10px; }
.prod .shape i { display: block; background: var(--ink); border-radius: 3px; }
.prod[aria-pressed="true"] .shape i { background: var(--brand); }
.prod b { font-weight: 600; font-size: 15px; line-height: 1.3; }
.prod small { color: var(--ink-soft); font-size: 13px; }

.finish { padding: 8px 24px 24px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: #F6F6F6; font-size: 14px; }
.checks li .ic { width: 20px; height: 20px; margin-top: 1px; }
.checks li.good .ic { color: var(--good); }
.checks li.warn { background: #FFF6E6; } .checks li.warn .ic { color: var(--warn); }
.checks li.bad { background: #FDECEC; } .checks li.bad .ic { color: var(--bad); }
.checks li b { display: block; font-weight: 600; }
.finish-preview { display: flex; justify-content: center; background: var(--work); border-radius: 12px; padding: 16px; }
.finish-preview img { max-width: 100%; max-height: 200px; box-shadow: 0 3px 14px rgba(0,0,0,.2); }
.finish-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.dev-link { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--ink-soft); font-size: 13px; text-decoration: underline; }

/* 3D-Ansicht */
.dlg-3d { width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 32px)); max-height: none; }
.view3d { flex: 1; min-height: 0; position: relative; background: #ececec; margin: 4px 16px 0; border-radius: 14px; overflow: hidden; }
.view3d canvas { cursor: grab; }
.view3d canvas:active { cursor: grabbing; }
.loading3d { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--ink-soft); }
.view3d-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px 16px; }
.view3d-bar .hint { flex: 1; min-width: 180px; }
.view3d-bar .btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
/* Hauptaktion im 3D-Dialog (z. B. „Tasse erwärmen“): Primärfarbe auch im gedrückten Zustand */
.view3d-bar .btn.cta, .view3d-bar .btn.cta[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.view3d-bar .btn.cta:hover { background: var(--brand-press); border-color: var(--brand-press); }
.view3d-bar .btn.cta:active { background: var(--brand-press); border-color: var(--brand-press); transform: translateY(1px); }

/* Tastenkürzel */
.key-row > span:last-child { white-space: nowrap; flex: none; }
#dlg-keys { width: min(780px, calc(100vw - 32px)); }
.keys { padding: 4px 24px 24px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; }
.keys h3 { grid-column: 1 / -1; margin: 12px 0 4px; font-size: 14px; font-weight: 600; }
.key-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid #F0F0F0; font-size: 14px; }
kbd { display: inline-block; min-width: 26px; padding: 2px 7px; border: 1px solid #CFCFCF; border-bottom-width: 2px; border-radius: 6px; background: #FAFAFA; font: 600 12px/1.5 Poppins, system-ui, sans-serif; text-align: center; white-space: nowrap; }

/* Einbettung im Shop */
.embed .product-btn:disabled { cursor: default; opacity: 1; border-color: transparent; }
.embed-close { margin-left: -8px; }
@media (max-width: 860px) { .embed .logo { display: none; } }

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(var(--bar-h) + 60px); transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast button { border: 0; background: none; color: var(--brand-on-dark); font-weight: 600; padding: 4px 2px; white-space: nowrap; }

.desk-only { }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  :root { --bar-h: 56px; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--bar-h) minmax(0, 1fr) auto auto;
    grid-template-areas: "bar" "work" "sheet" "tools";
  }
  .bar { padding: 0 10px 0 14px; gap: 8px; }
  .logo img { height: 26px; }
  .product-btn { margin-left: 4px; padding: 4px 8px 4px 10px; flex-direction: column; align-items: flex-start; gap: 0; border-color: transparent; position: relative; padding-right: 26px; }
  .product-btn .chev { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
  .product-name { font-size: 14px; max-width: 100%; }
  .product-size { font-size: 11.5px; }
  .bar .cta { min-height: 40px; padding: 0 16px; }

  .tools {
    flex-direction: row; justify-content: space-around; gap: 0; padding: 4px 4px calc(4px + var(--safe-b));
  }
  .tool { flex: 1; min-width: 0; padding: 7px 0 6px; font-size: 11px; border-radius: 10px; }
  .tool span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tool .dot { right: calc(50% - 18px); top: 4px; }

  .sheet {
    border-right: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(52, 52, 52, .16);
    max-height: 48dvh; margin-top: -14px; /* überlappt die Arbeitsfläche leicht */
  }
  .app.sheet-closed .sheet { display: none; }
  .sheet-head { padding: 14px 8px 0 18px; }
  .sheet-head h2 { font-size: 17px; }
  .grabber { display: block; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #D0D0D0; }
  .sheet-close { display: inline-flex; }
  .panel { padding: 4px 18px 18px; gap: 18px; }
  .lib { grid-template-columns: repeat(4, 1fr); }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile { padding: 8px 4px; font-size: 11px; }
  .tile svg { height: 34px; }
  .field { grid-template-columns: 76px 1fr 50px; }

  .work-top { top: 10px; left: 10px; right: 10px; gap: 8px; }
  .status { min-height: 34px; padding: 0 12px; font-size: 12px; }
  .history .icon-btn { width: 38px; height: 38px; }
  .ctx { bottom: 12px; }
  .ctx { left: 12px; right: 12px; transform: none; max-width: none; width: auto; }
  .ctx button { flex: 1 0 auto; min-width: 48px; height: 54px; padding: 0 4px; font-size: 11px; }
  .ctx button span { max-width: 64px; }
  .ctx .sep { margin: 10px 0; }

  .toast { top: calc(var(--bar-h) + 56px); width: max-content; }
  .desk-only { display: none !important; }
  .btn-3d { min-height: 38px; padding: 0 12px 0 10px; font-size: 13px; }
  .btn-3d .lbl { font-size: 0; } .btn-3d .lbl::after { content: "3D"; font-size: 13px; }
  .dlg-3d { width: 100vw; height: 92dvh; }
  .view3d { margin: 2px 10px 0; }
  .view3d-bar { padding: 10px 12px calc(12px + var(--safe-b)); }
  .view3d-bar .hint { flex-basis: 100%; }
  .view3d-bar .btn { flex: 1; padding: 0 10px; font-size: 14px; }

  .dlg { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; padding-bottom: var(--safe-b); }
  .products { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 4px 16px 20px; }
  .prod { padding: 10px; }
  .prod .shape { height: 72px; }
  .dlg-head { padding: 14px 8px 2px 18px; }
  .dlg-sub { margin: 0 18px 10px; }
  .finish { padding: 6px 18px 18px; }
  .finish-actions .btn { flex: 1; }
}
@media (max-width: 380px) {
  .logo img { height: 22px; }
  .product-size { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Version 5: Formen, Vorlagen, eigene Bilder, Vorlagen-Modus ---------- */
.tiles.masks { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tiles.masks .tile { padding: 6px 0; font-size: 10.5px; }
.tiles.masks .tile svg { height: 30px; }
.tile.img-sticker img { width: 100%; height: 42px; object-fit: contain; display: block; }
.lib.logos .lib-item { background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.lib.logos .lib-item img { object-fit: contain; padding: 6px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.hint.warn { color: #B42318; display: flex; gap: 6px; align-items: flex-start; }
.hint .ic { width: 15px; height: 15px; vertical-align: -2px; }
.dt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dt-tile { display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 13px; text-align: center; }
.dt-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #f3f3f3; border-radius: 8px; }
.dt-tile[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.dt-tile:hover { border-color: #BDBDBD; }
.ctx-note { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.ctx-note .ic { width: 16px; height: 16px; }
.designer .app { grid-template-rows: auto var(--bar-h) minmax(0, 1fr); grid-template-areas: "banner banner banner" "bar bar bar" "tools sheet work"; }
.designer-banner { grid-area: banner; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #2F6FED; color: #fff; font-size: 14px; }
.designer-banner .ic { width: 20px; height: 20px; stroke: #fff; flex: none; }
.designer-banner span { flex: 1; }
.designer-banner a { color: #fff; font-weight: 600; white-space: nowrap; }
.dt-form { display: grid; gap: 10px; margin: 6px 0 14px; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; }
.dt-form label:not(.check-row) { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.dt-form input:not([type=checkbox]) { min-height: 40px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 8px; font: inherit; font-size: 15px; color: var(--ink); }
.dt-form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.dt-form legend { font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
@media (max-width: 860px) {
  .tiles.masks { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dt-grid { grid-template-columns: repeat(3, 1fr); }
  .designer-banner { font-size: 12px; padding: 6px 10px; }
  .designer .app { grid-template-rows: auto var(--bar-h) minmax(0, 1fr) auto auto; grid-template-areas: "banner" "bar" "work" "sheet" "tools"; }
}

/* ---------- Version 6: Seiten, Ansicht, Ebenen, Bibliotheken, Bildwerkzeuge ---------- */
.save-state { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; margin-left: auto; }
.save-state.ok::before { content: "✓ "; color: var(--good); }
.save-state.warn { color: var(--warn); }
.bar .save-state + .cta { margin-left: 0; }
.page-nav { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); z-index: 2; display: flex; gap: 2px; padding: 3px; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-float); max-width: calc(100% - 24px); overflow-x: auto; }
.page-nav button { border: 0; background: none; min-height: 34px; padding: 0 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; white-space: nowrap; color: var(--ink-soft); }
.page-nav button[aria-selected="true"] { background: var(--ink); color: #fff; }
.page-nav .empty-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #C9C9C9; margin-left: 4px; vertical-align: 2px; }
.viewbar { position: absolute; left: 16px; bottom: 16px; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-float); }
.viewbar .icon-btn { width: 36px; height: 36px; }
.zoom-val { border: 0; background: none; min-width: 58px; height: 36px; font-size: 13px; font-variant-numeric: tabular-nums; border-radius: 8px; }
.zoom-val:hover { background: rgba(52,52,52,.07); }
.vsep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.stage-wrap.zoomed { overflow: auto; justify-content: flex-start; align-items: flex-start; touch-action: pan-x pan-y; }
.stage-wrap.zoomed #stage { margin: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.chip { flex: none; min-height: 34px; padding: 0 12px; border-radius: 17px; border: 1.5px solid var(--line); background: var(--paper); font-size: 13px; white-space: nowrap; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.search-row { display: flex; }
.search-in { width: 100%; min-height: 42px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 16px; background: var(--paper); }
.search-in:focus { border-color: var(--brand); outline: none; }
.tile.suggested { border-color: var(--brand); }
.tile svg { overflow: visible; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 0 25%; border-bottom: 1.5px solid var(--line); }
.placed { display: flex; flex-wrap: wrap; gap: 6px; }
.placed-item { width: 48px; height: 48px; padding: 6px; border: 1.5px solid var(--line); border-radius: 10px; background: repeating-conic-gradient(#f3f3f3 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.placed-item img, .placed-item svg { width: 100%; height: 100%; object-fit: contain; }
.placed-item[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.layer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.layer-row { display: flex; align-items: center; gap: 2px; border: 1.5px solid var(--line); border-radius: 10px; padding: 2px 4px 2px 2px; background: var(--paper); }
.layer-row.on { border-color: var(--brand); background: var(--brand-soft); }
.layer-row.hidden-layer { opacity: .55; }
.layer-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px; border: 0; background: none; text-align: left; font-size: 14px; }
.layer-main span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-main .ic.mini { width: 15px; height: 15px; color: var(--ink-soft); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm .ic { width: 18px; height: 18px; }
.num-row { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--ink-soft); }
.num-row input { width: 72px; min-height: 36px; padding: 0 8px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 15px; }
.flbl { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.tool-body { padding: 6px 24px 24px; overflow-y: auto; }
.align-grid { display: grid; gap: 16px; }
.align-grid h3 { margin: 0 0 8px; font-size: 14px; }
.align-grid .row-btns + .row-btns { margin-top: 8px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.media-btn { display: grid; gap: 4px; padding: 6px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); font-size: 12px; }
.media-btn img { width: 100%; aspect-ratio: 1; object-fit: contain; background: repeating-conic-gradient(#f3f3f3 0 25%, #fff 0 50%) 0 0 / 12px 12px; border-radius: 6px; }
.media-btn:hover { border-color: var(--brand); }
.cutout { display: grid; gap: 14px; }
.cut-prev { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cut-prev figure { margin: 0; display: grid; gap: 6px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.cut-prev img { width: 100%; max-height: 300px; object-fit: contain; border-radius: 10px; background: #f3f3f3; }
.cut-prev figure.checker img { background: repeating-conic-gradient(#e9e9e9 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.cut-wait { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 200px; border-radius: 10px; background: #f6f6f6; padding: 12px; color: var(--ink-soft); }
.spinner { width: 22px; height: 22px; border: 3px solid #ddd; border-right-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.finish-preview.multi { flex-wrap: wrap; gap: 12px; }
.finish-preview figure { margin: 0; display: grid; gap: 4px; justify-items: center; font-size: 12.5px; color: var(--ink-soft); }
.finish-preview.multi img { max-height: 150px; }
.checks li.info { background: #EEF4FF; } .checks li.info .ic { color: #2F6FED; }
.later { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check-row.accept { padding: 10px 12px; border-radius: 10px; background: #FDECEC; }
.dt-form .cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ctx button[aria-pressed="true"] { background: var(--brand-soft); }
@media (max-width: 860px) {
  .save-state { display: none; }
  .bar .save-state + .cta { margin-left: auto; }
  .page-nav { top: 54px; }
  .page-nav button { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
  .tool span { font-size: 10.5px; }
  .cut-prev { grid-template-columns: 1fr; }
  .dt-form .cols2 { grid-template-columns: 1fr; }
}

/* Nur für Screenreader */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#stage:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }

/* ---------- Textil: Stoff & Größen, Maße, Größentabelle ---------- */
.size-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.size-list li { display: grid; grid-template-columns: 3.2em 1fr auto; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 12px; }
.size-name { font-weight: 700; }
.size-note { color: var(--ink-soft); font-size: 12px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .icon-btn { width: 36px; height: 36px; font-size: 18px; font-weight: 700; }
.stepper .icon-btn:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.ctx-dims { font-variant-numeric: tabular-nums; }
.finish-textil { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--panel, #f4f1ec); }
.finish-textil .ic { width: 20px; height: 20px; flex: none; }
.finish-textil span { flex: 1; }
.size-chart { padding: 8px 24px 24px; display: grid; gap: 12px; overflow-y: auto; }
.size-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.size-table th, .size-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.size-table thead th { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.size-chart .field { display: grid; grid-template-columns: 1fr; gap: 6px; font-weight: 600; }
.size-chart input { padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; font: inherit; }

