/* ============================================================
   MODULARITY TOOL — SWISS GRID SYSTEM v3.1
   Satoshi · Crema / Blanco / Negro
   ============================================================ */

/* ── VARIABLES ─────────────────────────────────────────────── */
:root {
    --sidebar-width:    280px;
    --panel-height:     58px;
    --grid-cols:        20;

    /* Paleta crema · blanco · negro */
    --cream:            #f5f0e8;   /* fondo principal, tono analógico */
    --cream-mid:        #ede8de;   /* hover, separadores suaves */
    --cream-dark:       #ddd6c8;   /* bordes, divisores */
    --white:            #ffffff;   /* áreas de contenido */
    --light:            #e8e4dc;   /* bordes livianos */
    --mid:              #b8b0a4;   /* placeholders */
    --muted:            #888078;   /* texto secundario */
    --dark:             #3a3530;   /* texto terciario */
    --ink:              #1a1714;   /* texto principal */
    --black:            #0d0c0b;   /* encabezados, brand */

    --paper:            #ffffff;   /* canvas de trabajo */

    /* Acento — negro puro para interacciones */
    --accent:           var(--ink);
    --accent-dim:       rgba(26, 23, 20, 0.06);

    /*
     * Fuentes — Satoshi Variable para todo.
     * satoshi.css debe cargarse antes de style.css en el HTML.
     * --font-mono usa Satoshi-Variable en modo monoespaciado simulado
     * (letter-spacing ajustado) + fallback system monospace.
     */
    --font-display:     'Satoshi-Variable', 'Helvetica Neue', sans-serif;
    --font-mono:        'Satoshi-Variable', ui-monospace, monospace;

    --rule:             1px solid var(--cream-dark);
    --rule-dark:        1px solid var(--ink);
    --transition:       0.10s ease;
    --panel-transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-display);
    color: var(--ink);
    background: var(--cream);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ── LAYOUT ─────────────────────────────────────────────────── */
#app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
#toolbar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: var(--rule-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 200;
}

/* ── BRAND ── */
.brand {
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: var(--rule-dark);
    position: relative;
    flex-shrink: 0;
    background: var(--black);
}

/* Barra lateral fina — crema sobre negro */
.brand::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
}

.brand-text { display: flex; flex-direction: column; }

.brand h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.45rem;
    text-transform: uppercase;
    color: var(--white);
    line-height: 1;
}

.brand-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 4px;
}

.brand-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    width: 32px; height: 32px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    padding: 0;
    transition: transform var(--panel-transition);
}

#toolbar.panel-open .brand-toggle { transform: rotate(180deg); }

/* ── SECTION LABEL ── */
.section-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.28em;
    color: var(--muted);
    padding: 10px 20px 9px;
    border-bottom: var(--rule);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--cream);
}

/* ── PINCELES ───────────────────────────────────────────────── */
.brush-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-bottom: var(--rule);
    min-height: 0;
}

.brush-tabs {
    display: flex;
    flex-shrink: 0;
    border-bottom: var(--rule-dark);
    background: var(--white);
}

.brush-tab {
    flex: 1;
    height: 38px;
    background: transparent;
    border: none;
    border-right: var(--rule);
    color: var(--muted);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    touch-action: manipulation;
}

.brush-tab:last-child { border-right: none; }
.brush-tab:hover { background: var(--cream); color: var(--ink); }
.brush-tab.active { background: var(--white); color: var(--ink); font-weight: 800; }

/* Indicador activo — línea negra inferior */
.brush-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--ink);
}

.brush-tab .tab-count {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    opacity: 0.50;
    line-height: 1;
}

.brush-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
    background: var(--white);
}

.brush-scroll::-webkit-scrollbar { width: 3px; }
.brush-scroll::-webkit-scrollbar-thumb { background: var(--cream-dark); }

