/* ═══════════════════════════════════════════════════════════════════════════
   templates.css — Template creation wizard, list grid, and editor shell
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Template Cards Grid ────────────────────────────────────────────────── */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.template-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .2s, box-shadow .2s;
    cursor: pointer;
}
.template-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 20px rgba(19,73,236,.15);
}

.template-card-thumb {
    aspect-ratio: 16/9;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.template-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.template-card-thumb-placeholder {
    font-size: 3rem;
    color: var(--color-text-muted);
    opacity: .4;
}

/* Live Fabric.js canvas in template card thumbnails */
.template-card-canvas-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.template-card-canvas-wrap canvas {
    display: block;
    flex-shrink: 0;
}
.template-card-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    gap: .75rem;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
}
.template-card:hover .template-card-thumb-overlay { opacity: 1; }

.template-card-body {
    padding: 1rem 1.125rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.template-card-name {
    font-weight: 600;
    font-size: .9375rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.template-card-meta {
    font-size: .8125rem;
    color: var(--color-text-muted);
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Purpose badge ──────────────────────────────────────────────────────── */
.purpose-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: rgba(19,73,236,.12);
    color: var(--color-primary);
}

/* ── Status pill ─────────────────────────────────────────────────────────── */
.status-draft     { background: rgba(255,193,7,.15);  color: #e6ac00; }
.status-published { background: rgba(40,199,111,.15); color: #28c76f; }
.status-archived  { background: rgba(130,134,139,.2); color: #82868b; }

/* ── Template card actions strip ─────────────────────────────────────────── */
.template-card-actions {
    display: flex;
    border-top: 1px solid var(--color-border);
    padding: .6rem 1rem;
    gap: .5rem;
}
.template-card-actions button {
    flex: 1;
    font-size: .8rem;
    padding: .35rem .5rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    background: transparent;
    color: var(--color-text-muted);
    transition: background .15s, color .15s;
}
.template-card-actions button:hover {
    background: var(--color-bg);
    color: var(--color-text);
}
.template-card-actions button.danger:hover {
    background: rgba(234,84,85,.15);
    color: #ea5455;
}

/* ── Creation Wizard ─────────────────────────────────────────────────────── */
.wizard-container {
    max-width: 700px;
    margin: 2rem auto;
}

.wizard-steps {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}
.wizard-step {
    flex: 1;
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .875rem;
    background: var(--color-surface);
    color: var(--color-text-muted);
    border-right: 1px solid var(--color-border);
    transition: background .2s, color .2s;
}
.wizard-step:last-child { border-right: none; }
.wizard-step.active {
    background: rgba(19,73,236,.1);
    color: var(--color-primary);
    font-weight: 600;
}
.wizard-step.done {
    background: rgba(40,199,111,.08);
    color: #28c76f;
}
.wizard-step-num {
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    background: var(--color-border);
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.wizard-step.active .wizard-step-num {
    background: var(--color-primary);
    color: #fff;
}
.wizard-step.done .wizard-step-num {
    background: #28c76f;
    color: #fff;
}

.wizard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 2rem;
}
/* Spacing between D-control form groups inside the wizard */
.wizard-card .d-form-group.wizard-form-group {
    margin-bottom: 1.25rem;
}
.wizard-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: .35rem;
    color: var(--color-text);
}
.wizard-subtitle {
    color: var(--color-text-muted);
    font-size: .9rem;
    margin-bottom: 1.75rem;
}

/* ── Purpose grid ─────────────────────────────────────────────────────────── */
.purpose-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.purpose-item {
    border: 2px solid var(--color-border);
    border-radius: 10px;
    padding: .875rem .75rem;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    align-items: flex-start;
}
.purpose-item:hover { border-color: var(--color-primary); }
.purpose-item.selected {
    border-color: var(--color-primary);
    background: rgba(19,73,236,.07);
}
.purpose-item-icon {
    font-size: 1.5rem;
}
.purpose-item-name {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.2;
}
.purpose-item-size {
    font-size: .7rem;
    color: var(--color-text-muted);
}

/* ── Size inputs ─────────────────────────────────────────────────────────── */
.size-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.size-row label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    width: 60px;
    flex-shrink: 0;
}
.size-row input[type=number] {
    width: 110px;
    padding: .5rem .75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: .9rem;
}
.size-row input[type=number]:focus {
    outline: none;
    border-color: var(--color-primary);
}
.size-divider { color: var(--color-text-muted); font-weight: 700; }
.size-unit { color: var(--color-text-muted); font-size: .8rem; }

/* ── Starting-point cards ─────────────────────────────────────────────────── */
.start-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.start-option {
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem 1rem;
    cursor: pointer;
    text-align: center;
    transition: border-color .2s, background .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
.start-option:hover { border-color: var(--color-primary); }
.start-option.selected {
    border-color: var(--color-primary);
    background: rgba(19,73,236,.07);
}
.start-option-icon {
    font-size: 2rem;
    color: var(--color-primary);
}
.start-option-label {
    font-size: .875rem;
    font-weight: 600;
    color: var(--color-text);
}
.start-option-desc {
    font-size: .75rem;
    color: var(--color-text-muted);
}

/* ── Wizard nav buttons ──────────────────────────────────────────────────── */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

/* ── Editor layout (legacy — kept for compatibility) ─────────────────────── */
.editor-shell {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
    gap: 0;
}

/* ── Editor layout v2 (APITemplate.io-style) ────────────────────────────── */
.editor-shell2 {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
    gap: 0;
    background: var(--color-bg);
}

/* ── Loading / error covers ─────────────────────────────────────────────── */
.editor-loading, .editor-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 64px);
    gap: 1rem;
    color: var(--color-text-muted);
    font-size: .95rem;
}
.editor-error-state .material-symbols-outlined { font-size: 3rem; color: #ea5455; }
.editor-loading .spinner-icon {
    font-size: 2.5rem;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Left tool sidebar ───────────────────────────────────────────────────── */
.editor-tools {
    width: 148px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    padding-bottom: 1rem;
}

.editor-tool-section {
    padding: .6rem .5rem .5rem;
    border-bottom: 1px solid var(--color-border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .3rem;
}
.editor-tool-section-title {
    grid-column: 1 / -1;
    font-size: .63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--color-text-muted);
    margin-bottom: .2rem;
}

/* Tool button */
.editor-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    padding: .5rem .25rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: .68rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    user-select: none;
}
.editor-tool-btn .material-symbols-outlined { font-size: 1.15rem; }
.editor-tool-btn:hover {
    background: rgba(19,73,236,.1);
    border-color: rgba(19,73,236,.45);
    color: var(--color-primary);
}
.editor-tool-btn:active { transform: scale(.96); }
.editor-tool-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Color row inside tool section */
.tool-color-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .75rem;
    color: var(--color-text-muted);
    padding: .25rem 0;
}
.tool-color-row input[type=color] {
    width: 32px; height: 26px;
    border-radius: 5px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 0 2px;
    cursor: pointer;
}

/* ── Centre area (canvas + toolbar + layers) ────────────────────────────── */
.editor-centre {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #12141f;
    overflow: hidden;
    position: relative;
}

/* Top action bar */
.editor-action-bar {
    height: 50px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: 0 .75rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Generic editor buttons */
.ed-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .75rem;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.ed-btn .material-symbols-outlined { font-size: 1rem; }

.ed-btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.ed-btn-primary:hover { background: #0f3cbf; }
.ed-btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.ed-btn-secondary {
    background: var(--color-bg);
    color: var(--color-text-muted);
    border-color: var(--color-border);
}
.ed-btn-secondary:hover { background: var(--color-surface); color: var(--color-text); }

.ed-btn-publish {
    background: #28c76f;
    color: #fff;
    border-color: #28c76f;
}
.ed-btn-publish:hover { background: #20a35a; }
.ed-btn-publish:disabled { opacity: .45; cursor: not-allowed; }

.ed-btn-danger {
    background: rgba(234,84,85,.12);
    color: #ea5455;
    border-color: rgba(234,84,85,.3);
}
.ed-btn-danger:hover { background: rgba(234,84,85,.2); }

/* Snap toggle */
.snap-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
    padding: 0 .4rem;
}
.snap-toggle input[type=checkbox] {
    accent-color: var(--color-primary);
    width: 15px; height: 15px;
    cursor: pointer;
}

/* Zoom controls */
.zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 .2rem;
}
.zoom-controls .ed-btn-icon {
    width: 28px; height: 28px;
    border-radius: 0;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background .15s, color .15s;
    flex-shrink: 0;
    font-size: .95rem;
}
.zoom-controls .ed-btn-icon:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}
.zoom-controls .ed-btn-icon .material-symbols-outlined {
    font-size: 1rem;
}
.zoom-pct-btn {
    min-width: 52px;
    height: 28px;
    border: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0 .3rem;
    text-align: center;
    transition: background .15s;
}
.zoom-pct-btn:hover { background: var(--color-surface-alt); }

/* Save status */
.save-status {
    font-size: .8rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: 0 .4rem;
    white-space: nowrap;
}
.save-status.saving { color: var(--color-primary); }
.save-status.saved  { color: #28c76f; }
.save-status.error  { color: #ea5455; }

/* Canvas scroll area */
.editor-canvas-scroll2 {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    position: relative; /* required for the init overlay */
}

/* Canvas initializing overlay — shown until Fabric.js is ready */
.canvas-init-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    background: rgba(18, 20, 31, 0.82);
    color: #fff;
    font-size: .9rem;
    font-weight: 500;
    pointer-events: none; /* pass through clicks so Blazor state can still update */
}
.canvas-init-overlay .spinner-icon {
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

#fabric-canvas-wrapper {
    position: relative;
    box-shadow: 0 12px 48px rgba(0,0,0,.6);
    border-radius: 2px;
}

/* ── Floating Layers panel ───────────────────────────────────────────────── */
.layers-panel {
    position: absolute;
    top: 60px;
    right: 8px;
    width: 240px;
    max-height: calc(100% - 80px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
}
.layers-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--color-border);
    font-size: .82rem;
    font-weight: 700;
    color: var(--color-text);
    flex-shrink: 0;
}
.layers-close-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: .2rem;
    border-radius: 4px;
}
.layers-close-btn:hover { color: var(--color-text); background: var(--color-bg); }
.layers-close-btn .material-symbols-outlined { font-size: 1rem; }
.layers-body {
    overflow-y: auto;
    flex: 1;
}
.layer-row {
    display: flex;
    align-items: center;
    gap: .2rem;
    padding: .3rem .5rem;
    cursor: pointer;
    font-size: .8rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid rgba(255,255,255,.03);
    transition: background .12s;
}
.layer-row:hover  { background: var(--color-bg); color: var(--color-text); }
.layer-row.active {
    background: rgba(19,73,236,.12);
    color: var(--color-primary);
    font-weight: 600;
}
.layer-row-drag { font-size: .95rem; opacity: .35; flex-shrink: 0; cursor: grab; }
.layer-icon-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: .15rem;
    border-radius: 4px;
    flex-shrink: 0;
    transition: background .12s;
    opacity: .6;
}
.layer-icon-btn:hover { opacity: 1; background: var(--color-bg); }
.layer-icon-btn .material-symbols-outlined { font-size: .95rem; }
.layer-icon-btn.layer-delete-btn:hover { color: #ea5455; }
.layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    font-size: .78rem;
    padding: 0 .2rem;
}

