/* Editor: Vorschau links, Einstellungen rechts.
   Gestaltung nach BRAND.md: drückbare Knöpfe, Fredoka für Knöpfe und Titel, Inter für dichte Bedienelemente,
   Geist Mono für Zahlen. Blau ist die Farbe für „gewählt“ und für den Hauptknopf.
   Die Klassen und IDs kommen aus editor.js und editor.html. Bitte nicht umbenennen. */

.editor-page {
  --edge: var(--line-2);            /* Kante eines Bedienelements */
  --sel: var(--blue);               /* gewählt: Rand */
  --sel-bg: var(--blue-t);          /* gewählt: Fläche */
  --sel-fg: var(--blue-d);          /* gewählt: Text */
  --warn-ink: #7A4A00;
  --err-ink: #A3270E;
  height: 100vh; overflow: hidden; display: flex; flex-direction: column;
}

/* ---------- Kopfzeile ---------- */
.ed-top {
  height: 64px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 18px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.ed-top .logo { flex: none; }
.ed-top .logo .wm { font-size: 24px; }
.crumbs {
  display: flex; gap: 9px; align-items: center; min-width: 0; padding-left: 16px; border-left: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--fg-muted);
}
.crumbs a { white-space: nowrap; border-radius: 6px; }
.crumbs a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.crumbs span { color: var(--line-2); }
.crumbs b {
  font-family: var(--font-display); font-weight: 600; font-size: 16.5px; letter-spacing: -.005em; text-transform: none;
  color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Umschalter in der Kopfzeile und auf der Bühne: gleiche Form, gleiche Schrift */
.mode-seg, .view-btns, .view-mode { padding: 4px; gap: 2px; }
.mode-seg button, .view-btns button, .view-mode button {
  font-family: var(--font-display); font-weight: 500; font-size: 14px; letter-spacing: 0; line-height: 1.2;
  padding: 6px 14px; color: var(--ink-2); white-space: nowrap;
}
.mode-seg button:hover, .view-btns button:hover, .view-mode button:hover { color: var(--ink); }
.mode-seg button[aria-pressed="true"], .view-btns button[aria-pressed="true"], .view-mode button[aria-pressed="true"] {
  background: var(--ink); color: #fff; font-weight: 600;
}
.mode-seg { margin: 0 auto; flex: none; box-shadow: inset 0 0 0 1px var(--line); }

.ed-actions { display: flex; align-items: center; gap: 8px; flex: none; padding-bottom: 3px; /* Platz für die Knopfkante */ }
.ed-actions .icon-btn svg { width: 17px; height: 17px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { transform: none; box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); }
#dlBtn svg { width: 17px; height: 17px; flex: none; }
#dlBtn .dl-caret { width: 12px; height: 12px; margin-left: -2px; opacity: .85; }

/* Download-Menü */
.dl-wrap { position: relative; }
.dl-menu {
  position: absolute; right: 0; top: calc(100% + 12px); width: 324px; max-width: calc(100vw - 24px);
  background: var(--bg-elev); border-radius: 18px; box-shadow: var(--shadow-pop); padding: 6px; display: none; z-index: 60;
}
.dl-menu.open { display: grid; gap: 2px; }
.dl-menu.up { top: auto; bottom: calc(100% + 12px); }
.dl-item {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); column-gap: 12px; row-gap: 1px; align-items: center;
  width: 100%; text-align: left; border: 0; background: none; padding: 10px; border-radius: 13px; cursor: pointer;
  font-family: var(--font-ui); color: var(--ink);
}
.dl-item::before {
  content: "⤓"; grid-row: 1 / span 2; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--blue-t); color: var(--blue-d); font-size: 18px; font-weight: 700; line-height: 1;
}
.dl-item:first-child::before { background: var(--blue); color: #fff; box-shadow: 0 2px 0 var(--blue-d); }
.dl-item b { display: block; font-family: var(--font-display); font-size: 15.5px; font-weight: 600; line-height: 1.25; align-self: end; }
.dl-item span { font-size: 12.5px; line-height: 1.35; color: var(--fg-muted); align-self: start; }
.dl-item:hover { background: var(--paper-2); }
.dl-item:active { background: var(--blue-t); }
.dl-item:focus-visible { outline-offset: -2px; }

/* ---------- Bühne (3D-Vorschau) ---------- */
.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 420px; background: var(--bg); }
.ed-stage {
  position: relative; min-width: 0; margin: 14px; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden;
  background: radial-gradient(80% 70% at 50% 42%, #FFFFFF 0%, #F9F5EC 52%, var(--paper-2) 100%);
}
/* Schichtlinien als Abschluss der Fläche */
.ed-stage::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 54px; pointer-events: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0 5px, rgba(22, 24, 31, .06) 5px 6px);
  -webkit-mask-image: linear-gradient(to top, #000, transparent); mask-image: linear-gradient(to top, #000, transparent);
}
.ed-stage canvas { position: relative; width: 100%; height: 100%; touch-action: none; }
.ed-stage.stale canvas { opacity: .45; filter: grayscale(.4); transition: opacity .2s; }

