/* ═══════════════════════════════════════════════════════════════════
   StreamersForge — UI Components
   Buttons, cards, modals, forms, toasts, badges
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Primary */
.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-sm), 0 0 0 0 var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

/* Secondary */
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--border-strong);
}

/* Ghost */
.btn-ghost {
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Danger */
.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: var(--shadow-md);
}

/* Twitch */
.btn-twitch {
    background: var(--twitch);
    color: white;
    font-weight: 700;
}

.btn-twitch:hover:not(:disabled) {
    background: var(--twitch-hover);
    box-shadow: 0 0 20px rgba(145, 70, 255, 0.3);
}

/* Icon button */
.btn-icon {
    padding: var(--space-2);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
}

/* Button sizes */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
}

.btn-xl {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
    border-radius: var(--radius-lg);
}

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-default);
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
}

.card-interactive {
    cursor: pointer;
    transition: all var(--transition-base);
}

.card-interactive:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.card-active {
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-glow);
}

/* ─── Form Controls ──────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.form-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.form-input:hover {
    border-color: var(--border-strong);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-input::placeholder {
    color: var(--text-disabled);
}

.form-input-sm {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
}

/* Ensure text selection is visible in inputs */
.form-input::selection,
.form-input-sm::selection,
.form-number::selection {
    background: var(--accent);
    color: #ffffff;
}

.form-input,
.form-input-sm,
.form-number {
    user-select: text;
    -webkit-user-select: text;
}

/* Number input */
.form-number {
    width: 70px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

/* Hide number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Select */
.form-select {
    appearance: none;
    padding-right: var(--space-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* Color picker */
.form-color {
    width: 36px;
    height: 36px;
    padding: 2px;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.form-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.form-color::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

/* Range slider */
.form-range {
    width: 100%;
    height: 4px;
    appearance: none;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-glow);
}

/* Inline field */
.form-inline {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.form-inline .form-label {
    text-transform: none;
    letter-spacing: normal;
    min-width: fit-content;
}

/* ─── Modal (legacy — kept for backward compat) ─────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    animation: fadeIn var(--transition-fast);
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: calc(var(--z-modal) + 1);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    animation: scaleIn var(--transition-spring);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: var(--text-lg);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

/* ═════════════════════════════════════════════════════════════════════
   SF Modal — Unified Modal Design System
   ═════════════════════════════════════════════════════════════════════ */

/* Backdrop */
.sf-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal, 1000);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

/* Dialog container */
.sf-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 460px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sf-modal--wide {
    width: 640px;
}

/* Header */
.sf-modal-header {
    padding: 24px 28px 0;
}

.sf-modal-header h3 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
    line-height: 1.3;
}

.sf-modal-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* Body */
.sf-modal-body {
    padding: 20px 28px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Footer */
.sf-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-3);
    padding: 16px 28px 24px;
}

/* ─── List layout (Add Layer, Add Animation, etc.) ──────────────── */
.sf-modal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sf-modal-list-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.15s ease;
}