.brush-page { display: none; }
.brush-page.active {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.brush-item {
    aspect-ratio: 1;
    background: var(--white);
    border: 1px solid var(--cream-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
    touch-action: manipulation;
}

.brush-item:hover {
    border-color: var(--ink);
    background: var(--cream);
}

.brush-item.active {
    border-color: var(--ink);
    background: var(--cream);
    /* Sombra dura suiza monocromática */
    box-shadow: 3px 3px 0 0 var(--ink);
}

/* Triángulo de selección — esquina superior derecha */
.brush-item.active::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 0; height: 0;
    border-style: solid;
    border-width: 0 9px 9px 0;
    border-color: transparent var(--ink) transparent transparent;
}

.brush-item img {
    width: 62%; height: 62%;
    object-fit: contain;
    opacity: 0.55;
    transition: var(--transition);
    pointer-events: none;
}

.brush-item:hover img { opacity: 0.85; }
.brush-item.active img { opacity: 1; }

/* ── CONTROLES ──────────────────────────────────────────────── */
.controls-block {
    padding: 0 20px 14px;
    border-bottom: var(--rule);
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 230px;
    background: var(--white);
}

.controls-block::-webkit-scrollbar { width: 3px; }
.controls-block::-webkit-scrollbar-thumb { background: var(--cream-dark); }

.control-group { margin-top: 14px; }

.control-label {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.24em;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.control-label .val {
    color: var(--ink);
    font-size: 10px;
    font-weight: 700;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%; height: 1px;
    background: var(--cream-dark);
    outline: none; cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    background: var(--ink);
    border-radius: 0;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 12px; height: 12px;
    background: var(--ink);
    border: none; border-radius: 0;
    cursor: pointer;
}

input[type="color"] {
    width: 100%; height: 28px;
    border: 1px solid var(--cream-dark);
    background: var(--white);
    cursor: pointer; padding: 2px 3px;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; }

.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] { width: 28px; height: 28px; flex-shrink: 0; }

.check-label {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--dark);
    display: flex; align-items: center; gap: 7px;
    cursor: pointer; user-select: none; line-height: 1.4;
}

input[type="checkbox"] {
    appearance: none;
    width: 12px; height: 12px;
    border: 1.5px solid var(--cream-dark);
    background: var(--white);
    cursor: pointer;
    position: relative; flex-shrink: 0;
    transition: var(--transition);
}

input[type="checkbox"]:checked {
    background: var(--ink);
    border-color: var(--ink);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute; inset: 2px;
    background: var(--white);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

/* ── ACCIONES ───────────────────────────────────────────────── */
.actions {
    padding: 12px 14px;
    display: flex; flex-direction: column; gap: 6px;
    margin-top: auto; flex-shrink: 0;
    border-top: var(--rule-dark);
    background: var(--white);
}

.btn-row { display: flex; gap: 6px; }

button {
    width: 100%; height: 36px; padding: 0 12px;
    cursor: pointer;
    border: 1.5px solid var(--cream-dark);
    background: transparent;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--dark);
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
    gap: 5px; white-space: nowrap; touch-action: manipulation;
    border-radius: 0;
}

button:hover {
    border-color: var(--ink);
    color: var(--ink);
    background: var(--cream);
}

button:active { opacity: 0.65; }

/* Borrador activo */
#btn-eraser.active {
    border-color: var(--ink);
    color: var(--ink);
    background: var(--cream-mid);
}

/* Limpiar todo — sutil aviso de peligro */
#btn-clear {
    border-color: var(--cream-dark);
    color: var(--muted);
}
#btn-clear:hover {
    border-color: var(--ink);
    color: var(--ink);
    background: var(--cream-mid);
}

/* Exportar — negro sólido, texto crema */
#btn-export, #btn-export-svg {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--cream);
    font-weight: 800;
}
#btn-export:hover, #btn-export-svg:hover {
    background: var(--black);
    border-color: var(--black);
    color: var(--white);
}

/* Proyectos */
.btn-projects {
    background: var(--cream) !important;
    border-color: var(--ink) !important;
    color: var(--ink) !important;
    font-weight: 700;
}
.btn-projects:hover {
    background: var(--ink) !important;
    color: var(--cream) !important;
}

.shortcut-hint {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    line-height: 2.2;
    padding-top: 2px;
}

kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--cream);
    border: 1px solid var(--cream-dark);
    color: var(--dark);
    padding: 1px 5px;
}

/* ============================================================
   WORKSPACE
   ============================================================ */
#workspace {
    flex: 1;
    overflow: hidden;
    position: relative;
    /* Fondo crema con dot grid — como la referencia */
    background-color: var(--cream);
    background-image: radial-gradient(circle, rgba(26, 23, 20, 0.34) 0.8px, transparent 0.8px);
    background-size: 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px;
}

