/* ── Custom fonts ────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'FotowortSubtitle';
  src: url('subtitle-font.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  /* === BRAND === */
  --brand: #6f2232;
  --brand-deep: #5a1c2a;
  --brand-tint: #f5ebec;

  /* === SURFACES === */
  --surface-page: #fbf8f5;
  --surface-card: #ffffff;
  --surface-muted: #f3ede7;

  /* === TEXT === */
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --text-faint: #b0a89e;

  /* === BORDERS === */
  --border-default: #ede5dc;
  --border-strong: #d8cfc4;

  /* === RADII === */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;

  /* === SPACING (4px base) === */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* === TYPOGRAPHY === */
  --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --type-caption:  11px / 16px var(--font-sans);
  --type-body-sm:  13px / 20px var(--font-sans);
  --type-body:     14px / 22px var(--font-sans);
  --type-body-md:  15px / 24px var(--font-sans);
  --type-heading:  18px / 26px var(--font-sans);
  --type-display:  22px / 28px var(--font-serif);

  /* === SYSTEM === */
  --transition: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --control-width: 425px;
  --sheet-radius: 20px;

  /* === TOOLTIP === */
  --tooltip-bg: #2c2018;
  --tooltip-text: #ffffff;
  --tooltip-radius: 8px;
  --tooltip-padding: 10px 14px;
  --tooltip-font-size: 13px;
  --tooltip-line-height: 1.45;
  --tooltip-max-width: 260px;
  --tooltip-arrow-size: 8px;
  --tooltip-shadow: 0 4px 16px rgba(44, 32, 24, 0.18);
  --tooltip-z: 1000;

  /* === FOOTER === */
  --footer-pill-bg: #fde7ec;
  --footer-pill-text: var(--brand);
  --footer-stock-dot: #22c55e;
  --footer-border: 1px solid rgba(111, 34, 50, 0.08);
  --footer-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);

  /* === MATERIAL DESCRIPTION CARD === */
  --desc-card-bg: #ffffff;
  --desc-card-border: #ebe4de;
  --desc-card-accent: var(--brand);
  --desc-card-radius: 6px;
  --desc-card-padding: 10px 12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-card);
}
.screen.hidden { display: none !important; }

.screen-overlay {
  z-index: 100;
  justify-content: center;
  align-items: center;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
}

/* ── Header (word selection only) ────────────────────────────────────────── */
.app-header {
  padding: 20px 20px 0;
  padding-top: calc(20px + var(--safe-top));
  flex-shrink: 0;
}
.logo {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

/* ── Word Selection Screen ───────────────────────────────────────────────── */
.word-selection-content {
  flex: 1;
  padding: var(--space-xl) 20px;
  padding-bottom: calc(var(--space-xl) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.word-selection-title {
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.word-chip {
  padding: var(--space-md) var(--space-sm);
  border: 0.5px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  font: var(--type-body-md);
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.word-chip:active, .word-chip.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.word-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  color: var(--text-muted);
  font: var(--type-body-sm);
}
.word-divider::before, .word-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.custom-word-input-wrap { position: relative; }
.custom-word-input-wrap input {
  width: 100%;
  padding: 14px 48px 14px var(--space-lg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface-card);
  color: var(--text-primary);
}
.custom-word-input-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.custom-word-input-wrap input::placeholder { letter-spacing: 0; font-weight: 400; color: #bbb; }

.char-count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font: var(--type-caption);
  font-weight: 400;
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font: var(--type-body-md);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-large { padding: var(--space-lg); font-size: 17px; }

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 13px var(--space-lg);
  background: var(--surface-muted);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font: var(--type-body);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: var(--border-default); }

.btn-text {
  background: none;
  border: none;
  font: var(--type-body);
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs) 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-text.btn-done { color: var(--text-primary); font-weight: 500; font-size: 15px; }

/* ── Editor Layout (two-column) ──────────────────────────────────────────── */
.editor-layout {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

/* ── Preview Panel (right on desktop, top on mobile) ─────────────────────── */
.preview-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-page);
  padding: var(--space-md);
  min-width: 0;
  position: relative;
}


#konva-container {
  display: block;
  line-height: 0;
}
#konva-container canvas {
  display: block;
  touch-action: none;
}

/* ── Canvas Paper ────────────────────────────────────────────────────────── */
.canvas-paper {
  background: var(--surface-card);
  box-shadow: 0 8px 60px rgba(111,34,50,0.18), 0 2px 8px rgba(0,0,0,0.10);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ── Control Panel (left on desktop, bottom on mobile) ───────────────────── */
/* ── Desktop-only sidebar header ─────────────────────────────────────────── */
.control-panel-header {
  flex-shrink: 0;
  padding: calc(20px + var(--safe-top)) 20px var(--space-md);
  border-bottom: 1px solid var(--border-default);
}
.control-panel-header h1 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin: 0;
}

/* Sidebar column — outer shell, NO overflow so position:fixed children escape on iOS */
.editor-sidebar {
  width: var(--control-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-default);
  background: var(--surface-card);
}

/* Scrollable inner area — panels live here */
.control-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Panels inside the control panel */
.panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#panel-editor {
  overflow-y: auto;
  gap: 20px;
  padding: 20px;
  padding-top: 20px;
  padding-bottom: 0;
}

