/* ── Export mode: gallery + square/rect frame overlay ── */

body.export-mode .export-gallery,
body.sheet-export .export-gallery.sheet-panel {
  display: none;
}

body.sheet-export.sheet-open .export-gallery.sheet-panel[data-sheet="export"] {
  display: flex;
}

/* Export-Modus: kein Export-Toggle und kein Overflow (Sheet hat Exit / Word). */
body.export-mode #canvas-toolbar-io,
body.export-mode #canvas-toolbar-einsatz,
body.export-mode #canvas-toolbar-overflow,
body.export-mode #header-btn-export,
body.export-mode #btn-export,
body.export-mode #canvas-tb-export,
body.export-mode #btn-schnellansicht,
body.export-mode #header-btn-schnellansicht,
body.export-mode #canvas-tb-schnellansicht,
body.export-mode #canvas-overflow-schnellansicht,
body.export-mode #canvas-overflow-export {
  display: none !important;
}

/* Desktop: toolbar center on the Ausschnitt (JS pinpoints via sheet pad). */
@media (min-width: 721px) {
  body.export-mode.sheet-open .canvas-toolbar-dock {
    left: calc(50% + (12px + var(--sheet-width) + 8px) / 2);
  }
}

.export-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.schnellansicht-nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.schnellansicht-nav-row select {
  flex: 1 1 120px;
  min-width: 0;
}

.schnellansicht-waiting-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
}

.schnellansicht-waiting-wrap.hidden {
  display: none !important;
}

.schnellansicht-waiting-wrap input {
  width: auto;
  margin: 0;
}

/* Hide split control while exporting (split is forced off). */
body.export-mode [data-pane-split] {
  display: none !important;
}

/* While Word export / thumb rebuild runs, block all app interaction under busy overlay. */
body.export-busy,
body.export-word-busy {
  overflow: hidden;
}

body.export-busy #workspace,
body.export-busy .chrome-float,
body.export-word-busy #workspace,
body.export-word-busy .chrome-float,
body.export-busy .export-gallery,
body.export-word-busy .export-gallery {
  pointer-events: none !important;
}

/* Busy overlay itself must stay interactive (cancel). */
body.export-busy .export-busy-overlay,
body.export-word-busy .export-busy-overlay {
  pointer-events: auto !important;
}

/* ── Gallery panel (opaque, captures all pointer events — no click-through) ── */
.export-gallery {
  display: none;
  position: relative;
  top: auto;
  left: auto;
  bottom: auto;
  width: 100%;
  height: 100%;
  z-index: auto;
  flex-direction: column;
  gap: 0;
  background: transparent;
  border-right: none;
  box-shadow: none;
  pointer-events: auto;
  touch-action: manipulation;
  overflow: hidden;
  isolation: isolate;
}

/* Full-height hit layer so empty panel regions still capture clicks. */
.export-gallery::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: inherit;
  pointer-events: auto;
}

.export-gallery > * {
  position: relative;
  z-index: 1;
}

.export-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.export-gallery-title {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.export-gallery-exit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.export-gallery-exit:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.export-gallery-exit .material-symbols-outlined {
  font-size: 20px;
}

/* No autosave affordance in Export — Speichern is explicit on mobile editor. */
body.export-mode .save-status {
  display: none !important;
}

/* Ausschnitt: keep Karten-Auswahl above the crop dimmer (JS pins inside frame). */
body.export-mode.export-work-view .style-fan {
  z-index: 22;
}


/* Prominent Ausschnitt | Details segmented control under header */
.export-work-mode-bar {
  display: flex;
  gap: 4px;
  margin: 4px 12px 10px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  flex-shrink: 0;
}

.export-work-mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.export-work-mode-btn .material-symbols-outlined {
  font-size: 20px;
  opacity: 0.9;
}

.export-work-mode-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.export-work-mode-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}

.export-gallery-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Legacy gallery tools host removed — framing lives in #canvas-toolbar-export */
.export-active-tools {
  display: none !important;
}

/* Add Ausschnitt (primary) + Word export pinned to bottom of gallery panel */
.export-gallery-footer {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface, #1c1c1f);
}

.export-gallery-footer #export-add-snapshot {
  order: 0;
}

.export-gallery-footer .export-word-btn {
  order: 1;
}

.export-gallery-footer .export-word-btn,
.export-gallery-footer .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  background: var(--surface-2);
}