.view-btns, .view-mode { background: var(--bg-elev); box-shadow: 0 0 0 1px var(--border), 0 2px 0 var(--line), 0 8px 20px rgba(22, 24, 31, .06); }
.view-btns { position: absolute; top: 14px; right: 14px; z-index: 2; }
.view-btns button[data-view="reset"] { padding: 6px 9px; display: inline-grid; place-items: center; font-size: 16px; }
.view-btns button[data-view="reset"] svg { width: 16px; height: 16px; }
.view-mode[hidden] { display: none; }
.stage-left { position: absolute; top: 14px; left: 14px; display: grid; gap: 8px; justify-items: start; max-width: min(46%, 380px); z-index: 2; }

/* Kleine Angaben auf der Bühne */
.chip {
  display: inline-block; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; line-height: 1.35; color: var(--fg-muted);
  box-shadow: 0 1px 0 var(--line), 0 6px 16px rgba(22, 24, 31, .05);
}
.chip:empty { display: none; }
.stage-chips { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 28px); z-index: 1; }
#chipSize { color: var(--ink); font-weight: 600; }

/* Zustand: rechnet (dunkel, mit Drehrad) / Hinweis (gelb, ⚠) / Fehler (rot, Ausrufezeichen) */
.stage-status .chip {
  display: inline-flex; gap: 8px; align-items: center; padding: 7px 13px 7px 10px; border-radius: var(--r-full);
  background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 3px 0 #000, 0 8px 20px rgba(22, 24, 31, .12);
}
.spinner { width: 13px; height: 13px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .28); border-top-color: var(--sun); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-status .err {
  align-items: flex-start; gap: 9px; padding: 9px 13px 9px 9px; border-radius: 14px; max-width: 340px;
  background: var(--coral-t); color: var(--err-ink); border: 1.5px solid var(--coral); box-shadow: 0 3px 0 var(--coral-d), 0 8px 20px rgba(22, 24, 31, .08);
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; line-height: 1.4;
}
.stage-status .err::before {
  content: "!"; flex: none; width: 20px; height: 20px; margin-top: -1px; border-radius: 50%; display: grid; place-items: center;
  background: var(--coral); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 14px; line-height: 1;
}
.warn-list { display: grid; gap: 6px; justify-items: start; }
.warn-chip {
  background: var(--sun-t); color: var(--warn-ink); border: 1.5px solid #EDC766; border-radius: 12px; padding: 7px 11px;
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 500; line-height: 1.4; white-space: normal;
}
.cust-note { position: absolute; bottom: 14px; right: 14px; display: none; z-index: 1; }
.customer .cust-note { display: block; }
.cust-note .chip {
  background: var(--sun); color: var(--pill-ink); border-color: transparent; border-radius: 8px; padding: 5px 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; box-shadow: 0 2px 0 var(--sun-d);
}

/* ---------- Panel ---------- */
.ed-panel { border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; min-height: 0; min-width: 0; font-family: var(--font-ui); }

