/* ============================================================
   EDITOR.CSS — Editor Page Specific Styles (Figma-style layout)
   ============================================================ */

/* --- Editor Page Body Layout ---
   Uses flex column so toolbar + editor + footer stack naturally
   without fragile calc() height dependencies. */
body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  z-index: 9999;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0.5rem;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}


/* ============================================================
   TOOLBAR — Compact top bar with dropdown popovers
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  height: 48px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: relative;
  z-index: 500;
  gap: var(--space-1);
  flex-shrink: 0;
}
.toolbar__left,
.toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.toolbar__logo {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
  text-decoration: none;
  margin-right: var(--space-3);
  white-space: nowrap;
}
.toolbar__logo:hover { text-decoration: none; }

.toolbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  white-space: nowrap;
}
.toolbar__btn svg:not(.toolbar__chevron) {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.toolbar__btn:hover {
  background: var(--color-surface);
}
.toolbar__btn--primary {
  background: var(--color-accent);
  color: #fff;
}
.toolbar__btn--primary:hover {
  background: var(--color-accent-hover);
}
.toolbar__btn--subtle {
  color: var(--color-text-soft);
}

.toolbar__chevron {
  width: 12px;
  height: 12px;
  opacity: 0.5;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.toolbar__dropdown.is-open .toolbar__chevron {
  transform: rotate(180deg);
}

.toolbar__dropdown {
  position: relative;
}

/* ============================================================
   POPOVERS — Dropdown panels from toolbar
   ============================================================ */
.popover {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 280px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  animation: popoverIn 0.12s ease-out;
}
.popover--md { min-width: 340px; }
.popover--lg { min-width: 320px; max-width: 380px; }
.popover--sm { min-width: 180px; }
.popover--right { left: auto; right: 0; }

/* Templates popover */
.popover--templates {
  width: 420px;
  max-height: 480px;
}
.popover--templates .popover__body {
  max-height: 440px;
  overflow-y: auto;
}
.template-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.template-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}
.template-card__preview {
  width: 100%;
  aspect-ratio: 3/2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: var(--radius-sm);
  background: #fff;
  margin-bottom: 0.35rem;
  border: 1px solid var(--color-border);
}
.template-card__name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}
.template-card__desc {
  font-size: 0.58rem;
  color: var(--color-text-muted);
  line-height: 1.2;
}

.toolbar__dropdown.is-open > .popover {
  display: block;
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.popover__body {
  padding: var(--space-3);
  max-height: 50vh;
  overflow-y: auto;
}
.popover__body--list {
  padding: var(--space-1);
}
.popover__section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.popover__action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast);
  text-align: left;
}
.popover__action:hover {
  background: var(--color-surface);
}
.popover__action svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ============================================================
   EDITOR LAYOUT — Full-screen canvas + labels panel
   ============================================================ */
.editor {
  display: grid;
  grid-template-columns: 1fr 180px;
  flex: 1;
  min-height: 0;       /* allow grid to shrink below content size */
  overflow: hidden;
}

.canvas {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-6);
  overflow: hidden;
  background:
    linear-gradient(90deg, #e8eaed 1px, transparent 1px),
    linear-gradient(#e8eaed 1px, transparent 1px),
    #f4f5f7;
  background-size: 20px 20px;
}
[data-theme="dark"] .canvas {
  background:
    linear-gradient(90deg, #2d3040 1px, transparent 1px),
    linear-gradient(#2d3040 1px, transparent 1px),
    #1a1d27;
  background-size: 20px 20px;
}

.preview-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.preview-stage__placeholder {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-8);
}

/* ============================================================
   LABELS PANEL — Right sidebar for multi-label management
   ============================================================ */
.labels-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border);
  background: var(--color-card);
  overflow-y: auto;
}
.labels-panel__header {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.labels-panel__title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-soft);
}
.labels-panel__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.labels-panel__actions {
  padding: var(--space-2);
  border-top: 1px solid var(--color-border);
}
.labels-panel__add {
  width: 100%;
}

