/* Inter — UI font del Studio Design System (@fcl/design-system). */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== COLOR VARIABLES — @fcl/design-system tokens =====
 * Default = DARK (DS dark mode). Light vía [data-theme="light"] (DS light mode).
 * Los soft/glow se derivan del acento con color-mix → un solo lugar por acento. */
:root {
    /* superficies — DS dark */
    --bg-primary: #0a0a0a;        /* DS --background */
    --bg-secondary: #171717;      /* DS --card */
    --bg-tertiary: #262626;       /* DS --secondary (controles/campos) */
    --bg-card: #1a1a1a;           /* DS --muted (insets) */
    --bg-hover: #2e2e2e;          /* DS --secondary-hover (hover de controles) */
    --bg-active: #3a3a3a;         /* DS --secondary-active */

    /* inputs — DS: dark usa --input al 30% (bg-input/30), translúcido sobre la card */
    --input: #262626;             /* DS --input (dark) — borde de campos */
    --input-bg: color-mix(in srgb, var(--input) 30%, transparent);

    /* outline buttons — DS variante `outline` (dark) */
    --outline-bg: var(--input-bg);                                          /* dark:bg-input/30 */
    --outline-hover-bg: color-mix(in srgb, var(--input) 50%, transparent);  /* dark:hover:bg-input/50 */
    --outline-hover-fg: var(--text-primary);                                /* texto sin cambio */

    /* acento marca — DS dark primary (Electric Seafoam) */
    --accent-primary: #02ffd1;    /* DS --primary (dark) */
    --accent-hover: #2fe0cb;      /* DS --primary-hover (dark) */
    --accent-active: #55f3db;     /* DS --primary-active (dark) */
    --accent-foreground: #04004e; /* DS --accent-foreground: texto legible SOBRE el acento */
    --accent-hover-bg: color-mix(in srgb, var(--accent-primary) 10%, transparent);
    --accent-soft:     color-mix(in srgb, var(--accent-primary) 12%, transparent);
    --focus-ring:      color-mix(in srgb, var(--accent-primary) 50%, transparent); /* DS ring/50 */

    /* texto — DS dark */
    --text-primary: #e5e5e5;      /* DS --foreground */
    --text-secondary: #a3a3a3;    /* DS --muted-foreground */
    --text-tertiary: #6b6b6b;

    /* bordes */
    --border-color: #262626;      /* DS --border (dark) */
    --border-strong: #3a3a3a;     /* DS --border-strong (énfasis/hover) */
    --border-accent: var(--accent-primary);

    /* semánticos */
    --success: #c4df43;           /* DS --success (lime) */
    --warning: #ff9f26;           /* DS --warning */
    --danger:  #dc2626;           /* DS --destructive (dark) */

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);

    --toast-bg: #171717;
    --toast-text: #e5e5e5;
}

/* ===== LIGHT (DS light mode) ===== */
[data-theme="light"] {
    --bg-primary: #f7f7f7;        /* DS --surface-2 / --muted */
    --bg-secondary: #ffffff;      /* DS --card */
    --bg-tertiary: #f7f7f7;       /* DS --input-background */
    --bg-card: #f7f7f7;
    --bg-hover: #eef2f7;
    --bg-active: #e3ecf7;
    --bg-hover-light: #eef2f7;

    --input: #eaf3fe;             /* DS --input (light) — borde de campos */
    --input-bg: #f7f7f7;          /* DS --input-background (light) */

    /* outline buttons — DS variante `outline` (light) */
    --outline-bg: #ffffff;        /* DS outline: bg-background */
    --outline-hover-bg: #02ffd1;  /* DS outline: hover:bg-accent (seafoam) */
    --outline-hover-fg: #04004e;  /* DS --accent-foreground */

    --accent-primary: #041cff;    /* DS --primary (light, azul eléctrico) */
    --accent-hover: #1506c9;      /* DS --primary-hover */
    --accent-active: #080197;     /* DS --primary-active */
    --accent-foreground: #ffffff; /* blanco sobre azul */

    --text-primary: #0d0d0d;      /* DS --foreground (light) */
    --text-secondary: #5b5b66;    /* DS muted-foreground suavizado para jerarquía */
    --text-tertiary: #9a9aa3;

    --border-color: #eaf3fe;      /* DS --border (light) */
    --border-strong: #cbe3ff;     /* DS --border-strong (énfasis/hover) */

    /* semánticos oscurecidos para contraste AA sobre blanco
     * (lime/amber/pink DS son fills con texto oscuro, no texto) */
    --success: #6f8c00;
    --warning: #b45e00;
    --danger:  #c0356b;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);

    --toast-bg: #ffffff;
    --toast-text: #0d0d0d;
}