#panel-configure {
  /* internal scroll via .cfg-body; header / summary / footer are fixed */
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.control-section-label {
  display: flex;
  align-items: center;
  font: var(--type-body-sm);
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

/* ── Per-letter thumbnails ────────────────────────────────────────────────── */
.letter-thumbs {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.letter-thumb {
  flex: 1;
  min-width: 48px;
  max-width: 80px;
  aspect-ratio: 1;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--surface-muted);
  transition: border-color var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.letter-thumb:active { transform: scale(0.94); }
.letter-thumb.filled { border-color: var(--brand); }
.letter-thumb.selected-letter { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

.letter-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.letter-thumb-char {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 400;
  color: var(--border-strong);
  letter-spacing: 0;
}
.letter-thumb.filled .letter-thumb-char {
  position: absolute;
  bottom: 2px;
  right: 5px;
  inset: auto;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.file-input-hidden { display: none; }

/* ── Photo Section (drop zone + gallery) ────────────────────────────────── */
.photo-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: var(--space-sm);
}

.drop-zone {
  border: 1.5px dashed var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-xl) var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface-muted);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--brand);
  background: var(--brand-tint);
}
/* Mobile: brand style is the default (no hover needed) */
@media (hover: none) {
  .drop-zone {
    border-color: var(--brand);
    background: var(--brand-tint);
  }
  .drop-zone .drop-zone-icon { color: var(--brand); }
}
.drop-zone-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  transition: color var(--transition);
}
@media (hover: hover) {
  .drop-zone:hover .drop-zone-icon { color: var(--brand); }
}
.drop-zone-title {
  font: var(--type-body);
  font-weight: 500;
  color: var(--text-primary);
}
.drop-zone-hint {
  font: var(--type-body-sm);
  color: var(--text-secondary);
}
.drop-zone-browse {
  background: none;
  border: none;
  font: var(--type-body-sm);
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.drop-zone-sub {
  font: var(--type-caption);
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Photo Gallery */
.photo-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.photo-section .control-section-label {
  margin-bottom: var(--space-xs);
}
.btn-text-sm {
  background: none;
  border: none;
  font: var(--type-body-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}
.btn-text-sm:hover { color: var(--text-primary); }

.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
}
.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: grab;
  border: 2px solid transparent;
  transition: border-color var(--transition), transform var(--transition);
}
/* Only scale on devices that truly support hover — prevents iOS double-tap bug */
@media (hover: hover) {
  .gallery-item:hover img { transform: scale(1.06); }
}
.gallery-item.drag-source { opacity: 0.5; }
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: transform 0.2s ease;
}
.gallery-badge {
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
  pointer-events: none;
}
.gallery-delete {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.60);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}
@media (hover: hover) {
  .gallery-item:hover .gallery-delete { opacity: 1; }
}
/* On touch devices always show a subtle delete button — no hover to reveal it */
@media (hover: none) {
  .gallery-delete { opacity: 0.75; }
}

/* letter-thumb drop target */
.letter-thumb.drop-target {
  border-color: var(--brand);
  background: var(--brand-tint);
  transform: scale(1.05);
}