.export-gallery-footer .btn:hover {
  background: var(--surface-3, #333);
}

.export-gallery-footer .btn:disabled,
.export-gallery-footer .btn.is-busy:disabled {
  opacity: 0.75;
  cursor: wait;
}

/* Dark gallery scrollbars (Firefox + WebKit) */
.export-gallery-sections {
  scrollbar-width: thin;
  scrollbar-color: #5a5a60 #2a2a2e;
}

.export-gallery-sections::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.export-gallery-sections::-webkit-scrollbar-track {
  background: #2a2a2e;
  border-radius: 999px;
}

.export-gallery-sections::-webkit-scrollbar-thumb {
  background: #5a5a60;
  border-radius: 999px;
  border: 2px solid #2a2a2e;
}

.export-gallery-sections::-webkit-scrollbar-thumb:hover {
  background: #7a7a82;
}

.export-gallery {
  scrollbar-width: thin;
  scrollbar-color: #5a5a60 #2a2a2e;
}

.export-gallery-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}

.export-gallery-actions .btn .material-symbols-outlined {
  font-size: 18px;
}

.export-gallery-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.export-gallery-actions .btn.is-busy:disabled {
  opacity: 0.75;
  cursor: wait;
}

.export-gallery-sections {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-gallery-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 6px 2px;
}

.export-gallery-list {
  min-height: 36px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px dashed transparent;
  transition: border-color 0.15s, background 0.15s;
}

.export-gallery-list.drag-over {
  border-color: var(--primary);
  background: var(--primary-muted);
}

.export-gallery-empty {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
  padding: 8px 6px;
  margin: 0;
  opacity: 0.9;
}

.export-gallery-card {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}

.export-gallery-card:hover {
  background: var(--surface-3);
}

.export-gallery-card.active {
  border-color: var(--primary);
  background: var(--primary-muted);
}

.export-gallery-card.is-dragging {
  opacity: 0.45;
}

/* Always visible (touch + mouse) — do not require hover */
.export-gallery-card-delete,
.export-gallery-card-edit {
  position: absolute;
  top: 2px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: rgba(12, 12, 14, 0.65);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  opacity: 1;
  transition: background 0.12s, color 0.12s;
  z-index: 2;
}

.export-gallery-card-delete {
  right: 2px;
}

.export-gallery-card-edit {
  right: 26px;
}

.export-gallery-card-delete:hover,
.export-gallery-card-delete:focus-visible {
  background: var(--danger-bg);
  color: var(--danger);
}

.export-gallery-card-edit:hover,
.export-gallery-card-edit:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text, #f5f5f5);
}

.export-gallery-card-delete .material-symbols-outlined,
.export-gallery-card-edit .material-symbols-outlined {
  font-size: 16px;
}

.export-gallery-thumb {
  width: 52px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface));
  border: 1px solid var(--border);
  overflow: hidden;
}

.export-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 3px;
}

.export-gallery-thumb.is-loading {
  opacity: 0.65;
}