/* Schritte: nummerierter Knopf, darunter der Name. Erledigte Schritte sind hell eingefärbt, der aktuelle ist blau. */
.ed-tabs {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); flex: none;
  padding: 12px 8px 9px; background: var(--paper-2); border-bottom: 1px solid var(--border);
}
.ed-tabs:empty { display: none; }
.ed-tab {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 8px; min-width: 0;
  border: 0; background: none; cursor: pointer; padding: 2px 2px 4px; border-radius: 12px;
  color: var(--ink-2); font-family: var(--font-display); -webkit-tap-highlight-color: transparent;
}
.ed-tab small {
  position: relative; z-index: 1; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: -.02em; color: var(--ink-2);
  background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2);
  transition: transform .09s ease, box-shadow .09s ease;
}
.ed-tab span { max-width: 100%; font-size: 13.5px; font-weight: 500; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Verbindungslinie zum nächsten Schritt */
.ed-tab:not(:last-child)::after {
  content: ""; position: absolute; top: 17px; left: calc(50% + 21px); width: calc(100% - 42px); height: 2px; border-radius: 2px; background: var(--line-2);
}
.ed-tab:hover { color: var(--ink); }
.ed-tab:hover small { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 2px 0 var(--line-2); }
.ed-tab:active small { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 0 0 var(--line-2); }
/* erledigt: alle Schritte vor dem aktuellen */
.ed-tab:has(~ .ed-tab[aria-selected="true"]) small { background: var(--blue-t); color: var(--blue-d); box-shadow: inset 0 0 0 1.5px #B9C5FB, 0 3px 0 #B9C5FB; }
.ed-tab:has(~ .ed-tab[aria-selected="true"])::after { background: var(--blue); }
.ed-tab:has(~ .ed-tab[aria-selected="true"]):hover small { box-shadow: inset 0 0 0 1.5px #B9C5FB, 0 2px 0 #B9C5FB; }
.ed-tab:has(~ .ed-tab[aria-selected="true"]):active small { box-shadow: inset 0 0 0 1.5px #B9C5FB, 0 0 0 #B9C5FB; }
/* aktuell */
.ed-tab[aria-selected="true"] { color: var(--ink); }
.ed-tab[aria-selected="true"] span { font-weight: 600; }
.ed-tab[aria-selected="true"] small, .ed-tab[aria-selected="true"]:hover small { background: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue-d); transform: none; }
.ed-tab[aria-selected="true"]:active small { transform: translateY(3px); box-shadow: 0 0 0 var(--blue-d); }
.ed-tab:focus-visible { outline-offset: -1px; }

.ed-scroll {
  flex: 1; overflow-y: auto; padding: 20px 18px 30px; display: grid; gap: 20px 12px; align-content: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.ed-scroll > * { grid-column: span 2; min-width: 0; }
.ed-scroll > .half { grid-column: span 1; }

/* Fusszeile des Panels: drückbare Knöpfe aus site.css. Unten bleibt Platz für die Knopfkante. */
.ed-foot {
  position: relative; flex: none; display: flex; gap: 10px; padding: 12px 18px calc(13px + var(--press));
  border-top: 1px solid var(--border); background: var(--bg);
}
.ed-foot .btn { height: 50px; min-width: 0; font-size: 16.5px; }
.ed-foot .btn-ghost { padding: 0 18px; }
.ed-foot .grow { flex: 1; }

/* ---------- Felder ---------- */
.f-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 22px; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.f-label small {
  flex: none; font-family: var(--font-mono); font-weight: 500; font-size: 11px; line-height: 1; color: var(--ink-2);
  background: var(--paper-2); padding: 4px 7px; border-radius: 6px; white-space: nowrap;
}
.f-hint { font-size: 12.5px; color: var(--fg-muted); margin-top: 7px; line-height: 1.45; }

/* Textfeld: leicht vertieft, damit es sich von den erhabenen Knöpfen abhebt */
.f-input {
  width: 100%; height: 48px; border: 0; border-radius: 12px; padding: 0 14px; background: var(--bg-elev); color: var(--ink);
  font-family: var(--font-ui); font-size: 15.5px; font-weight: 500;
  box-shadow: inset 0 0 0 1.5px var(--edge), inset 0 3px 0 rgba(22, 24, 31, .045);
}
.f-input::placeholder { color: var(--ink-3); font-weight: 400; }
.f-input:hover { box-shadow: inset 0 0 0 1.5px var(--ink-3), inset 0 3px 0 rgba(22, 24, 31, .045); }
.f-input:focus-visible, .range-num input:focus-visible {
  outline: 2.5px solid var(--blue); outline-offset: -1px; box-shadow: 0 0 0 5px var(--blue-t);
}
.f-input[type="number"] { font-family: var(--font-mono); font-size: 14.5px; }

/* Schriftwahl */
.font-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px 8px; padding-bottom: 3px; }
.font-card {
  border: 0; background: var(--bg-elev); border-radius: 13px; padding: 11px 8px 8px; cursor: pointer; text-align: center; min-width: 0; color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--edge), 0 3px 0 var(--edge);
  transition: transform .09s ease, box-shadow .09s ease;
}
.font-card .sample { display: block; font-size: 22px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-card small { display: block; font-family: var(--font-ui); font-size: 11px; font-weight: 500; color: var(--ink-2); margin-top: 3px; }
.font-card:hover { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 2px 0 var(--edge); }
.font-card:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 0 0 var(--edge); }
.font-card[aria-pressed="true"], .font-card[aria-pressed="true"]:hover {
  background: var(--sel-bg); color: var(--sel-fg); transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--sel);
}
.font-card[aria-pressed="true"] small { color: var(--sel-fg); font-weight: 600; }
.font-card[aria-pressed="true"] small::before { content: "✓ "; }

/* Kleiner Nebenknopf (z. B. „Alle Schriften zeigen“) */
.link-btn {
  display: block; width: 100%; height: 40px; margin: 10px 0 3px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--bg-elev); color: var(--ink); font-family: var(--font-display); font-size: 14.5px; font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--edge), 0 3px 0 var(--edge);
  transition: transform .09s ease, box-shadow .09s ease;
}
.link-btn:hover { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 2px 0 var(--edge); }
.link-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 0 0 var(--edge); }