/* ── Subtitle Inline Editor ──────────────────────────────────────────────── */
.subtitle-editor-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}
.subtitle-editor-section .control-section-label {
  margin-bottom: 2px;
}
.subtitle-input-wrap {
  position: relative;
}
.subtitle-input-wrap textarea {
  width: 100%;
  padding: var(--space-md) 48px var(--space-md) 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-style: italic;
  font-family: Georgia, serif;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface-card);
  color: var(--text-primary);
  resize: none;
  overflow: hidden;
  line-height: 1.5;
}
.subtitle-input-wrap textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

.subtitle-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.suggestion-chip {
  padding: var(--space-xs) var(--space-md);
  border: 0.5px solid var(--border-default);
  border-radius: var(--radius-pill);
  font: var(--type-body-sm);
  font-style: italic;
  font-family: Georgia, serif;
  background: var(--surface-card);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  color: var(--text-primary);
}
.suggestion-chip:active, .suggestion-chip:hover { background: var(--surface-muted); }

/* ── Letter Edit Toolbar (floating pill over canvas) ─────────────────────── */
.letter-edit-toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  background: var(--surface-card);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.08);
  white-space: nowrap;
}
.edit-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-width: 46px;
  flex-shrink: 0;
}
.edit-tool-btn:hover, .edit-tool-btn:active { background: var(--surface-muted); }
.edit-tool-btn svg { width: 24px; height: 24px; flex-shrink: 0; stroke-width: 1.5; }
.edit-tool-danger { color: #e53e3e; }

/* Nav arrows — slightly narrower padding */
.edit-tool-nav { min-width: 38px; padding: 6px 6px; }

.edit-tool-divider {
  width: 1px;
  height: 34px;
  background: var(--border-default);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Empty-letter toolbar: hide all edit buttons, show only nav arrows */
.letter-edit-toolbar.edit-toolbar-empty .edit-tool-btn:not(.edit-tool-nav) { display: none !important; }
.letter-edit-toolbar.edit-toolbar-empty .edit-tool-divider { display: none !important; }

/* ── Rotation slider (extension below toolbar) ───────────────────────────── */
.rotation-slider-wrap {
  position: absolute;
  bottom: 81px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.08);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  min-width: min(280px, 80vw);
}
.rotation-slider-label {
  font: var(--type-caption);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.rotation-slider {
  flex: 1;
  min-width: 120px;
  cursor: pointer;
}
.rotation-slider-value {
  font: var(--type-caption);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Zoom-back button (mobile, top-left of preview panel) ────────────────── */
.edit-zoom-back {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px 7px 10px;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font: var(--type-body-sm);
  font-weight: 500;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  -webkit-tap-highlight-color: transparent;
}
.edit-zoom-back svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.5; }
.edit-zoom-back:active { opacity: 0.75; }

/* ── Zoom-mode top-right controls (undo/redo + zoom step) ───────────────── */
.zoom-top-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.zoom-top-controls.hidden { display: none; }
.zoom-top-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease, opacity 0.1s ease;
}
.zoom-top-btn:hover:not(:disabled) { background: var(--surface-muted); }
.zoom-top-btn:active:not(:disabled) { opacity: 0.65; }
.zoom-top-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.zoom-top-btn svg { width: 16px; height: 16px; stroke-width: 2; pointer-events: none; }
.zoom-top-sep {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 3px;
  flex-shrink: 0;
}

/* ── Subtitle canvas inline-edit overlay (desktop) ──────────────────────── */
.subtitle-canvas-input {
  position: absolute;
  z-index: 20;
  outline: none;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-xs);
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  text-align: center;
  color: var(--text-primary);
  cursor: text;
  min-width: 40px;
  min-height: 1em;
  white-space: pre-wrap;
  word-break: break-word;
}


/* Pulsing "Auf Lager" dot */
.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--footer-stock-dot);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  50%       { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}

/* ── Bottom Sheets ───────────────────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
  opacity: 0;
  transition: opacity var(--transition);
}
.sheet-backdrop.visible { opacity: 1; }
.sheet-backdrop.hidden { display: none !important; }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 70;
  background: var(--surface-card);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  padding-bottom: max(20px, var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet.hidden { display: none !important; }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-default);
  border-radius: 2px;
  margin: var(--space-md) auto var(--space-lg);
}
.sheet-content { padding: 0 20px; }
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.sheet-title { font: var(--type-body-md); font-weight: 500; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.sheet-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font: var(--type-caption);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.sheet-action-btn:active { background: var(--border-default); }
.sheet-action-btn svg { width: 22px; height: 22px; }

.sheet-slider-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.slider-label {
  font: var(--type-body-sm);
  font-weight: 500;
  color: var(--text-secondary);
  width: 52px;
  flex-shrink: 0;
}
.slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-default);
  border-radius: 2px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.slider-value {
  font: var(--type-body-sm);
  font-weight: 500;
  color: var(--text-primary);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Loading Screen ──────────────────────────────────────────────────────── */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-default);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-message { font: var(--type-body-md); color: var(--text-secondary); }