/* Label thumbnail items */
.label-thumb {
  position: relative;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
  cursor: pointer;
  transition: all var(--duration-fast);
  background: var(--color-surface);
}
.label-thumb:hover {
  border-color: var(--color-accent);
}
.label-thumb.is-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}
.label-thumb__preview {
  width: 100%;
  aspect-ratio: 3/2;
  background: #fff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.45rem;
  color: var(--color-text-muted);
  line-height: 1.25;
  text-align: center;
  padding: 6px;
}
.label-thumb__text {
  text-align: left;
  color: var(--color-text-soft, #666);
  white-space: pre-line;
  overflow: hidden;
  max-height: 2.5em;
  font-size: 0.55rem;
  line-height: 1.3;
}
.label-thumb__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}
.label-thumb__name {
  font-size: 0.6rem;
  color: var(--color-text-soft);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.label-thumb__actions {
  display: flex;
  gap: 2px;
}
.label-thumb__btn {
  padding: 1px 4px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.6rem;
  color: var(--color-text-muted);
  border-radius: 3px;
  transition: all var(--duration-fast);
}
.label-thumb__btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}
.label-thumb__btn--delete:hover {
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  color: var(--color-error);
}
.label-thumb__badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 0.5rem;
  color: var(--color-text-muted);
  background: var(--color-surface);
  padding: 0 3px;
  border-radius: 2px;
}

/* ============================================================
   STATUS FOOTER — Bottom bar with zoom, undo/redo, queue
   ============================================================ */
.status-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  height: 36px;
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 1;
}
.status-footer__left,
.status-footer__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.status-footer__zoom {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
}
.status-footer__sep {
  width: 1px;
  height: 16px;
  background: var(--color-border);
}

/* --- Undo / Redo Buttons --- */
.undo-redo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.undo-redo-btn:hover:not(:disabled) {
  background: var(--color-bg);
}
.undo-redo-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --- Zoom Control Group --- */
.zoom-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
  height: 26px;
}
.zoom-group__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--color-text-soft);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.zoom-group__btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}
.zoom-group__pct {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-width: 40px;
  padding: 0 2px;
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-soft);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.zoom-group__pct:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* --- Zoom Slider --- */
.zoom-slider {
  width: 80px;
  height: 4px;
  margin: 0 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border);
  border-radius: 2px;
  cursor: pointer;
}
.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}
.zoom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.zoom-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: none;
}
.zoom-slider:focus {
  outline: none;
}
.zoom-slider:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

/* ============================================================
   ADDRESS CONTROLS (inside popover)
   ============================================================ */
.addr-group { margin-bottom: var(--space-3); }
.addr-group:last-child { margin-bottom: 0; }

/* Address visibility toggle */
.addr-toggle {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 5px;
  cursor: pointer;
  color: var(--color-text-soft);
  display: flex;
  align-items: center;
  transition: all var(--duration-fast);
}
.addr-toggle:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
  border-color: var(--color-border);
}
.addr-toggle .eye-open { display: block; }
.addr-toggle .eye-closed { display: none; }
.addr-toggle.is-hidden .eye-open { display: none; }
.addr-toggle.is-hidden .eye-closed { display: block; }
.addr-toggle.is-hidden {
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* Hidden address group styling */
.addr-group--hidden textarea {
  opacity: 0.4;
  background: var(--color-surface);
}
.addr-group--hidden::after {
  content: 'Hidden on label';
  font-size: 0.6rem;
  color: var(--color-text-muted);
  display: block;
  margin-top: var(--space-1);
  font-style: italic;
}

.addr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}
.addr-header label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-soft);
}
.addr-header__actions {
  display: flex;
  gap: var(--space-1);
}
.addr-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  cursor: pointer;
  color: var(--color-text-soft);
  font-size: 0.7rem;
  font-family: inherit;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: all var(--duration-fast);
}
.addr-btn:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
  border-color: var(--color-border);
}
.addr-btn svg {
  width: 12px;
  height: 12px;
  stroke-width: 2;
  fill: none;
}
.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-1) var(--space-2);
  margin: var(--space-1) 0;
  background: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-soft);
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
}
.swap-btn:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.swap-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
  fill: none;
}

/* ============================================================
   FONT PICKER
   ============================================================ */
.font-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.font-grid__category {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.font-grid__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.font-chip {
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all var(--duration-fast);
  white-space: nowrap;
  font-family: inherit;
  color: var(--color-text);
  line-height: 1.4;
}
.font-chip:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  color: var(--color-accent);
}
.font-chip.is-active {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
}
[data-theme="dark"] .font-chip.is-active {
  background: var(--color-accent);
  color: #fff;
}

/* ============================================================
   SLIDER / TOGGLE / COLOR ROWS
   ============================================================ */
.slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.slider-row:last-child { margin-bottom: 0; }
.slider-row__label {
  font-size: 0.72rem;
  color: var(--color-text-soft);
  font-weight: 500;
  min-width: 60px;
}
.slider-row__value {
  font-size: 0.72rem;
  color: var(--color-text-soft);
  font-weight: 600;
  min-width: 28px;
  text-align: right;
}
.toggle-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.color-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.color-row__label {
  font-size: 0.72rem;
  color: var(--color-text-soft);
  font-weight: 500;
}

/* ============================================================
   BORDER OPTIONS
   ============================================================ */
.border-options {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.border-opt {
  width: 48px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  transition: all var(--duration-fast);
}
.border-opt:hover { border-color: var(--color-border-focus); background: var(--color-accent-light); }
.border-opt.is-active { border-color: var(--color-accent); background: var(--color-accent-light); }
.border-opt__mini {
  width: 30px;
  height: 20px;
  border-radius: 1px;
}
.border-opt[data-border="none"] .border-opt__mini { border: 1px solid var(--color-border); }
.border-opt[data-border="thin"] .border-opt__mini { border: 1px solid var(--color-text); }
.border-opt[data-border="thick"] .border-opt__mini { border: 2px solid var(--color-text); }
.border-opt[data-border="double"] .border-opt__mini { border: 3px double var(--color-text); }
.border-opt[data-border="dashed"] .border-opt__mini { border: 1.5px dashed var(--color-text); }
.border-opt[data-border="ornate"] .border-opt__mini {
  border: 2px solid var(--color-text);
  outline: 1px solid var(--color-text);
  outline-offset: 2px;
}

/* ============================================================
   LABEL SIZE OPTIONS
   ============================================================ */
.size-options {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.size-options--compact { margin-bottom: 0.5rem; }
.size-opt {
  flex: 1;
  min-width: 70px;
  padding: 0.45rem 0.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  font-family: inherit;
}
.size-opt:hover { border-color: var(--color-border-focus); background: var(--color-accent-light); }
.size-opt.is-active { border-color: var(--color-accent); background: var(--color-accent-light); }
.size-opt--more {
  flex: 0 0 auto;
  min-width: 60px;
  background: var(--color-surface);
  border-style: dashed;
}
.size-opt--more:hover { border-color: var(--color-accent); border-style: dashed; }
.size-opt__dim {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}
.size-opt__desc {
  font-size: 0.65rem;
  color: var(--color-text-soft);
  margin-top: 0.1rem;
}
.size-opt.is-active .size-opt__dim { color: var(--color-accent); }
[data-theme="dark"] .size-opt:hover { border-color: var(--color-accent); background: var(--color-accent-light); }

.size-expanded {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}
.size-group { margin-bottom: var(--space-3); }
.size-group:last-child { margin-bottom: 0; }
.size-group__title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

/* Custom Size Row */
.custom-size-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.custom-size-row__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-soft);
}
.custom-size-row__input {
  width: 60px;
  padding: 0.35rem 0.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  text-align: center;
}
.custom-size-row__input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.1);
}
.custom-size-row__x { font-size: 0.85rem; color: var(--color-text-muted); }
.custom-size-row__unit { font-size: 0.72rem; color: var(--color-text-muted); font-weight: 500; }

/* Print Mode Row */
.print-mode-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}
.copies-input {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.25rem;
}
.copies-count {
  width: 3.2rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-sm);
  text-align: center;
  font-family: inherit;
}
.copies-count:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}

/* ============================================================
   THE LABEL (on canvas)
   ============================================================ */