/* ===== ACENTOS ALTERNATIVOS (paleta DS) =====
 * El slot "cyan" = marca (sin override: usa seafoam en dark / azul en light). */

/* Pink — DS pink */
[data-accent="pink"] {
    --accent-primary: #ec80a5;
    --accent-hover: #e06b96;
    --accent-active: #d65a8c;
    --accent-foreground: #440d27;   /* DS --destructive-foreground */
    --border-accent: #ec80a5;
}
[data-theme="light"][data-accent="pink"] {
    --accent-primary: #c0357e;
    --accent-hover: #a82d6d;
    --accent-active: #8f255c;
    --accent-foreground: #ffffff;
    --border-accent: #c0357e;
}

/* Green — DS lime */
[data-accent="green"] {
    --accent-primary: #c4df43;
    --accent-hover: #b6d233;
    --accent-active: #a7c322;
    --accent-foreground: #2e3a09;   /* DS --success-foreground */
    --border-accent: #c4df43;
}
[data-theme="light"][data-accent="green"] {
    --accent-primary: #5f7a00;
    --accent-hover: #4f6600;
    --accent-active: #3f5200;
    --accent-foreground: #ffffff;
    --border-accent: #5f7a00;
}

/* ===== BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

body, html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0 0 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    overflow-x: hidden;
}

body > section:not(.toast-container),
body > div:not(.toast-container):not(.cp-popover) {
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 16px;
    padding-right: 16px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
}

.toast {
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
    min-width: 280px;
    max-width: 400px;
    animation: slideDown 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success { 
    border-color: var(--success);
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.warning { 
    border-color: var(--warning);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.error { 
    border-color: var(--danger);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.info {
    border-color: var(--accent-primary);
}

.toast.info .toast-icon {
    color: var(--accent-primary);
}

.toast-icon {
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
}

@keyframes slideDown {
    from { 
        transform: translateY(-100px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from { 
        transform: translateY(0);
        opacity: 1;
    }
    to { 
        transform: translateY(-100px);
        opacity: 0;
    }
}

/* ===== HEADER ===== */
.header-settings {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);   /* DS card: bg-card + border */
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 8px;
}

.header-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-picker {
    display: flex;
    gap: 8px;
}

.color-thumbnail {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.color-thumbnail:hover {
    transform: scale(1.1);
}

.color-thumbnail.active {
    border: 3px solid var(--text-primary);
}

.color-thumbnail.cyan {
    background: #02ffd1;
}

.color-thumbnail.pink {
    background: #ec80a5;
}

.color-thumbnail.green {
    background: #c4df43;
}

.header-icon {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .theme-toggle:hover {
    border-color: var(--accent-primary);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--text-primary);
    transition: transform 0.3s ease;
}

.theme-toggle:active svg {
    transform: rotate(180deg);
}

.header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.header-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-button:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .header-button:hover {
    border-color: var(--accent-primary);
}

/* ===== STATUS ===== */
.status-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: 8px;
}

.status-container .status-item {
    flex: 1 1 calc(50% - 6px);
    min-width: 70px;
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 8px;
    background: transparent;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.status-item:hover {
    border-color: color-mix(in srgb, var(--accent-primary) 35%, transparent);
    background: var(--accent-soft);
}

.status-item:active {
    border-color: var(--accent-primary);
}

.status-item.active {
    border-color: var(--accent-primary);
}

.status-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.15;
    text-align: left;
    max-width: 64px;
}