/* ── Upload Progress Overlay ─────────────────────────────────────────────── */
.upload-progress-area {
  position: fixed;
  bottom: 24px;
  left: var(--space-lg);
  right: calc(var(--control-width) + var(--space-lg));
  z-index: 50;
  pointer-events: none;
}
.upload-progress-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.upload-item {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.upload-item-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-muted);
  flex-shrink: 0;
}
.upload-item-info { flex: 1; min-width: 0; }
.upload-item-name {
  font: var(--type-body-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-ring-wrap {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  position: relative;
}
.upload-ring-wrap svg { transform: rotate(-90deg); }
.upload-ring-bg { fill: none; stroke: var(--border-default); stroke-width: 3; }
.upload-ring-fill { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 200ms ease; }
.upload-ring-check { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; }
.upload-ring-check.visible { display: flex; }
.upload-ring-check svg { width: 16px; height: 16px; color: var(--brand); }
.upload-item.done .upload-ring-fill { stroke: #22c55e; }
.upload-item.error .upload-ring-fill { stroke: #ef4444; }

/* ── Editor Word Input (top of control panel) ────────────────────────────── */
.editor-word-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.editor-word-section .control-section-label {
  margin-bottom: 2px;
}
.editor-word-input-wrap {
  position: relative;
}
.editor-word-input {
  width: 100%;
  padding: var(--space-md) 48px var(--space-md) 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface-card);
  color: var(--text-primary);
}
.editor-word-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.editor-word-input::placeholder {
  font-weight: 400;
  letter-spacing: 0;
  color: #ccc;
  font-size: 15px;
}
.editor-word-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  max-height: 36px;
  overflow: hidden;
  transition: max-height 250ms ease-out;
}
.word-suggestion-trigger {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font: var(--type-caption);
  font-weight: 500;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--transition), border-style var(--transition);
}
.word-suggestion-trigger.is-expanded {
  border-style: solid;
  border-color: var(--brand);
}
.word-suggestion-chip {
  padding: 5px 11px;
  border: 0.5px solid var(--border-default);
  border-radius: var(--radius-pill);
  font: var(--type-caption);
  font-weight: 500;
  letter-spacing: 0.5px;
  background: var(--surface-card);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  color: var(--text-primary);
}
.word-suggestion-chip:hover,
.word-suggestion-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ── Progress label (shown below gallery when photos uploaded) ───────────── */
.progress-label-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  font: var(--type-caption);
  font-weight: 500;
  color: var(--text-muted);
  margin-top: var(--space-xs);
  transition: color 200ms ease;
}
.progress-label-inline.progress-done { color: #2d8659; }
.progress-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Upload auto-hint ────────────────────────────────────────────────────── */
.upload-auto-hint {
  font: var(--type-caption);
  font-weight: 400;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-xs);
}

/* ── Gallery empty add tile ──────────────────────────────────────────────── */
.gallery-item-add {
  background: var(--surface-muted);
  border: 1px dashed var(--border-default) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.gallery-item-add:hover,
.gallery-item-add.drag-over {
  border-color: var(--brand) !important;
  background: var(--brand-tint);
}
@media (hover: none) {
  .gallery-item-add {
    border-color: var(--brand) !important;
    background: var(--brand-tint);
  }
  .gallery-item-add .gallery-add-plus { color: var(--brand); }
}
.gallery-add-plus {
  font-size: 20px;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1;
}

/* ── Configure Panel (inside sidebar) ────────────────────────────────────── */

.cfg-summary {
  padding: var(--space-lg) 20px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.cfg-summary-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}
.cfg-summary-label {
  font: var(--type-body-sm);
  color: var(--text-secondary);
  min-width: 80px;
}
.cfg-summary-value {
  font: var(--type-body);
  font-weight: 500;
  flex: 1;
}
.cfg-summary-muted { font-weight: 400; color: var(--text-secondary); }
.cfg-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  padding: var(--space-xs);
  line-height: 1;
}