.label-outer {
  transform-origin: center center;
}
.label {
  background: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
}
/* Allow handles to be visible when an element is selected */
.label:has(.is-selected) {
  overflow: visible;
}
.label--none   { border: none; box-shadow: var(--shadow-lg); }
.label--thin   { border: 1px solid #222; }
.label--thick  { border: 2.5px solid #222; }
.label--double { border: 4px double #222; }
.label--dashed { border: 2px dashed #444; }
.label--ornate { border: 2px solid #222; }
.label--ornate::before,
.label--ornate::after {
  content: "";
  position: absolute;
  top: 6px; left: 6px; right: 6px; bottom: 6px;
  border: 1px solid #888;
  pointer-events: none;
}
.label--round {
  border-radius: 50%;
  overflow: hidden;
}
/* Placeholder Text Element Styles */
.label__custom-text--placeholder {
  cursor: text;
}

/* Inline Editing State */
.label__custom-text.is-inline-editing {
  outline: 1px dashed rgba(0, 0, 0, 0.3);
  outline-offset: 4px;
  border-radius: 2px;
  cursor: text !important;
  min-width: 80px;
  min-height: 1.2em;
}
.label__custom-text.is-inline-editing:focus {
  outline: 1px dashed rgba(0, 0, 0, 0.4);
  outline-offset: 4px;
}
[data-theme="dark"] .label__custom-text.is-inline-editing {
  outline-color: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   ADDRESS BOOK & MODALS
   ============================================================ */
.book-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  padding: var(--space-8) var(--space-4);
}
.save-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.save-row input {
  flex: 1;
  padding: 0.45rem 0.6rem;
}
.save-row button {
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
}
.save-row button:hover { background: var(--color-accent-hover); }
.save-row__select {
  padding: 0.45rem 0.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  background: var(--color-card);
  color: var(--color-text);
  cursor: pointer;
}
.save-row__input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
}
.modal__body {
  margin-bottom: var(--space-3);
  max-height: 50vh;
  overflow-y: auto;
}
.addr-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  padding: var(--space-8) var(--space-4);
}

/* Address Book Search & Favorites */
.addr-search-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: var(--space-2);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface);
  padding: 0.25rem 0;
}
.addr-search-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-sm);
}
.addr-search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}
.addr-fav-toggle {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
}
.addr-fav-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.addr-fav-toggle.is-active {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-warning);
}
.addr-list-inner {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.saved-addr {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: var(--space-2) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
}
.saved-addr:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}
.saved-addr--fav {
  background: color-mix(in srgb, var(--color-accent-light) 30%, transparent);
  border-radius: var(--radius-md);
}
.saved-addr__fav {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--duration-fast);
  padding: 0;
}
.saved-addr__fav:hover,
.saved-addr--fav .saved-addr__fav {
  color: var(--color-warning);
}
.saved-addr__info {
  flex: 1;
  min-width: 0;
}
.saved-addr__info strong {
  display: block;
  font-size: var(--text-sm);
}
.saved-addr__info span {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-addr__group {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-style: italic;
}
.saved-addr__actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.25rem;
}

/* Print-Only Label */
.print-only-label { display: none; }

/* ============================================================
   BACKGROUND CONTROLS
   ============================================================ */
.bg-controls { padding: 0; }
.bg-row { display: flex; gap: 0.35rem; }
.bg-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bg-preset {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast);
}
.bg-preset:hover { transform: scale(1.15); }
.bg-preset.is-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}
.bg-angle-row { display: flex; align-items: center; gap: 0.5rem; }

/* Queue Badge */
.queue-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-xs);
  color: var(--color-text-soft);
  background: var(--color-accent-light);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}
.queue-badge strong { color: var(--color-accent); }
.btn--link {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  font-size: var(--text-xs);
  padding: 0 0.25rem;
  text-decoration: underline;
}

/* ============================================================
   CSV IMPORT MODAL
   ============================================================ */
.modal--wide { max-width: 560px; width: 92vw; }
.csv-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-4);
}
.csv-tab {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--color-text-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--duration-fast);
}
.csv-tab:hover { color: var(--color-text); }
.csv-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}
.csv-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: var(--text-xs);
  line-height: 1.5;
  resize: vertical;
  background: var(--color-surface);
  color: var(--color-text);
}
.csv-file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: var(--space-8) var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  transition: all var(--duration-fast);
}
.csv-file-label:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}
.csv-help {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}
.csv-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}
.csv-mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.csv-map-row { display: flex; align-items: center; gap: 0.5rem; }
.csv-map-label { font-size: var(--text-xs); color: var(--color-text-soft); min-width: 5.5rem; }
.csv-map-select {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  background: var(--color-surface);
  color: var(--color-text);
}
.csv-preview-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.csv-preview-card {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs);
}
.csv-preview-card:last-child { border-bottom: none; }
.csv-preview-num { font-weight: 700; color: var(--color-accent); flex-shrink: 0; min-width: 2rem; }
.csv-preview-text { white-space: pre-line; color: var(--color-text); line-height: 1.4; }
.csv-preview-more {
  padding: 0.5rem 0.75rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
  font-style: italic;
}

/* ============================================================
   DRAG & DROP
   ============================================================ */