/* Marcas de registro de imprenta — sutiles */
#workspace::before,
#workspace::after {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    pointer-events: none;
    opacity: 0.2;
    z-index: 0;
}
#workspace::before {
    top: 14px; left: 14px;
    border-top: 1px solid var(--ink);
    border-left: 1px solid var(--ink);
}
#workspace::after {
    bottom: 14px; right: 14px;
    border-bottom: 1px solid var(--ink);
    border-right: 1px solid var(--ink);
}

/* ── GRID CANVAS — sin sombra ── */
#grid-canvas {
    display: grid;
    background-color: var(--paper);
    /* Sin box-shadow — superficie limpia */
    border: 1px solid var(--ink);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    max-width: 100%;
    max-height: 100%;
}

/* ── CELDAS ── */
.cell {
    position: relative;
    overflow: visible;
    background-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    outline: 0.5px solid rgba(26,23,20,0.08);
}

.no-grid .cell { outline: none; }
.cell:hover { background-color: var(--accent-dim); }

.cell svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
    shape-rendering: geometricPrecision;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cream-dark); }

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 1100px) {
    :root { --sidebar-width: 250px; }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 600px) {
    :root { --panel-height: 58px; }

    #app-container { flex-direction: column; }

    #workspace {
        width: 100vw;
        height: calc(100dvh - var(--panel-height));
        padding: 16px;
        justify-content: center;
        align-items: center;
    }

    #toolbar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        width: 100%;
        height: 82vh; max-height: 82vh;
        transform: translateY(calc(100% - var(--panel-height)));
        transition: transform var(--panel-transition);
        border-right: none;
        border-top: 2px solid var(--ink);
        box-shadow: 0 -4px 32px rgba(26,23,20,0.12);
        overflow: hidden;
    }

    #toolbar.panel-open { transform: translateY(0); }

    .brand {
        cursor: pointer;
        height: var(--panel-height);
    }

    .brand::after {
        content: '';
        position: absolute;
        top: 9px; left: 50%;
        transform: translateX(-50%);
        width: 28px; height: 2px;
        background: var(--muted);
    }

    .brand::before { display: none; }
    .brand-sub { display: none; }
    .brand-toggle { display: flex; }

    .brush-page.active { grid-template-columns: repeat(4, 1fr); }

    .controls-block {
        max-height: none;
        padding: 8px 16px 10px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 16px;
    }

    .control-group { margin-top: 10px; }

    .actions {
        flex-direction: row; flex-wrap: wrap;
        padding: 8px 10px 10px; gap: 5px;
    }

    .actions .btn-row { flex: 1; min-width: 100px; }
    #btn-clear { flex: 1; }
    .shortcut-hint { display: none; }
    .cell:hover { background-color: transparent; }

    /* ── Mono font-size: restaurar a 7px en mobile ── */
    .brand-sub,
    .section-label,
    .brush-tab .tab-count,
    .control-label,
    .control-label .val,
    .check-label,
    kbd,
    .pm-empty,
    .pm-item-meta,
    .pm-storage-info,
    #save-toast,
    .ins-empty,
    .ins-section-title,
    .ins-hex,
    .ins-count,
    .ins-hint { font-size: 7px; }
}

@media (max-width: 380px) {
    .brush-page.active { grid-template-columns: repeat(3, 1fr); }
    #workspace { padding: 10px; }
}

/* ============================================================
   SISTEMA DE PROYECTOS
   ============================================================ */

#projects-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13,12,11,0.55);
    backdrop-filter: blur(3px);
}

.pm-panel {
    position: relative;
    z-index: 1;
    background: var(--white);
    border: 2px solid var(--ink);
    box-shadow: 6px 6px 0 0 var(--ink);
    width: min(480px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.pm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 2px solid var(--ink);
    flex-shrink: 0;
    background: var(--black);
}

.pm-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.3rem;
    text-transform: uppercase;
    color: var(--white);
}

