/*
 * JR Product Customizer – Frontend Styles
 * Akzentfarbe via CSS-Variablen (Standard: Olivgrün), überschreibbar über die
 * Plugin-Einstellung «Akzentfarbe Frontend» (wird als :root-Style injiziert).
 */
:root {
    --jrpc-accent: #6B8E23;
    --jrpc-accent-dark: #556B2F;
}

.jrpc-launch-wrap { margin: 12px 0; }
/*
 * !important ist hier bewusst gesetzt: Shop-Themes stylen generische
 * Button-Klassen (z. B. rot) und würden die Akzentfarbe sonst überschreiben.
 */
.jrpc-open-btn {
    display: block !important; width: 100% !important;
    background: var(--jrpc-accent) !important;
    border: 1px solid var(--jrpc-accent) !important;
    color: #fff !important; font-weight: 600; font-size: 16px;
    padding: 12px 16px; border-radius: 4px; cursor: pointer;
    transition: background .15s ease; text-align: center;
}
.jrpc-open-btn:hover,
.jrpc-open-btn:focus {
    background: var(--jrpc-accent-dark) !important;
    border-color: var(--jrpc-accent-dark) !important;
    color: #fff !important;
}
.jrpc-open-icon { margin-right: 6px; }
.jrpc-status { font-size: 13px; margin-top: 6px; color: var(--jrpc-accent-dark); }

/* Vorschau der übernommenen Personalisierung auf der Artikelseite */
.jrpc-page-preview {
    display: flex; align-items: center; gap: 12px;
    margin-top: 10px; padding: 10px;
    background: #f5f8ee; border: 1px solid var(--jrpc-accent);
    border-radius: 6px;
}
.jrpc-page-preview[hidden] { display: none; }
.jrpc-page-preview-imgs { display: inline-flex; flex-wrap: wrap; gap: 5px; flex: 0 0 auto; }
.jrpc-page-preview img {
    width: 64px; height: 64px; object-fit: contain;
    background: #fff; border: 1px solid #ddd; border-radius: 4px;
    cursor: zoom-in;
}
.jrpc-page-preview-text { font-size: 13px; line-height: 1.4; }
.jrpc-page-preview-text strong { color: var(--jrpc-accent-dark); }

.jrpc-modal {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(0,0,0,.55);
    display: none; align-items: center; justify-content: center;
    padding: 16px;
}
.jrpc-modal.is-open { display: flex; }