.draggable {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.draggable:hover {
  outline: 2px dashed var(--color-accent);
  outline-offset: 2px;
}
.draggable.is-dragging {
  cursor: grabbing;
  opacity: 0.85;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  z-index: 100;
}
.draggable.is-selected {
  /* No outline — the resize handles and dashed border provide selection feedback */
  position: relative;
}
/* Suppress the dashed border during inline editing — the editing outline takes over */
.draggable.is-selected.is-inline-editing {
  border-color: transparent !important;
}

/* --- Selection Handles for Resize/Rotate --- */
.selection-handles {
  position: absolute;
  inset: -8px;
  pointer-events: none;
  z-index: 100;
}
.handle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fff;
  border: 1.5px solid var(--color-accent);
  border-radius: 1px;
  pointer-events: auto;
  z-index: 101;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.handle--nw { top: 0; left: 0; cursor: nwse-resize; transform: translate(-50%, -50%); }
.handle--n  { top: 0; left: 50%; cursor: ns-resize; transform: translate(-50%, -50%); }
.handle--ne { top: 0; right: 0; cursor: nesw-resize; transform: translate(50%, -50%); }
.handle--e  { top: 50%; right: 0; cursor: ew-resize; transform: translate(50%, -50%); }
.handle--se { bottom: 0; right: 0; cursor: nwse-resize; transform: translate(50%, 50%); }
.handle--s  { bottom: 0; left: 50%; cursor: ns-resize; transform: translate(-50%, 50%); }
.handle--sw { bottom: 0; left: 0; cursor: nesw-resize; transform: translate(-50%, 50%); }
.handle--w  { top: 50%; left: 0; cursor: ew-resize; transform: translate(-50%, -50%); }

.handle--rotate {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  cursor: grab;
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.handle--rotate:active { cursor: grabbing; }

.handle__rotate-line {
  position: absolute;
  top: -18px;
  left: 50%;
  width: 1px;
  height: 14px;
  background: var(--color-accent);
  transform: translateX(-50%);
  pointer-events: none;
}

/* Snap guide overlay */
.drag-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
.guide {
  position: absolute;
  background: transparent;
  transition: background 0.1s;
}
.guide--v {
  width: 1px;
  border-left: 1px dashed rgba(99,102,241,0.25);
}
.guide--h {
  height: 1px;
  border-top: 1px dashed rgba(99,102,241,0.25);
}
.guide.is-snapped { border-color: var(--color-accent); background: rgba(99,102,241,0.08); }
.guide--v.is-snapped { border-left-style: solid; width: 2px; }
.guide--h.is-snapped { border-top-style: solid; height: 2px; }

/* Custom text elements on the label */
.label__custom-text {
  position: absolute;
  white-space: pre-line;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
/* Show resize handles outside the element bounds when selected */
.label__custom-text.is-selected,
.label__custom-text.is-inline-editing {
  overflow: visible;
}
/* Custom image elements on the label */
.label__custom-image {
  position: absolute;
  user-select: none;
  -webkit-user-select: none;
  z-index: 5;
  border: 1px solid transparent;
  transition: border-color var(--duration-fast);
}
.label__custom-image:hover { border-color: var(--color-accent); }
.label__custom-image.is-selected {
  border-color: var(--color-accent);
}
.label__custom-image.is-dragging { opacity: 0.85; }
.label__custom-image img {
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Image editor thumbnail */
.image-editor-thumb {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}
[data-theme="dark"] .image-editor-thumb {
  background: repeating-conic-gradient(#2a2d3a 0% 25%, #1e212b 0% 50%) 50% / 12px 12px;
}

/* ============================================================
   ELEMENTS PANEL (inside popover)
   ============================================================ */
.elements-card__header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.elements-card__actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.elements-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: var(--space-2);
}
.elements-list:empty::after {
  content: 'Drag addresses on the label or add custom text.';
  display: block;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  padding: var(--space-2) 0;
}
.element-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  background: var(--color-surface);
  transition: all var(--duration-fast);
}
.element-item:hover { border-color: var(--color-accent); }
.element-item.is-active {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}
.element-item__icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
}
.element-item__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--color-text);
}
.element-item__actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}
.element-item__btn {
  padding: 0.15rem 0.3rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  border-radius: 4px;
  transition: all var(--duration-fast);
}
.element-item__btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}
.element-item__btn--delete:hover {
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  color: var(--color-error);
}
.element-edit-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-accent-light);
  margin-top: 0.35rem;
}
.element-edit-row input[type="text"],
.element-edit-row textarea {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-xs);
  background: var(--color-card);
  color: var(--color-text);
}
.element-edit-row textarea {
  min-height: 3rem;
  resize: vertical;
}
.element-edit-row__row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.element-edit-row__label {
  font-size: var(--text-xs);
  color: var(--color-text-soft);
  min-width: 3rem;
}
.reset-positions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Symbol picker buttons */
.symbol-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-card);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}
.symbol-btn:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  transform: scale(1.1);
}
.element-font-select { max-width: 100%; }