.cfg-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.cfg-selector-group { display: flex; flex-direction: column; gap: var(--space-sm); }
.cfg-selector-label {
  font: var(--type-body-sm);
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
/* Reset transform/tracking on inline value so "40x30 cm" stays normal case */
.cfg-selector-label strong,
.cfg-selector-label .size-guide-btn {
  text-transform: none;
  letter-spacing: 0;
}
.cfg-selector-label strong { color: var(--text-primary); font-weight: 500; font-size: 13px; }

.cfg-selector-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.cfg-pill {
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  font: var(--type-body);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  color: var(--text-primary);
}
.cfg-pill.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}
.cfg-pill:hover:not(.active) { border-color: var(--border-strong); }

.cfg-addon-row {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--border-default);
}
.cfg-addon-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font: var(--type-body-md);
  flex: 1;
}
.cfg-addon-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
}


/* ── Step progress bar (desktop: top of sidebar; mobile: fixed top of screen) ── */
.progress-steps {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: calc(var(--space-md) + var(--safe-top)) 20px var(--space-md);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.ps-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: var(--type-caption);
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: default;
}
button.ps-step { cursor: pointer; }
button.ps-step:hover { color: var(--text-secondary); }
.ps-step.active { color: var(--text-primary); }
.ps-step.done   { color: var(--text-secondary); }

/* Number circle */
.ps-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 10px;
  font-weight: 500;
  flex-shrink: 0;
}
.ps-step.active .ps-num {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}
.ps-step.done .ps-num {
  background: var(--brand);
  color: transparent; /* hide digit */
  border-color: var(--brand);
  font-size: 0;
}
.ps-step.done .ps-num::before {
  content: '✓';
  font-size: 10px;
  color: white;
}
.ps-sep { color: var(--border-strong); font-size: 10px; user-select: none; }

