.ig-card { padding: 28px; --ig-accent: var(--site-light); }
.ig-title-bar { background: linear-gradient(135deg, var(--site-dark) 0%, var(--site-dark-2) 100%); border-radius: 10px 10px 0 0; padding: 18px 24px; margin: -28px -28px 24px; }
.ig-title-bar h1 { color: #fff; margin: 0; font-size: 1.4em; text-align: center; }

.ig-intro { color: #4b5563; line-height: 1.7; margin: 0 0 20px; }
.ig-intro strong { color: var(--ig-accent); }

/* ===== Template selector ===== */
.ig-template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 24px; }
.ig-template-card { border: 2px solid #e5e7eb; border-radius: 10px; padding: 16px 10px; text-align: center; cursor: pointer; background: #fafbfc; transition: all .15s ease; }
.ig-template-card i { font-size: 1.6em; color: #9aa0aa; display: block; margin-bottom: 8px; }
.ig-template-card span { font-weight: 700; font-size: .88em; color: #374151; }
.ig-template-card:hover { border-color: var(--ig-accent); }
.ig-template-card.active { border-color: var(--ig-accent); background: #f0fdfa; }
.ig-template-card.active i, .ig-template-card.active span { color: var(--ig-accent); }

/* ===== Workspace: controls + live preview ===== */
.ig-workspace { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }

.ig-controls { border: 1px solid #eee; border-radius: 10px; padding: 18px 20px; background: #fafbfc; }
.ig-controls h3 { font-size: .8em; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; margin: 0 0 12px; }
.ig-controls h3.ig-fields-heading { margin-top: 20px; padding-top: 18px; border-top: 1px solid #e5e7eb; }

.ig-bg-toggle-row { display: flex; gap: 8px; margin-bottom: 14px; }
.ig-bg-toggle { flex: 1; border: 1px solid #ddd; background: #fff; border-radius: 7px; padding: 9px 6px; font-weight: 700; font-size: .85em; cursor: pointer; color: #4b5563; transition: all .15s ease; }
.ig-bg-toggle:hover { border-color: var(--ig-accent); }
.ig-bg-toggle.active { border-color: var(--ig-accent); background: var(--ig-accent); color: #fff; }

.ig-color-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ig-color-row label { font-size: .85em; font-weight: 600; color: #374151; flex: 1; }
.ig-color-row input[type="color"] { width: 40px; height: 40px; border: none; border-radius: 6px; padding: 0; cursor: pointer; background: none; flex-shrink: 0; }

.ig-select-row { margin-bottom: 4px; }
.ig-select-row label { display: block; font-size: .85em; font-weight: 600; color: #374151; margin-bottom: 6px; }
.ig-select-row select { width: 100%; border: 1px solid #ddd; border-radius: 7px; padding: 9px 10px; font-size: .9em; box-sizing: border-box; background: #fff; color: #23272f; }
.ig-select-row input[type="range"] { width: 100%; accent-color: var(--ig-accent); }

.ig-image-bg-row { margin-bottom: 14px; }
.ig-image-upload-label { display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px dashed #ddd; border-radius: 8px; padding: 14px 10px; font-size: .87em; font-weight: 600; color: #4b5563; cursor: pointer; text-align: center; transition: all .15s ease; margin-bottom: 10px; }
.ig-image-upload-label:hover { border-color: var(--ig-accent); color: var(--ig-accent); }
.ig-image-upload-label i { color: var(--ig-accent); }
.ig-image-bg-preview-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ig-image-bg-preview-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid #e5e7eb; flex-shrink: 0; }
.ig-image-remove-btn { border: 1px solid #ddd; background: #fff; color: var(--site-danger); border-radius: 7px; padding: 8px 12px; cursor: pointer; font-size: .85em; transition: all .15s ease; }
.ig-image-remove-btn:hover { border-color: var(--site-danger); background: var(--site-danger-bg); }

.hide { display: none !important; }

/* ===== Layers panel: add buttons, layer list, per-selected-layer editor ===== */
.ig-layer-add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.ig-layer-add-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #ddd; background: #fff; border-radius: 7px; padding: 10px 6px; font-weight: 700; font-size: .82em; cursor: pointer; color: #4b5563; text-align: center; transition: all .15s ease; }
.ig-layer-add-btn:hover { border-color: var(--ig-accent); color: var(--ig-accent); }
.ig-layer-add-btn i { color: var(--ig-accent); }

.ig-layer-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; max-height: 220px; overflow-y: auto; }
.ig-layer-empty { font-size: .82em; color: #9ca3af; text-align: center; padding: 10px 0; margin: 0; }
.ig-layer-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; border: 1px solid transparent; cursor: pointer; font-size: .85em; color: #374151; transition: all .15s ease; }
.ig-layer-row:hover { background: #f5f6f8; }
.ig-layer-row.active { border-color: var(--ig-accent); background: #f0fdfa; color: var(--ig-accent); }
.ig-layer-row i:first-child { width: 16px; text-align: center; color: #9aa0aa; flex-shrink: 0; }
.ig-layer-row.active i:first-child { color: var(--ig-accent); }
.ig-layer-row-thumb { width: 20px; height: 20px; object-fit: cover; border-radius: 4px; border: 1px solid #e5e7eb; flex-shrink: 0; }
.ig-layer-row-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-layer-del-btn { border: none; background: none; color: var(--site-danger); cursor: pointer; padding: 4px 6px; border-radius: 5px; flex-shrink: 0; opacity: .6; }
.ig-layer-del-btn:hover { opacity: 1; background: var(--site-danger-bg); }

.ig-layer-editor { border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; background: #fff; margin-bottom: 6px; }
.ig-layer-editor .ig-select-row { margin-bottom: 10px; }
.ig-layer-editor .ig-select-row label { font-weight: 600; }

/* Custom "shape" dropdown - styled to match a plain <select> (like the font
   dropdown) but with a small SVG thumbnail per option, which a native
   <select> can't render consistently across browsers. */
.ig-shape-dd { position: relative; }
.ig-shape-dd-btn { width: 100%; display: flex; align-items: center; gap: 8px; border: 1px solid #ddd; border-radius: 7px; padding: 9px 10px; font-size: .9em; box-sizing: border-box; background: #fff; color: #23272f; cursor: pointer; text-align: left; font-family: inherit; }
.ig-shape-dd-btn:hover { border-color: var(--ig-accent); }
.ig-shape-dd-btn .ig-shape-dd-label { flex: 1; }
.ig-shape-dd-caret { font-size: .8em; color: #9aa0aa; flex-shrink: 0; }
.ig-shape-dd-icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; color: var(--ig-accent); }
.ig-shape-dd-icon svg { width: 100%; height: 100%; }

/* position:fixed (not absolute) - the .card ancestor has overflow:hidden
   (for its rounded corners), which would otherwise clip an absolutely
   positioned menu the moment it extends past the card's edge. Fixed
   positioning is set relative to the viewport via JS (left/top/width) in
   buildShapeDropdown(), same technique the canvas right-click menu uses. */
.ig-shape-dd-menu { position: fixed; z-index: 60; background: #fff; border: 1px solid #ddd; border-radius: 7px; box-shadow: 0 8px 20px rgba(20,22,31,.12); padding: 4px; max-height: 260px; overflow-y: auto; }
.ig-shape-dd-option { width: 100%; display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 8px 8px; border-radius: 5px; font-size: .88em; color: #23272f; cursor: pointer; text-align: left; font-family: inherit; }
.ig-shape-dd-option:hover { background: #f5f6f8; }
.ig-shape-dd-option.active { background: #f0fdfa; color: var(--ig-accent); font-weight: 700; }
.ig-bold-row { display: flex; align-items: center; gap: 8px; font-size: .85em; font-weight: 600; color: #374151; margin: 4px 0 12px; cursor: pointer; }
.ig-layer-editor-delete { width: 100%; justify-content: center; display: flex; align-items: center; gap: 8px; }

.ig-text-input { width: 100%; border: 1px solid #ddd; border-radius: 7px; padding: 9px 10px; font-size: .92em; box-sizing: border-box; margin-bottom: 10px; color: #23272f; }
.ig-text-input:focus { outline: none; border-color: var(--ig-accent); }

.ig-subrow { display: flex; align-items: center; gap: 12px; }
.ig-size-control { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ig-size-control span:first-child { font-size: .78em; color: #6b7280; flex-shrink: 0; }
.ig-size-control input[type="range"] { flex: 1; min-width: 0; accent-color: var(--ig-accent); }
.ig-size-val { font-size: .78em; color: #6b7280; min-width: 40px; text-align: right; flex-shrink: 0; }
.ig-color-input { width: 34px; height: 34px; border: none; border-radius: 6px; padding: 0; cursor: pointer; background: none; flex-shrink: 0; }

/* ===== Live canvas preview ===== */
.ig-preview-wrap { display: flex; flex-direction: column; align-items: center; }
.ig-canvas-box { width: 100%; background: repeating-conic-gradient(#f1f3f6 0% 25%, #fff 0% 50%) 50% / 20px 20px; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; display: flex; align-items: center; justify-content: center; min-height: 320px; box-sizing: border-box; }
#igCanvas { max-width: 100%; max-height: 560px; height: auto; display: block; border-radius: 4px; box-shadow: 0 6px 18px rgba(0,0,0,.18); touch-action: none; }
.ig-drag-hint { font-size: .8em; color: #6b7280; margin: 10px 0 0; text-align: center; }
.ig-drag-hint i { color: var(--ig-accent); margin-right: 4px; }
.ig-canvas-dims { font-size: .8em; color: #9ca3af; margin-top: 4px; }

.ig-context-menu { position: fixed; z-index: 300; background: #fff; border: 1px solid #e2e4e9; border-radius: 8px; box-shadow: 0 10px 28px rgba(20,22,31,.18); padding: 6px; min-width: 170px; }
.ig-context-menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; border-radius: 6px; font-size: .88em; color: #23272f; cursor: pointer; font-family: inherit; }
.ig-context-menu button:hover { background: #f5f6f8; }
.ig-context-menu button i { width: 16px; text-align: center; color: var(--ig-accent); flex-shrink: 0; }
.ig-context-menu button.ig-context-danger { color: var(--site-danger); }
.ig-context-menu button.ig-context-danger i { color: var(--site-danger); }
.ig-context-menu button.ig-context-danger:hover { background: var(--site-danger-bg); }

.ig-btn { margin-top: 18px; border: none; border-radius: 8px; padding: 13px 26px; font-weight: 700; cursor: pointer; font-size: .98em; display: flex; align-items: center; gap: 8px; justify-content: center; width: 100%; max-width: 360px; background: var(--ig-accent); color: #fff; transition: filter .15s ease; }
.ig-btn:hover { filter: brightness(1.1); }
.ig-btn:disabled { opacity: .5; cursor: not-allowed; }

.ig-status { text-align: center; color: #6b7280; font-size: .88em; margin-top: 12px; min-height: 1.3em; }
.ig-status:empty { display: none; }

@media (max-width: 900px) {
    .ig-workspace { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .ig-template-grid { grid-template-columns: repeat(2, 1fr); }
}