.pm-close {
    width: 30px; height: 30px;
    background: none;
    border: 1px solid rgba(245,240,232,0.2);
    color: var(--cream);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.pm-close:hover {
    border-color: var(--cream);
    color: var(--white);
    background: rgba(245,240,232,0.08);
}

.pm-save-row {
    display: flex;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: var(--rule);
    flex-shrink: 0;
    background: var(--cream);
}

.pm-save-row input[type="text"] {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1.5px solid var(--cream-dark);
    background: var(--white);
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
    outline: none;
    transition: var(--transition);
}

.pm-save-row input[type="text"]::placeholder {
    color: var(--mid);
    font-weight: 400;
}

.pm-save-row input[type="text"]:focus {
    border-color: var(--ink);
}

.pm-save-row input[type="text"].pm-error {
    border-color: #8b2500;
    background: #fff8f5;
}

.pm-save-row button {
    width: auto;
    padding: 0 18px;
    background: var(--ink);
    border: 1.5px solid var(--ink);
    color: var(--cream);
    flex-shrink: 0;
    font-weight: 800;
    font-size: 0.78rem;
}
.pm-save-row button:hover {
    background: var(--black);
    border-color: var(--black);
    color: var(--white);
}

.pm-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.pm-list::-webkit-scrollbar { width: 3px; }
.pm-list::-webkit-scrollbar-thumb { background: var(--cream-dark); }

.pm-empty {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--muted);
    text-align: center;
    padding: 28px 0;
}

.pm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: var(--rule);
    transition: var(--transition);
    gap: 12px;
}

.pm-item:hover { background: var(--cream); }
.pm-item:last-child { border-bottom: none; }

.pm-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.pm-item-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-item-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
}

.pm-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.pm-load-btn {
    width: auto !important;
    padding: 0 14px !important;
    height: 30px !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    background: var(--ink) !important;
    border-color: var(--ink) !important;
    color: var(--cream) !important;
}
.pm-load-btn:hover {
    background: var(--black) !important;
    border-color: var(--black) !important;
    color: var(--white) !important;
}

.pm-del-btn {
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    font-size: 0.72rem !important;
    color: var(--muted) !important;
    border-color: var(--cream-dark) !important;
    background: transparent !important;
}
.pm-del-btn:hover {
    color: var(--ink) !important;
    border-color: var(--ink) !important;
    background: var(--cream-mid) !important;
}

.pm-footer {
    padding: 10px 20px;
    border-top: var(--rule);
    flex-shrink: 0;
    background: var(--cream);
}

.pm-storage-info {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
}

/* Toast */
#save-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--ink);
    color: var(--cream);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    padding: 9px 22px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
    white-space: nowrap;
    /* Sombra dura suiza monocromática */
    box-shadow: 3px 3px 0 0 var(--cream-dark);
}

#save-toast.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 600px) {
    .pm-panel {
        width: 100vw;
        max-height: 90vh;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        box-shadow: 0 -4px 40px rgba(26,23,20,0.15);
    }
    #projects-modal { align-items: flex-end; }
}

/* ============================================================
   INSPECTOR DE ESTILOS GLOBALES
   ============================================================ */

#inspector-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    width: 42px;
    height: 42px;
    padding: 0;
    background: var(--white);
    border: 1.5px solid var(--ink);
    box-shadow: 3px 3px 0 0 var(--ink);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 0;
}

#inspector-btn svg {
    width: 18px; height: 18px;
    transition: transform 0.25s ease;
}

#inspector-btn:hover {
    background: var(--ink);
    color: var(--cream);
    box-shadow: none;
    translate: 2px 2px;
}

#inspector-btn:hover svg { transform: rotate(45deg); }

#inspector-panel {
    position: absolute;
    bottom: 74px;
    right: 20px;
    z-index: 300;
    width: 280px;
    max-height: calc(100% - 110px);
    background: var(--white);
    border: 1.5px solid var(--ink);
    box-shadow: 6px 6px 0 0 var(--ink);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

#inspector-panel.inspector-open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.ins-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid var(--ink);
    flex-shrink: 0;
    gap: 6px;
    background: var(--black);
}

.ins-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.05rem;
    text-transform: uppercase;
    color: var(--white);
    flex: 1;
}

.ins-rescan,
.ins-close-btn {
    width: 24px; height: 24px;
    background: none;
    border: 1px solid rgba(245,240,232,0.2);
    color: var(--cream);
    cursor: pointer;
    font-size: 0.82rem;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: var(--transition);
}