/* Layers toggle floating button */
.layers-toggle-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
    z-index: 40;
    transition: background .15s, color .15s;
}
.layers-toggle-btn:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.layers-toggle-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.layers-toggle-btn .material-symbols-outlined { font-size: 1.2rem; }

/* ── Right properties panel v2 ───────────────────────────────────────────── */
.editor-props2 {
    width: 278px;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* Tab bar */
.props-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    background: var(--color-bg);
}
.props-tab {
    flex: 1;
    padding: .55rem .2rem;
    font-size: .72rem;
    font-weight: 600;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.props-tab:hover { color: var(--color-text); }
.props-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--color-surface);
}

/* Props content scroll */
.editor-props2 > *:not(.props-tabs) {
    overflow-y: auto;
    flex: 1;
}

/* Empty state */
.props-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 2.5rem 1rem;
    color: var(--color-text-muted);
    font-size: .82rem;
    text-align: center;
}

/* Section block */
.props-section {
    padding: .6rem .75rem;
    border-bottom: 1px solid rgba(255,255,255,.05);
}

/* Basic row */
.props-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem 0;
    font-size: .8rem;
    color: var(--color-text-muted);
}
.props-row label {
    flex-shrink: 0;
    min-width: 62px;
    font-size: .76rem;
    color: var(--color-text-muted);
}
.props-row input[type=text],
.props-row input[type=number],
.props-row select {
    flex: 1;
    min-width: 0;
    padding: .28rem .45rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: .78rem;
}
.props-row input:focus, .props-row select:focus {
    outline: none;
    border-color: var(--color-primary);
}
.props-row input[type=checkbox] {
    accent-color: var(--color-primary);
    width: 14px; height: 14px;
    cursor: pointer;
}