/* Schieberegler mit Zahlenfeld */
.range-row { display: grid; grid-template-columns: 1fr; }
.range-num { display: flex; align-items: center; gap: 5px; flex: none; }
.range-num input {
  width: 68px; height: 30px; border: 0; border-radius: 9px; text-align: right; padding: 0 8px; background: var(--bg-elev); color: var(--ink);
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 500;
  box-shadow: inset 0 0 0 1.5px var(--edge), inset 0 2px 0 rgba(22, 24, 31, .04);
}
.range-num input:hover { box-shadow: inset 0 0 0 1.5px var(--ink-3), inset 0 2px 0 rgba(22, 24, 31, .04); }
.range-num span { min-width: 16px; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); font-weight: 500; }

/* Der Regler-Griff ist ein kleiner Knopf mit zwei Löchern (Markenzeichen). Die blaue Füllung links vom Griff
   malt der Griff selbst (border-image), in Firefox macht das ::-moz-range-progress. */
input[type="range"] {
  --thumb: 22px; --track: 8px;
  --knob: radial-gradient(circle at 35% 50%, #fff 1.5px, transparent 2.1px), radial-gradient(circle at 65% 50%, #fff 1.5px, transparent 2.1px), var(--blue);
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 32px; margin: 0; padding: 0;
  background: none; cursor: pointer; accent-color: var(--blue);
}
input[type="range"]:focus-visible { outline: none; } /* der Fokusring liegt um den Griff */
input[type="range"]::-webkit-slider-runnable-track { height: var(--track); border-radius: 99px; background: var(--line); box-shadow: inset 0 1px 0 rgba(22, 24, 31, .08); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); margin-top: calc((var(--track) - var(--thumb)) / 2);
  border-radius: 50%; background: var(--knob); box-shadow: 0 2px 0 var(--blue-d);
  border-image: linear-gradient(90deg, var(--blue) 50%, transparent 0) 0 1 / calc(50% - var(--track) / 2) 100vw / 0 calc(100vw - 5px);
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 2px 0 var(--blue-d), 0 0 0 4px rgba(45, 78, 245, .16); }
input[type="range"]:active::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(45, 78, 245, .26); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4.5px var(--blue); }
@supports selector(::-webkit-slider-thumb) {
  /* schneidet die Füllung am Rand ab und rundet ihr linkes Ende */
  input[type="range"] {
    overflow: hidden;
    -webkit-mask:
      linear-gradient(#000 0 0) right / calc(100% - 4px) 100% no-repeat,
      linear-gradient(#000 0 0) left top / 4px calc(50% - 4px) no-repeat,
      linear-gradient(#000 0 0) left bottom / 4px calc(50% - 4px) no-repeat,
      radial-gradient(circle 4px at 4px 50%, #000 3.6px, transparent 4px) no-repeat;
    mask:
      linear-gradient(#000 0 0) right / calc(100% - 4px) 100% no-repeat,
      linear-gradient(#000 0 0) left top / 4px calc(50% - 4px) no-repeat,
      linear-gradient(#000 0 0) left bottom / 4px calc(50% - 4px) no-repeat,
      radial-gradient(circle 4px at 4px 50%, #000 3.6px, transparent 4px) no-repeat;
  }
}
input[type="range"]::-moz-range-track { height: var(--track); border-radius: 99px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: var(--track); border-radius: 99px; background: var(--blue); }
input[type="range"]::-moz-range-thumb {
  width: var(--thumb); height: var(--thumb); border: 0; border-radius: 50%; background: var(--knob); box-shadow: 0 2px 0 var(--blue-d);
}
input[type="range"]:hover::-moz-range-thumb { box-shadow: 0 2px 0 var(--blue-d), 0 0 0 4px rgba(45, 78, 245, .16); }
input[type="range"]:active::-moz-range-thumb { box-shadow: 0 0 0 5px rgba(45, 78, 245, .26); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4.5px var(--blue); }
@media (forced-colors: active) {
  input[type="range"] { -webkit-appearance: auto; appearance: auto; overflow: visible; -webkit-mask: none; mask: none; }
  input[type="range"]:focus-visible { outline: 2px solid Highlight; }
}

/* Auswahl-Knöpfe: der gewählte ist eingedrückt */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 9px 8px; padding-bottom: 3px; }
.choice-btn {
  height: 42px; border: 0; border-radius: 12px; background: var(--bg-elev); color: var(--ink); cursor: pointer;
  font-family: var(--font-display); font-size: 14.5px; font-weight: 500;
  box-shadow: inset 0 0 0 1.5px var(--edge), 0 3px 0 var(--edge);
  transition: transform .09s ease, box-shadow .09s ease;
}
/* lange Namen brechen um, statt abgeschnitten zu werden */
.choice-grid .choice-btn { height: auto; min-height: 42px; padding: 5px 6px; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; text-wrap: balance; }
.choice-btn:hover { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 2px 0 var(--edge); }
.choice-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 0 0 var(--edge); }
.choice-btn[aria-pressed="true"], .choice-btn[aria-pressed="true"]:hover {
  background: var(--sel-bg); color: var(--sel-fg); transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--sel);
}
.printer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px 8px; padding-bottom: 3px; }
.printer-grid .choice-btn {
  height: auto; min-height: 54px; padding: 9px 12px; text-align: left; white-space: normal;
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; line-height: 1.3;
}
.printer-grid .choice-btn small { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 500; }

/* Schalter: der Griff ist ebenfalls ein kleiner Knopf */
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 30px; font-size: 13.5px; font-weight: 600; }
.switch {
  width: 50px; height: 30px; border-radius: 99px; background: var(--line-2); border: 0; position: relative; cursor: pointer; flex: none;
  box-shadow: inset 0 2px 0 rgba(22, 24, 31, .1); transition: background .2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 50%, var(--line-2) 1.5px, transparent 2.1px), radial-gradient(circle at 65% 50%, var(--line-2) 1.5px, transparent 2.1px), #fff;
  box-shadow: 0 2px 0 rgba(22, 24, 31, .22); transition: transform .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"]::after {
  transform: translateX(22px); box-shadow: 0 2px 0 var(--blue-d);
  background: radial-gradient(circle at 35% 50%, var(--blue) 1.5px, transparent 2.1px), radial-gradient(circle at 65% 50%, var(--blue) 1.5px, transparent 2.1px), #fff;
}

/* Farben: runde Farbknöpfe, der gewählte bekommt einen Ring */
.color-row { display: grid; grid-template-columns: repeat(auto-fill, 30px); justify-content: space-between; gap: 10px 6px; padding: 3px 3px 5px; }
.color-row .swatch, .color-custom {
  width: 30px; height: 30px; flex: none; border: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px rgba(22, 24, 31, .16), 0 2px 0 rgba(22, 24, 31, .2);
  transition: transform .09s ease, box-shadow .09s ease;
}
.color-row .swatch:hover, .color-custom:hover { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px rgba(22, 24, 31, .16), 0 1px 0 rgba(22, 24, 31, .2); }
.color-row .swatch[aria-pressed="true"], .color-row .swatch[aria-pressed="true"]:hover, .color-custom.active, .color-custom.active:hover {
  transform: none; box-shadow: inset 0 0 0 1.5px rgba(22, 24, 31, .16), 0 0 0 2.5px var(--paper), 0 0 0 5px var(--ink);
}
.color-custom { position: relative; overflow: hidden; cursor: pointer; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.color-custom input { position: absolute; inset: -6px; width: 42px; height: 42px; opacity: 0; cursor: pointer; }
.color-custom:focus-within { outline: 2.5px solid var(--blue); outline-offset: 2px; } /* das Farbfeld selbst ist unsichtbar */

/* Farbsets */
.preset-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px 8px; padding-bottom: 3px; }
.preset {
  --dot-ring: var(--bg-elev);
  display: grid; gap: 9px; justify-items: start; min-width: 0; border: 0; background: var(--bg-elev); border-radius: 14px; padding: 12px 12px 11px;
  text-align: left; cursor: pointer; font-family: var(--font-ui); color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--edge), 0 3px 0 var(--edge);
  transition: transform .09s ease, box-shadow .09s ease;
}
.preset:hover { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 2px 0 var(--edge); }
.preset:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px var(--edge), 0 0 0 var(--edge); }
.preset .dots { display: flex; padding-left: 2px; }
.preset .dots i { width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 2px var(--dot-ring), inset 0 0 0 1px rgba(22, 24, 31, .16); }
.preset .dots i + i { margin-left: -6px; }
.preset b { max-width: 100%; font-family: var(--font-display); font-size: 14.5px; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.preset[aria-pressed="true"], .preset[aria-pressed="true"]:hover {
  --dot-ring: var(--sel-bg);
  background: var(--sel-bg); color: var(--sel-fg); transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--sel);
}
.preset[aria-pressed="true"] b::before { content: "✓ "; }

