/* Farben und Maße orientieren sich an den Apple Human Interface Guidelines
   (Systemfarben, gruppierte Hintergründe, Trennlinien, 44-pt-Tippflächen). */

:root {
  --accent: #007aff;
  --accent-pressed: #0062cc;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --red: #ff3b30;
  --green: #34c759;
  --orange: #ff9500;

  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --separator-opaque: #c6c6c8;
  --fill: rgba(120, 120, 128, 0.2);
  --fill-2: rgba(120, 120, 128, 0.16);
  --fill-3: rgba(118, 118, 128, 0.12);

  --bg: #f2f2f7;
  --bg-2: #ffffff;
  --bg-3: #f2f2f7;
  --sidebar: rgba(236, 236, 241, 0.82);
  --bar: rgba(249, 249, 249, 0.86);
  --sheet: #ffffff;
  --canvas: #e5e5ea;

  --shadow-1: 0 0.5px 0 rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-knob: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06);

  --r-s: 8px;
  --r-m: 10px;
  --r-l: 14px;

  --row: 44px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0a84ff;
    --accent-pressed: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.2);
    --red: #ff453a;
    --green: #30d158;
    --orange: #ff9f0a;

    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.6);
    --separator-opaque: #38383a;
    --fill: rgba(120, 120, 128, 0.36);
    --fill-2: rgba(120, 120, 128, 0.32);
    --fill-3: rgba(118, 118, 128, 0.24);

    --bg: #000000;
    --bg-2: #1c1c1e;
    --bg-3: #2c2c2e;
    --sidebar: rgba(28, 28, 30, 0.82);
    --bar: rgba(22, 22, 23, 0.86);
    --sheet: #1c1c1e;
    --canvas: #111113;

    --shadow-1: 0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --shadow-2: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 16px 40px rgba(0, 0, 0, 0.6);
  }
}

@media (pointer: coarse) {
  :root { --row: 48px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.5); outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Grundlayout ---------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-right: 0.5px solid var(--separator);
  overflow-y: auto;
  padding: 14px 10px 16px;
}

.sidebar-head { display: flex; align-items: center; gap: 9px; padding: 6px 10px 14px; }
.app-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--red);
  position: relative;
}
.app-mark::after {
  content: ""; position: absolute; inset: 6px 7px 5px;
  border-radius: 1.5px; background: #fff;
  box-shadow: inset 0 3px 0 -1.5px var(--red);
}
.app-name { font-weight: 600; font-size: 15px; }

.nav-group + .nav-group { margin-top: 14px; }
.nav-title {
  font-size: 11px; font-weight: 600; color: var(--label-2);
  padding: 0 10px 4px; margin: 0;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 32px; padding: 5px 10px; border-radius: 7px;
  text-decoration: none; color: var(--label); font-size: 14px;
}
.nav-item svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.nav-item:hover { background: var(--fill-3); }
.nav-item[aria-current="page"] { background: var(--fill); font-weight: 500; }
@media (pointer: coarse) { .nav-item { min-height: 44px; } }

.sidebar-foot { margin: auto 10px 0; padding-top: 20px; font-size: 12px; color: var(--label-2); }

.main { min-width: 0; padding: 0 0 64px; }
.main:focus { outline: none; }

/* ---------- Werkzeugseite ---------- */

.page { max-width: 780px; margin: 0 auto; padding: 40px 32px 0; }
.page.wide { max-width: 1120px; }

.nav-bar { display: none; }