/* Color row */
.props-color-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .28rem 0;
    font-size: .78rem;
}
.props-color-row label {
    min-width: 62px;
    font-size: .76rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.props-color-row input[type=color] {
    width: 32px; height: 26px;
    padding: 0 2px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    cursor: pointer;
}
.props-color-row span {
    font-size: .72rem;
    color: var(--color-text-muted);
}

/* Inline variable name input — appears alongside color/number property fields */
.var-name-input {
    margin-left: auto;
    width: 80px;
    min-width: 0;
    padding: .22rem .38rem;
    background: rgba(var(--color-primary-rgb, 99,102,241),.08);
    border: 1px dashed rgba(var(--color-primary-rgb, 99,102,241),.45);
    border-radius: 5px;
    color: var(--color-text);
    font-size: .7rem;
    opacity: .75;
    transition: opacity .15s, border-color .15s;
}
.var-name-input:focus {
    outline: none;
    opacity: 1;
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb, 99,102,241),.14);
}
.var-name-input::placeholder { color: var(--color-text-muted); opacity: .6; }

/* Variable binding rows in the Variables sub-section */
.props-var-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem 0;
    font-size: .78rem;
}
.props-var-row label {
    flex-shrink: 0;
    min-width: 72px;
    font-size: .74rem;
    color: var(--color-text-muted);
}
.props-var-row .var-name-input {
    flex: 1;
    width: auto;
    margin-left: 0;
}