/* ============================================================
   COLLAPSIBLE SECTIONS
   ============================================================ */
.collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.25rem 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-family: inherit;
  transition: color 0.15s;
}
.collapsible-toggle:hover { color: var(--color-text-soft); }
.collapsible-toggle::before {
  content: '\25B6';
  font-size: 0.5rem;
  transition: transform 0.2s;
  display: inline-block;
}
.collapsible-toggle.is-open::before {
  transform: rotate(90deg);
}
.collapsible-body {
  display: none;
  padding-top: 0.5rem;
}
.collapsible-body.is-open {
  display: block;
}

/* ============================================================
   FLOATING FORMAT TOOLBAR
   ============================================================ */
.format-toolbar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  white-space: nowrap;
}
.format-toolbar.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.format-toolbar__font {
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  background: var(--color-surface);
  color: var(--color-text);
  max-width: 140px;
  font-family: inherit;
  cursor: pointer;
}
.format-toolbar__size {
  width: 3.2rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  text-align: center;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
}
.format-toolbar__btn {
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.12s;
  line-height: 1.3;
}
.format-toolbar__btn:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}
.format-toolbar__btn.is-active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.format-toolbar__sep {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* --- Inline Edit Textarea Overlay --- */
.label__edit-overlay {
  position: absolute;
  background: rgba(255, 255, 255, 0.97);
  color: #111827;
  border: 2px solid var(--color-accent);
  border-radius: 4px;
  padding: 6px 8px;
  z-index: 300;
  font-family: inherit;
  resize: none;
  outline: none;
  min-width: 150px;
  min-height: 60px;
  line-height: 1.55;
  white-space: pre-line;
  box-shadow: 0 2px 12px rgba(80, 70, 229, 0.15);
}
.label__edit-overlay::selection {
  background: var(--color-accent);
  color: #fff;
}
[data-theme="dark"] .label__edit-overlay {
  background: rgba(30, 33, 43, 0.97);
  color: #e8eaed;
}

/* ============================================================
   KEYBOARD SHORTCUTS MODAL
   ============================================================ */
.modal--shortcuts {
  max-width: 520px;
  width: 90vw;
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 480px) {
  .shortcuts-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.shortcuts-group__title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  margin-bottom: 0.5rem;
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.78rem;
  color: var(--color-text);
  gap: 0.5rem;
}
.shortcut-desc {
  flex: 1;
  color: var(--color-text-soft);
}
.shortcut-row kbd {
  display: inline-block;
  padding: 2px 7px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
  box-shadow: 0 1px 0 var(--color-border);
  white-space: nowrap;
}
.shortcuts-hint {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
}
.shortcuts-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text);
  box-shadow: 0 1px 0 var(--color-border);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* At medium widths: icon-only toolbar buttons, narrower sidebar */
@media (max-width: 1100px) {
  .toolbar__btn {
    font-size: 0;
    padding: 7px 8px;
    gap: 0;
  }
  .toolbar__chevron {
    display: none;
  }
  /* Keep Print button readable */
  .toolbar__btn--primary {
    font-size: 0.75rem;
    padding: 6px 12px;
    gap: 4px;
  }
  .editor {
    grid-template-columns: 1fr 140px;
  }
  .toolbar__logo {
    margin-right: var(--space-2);
  }
}

@media (max-width: 860px) {
  .editor {
    grid-template-columns: 1fr 120px;
  }
  .toolbar__logo {
    font-size: 0.75rem;
    margin-right: var(--space-1);
  }
}

@media (max-width: 700px) {
  .editor {
    grid-template-columns: 1fr;
  }
  .labels-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  .toolbar {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-1) var(--space-2);
    gap: 2px;
  }
  .toolbar__left,
  .toolbar__right {
    flex-wrap: wrap;
  }
  .popover {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: 100%;
    max-height: 50vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: popoverSlideUp 0.2s ease-out;
  }
  .popover--right {
    left: 0;
    right: 0;
  }
  @keyframes popoverSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 480px) {
  .csv-mapping-grid {
    grid-template-columns: 1fr;
  }
  .format-toolbar {
    flex-wrap: wrap;
    max-width: calc(100vw - 2rem);
  }
  .format-toolbar__font {
    max-width: 100px;
  }
  .toolbar__btn {
    padding: 5px 7px;
    font-size: 0.72rem;
  }
  .status-footer {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-1) var(--space-2);
    gap: var(--space-1);
  }
}