.export-gallery-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.export-gallery-card-title {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.export-gallery-card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Snapshot config dialog (add + pencil edit) ── */
.export-snapshot-dialog {
  position: fixed;
  inset: 0;
  z-index: 3500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.export-snapshot-dialog.hidden {
  display: none !important;
}

.export-snapshot-dialog-scrim {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 14, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.export-snapshot-dialog-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(420px, 92vw);
  max-height: min(88vh, 720px);
  border-radius: var(--radius, 12px);
  background: var(--surface, #1c1c1f);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  color: var(--text, #f5f5f5);
  overflow: hidden;
}

.export-snapshot-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.export-snapshot-dialog-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.export-snapshot-dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

.export-snapshot-dialog-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.export-snapshot-dialog-body {
  padding: 12px 14px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #5a5a60 #2a2a2e;
}

.export-snapshot-dialog-note {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.export-snapshot-dialog-note.hidden {
  display: none !important;
}

.export-snapshot-dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.export-snapshot-dialog-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.export-snapshot-dialog-footer .btn .material-symbols-outlined {
  font-size: 18px;
}

.export-snapshot-dialog-footer #export-snap-save-view.hidden {
  display: none !important;
}

.export-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.export-field input,
.export-field textarea,
.export-field select {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  resize: vertical;
}

.export-field select {
  resize: none;
  cursor: pointer;
  appearance: auto;
}

.export-field input:focus,
.export-field textarea:focus,
.export-field select:focus {
  outline: none;
  border-color: rgba(198, 40, 40, 0.45);
}

.export-nav-center-btn {
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.export-nav-center-btn .material-symbols-outlined {
  font-size: 1.15rem;
}

.export-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.export-check.hidden {
  display: none !important;
}

.export-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.export-nav-field select.hidden {
  display: none !important;
}

.export-frame-size-toggle {
  display: flex;
  gap: 4px;
}

.export-size-btn {
  flex: 1;
  padding: 7px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.export-size-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.export-size-btn.active {
  background: var(--primary-muted);
  border-color: var(--primary);
  color: var(--primary);
}

.export-frame-size-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Frame overlay (milky exterior, clear interior) ── */
.export-frame-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.export-frame-overlay.hidden {
  display: none !important;
}

.export-frame-window {
  position: relative;
  box-sizing: border-box;
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  border-radius: 2px;
  /* Milky dim outside the frame; interior stays clear */
  box-shadow: 0 0 0 9999px rgba(18, 18, 22, 0.58);
  background: transparent;
  pointer-events: none;
}

.export-frame-window::after {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.export-frame-window[data-frame-size='rect'],
.export-frame-window[data-frame-size='lq'] {
  border-color: rgba(250, 204, 21, 0.55);
}

.export-frame-window[data-frame-size='square'],
.export-frame-window[data-frame-size='hq'] {
  border-color: rgba(255, 255, 255, 0.42);
}

/* Slightly inset map controls when gallery open on narrow primary */
body.export-mode .split-pane--primary .map-controls--pane {
  left: auto;
  right: 12px;
}

/*
 * Details mode: lock map chrome (layers, compass, 3D/axonometry, pitch, style fan).
 * User must switch to Ausschnitt to change camera / layers / style.
 */
body.export-work-detail .map-controls--pane,
body.export-work-detail .map-controls--pane .map-control-btn,
body.export-work-detail .map-controls--pane .map-pitch-control,
body.export-work-detail .map-controls--pane .map-layers-wrap,
body.export-work-detail .map-controls--pane .map-layers-panel,
body.export-work-detail .map-controls--pane .map-layers-panel * {
  pointer-events: none !important;
  cursor: not-allowed !important;
}

body.export-work-detail .map-controls--pane {
  opacity: 0.38;
  filter: grayscale(0.25);
}

/* Details: no Karten-Auswahl — switch to Ausschnitt to change map style. */
body.export-work-detail .style-fan {
  display: none !important;
}

body.export-work-detail #layer-options,
body.export-work-detail #layer-options-mirror,
body.export-work-detail #layer-options button,
body.export-work-detail #layer-options input,
body.export-work-detail #layer-options label,
body.export-work-detail #layer-options-mirror button,
body.export-work-detail #layer-options-mirror input,
body.export-work-detail #layer-options-mirror label {
  pointer-events: none !important;
  cursor: not-allowed !important;
}

body.export-work-detail #layer-options,
body.export-work-detail #layer-options-mirror {
  opacity: 0.38;
  filter: grayscale(0.25);
}

/* Keep plan / draw canvas above MapLibre + 3D meshes for flat annotation hit/paint */
body.export-mode .split-pane--primary #canvas-draw,
body.export-mode .split-pane--primary .map-plan-view__plan,
body.export-work-detail .split-pane--primary #canvas-draw,
body.export-work-detail .split-pane--primary .map-plan-view__plan {
  z-index: 6;
}

/* Freeze overlay must cover draw during style swap (export raises draw to 6). */
body.export-mode .split-pane--primary #canvas-plan-freeze,
body.export-mode .split-pane--primary .map-plan-view__plan-freeze,
body.export-work-detail .split-pane--primary #canvas-plan-freeze,
body.export-work-detail .split-pane--primary .map-plan-view__plan-freeze {
  z-index: 10;
}

body.export-work-detail.map-3d-active .split-pane--primary #canvas-draw,
body.export-work-detail.map-3d-active .split-pane--primary .map-plan-view__plan,
body.export-work-detail.map-3d-active .split-pane--primary #canvas-overlay {
  z-index: 6;
  pointer-events: auto;
}

/* Freehand shapes: inline in main toolbar, only Export → Details */
body:not(.export-work-detail) #canvas-export-shapes,
body:not(.export-work-detail) .canvas-export-shapes-divider {
  display: none !important;
}

#canvas-export-shapes {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Export (Ausschnitt + Details): fully hide plan tools — not merely dimmed */
body.export-mode #canvas-toolbar-symbols,
body.export-mode #canvas-symbols-more,
body.export-mode #canvas-buildings-start,
body.export-mode .shape-btn[data-shape="route"],
body.export-mode .shape-btn[data-shape="symbol"],
body.export-mode #canvas-toolbar-3d,
body.export-mode #canvas-toolbar-building,
body.export-mode #canvas-toolbar-nav,
body.export-mode #canvas-toolbar-nav-stop,
body.export-mode #canvas-toolbar-vehicle,
body.export-mode #canvas-toolbar-sphere-elev {
  display: none !important;
}

/* Ausschnitt: no props group; framing tools are in #canvas-toolbar-export */
body.export-work-view #canvas-toolbar-props {
  display: none !important;
}

/* Framing tools only while Export → Ausschnitt */
body:not(.export-work-view) #canvas-toolbar-export,
#canvas-toolbar-export.hidden {
  display: none !important;
}