/* Label row (no input) */
.props-label-row {
    font-size: .76rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: .2rem 0 .35rem;
}

/* Textarea */
.props-textarea {
    width: 100%;
    min-height: 60px;
    padding: .4rem .5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: .8rem;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.props-textarea:focus { outline: none; border-color: var(--color-primary); }

/* Stepper (- value +) */
.props-stepper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
    flex: 1;
}
.props-stepper button {
    width: 26px;
    background: var(--color-bg);
    border: none;
    color: var(--color-text-muted);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: background .12s, color .12s;
}
.props-stepper button:hover { background: rgba(19,73,236,.15); color: var(--color-primary); }
.props-stepper input[type=number] {
    flex: 1;
    min-width: 0;
    padding: .28rem .3rem;
    background: var(--color-bg);
    border: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: .78rem;
    text-align: center;
}
.props-stepper input[type=number]:focus { outline: none; background: rgba(19,73,236,.07); }

/* Align buttons */
.props-align-btns {
    display: flex;
    gap: .25rem;
}
.props-align-btns button {
    width: 30px; height: 28px;
    border-radius: 5px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem;
    transition: background .12s, color .12s;
}
.props-align-btns button .material-symbols-outlined { font-size: .95rem; }
.props-align-btns button:hover { background: var(--color-surface); color: var(--color-text); }
.props-align-btns button.active { background: rgba(19,73,236,.15); color: var(--color-primary); border-color: var(--color-primary); }

/* Triple toggle buttons (origin, style) */
.props-triple-btns {
    display: flex;
    flex: 1;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}
.props-triple-btns button {
    flex: 1;
    padding: .28rem .2rem;
    background: var(--color-bg);
    border: none;
    border-right: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: .72rem;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.props-triple-btns button:last-child { border-right: none; }
.props-triple-btns button:hover { background: var(--color-surface); color: var(--color-text); }
.props-triple-btns button.active { background: rgba(19,73,236,.15); color: var(--color-primary); font-weight: 700; }

/* Layer action buttons row */
.props-layer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .5rem .75rem;
}
.props-layer-actions .ed-btn {
    padding: .3rem .5rem;
    font-size: .72rem;
}
.props-layer-actions .ed-btn .material-symbols-outlined { font-size: .9rem; }

/* ── Fonts tab ────────────────────────────────────────────────────────────── */
.font-lib-header {
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .6rem 0 .35rem;
}
.font-search-input {
    width: 100%;
    padding: .35rem .5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    color: var(--color-text);
    font-size: .8rem;
    box-sizing: border-box;
    margin-bottom: .4rem;
}
.font-search-input:focus { outline: none; border-color: var(--color-primary); }
.font-list {
    height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    margin-top: .25rem;
}
.font-list-item {
    padding: .4rem .5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: .82rem;
    color: var(--color-text-muted);
    transition: background .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.font-list-item:hover { background: var(--color-bg); color: var(--color-text); }
.font-list-item.selected { background: rgba(19,73,236,.15); color: var(--color-primary); font-weight: 600; }
.font-variants-hint {
    font-size: .78rem;
    color: var(--color-text-muted);
    margin: .25rem 0 .5rem;
    font-style: italic;
}

/* ── Legacy compatibility (still used by sidebar-section title in old pages) */
.editor-sidebar {
    width: 280px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}
.editor-sidebar-section {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}
.editor-sidebar-section-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-text-muted);
    margin-bottom: .75rem;
}
.editor-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    overflow: hidden;
}
.editor-toolbar {
    height: 52px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 1rem;
    flex-shrink: 0;
}
.editor-toolbar-group {
    display: flex;
    gap: .25rem;
    align-items: center;
    padding: 0 .5rem;
    border-right: 1px solid var(--color-border);
}
.editor-toolbar-group:last-child { border-right: none; }
.toolbar-btn {
    width: 36px; height: 36px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
    font-size: 1.1rem;
}
.toolbar-btn:hover { background: var(--color-bg); color: var(--color-text); }
.toolbar-btn.active { background: rgba(19,73,236,.15); color: var(--color-primary); }
.editor-canvas-scroll { flex:1; overflow:auto; display:flex; align-items:center; justify-content:center; padding:2rem; }
.editor-props-panel {
    width: 260px;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}