/* ── Shared price elements ───────────────────────────────────────────────── */
.pf-prices {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.pf-compare {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: line-through;
}
.pf-current {
  font-size: 22px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
/* ── Footer — unified BEM (both steps) ───────────────────────────────────── */
.cfg-footer {
  flex-shrink: 0;
  border-top: var(--footer-border);
  box-shadow: var(--footer-shadow);
  background: var(--surface-card);
  padding: 14px var(--space-lg) var(--space-lg);
  padding-bottom: max(var(--space-lg), var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Step 1: push footer to bottom of panel; escape horizontal panel padding */
.cfg-footer--step-1 {
  margin-top: auto;
  margin-left: -20px;
  margin-right: -20px;
}

/* Step 2 title (product name + size, truncating) */
.cfg-footer__title {
  font: var(--type-body-md);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row: delivery info left, price right */
.cfg-footer__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

/* Delivery line */
.cfg-footer__delivery {
  display: flex;
  align-items: center;
  gap: 6px;
  font: var(--type-body-sm);
  color: var(--text-secondary);
}

/* Button row */
.cfg-footer__actions {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

/* Primary CTA */
.cfg-footer__cta {
  flex: 1;
  min-height: 48px;
  padding: 14px;
  background: var(--brand);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}
.cfg-footer__cta:hover    { filter: brightness(1.08); }
.cfg-footer__cta:active   { transform: scale(0.99); }
.cfg-footer__cta:disabled { opacity: 0.5; cursor: not-allowed; }

/* Back button (Step 2 only) */
.cfg-back-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cfg-back-btn svg { width: 20px; height: 20px; stroke-width: 1.5; }


/* ── Mobile layout ───────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  /* column-reverse: canvas on top, sidebar at bottom — without changing DOM order */
  .editor-layout {
    flex-direction: column-reverse;
    height: 100%;
  }

  /* Progress bar: escape control-panel flow, pin to top of viewport */
  .progress-steps {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: rgba(251, 248, 245, 0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: calc(var(--space-sm) + var(--safe-top)) 20px var(--space-sm);
    justify-content: center;
    border-radius: 0;
  }

  /* Preview panel: fills remaining space above control panel; canvas centered within */
  .preview-panel {
    flex: 1;
    min-height: calc(50px + var(--safe-top) + (100vw - 16px) * 0.707);
    padding: calc(42px + var(--safe-top)) var(--space-sm) var(--space-sm);
    overflow: hidden;
    align-items: center;
    justify-content: center;
  }

  /* Canvas paper: full width, height comes from the Konva canvas inside */
  .canvas-paper {
    width: 100%;
    box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  }

  /* Sidebar: natural content height, bounded so canvas is never covered */
  /* NO overflow here — lets position:fixed progress bar escape to viewport on iOS Safari */
  .editor-sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: calc(100svh - var(--safe-top) - 50px - (100vw - 16px) * 0.707);
    border-right: none;
    border-top: 1px solid var(--border-default);
  }

  /* Control panel: scrollable inner area within the sidebar */
  .control-panel {
    overflow-y: auto;
    flex: 1;
  }

  /* Panels: natural height — control-panel is the scroll container */
  .panel { flex: none; }

  /* Desktop header hidden on mobile */
  .control-panel-header { display: none; }

  /* Editor panel: padding-bottom clears the fixed footer */
  #panel-editor {
    padding: var(--space-md) var(--space-lg);
    padding-bottom: calc(140px + var(--safe-bottom));
    gap: var(--space-md);
  }

  /* Configure: cfg-summary hidden; body flows naturally; control-panel scrolls */
  .cfg-summary { display: none; }
  #panel-configure { padding-bottom: calc(140px + var(--safe-bottom)); }
  .cfg-body { overflow-y: visible; flex: none; gap: var(--space-md); padding: var(--space-md) var(--space-lg); }

  /* Both steps — compact labels/fonts on mobile */
  .control-section-label { font-size: 11px; }
  .cfg-selector-label { font-size: 11px; }
  .cfg-selector-group { gap: var(--space-xs); }
  .cfg-pill { font-size: 12px; padding: 6px 12px; }
  .editor-word-input { font-size: 13px; }
  .subtitle-input-wrap textarea { font-size: 13px; }
  .pf-current { font-size: 20px; }

  /* Both footers: fixed at viewport bottom; hidden via panel's display:none on other step */
  .cfg-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: var(--space-md) var(--space-lg);
    padding-bottom: max(var(--space-md), var(--safe-bottom));
  }


  .letter-thumb { max-width: none; }
  .photo-gallery-grid { grid-template-columns: repeat(5, 1fr); }

  /* Toolbar stays at bottom-center; buttons sized for touch */
  .letter-edit-toolbar { padding: 6px 10px; bottom: 14px; }
  .edit-tool-btn { min-width: 40px; padding: 6px 7px; }
  .edit-tool-btn svg { width: 22px; height: 22px; }
  .edit-tool-nav { min-width: 35px; padding: 6px 5px; }
  .rotation-slider-wrap { bottom: 74px; }

  /* Zurück button: clear the fixed progress bar (safe-top + ~40px bar height + 8px gap) */
  .edit-zoom-back { top: calc(var(--safe-top) + 48px); }
  .zoom-top-controls { top: calc(var(--safe-top) + 48px); }

  .upload-progress-area { left: var(--space-sm); right: var(--space-sm); bottom: var(--space-sm); }

  /* ── Zoom-mode: letter-editing view ─────────────────────────────────────── */
  .editor-layout.zoom-mode .preview-panel {
    padding: 0;
    background: var(--surface-card);
    flex: 1;
    min-height: 0;
  }
  .editor-layout.zoom-mode .canvas-paper {
    border-radius: 0;
    box-shadow: none;
    background: var(--surface-card);
  }
  /* ── Zoom-mode: sidebar collapses to gallery strip only ── */
  .editor-layout.zoom-mode .editor-sidebar {
    max-height: none !important;
  }
  /* control-panel must NOT clip: photo-gallery-grid is the scroll container */
  .editor-layout.zoom-mode .control-panel {
    overflow-y: visible !important;
  }
  .editor-layout.zoom-mode .panel {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
  }
  .editor-layout.zoom-mode #panel-editor {
    padding: 0 !important;
    gap: 0 !important;
    overflow: visible;
  }
  /* Hide everything except the gallery in the control panel */
  .editor-layout.zoom-mode #panel-editor > *:not(.photo-section) {
    display: none !important;
  }
  .editor-layout.zoom-mode .drop-zone        { display: none !important; }
  .editor-layout.zoom-mode .upload-auto-hint { display: none !important; }
  .editor-layout.zoom-mode .photo-section {
    padding: var(--space-sm) 14px 10px;
    overflow-y: visible;
  }
  .editor-layout.zoom-mode .photo-gallery { display: flex !important; }
  /* Cap at 2 rows — explicit row height prevents overlay when overflow creates scroll container */
  /* Each cell = (100vw − 2×14px padding − 4×4px gaps) / 5 cols = (100vw − 44px) / 5 */
  .editor-layout.zoom-mode .photo-gallery-grid {
    grid-auto-rows: calc((100vw - 44px) / 5);
    max-height: calc(2 * (100vw - 44px) / 5 + var(--space-xs));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* In zoom mode while configure panel is showing, swap back to editor panel */
  .editor-layout.zoom-mode #panel-configure { display: none !important; }
  .editor-layout.zoom-mode #panel-editor    { display: flex !important; }

  /* Extend photo section label in zoom mode */
  .editor-layout.zoom-mode .photo-section .control-section-label::after {
    content: ' – klicken zum hinzufügen';
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
    font-size: 10px;
  }
}

/* ── First-upload hint bar (floating pill over canvas) ───────────────────── */
.hint-bar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.08);
  white-space: nowrap;
  pointer-events: all;
  animation: hint-in 300ms ease-out;
}
.hint-bar.hint-fading {
  animation: none;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 300ms ease;
}
.hint-bar-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hint-bar-text strong {
  font: var(--type-body-sm);
  font-weight: 600;
  color: var(--text-primary);
}
.hint-bar-text span {
  font: var(--type-caption);
  color: var(--text-secondary);
}
.hint-bar-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  margin-left: 2px;
}
.hint-bar-close svg { width: 14px; height: 14px; }
.hint-bar-close:hover { color: var(--text-primary); }
@keyframes hint-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Fertig button (last letter in mobile zoom) ─────────────────────────── */
/* nav-fertig-svg hidden by default; shown when .edit-tool-fertig active */
.nav-fertig-svg { display: none; }
.edit-tool-btn.edit-tool-fertig { color: var(--brand); }
.edit-tool-btn.edit-tool-fertig .nav-arrow-svg { display: none; }
.edit-tool-btn.edit-tool-fertig .nav-fertig-svg { display: block; }

