.color-presets {
    border: 1px solid var(--border-muted, rgba(99, 102, 241, 0.12));
    border-radius: 1rem;
    padding: 1rem;
    margin-top: 1rem;
    background: var(--surface-muted, rgba(99, 102, 241, 0.04));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.color-presets__header span {
    display: block;
    font-weight: 600;
}

.color-presets__header small {
    color: var(--text-muted, #6b7280);
    font-size: 0.85rem;
}

.color-presets__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.color-presets__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.color-presets__toggle {
    appearance: none;
    border: 1px solid var(--border-muted, rgba(99, 102, 241, 0.18));
    background: var(--surface-card, #fff);
    color: var(--text-color, #111827);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.color-presets__toggle:hover {
    border-color: color-mix(in srgb, var(--accent-primary, #667eea) 35%, transparent);
}

.color-presets[data-collapsed="true"] .color-presets__grid {
    display: none;
}

.color-presets--compact .color-presets__grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.color-preset-card {
    border: 1px solid var(--border-muted, rgba(99, 102, 241, 0.12));
    border-radius: 1rem;
    padding: 0.75rem 0.9rem;
    background: var(--surface-card, #ffffff);
    font: inherit;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    text-align: left;
    position: relative;
    overflow: visible;
    z-index: 1;
}

.color-preset-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 10px 20px rgba(15, 23, 42, 0.08));
}

.color-preset-card.is-active {
    border-color: color-mix(in srgb, var(--preset-primary, var(--accent-primary, #667eea)) 60%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--preset-primary, var(--accent-primary, #667eea)) 25%, transparent);
}

.color-preset-card:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--preset-primary, var(--accent-primary, #667eea)) 65%, transparent);
    outline-offset: 2px;
}

.color-preset-card__swatch {
    width: 56px;
    height: 52px;
    border-radius: 0.85rem;
    overflow: hidden;
    display: grid;
    grid-template-rows: 58% 1fr;
    gap: 4px;
}

.color-preset-card__swatch-primary {
    border-radius: 0.7rem 0.7rem 0.35rem 0.35rem;
    background: var(--preset-primary, #667eea);
}

.color-preset-card__swatch-accent,
.color-preset-card__swatch-contrast {
    border-radius: 0.35rem;
}

.color-preset-card__swatch-accent {
    background: var(--preset-accent, #764ba2);
}

.color-preset-card__swatch-contrast {
    background: var(--preset-contrast, #ffffff);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.color-preset-card--custom {
    border-style: dashed;
}

.color-preset-card__swatch-primary--custom {
    background: repeating-linear-gradient(135deg, #667eea 0, #667eea 12px, #f97316 12px, #f97316 24px);
}

.color-preset-card__swatch-accent--custom {
    background: repeating-linear-gradient(45deg, #764ba2 0, #764ba2 12px, #0ea5e9 12px, #0ea5e9 24px);
}

.color-preset-card__swatch-contrast--custom {
    background: #f8fafc;
}

.color-custom-modal[hidden] {
    display: none;
}

.color-custom-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.color-custom-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
}

.color-custom-modal__dialog {
    position: relative;
    width: min(640px, 100%);
    background: var(--surface-card, #ffffff);
    border-radius: 1.25rem;
    box-shadow: 0 40px 90px rgba(15, 23, 42, 0.25);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1;
}

.color-custom-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.color-custom-modal__header p {
    margin: 0.25rem 0 0;
    color: var(--text-muted, #6b7280);
}

.color-custom-modal__close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
}

.color-custom-modal__content {
    border: 1px solid var(--border-muted, rgba(99, 102, 241, 0.12));
    border-radius: 1rem;
    padding: 1rem;
    background: var(--surface-muted, rgba(99, 102, 241, 0.04));
}

.color-custom-modal__content .manual-color-fields {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.color-custom-modal__content .manual-color-fields .color-picker,
.color-custom-modal__content .manual-color-fields label {
    width: 100%;
}

.color-custom-modal__footer {
    display: flex;
    justify-content: flex-end;
}

body.color-modal-open {
    overflow: hidden;
}

.manual-color-fields {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.manual-color-fields .color-picker,
.manual-color-fields label {
    width: 100%;
}

.color-custom-modal__dialog:focus-within {
    outline: 2px solid var(--accent-primary, #667eea);
    outline-offset: 2px;
}
.color-preset-card__meta strong {
    display: block;
    font-size: 0.95rem;
}

.color-preset-card__meta small {
    color: var(--text-muted, #6b7280);
    font-size: 0.8rem;
}

/* Hover Preview */
.color-preset-card__preview {
    position: absolute;
    left: 50%;
    top: -8px;
    transform: translate(-50%, -100%);
    width: 540px;
    height: 300px;
    border-radius: 12px;
    background: var(--surface-card, #ffffff);
    border: 1px solid var(--border-muted, rgba(99, 102, 241, 0.18));
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    padding: 0;
    opacity: 0;
    visibility: hidden;
    /* No transition for instant show */
    transition: none;
    pointer-events: none;
    z-index: 40;
    overflow: hidden;
}

.color-preset-card:hover,
.color-preset-card:focus-visible {
    z-index: 50;
}

.color-preset-card__preview[data-loading="true"] {
    opacity: 0;
    visibility: hidden;
}

.color-preset-card:hover .color-preset-card__preview,
.color-preset-card:focus-visible .color-preset-card__preview {
    opacity: 1;
    visibility: visible;
}

.color-preset-card__preview iframe {
    display: block;
    width: 1800px;
    height: 1000px;
    border: 0;
    border-radius: 12px;
    transform-origin: top left;
    transform: scale(0.3);
    pointer-events: none;
}
