/* ============================================================================
   editor-mobile.css — Smartphone-Layout für den Editor (< 768 px).
   Desktop & Tablet bleiben durch das Media-Query unberührt. Die zusätzliche
   body.is-mobile-editor-Klasse (gesetzt via mobile-shell.js) härtet die
   Aktivierung gegen Safari-Resize-Quirks ab.
   ============================================================================ */

/* Default-Hide für Mobile-only-Elemente, falls der Viewport später grösser
   wird (z.B. Tablet-Rotation): die Sheets dürfen dann nicht im Layout
   stehen bleiben. */
.mobile-sheet,
.mobile-tabbar,
.mobile-help-bubble,
.mobile-feedback-bubble,
.mobile-onboarding-bg,
.mobile-sheet-backdrop {
  display: none;
}

/* Aktivierung: schmaler Viewport (Smartphone hoch- und Querformat) ODER echter
   Touch-Pointer auf niedriger Höhe (iPhone Landscape ist 393×852 = 852 px breit,
   greift sonst nicht in (max-width: 768px)). Die Body-Klasse `is-mobile-editor`
   härtet zusätzlich gegen Safari-Resize-Quirks ab. */
@media (max-width: 768px), (max-height: 480px) and (pointer: coarse) {

  body.editor-page.is-mobile-editor {
    /* iOS: 100vh ignoriert die Adressleiste — 100dvh kennt den dynamischen Viewport. */
    height: 100dvh;
    min-height: 100vh;
    /* Pinch-Zoom auf der ganzen Seite unterbinden — nur die Konva-Stage darf
       zoomen (siehe `.canvas-stage` weiter unten, `touch-action: none`).
       `pan-x pan-y` erlaubt das normale Scrollen mit dem Finger, blockt aber
       die Zwei-Finger-Pinch-Geste. Kombiniert mit dem `user-scalable=no`-
       Viewport-Meta auf der Editor-Seite und einem `gesturestart`-Listener
       in `mobile-shell.js` (für iOS Safari, das das Viewport-Meta tlw.
       ignoriert). */
    touch-action: pan-x pan-y;
  }
  body.is-mobile-editor .canvas-stage,
  body.is-mobile-editor .konvajs-content {
    /* Konva muss alle Touch-Gesten selbst behandeln — also keine Standard-
       Browser-Gesten dazwischenfunken. */
    touch-action: none;
  }

  /* ── Header / Toolbar ──────────────────────────────────────────────────── */
  /* Auf dem Smartphone wandert die komplette Editor-Toolbar (Undo/Redo,
     Autosave, Bestellen, Speichern) in die Site-Nav. Damit gewinnen wir
     eine ganze Zeile vertikalen Platz für die Collage selbst. Die alte
     `.editor-toolbar` wird komplett ausgeblendet. */
  body.is-mobile-editor .editor-toolbar { display: none !important; }

  /* Site-Nav im Editor: knapper Padding + Gap, damit alle Aktionen auf einer
     Zeile in einen 360–430 px breiten Viewport passen. */
  body.is-mobile-editor .site-header .site-nav {
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.is-mobile-editor .site-header .site-nav::-webkit-scrollbar { display: none; }

  /* Undo/Redo + Autosave/Save als kompakte Icon-Gruppen. */
  body.is-mobile-editor .site-nav__editor-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
  }
  body.is-mobile-editor .site-nav__editor-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    padding: 0;
    border: 1px solid var(--line, #e0d8cc);
    background: #fff;
    border-radius: 8px;
    color: var(--ink, #2a2520);
    font-size: 0;            /* Text (z. B. „Undo") ausblenden — Icon übernimmt */
  }
  body.is-mobile-editor .site-nav__editor-action svg { display: block; }
  body.is-mobile-editor .site-nav__editor-action:disabled { opacity: .35; }

  /* „Speichern" (Gast-CTA) und „Bestellen" (Primary-CTA) kompakt halten. */
  body.is-mobile-editor .site-nav__editor-save,
  body.is-mobile-editor .site-nav__editor-order {
    min-height: 36px;
    padding: 6px 12px;
    font-size: .85em;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  body.is-mobile-editor .site-nav__editor-order { font-weight: 600; }

  /* Legacy-Skeleton (falls editor-toolbar versehentlich doch gerendert wird) */
  body.is-mobile-editor .editor-toolbar-legacy {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 8px;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
  }
  body.is-mobile-editor .editor-toolbar::-webkit-scrollbar { display: none; }
  body.is-mobile-editor .editor-toolbar .toolbar-divider,
  body.is-mobile-editor .editor-toolbar .toolbar-spacer {
    flex: 0 0 auto;
  }
  body.is-mobile-editor .editor-toolbar .toolbar-spacer { flex: 1 1 auto; }
  body.is-mobile-editor .editor-toolbar .btn--ghost,
  body.is-mobile-editor .editor-toolbar .btn {
    min-height: 38px;
    padding: 6px 10px;
    font-size: .85em;
    white-space: nowrap;
  }
  body.is-mobile-editor .editor-toolbar #btn-order {
    /* Primärer CTA — etwas grösser für den Daumen. */
    min-height: 40px;
    padding: 8px 14px;
    font-weight: 600;
  }
  body.is-mobile-editor .js-mobile-hidden { display: none !important; }

  /* Autosave-Indikator auf Mobile: als floating Bubble unten RECHTS,
     spiegelbildlich zum Hilfe-?-Icon (unten links). Nur sichtbar, wenn
     gerade gespeichert oder ein Problem vorliegt — der „gespeichert"-Zustand
     bleibt aus dem Sichtfeld. */
  body.is-mobile-editor .autosave-indicator__label { display: none; }
  body.is-mobile-editor .autosave-indicator {
    position: fixed;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    left: auto; top: auto;
    z-index: 900;
    width: 40px; height: 40px;
    padding: 0; gap: 0;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e6ddcf;
    box-shadow: 0 4px 14px rgba(0,0,0,.16);
    transition: opacity .18s ease;
    /* Tap-Save: Bubble fängt Klicks wieder ein (in app.css ist pointer-events
       für die Desktop-Variante auf none gesetzt). */
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
  }
  body.is-mobile-editor .autosave-indicator:active {
    transform: scale(0.94);
    transition: transform .08s ease;
  }
  /* Wenn ein Sheet offen ist, ebenfalls ausblenden (wie das Hilfe-Icon). */
  body.is-mobile-editor.is-mobile-sheet-open .autosave-indicator {
    opacity: 0;
    pointer-events: none;
  }

  /* ── Editor-Layout: Sidebar verschwindet, Canvas voll ─────────────────── */
  body.is-mobile-editor .editor-layout {
    display: block !important;
    grid-template-columns: none !important;
    background: #f1ece4;
    /* Sicherheit gegen Konflikte mit app.css-Regeln */
    min-height: 0;
  }
  body.is-mobile-editor .editor-sidebar {
    /* Wird per JS in den .mobile-photo-drawer umgezogen — Original-Hülle ausblenden. */
    display: none !important;
  }
  body.is-mobile-editor .editor-canvas {
    /* Unten Platz für die fixe Tab-Bar (56 px + Safe-Area). Seitliche
       Padding bleiben symmetrisch — kein Drawer mehr links. */
    padding: 4px 4px calc(60px + env(safe-area-inset-bottom, 0px)) 4px;
    background: #f1ece4;
    min-height: 0;
  }
  body.is-mobile-editor .canvas-stage {
    max-height: none !important;
    padding: 6px;
    overflow: hidden;
  }

  /* Canvas-Hint (Tastatur-Hinweise) auf Mobile ausblenden. Hilfe via ?-Button. */
  body.is-mobile-editor #canvas-hint { display: none; }

  /* ── Zoom-Controls im Werkzeuge-Sheet (oben als kompakte Reihe) ───────── */
  .mobile-tools-sheet__zoom-slot {
    display: flex;
    justify-content: center;
    margin: 4px 0 10px;
  }
  .mobile-tools-sheet__zoom-slot:empty { display: none; }
  body.is-mobile-editor .zoom-controls {
    margin: 0;
    background: var(--bg-soft, #f8f5f0);
    border: 1px solid #e6ddcf;
    border-radius: 999px;
    padding: 2px;
    gap: 0;
    align-self: center;
  }
  body.is-mobile-editor .zoom-controls button {
    width: 32px; height: 32px;
    padding: 0;
    font-size: 1em;
  }
  body.is-mobile-editor .zoom-controls .zoom-pct {
    min-width: 38px;
    padding: 0 2px;
    font-size: .78em;
    color: var(--ink-soft, #5a534b);
  }
  /* "Fit"-Button im Mobile-Sheet ist redundant (Zoom kann via Pinch
     zurückgesetzt werden, Layout sowieso eng) — ausblenden, spart Breite. */
  body.is-mobile-editor .zoom-controls #btn-zoom-fit { display: none; }

  /* Bestehende Properties-Panel-Floats (Frame, Line, …) sicher unten ankern,
     damit sie das Werkzeuge-Sheet nicht überlappen. */
  body.is-mobile-editor .editor-properties {
    display: none !important;
  }

  /* ── Mobile-Sheets (Fotomediathek + Werkzeuge, beide unten, gleicher Stil)─ */
  .mobile-sheet {
    position: fixed;
    left: 0; right: 0;
    bottom: 56px;                                 /* sitzt über der Tab-Bar */
    z-index: 930;
    background: #fff;
    border-top: 1px solid #e6ddcf;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    transform: translateY(8px);
    opacity: 0;
    transition: max-height .26s ease, transform .26s ease, opacity .2s ease;
    visibility: hidden;
    pointer-events: none;
  }
  .mobile-sheet.is-open {
    max-height: calc(72dvh - 56px);
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .mobile-sheet__header {
    flex: 0 0 auto;
    position: relative;
    padding: 18px 52px 10px 18px;
    border-bottom: 1px solid #efe7da;
  }
  .mobile-sheet__handle-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px; height: 4px;
    border-radius: 2px;
    background: #d8cfbf;
    pointer-events: none;
  }
  .mobile-sheet__title {
    margin: 0;
    font-size: 1em;
    font-weight: 600;
    color: var(--ink, #2a2520);
  }
  .mobile-sheet__close {
    position: absolute;
    top: 10px; right: 10px;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: #fff;
    color: var(--ink, #2a2520);
    border: 1px solid #e6ddcf;
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s;
  }
  .mobile-sheet__close:active { background: #f4eee4; }
  .mobile-sheet__inner {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 14px 18px;
    -webkit-overflow-scrolling: touch;
  }

  /* Fotomediathek-Inhalt: Upload + Thumbs. */
  .mobile-sheet--photos #upload-zone {
    margin-bottom: 10px;
    padding: 14px;
  }
  .mobile-sheet--photos #thumb-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .mobile-sheet--photos #thumb-grid .thumb-wrap { aspect-ratio: 1; }
  /* Pending-Asset in der Fotomediathek: kräftiger Akzent-Rahmen. */
  .thumb-wrap.is-pending {
    border-color: var(--accent, #ff6b5b) !important;
    box-shadow: 0 0 0 3px rgba(255,107,91,.32);
  }

  /* Werkzeuge-Inhalt: oberste Zeile = Zoom links + "Am PC weitermachen?" rechts. */
  .mobile-sheet--tools .mobile-tools-sheet__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 12px;
    min-width: 0;
    flex-wrap: nowrap;
  }
  .mobile-sheet--tools .mobile-tools-sheet__zoom-slot {
    display: flex;
    justify-content: flex-start;
    margin: 0;
    flex: 0 0 auto;
  }
  .mobile-sheet--tools .mobile-tools-sheet__zoom-slot:empty { display: none; }
  .mobile-tools-sheet__resume {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: #fff;
    border: 1px solid var(--accent, #ff6b5b);
    color: var(--accent, #ff6b5b);
    border-radius: 999px;
    font-size: .78em;
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
  }
  .mobile-tools-sheet__resume svg { flex: 0 0 auto; }
  .mobile-tools-sheet__resume span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .mobile-tools-sheet__resume:active { background: #fff6f4; }
  /* Auf besonders schmalen Bildschirmen (< 380 px) Text verkürzen, nur Icon
     + kurzer Hinweis bleibt — verhindert horizontales Scrollen. */
  @media (max-width: 380px) {
    .mobile-tools-sheet__resume span::after { content: ""; }
  }
  .mobile-sheet--tools .add-tools {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 0 0 12px;
  }
  /* Die `.editor-sidebar .tool-btn`-Regel aus index.php greift nach dem
     DOM-Move nicht mehr — wir replizieren die wesentlichen Styles hier. */
  .mobile-sheet--tools .tool-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px;
    min-height: 64px;
    padding: 8px 4px;
    background: #fff;
    border: 1px solid #e6ddcf;
    border-radius: 12px;
    color: #4a4035;
    font-size: .72em;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    cursor: pointer;
  }
  .mobile-sheet--tools .tool-btn svg {
    width: 22px; height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .mobile-sheet--tools .tool-btn--primary {
    border-color: var(--accent, #ff6b5b);
    color: var(--accent, #ff6b5b);
  }
  .mobile-sheet--tools .tool-btn:active {
    transform: translateY(1px);
  }
  .mobile-sheet--tools .mobile-tools-sheet__extras {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 4px;
    border-top: 1px solid #efe7da;
    padding-top: 12px;
  }
  .mobile-sheet--tools .mobile-tools-sheet__extras .btn {
    min-height: 44px;
    padding: 6px 4px;
    font-size: .78em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Body-Scroll sperren bei offenem Sheet — sonst lässt sich der Hintergrund
     mit dem Finger noch verschieben/scrollen. `touch-action: none` blockt
     auch iOS-Touch-Pan; overflow:hidden ergänzt für DEsktop-ähnliches Verhalten. */
  body.is-mobile-editor.is-mobile-sheet-open {
    overflow: hidden !important;
    touch-action: none !important;
  }
  body.is-mobile-editor.is-mobile-sheet-open .editor-layout,
  body.is-mobile-editor.is-mobile-sheet-open .editor-canvas,
  body.is-mobile-editor.is-mobile-sheet-open .canvas-stage {
    touch-action: none !important;
    pointer-events: none !important;
  }

  /* ── Sheet-Backdrop (Modal-Sperre, wenn ein Sheet offen ist) ─────────── */
  .mobile-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20,16,12,.45);
    z-index: 925;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
    pointer-events: none;
  }
  .mobile-sheet-backdrop.is-active {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* ── Tab-Bar (zwei Buttons unten) ─────────────────────────────────────── */
  .mobile-tabbar {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 940;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border-top: 1px solid #e6ddcf;
    box-shadow: 0 -4px 14px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-tabbar__btn {
    background: transparent;
    border: none;
    border-top: 3px solid transparent;
    padding: 8px 6px 10px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--ink-soft, #5a534b);
    font-size: .72em;
    font-weight: 500;
    cursor: pointer;
    transition: color .15s, border-color .15s;
  }
  .mobile-tabbar__btn svg { color: var(--ink-soft, #5a534b); }
  .mobile-tabbar__btn.is-active {
    color: var(--accent, #ff6b5b);
    border-top-color: var(--accent, #ff6b5b);
    background: #fff7f5;
  }
  .mobile-tabbar__btn.is-active svg { color: var(--accent, #ff6b5b); }
  .mobile-tabbar__btn:active { background: #f6efe4; }
  /* Default: Inner-Wrapper transparent — der Button-Flex (column) gilt direkt
     für svg + span. Erst im Landscape-Block (weiter unten) wird der Wrapper
     zum sichtbaren Layout-Container mit 90°-Rotation. */
  .mobile-tabbar__btn-inner { display: contents; }

  /* ── Hilfe-Bubble (?) ─────────────────────────────────────────────────── */
  /* z-index unter Backdrop (925) und Sheet (930) — sobald ein Sheet ausfährt,
     verschwindet die Bubble hinter dem Sheet. Sichtbarkeit zusätzlich per
     Body-Klasse hart abschalten, damit auch der Schatten keinen Streifen
     unter dem Sheet zeigt. */
  .mobile-help-bubble,
  .mobile-feedback-bubble {
    position: fixed;
    left: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #fff;
    color: var(--ink-soft, #5a534b);
    border: 1px solid #e6ddcf;
    box-shadow: 0 4px 14px rgba(0,0,0,.16);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2em; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .18s ease;
  }
  /* Feedback-Bubble (Sprechblase) rechts neben der Hilfe-Bubble (?). */
  .mobile-feedback-bubble {
    left: calc(10px + 48px);
  }
  body.is-mobile-editor.is-mobile-sheet-open .mobile-help-bubble,
  body.is-mobile-editor.is-mobile-sheet-open .mobile-feedback-bubble {
    opacity: 0;
    pointer-events: none;
  }
  .mobile-help-bubble:active,
  .mobile-feedback-bubble:active { transform: scale(.95); }

  /* ── Frame-Await-Pulsation (Pending-Asset-Modus) ──────────────────────── */
  body.is-mobile-editor .konvajs-content.is-await-photo {
    animation: mobileAwaitGlow 1.4s ease-in-out infinite;
  }
  @keyframes mobileAwaitGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,91,.0); }
    50%      { box-shadow: 0 0 0 4px rgba(255,107,91,.18); }
  }

  /* ── Boot-Overlay kompakter ───────────────────────────────────────────── */
  body.is-mobile-editor #editor-boot-overlay .boot-overlay__panel {
    padding: 18px 24px;
  }
  body.is-mobile-editor #editor-boot-overlay .boot-overlay__text {
    font-size: .85em;
  }

  /* ── Cross-Device-Onboarding-Modal ────────────────────────────────────── */
  .mobile-onboarding-bg {
    position: fixed; inset: 0;
    background: rgba(20,16,12,.55);
    z-index: 6000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
  }
  .mobile-onboarding-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px 22px 18px;
    max-width: 380px; width: 100%;
    box-shadow: 0 16px 48px rgba(0,0,0,.25);
    text-align: left;
  }
  .mobile-onboarding-card h2 {
    margin: 0 0 6px;
    font-size: 1.15em;
    color: var(--ink, #2a2520);
  }
  .mobile-onboarding-card p {
    margin: 0 0 10px;
    font-size: .92em;
    line-height: 1.45;
    color: var(--ink-soft, #5a534b);
  }
  .mobile-onboarding-card .mobile-onboarding-hero {
    margin: 6px 0 14px;
    padding: 12px 14px;
    background: #fff7ee;
    border-left: 4px solid var(--accent, #ff6b5b);
    border-radius: 8px;
    font-size: .92em;
    color: var(--ink, #2a2520);
  }
  .mobile-onboarding-card__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
  }
  .mobile-onboarding-card__actions .btn { min-height: 44px; }

  /* ── Locked-Overlay mobile-tauglich ───────────────────────────────────── */
  body.is-mobile-editor .locked-overlay > div {
    max-width: calc(100vw - 40px);
    padding: 20px 22px !important;
  }

  /* Reflow-Dialog (Format ändern): 1fr 1fr ist auf engen Phones zu schmal —
     auf eine Spalte stacken. */
  [data-editor-modal] .modal-dialog__actions,
  [data-editor-modal] > div > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Format-wählen-Grid: auf Mobile 3 Kacheln pro Zeile statt auto-fill(120px).
     Greift sowohl für den Editor-Format-Dialog (`format-panel.js`) als auch
     für den Preset-Format-Dialog vor dem Editor-Start (`_preset_format_dialog.php`). */
  [data-editor-modal] .format-grid,
  .preset-format-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }
  [data-editor-modal] .format-grid .format-tile,
  .preset-format-grid .preset-format-tile {
    padding: 8px 4px !important;
    gap: 4px !important;
    font-size: .82em !important;
  }
  /* Preview-Slot: auf Mobile niedrigeren Fixed-Slot, Innenbox skalieren. */
  [data-editor-modal] .format-grid .format-tile__slot,
  .preset-format-grid .preset-format-tile__slot {
    height: 48px !important;
  }
  [data-editor-modal] .format-grid .format-tile__slot > div,
  .preset-format-grid .preset-format-tile__slot > div {
    transform: scale(.72);
    transform-origin: center;
  }
  [data-editor-modal] .format-grid .format-tile strong,
  .preset-format-grid .preset-format-tile strong {
    font-size: .78em !important;
    line-height: 1.2;
  }

  /* ── Editor-Modale auf Mobile: nicht mehr „min-width: 520/620 px" — passen
       sich dem Viewport an. !important sticht Inline-Styles aus makeModal. */
  [data-editor-modal] {
    padding: 8px !important;
  }
  [data-editor-modal] > div {
    min-width: 0 !important;
    width: 100% !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    padding: 16px !important;
    margin: 0 !important;
    /* Verhindert, dass horizontale Touch-Drags auf Range-Sliders das Modal
       horizontal scrollen — nur vertikales Scrolling im Modal-Body erlaubt. */
    touch-action: pan-y !important;
  }

  /* Range-Slider in Modalen: native Touch-Behandlung deaktivieren, damit der
     Touch-Drag nicht vom Modal abgefangen wird und versehentlich der
     Modal-Inhalt verschoben/gescrollt wird. */
  [data-editor-modal] input[type="range"] {
    touch-action: none !important;
    min-height: 32px;
  }

  /* Color-Input: iOS rendert den nativen Indicator klein und unscheinbar;
     wir setzen den Hintergrund per Inline-Style via JS (frame-panel.js)
     auf die aktuelle Farbe — appearance:none sorgt dafür, dass der
     Browser-Default das nicht überdeckt. */
  [data-editor-modal] input[type="color"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    padding: 0 !important;
  }
  [data-editor-modal] input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
  [data-editor-modal] input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

  /* Frame-Panel-Farbpicker: Hex-Feld auf Mobile ausblenden — spart Platz für
     die Schnellpalette. Die Palette darf gerne umbrechen / etwas kleinere
     Swatches haben, damit alle Farben sichtbar bleiben. */
  [data-editor-modal] .frame-panel-color-hex {
    display: none !important;
  }
  [data-editor-modal] .frame-panel-color-row {
    gap: 10px !important;
    flex-wrap: wrap;
  }
  [data-editor-modal] .frame-panel-palette {
    display: flex !important;
    flex: 1 1 auto;
    gap: 5px !important;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  [data-editor-modal] .frame-panel-palette button {
    width: 24px !important;
    height: 24px !important;
  }
  [data-editor-modal] .frame-panel-color {
    width: 44px !important;
    height: 36px !important;
    flex: 0 0 auto;
  }

  /* Frame-Panel-Aktionen: auf Mobile stapeln, alle Buttons gleich breit. */
  [data-editor-modal] .frame-panel-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  [data-editor-modal] .frame-panel-actions > div {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
  }
  [data-editor-modal] .frame-panel-actions .btn {
    flex: 1 1 0;
    padding: 10px 6px !important;
    font-size: .92em !important;
    white-space: nowrap;
    /* Sicherstellen, dass das Label (OK / Abbrechen) im Button mittig steht
       — auch wenn der Button via `flex: 1` deutlich breiter wird als der Text. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  /* Image-Picker-Grid kompakter auf Mobile */
  [data-editor-modal] [class*="img-picker"] {
    /* Falls die Picker-spezifischen Klassen Grid haben, bleiben sie auto. */
  }

  /* ── Objekt-Kontextmenü: bleibt im Viewport, wickelt um statt überzulaufen.
       Scroll/Wrap auf den INNEREN Wrapper, damit der äussere Rahmen
       overflow:visible behält und der Pfeil-Fortsatz (::before) nicht
       abgeschnitten wird. */
  #editor-context-menu { max-width: calc(100vw - 20px) !important; }
  #editor-bg-context-menu { max-width: calc(100vw - 20px) !important; }
  /* Buttons in ein Grid mit fester Spaltenzahl (--ctx-cols) legen → grosse
     Menüs landen kompakt auf zwei Zeilen statt drei. */
  #editor-context-menu .editor-ctx-inner,
  #editor-bg-context-menu .editor-ctx-inner {
    display: grid !important;
    grid-template-columns: repeat(var(--ctx-cols, 6), minmax(0, 1fr)) !important;
    gap: 2px !important;
    max-width: calc(100vw - 32px) !important;
    max-height: 60dvh !important;
    overflow-y: auto !important;
  }
  #editor-context-menu button,
  #editor-bg-context-menu button {
    min-width: 0 !important;
    padding: 6px 2px !important;
    gap: 3px !important;
  }
  #editor-context-menu button span,
  #editor-bg-context-menu button span {
    font-size: 9.5px !important;
    white-space: nowrap !important;
  }

  /* ── Spezialform-/Text-Form-Dialog: Vorschau + Steuerung übereinander
       statt zwei Spalten, sonst überläuft das Inline-Grid den schmalen
       Modal-Body und die Steuerung verschwindet rechts ausserhalb.
       Inline-Styles tragen kein !important, daher reicht hier die normale
       Spezifität nicht — wir setzen explizit !important. */
  [data-editor-modal] .editor-shape-dialog-layout {
    display: block !important;
    grid-template-columns: none !important;
  }
  [data-editor-modal] .editor-shape-dialog-layout > .editor-shape-dialog-preview {
    min-height: 0 !important;
    padding: 8px !important;
    margin-bottom: 14px !important;
  }
  /* Canvas: Höhe automatisch aus dem internen Pixelpuffer ableiten, damit
     max-width:100% das Bild nicht horizontal staucht. Sonst kippen die
     Hit-Detection-Koordinaten und vertikale Linien sind nicht mehr greifbar. */
  [data-editor-modal] .editor-shape-dialog-canvas {
    height: auto !important;
    max-width: 100% !important;
    max-height: 60dvh !important;
    /* Touch-Drag muss in BEIDEN Achsen funktionieren — der Modal-Body hat
       pan-y gesetzt, was wir hier wieder aufheben. */
    touch-action: none !important;
  }
}

/* ============================================================================
   Editor im Querformat (Phone-Landscape): Tab-Bar wandert an die rechte Kante,
   Sheets gleiten von rechts ein. Vermeidet den extrem flachen Bottom-Sheet,
   der bei ~390 px Viewport-Höhe den Canvas erdrückt. Zusätzlich Safe-Area-
   Padding für die Notch links/rechts (je nach Haltung).
   ============================================================================ */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  /* ── Tab-Bar: vertikale Spalte rechts ─────────────────────────────────── */
  body.is-mobile-editor .mobile-tabbar {
    left: auto;
    top: 0;
    right: 0;
    bottom: 0;
    width: calc(58px + env(safe-area-inset-right, 0px));
    grid-template-columns: 1fr;
    /* Beide Buttons in der Bildschirmhöhe zentriert (auto-Rows ohne 1fr,
       align-content: center packt sie mittig). */
    grid-template-rows: auto auto;
    align-content: center;
    row-gap: 18px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    border-top: none;
    border-left: 1px solid #e6ddcf;
    box-shadow: -4px 0 14px rgba(0,0,0,.08);
  }
  body.is-mobile-editor .mobile-tabbar__btn {
    /* Hoch-Tab: 58×120 — Inner-Wrapper wird 90° CCW gedreht, sodass Icon +
       Label vertikal liegen und der Text von unten nach oben gelesen wird. */
    height: 120px;
    width: 100%;
    border-top: none;
    border-right: 3px solid transparent;
    padding: 0;
    font-size: .68em;
    gap: 0;
    overflow: hidden;
  }
  body.is-mobile-editor .mobile-tabbar__btn-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* Inner als 90°-CCW-gedrehter Block: die ursprüngliche Höhe (118 px)
       wird nach dem Rotieren zur Tab-Breite, die Breite zur Tab-Höhe. */
    width: 118px;
    transform: rotate(-90deg);
    transform-origin: center center;
    white-space: nowrap;
    line-height: 1.1;
  }
  body.is-mobile-editor .mobile-tabbar__btn-inner svg {
    flex: 0 0 auto;
  }
  body.is-mobile-editor .mobile-tabbar__btn.is-active {
    border-right-color: var(--accent, #ff6b5b);
    border-top-color: transparent;
  }

  /* ── Sheets: vertikale Spalte links neben der Tab-Bar ─────────────────── */
  body.is-mobile-editor .mobile-sheet {
    left: auto;
    top: 0;
    right: calc(58px + env(safe-area-inset-right, 0px));
    bottom: 0;
    width: min(62vw, 420px);
    max-height: 100dvh;
    border-radius: 18px 0 0 18px;
    border-top: none;
    border-right: 1px solid #e6ddcf;
    transform: translateX(12px);
    box-shadow: -10px 0 32px rgba(0,0,0,.20);
  }
  body.is-mobile-editor .mobile-sheet.is-open {
    transform: translateX(0);
    max-height: 100dvh;
  }
  /* Handle-Bar oben mittig macht nur am Bottom-Sheet Sinn. */
  body.is-mobile-editor .mobile-sheet__handle-bar { display: none; }
  body.is-mobile-editor .mobile-sheet__header {
    padding: 14px 52px 10px 16px;
  }
  body.is-mobile-editor .mobile-sheet__close {
    top: 8px;
    right: 8px;
    width: 34px; height: 34px;
  }
  body.is-mobile-editor .mobile-sheet__inner {
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  /* Fotomediathek: engere Spalten, kleinere Thumbs — sonst sieht man bei
     420 px Sheet-Breite nur 3 riesige Kacheln. */
  body.is-mobile-editor .mobile-sheet--photos #thumb-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  /* Werkzeuge: Kacheln kompakter, Extras enger packen. */
  body.is-mobile-editor .mobile-sheet--tools .add-tools {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  body.is-mobile-editor .mobile-sheet--tools .tool-btn {
    min-height: 56px;
    padding: 6px 3px;
    font-size: .66em;
    gap: 2px;
  }
  body.is-mobile-editor .mobile-sheet--tools .tool-btn svg {
    width: 20px; height: 20px;
  }
  body.is-mobile-editor .mobile-sheet--tools .mobile-tools-sheet__extras {
    grid-template-columns: repeat(2, 1fr);
    padding-top: 10px;
  }
  body.is-mobile-editor .mobile-sheet--tools .mobile-tools-sheet__topbar {
    margin: 0 0 8px;
  }

  /* ── Canvas-Layout: links/rechts Safe-Area + Platz für rechte Tab-Bar ── */
  body.is-mobile-editor .editor-canvas {
    /* unten kein 60-px-Padding mehr (Tab-Bar ist jetzt rechts), dafür
       rechts der Tab-Bar-Platz + Notch-Safe-Area. Links nur Notch-Safe-Area. */
    padding-top: calc(4px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(4px + env(safe-area-inset-left, 0px));
    padding-right: calc(62px + env(safe-area-inset-right, 0px));
  }

  /* ── Hilfe-Bubble wandert nach RECHTS, oberhalb der Speichern-Bubble.
       Beide an gleicher x-Koordinate links neben der Tab-Bar. */
  body.is-mobile-editor .mobile-help-bubble {
    left: auto;
    right: calc(68px + env(safe-area-inset-right, 0px));
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  /* Feedback-Bubble in Querformat oberhalb der Hilfe-Bubble stapeln. */
  body.is-mobile-editor .mobile-feedback-bubble {
    left: auto;
    right: calc(68px + env(safe-area-inset-right, 0px));
    bottom: calc(102px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Speichern-Bubble: unten, links neben der rechten Tab-Bar ────────── */
  body.is-mobile-editor .autosave-indicator {
    right: calc(68px + env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Canvas linksbündig statt zentriert: wenn das Sheet von rechts
       reingleitet, bleibt möglichst viel der Collage links sichtbar.
       Wichtig: `#konva-container` hat in der Editor-Seite ein inline
       `margin: auto` (für das Auto-Zentrieren bei Zoom-Overflow). Auf einem
       Flex-Item gewinnt `margin: auto` immer gegen `justify-content`, also
       hier explizit `margin-left: 0` setzen. `justify-content` allein
       reichte nicht aus. */
  body.is-mobile-editor .canvas-stage {
    justify-content: flex-start;
  }
  body.is-mobile-editor .canvas-stage > #konva-container {
    margin-left: 0;
    margin-right: auto;
  }

  /* ── Site-Header im Editor-Querformat: Bestellen-Button braucht zusätzlichen
       Platz rechts (Tab-Bar 58 px + Safe-Area), sonst sitzt er hinter der
       vertikalen Tab-Bar. `!important` weil die globale Notch-Regel (s. unten)
       ebenfalls !important nutzt und sonst überschriebe — Editor-Override für
       rechts muss gewinnen. */
  body.is-mobile-editor .site-header .inner {
    padding-left: max(14px, env(safe-area-inset-left, 0px)) !important;
    padding-right: calc(62px + env(safe-area-inset-right, 0px)) !important;
  }

  /* Im Querformat ebenfalls „Preise"-Link aus der Nav nehmen (die existierende
     Regel in @media (max-width:720px) greift bei ~844 px Landscape-Breite
     nicht). */
  body.is-mobile-editor .site-header .site-nav > a[href$="/preise"] {
    display: none;
  }

  /* ── Staging-Banner: Tab-Bar + Sheets unter den Banner schieben, damit
       Inhalte nicht hinter dem klebenden „🚧 STAGING"-Streifen verschwinden. */
  body:has(.staging-banner).is-mobile-editor .mobile-tabbar,
  body:has(.staging-banner).is-mobile-editor .mobile-sheet {
    top: 36px;
  }
}

/* ============================================================================
   Site-weite Mobile-Anpassungen (Header, Startseite).
   ============================================================================ */

/* Default (Desktop): Mobile-Label verstecken. Steht VOR der Mobile-Media-Query,
   damit der Mobile-Override bei gleicher Spezifität später kommt und gewinnt. */
.site-header .site-nav > a.btn.is-resume .lbl-mobile { display: none; }

/* Portrait-only: Header wrappt auf 2 Zeilen (Logo zentriert oben, Nav darunter).
   Im Phone-Landscape ist genug horizontaler Platz für Logo links + Nav rechts
   auf einer Zeile — nicht hier mitzuziehen, sonst wird die Header-Höhe doppelt. */
@media (max-width: 720px) and (orientation: portrait) {
  .site-header .inner {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
  }
  .site-header .brand {
    flex: 0 0 100%;
    justify-content: center;
    font-size: 1.15rem;
  }
  .site-nav {
    flex: 0 0 100%;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
  }
  .site-nav a {
    padding: 6px 10px;
    font-size: .92em;
  }
}

/* Mobile (Portrait + Phone-Landscape): Links ausblenden, Resume-Label kurz. */
@media (max-width: 720px),
       (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  /* Links, die auf Mobile keinen Sinn haben — entfallen aus der Nav.
     Ausnahme: der „Zum Editor"-Button bei aktiver Gestaltung (Klasse is-resume). */
  .site-header .site-nav > a.btn:not(.is-resume),
  .site-header .site-nav > a[href$="/preise"],
  .site-header .site-nav > a[href$="/faq"] {
    display: none;
  }
  /* „Zum Editor zurück" → auf Mobile als kurzes „Zum Editor". */
  .site-header .site-nav > a.btn.is-resume .lbl-desktop { display: none; }
  .site-header .site-nav > a.btn.is-resume .lbl-mobile  { display: inline; }
  .site-header .site-nav > a.btn.is-resume {
    padding: 6px 10px;
    font-size: .92em;
  }
}

/* Horizontal-Scroll grundsätzlich verhindern (kein Overflow auf Mobile).
   Seitliche Mindest-Polsterung von 16px, damit Inhalt nicht am Bildschirmrand
   klebt — im Hochformat ist `safe-area-inset` 0, deshalb `max(16px, inset)`.
   Auf Notch-Phones im Querformat schiebt der grössere Inset den Inhalt aus dem
   ausgesparten Bereich. `!important`, weil viele Page-Views per Inline-Shorthand
   `padding: 32px 0` padding-left:0 setzen. */
@media (max-width: 720px),
       (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .container,
  .site-header .inner {
    padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
  }
}

/* Startseite — Drei Promo-Kacheln im Hochformat stapeln. Inline-Styles werden
   per !important überschrieben. Im Querformat bleiben sie nebeneinander. */
@media (max-width: 640px) and (orientation: portrait) {
  .promo-bar {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    margin: 20px 0 !important;
  }
  .promo-bar .card--promo {
    padding: 18px !important;
  }
}

/* Vier Feature-Kacheln auf engem Phone in 2 Spalten — sonst geht es zu eng. */
@media (max-width: 480px) {
  .feature-bar {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .feature { padding: 14px !important; }
}

/* ============================================================================
   Checkout / Cart Mobile-Polish (eigener Breakpoint 720 px wie app.css).
   Eingeschränkt auf body.cart-page / body.checkout-page, damit der Rest der
   Site unangetastet bleibt.
   ============================================================================ */

@media (max-width: 720px) {

  body.cart-page input,
  body.cart-page select,
  body.cart-page textarea,
  body.checkout-page input,
  body.checkout-page select,
  body.checkout-page textarea {
    font-size: 16px !important;     /* verhindert iOS-Autozoom */
    min-height: 44px;
  }

  body.cart-page .btn,
  body.checkout-page .btn {
    min-height: 44px;
  }

  /* Mengen-Stepper deutlich grösser (Cart + Checkout-Übersicht). */
  body.cart-page .qty-btn,
  body.checkout-page .qty-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.25em !important;
  }
  body.cart-page .qty-input,
  body.checkout-page .qty-input {
    width: 56px !important;
    height: 40px;
    font-size: 1em !important;
  }

  /* Cart-Tabelle wird auf schmalen Phones zur Card-Liste. Wir bleiben aber
     beim bestehenden table-Markup — nur Padding und Spaltenbreiten anpassen. */
  body.cart-page table th,
  body.cart-page table td,
  body.checkout-page table th,
  body.checkout-page table td {
    padding: 8px 6px !important;
  }
  body.cart-page table th:nth-child(2),
  body.cart-page table td:nth-child(2),
  body.checkout-page table th:nth-child(2),
  body.checkout-page table td:nth-child(2) {
    /* „Einzelpreis"-Spalte verstecken — sie steckt eh nochmal im Zeilen-Total. */
    display: none;
  }
  body.cart-page table th,
  body.checkout-page table th {
    font-size: .82em;
  }

  /* Sticky-Bottom-CTA für die Kasse — die Bestell-Aktion bleibt erreichbar,
     auch bei langem Formular. */
  body.checkout-page form .btn--lg.btn--block {
    position: sticky;
    bottom: 0;
    margin-top: 12px;
    z-index: 30;
    box-shadow: 0 -6px 18px rgba(0,0,0,.10);
  }

  /* Payment-Methoden bekommen mehr Tap-Höhe. */
  body.checkout-page .pay-method {
    padding: 16px 14px;
    min-height: 56px;
  }
  body.checkout-page .pay-method__check {
    width: 26px; height: 26px;
  }

  /* Form-Group-Spacing reduzieren — auf Phones ist jedes vertikale mm wertvoll. */
  body.checkout-page .form-group { margin-bottom: 10px; }
  body.checkout-page .form-row { gap: 8px; }

  /* Add-more im Cart: kompakter. */
  body.cart-page .cart-add-more[open] > summary { font-size: 1.15em; }

  /* Container-Padding: Cart/Checkout-Sections haben inline-style „padding: 32px 0"
     — wir reservieren auf Mobile horizontalen Atemraum. */
  body.cart-page section.container,
  body.checkout-page section.container {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* Cart: „+ Neue Collage gestalten" auf Mobile entfernen — der primäre CTA
     ist „Zur Kasse", neue Gestaltungen lohnen sich auf dem Phone nicht. */
  body.cart-page a.btn[href$="/vorlagen"] {
    display: none !important;
  }
}

/* ── Cart/Checkout-Tabellen als Karten-Liste auf engen Phones (≤580 px) ──── */
@media (max-width: 580px) {
  body.cart-page table,
  body.checkout-page table {
    display: block;
    width: 100%;
    border-collapse: collapse;
  }
  body.cart-page table thead,
  body.checkout-page table thead { display: none; }
  body.cart-page table tbody,
  body.checkout-page table tbody { display: block; }

  /* Hauptzeile (mit data-idx): 3-Spalten-Grid, Produkt oben breit. */
  body.cart-page table tbody tr[data-idx],
  body.checkout-page table tbody tr[data-idx] {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "product product del"
      "qty     total   total";
    column-gap: 10px;
    row-gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  body.cart-page table tbody tr[data-idx] td,
  body.checkout-page table tbody tr[data-idx] td {
    display: block;
    padding: 0 !important;
    border: none !important;
  }
  body.cart-page table tbody tr[data-idx] td:nth-child(1),
  body.checkout-page table tbody tr[data-idx] td:nth-child(1) { grid-area: product; }
  body.cart-page table tbody tr[data-idx] td:nth-child(2),
  body.checkout-page table tbody tr[data-idx] td:nth-child(2) { display: none !important; }
  body.cart-page table tbody tr[data-idx] td:nth-child(3),
  body.checkout-page table tbody tr[data-idx] td:nth-child(3) { grid-area: qty; }
  body.cart-page table tbody tr[data-idx] td:nth-child(4),
  body.checkout-page table tbody tr[data-idx] td:nth-child(4) {
    grid-area: total; text-align: right !important;
    align-self: center; font-weight: 700; font-size: 1.05em;
  }
  body.cart-page table tbody tr[data-idx] td:nth-child(5),
  body.checkout-page table tbody tr[data-idx] td:nth-child(5) {
    grid-area: del; align-self: start; text-align: right !important;
  }
  /* Zusatzzeile „inkl. Druckdaten als kostenloser Download": auf Mobile als
     kompakte Zeile (Label links, „gratis" rechts) direkt unter dem Produkt. */
  body.cart-page table tbody tr.included-row,
  body.checkout-page table tbody tr.included-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 0 0 10px;
    margin-top: -2px;
    border-bottom: 1px solid var(--line);
  }
  body.cart-page table tbody tr.included-row td,
  body.checkout-page table tbody tr.included-row td {
    display: block;
    padding: 0 !important;
    border: none !important;
  }
  body.cart-page table tbody tr.included-row td:first-child,
  body.checkout-page table tbody tr.included-row td:first-child { flex: 1; }
  /* leere letzte Zelle (Lösch-Spalte) unterdrücken */
  body.cart-page table tbody tr.included-row td:nth-child(3),
  body.checkout-page table tbody tr.included-row td:nth-child(3) { display: none; }
  /* übrige Nicht-Item-Zeilen (falls vorhanden) weiterhin ausblenden */
  body.cart-page table tbody tr:not([data-idx]):not(.included-row) {
    display: none;
  }

  /* tfoot: jede Zeile als Flex-Row mit Label links, Wert rechts. */
  body.cart-page table tfoot,
  body.checkout-page table tfoot { display: block; }
  body.cart-page table tfoot tr,
  body.checkout-page table tfoot tr {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 6px 0; border: none;
  }
  body.cart-page table tfoot tr td,
  body.checkout-page table tfoot tr td {
    padding: 0 !important; border: none !important; text-align: left !important;
  }
  body.cart-page table tfoot tr td[colspan],
  body.checkout-page table tfoot tr td[colspan] { flex: 1; }
  body.cart-page table tfoot tr td:last-child,
  body.checkout-page table tfoot tr td:last-child { text-align: right !important; }
}