.jrpc-dialog {
    background: #fff; border-radius: 10px; width: min(1100px, 100%);
    height: min(90vh, 780px); display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.jrpc-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.jrpc-title { font-size: 18px; font-weight: 700; }
.jrpc-close {
    background: none; border: none; font-size: 28px; line-height: 1;
    cursor: pointer; color: #666;
}
.jrpc-body { flex: 1; display: flex; min-height: 0; }

.jrpc-tools {
    width: 280px; border-right: 1px solid #eee; padding: 14px;
    overflow-y: auto; background: #fafafa;
}
.jrpc-tool-group { display: grid; gap: 8px; margin-bottom: 14px; }
/* WICHTIG: display:grid würde sonst das hidden-Attribut übersteuern –
   die Typ-Auswahl muss eingeklappt starten und per Button aufklappen. */
.jrpc-tool-group[hidden] { display: none !important; }
.jrpc-tool {
    display: block; width: 100%; text-align: left;
    padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 14px;
}
.jrpc-tool:hover { border-color: var(--jrpc-accent); background: #f5f8ee; }

/* Einstiegspunkt: Element hinzufuegen (klappt die Typ-Auswahl auf) */
.jrpc-add-element {
    display: block; width: 100%; text-align: center;
    padding: 11px 12px; margin-bottom: 8px;
    border: 1px solid var(--jrpc-accent); border-radius: 6px;
    background: var(--jrpc-accent); color: #fff;
    cursor: pointer; font-size: 14px; font-weight: 600;
}
.jrpc-add-element:hover { background: var(--jrpc-accent-dark); border-color: var(--jrpc-accent-dark); }
.jrpc-add-element .jrpc-plus { font-weight: 800; font-size: 17px; margin-right: 4px; color: #fff; }

/* Clipart-/Design-Auswahl als Akkordeon je Kategorie */
.jrpc-acc { border: 1px solid #e2e2e2; border-radius: 6px; margin-bottom: 6px; background: #fff; overflow: hidden; }
.jrpc-acc-head {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 9px 10px; border: none; background: #f7f7f2;
    cursor: pointer; font-size: 13px; font-weight: 600; text-align: left;
}
.jrpc-acc-head:hover { background: #f0f3e6; }
.jrpc-acc-arrow { transition: transform .15s ease; font-size: 11px; color: var(--jrpc-accent-dark); }
.jrpc-acc.is-open .jrpc-acc-arrow { transform: rotate(90deg); }
.jrpc-acc-count { margin-left: auto; font-weight: 400; color: #888; font-size: 11.5px; }
.jrpc-acc-body {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px;
}
.jrpc-acc-body[hidden] { display: none; }
.jrpc-acc-body img {
    width: 100%; height: 56px; object-fit: contain; cursor: pointer;
    border: 1px solid #eee; border-radius: 5px; background: #fff; padding: 4px;
}
.jrpc-acc-body img:hover { border-color: var(--jrpc-accent); }
.jrpc-tool-group { margin-top: 0; }

.jrpc-clear-all {
    display: block; width: 100%; text-align: left;
    padding: 9px 12px; margin-bottom: 12px;
    border: 1px solid #d9b8b8; border-radius: 6px;
    background: #fff; color: #9c2b2b; font-size: 13px; cursor: pointer;
    transition: background .15s ease;
}
.jrpc-clear-all:hover { background: #fff5f5; border-color: #c96a6a; }
/* display:block würde sonst das hidden-Attribut übersteuern (die Knöpfe
   erscheinen nur, wenn die jeweiligen Flächen gefüllt sind). */
.jrpc-clear-all[hidden] { display: none !important; }
.jrpc-clear-all.is-armed {
    background: #b71c1c; border-color: #b71c1c; color: #fff; font-weight: 600;
}

.jrpc-hint {
    font-size: 12px; line-height: 1.45; color: #5a5a44;
    background: #f5f8ee; border: 1px solid #d8e3c0; border-radius: 6px;
    padding: 8px 10px; margin-bottom: 12px;
}
.jrpc-hint[hidden] { display: none; }

.jrpc-props h4, .jrpc-clipart-panel h4, .jrpc-qr-panel h4 { margin: 8px 0 10px; font-size: 14px; }
.jrpc-prop { margin-bottom: 10px; }
.jrpc-prop[hidden] { display: none; }
.jrpc-prop label { display: block; font-size: 12px; color: #555; margin-bottom: 3px; }
.jrpc-prop input, .jrpc-prop select, .jrpc-prop textarea { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; }
.jrpc-prop textarea { resize: vertical; min-height: 44px; font: inherit; }
.jrpc-del {
    display: block; width: 100%; margin: 0 0 8px; padding: 8px;
    border: 1px solid #e0b4b4; text-align: left;
    background: #fff5f5; color: #b71c1c; border-radius: 6px; cursor: pointer;
    font-size: 13px;
}
.jrpc-del:hover { background: #ffecec; border-color: #c96a6a; }
.jrpc-del[hidden] { display: none; }

/* Schriftstil- und Ausrichten-Buttons im Eigenschaften-Panel.
   !important schützt vor Theme-CSS: manche Templates (u. a. NOVA-Childs)
   stylen nackte <button>- sowie <b>/<u>-Elemente mit eigenen Farben –
   das liess das B im Fett-Knopf in der falschen Farbe erscheinen. */
.jrpc-style-row, .jrpc-align-row { display: flex; gap: 4px; flex-wrap: wrap; }
.jrpc-style-row button, .jrpc-align-row button {
    flex: 1; min-width: 34px; padding: 7px 0; border: 1px solid #ccc; border-radius: 5px;
    background: #fff !important; color: #333 !important;
    cursor: pointer; font-size: 14px; line-height: 1;
}
.jrpc-style-row button:hover, .jrpc-align-row button:hover {
    border-color: var(--jrpc-accent); background: #f5f8ee !important;
}
.jrpc-style-row button.is-on, .jrpc-align-row button.is-on {
    background: var(--jrpc-accent) !important; border-color: var(--jrpc-accent);
    color: #fff !important;
}
.jrpc-style-row button b, .jrpc-style-row button i, .jrpc-style-row button u,
.jrpc-align-row button b, .jrpc-align-row button i, .jrpc-align-row button u {
    color: inherit !important;
}
.jrpc-outline-icon { color: transparent !important; -webkit-text-stroke: 1px #333; font-weight: 700; }
.jrpc-style-row button.is-on .jrpc-outline-icon { -webkit-text-stroke: 1px #fff; }

/* Hinweis zur Wort-Markierung: nur auf Touch-Geräten anzeigen */
.jrpc-touch-hint { display: none; }
@media (pointer: coarse) { .jrpc-touch-hint { display: block; } }

/* Seite hinter dem offenen Editor nicht scrollen lassen */
html.jrpc-noscroll, body.jrpc-noscroll { overflow: hidden !important; }

/* Schriftgroesse: Slider + Zahleneingabe nebeneinander */
.jrpc-size-row { display: flex; gap: 8px; align-items: center; }
.jrpc-size-row input[type="range"] { flex: 1; min-width: 0; }
.jrpc-size-row input[type="number"] {
    flex: 0 0 64px; width: 64px; padding: 6px 4px; text-align: center;
    border: 1px solid #ccc; border-radius: 5px; font-size: 14px;
}

/* Drehen (Winkeleingabe) & Spiegeln */
.jrpc-transform-row { display: flex; gap: 4px; align-items: center; }
.jrpc-transform-row input[type="number"] {
    flex: 0 0 70px; width: 70px; padding: 7px 4px; text-align: center;
    border: 1px solid #ccc; border-radius: 5px; font-size: 14px;
}
.jrpc-transform-row .jrpc-deg { margin-right: 6px; color: #555; }
.jrpc-transform-row button {
    flex: 1; min-width: 34px; padding: 7px 0; border: 1px solid #ccc; border-radius: 5px;
    background: #fff; cursor: pointer; font-size: 14px; line-height: 1;
}
.jrpc-transform-row button:hover { border-color: var(--jrpc-accent); background: #f5f8ee; }
.jrpc-transform-row button.is-on {
    background: var(--jrpc-accent); border-color: var(--jrpc-accent); color: #fff;
}

/* Vorschaubilder per Klick vergrössern (Lightbox) */
.jrpc-page-preview img { cursor: zoom-in; }
.jrpc-lightbox {
    position: fixed; inset: 0; z-index: 100001;
    background: rgba(0,0,0,.8); cursor: zoom-out;
    display: flex; align-items: center; justify-content: center;
}
.jrpc-lightbox img {
    max-width: 92vw; max-height: 92vh; object-fit: contain;
    background: #fff; border-radius: 6px; padding: 6px;
}

/* Bereichs-Buttons (zweite Zeile unter den Ansichts-Tabs) */
.jrpc-zones {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-bottom: 1px solid #eee; overflow-x: auto;
    background: #fcfcfa;
}
.jrpc-zones[hidden] { display: none; }
.jrpc-zones-label { font-size: 12px; color: #777; white-space: nowrap; }
.jrpc-zone-chip {
    padding: 5px 13px; border: 1px dashed var(--jrpc-accent); border-radius: 16px;
    background: #fff; color: var(--jrpc-accent-dark); font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.jrpc-zone-chip:hover { background: #f5f8ee; }
.jrpc-zone-chip.is-active {
    background: var(--jrpc-accent); border-style: solid; color: #fff;
}

.jrpc-tool.is-disabled, .jrpc-tool:disabled {
    opacity: .4; cursor: not-allowed; border-color: #ddd; background: #fff;
}

/* Punkt-Markierung: Fläche enthält Elemente */
.jrpc-has-elements {
    margin-left: 6px; font-size: 9px; vertical-align: 2px;
    color: var(--jrpc-accent);
}
.jrpc-view-tab.is-active .jrpc-has-elements,
.jrpc-zone-chip.is-active .jrpc-has-elements { color: #fff; }

/* Design-Vorlagen: Bearbeiten-Button im Eigenschaften-Panel */
.jrpc-motif-edit {
    display: block; width: 100%;
    padding: 8px 12px; border: 1px solid var(--jrpc-accent); border-radius: 6px;
    background: #fff; color: var(--jrpc-accent-dark); font-weight: 600;
    cursor: pointer; font-size: 13px;
}
.jrpc-motif-edit:hover { background: var(--jrpc-accent); color: #fff; }
.jrpc-prop-hint { font-size: 11px; color: #888; margin-top: 4px; }

.jrpc-qr-panel label { display: block; font-size: 12px; color: #555; margin-bottom: 3px; }
.jrpc-qr-panel input, .jrpc-qr-panel textarea { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 8px; }
.jrpc-qr-panel textarea { resize: vertical; min-height: 56px; font: inherit; }
.jrpc-qr-add {
    width: 100%; padding: 8px; border: 1px solid var(--jrpc-accent);
    background: var(--jrpc-accent); color: #fff; border-radius: 6px; cursor: pointer;
}
.jrpc-qr-add:hover { background: var(--jrpc-accent-dark); }

.jrpc-clipart-list { display: block; }
/* Spaltenzahl des Akkordeon-Rasters je Layout */
@media (max-width: 768px) { .jrpc-acc-body { grid-template-columns: repeat(4, 1fr); } }
@media (max-height: 520px) and (orientation: landscape) { .jrpc-acc-body { grid-template-columns: repeat(3, 1fr); } }
.jrpc-clipart-list img {
    width: 100%; height: 60px; object-fit: contain; cursor: pointer;
    border: 1px solid #eee; border-radius: 4px; padding: 4px; background: #fff;
}
.jrpc-clipart-list img:hover { border-color: var(--jrpc-accent); }
.jrpc-clipart-cat { grid-column: 1/-1; font-size: 12px; font-weight: 600; color: #888; margin-top: 6px; }

/* Layout-Vorlagen: grosse Kacheln mit Produktvorschau + Name */
.jrpc-layout-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.jrpc-layout-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 8px; border: 1px solid #e2e2e2; border-radius: 8px;
    background: #fff; cursor: pointer; font: inherit; text-align: center;
}
.jrpc-layout-item img {
    width: 100%; height: 90px; object-fit: contain; border-radius: 4px;
}
.jrpc-layout-item span { font-size: 12px; font-weight: 600; color: #444; }
.jrpc-layout-item:hover { border-color: var(--jrpc-accent); box-shadow: 0 1px 6px rgba(0,0,0,.12); }

.jrpc-stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.jrpc-views {
    display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #eee;
    overflow-x: auto;
}
.jrpc-view-tab {
    padding: 6px 14px; border: 1px solid #ddd; border-radius: 20px;
    background: #fff; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.jrpc-view-tab.is-active {
    background: var(--jrpc-accent); color: #fff; border-color: var(--jrpc-accent);
}

.jrpc-canvas-wrap {
    position: relative;
    flex: 1; display: flex; align-items: center; justify-content: center;
    background: #f0f0f0 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><rect width="10" height="10" fill="%23e8e8e8"/><rect x="10" y="10" width="10" height="10" fill="%23e8e8e8"/></svg>');
    overflow: auto; padding: 16px;
}
/* Beim Hineinzoomen oben-links andocken, damit gescrollt werden kann */
.jrpc-canvas-wrap .canvas-container { margin: auto; }

/* Kopfleiste der Stage: Ansichts-Buttons links, Zoom FEST rechts am Rand
   (liegt nie über dem Produkt). */
.jrpc-stage-bar {
    display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid #eee; padding-right: 10px;
}
.jrpc-stage-bar .jrpc-views { flex: 1; min-width: 0; border-bottom: none; }
.jrpc-zoom {
    display: flex; align-items: center; gap: 2px; flex: 0 0 auto;
    background: #fff; border: 1px solid #ddd;
    border-radius: 20px; padding: 2px 5px;
}
.jrpc-zoom button {
    width: 34px; height: 34px; border: none; background: none;
    font-size: 20px; line-height: 1; cursor: pointer; color: var(--jrpc-accent-dark);
    border-radius: 50%;
}
.jrpc-zoom button:hover { background: #f5f8ee; }
.jrpc-zoom span { font-size: 12px; color: #555; min-width: 42px; text-align: center; }

/* Aktionsleiste ÜBER der Vorschau: Hinzufügen, Rückgängig, Leeren, Hilfe */
.jrpc-topbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 12px; border-bottom: 1px solid #eee; background: #fafafa;
}
.jrpc-topbar-spacer { flex: 1 1 auto; }
.jrpc-add-wrap { position: relative; }
/* «Element hinzufügen» im Topbar: kompakt, nicht volle Breite */
.jrpc-topbar .jrpc-add-element {
    display: inline-flex; align-items: center; width: auto; margin: 0;
    padding: 8px 14px; font-size: 13.5px; white-space: nowrap;
}
/* Typ-Auswahl als Aufklapp-Menü unter dem Button */
.jrpc-topbar .jrpc-tool-group {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
    display: grid; grid-template-columns: 1fr; gap: 4px; margin: 0;
    min-width: 210px; padding: 6px; background: #fff;
    border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16);
}
.jrpc-topbar .jrpc-tool-group[hidden] { display: none !important; }
/* Rückgängig/Wiederherstellen als kompakte Icon-Knöpfe */
.jrpc-topbar .jrpc-history-row { margin: 0; gap: 4px; }
.jrpc-topbar .jrpc-history-row button {
    flex: 0 0 auto; width: 36px; height: 36px; padding: 0; font-size: 16px; border-radius: 6px;
}
/* Leeren-Knöpfe im Topbar: dezent, Text auf kleinen Displays ausblendbar */
.jrpc-topbar .jrpc-clear-all {
    display: inline-flex; align-items: center; width: auto; margin: 0;
    padding: 7px 12px; font-size: 12.5px; white-space: nowrap;
}
.jrpc-help-btn {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid #cfd6c2; background: #fff; color: var(--jrpc-accent-dark);
    font-size: 17px; font-weight: 700; cursor: pointer; line-height: 1;
}
.jrpc-help-btn:hover { background: #f5f8ee; border-color: var(--jrpc-accent); }
/* Hilfe-Hinweis: schwebt über der Vorschau */
.jrpc-help-panel {
    position: absolute; top: 10px; right: 10px; z-index: 25; width: min(340px, 88%);
    background: #fff; border: 1px solid #cfd6c2; border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 14px 16px;
}
.jrpc-help-panel[hidden] { display: none; }
.jrpc-help-panel h4 { margin: 0 24px 8px 0; font-size: 14px; color: var(--jrpc-accent-dark); }
.jrpc-help-text p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.45; color: #444; }
.jrpc-help-text p:last-child { margin-bottom: 0; }
.jrpc-help-close {
    position: absolute; top: 8px; right: 10px; border: none; background: none;
    font-size: 22px; line-height: 1; cursor: pointer; color: #888;
}
/* Eigenschaften-Kopf: Titel + «Element löschen» in einer Zeile */
.jrpc-props-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.jrpc-props-head h4 { margin: 0; font-size: 14px; }
.jrpc-props-head .jrpc-del { margin: 0; width: auto; padding: 5px 10px; font-size: 12px; }
/* Seitenleiste einklappen, wenn nichts anzuzeigen ist */
.jrpc-tools.is-collapsed {
    flex: 0 0 0; width: 0; min-width: 0; max-height: 0;
    padding: 0; border: none; overflow: hidden;
}
/* Zweiter Start-Button «Weiteres Exemplar» */
.jrpc-open-new { margin-top: 8px; background: #fff; color: var(--jrpc-accent-dark); border: 1px dashed var(--jrpc-accent); }
.jrpc-open-new[hidden] { display: none; }

.jrpc-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; border-top: 1px solid #eee; gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
/* Bestätigung: Text/Schreibweise geprüft (Retouren-Schutz) */
.jrpc-confirm-row { flex: 1 1 100%; font-size: 12.5px; line-height: 1.35; }
.jrpc-confirm-short { display: none; }
.jrpc-confirm-row label { display: flex; align-items: flex-start; gap: 8px; margin: 0; cursor: pointer; }
.jrpc-confirm-row input { margin-top: 2px; flex: 0 0 auto; }
.jrpc-confirm-row.is-error span { color: #b71c1c; font-weight: 600; }
/* Rückgängig / Wiederherstellen */
.jrpc-history-row { display: flex; gap: 6px; margin-bottom: 10px; }
.jrpc-history-row button {
    flex: 1; padding: 7px 6px; border: 1px solid #ddd; border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 12.5px;
}
.jrpc-history-row button:hover:not(:disabled) { border-color: var(--jrpc-accent); background: #f5f8ee; }
.jrpc-history-row button:disabled { opacity: .4; cursor: default; }
/* Preis + Statusmeldung teilen sich den flexiblen Platz LINKS der Buttons:
   eine (auch lange) Meldung bricht INNERHALB dieses Bereichs um, statt die
   Buttons in eine neue Zeile zu verdrängen (kein Layout-Sprung). */
.jrpc-price { font-size: 15px; flex: 1 1 0; min-width: 0; }
.jrpc-modal-status { margin-left: 12px; font-size: 13px; color: var(--jrpc-accent-dark); }
.jrpc-processing { margin-left: 8px; font-size: 12px; color: #777; }
.jrpc-modal-status.is-error { color: #b71c1c; }
.jrpc-actions { display: flex; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.jrpc-btn-primary {
    background: var(--jrpc-accent); border: 1px solid var(--jrpc-accent);
    color: #fff; font-weight: 600; padding: 10px 22px; border-radius: 4px; cursor: pointer;
}
.jrpc-btn-primary:hover { background: var(--jrpc-accent-dark); border-color: var(--jrpc-accent-dark); }
.jrpc-cart-icon { vertical-align: -3px; margin-right: 4px; }
.jrpc-btn-secondary {
    background: #fff; border: 1px solid #ccc; color: #333;
    padding: 10px 22px; border-radius: 4px; cursor: pointer;
}
.jrpc-btn-secondary:hover { background: #f2f2f2; }

/* Touch: Ziehen/Skalieren auf dem Canvas ohne Seiten-Scrolling */
.jrpc-canvas-wrap canvas { touch-action: none; }

/* ---------- Smartphone-Layout (Vollbild-Editor) ---------- */
@media (max-width: 768px) {
    .jrpc-modal { padding: 0; align-items: stretch; }
    .jrpc-dialog {
        width: 100%; height: 100%; height: 100dvh; max-height: none;
        border-radius: 0;
    }
    .jrpc-header { padding: 8px 14px; }
    .jrpc-title { font-size: 15px; }

    /* Canvas zuerst, Werkzeuge kompakt darunter; Kopf/Fuss sind fix,
       Canvas und Werkzeuge teilen sich den Rest (beide scrollbar). */
    .jrpc-body { flex-direction: column; min-height: 0; }
    .jrpc-stage { order: 1; min-height: 32%; flex: 1 1 46%; }
    .jrpc-tools {
        order: 2; width: 100%; flex: 0 1 auto; max-height: 38%;
        border-right: none; border-top: 1px solid #eee;
        padding: 10px; overflow-y: auto;
    }
    .jrpc-canvas-wrap { padding: 8px; }

    /* Typ-Auswahl als 2-spaltiges Aufklapp-Menü */
    .jrpc-topbar .jrpc-tool-group { grid-template-columns: repeat(2, 1fr); min-width: 260px; }
    .jrpc-tool { padding: 8px 8px; font-size: 13px; text-align: center; }
    .jrpc-del { padding: 7px 10px; font-size: 12px; }
    .jrpc-hint { font-size: 11px; padding: 6px 8px; margin-bottom: 8px; }

    /* Topbar kompakt: Leeren-Text weg (nur Symbol), enger */
    .jrpc-topbar { padding: 6px 10px; gap: 6px; }
    .jrpc-topbar .jrpc-add-element { padding: 7px 11px; font-size: 13px; }
    .jrpc-topbar .jrpc-clear-all { padding: 6px 8px; }
    .jrpc-clear-txt { display: none; }
    .jrpc-topbar .jrpc-history-row button { width: 32px; height: 32px; font-size: 15px; }
    .jrpc-help-btn { width: 32px; height: 32px; font-size: 16px; }

    .jrpc-views, .jrpc-zones { padding: 6px 10px; }
    .jrpc-view-tab { padding: 5px 11px; font-size: 12px; }
    .jrpc-zone-chip { padding: 4px 10px; font-size: 12px; }


    /* Footer maximal kompakt: Kurz-Bestätigung, Preis einzeilig, Buttons
       in EINER Zeile. WICHTIG: kein wrap – in Spaltenrichtung würde der
       Umbruch eine zweite, unsichtbare Spalte erzeugen. */
    .jrpc-footer { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 3px; padding: 5px 8px; }
    .jrpc-confirm-row { flex: 0 0 auto; font-size: 11px; line-height: 1.25; }
    .jrpc-confirm-full { display: none; }
    .jrpc-confirm-short { display: inline; }
    .jrpc-confirm-row input { margin-top: 1px; }
    /* WICHTIG: flex 0 0 auto – der Footer ist hier eine SPALTE. Die
       Desktop-Regel (flex-basis 0) würde die Zeile zusammen mit
       overflow:hidden auf 0 Höhe kollabieren lassen: Aufpreis unsichtbar. */
    .jrpc-price { flex: 0 0 auto; text-align: left; font-size: 11.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .jrpc-processing { display: inline; margin: 0 0 0 6px; font-size: 10.5px; }
    .jrpc-modal-status { display: inline; margin: 0 0 0 6px; font-size: 10.5px; }
    .jrpc-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 4px; }
    .jrpc-btn-primary, .jrpc-btn-secondary { padding: 8px 9px; font-size: 12px; white-space: nowrap; }
}

@media (max-width: 420px) {
    /* Auch ganz schmal: eine Zeile statt gestapelter Buttons */
    .jrpc-actions { grid-template-columns: auto auto 1fr; gap: 4px; }
    .jrpc-btn-primary, .jrpc-btn-secondary { padding: 9px 7px; font-size: 11.5px; }
    .jrpc-tool-group { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Smartphone QUER (geringe Höhe): Werkzeuge links, Canvas gross ----------
   Muss NACH dem Hochformat-Block stehen, damit er bei schmalen, niedrigen
   Displays (Telefon quer, z. B. 844×390) dessen Spalten-Layout überschreibt.
   WICHTIG: zusätzlich an die Querlage gebunden – bei hoher Text-/System-
   Skalierung kann die CSS-Höhe auch im HOCHFORMAT unter 520px fallen und
   würde sonst fälschlich das Quer-Layout aktivieren. */
@media (max-height: 520px) and (orientation: landscape) {
    .jrpc-modal { padding: 0; align-items: stretch; }
    .jrpc-dialog { width: 100%; height: 100%; height: 100dvh; max-height: none; border-radius: 0; }
    .jrpc-confirm-row { font-size: 10.5px; line-height: 1.25; }
    .jrpc-confirm-full { display: none; }
    .jrpc-confirm-short { display: inline; }
    .jrpc-header { padding: 4px 12px; }
    .jrpc-title { font-size: 13px; }
    .jrpc-close { font-size: 22px; }

    /* Nebeneinander statt übereinander: schmale Werkzeugspalte, Rest Canvas */
    .jrpc-body { flex-direction: row; }
    .jrpc-stage { order: 2; flex: 1 1 auto; min-height: 0; }
    .jrpc-tools {
        order: 1; flex: 0 0 200px; width: 200px; max-height: none;
        border-top: none; border-right: 1px solid #eee;
        padding: 8px; overflow-y: auto;
    }
    .jrpc-topbar { padding: 4px 8px; gap: 5px; }
    .jrpc-topbar .jrpc-tool-group { grid-template-columns: 1fr; min-width: 180px; }
    .jrpc-tool { padding: 6px 8px; font-size: 12px; text-align: left; }
    .jrpc-del { padding: 5px 8px; font-size: 11px; }
    .jrpc-topbar .jrpc-add-element { padding: 6px 9px; font-size: 12px; }
    .jrpc-clear-txt { display: none; }
    .jrpc-topbar .jrpc-history-row button { width: 28px; height: 28px; font-size: 14px; }
    .jrpc-help-btn { width: 28px; height: 28px; font-size: 14px; }
    .jrpc-hint { display: none; } /* Hinweistext kostet in Querlage zu viel Höhe */

    .jrpc-views, .jrpc-zones { padding: 4px 8px; gap: 6px; }
    .jrpc-view-tab { padding: 3px 9px; font-size: 11px; }
    .jrpc-zone-chip { padding: 3px 8px; font-size: 11px; }
    .jrpc-canvas-wrap { padding: 6px; }

    .jrpc-zoom { bottom: 4px; padding: 2px 4px; }
    .jrpc-zoom button { width: 28px; height: 28px; font-size: 16px; }
    .jrpc-zoom span { min-width: 34px; font-size: 11px; }

    /* Footer einzeilig und flach halten */
    .jrpc-footer { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 5px 10px; gap: 8px; }
    .jrpc-confirm-row { flex: 1 1 100%; }
    .jrpc-price { font-size: 12px; text-align: left; white-space: normal; flex: 1 1 0; min-width: 0; }
    .jrpc-processing { display: none; }
    .jrpc-modal-status { display: inline; margin: 0 0 0 6px; font-size: 11px; }
    .jrpc-actions { display: flex; flex: 0 0 auto; margin-left: auto; justify-content: flex-end; gap: 6px; }
    .jrpc-btn-primary, .jrpc-btn-secondary { padding: 7px 10px; font-size: 12px; white-space: nowrap; }

    .jrpc-layout-list { grid-template-columns: 1fr; }
    .jrpc-layout-item img { height: 64px; }
}

/* ---------- Auswahl «Welche Gravur bearbeiten?» (mehrere im Warenkorb) ---------- */
.jrpc-chooser {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.jrpc-chooser-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    padding: 20px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.jrpc-chooser-title {
    font-weight: 700;
    font-size: 17px;
    color: #222;
    margin-bottom: 4px;
}
button.jrpc-chooser-item {
    display: flex !important;
    align-items: center;
    gap: 12px;
    border: 1px solid #d9d9d9 !important;
    border-radius: 10px;
    background: #fff !important;
    color: #222 !important;
    padding: 10px 12px !important;
    cursor: pointer;
    font-size: 15px;
    text-align: left;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .15s, background .15s;
}
button.jrpc-chooser-item:hover {
    border-color: var(--jrpc-accent, #6B8E23) !important;
    background: #f6f8f2 !important;
}
.jrpc-chooser-item img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 6px;
    background: #f3f3f3;
    flex: 0 0 auto;
}
button.jrpc-chooser-new {
    justify-content: center;
    font-weight: 600;
    color: var(--jrpc-accent, #6B8E23) !important;
    border-style: dashed !important;
}
button.jrpc-chooser-cancel {
    border: none !important;
    background: none !important;
    color: #777 !important;
    cursor: pointer;
    padding: 6px !important;
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
}
button.jrpc-chooser-cancel:hover { color: #333 !important; }
