/* ── 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-black: #1a1a1a;
  --brand-grey:  #6b6b6b;
  --brand-light: #f5f5f5;
  --brand-border: #e0e0e0;
  --radius: 12px;
  --sheet-radius: 20px;
  --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;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  color: var(--brand-black);
  background: #fff;
  -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: #fff;
}
.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: 700;
  letter-spacing: -0.5px;
  color: var(--brand-black);
}

/* ── Word Selection Screen ───────────────────────────────────────────────── */
.word-selection-content {
  flex: 1;
  padding: 24px 20px;
  padding-bottom: calc(24px + 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: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

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

.word-chip {
  padding: 12px 8px;
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  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-black);
  border-color: var(--brand-black);
  color: #fff;
}

.word-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--brand-grey);
  font-size: 13px;
}
.word-divider::before, .word-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--brand-border);
}

.custom-word-input-wrap { position: relative; }
.custom-word-input-wrap input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  outline: none;
  transition: border-color var(--transition);
  background: #fff;
  color: var(--brand-black);
}
.custom-word-input-wrap input:focus { border-color: var(--brand-black); }
.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-size: 12px;
  color: var(--brand-grey);
  pointer-events: none;
}

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

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  background: var(--brand-light);
  color: var(--brand-black);
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: var(--brand-border); }

.btn-text {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--brand-grey);
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-text.btn-done { color: var(--brand-black); font-weight: 600; 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: #f0f0f0;
  padding: 12px;
  min-width: 0;
  position: relative;  /* anchor for floating toolbar + zoom-back button */
}


#konva-container {
  /* Width/height are set by Konva dynamically; we let it control its own size */
  display: block;
  line-height: 0;
}
#konva-container canvas {
  display: block;
  touch-action: none;
  /* No CSS scaling — Konva rebuilds at the correct native size via ResizeObserver */
}

/* ── Canvas Paper ────────────────────────────────────────────────────────── */
.canvas-paper {
  background: #fff;
  box-shadow: 0 4px 40px rgba(0,0,0,0.13), 0 1px 4px rgba(0,0,0,0.06);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ── Control Panel (left on desktop, bottom on mobile) ───────────────────── */
.control-panel {
  width: var(--control-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;           /* panels handle their own scroll */
  border-right: 1px solid var(--brand-border);
  background: #fff;
}

/* 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: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}

#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;
}
.progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-grey);
}
.progress-bar-track {
  height: 2px;
  background: var(--brand-border);
  flex-shrink: 0;
  margin-top: -12px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--brand-black);
  transition: width 400ms ease;
}

.control-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-grey);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: -12px;
}

/* ── Per-letter thumbnails ────────────────────────────────────────────────── */
.letter-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.letter-thumb {
  flex: 1;
  min-width: 48px;
  max-width: 80px;
  aspect-ratio: 1;
  border: 1.5px solid var(--brand-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--brand-light);
  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-black); }
.letter-thumb.selected-letter { border-color: var(--brand-black); box-shadow: 0 0 0 2px var(--brand-black); }

.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: 700;
  color: #ccc;
  letter-spacing: 0;
}
.letter-thumb.filled .letter-thumb-char {
  position: absolute;
  bottom: 2px;
  right: 5px;
  inset: auto;
  font-size: 10px;
  font-weight: 700;
  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;
}

.drop-zone {
  border: 2px dashed var(--brand-border);
  border-radius: var(--radius);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--brand-light);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--brand-black);
  background: #f0f0f0;
}
.drop-zone-icon {
  width: 40px;
  height: 40px;
  color: var(--brand-grey);
  margin-bottom: 4px;
}
.drop-zone-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-black);
}
.drop-zone-hint {
  font-size: 13px;
  color: var(--brand-grey);
}
.drop-zone-browse {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--brand-black);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.drop-zone-sub {
  font-size: 11px;
  color: var(--brand-grey);
  margin-top: 2px;
}

/* Photo Gallery */
.photo-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.photo-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-text-sm {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-grey);
  cursor: pointer;
  padding: 0;
}
.btn-text-sm:hover { color: var(--brand-black); }

.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  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
   (first tap triggers :hover, consuming the tap; click fires only on second tap) */
@media (hover: hover) {
  .gallery-item:hover { transform: scale(1.03); }
}
.gallery-item.drag-source { opacity: 0.5; }
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.gallery-badge {
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 4px;
  border-radius: 4px;
  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-black);
  background: #e8e8e8;
  transform: scale(1.05);
}

/* ── Subtitle Inline Editor ──────────────────────────────────────────────── */
.subtitle-editor-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.subtitle-input-wrap {
  position: relative;
}
.subtitle-input-wrap input {
  width: 100%;
  padding: 12px 48px 12px 14px;
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius);
  font-size: 15px;
  font-style: italic;
  font-family: Georgia, serif;
  outline: none;
  transition: border-color var(--transition);
  background: #fff;
  color: var(--brand-black);
}
.subtitle-input-wrap input:focus { border-color: var(--brand-black); }