/* Leise Knöpfe: „Mehr Optionen“, „Alles zurücksetzen“ */
.more-btn {
  justify-self: start; display: inline-flex; gap: 8px; align-items: center; border: 0; cursor: pointer; text-align: left;
  padding: 9px 15px; border-radius: var(--r-full); background: var(--paper-2); color: var(--ink-2);
  font-family: var(--font-display); font-size: 14px; font-weight: 500; transition: background .15s ease, color .15s ease;
}
.more-btn:hover { color: var(--ink); background: var(--line); }

/* Hinweise */
.note-box { border-radius: 12px; padding: 12px 14px; font-size: 13.5px; background: var(--bg-subtle); color: var(--fg-muted); }
.note-box.ok { background: var(--mint-t); color: #0B7A50; }
.note-box.warn { background: var(--sun-t); color: var(--warn-ink); }
.member-note {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--blue-t); color: var(--blue-d);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; line-height: 1.35;
}
.member-note::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%; background-color: var(--blue);
  background-image: radial-gradient(circle at 34% 50%, var(--blue-t) 1.4px, transparent 1.9px), radial-gradient(circle at 66% 50%, var(--blue-t) 1.4px, transparent 1.9px);
}

/* ---------- Druck-Schritt: Datenblätter ---------- */
.plate-list { display: grid; gap: 12px; }
.plate-card { border: 1.5px solid var(--edge); border-radius: 16px; background: var(--bg-elev); overflow: hidden; }
.plate-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 3px 10px; padding: 11px 14px 10px; border-bottom: 1px solid var(--line); background: var(--paper); }
.plate-head b { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; }
.plate-head .mono { font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.parts-list { display: grid; border: 1.5px solid var(--edge); border-radius: 14px; overflow: hidden; background: var(--bg-elev); }
.plate-card .parts-list { border: 0; border-radius: 0; }
.parts-list div { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 9px 14px; font-size: 13.5px; font-weight: 500; line-height: 1.35; color: var(--ink); }
.parts-list div + div { border-top: 1px solid var(--line); }
.parts-list i { width: 16px; height: 16px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(22, 24, 31, .16); }
.parts-list span, .parts-list div span, .parts-list .sum span { margin-left: auto; text-align: right; font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
/* Platten-Hinweis: in Ordnung (ruhig, ✓) oder Achtung (gelb, ⚠ und Warnstreifen links) */
.plate-meta { position: relative; padding: 9px 14px 10px; border-top: 1px solid var(--line); background: var(--paper); color: var(--ink-2); font-size: 12.5px; font-weight: 500; line-height: 1.55; }
.plate-meta.warn { padding-left: 24px; background: var(--sun-t); color: var(--warn-ink); font-weight: 600; }
.plate-meta.warn::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px;
  background: repeating-linear-gradient(-45deg, var(--sun-d) 0 4px, var(--sun-t) 4px 8px);
}
/* Summe: Etikett in Sonne */
.parts-list:has(> .sum) { border-color: var(--sun-d); }
.parts-list .sum { min-height: 46px; background: var(--sun); color: var(--ink); font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.parts-list .sum span { color: var(--pill-ink); font-size: 13px; font-weight: 600; }
.tips { margin: 0; padding: 0; list-style: none; color: var(--fg-muted); font-size: 13.5px; line-height: 1.5; display: grid; gap: 8px; }
.tips li { position: relative; padding-left: 22px; }
.tips li::before {
  content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background-color: var(--blue);
  background-image: radial-gradient(circle at 33% 50%, var(--paper) 1.2px, transparent 1.7px), radial-gradient(circle at 67% 50%, var(--paper) 1.2px, transparent 1.7px);
}

/* ---------- Kundenansicht: wie ein Bestellformular ---------- */
.customer .ed-tabs, .customer #undo, .customer #redo, .customer #share, .customer .dl-wrap { display: none; }
.customer #viewMode, .customer #chipParts, .customer #chipColors, .customer #chipInfo { display: none !important; }
/* kein overflow: hidden hier: als Rasterzeile würde der Kopf sonst zusammengedrückt, sobald das Panel scrollt */
.cust-head { position: relative; padding: 18px 18px 26px; border-radius: 20px; background: var(--sun-t); }
.cust-head::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(58, 44, 0, .1) 3px 4px) bottom / 100% 12px no-repeat;
}
.cust-head .eyebrow { font-size: 11.5px; }
.cust-head h2 { font-size: 28px; margin-top: 8px; }
.cust-head p { color: var(--ink-2); font-size: 14px; line-height: 1.45; margin-top: 6px; }
.sec-title { display: flex; gap: 10px; align-items: center; font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1.15; }
.sec-title i {
  font-style: normal; font-family: var(--font-mono); font-size: 12px; font-weight: 600; flex: none; width: 28px; height: 28px; margin-bottom: 3px;
  border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue-d);
}
.sec-title ~ .sec-title { margin-top: 2px; padding-top: 20px; border-top: 1.5px dashed var(--line-2); }