.page-head { margin-bottom: 24px; }
.page-title {
  font-family: var(--font-display);
  font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.page-sub { margin: 0; color: var(--label-2); font-size: 15px; max-width: 58ch; }

.section { margin-top: 28px; }
.page-head + div > :first-child { margin-top: 0; }
.section-title {
  font-size: 13px; font-weight: 400; color: var(--label-2);
  text-transform: uppercase; letter-spacing: 0.02em;
  margin: 0 0 7px 16px;
}
.section-foot { font-size: 13px; color: var(--label-2); margin: 7px 16px 0; }

.group {
  background: var(--bg-2);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.row {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--row); padding: 6px 16px;
  position: relative;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0;
  border-top: 0.5px solid var(--separator);
}
.row.with-icon + .row::before, .row + .row.with-icon::before { left: 56px; }
.row-label { flex: 1 1 auto; min-width: 0; }
.row-label small { display: block; color: var(--label-2); font-size: 13px; }
.row-value { color: var(--label-2); flex: none; }
.row.stack { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 11px; padding-bottom: 12px; }
.row.stack .row-label { flex: none; }

/* ---------- Ablagefläche ---------- */

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 240px; padding: 32px 24px;
  border-radius: var(--r-l);
  border: 1.5px dashed var(--separator-opaque);
  background: var(--bg-2);
  text-align: center;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.drop.compact { min-height: 0; padding: 18px; flex-direction: row; gap: 14px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { width: 44px; height: 44px; color: var(--label-3); }
.drop.compact .drop-icon { display: none; }
.drop-text { margin: 0; color: var(--label-2); }
.drop-text strong { display: block; color: var(--label); font-weight: 600; font-size: 17px; margin-bottom: 2px; }
.drop.compact .drop-text strong { display: inline; font-size: 15px; font-weight: 400; color: var(--label-2); }

/* ---------- Bedienelemente ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 16px;
  border: 0; border-radius: var(--r-s);
  background: var(--fill-2); color: var(--accent);
  font-size: 15px; font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.12s var(--ease), opacity 0.12s var(--ease);
  user-select: none; -webkit-user-select: none;
}
.btn:hover { background: var(--fill); }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-pressed); }
.btn.destructive { color: var(--red); }
.btn.plain { background: transparent; padding: 0 8px; }
.btn.plain:hover { background: var(--fill-3); }
.btn.large { min-height: 50px; padding: 0 24px; font-size: 17px; font-weight: 600; border-radius: 12px; }
.btn.icon { padding: 0; width: 36px; }
.btn.small { min-height: 30px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn.small.icon { width: 30px; padding: 0; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn.icon { width: 44px; } .btn.small { min-height: 36px; } .btn.small.icon { width: 36px; } }

.actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.actions .hint { margin-right: auto; color: var(--label-2); font-size: 13px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Segmentierte Auswahl */
.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--fill-3); border-radius: 9px; padding: 2px; gap: 2px;
  max-width: 100%;
}
.segmented.full { display: grid; width: 100%; }
.segmented button {
  border: 0; background: transparent; border-radius: 7px;
  min-height: 28px; padding: 0 12px; font-size: 13px; font-weight: 500;
  color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segmented button[aria-checked="true"] { background: var(--bg-2); box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 3px 1px rgba(0,0,0,0.04); }
@media (prefers-color-scheme: dark) { .segmented button[aria-checked="true"] { background: #636366; } }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button svg { width: 15px; height: 15px; flex: none; }
.segmented button span { overflow: hidden; text-overflow: ellipsis; }
@media (pointer: coarse) { .segmented button { min-height: 34px; } }

/* Schalter */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 31px; background: var(--fill);
  transition: background-color 0.2s var(--ease);
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-knob);
  transition: transform 0.2s var(--ease);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid rgba(0, 122, 255, 0.5); outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* Eingabefelder */
.field {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 0; border-radius: var(--r-s);
  background: var(--fill-3);
  font-size: 15px;
}
.field::placeholder { color: var(--label-3); }
.field:focus-visible { outline: 3px solid rgba(0, 122, 255, 0.5); outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; }
.field.inline { width: auto; min-width: 0; text-align: right; background: transparent; padding-right: 0; }
.field.inline:focus { background: var(--fill-3); padding-right: 10px; }
.field.num { width: 84px; text-align: right; }
textarea.field { resize: vertical; min-height: 80px; line-height: 1.4; }
select.field {
  appearance: none; -webkit-appearance: none;
  padding-right: 28px; width: auto; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M1.5 5 5 1.5 8.5 5M1.5 9 5 12.5 8.5 9' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
@media (pointer: coarse) { .field { min-height: 40px; font-size: 16px; } }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; height: 28px; }
input[type="color"] {
  -webkit-appearance: none; appearance: none; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer; flex: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0.5px solid var(--separator); border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: 0.5px solid var(--separator); border-radius: 50%; }

.slider-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.slider-row output { min-width: 52px; text-align: right; color: var(--label-2); font-variant-numeric: tabular-nums; }

/* Positionsraster */
.pos-grid { display: grid; grid-template-columns: repeat(3, 28px); gap: 4px; padding: 4px; background: var(--fill-3); border-radius: 9px; }
.pos-grid button { width: 28px; height: 22px; border: 0; border-radius: 5px; background: transparent; display: grid; place-items: center; }
.pos-grid button::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--label-3); }
.pos-grid button[aria-checked="true"] { background: var(--bg-2); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.pos-grid button[aria-checked="true"]::after { background: var(--accent); }
.pos-grid button:disabled { display: none; }

/* ---------- Dateiliste ---------- */

.file-row { gap: 12px; }
.file-thumb {
  width: 32px; height: 40px; flex: none; border-radius: 3px;
  background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator);
  display: grid; place-items: center; overflow: hidden;
}
.file-thumb canvas, .file-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.file-thumb svg { width: 18px; height: 18px; color: var(--label-3); }
.file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 13px; color: var(--label-2); }
.file-tools { display: flex; gap: 2px; flex: none; }
.file-row.dragging { opacity: 0.4; }
.file-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.file-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.handle { cursor: grab; color: var(--label-3); touch-action: none; }
.handle svg { width: 18px; height: 18px; }