.prop-row { display:flex; align-items:center; justify-content:space-between; padding:.5rem .875rem; gap:.75rem; }
.prop-label { font-size:.8rem; color:var(--color-text-muted); flex-shrink:0; }
.prop-row input[type=text], .prop-row input[type=number], .prop-row select {
    flex:1; min-width:0; padding:.35rem .5rem;
    background:var(--color-bg); border:1px solid var(--color-border); border-radius:6px;
    color:var(--color-text); font-size:.8125rem;
}
.prop-row input[type=color] { width:32px; height:28px; padding:0 2px; background:var(--color-bg); border:1px solid var(--color-border); border-radius:6px; cursor:pointer; }
.prop-row input:focus, .prop-row select:focus { outline:none; border-color:var(--color-primary); }
.layer-list { display:flex; flex-direction:column; gap:.2rem; padding:.5rem; }
.layer-item { display:flex; align-items:center; gap:.5rem; padding:.4rem .6rem; border-radius:6px; cursor:pointer; font-size:.82rem; color:var(--color-text-muted); transition:background .15s,color .15s; }
.layer-item:hover { background:var(--color-bg); color:var(--color-text); }
.layer-item.active { background:rgba(19,73,236,.12); color:var(--color-primary); font-weight:600; }
.layer-item .material-symbols-outlined { font-size:1rem; }
.color-swatches { display:flex; flex-wrap:wrap; gap:.4rem; padding:.5rem .875rem; }
.color-swatch { width:22px; height:22px; border-radius:4px; cursor:pointer; border:2px solid transparent; transition:border-color .15s,transform .15s; }
.color-swatch:hover { transform:scale(1.15); }
.color-swatch.selected { border-color:var(--color-primary); }
.font-format-row { display:flex; gap:.35rem; padding:.5rem .875rem; }
.fmt-btn { flex:1; padding:.35rem; border:1px solid var(--color-border); border-radius:6px; background:transparent; color:var(--color-text-muted); font-size:.85rem; font-weight:700; cursor:pointer; transition:background .15s,color .15s,border-color .15s; }
.fmt-btn:hover { background:var(--color-bg); color:var(--color-text); }
.fmt-btn.active { background:rgba(19,73,236,.15); color:var(--color-primary); border-color:var(--color-primary); }

/* ═══════════════════════════════════════════════════════════════════════════
   Playground (Module 14) — /generate/playground
   Two-panel layout: left = variable editor, right = live preview.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Initialisation loader ──────────────────────────────────────────────── */
.pg-init-loading {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 3rem 0;
    color: var(--color-text-muted);
    font-size: .95rem;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.pg-spin { animation: pgSpin 1s linear infinite; display: inline-flex; }
@keyframes pgSpin { to { transform: rotate(360deg); } }

/* ── Shell ───────────────────────────────────────────────────────────────── */
.playground-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);   /* leaves room for header + page header */
    min-height: 500px;
}

/* ── Config bar ──────────────────────────────────────────────────────────── */
.playground-config-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 1rem 0 .875rem;
    border-bottom: 1px solid var(--color-border-dark);
    flex-wrap: wrap;
}

.pg-config-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    flex: 1 1 200px;
    max-width: 340px;
}
.pg-config-field--sm { max-width: 140px; flex-basis: 100px; }

.pg-config-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
}
.pg-config-select { width: 100%; }

.pg-gen-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .55rem 1.25rem;
    font-size: .9rem;
    font-weight: 600;
    border-radius: 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background .2s, opacity .2s;
    align-self: flex-end;
    white-space: nowrap;
    flex-shrink: 0;
}
.pg-gen-btn:hover:not(:disabled) { background: var(--color-primary-hover); }
.pg-gen-btn:disabled { opacity: .45; cursor: not-allowed; }
.pg-btn-icon { font-size: 1.1rem; }

.pg-alert { margin-top: .75rem; }

/* ── Body ────────────────────────────────────────────────────────────────── */
.playground-body {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
    border: 1px solid var(--color-border-dark);
    border-top: none;
    border-radius: 0 0 12px 12px;
    background: var(--color-bg-dark);
}

/* ── Left panel ──────────────────────────────────────────────────────────── */
.playground-left {
    border-right: 1px solid var(--color-border-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-surface-dark);
}