/* Compact export framing group in the main canvas toolbar */
.canvas-toolbar-export {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  width: max-content;
}

.canvas-toolbar-export.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.canvas-toolbar-export .canvas-export-size-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.canvas-toolbar-export .export-size-btn {
  width: auto;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.canvas-toolbar-export .export-size-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.canvas-toolbar-export .export-size-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.canvas-toolbar-export .canvas-export-size-label {
  display: block;
  letter-spacing: 0.02em;
}

.canvas-toolbar-export .canvas-export-select {
  height: 32px;
  max-width: 9.5rem;
  min-width: 5.5rem;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.canvas-toolbar-export .canvas-export-select.hidden {
  display: none !important;
}

.canvas-toolbar-export .canvas-export-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.canvas-toolbar-export .canvas-export-check.hidden {
  display: none !important;
}

.canvas-toolbar-export .canvas-export-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.canvas-toolbar-export .export-nav-center-btn {
  margin: 0;
}

.canvas-toolbar--export {
  width: max-content;
  justify-content: center;
}

/* Dim leftovers (if any class remains from older sessions) */
body.export-mode .export-tool-dimmed {
  opacity: 0.42;
  pointer-events: none !important;
  cursor: not-allowed !important;
}

/* ── Word export busy overlay (fullscreen lock) ── */
.export-busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 14, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  touch-action: none;
}

.export-busy-overlay.hidden {
  display: none !important;
}

.export-busy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: min(320px, 88vw);
  max-width: 400px;
  padding: 28px 28px 22px;
  border-radius: var(--radius, 12px);
  background: var(--surface, #1c1c1f);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
  pointer-events: auto;
}

.export-busy-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--primary, #c62828);
  animation: export-busy-spin 0.75s linear infinite;
}

@keyframes export-busy-spin {
  to { transform: rotate(360deg); }
}

.export-busy-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.export-busy-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.3em;
}

.export-busy-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2, #2a2a2e);
  overflow: hidden;
}

.export-busy-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--primary, #c62828);
  transition: width 0.2s ease;
}

.export-busy-card .btn {
  margin-top: 4px;
  font-family: inherit;
  font-size: 0.84rem;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
}