.file-row.with-icon + .row::before, .row + .file-row::before { left: 60px; }

/* ---------- Seitenraster ---------- */

.page-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 20px 16px; padding: 20px; background: var(--bg-2); border-radius: var(--r-m); box-shadow: var(--shadow-1);
}
.page-card { display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; }
.page-card .sheet {
  width: 100%; aspect-ratio: 1 / 1; display: grid; place-items: center; contain: size;
  border-radius: 8px; padding: 8px; position: relative; cursor: grab;
  transition: background-color 0.12s var(--ease);
}
.page-card .sheet:hover { background: var(--fill-3); }
.page-card .paper {
  max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; background: #fff;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.12);
  transition: transform 0.25s var(--ease);
  display: block;
}
.page-card .paper.placeholder { width: 70%; aspect-ratio: 1 / 1.414; background: var(--bg-3); }
.page-card.selected .sheet { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.page-card.dragging { opacity: 0.35; }
.page-card.drop-before::before, .page-card.drop-after::after {
  content: ""; position: absolute; top: 4px; bottom: 34px; width: 3px; border-radius: 2px; background: var(--accent);
}
.page-card.drop-before::before { left: -10px; }
.page-card.drop-after::after { right: -10px; }
.page-card .label { font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.page-card .card-tools {
  display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s var(--ease);
  position: absolute; top: 6px; right: 6px; z-index: 2;
}
.page-card:hover .card-tools, .page-card:focus-within .card-tools { opacity: 1; }
@media (hover: none) { .page-card .card-tools { opacity: 1; } }
.card-tools button {
  width: 28px; height: 28px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bar); color: var(--label);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.card-tools button svg { width: 15px; height: 15px; }
.card-tools button.del { color: var(--red); }
.page-card .check {
  position: absolute; left: 12px; bottom: 40px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; opacity: 0; transform: scale(0.8);
  transition: opacity 0.12s, transform 0.12s;
  pointer-events: none;
}
.page-card .check svg { width: 13px; height: 13px; }
.page-card.selected .check { opacity: 1; transform: none; }

.grid-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.grid-toolbar .count { margin-right: auto; color: var(--label-2); font-size: 13px; }

/* ---------- Ergebnis ---------- */

.result { text-align: center; padding: 36px 24px 28px; }
.result-mark {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; background: var(--green); color: #fff;
}
.result-mark svg { width: 28px; height: 28px; }
.result h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.015em; }
.result p { margin: 0; color: var(--label-2); }
.result .actions { justify-content: center; margin-top: 20px; }
.result-list { margin-top: 20px; text-align: left; }
.savings { color: var(--green); font-weight: 600; }
.savings.none { color: var(--label-2); font-weight: 400; }

/* ---------- Hinweise ---------- */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-m); margin-top: 16px;
  background: var(--fill-3); font-size: 13px; color: var(--label);
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--orange); }
.notice.error svg { color: var(--red); }
.notice p { margin: 0; }