.ins-rescan:hover {
    border-color: var(--cream);
    transform: rotate(-180deg);
}
.ins-close-btn:hover {
    border-color: rgba(245,240,232,0.5);
    background: rgba(245,240,232,0.06);
}

.ins-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 12px;
}

.ins-body::-webkit-scrollbar { width: 3px; }
.ins-body::-webkit-scrollbar-thumb { background: var(--cream-dark); }

.ins-empty {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--muted);
    text-align: center;
    padding: 22px 14px;
    line-height: 2.2;
}

.ins-section-title {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.28em;
    color: var(--muted);
    padding: 10px 16px 5px;
    border-top: var(--rule);
    margin-top: 6px;
}

.ins-section-title:first-child {
    border-top: none;
    margin-top: 0;
}

.ins-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    transition: var(--transition);
}

.ins-row:hover { background: var(--cream); }

.ins-swatch-wrap {
    position: relative;
    flex-shrink: 0;
}

.ins-color-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0; margin: 0;
}

.ins-swatch {
    display: block;
    width: 26px; height: 26px;
    border: 1px solid var(--cream-dark);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.ins-swatch:hover {
    border-color: var(--ink);
    box-shadow: 2px 2px 0 0 var(--ink);
}

.ins-swatch-bg {
    outline: 1px solid var(--cream-dark);
    outline-offset: 2px;
}

.ins-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ins-hex {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink);
    letter-spacing: 0.08em;
    font-weight: 700;
}

.ins-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.ins-symbol-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    transition: var(--transition);
}

.ins-symbol-row:hover { background: var(--cream); }

.ins-symbol-preview {
    width: 36px; height: 36px;
    background: var(--cream);
    border: 1px solid var(--cream-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--ink);
    overflow: hidden;
}

.ins-symbol-preview svg {
    width: 30px; height: 30px;
}

.ins-replace-btn {
    width: auto !important;
    height: 26px !important;
    padding: 0 8px !important;
    font-size: 0.65rem !important;
    letter-spacing: 0.06em !important;
    flex-shrink: 0;
    white-space: nowrap;
    border-color: var(--cream-dark) !important;
    color: var(--dark) !important;
}

.ins-replace-btn:hover {
    border-color: var(--ink) !important;
    color: var(--ink) !important;
    background: var(--cream) !important;
}

.ins-hint {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-align: center;
    padding: 8px 14px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    line-height: 1.9;
    border-top: var(--rule);
    margin-top: 4px;
}

@media (max-width: 600px) {
    #inspector-btn {
        bottom: calc(var(--panel-height) + 16px);
        right: 14px;
        width: 38px; height: 38px;
    }
    #inspector-panel {
        bottom: calc(var(--panel-height) + 65px);
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 55vh;
    }
}

/* ============================================================
   MODAL DE CONFIRMACIÓN — Swiss brutal monocromático
   ============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(13,12,11,0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--white);
    padding: 0;
    border: 2px solid var(--ink);
    width: 90%;
    max-width: 400px;
    text-align: center;
    /* Sombra dura neo-brutalista */
    box-shadow: 8px 8px 0px var(--ink);
    overflow: hidden;
}

/* Franja superior negra con el símbolo de alerta */
.modal-icon {
    display: block;
    background: var(--black);
    padding: 20px 0 16px;
    font-family: var(--font-display);
    font-size: 54px;
    font-weight: 900;
    color: var(--cream);
    line-height: 1;
    border-bottom: 2px solid var(--ink);
}

#modal-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--ink);
    line-height: 1.1;
    padding: 28px 32px 8px;
}

#modal-text {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--dark);
    line-height: 1.75;
    padding: 0 32px 28px;
}

/* Botones como dos franjas divididas — estilo imprenta suiza */
.modal-actions {
    display: flex;
    border-top: 2px solid var(--ink);
}

.modal-actions button {
    flex: 1;
    padding: 16px 12px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.9rem;
    text-transform: uppercase;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: var(--transition);
    height: auto;
}

.btn-modal-secondary {
    background: var(--white);
    color: var(--ink);
    border-right: 2px solid var(--ink);
}
.btn-modal-secondary:hover {
    background: var(--cream);
}

.btn-modal-danger {
    background: var(--ink);
    color: var(--cream);
}
.btn-modal-danger:hover {
    background: var(--black);
    color: var(--white);
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}