/* Kurze Meldung: mittig über der Vorschau, nicht über den Knöpfen */
.editor-page .toast { left: calc((100vw - 420px) / 2); bottom: 84px; max-width: min(560px, calc(100vw - 420px - 56px)); font-family: var(--font-ui); }

/* Animationen auch für Pseudo-Elemente abschalten (site.css erfasst nur echte Elemente) */
@media (prefers-reduced-motion: reduce) {
  .editor-page *::before, .editor-page *::after { animation: none !important; transition: none !important; }
}

/* ---------- Schmale Fenster: Vorschau oben, Einstellungen darunter, Knöpfe bleiben erreichbar ---------- */
@media (max-width: 900px) {
  .editor-page { height: auto; overflow: auto; }
  /* Spalten dürfen schmaler werden als ihr Inhalt (sonst läuft die Seite seitlich über) */
  .ed-main { grid-template-columns: minmax(0, 1fr); }
  .ed-panel, .ed-stage { min-width: 0; }
  .ed-top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .crumbs { display: none; }
  .ed-top .logo { order: 1; }
  .ed-actions { order: 2; margin-left: auto; }
  .mode-seg { display: inline-flex; order: 3; margin: 0; }
  .ed-stage { height: 46vh; min-height: 260px; margin: 10px; border-radius: var(--r-lg); }
  .stage-left { max-width: 62%; top: 10px; left: 10px; }
  .view-btns { top: 10px; right: 10px; }
  .stage-chips { left: 10px; bottom: 10px; max-width: calc(100% - 20px); }
  .cust-note { right: 10px; bottom: 10px; }
  .customer .stage-chips { max-width: calc(100% - 20px); }
  .ed-panel { border-left: 0; border-top: 1px solid var(--border); }
  .ed-tabs { grid-auto-columns: minmax(84px, 1fr); overflow-x: auto; scrollbar-width: none; }
  .ed-tabs::-webkit-scrollbar { display: none; }
  .ed-tab { min-width: 84px; }
  .ed-foot { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding-bottom: calc(13px + var(--press) + env(safe-area-inset-bottom, 0px)); }
  .editor-page .toast { left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); max-width: min(92vw, 560px); }
  /* auf Tablets bleiben die Felder in einer lesbaren Spalte */
  .ed-tabs, .ed-scroll, .ed-foot { padding-left: max(18px, calc((100% - 640px) / 2)); padding-right: max(18px, calc((100% - 640px) / 2)); }
}
@media (max-width: 560px) {
  /* wenig Platz: nur „3D“ und Zurücksetzen zeigen, gedreht wird mit dem Finger */
  .view-btns button[data-view="top"], .view-btns button[data-view="bottom"] { display: none; }
  .stage-left { max-width: 70%; }
  .ed-top .logo .wm { display: none; }
  .ed-top .logo .logo-icon { display: block; }
  .ed-top { flex-wrap: wrap; }
  .ed-actions { order: 2; margin-left: auto; }
  .mode-seg { order: 3; width: 100%; }
  .mode-seg button { flex: 1; }
  #undo, #redo { display: none; }
  /* fünf Schritte passen bei 375 px nebeneinander, darunter lässt sich die Leiste wischen */
  .ed-tabs { grid-auto-columns: minmax(66px, 1fr); padding-left: 6px; padding-right: 6px; }
  .ed-tab { min-width: 66px; }
  .ed-tab span { font-size: 12.5px; }
  .ed-scroll { padding: 18px 14px 26px; }
  .choice-grid .choice-btn { font-size: 14px; }
  .ed-foot { padding-left: 14px; padding-right: 14px; }
  .cust-head h2 { font-size: 25px; }
}
@media (max-width: 350px) {
  /* sehr schmal: Spalten richten sich nach dem Wort, damit alle Schritte sichtbar bleiben */
  .ed-tabs { grid-auto-columns: minmax(min-content, 1fr); padding-left: 4px; padding-right: 4px; }
  .ed-tab { min-width: 0; padding-left: 1px; padding-right: 1px; }
  .ed-tab span { font-size: 12px; max-width: none; overflow: visible; }
}

/* Erledigte Schritte: gleiche Optik wie oben über :has(), hier über das Attribut aus editor.js (für ältere Browser) */
.ed-tab[data-state="done"] small { background: var(--blue-t); color: var(--blue-d); box-shadow: inset 0 0 0 1.5px #B9C5FB, 0 3px 0 #B9C5FB; }
.ed-tab[data-state="done"]::after { background: var(--blue); }
.more-btn svg { flex: none; }