.toasts {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 11px 18px; border-radius: 22px; font-size: 14px; font-weight: 500;
  background: rgba(30, 30, 32, 0.92); color: #fff;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toast-in 0.25s var(--ease);
  max-width: 100%;
}
.toast.error { background: rgba(200, 40, 32, 0.95); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Sheets / Dialoge ---------- */

.backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.32);
  animation: fade-in 0.2s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }
.dialog {
  width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--sheet); border-radius: var(--r-l); box-shadow: var(--shadow-2);
  padding: 22px 20px 18px;
  animation: dialog-in 0.25s var(--ease);
}
.dialog.wide { width: min(620px, 100%); }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.96); } }
.dialog h2 { font-size: 17px; font-weight: 600; margin: 0 0 6px; text-align: center; }
.dialog > p { margin: 0 0 16px; text-align: center; color: var(--label-2); font-size: 13px; }
.dialog .actions { margin-top: 18px; }
.dialog .actions .btn { flex: 1; }

.sig-pad {
  width: 100%; height: 200px; border-radius: var(--r-m); background: #fff; touch-action: none;
  box-shadow: inset 0 0 0 0.5px var(--separator); display: block; cursor: crosshair;
}
.sig-line { position: relative; }
.sig-line::after { content: ""; position: absolute; left: 24px; right: 24px; bottom: 44px; border-top: 1px solid #d1d1d6; pointer-events: none; }
.sig-colors { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.sig-colors button { width: 26px; height: 26px; border-radius: 50%; border: 0; box-shadow: 0 0 0 0.5px var(--separator); }
.sig-colors button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--accent); }

/* ---------- Editor ---------- */

.editor { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
.editor-stage {
  background: var(--canvas); border-radius: var(--r-m); padding: 24px; overflow: auto;
  display: flex; justify-content: center; min-height: 420px;
  box-shadow: inset 0 0 0 0.5px var(--separator);
}
.editor-page { position: relative; box-shadow: 0 0 0 0.5px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.16); background: #fff; flex: none; }
.editor-page canvas { display: block; }
.editor-layer { position: absolute; inset: 0; }
.editor-layer.placing { cursor: crosshair; touch-action: none; }
.editor-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 0 12px; background: var(--bg);
}
.editor-toolbar .segmented button { display: inline-flex; align-items: center; gap: 6px; }
.editor-toolbar .segmented svg { width: 15px; height: 15px; }
.editor-toolbar .spacer { flex: 1; }
.pager { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--label-2); }

.el {
  position: absolute; outline: 1px solid transparent; touch-action: none;
}
.el.sel { outline: 1px solid var(--accent); }
.el.text {
  white-space: pre; font-family: Helvetica, Arial, sans-serif; line-height: 1.2;
  cursor: move; padding: 0; min-width: 4px; min-height: 1em;
  user-select: none; -webkit-user-select: none;
}
.el.text.editing { cursor: text; user-select: text; -webkit-user-select: text; outline: 1px dashed var(--accent); }
.el.box { cursor: move; }
.el.img { cursor: move; }
.el.img img { width: 100%; height: 100%; display: block; pointer-events: none; }
.el .grip {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--accent); cursor: nwse-resize; display: none;
}
.el.sel .grip { display: block; }
@media (pointer: coarse) { .el .grip { width: 22px; height: 22px; right: -11px; bottom: -11px; } }