.export-busy-card .btn:hover {
  background: var(--surface-3, #333);
}

@media (max-width: 720px) {
  /*
   * Export on mobile: gallery becomes a bottom sheet above the toolbar dock
   * so the Ausschnitt keeps usable map width (side sheet at ~86vw left the
   * crop frame ~70px wide). Desktop side-sheet behavior is unchanged.
   */
  body.export-mode.sheet-export .app-sheet:not(.app-sheet--help) {
    top: auto;
    left: 0;
    right: 0;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: min(42vh, 320px);
    max-height: min(46vh, 360px);
    border-radius: 16px 16px 0 0;
    transform: translateY(calc(100% + 24px));
    --sheet-span: 100%;
  }

  body.export-mode.sheet-export.sheet-open .app-sheet:not(.app-sheet--help) {
    transform: none;
  }

  body.export-mode.sheet-export .export-gallery.sheet-panel[data-sheet="export"] {
    min-height: 0;
  }

  .export-gallery {
    width: 100%;
  }

  .export-gallery-header {
    padding: 6px 8px 2px 12px;
  }

  .export-gallery-exit,
  .export-snapshot-dialog-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .export-work-mode-bar {
    margin: 2px 10px 8px;
    padding: 3px;
  }

  .export-work-mode-btn {
    padding: 12px 8px;
    min-height: 44px;
    font-size: 0.84rem;
    gap: 4px;
  }

  .export-gallery-actions {
    padding: 8px 10px;
  }

  .export-gallery-actions .btn,
  .export-gallery-footer .btn {
    min-height: 44px;
    padding: 12px 12px;
    font-size: 0.86rem;
  }

  .export-gallery-sections {
    padding: 6px 8px 10px;
    gap: 8px;
  }

  .export-gallery-card {
    gap: 8px;
    padding: 8px;
    min-height: 56px;
  }

  .export-gallery-card-delete,
  .export-gallery-card-edit {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  /* Framing toolbar: scroll instead of crush; keep 44px touch targets */
  body.export-mode .canvas-toolbar-dock {
    left: 4px;
    right: 4px;
  }

  body.export-mode .canvas-toolbar-dock .canvas-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    gap: 4px;
    justify-content: flex-start;
  }

  body.export-mode .canvas-toolbar-dock .canvas-toolbar::-webkit-scrollbar {
    display: none;
  }

  body.export-mode .canvas-toolbar-export,
  body.export-mode #canvas-toolbar-export {
    flex-shrink: 0;
    gap: 3px;
    max-width: none;
  }

  body.export-mode .canvas-toolbar-export .export-size-btn,
  body.export-mode .canvas-toolbar-export .export-nav-center-btn,
  body.export-mode #canvas-export-shapes .canvas-tb-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  body.export-mode .canvas-toolbar-export .canvas-export-select {
    height: 40px;
    min-height: 40px;
    max-width: 7.25rem;
    min-width: 4.75rem;
    font-size: 0.7rem;
    border-radius: 10px;
  }

  body.export-mode .canvas-toolbar-export .canvas-export-check {
    min-height: 40px;
    padding: 0 6px;
    font-size: 0.7rem;
  }

  body.export-mode .canvas-toolbar-export .canvas-export-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  body.export-mode #canvas-toolbar-core .canvas-tb-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Dialogs: full-width bottom sheet, larger hit targets, safe-area */
  .export-snapshot-dialog {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .export-snapshot-dialog-panel {
    width: 100%;
    max-width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 16px 16px 0 0;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .export-snapshot-dialog-header {
    padding: 10px 12px;
  }

  .export-snapshot-dialog-body {
    padding: 12px 14px 10px;
  }

  .export-snapshot-dialog-footer {
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  .export-snapshot-dialog-footer .btn,
  .export-field input,
  .export-field textarea,
  .export-field select {
    min-height: 44px;
    font-size: 1rem; /* avoid iOS input zoom */
  }

  .export-field textarea {
    min-height: 88px;
  }

  .export-snap-image-actions {
    gap: 8px;
  }

  .export-snap-image-actions .btn {
    min-height: 44px;
    padding: 10px 12px;
  }

  .export-snap-image-picker {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    max-height: min(36vh, 240px);
  }

  .export-bild-gallery-dialog .export-snapshot-dialog-panel {
    max-width: 100%;
  }

  .export-bild-gallery-dialog .export-snap-image-picker {
    max-height: min(46vh, 320px);
  }

  .export-busy-card {
    width: min(100% - 24px, 400px);
    min-width: 0;
    margin: 12px;
    padding: 24px 20px 18px;
  }

  .export-busy-card .btn {
    min-height: 44px;
    width: 100%;
  }

  /* Keep map controls clear of the bottom gallery */
  body.export-mode.sheet-open .split-pane--primary .map-controls--pane,
  body.export-mode.sheet-open .split-pane--primary .map-side-chrome {
    bottom: auto;
  }

  body.export-mode .export-frame-overlay {
    /* bottom pad applied via JS from sheet height */
    box-sizing: border-box;
  }

  /* List: gallery fills the viewport; no framing map mixed in. */
  body.export-mode.export-mobile-list.sheet-export .app-sheet:not(.app-sheet--help),
  body.export-mode.export-mobile-list.sheet-export.sheet-open .app-sheet:not(.app-sheet--help) {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    transform: none;
    --sheet-span: 100%;
    z-index: 28;
  }

  body.export-mode.export-mobile-list .export-gallery.sheet-panel[data-sheet="export"] {
    min-height: 100%;
  }

  body.export-mode.export-mobile-list .export-gallery .export-work-mode-bar {
    display: none !important;
  }

  body.export-mode.export-mobile-list .export-frame-overlay,
  body.export-mode.export-mobile-list .canvas-toolbar-dock,
  body.export-mode.export-mobile-list #canvas-toolbar-export {
    display: none !important;
  }

  /* Editor: hide gallery/sheet; frame visible with no bottom sheet pad. */
  body.export-mode.export-mobile-edit .app-sheet:not(.app-sheet--help),
  body.export-mode.export-mobile-edit .export-gallery {
    display: none !important;
  }

  body.export-mode.export-mobile-edit .export-frame-overlay {
    display: flex;
    padding-bottom: 0;
  }

  body.export-mode.export-mobile-edit .export-mobile-editor-chrome:not(.hidden) {
    display: flex;
  }

  .export-mobile-editor-chrome {
    position: absolute;
    top: 68px;
    left: 12px;
    right: 12px;
    max-width: none;
    z-index: 26;
    display: none;
    flex-direction: column;
    gap: 0;
    pointer-events: auto;
  }

  .export-mobile-editor-chrome.hidden {
    display: none !important;
  }

  /* Single menubar: back | Ausschnitt/Details | Speichern */
  .export-mobile-editor-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 14px;
    background: var(--chrome-bg);
    backdrop-filter: var(--chrome-blur);
    -webkit-backdrop-filter: var(--chrome-blur);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .export-mobile-editor-sep {
    width: 1px;
    align-self: stretch;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
  }

  .export-mobile-back-btn,
  #export-mobile-back.export-mobile-back-btn {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .export-mobile-back-btn .material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
  }

  .export-mobile-editor-bar .btn {
    min-height: 44px;
    flex-shrink: 0;
  }

  #export-mobile-save {
    margin-left: 0;
  }

  .export-mobile-back:focus-visible,
  #export-mobile-back:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  .export-mobile-editor-chrome .export-work-mode-bar {
    flex: 1;
    margin: 0;
    min-width: 0;
    padding: 3px;
    gap: 3px;
  }

  .export-mobile-editor-chrome .export-work-mode-btn {
    padding: 8px 6px;
    font-size: 0.8rem;
    gap: 4px;
  }

  .export-mobile-editor-chrome .export-work-mode-btn .material-symbols-outlined {
    font-size: 18px;
  }

  /* Ausschnitt: keep Karten-Auswahl above the crop dimmer, inside the frame (JS pins). */
  body.export-mode.export-mobile-edit.export-work-view .map-side-chrome {
    z-index: 22;
    pointer-events: none;
  }

  body.export-mode.export-mobile-edit.export-work-view .map-side-chrome .style-fan,
  body.export-mode.export-mobile-edit.export-work-view .map-side-chrome .style-fan * {
    pointer-events: auto;
  }
}