/* Empty state when no template selected */
.pg-left-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: .65rem;
    color: var(--color-text-muted);
    font-size: .9rem;
    padding: 2rem;
    text-align: center;
}
.pg-left-empty-icon { font-size: 2.5rem; opacity: .4; }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
.pg-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border-dark);
    background: var(--color-bg-dark);
    flex-shrink: 0;
}
.pg-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .55rem .5rem;
    font-size: .8rem;
    font-weight: 600;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.pg-tab:hover { color: #c9d1e0; }
.pg-tab--active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--color-surface-dark);
}
.pg-tab-icon { font-size: .95rem; }
.pg-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: rgba(19,73,236,.25);
    color: var(--color-primary);
    font-size: .7rem;
    font-weight: 700;
}

/* ── No-vars state ───────────────────────────────────────────────────────── */
.pg-no-vars {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: .88rem;
    flex: 1;
}
.pg-no-vars .material-symbols-outlined { font-size: 1.75rem; opacity: .5; }
.pg-no-vars-hint { font-size: .8rem; margin-top: .25rem; }

/* ── Variable form ───────────────────────────────────────────────────────── */
.pg-vars-list {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .875rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.pg-var-row {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.pg-var-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .825rem;
    font-weight: 600;
    color: #c9d1e0;
}
.pg-var-key {
    font-size: .7rem;
    font-weight: 400;
    color: var(--color-text-muted);
    font-family: 'Courier New', monospace;
    background: rgba(255,255,255,.05);
    padding: .1rem .35rem;
    border-radius: 4px;
}

/* Color input row */
.pg-color-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.pg-color-swatch {
    width: 36px;
    height: 36px;
    padding: 1px 2px;
    border: 1px solid var(--color-border-dark);
    border-radius: 7px;
    background: var(--color-bg-dark);
    cursor: pointer;
    flex-shrink: 0;
}
.pg-color-text { flex: 1; font-family: monospace; font-size: .8rem; }

/* ── JSON editor tab ─────────────────────────────────────────────────────── */
.pg-json-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: .75rem .875rem;
    gap: .5rem;
    overflow: hidden;
}
.pg-json-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.pg-json-hint {
    font-size: .72rem;
    font-family: monospace;
    color: var(--color-text-muted);
    background: rgba(255,255,255,.05);
    padding: .15rem .45rem;
    border-radius: 5px;
}
.pg-json-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .76rem;
    background: none;
    border: 1px solid var(--color-border-dark);
    border-radius: 6px;
    color: var(--color-text-muted);
    padding: .25rem .55rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.pg-json-reset-btn .material-symbols-outlined { font-size: .9rem; }
.pg-json-reset-btn:hover {
    background: rgba(255,255,255,.06);
    color: #c9d1e0;
}
.pg-json-textarea {
    flex: 1;
    width: 100%;
    padding: .65rem .75rem;
    background: #0d101a;
    border: 1px solid var(--color-border-dark);
    border-radius: 8px;
    color: #a8d4ff;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: .78rem;
    line-height: 1.55;
    resize: none;
    overflow-y: auto;
    box-sizing: border-box;
}
.pg-json-textarea:focus {
    outline: none;
    border-color: rgba(19,73,236,.55);
}

/* ── Left footer ─────────────────────────────────────────────────────────── */
.pg-left-footer {
    padding: .55rem .875rem;
    border-top: 1px solid var(--color-border-dark);
    font-size: .75rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
    background: var(--color-bg-dark);
}
.pg-left-footer-icon { font-size: .9rem; }

/* ── Right preview panel ─────────────────────────────────────────────────── */
.playground-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: #12141f;
}

/* Generation error */
.pg-gen-error { margin: .75rem; }

/* Loading state */
.pg-preview-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: var(--color-text-muted);
    font-size: .9rem;
    text-align: center;
}
.pg-preview-spinner { font-size: 2.5rem; color: var(--color-primary); }
.pg-preview-loading-hint { font-size: .78rem; max-width: 300px; }

/* Empty state */
.pg-preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
}
.pg-preview-empty-icon { font-size: 4rem; opacity: .2; }
.pg-preview-empty-title { font-size: 1rem; font-weight: 600; color: #8490a8; }
.pg-preview-empty-hint { font-size: .85rem; }

/* Preview image */
.pg-preview-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    min-height: 0;
}
.pg-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,.65);
}

/* Meta bar below preview */
.pg-preview-meta {
    padding: .6rem 1rem;
    border-top: 1px solid var(--color-border-dark);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    background: var(--color-surface-dark);
    flex-shrink: 0;
}
.pg-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 20px;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--color-border-dark);
    font-size: .75rem;
    color: var(--color-text-muted);
}
.pg-meta-icon { font-size: .85rem; }
.pg-download-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .75rem;
    border-radius: 6px;
    background: rgba(19,73,236,.15);
    color: var(--color-primary);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(19,73,236,.3);
    margin-left: auto;
    transition: background .15s;
}
.pg-download-btn:hover { background: rgba(19,73,236,.28); }
.pg-download-btn .material-symbols-outlined { font-size: .95rem; }