/* ── Size guide help link ───────────────────────────────────────────────── */
.size-guide-btn {
  background: none;
  border: none;
  padding: 0;
  font: var(--type-body-sm);
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.size-guide-btn:hover { opacity: 0.75; }

/* ── Size guide lightbox ────────────────────────────────────────────────── */
.size-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.size-guide-overlay.hidden { display: none; }
.size-guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.size-guide-modal {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  max-width: min(640px, 92vw);
  max-height: 88vh;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  animation: sg-in 0.2s ease;
}
@keyframes sg-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.size-guide-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 88vh;
  object-fit: contain;
}
.size-guide-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.size-guide-close:hover { background: #fff; }
.size-guide-close svg { width: 16px; height: 16px; stroke-width: 1.5; }

/* ── Undo / Redo bar ────────────────────────────────────────────────────── */

/* ── Help icon (.help-icon) ─────────────────────────────────────────────── */
/* Just the Lucide 'info' icon — no circle wrapper, the icon already is one  */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  margin-left: 4px;
  background: none;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.help-icon:hover,
.help-icon.is-active { color: var(--brand); }
.help-icon:active { transform: scale(0.92); }
.help-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.help-icon svg { width: 15px; height: 15px; stroke-width: 1.5; pointer-events: none; }

/* ── Tooltip popover ────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  z-index: var(--tooltip-z);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  padding: var(--tooltip-padding);
  border-radius: var(--tooltip-radius);
  box-shadow: var(--tooltip-shadow);
  font-size: var(--tooltip-font-size);
  line-height: var(--tooltip-line-height);
  font-weight: 400;
  text-align: left;
  max-width: var(--tooltip-max-width);
  width: max-content;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.tooltip::after {
  content: "";
  position: absolute;
  width: var(--tooltip-arrow-size);
  height: var(--tooltip-arrow-size);
  background: var(--tooltip-bg);
  transform: rotate(45deg);
}
.tooltip--top::after {
  bottom: calc(var(--tooltip-arrow-size) / -2);
  left: 50%;
  margin-left: calc(var(--tooltip-arrow-size) / -2);
}
.tooltip--bottom::after {
  top: calc(var(--tooltip-arrow-size) / -2);
  left: 50%;
  margin-left: calc(var(--tooltip-arrow-size) / -2);
}
@media (max-width: 680px) {
  .tooltip {
    --tooltip-font-size: 14px;
    --tooltip-max-width: calc(100vw - 32px);
    --tooltip-padding: 12px 14px;
  }
}

/* ── Material description card ──────────────────────────────────────────── */
.material-description {
  margin-top: 0;
  padding: var(--desc-card-padding);
  background: var(--desc-card-bg);
  border: 1px solid var(--desc-card-border);
  border-left: 3px solid var(--desc-card-accent);
  border-radius: var(--desc-card-radius);
  font-size: 13px;
  line-height: 1.5;
  color: #444;
  transition: opacity 0.18s ease;
  min-height: 44px;
}
.material-description.is-fading { opacity: 0.4; }
.material-description__title {
  display: block;
  color: var(--desc-card-accent);
  font-weight: 500;
  margin-bottom: 2px;
}
.material-description__body { display: block; color: #444; }
@media (max-width: 680px) {
  .material-description { font-size: 12px; padding: 8px 12px; line-height: 1.4; }
}

/* ── Canvas area (wraps action bar + canvas paper) ──────────────────────── */
.canvas-area {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ── Canvas action bar ───────────────────────────────────────────────────── */
/* Desktop: sits above canvas in normal flow, buttons aligned right          */
/* Mobile:  overlaid on canvas via position:absolute                         */
.canvas-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-bottom: 8px;
  z-index: 10;
}
.editor-layout.zoom-mode .canvas-actions { display: none; }

@media (max-width: 680px) {
  .canvas-area { position: relative; }
  .canvas-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    padding-bottom: 0;
  }
}
.canvas-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.88);
  color: var(--text-primary);
  font: var(--type-body-sm);
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.canvas-action-btn:hover { background: rgba(255,255,255,0.98); }
.canvas-action-btn svg { width: 14px; height: 14px; stroke-width: 1.5; flex-shrink: 0; }
.canvas-action-btn:disabled { opacity: 0.3; cursor: default; }
.canvas-action-btn:disabled:hover { background: rgba(255,255,255,0.88); }
/* Icon-only buttons: no label, fixed width */
.canvas-action-icon-only { padding: 0; width: 30px; justify-content: center; }