/* Per-Ausschnitt gallery image (Objekt documents) */
.export-snap-image-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.export-snap-image-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.export-snap-image-preview {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.export-snap-image-preview.is-empty::after {
  content: 'Kein Bild';
  font-size: 0.65rem;
  opacity: 0.55;
  text-align: center;
  padding: 0.25rem;
}
.export-snap-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.export-snap-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.export-snap-image-hint {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.75;
  line-height: 1.35;
}
.export-snap-image-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
  max-height: 220px;
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
}
.export-snap-image-picker.hidden {
  display: none;
}
.export-snap-image-picker-empty {
  grid-column: 1 / -1;
  margin: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.7;
}
.export-snap-image-pick-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  padding: 0.25rem;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.export-snap-image-pick-item.is-selected {
  outline: 2px solid #2563eb;
  border-color: transparent;
}
.export-snap-image-pick-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: rgba(0, 0, 0, 0.06);
}
.export-snap-image-pick-label {
  font-size: 0.7rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---- Export basemap «Bild» (style-fan tile + gallery dialog) ---- */
body:not(.export-mode) .style-fan-tile--export-bild {
  display: none !important;
}

body.export-mode .style-fan-tile--export-bild:not(.hidden) {
  display: inline-flex;
}

/* Active Bild tile: solid primary ring (still dashed empty slot look) */
body.export-mode .style-fan-tile--export-bild.active {
  border-style: solid;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.18);
}

.export-bild-gallery-dialog .export-snap-image-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
  max-height: min(50vh, 360px);
  overflow: auto;
  min-width: 0;
  width: 100%;
}

.export-bild-gallery-dialog .export-snapshot-dialog-panel {
  max-width: min(560px, 94vw);
}

/* Image background: hide layer chrome only (basemap fan stays for map/Bild). */
body.export-mode.export-bg-image #map-controls-primary.export-bg-hidden,
body.export-mode.export-bg-image #map-controls-mirror.export-bg-hidden,
.map-controls--pane.export-bg-hidden {
  display: none !important;
}

/* Details: style fan (incl. Bild) fully hidden — see body.export-work-detail .style-fan. */

