.ig-overlay {
  position: fixed;
  inset: 0;
  z-index: 200000;
  background: var(--theme-main-background-color, #1a1a2e);
  color: var(--theme-main-text-color, #e8e4dc);
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ── Header ── */

.ig-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(128,128,128,.2);
  flex-shrink: 0;
  gap: 12px;
}

.ig-header-title {
  font-weight: 600;
  font-size: 1rem;
}

/* ── Body ── */

.ig-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Preview column ── */

.ig-preview-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 10px;
  overflow: auto;
}

.ig-canvas {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,.55);
  object-fit: contain;
}

.ig-preview-info {
  font-size: 11px;
  opacity: .5;
}

/* ── Controls column ── */

.ig-controls-col {
  width: 320px;
  min-width: 260px;
  max-width: 380px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px 16px;
  border-left: 1px solid rgba(128,128,128,.2);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Sections ── */

.ig-section {
  margin-bottom: 18px;
}

.ig-section-title {
  font-size: 0.78em;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .55;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(128,128,128,.2);
}

/* ── Rows ── */

.ig-row {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ig-row-inline {
  flex-direction: row;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.ig-row-slider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ig-row-slider .ig-label {
  min-width: 80px;
  flex-shrink: 0;
  margin: 0;
}

/* ── Size groups ── */

.ig-size-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 64px;
}

.ig-color-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.ig-opacity-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 80px;
}

/* ── Labels ── */

.ig-label {
  font-size: 0.82em;
  opacity: .7;
  display: block;
  margin-bottom: 2px;
}

.ig-sublabel {
  font-size: 0.8em;
  font-weight: 600;
  opacity: .6;
  margin: 8px 0 4px;
}

/* ── Inputs ── */

.ig-overlay input[type=number],
.ig-overlay input[type=text],
.ig-overlay textarea,
.ig-overlay select {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(128,128,128,.3);
  border-radius: 4px;
  color: inherit;
  font-family: inherit;
  font-size: 0.9em;
  padding: 4px 7px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s;
}

.ig-overlay input[type=number]:focus,
.ig-overlay input[type=text]:focus,
.ig-overlay textarea:focus,
.ig-overlay select:focus {
  border-color: rgba(128,128,200,.6);
}

.ig-number {
  width: 100%;
}

.ig-textarea {
  resize: vertical;
  min-height: 60px;
}

/* ── Sliders ── */

.ig-slider {
  flex: 1;
  accent-color: rgba(128,128,200,.8);
  height: 4px;
  cursor: pointer;
}

.ig-slider-val {
  font-size: 0.8em;
  opacity: .6;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Color input (Coloris) ── */

.ig-color-input {
  cursor: pointer;
  font-family: monospace !important;
  font-size: 0.85em !important;
  padding-left: 8px !important;
}

/* ── Buttons ── */

.ig-btn {
  padding: 6px 16px;
  border-radius: 5px;
  border: 1px solid rgba(128,128,128,.35);
  background: rgba(255,255,255,.07);
  color: inherit;
  font-size: 0.9em;
  cursor: pointer;
  transition: background .15s;
}

.ig-btn:hover {
  background: rgba(255,255,255,.13);
}

.ig-btn-primary {
  background: rgba(100,100,200,.35);
  border-color: rgba(100,100,200,.5);
}

.ig-btn-primary:hover {
  background: rgba(100,100,200,.55);
}

.ig-btn:disabled {
  opacity: .4;
  cursor: default;
}

/* ── Pattern grid ── */

.ig-pattern-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.ig-pattern-btn {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  border: 2px solid transparent;
  background: rgba(255,255,255,.06);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: inherit;
  transition: border-color .15s, background .15s;
}

.ig-pattern-btn:hover {
  background: rgba(255,255,255,.12);
}

.ig-pattern-btn.is-active {
  border-color: rgba(100,120,220,.7);
  background: rgba(100,120,220,.15);
}

.ig-pattern-btn canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* ── Toggle switch ── */

.ig-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ig-toggle-label {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.ig-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ig-toggle-knob {
  position: absolute;
  inset: 0;
  background: rgba(128,128,128,.3);
  border-radius: 20px;
  transition: background .2s;
}

.ig-toggle-knob::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}

.ig-toggle-input:checked + .ig-toggle-knob {
  background: rgba(100,120,220,.7);
}

.ig-toggle-input:checked + .ig-toggle-knob::after {
  transform: translateX(16px);
}

/* ── Sub-controls (icon / text sections) ── */

.ig-sub-controls {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0 0;
}

.ig-hidden {
  display: none !important;
}

/* ── Icon type select (custom) ── */

.ig-select-hidden {
  display: none;
}

.ig-select-small {
  width: 100%;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .ig-body {
    flex-direction: column;
    overflow: auto;
  }

  .ig-preview-col {
    padding: 12px;
    flex: none;
    min-height: 160px;
  }

  .ig-canvas {
    max-height: 200px;
  }

  .ig-controls-col {
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid rgba(128,128,128,.2);
    overflow-y: visible;
  }
}

/* Save section */

.ig-save-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ig-save-name-input {
  flex: 1;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(128, 128, 128, .3);
  border-radius: 0.35rem;
  color: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
}

.ig-save-name-input::placeholder {
  color: var(--theme-secondary-text-color);
  opacity: 1;
}

/* Image picker modal */

.smi-img-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.smi-img-picker-panel {
  background: var(--theme-main-background-color);
  color: var(--theme-main-text-color);
  border-radius: 0.75rem;
  width: min(500px, 95vw);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.smi-img-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(128, 128, 128, .2);
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

.smi-img-picker-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity .15s;
}

.smi-img-picker-close:hover {
  opacity: 1;
}

.smi-img-picker-tabs {
  display: flex;
  border-bottom: 1px solid rgba(128, 128, 128, .2);
  flex-shrink: 0;
}

.smi-img-picker-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity .15s, border-color .15s;
}

.smi-img-picker-tab.is-active {
  opacity: 1;
  border-bottom-color: rgba(128, 128, 200, 0.7);
}

.smi-img-picker-pane {
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  overflow-y: auto;
  flex: 1;
}

.smi-img-picker-pane--hidden {
  display: none;
}

.smi-img-picker-hint {
  font-size: 0.85rem;
  opacity: 0.6;
  text-align: center;
  margin: 0;
}

.smi-img-picker-action-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(128, 128, 128, .35);
  background: rgba(255, 255, 255, .07);
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background .15s;
}