.subtitle-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.suggestion-chip {
  padding: 6px 12px;
  border: 1.5px solid var(--brand-border);
  border-radius: 20px;
  font-size: 12px;
  font-style: italic;
  font-family: Georgia, serif;
  background: #fff;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  color: var(--brand-black);
}
.suggestion-chip:active, .suggestion-chip:hover { background: var(--brand-light); }

/* ── 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 10px;
  background: #fff;
  border-radius: 16px;
  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;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 9px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--brand-black);
  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(--brand-light); }
.edit-tool-btn svg { width: 20px; height: 20px; }
.edit-tool-danger { color: #e53e3e; }

/* Prev / next nav arrows — icon-only, no label, narrower */
.edit-tool-nav {
  min-width: 34px;
  padding: 6px 5px;
}
.edit-tool-nav svg { width: 18px; height: 18px; }

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

/* ── 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: 1.5px solid var(--brand-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--brand-black);
  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; }
.edit-zoom-back:active { opacity: 0.75; }

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

/* ── Product Info (sticky bottom of control panel) ───────────────────────── */
.product-info {
  margin-top: auto;
  border-top: 1px solid var(--brand-border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.product-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.product-info-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.product-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-black);
}
.product-delivery {
  font-size: 12px;
  color: var(--brand-grey);
}
.product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-black);
  white-space: nowrap;
}

/* ── 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: #fff;
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  padding-bottom: calc(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(--brand-border);
  border-radius: 2px;
  margin: 12px auto 16px;
}
.sheet-content { padding: 0 20px; }
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.sheet-title { font-size: 17px; font-weight: 700; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.sheet-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--brand-light);
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-black);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.sheet-action-btn:active { background: var(--brand-border); }
.sheet-action-btn svg { width: 22px; height: 22px; }

.sheet-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.slider-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-grey);
  width: 52px;
  flex-shrink: 0;
}
.slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--brand-border);
  border-radius: 2px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--brand-black);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.slider-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-black);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Subtitle Sheet ──────────────────────────────────────────────────────── */
.subtitle-input-wrap {
  position: relative;
  margin-bottom: 16px;
}
.subtitle-input-wrap input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-style: italic;
  font-family: Georgia, serif;
  outline: none;
  transition: border-color var(--transition);
}
.subtitle-input-wrap input:focus { border-color: var(--brand-black); }

.subtitle-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggestion-chip {
  padding: 8px 14px;
  border: 1.5px solid var(--brand-border);
  border-radius: 20px;
  font-size: 13px;
  font-style: italic;
  font-family: Georgia, serif;
  background: #fff;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  color: var(--brand-black);
}
.suggestion-chip:active { background: var(--brand-light); }

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

/* ── Upload Progress Overlay ─────────────────────────────────────────────── */
.upload-progress-area {
  position: fixed;
  bottom: 24px;
  left: 16px;
  right: calc(var(--control-width) + 16px);
  z-index: 50;
  pointer-events: none;
}
.upload-progress-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upload-item {
  background: #fff;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.upload-item-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--brand-light);
  flex-shrink: 0;
}
.upload-item-info { flex: 1; min-width: 0; }
.upload-item-name { font-size: 13px; 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(--brand-border); stroke-width: 3; }
.upload-ring-fill { fill: none; stroke: var(--brand-black); 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-black); }
.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-input-wrap {
  position: relative;
}
.editor-word-input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--brand-border);
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  outline: none;
  transition: border-color var(--transition);
  background: #fff;
  color: var(--brand-black);
}
.editor-word-input:focus { border-color: var(--brand-black); }
.editor-word-input::placeholder {
  font-weight: 400;
  letter-spacing: 1px;
  color: #ccc;
  font-size: 16px;
}
.editor-word-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.word-suggestion-chip {
  padding: 5px 11px;
  border: 1.5px solid var(--brand-border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: #fff;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  color: var(--brand-black);
}
.word-suggestion-chip:hover,
.word-suggestion-chip.active {
  background: var(--brand-black);
  border-color: var(--brand-black);
  color: #fff;
}

/* ── Progress inline ─────────────────────────────────────────────────────── */
.progress-label-inline {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-grey);
  margin-top: -10px;
}

/* ── Upload auto-hint ────────────────────────────────────────────────────── */
.upload-auto-hint {
  font-size: 11px;
  color: var(--brand-grey);
  text-align: center;
  margin-top: 6px;
}

/* ── Gallery empty add tile ──────────────────────────────────────────────── */
.gallery-item-add {
  background: var(--brand-light);
  border: 2px dashed var(--brand-border) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.gallery-item-add:hover {
  border-color: var(--brand-black) !important;
  background: #ebebeb;
}
.gallery-add-plus {
  font-size: 20px;
  font-weight: 300;
  color: var(--brand-grey);
  line-height: 1;
}

/* ── Configure Panel (inside sidebar) ────────────────────────────────────── */
.cfg-steps-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  padding-top: calc(14px + var(--safe-top));
  border-bottom: 1px solid var(--brand-border);
  flex-shrink: 0;
}
.step-item {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--brand-grey);
  text-transform: uppercase;
}
.step-item.active { color: var(--brand-black); }
.step-item.done   { color: var(--brand-grey); text-decoration: line-through; }
.step-sep { color: var(--brand-border); font-size: 12px; }