.sf-modal-list-item:hover:not(.disabled) {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.sf-modal-list-item.active {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.sf-modal-list-item.disabled {
    opacity: 0.5;
    cursor: default;
}

.sf-modal-list-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.sf-modal-list-item:hover:not(.disabled) .sf-modal-list-icon {
    background: var(--accent-muted);
    color: var(--accent-light);
}

.sf-modal-list-content {
    flex: 1;
    min-width: 0;
}

.sf-modal-list-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.sf-modal-list-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.3;
}

.sf-modal-list-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ─── Grid layout (Trigger types, size presets) ─────────────────── */
.sf-modal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.sf-modal-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: 16px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.sf-modal-grid-item:hover:not(.disabled) {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.sf-modal-grid-item.active {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.sf-modal-grid-item.disabled {
    opacity: 0.5;
    cursor: default;
}

.sf-modal-grid-icon {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.sf-modal-grid-item:hover:not(.disabled) .sf-modal-grid-icon {
    color: var(--accent-light);
}

.sf-modal-grid-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.sf-modal-grid-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.3;
}

.sf-modal-grid-hint {
    font-size: 10px;
    color: var(--text-disabled);
    font-style: italic;
    margin-top: -2px;
}

.sf-modal-grid-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.sf-modal-grid-input.hidden {
    visibility: hidden;
}

.sf-modal-grid-input-pair {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
}

.sf-modal-grid-input-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sf-modal-grid-input .form-number {
    width: 100%;
    font-size: 11px;
    padding: 4px 6px;
}

.sf-modal-grid-input-x {
    display: none;
}

/* ─── Form row (Scale, Dimensions, etc.) ────────────────────────── */
.sf-modal-field {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.sf-modal-field-label {
    width: 110px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.sf-modal-field-control {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ─── Dimension comparison boxes ────────────────────────────────── */
.sf-modal-dims {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.sf-modal-dim-box {
    flex: 1;
    text-align: center;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
}

.sf-modal-dim-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.sf-modal-dim-value {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.sf-modal-dim-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sf-modal-dims-arrow {
    display: flex;
    align-items: center;
    margin-top: 18px;
    opacity: 0.4;
}

/* ─── Separator ─────────────────────────────────────────────────── */
.sf-modal-separator {
    height: 1px;
    background: var(--border-subtle);
    margin: 16px 0;
}

/* ─── Radio group ───────────────────────────────────────────────── */
.sf-modal-radio-group {
    display: flex;
    gap: var(--space-3);
}

.sf-modal-radio {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.sf-modal-radio:hover {
    border-color: var(--accent);
}

.sf-modal-radio:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-muted);
    color: var(--text-primary);
}

.sf-modal-radio input[type="radio"] {
    accent-color: var(--accent);
}

/* ═════════════════════════════════════════════════════════════════════
   Color Field — Compact swatch + hex + edit button
   ═════════════════════════════════════════════════════════════════════ */
.color-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-field-swatch {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-default);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s ease;
}

.color-field-swatch:hover {
    border-color: var(--text-secondary);
}

.color-field-label {
    flex: 1;
    min-width: 0;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 28px;
    user-select: none;
}

/* ═════════════════════════════════════════════════════════════════════
   Color Picker Modal
   ═════════════════════════════════════════════════════════════════════ */
.cpicker-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 16px;
}

.cpicker-tab {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.cpicker-tab:hover {
    color: var(--text-secondary);
}

.cpicker-tab.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

.cpicker-panel {
    display: none;
    height: 220px;
    overflow-y: auto;
}

.cpicker-panel.active {
    display: block;
}

/* Variations tab */
.cpicker-var-mode {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.cpicker-var-mode-btn {
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cpicker-var-mode-btn:hover {
    border-color: var(--text-muted);
}

.cpicker-var-mode-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.cpicker-var-columns {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.cpicker-var-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 38px;
}

.cpicker-var-col-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 38px;
    text-align: center;
}

.cpicker-var-swatch {
    width: 34px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.12s ease;
    padding: 0;
    background: none;
    position: relative;
}

.cpicker-var-swatch:hover {
    transform: scale(1.1);
    border-color: var(--text-secondary);
}

.cpicker-var-swatch.selected {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 2px var(--accent);
}

.cpicker-var-pct {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 7px;
    font-weight: 700;
    color: rgba(255, 255, 255, .8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
    pointer-events: none;
}

/* Swatch grid inside modal */
.cpicker-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cpicker-swatch {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.12s ease;
    padding: 0;
    background: none;
}

.cpicker-swatch:hover {
    transform: scale(1.15);
    border-color: var(--text-secondary);
}

.cpicker-swatch.selected {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 2px var(--accent);
}

.cpicker-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 12px 0 6px;
}

.cpicker-section-label:first-child {
    margin-top: 0;
}

/* Preview row */
.cpicker-preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-top: 14px;
}

.cpicker-preview-swatch {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-default);
    flex-shrink: 0;
}

.cpicker-preview-hex {
    font-family: var(--font-mono);
    font-size: var(--text-md);
    color: var(--text-primary);
    font-weight: 600;
}

/* Full-color picker tab */
.cpicker-native-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cpicker-native-input {
    width: 100%;
    height: 160px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.cpicker-native-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.cpicker-native-input::-webkit-color-swatch {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

/* Hex input tab */
.cpicker-hex-input {
    width: 100%;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    text-align: center;
    letter-spacing: 0.05em;
}

/* Add to theme button */
.cpicker-add-theme {
    width: 100%;
    margin-top: 8px;
}

/* ─── Font Picker Modal ──────────────────────────────────── */
.fpicker-preview {
    font-size: 28px;
    line-height: 1.3;
    padding: 16px 12px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    text-align: center;
    word-break: break-word;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: font-family .15s, font-weight .15s, font-style .15s;
}

.fpicker-attrs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.fpicker-attr-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.fpicker-attr-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
}

.fpicker-attr-select {
    font-size: var(--text-xs) !important;
    padding: 4px 6px !important;
    min-width: 110px;
}

.fpicker-attr-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, background .15s;
}

.fpicker-attr-btn:hover {
    border-color: var(--accent);
}

.fpicker-attr-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    -webkit-text-stroke-color: #fff !important;
}

.fpicker-search {
    width: 100%;
    margin-bottom: 8px;
    font-size: var(--text-sm) !important;
}

.fpicker-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 6px;
}

.fpicker-cat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 8px 6px 3px;
}

.fpicker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: background .12s;
}

.fpicker-item:hover {
    background: var(--bg-surface);
}

.fpicker-item.selected {
    background: var(--accent);
    color: #fff;
}

.fpicker-item.fpicker-locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.fpicker-item.fpicker-locked:hover {
    opacity: 0.7;
    background: var(--bg-tertiary);
}

.fpicker-lock {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--accent-light);
    background: var(--accent-muted);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Font display row in properties panel */
.font-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .15s;
}