.smi-img-picker-action-btn:hover {
  background: rgba(255, 255, 255, .14);
}

.smi-img-picker-action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.smi-img-picker-status {
  font-size: 0.82rem;
  opacity: 0.6;
  margin: 0;
  text-align: center;
}

.smi-img-picker-create-action-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.smi-img-picker-config-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.smi-img-picker-config-empty {
  font-size: 0.85rem;
  opacity: 0.5;
  text-align: center;
  margin: 0.5rem 0;
}

.smi-img-picker-config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(128, 128, 128, .2);
  background: rgba(255, 255, 255, .04);
  transition: background .15s;
}

.smi-img-picker-config-item--current {
  border-color: rgba(128, 128, 200, 0.4);
}

.smi-img-picker-config-name {
  flex: 1;
  font-size: 0.9rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smi-img-picker-config-name:hover {
  text-decoration: underline;
}

.smi-img-picker-config-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.smi-img-picker-config-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem;
  opacity: 0.5;
  transition: opacity .15s, color .15s;
  font-size: 0.85rem;
}

.smi-img-picker-config-btn:hover {
  opacity: 1;
}

.smi-img-picker-config-btn--delete:hover {
  color: #e05555;
  opacity: 1;
}

.smi-img-picker-config-rename-input {
  flex: 1;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(128, 128, 128, .3);
  border-radius: 0.35rem;
  color: inherit;
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
}

.smi-img-picker-config-rename-input::placeholder {
  color: var(--theme-secondary-text-color);
  opacity: 1;
}