.status-count {
    font-size: 54px;
    font-weight: 900;
    line-height: 0.85;
    color: var(--accent-primary);
    font-family: "findreplace", sans-serif;
    font-style: normal;
}

/* ===== MARK BUTTONS ===== */
.mark-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.mark-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.mark-button:hover { border-color: var(--accent-primary); }

.mark-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== CLEAR BUTTONS ===== */
.clear-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 6px;
}

.clear-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.clear-button:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.clear-button.clear-danger:hover { border-color: var(--danger, #ef4444); color: var(--danger, #ef4444); }

.refresh-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
}
.refresh-button:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.refresh-button svg { transition: transform 0.3s ease; }
.refresh-button.spinning svg { animation: spin 0.8s linear infinite; color: var(--accent-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.action-button {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
}

.action-button:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .action-button:hover {
    border-color: var(--accent-primary);
}

/* ===== SHAPE CONTROLS ===== */
.shape-controls {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);   /* DS card: bg-card + border */
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.shape-controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.shape-control-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-control-button:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .shape-control-button:hover {
    border-color: var(--accent-primary);
}

.shape-control-button.active {
    background: var(--accent-primary);
    color: var(--accent-foreground);
    border-color: var(--accent-primary);
}

.shape-control-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ===== SECTIONS ===== */
.section-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);   /* DS card: bg-card + border */
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: visible;
    padding: 8px 8px 0 8px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

/* ===== HOVER (patrón DS: la card es superficie estática) =====
 * El DS NO repinta superficies en hover (su Card no tiene hover; el trigger del
 * Accordion solo subraya). La afordancia del header colapsable la damos reforzando
 * el BORDE (--border-strong), nunca el fondo → sin "parcheo" en secciones densas. */

/* Cerrada (la card es básicamente el header): borde más marcado = "click para abrir" */
.section-card:not(:has(.section-content.show)):hover {
    border-color: var(--border-strong);
}

/* Abierta: solo reacciona al pasar por el header */
.section-card:has(.section-toggle:hover) {
    border-color: var(--border-strong);
}

.section-toggle {
    width: 100%;
    margin: 0 0 8px 0;
    background: transparent;
    border: none;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 8px;
}

.section-icon {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-arrow {
    width: 14px;
    height: 14px;
    margin-left: auto;
    transition: transform 0.2s ease;
    color: var(--accent-primary);
    will-change: transform;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-toggle.open .toggle-arrow {
    transform: rotate(180deg);
}

.section-content {
    background: var(--bg-secondary);
    width: 100%;
    overflow: visible;
    transition: background 0.25s ease;
}

.section-inner {
    padding: 0 8px 16px 8px;
    transition: background 0.25s ease;
}

/* ===== INPUTS ===== */
.input-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-field {
    width: 100%;
    background: var(--input-bg);          /* DS: bg-input/30 (dark) / input-background (light) */
    border: 1px solid var(--input);       /* DS: border-input */
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    margin-bottom: 12px;
    transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);  /* DS: focus-visible:border-ring */
    box-shadow: 0 0 0 3px var(--focus-ring); /* DS: ring-ring/50 ring-[3px] */
}

.input-field::placeholder {
    color: var(--text-tertiary);
}

.input-with-button {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.input-with-button .input-field {
    flex: 1;
    margin-bottom: 0;
}

.input-button {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.input-button:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .input-button:hover {
    border-color: var(--accent-primary);
}

.input-button svg {
    width: 18px;
    height: 18px;
    color: var(--text-primary);
    flex-shrink: 0;
}

#initialColorInput, 
#newColorInput {
    margin: 6px auto;
    border-radius: 6px;
}

/* ===== CHIPS ===== */
.chips-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chips-container {
    min-height: 80px;
    max-height: 120px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.chip:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

[data-theme="light"] .chip:hover {
    background: var(--bg-hover-light);
    border-color: var(--accent-primary);
}

.chip.selected {
    background: var(--accent-primary);
    color: var(--accent-foreground);
    border-color: var(--accent-primary);
}

.chip svg {
    width: 14px;
    height: 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chip.selected svg {
    opacity: 1;
}

/* ===== LISTS ===== */
.list-empty {
    list-style: none;
    color: var(--text-secondary);
    font-size: 11px;
    text-align: center;
    padding: 26px 8px;
    line-height: 1.4;
}

.style-list-container,
.position-list-container,
.color-list-container,
.radius-list-container {
    min-height: 100px;
    max-height: 150px;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 12px;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.style-list,
.position-list,
.color-list,
.radius-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.style-item,
.position-item,
.color-item,
.radius-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    color: var(--text-primary);
}

.style-item {
    display: flex;
    align-items: center;
}

.style-item-info {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.style-indicators {
    display: inline-flex;
    gap: 4px;
    font-size: 10px;
    color: var(--accent-primary);
    opacity: 0.8;
    flex-shrink: 0;
    margin-left: 8px;
}

.style-item:hover,
.position-item:hover,
.color-item:hover,
.radius-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

[data-theme="light"] .style-item:hover,
[data-theme="light"] .position-item:hover,
[data-theme="light"] .color-item:hover,
[data-theme="light"] .radius-item:hover {
    background: var(--bg-hover-light);
    border-color: var(--accent-primary);
}

.style-item.selected,
.position-item.selected,
.color-item.selected,
.radius-item.selected {
    border-color: var(--accent-primary);
    background: var(--accent-soft);
}

.chips-container::-webkit-scrollbar,
.style-list-container::-webkit-scrollbar,
.position-list-container::-webkit-scrollbar,
.color-list-container::-webkit-scrollbar,
.radius-list-container::-webkit-scrollbar {
    width: 6px;
}

.chips-container::-webkit-scrollbar-track,
.style-list-container::-webkit-scrollbar-track,
.position-list-container::-webkit-scrollbar-track,
.color-list-container::-webkit-scrollbar-track,
.radius-list-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chips-container::-webkit-scrollbar-thumb,
.style-list-container::-webkit-scrollbar-thumb,
.position-list-container::-webkit-scrollbar-thumb,
.color-list-container::-webkit-scrollbar-thumb,
.radius-list-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chips-container::-webkit-scrollbar-thumb:hover,
.style-list-container::-webkit-scrollbar-thumb:hover,
.position-list-container::-webkit-scrollbar-thumb:hover,
.color-list-container::-webkit-scrollbar-thumb:hover,
.radius-list-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ===== CREATE STYLE BUTTONS ===== */
.create-style-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.create-style-buttons.four-cols {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.style-type-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.style-type-button:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .style-type-button:hover {
    border-color: var(--accent-primary);
}

/* ===== COLOR MODE TABS ===== */
.color-mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.color-mode-tab {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-mode-tab:hover {
    background: var(--bg-hover);
}

[data-theme="light"] .color-mode-tab:hover {
    background: var(--bg-hover-light);
}

.color-mode-tab.active:hover {
    background: var(--accent-primary);
}

[data-theme="light"] .color-mode-tab.active:hover {
    background: var(--accent-primary);
}

.color-mode-tab.active {
    background: var(--accent-primary);
    color: var(--accent-foreground);
    border-color: var(--accent-primary);
}

/* ===== BUTTONS ===== */
button {
    cursor: pointer;
    font-family: inherit;
    outline: none;
}

button:active {
    transform: scale(0.98);
}

.button-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.button-row-full {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.apply-dropdown {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' 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 8px center;
    background-size: 14px;
    padding-right: 32px;
    text-align: left;
}

[data-theme="light"] .apply-dropdown {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b5b66' 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");
}

.apply-dropdown:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .apply-dropdown:hover {
    border-color: var(--accent-primary);
}

.apply-dropdown:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--focus-ring); /* DS: ring-ring/50 ring-[3px] */
}

.apply-dropdown option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.delete-button-inline {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.delete-button-inline:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .delete-button-inline:hover {
    border-color: var(--accent-primary);
}

.delete-button-inline svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.delete-button-block {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}

.delete-button-block:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .delete-button-block:hover {
    border-color: var(--accent-primary);
}

.delete-button-block svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.apply-button {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.apply-button:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .apply-button:hover {
    border-color: var(--accent-primary);
}

.apply-button svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.apply-button-half {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-button-half:hover {
    border-color: var(--accent-primary);
}

[data-theme="light"] .apply-button-half:hover {
    border-color: var(--accent-primary);
}

.dropdown-hidden {
    display: none;
}

/* ===== OUTLINE BUTTONS — DS variante `outline` =====
 * Unifica los botones de control al lenguaje del sistema:
 *   base  → borde --input + fondo sutil (--outline-bg) + texto --foreground
 *   hover → dark: relleno neutro más opaco (input/50) · light: relleno acento seafoam
 * Los selectores de hover llevan [data-theme] (siempre presente en <body>) para
 * imponerse a las reglas previas de "borde→acento" sin eliminarlas. */
.header-button, .action-button, .shape-control-button, .style-type-button,
.delete-button-inline, .delete-button-block, .apply-button, .apply-button-half,
.mark-button, .clear-button, .refresh-button, .input-button, .theme-toggle,
.apply-dropdown {
    background-color: var(--outline-bg);
    border: 1px solid var(--input);
    color: var(--text-primary);
}

[data-theme] .header-button:hover,
[data-theme] .action-button:hover,
[data-theme] .shape-control-button:not(.active):hover,
[data-theme] .style-type-button:hover,
[data-theme] .delete-button-inline:hover,
[data-theme] .delete-button-block:hover,
[data-theme] .apply-button:hover,
[data-theme] .apply-button-half:hover,
[data-theme] .mark-button:hover,
[data-theme] .clear-button:not(.clear-danger):hover,
[data-theme] .refresh-button:hover,
[data-theme] .input-button:hover,
[data-theme] .theme-toggle:hover,
[data-theme] .apply-dropdown:hover {
    background-color: var(--outline-hover-bg);
    border-color: var(--input);
    color: var(--outline-hover-fg);
}

/* ===== SIGNATURE ===== */
.Signage {
    text-align: center;
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 16px;
    padding: 8px;
}

/* ===== THEME COLORS ===== */
.theme-colors-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 12px;
    overflow: hidden;
    min-width: 0;
}

.theme-swatch {
    aspect-ratio: 1;
    width: 100%;
    min-width: 0;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.theme-swatch:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
    z-index: 1;
}

.theme-masters-note {
    font-size: 10px;
    color: var(--text-secondary);
    margin: -6px 0 8px;
}

.theme-masters-note:empty {
    display: none;
}

.theme-scope {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.theme-scope-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-right: 2px;
}

.theme-scope-btn {
    flex: 1;
    min-width: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.theme-scope-btn:hover {
    border-color: var(--accent-primary);
}

.theme-scope-btn.active {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: var(--accent-soft);
}

.theme-palette-btn {
    margin-bottom: 12px;
}

.theme-palette-preview {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.theme-palette-rows {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}

.theme-palette-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 11px;
    color: var(--text-secondary);
}

.theme-palette-row .slot-name {
    width: 58px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.theme-palette-row .slot-hex {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
}

.theme-palette-chip {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.theme-palette-arrow {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.theme-palette-warning {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.4;
}

.theme-palette-warning:empty {
    display: none;
}

.theme-palette-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.theme-palette-actions .action-button {
    margin-bottom: 0;
    padding: 8px;
    font-size: 12px;
}

.theme-palette-cancel {
    color: var(--text-secondary);
}

.theme-color-editor {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.theme-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.theme-editor-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
}

.theme-editor-close:hover {
    color: var(--accent-primary);
}

.theme-editor-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-editor-old,
.theme-editor-new {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.theme-editor-arrow {
    color: var(--text-secondary);
    font-size: 14px;
    flex-shrink: 0;
}

.theme-refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    padding: 0 4px;
    margin-left: 4px;
}

.theme-refresh-btn:hover {
    color: var(--accent-primary);
}

/* ===== COLOR PICKER WIDGET ===== */
.color-picker-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.color-picker-native {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.color-picker-native::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-native::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.color-picker-native::-moz-color-swatch {
    border: none;
    border-radius: 3px;
}

.color-picker-native:hover {
    border-color: var(--accent-primary);
}

.color-picker-hex {
    flex: 1;
    margin-bottom: 0 !important;
    font-family: "Consolas", "Monaco", monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== COMPACT COLOR PICKER (DS ColorPickerPopover, vanilla) ===== */
/* Color Swap usa este picker para Original y Destination. El popover se
 * inyecta en <body> desde Script.js, por eso los estilos son globales. */
.cp-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    width: 100%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 6px;
    padding: 0 8px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.cp-trigger:hover { background: var(--bg-hover); }
.cp-trigger:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.cp-trigger-swatch {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
}
.cp-trigger-swatch.empty {
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
    background-color: #fff;
}
.cp-trigger-hex {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, "Consolas", "Monaco", monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cp-trigger-hex.placeholder { color: var(--text-secondary); text-transform: none; letter-spacing: 0; }
.cp-trigger-caret { flex-shrink: 0; color: var(--text-secondary); }

.cp-popover {
    position: absolute;
    z-index: 2000;
    width: 224px;
    max-width: calc(100vw - 24px);
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    display: none;
    flex-direction: column;
    gap: 12px;
}
.cp-popover.open { display: flex; }

.cp-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-swatch {
    position: relative;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease;
}
.cp-swatch:hover { transform: scale(1.1); }
.cp-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.cp-swatch.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 30%, transparent);
}
.cp-swatch svg { position: absolute; inset: 0; margin: auto; width: 12px; height: 12px; }

.cp-divider {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cp-sv {
    position: relative;
    width: 100%;
    height: 130px;
    border-radius: 6px;
    cursor: crosshair;
    overflow: hidden;
    touch-action: none;
}
.cp-sv-white { position: absolute; inset: 0; background: linear-gradient(to right, #fff, rgba(255,255,255,0)); }
.cp-sv-black { position: absolute; inset: 0; background: linear-gradient(to top, #000, rgba(0,0,0,0)); }
.cp-sv-pointer {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.cp-hue {
    position: relative;
    width: 100%;
    height: 12px;
    border-radius: 9999px;
    cursor: pointer;
    touch-action: none;
    background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cp-hue-pointer {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.cp-hex-row { display: flex; align-items: center; gap: 8px; }
.cp-eyedropper {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
}
.cp-eyedropper:hover { background: var(--bg-hover); }
.cp-hex-swatch {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
}
.cp-hex-input {
    height: 32px;
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border-strong);
    background: var(--input-bg);
    border-radius: 6px;
    padding: 0 10px;
    font-family: ui-monospace, "Consolas", "Monaco", monospace;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-primary);
}
.cp-hex-input:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }

.cp-rgb { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cp-rgb-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cp-rgb-input {
    height: 32px;
    width: 100%;
    text-align: center;
    border: 1px solid var(--border-strong);
    background: var(--input-bg);
    border-radius: 6px;
    font-family: ui-monospace, "Consolas", "Monaco", monospace;
    font-size: 12px;
    color: var(--text-primary);
}
.cp-rgb-input:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.cp-rgb-cell span {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Colors: el picker usa el mismo popover que Color Swap (swatches del DS dentro) */
.color-picker-widget .cp-trigger { flex: 1; width: auto; height: 40px; }

/* Color Swap: tres botones Apply en una fila */
.button-row-full.button-row-3 { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.button-row-full.button-row-3 .apply-button-half {
    font-size: 11px;
    padding: 6px 6px;
    line-height: 1.2;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
    body > section:not(.toast-container),
    body > div:not(.toast-container):not(.cp-popover) {
        max-width: calc(100% - 32px);
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ===== LAYOUT TOOLS (autolayout + grid) ===== */
.layout-full-button {
    width: 100%;
    margin-bottom: 8px;
}
.layout-full-button:last-child {
    margin-bottom: 0;
}