.font-field:hover {
    border-color: var(--accent);
}

.font-field-name {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-field-meta {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Settings palette section */
.settings-palette-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.settings-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-palette-item .settings-palette-swatch {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-default);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s ease;
}

.settings-palette-item .settings-palette-swatch:hover {
    border-color: var(--accent);
}

.settings-palette-item .settings-palette-name {
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: var(--text-xs);
    outline: none;
    transition: border-color 0.15s ease;
}

.settings-palette-item .settings-palette-name:focus {
    border-color: var(--accent);
}

.settings-palette-item .settings-palette-remove {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    border: 1px solid transparent;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.4;
    transition: all 0.15s ease;
}

.settings-palette-item:hover .settings-palette-remove {
    opacity: 1;
}

.settings-palette-item .settings-palette-remove:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ─── Toast ──────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-left: 6px solid var(--accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideDown var(--transition-slow);
    min-width: 280px;
    pointer-events: auto;
    font-size: var(--text-md);
}

.toast-success {
    border-left-color: var(--success);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-message {
    font-size: var(--text-md);
    color: var(--text-primary);
}

.toast-close {
    margin-left: auto;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-xl);
    line-height: 1;
}

/* ─── Badge ──────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--accent-muted);
    color: var(--accent-light);
}

.badge-success {
    background: var(--success-muted);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-muted);
    color: var(--warning);
}

.badge-pro {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-weight: 700;
}

/* ─── Divider ────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-4) 0;
}

/* ─── Tooltip ────────────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--text-primary);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ─── Loader ─────────────────────────────────────────────────────── */
.loader {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loader-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* ─── Empty State ────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--text-sm);
    max-width: 300px;
}

/* ─── Context Menu ───────────────────────────────────────────────── */
.context-menu {
    position: absolute;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    min-width: 160px;
    padding: var(--space-1);
    animation: scaleIn var(--transition-fast);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--accent-muted);
    color: var(--text-primary);
}

.context-menu-item.danger:hover {
    background: var(--danger-muted);
    color: var(--danger);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-1) 0;
}

/* ─── Avatar ─────────────────────────────────────────────────────── */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 24px;
    height: 24px;
}

.avatar-lg {
    width: 40px;
    height: 40px;
}

.avatar-xl {
    width: 48px;
    height: 48px;
}

/* ─── Tabs ───────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0;
}

.tab {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

/* ═════════════════════════════════════════════════════════════════════
   Preview Modal — Overlay Preview with Command Bar
   ═════════════════════════════════════════════════════════════════════ */