.cfg-summary {
  padding: 16px 20px;
  border-bottom: 1px solid var(--brand-border);
  flex-shrink: 0;
}
.cfg-summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.cfg-summary-label {
  font-size: 13px;
  color: var(--brand-grey);
  min-width: 80px;
}
.cfg-summary-value {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}
.cfg-summary-muted { font-weight: 400; color: var(--brand-grey); }
.cfg-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--brand-grey);
  padding: 4px;
  line-height: 1;
}

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

.cfg-selector-group { display: flex; flex-direction: column; gap: 10px; }
.cfg-selector-label { font-size: 13px; color: var(--brand-grey); }
.cfg-selector-label strong { color: var(--brand-black); }

.cfg-selector-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cfg-pill {
  padding: 8px 16px;
  border: 2px solid var(--brand-border);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  color: var(--brand-black);
}
.cfg-pill.active {
  border-color: var(--brand-black);
  background: var(--brand-black);
  color: #fff;
}
.cfg-pill:hover:not(.active) { border-color: #999; }

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

.cfg-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--brand-border);
  padding: 16px 20px;
  padding-bottom: calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cfg-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cfg-product-name {
  font-size: 15px;
  font-weight: 600;
}
.cfg-prices { display: flex; align-items: center; gap: 8px; }
.cfg-compare-price {
  font-size: 14px;
  color: var(--brand-grey);
  text-decoration: line-through;
}
.cfg-current-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-black);
}
.cfg-delivery {
  font-size: 12px;
  color: #2e7d32;
}
.cfg-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.cfg-back-btn {
  width: 48px;
  height: 48px;
  border: 2px solid var(--brand-border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cfg-cart-btn { flex: 1; }

/* ── 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%;
  }

  /* Canvas panel: shrinks to exactly the canvas height (not flex: 1) */
  .preview-panel {
    flex-shrink: 0;
    padding: 8px;
    overflow: hidden;
    align-items: flex-start;
    justify-content: flex-start;
  }

  /* 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: fills ALL remaining space below canvas — no hardcoded height */
  .control-panel {
    width: 100%;
    flex: 1;             /* takes whatever is left after the canvas */
    min-height: 160px;   /* never fully disappear on very tall canvases */
    flex-shrink: 0;      /* but don't compress if content is taller */
    border-right: none;
    border-top: 1px solid var(--brand-border);
  }

  /* Editor panel inner scroll area on mobile */
  #panel-editor {
    padding: 12px 14px;
    padding-bottom: calc(12px + var(--safe-bottom));
    gap: 12px;
  }

  /* Configure panel steps nav safe area on mobile */
  .cfg-steps-nav {
    padding-top: calc(10px + var(--safe-top));
    padding-bottom: 10px;
  }

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

  /* Toolbar stays at bottom-center; shrink buttons slightly on narrow screens */
  .letter-edit-toolbar { padding: 5px 8px; bottom: 14px; }
  .edit-tool-btn { min-width: 40px; padding: 5px 7px; font-size: 9px; }
  .edit-tool-btn svg { width: 18px; height: 18px; }

  .upload-progress-area { left: 8px; right: 8px; bottom: 8px; }

  /* Remove grey strip below canvas — toolbar floats over canvas so no gap needed */
  .preview-panel { padding-bottom: 0; }

  /* ── Zoom-mode: letter-editing view ─────────────────────────────────────── */
  /* JS adds .zoom-mode to .editor-layout when a letter is tapped on mobile.   */
  /* Stage is rebuilt at new (padding-free) dimensions; Konva zoom animates in. */
  .editor-layout.zoom-mode .preview-panel {
    padding: 0;           /* canvas fills full viewport width — no grey border */
    background: #fff;
    flex: 1;              /* canvas expands to fill all space freed by collapsed panel */
  }
  .editor-layout.zoom-mode .canvas-paper {
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }
  /* ── Zoom-mode: control panel collapses to gallery strip only ── */
  /* Three flex layers all need resetting to prevent extra whitespace:
     1. .control-panel  — has flex:1 + min-height:160px on mobile
     2. .panel          — has flex:1 (fills control-panel)
     3. #panel-editor   — has gap + padding                        */
  .editor-layout.zoom-mode .control-panel {
    flex: 0 0 auto !important;
    min-height: 0 !important;   /* override min-height:160px */
  }
  .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: 8px 14px 10px;
    overflow-y: visible;
  }
  .editor-layout.zoom-mode .photo-gallery { display: flex !important; }
  .editor-layout.zoom-mode .photo-gallery-header { padding-bottom: 4px; }
}