/* ── Fullscreen preview overlay ─────────────────────────────────────────── */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.fullscreen-overlay.hidden { display: none; }
.fullscreen-img {
  display: block;
  max-width: 94vw;
  max-height: 94vh;
  object-fit: contain;
  border-radius: 4px;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.fullscreen-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.fullscreen-close:hover { background: rgba(255,255,255,0.25); }
.fullscreen-close svg { width: 18px; height: 18px; stroke-width: 1.5; }

/* ── Info / Hilfe modal ─────────────────────────────────────────────────── */
.info-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.info-overlay.hidden { display: none; }
.info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.info-modal {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 14px;
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  animation: sg-in 0.2s ease;
}
.info-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-muted);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.info-close:hover { background: var(--border-default); }
.info-close svg { width: 16px; height: 16px; stroke-width: 1.5; }
.info-modal-content { padding: 28px 24px 24px; }
.info-section + .info-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-default); }
.info-section-title {
  font: var(--type-body-md);
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 12px;
}
.info-steps, .info-tips {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 20px;
}
.info-steps li, .info-tips li {
  font: var(--type-body-sm);
  color: var(--text-primary);
  line-height: 1.55;
}
.info-steps li strong { color: var(--text-primary); }

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tooltip, .material-description, .help-icon { transition: none; }
  .tooltip { transform: none; }
}

/* ── Legal links ─────────────────────────────────────────────────────────── */
.legal-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.legal-links a {
  font-size: 9px;
  color: var(--text-faint);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.legal-links a:hover { text-decoration: underline; }

/* Desktop: absolute bottom-right of the preview panel */
.legal-links--canvas {
  position: absolute;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: 5;
}

.legal-links--panel { display: none; }

@media (max-width: 680px) {
  .legal-links--canvas { display: none; }
}