.inspector .group + .group { margin-top: 16px; }
.inspector .empty { padding: 16px; color: var(--label-2); font-size: 13px; text-align: center; }

/* ---------- Startseite (mobil) ---------- */

.home { display: none; }

/* ---------- Mobil ---------- */

@media (max-width: 1000px) and (min-width: 761px) {
  .editor { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { display: none; }
  .home { display: block; padding: 8px 16px 40px; }
  .home-title { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 44px 4px 6px; }
  .home-sub { margin: 0 4px 22px; color: var(--label-2); font-size: 15px; }
  .home .section { margin-top: 24px; }
  .home .row { text-decoration: none; color: var(--label); }
  .home .row svg.icon { width: 29px; height: 29px; padding: 5px; border-radius: 7px; background: var(--accent); color: #fff; flex: none; }
  .home .row .chev { width: 8px; height: 13px; color: var(--label-3); flex: none; }
  .home .row + .row::before { left: 57px; }

  .nav-bar {
    display: flex; align-items: center; position: sticky; top: 0; z-index: 20;
    min-height: 44px; padding: env(safe-area-inset-top) 8px 0;
    background: var(--bar);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--separator);
  }
  .nav-back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); text-decoration: none; font-size: 17px; padding: 10px 8px; }
  .nav-back svg { width: 12px; height: 20px; }

  .page { padding: 12px 16px 0; }
  .page-title { font-size: 30px; }
  .drop { min-height: 200px; }
  .actions { margin-top: 22px; }
  .actions .btn.primary.large { width: 100%; }
  .actions .hint { width: 100%; margin: 0; text-align: center; }
  .page-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); padding: 14px; gap: 14px 10px; }
  .editor { grid-template-columns: 1fr; }
  .editor-toolbar .segmented button span { display: none; }
  .editor-toolbar .segmented button { padding: 0 10px; }
  .editor-toolbar .segmented { width: 100%; display: grid; }
  .editor-stage { padding: 12px; min-height: 300px; }
  .section-title { margin-left: 16px; }
  .row.split-mobile { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.noscript { padding: 40px; text-align: center; }

/* ---------- Konverter ---------- */

.app-mark { background: #5856d6; display: grid; place-items: center; }
.app-mark::after { display: none; }
.app-mark svg { width: 17px; height: 17px; color: #fff; }

.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 8px; }
.target {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px;
  min-height: 54px; padding: 9px 12px; text-align: left;
  border: 0; border-radius: var(--r-m); background: var(--bg-2); box-shadow: var(--shadow-1);
  transition: background-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.target:hover { background: color-mix(in srgb, var(--bg-2) 92%, var(--label)); }
.target[aria-checked="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.target-label { font-size: 14px; font-weight: 600; }
.target-note { font-size: 12px; color: var(--label-2); line-height: 1.25; }
.target-sub { font-size: 13px; color: var(--label-2); margin: 16px 4px 8px; }
.target-wrap > .target-sub:first-child { margin-top: 0; }

.fmt-badge {
  flex: none; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--label-2);
  background: var(--fill-3); padding: 3px 7px; border-radius: 6px; max-width: 110px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fmt-line { display: flex; gap: 12px; font-size: 13px; line-height: 1.45; }
.fmt-key { flex: none; width: 64px; color: var(--label-2); }

.conv-group + .conv-group { margin-top: 36px; padding-top: 28px; border-top: 0.5px solid var(--separator); }
.conv-options:empty { display: none; }

@media (max-width: 760px) {
  .target-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .fmt-key { width: 56px; }
}