.preview-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: var(--z-modal, 1000);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

/* Command bar at top */
.preview-modal-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
    z-index: 2;
}

.preview-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.preview-bar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.preview-bar-triggers {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 2px 0;
}

.preview-bar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.preview-bar-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.preview-bar-empty {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Animation group in command bar */
.preview-anim-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    border-right: 1px solid var(--border-subtle);
    padding-right: 12px;
    flex-shrink: 0;
}

.preview-anim-group:last-child {
    border-right: none;
    padding-right: 0;
}

.preview-anim-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-anim-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Play button (generic trigger) */
.preview-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: var(--accent-muted);
    color: var(--accent-light);
    border: 1px solid var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
}

.preview-play-btn:hover:not(.cooldown) {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-glow);
}

.preview-play-btn.cooldown {
    opacity: 0.5;
    pointer-events: none;
}

/* Trigger button (specific trigger) */
.preview-trigger-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--trigger-color, var(--accent)) 15%, transparent);
    color: var(--trigger-color, var(--accent-light));
    border: 1px solid color-mix(in srgb, var(--trigger-color, var(--accent)) 40%, transparent);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.preview-trigger-btn:hover:not(.cooldown) {
    background: color-mix(in srgb, var(--trigger-color, var(--accent)) 30%, transparent);
    border-color: var(--trigger-color, var(--accent));
    box-shadow: 0 0 12px color-mix(in srgb, var(--trigger-color, var(--accent)) 25%, transparent);
}

.preview-trigger-btn.cooldown {
    opacity: 0.5;
    pointer-events: none;
}

/* Preview body (iframe area) */
.preview-modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
}

.preview-iframe {
    border: none;
    background: transparent;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* ─── Variable Insertion Pills ────────────────────────────────── */
.prop-var-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.prop-var-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-light);
    background: var(--accent-muted);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.12s ease;
    line-height: 1.6;
}

.prop-var-pill:hover {
    background: color-mix(in srgb, var(--accent) 25%, transparent);
    border-color: var(--accent);
    color: white;
}

/* ─── Read-only Text Display ──────────────────────────────────── */
.prop-text-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-height: 32px;
}

.prop-text-value {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
    line-height: 1.4;
}

.prop-text-edit {
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   Upgrade Modal — Plus subscription CTA overlay
   ═══════════════════════════════════════════════════════════════════ */

.upgrade-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.upgrade-modal-overlay.active {
    opacity: 1;
}

.upgrade-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl), var(--shadow-glow-lg);
    padding: var(--space-10) var(--space-8);
    max-width: 400px;
    width: 90%;
    text-align: center;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.upgrade-modal-overlay.active .upgrade-modal {
    transform: scale(1) translateY(0);
}

.upgrade-modal-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    border: none;
    cursor: pointer;
}

.upgrade-modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.upgrade-modal-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-4);
}

.upgrade-modal-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-2);
}

.upgrade-modal-feature {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.upgrade-modal-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-6);
}

.upgrade-modal-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-1);
    margin-bottom: var(--space-6);
}

.upgrade-modal-amount {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-primary);
}

.upgrade-modal-period {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.upgrade-modal-cta {
    width: 100%;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.upgrade-modal-note {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ─── Plus Badge ──────────────────────────────────────────────────── */
.badge-plus {
    background: linear-gradient(135deg, var(--accent), #c084fc);
    color: white;
    font-weight: 700;
}

/* ─── Locked Feature Indicator ────────────────────────────────────── */
.tier-locked {
    position: relative;
    cursor: pointer;
}

.tier-locked::after {
    content: '⚡';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 10px;
    opacity: 0.8;
}

.tier-lock-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: auto;
}

.tier-lock-icon::before {
    content: '🔒';
    font-size: 10px;
}

/* ─── Font picker Plus overlay ────────────────────────────────────── */
.font-option-locked {
    opacity: 0.5;
    cursor: pointer;
}

.font-option-locked:hover {
    opacity: 0.7;
}

.font-option-locked .plus-badge-inline {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    background: linear-gradient(135deg, var(--accent), #c084fc);
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 8px;
    flex-shrink: 0;
}