/* ── Final CTA banner ───────────────────────────────────────────────────── */
.pg-final-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: .75rem 1rem 0;
    padding: .9rem 1.1rem;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(19,73,236,.12), rgba(99,102,241,.08));
    border: 1px solid rgba(19,73,236,.3);
    flex-wrap: wrap;
}
.pg-final-cta-text {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
}
.pg-final-cta-icon {
    font-size: 1.4rem;
    color: var(--color-primary);
    flex-shrink: 0;
    margin-top: .1rem;
}
.pg-final-cta-title {
    font-weight: 600;
    font-size: .88rem;
    color: var(--color-text);
    margin: 0 0 .15rem;
}
.pg-final-cta-hint {
    font-size: .78rem;
    color: var(--color-text-muted);
    margin: 0;
}
.pg-final-cta-err {
    color: var(--color-danger);
    font-weight: 500;
}
.pg-final-btn {
    white-space: nowrap;
    padding: .5rem 1.1rem;
    font-size: .82rem;
    flex-shrink: 0;
}

/* ── Final (clean) result section ───────────────────────────────────────── */
.pg-final-result {
    margin: .75rem 1rem 0;
    border-radius: 10px;
    border: 1px solid var(--color-success, #22c55e);
    overflow: hidden;
}
.pg-final-result-hdr {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .9rem;
    background: rgba(34,197,94,.1);
    font-size: .82rem;
    font-weight: 600;
    color: var(--color-success, #22c55e);
}
.pg-final-result-hdr .pg-download-btn {
    margin-left: auto;
    font-size: .78rem;
    padding: .25rem .65rem;
}

/* ── Responsive: stack panels on small screens ──────────────────────────── */
@media (max-width: 768px) {
    .playground-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 340px;
    }
    .playground-left { border-right: none; border-bottom: 1px solid var(--color-border-dark); }
    .playground-shell { height: auto; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SINGLE GENERATE PAGE  (sg-*)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Loading skeleton */
.sg-loading {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 2rem;
    color: var(--color-text-muted, #94a3b8);
    font-size: .9rem;
}

/* Two-column shell */
.sg-shell {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    min-height: 620px;
    border: 1px solid var(--color-border-dark, #1e293b);
    border-radius: var(--radius-card, .75rem);
    overflow: hidden;
    background: var(--color-surface, #0f172a);
}

/* Left config column */
.sg-left {
    border-right: 1px solid var(--color-border-dark, #1e293b);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Right result column */
.sg-right {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--color-bg-alt, #0a0f1a);
}

/* Section block inside left column */
.sg-section {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--color-border-dark, #1e293b);
}
.sg-section:last-of-type { border-bottom: none; }

.sg-section-title {
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-text-muted, #94a3b8);
    margin: 0 0 .75rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.sg-section-icon { font-size: 1rem; opacity: .7; }

.sg-select { width: 100%; }

.sg-alert { margin-top: .5rem; }

/* Format buttons */
.sg-format-btns {
    display: flex;
    gap: .4rem;
}
.sg-fmt-btn {
    flex: 1;
    padding: .35rem .5rem;
    border: 1px solid var(--color-border-dark, #1e293b);
    border-radius: .4rem;
    background: transparent;
    color: var(--color-text-muted, #94a3b8);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.sg-fmt-btn:hover { background: var(--color-surface-hover, #1e293b); color: var(--color-text, #e2e8f0); }
.sg-fmt-btn--active {
    background: var(--color-primary, #6366f1);
    border-color: var(--color-primary, #6366f1);
    color: #fff;
}

/* Variable count badge */
.sg-var-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: var(--color-primary, #6366f1);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    margin-left: auto;
}

/* Variable rows */
.sg-vars-list { display: flex; flex-direction: column; gap: .75rem; }
.sg-var-row { display: flex; flex-direction: column; gap: .3rem; }
.sg-var-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
}
.sg-var-type-tag {
    display: inline-flex;
    align-items: center;
    padding: .1rem .4rem;
    border-radius: 3px;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .04em;
    background: var(--color-primary-muted, rgba(99,102,241,.15));
    color: var(--color-primary-light, #818cf8);
}
.sg-var-key { color: var(--color-text, #e2e8f0); font-weight: 500; }

/* "No variables" notice */
.sg-no-vars {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--color-text-muted, #94a3b8);
    font-size: .85rem;
}

/* Generate action row */
.sg-actions {
    padding: 1.1rem 1.25rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.sg-gen-btn { width: 100%; justify-content: center; gap: .45rem; }
.sg-credit-note {
    font-size: .75rem;
    color: var(--color-text-muted, #94a3b8);
    display: flex;
    align-items: flex-start;
    gap: .3rem;
    line-height: 1.4;
    margin: 0;
}
.sg-credit-icon { font-size: .9rem; flex-shrink: 0; margin-top: .05rem; }
.sg-credit-note a { color: var(--color-primary-light, #818cf8); }

/* Error inside right panel */
.sg-gen-error { margin-bottom: 0; }
.sg-topup-link { color: var(--color-warning, #f59e0b) !important; font-weight: 600; text-decoration: none; }
.sg-topup-link:hover { text-decoration: underline; }

/* Result card */
.sg-result-wrap {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    flex: 1;
}
.sg-result-hdr {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--color-success, #22c55e);
}
.sg-result-ok-icon { font-size: 1.1rem; }
.sg-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-left: auto;
    padding: .3rem .75rem;
    border: 1px solid var(--color-success, #22c55e);
    border-radius: .4rem;
    color: var(--color-success, #22c55e);
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}
.sg-dl-btn:hover { background: rgba(34,197,94,.1); }
.sg-dl-btn .material-symbols-outlined { font-size: .95rem; }
.sg-result-img {
    max-width: 100%;
    border-radius: .5rem;
    border: 1px solid var(--color-border-dark, #1e293b);
    background: #000;
}
.sg-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .25rem;
}

/* Responsive: stack on small screens */
@media (max-width: 820px) {
    .sg-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .sg-left { border-right: none; border-bottom: 1px solid var(--color-border-dark, #1e293b); }
}

/* ── Editor asset picker modal (aspk-*) ─────────────────────────────────── */

.aspk-backdrop {
    position: fixed;
    inset: 0;
    z-index: 420;
    background: rgba(3, 7, 18, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.aspk-modal {
    width: min(980px, 96vw);
    max-height: 88vh;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aspk-header {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.aspk-title {
    margin: 0;
    color: #e2e8f0;
    font-size: .98rem;
    font-weight: 700;
}

.aspk-subtitle {
    margin: .2rem 0 0;
    color: #94a3b8;
    font-size: .82rem;
}

.aspk-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.aspk-close:hover {
    color: #e2e8f0;
}

.aspk-toolbar {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
    padding: .75rem 1.1rem;
    border-bottom: 1px solid #1e293b;
}

.aspk-search {
    width: min(320px, 100%);
    height: 36px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #111827;
    color: #e2e8f0;
    padding: 0 .8rem;
    outline: none;
}

.aspk-search:focus {
    border-color: #6366f1;
}

.aspk-pill {
    height: 32px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #111827;
    color: #94a3b8;
    font-size: .75rem;
    font-weight: 600;
    padding: 0 .7rem;
    cursor: pointer;
}

.aspk-pill--active {
    border-color: #6366f1;
    color: #c7d2fe;
    background: #1e1b4b;
}

.aspk-body {
    padding: .9rem 1.1rem;
    overflow: auto;
    min-height: 220px;
}

.aspk-empty {
    color: #94a3b8;
    font-size: .88rem;
    text-align: center;
    padding: 2rem 1rem;
}

.aspk-empty--error {
    color: #fca5a5;
}

.aspk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .55rem;
}

.aspk-card {
    border: 1px solid #334155;
    background: #111827;
    border-radius: 10px;
    padding: .65rem .7rem;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: .6rem;
}

.aspk-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.aspk-card-icon .material-symbols-outlined {
    font-size: 1.15rem;
    color: #818cf8;
}

.aspk-card-icon .aspk-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.aspk-card-meta {
    min-width: 0;
}

.aspk-name {
    margin: 0;
    color: #e2e8f0;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aspk-type {
    margin: .2rem 0 0;
    color: #94a3b8;
    font-size: .72rem;
}

.aspk-use {
    height: 30px;
    border-radius: 7px;
    border: 1px solid #6366f1;
    background: #312e81;
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    padding: 0 .7rem;
    cursor: pointer;
}

.aspk-use:hover {
    background: #4338ca;
}

.aspk-pager {
    border-top: 1px solid #1e293b;
    padding: .7rem 1.1rem 1rem;
    display: flex;
    gap: .35rem;
    align-items: center;
    justify-content: center;
}

.aspk-page-btn {
    min-width: 33px;
    height: 32px;
    border-radius: 7px;
    border: 1px solid #334155;
    background: #111827;
    color: #94a3b8;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0 .55rem;
}

.aspk-page-btn--active {
    color: #fff;
    background: #312e81;
    border-color: #6366f1;
}

.aspk-page-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .aspk-grid {
        grid-template-columns: 1fr;
    }
}
