/* =========================================
   1. VARIABILI E TEMI (ELEGANCE & ACCESSIBILITY)
   ========================================= */
:root {
  /* Sfondi - Stile "Notion/Linear" (Colori panna/grigio chiarissimo) */
  --bg-base: #f8fafc;       
  --bg-panel: #ffffff;      
  --bg-surface: #f1f5f9;    
  
  /* Colori di Sistema (Palette ad alto contrasto, Color-Blind Safe) */
  --primary: #2563eb;       /* Blu reale */
  --primary-light: #3b82f6;
  --primary-dark: #1e40af;

  --success: #0f766e;       /* Ottanio/Teal: migliore del verde puro per deuteranopia */
  --danger: #be123c;        /* Rosa scuro/Cremisi: alto contrasto */
  --warning: #b45309;       /* Ambra scura */

  /* Tipografia ad alto contrasto */
  --text-main: #0f172a;     
  --text-muted: #475569;    
  
  --gray-100: #f1f5f9;      
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Ombre diffuse ed eleganti (Addio glow) */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  
  --glow-success: transparent;
  --glow-primary: transparent;
  --glow-warning: transparent;
  --glow-danger: transparent;

  --header-inset: none;
  --shadow-danger-hover: none;
  --shadow-primary-btn: none;

  --dock-bg: rgba(255, 255, 255, 0.85);
  --radius: 8px;
  --transition: all 0.2s ease;
  
  /* Highlights Testuali */
  --highlight-bg: #fef3c7;
  --highlight-text: #92400e; 
}

/* TEMA SCURO (Elegante stile IDE, niente neri puri, ma blu notte) */
[data-theme="dark"] {
  --bg-base: #0f172a;       
  --bg-panel: #1e293b;      
  --bg-surface: #334155;    
  
  --success: #14b8a6;       
  --danger: #fb7185;        
  --warning: #fbbf24;       
  --primary: #60a5fa;

  --text-main: #f8fafc;     
  --text-muted: #94a3b8;    
  
  --gray-100: #1e293b;      
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-600: #94a3b8;
  --gray-800: #e2e8f0;
  --gray-900: #f8fafc;

  /* Ombre nel dark mode servono a creare "livelli" (elevation) */
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.4);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.5);

  --dock-bg: rgba(30, 41, 59, 0.85);
  --highlight-bg: rgba(245, 158, 11, 0.2);
  --highlight-text: #fcd34d; 
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100dvh;
  transition: var(--transition);
}

h1, h2, h3, h4, h5, header { 
    font-family: 'DM Sans', sans-serif; 
    letter-spacing: -0.5px; /* Un tocco di classe per rendere i titoli più compatti */
}

/* OVERRIDE FORZATO PER STILI INLINE (salva-vita per il JS durante cambio tema) */
[data-theme="light"] .switch-container-item {
    color: var(--text-main); 
}

/* =========================================
   2. HEADER & CONTROLLI SUPERIORI
   ========================================= */
header {
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-base) 100%);
  color: var(--success);
  padding: 5rem 1rem 1.8rem;
  text-align: center;
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: var(--shadow-lg), var(--header-inset);
  position: relative;
}

header h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; margin-bottom: .4rem; text-shadow: 0 0 15px var(--glow-success); }
header p { 
    font-size: clamp(0.9rem, 3.5vw, 1.15rem); 
    color: var(--text-muted); 
    font-family: 'Inter', sans-serif; 
    font-weight: 500;
}

.header-right-group {
    position: absolute; 
    top: 1.5rem; 
    right: 1.5rem; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    z-index: 500;
}

.icon-btn, .theme-toggle {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--bg-surface); border: 1px solid var(--gray-300);
    color: var(--text-main); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition); padding: 0; box-shadow: var(--shadow-sm);
}

.icon-btn:hover, .theme-toggle:hover {
    background: var(--bg-panel); border-color: var(--primary); color: var(--primary); transform: scale(1.05); box-shadow: 0 0 10px var(--glow-primary);
}

.icon-btn.warning { border-color: var(--danger); color: var(--danger); }
.icon-btn.warning:hover { 
    background: var(--danger); 
    color: white; 
    box-shadow: 0 0 15px var(--glow-danger);
}

[data-theme="dark"] .icon-moon { display: none !important; }
[data-theme="dark"] .icon-sun { display: block !important; }
[data-theme="light"] .icon-sun { display: none !important; }
[data-theme="light"] .icon-moon { display: block !important; }

/* =========================================
   3. SPLASH SCREEN
   ========================================= */
#splash-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #050a15; z-index: 999999;
    display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
}
.anonipro-targeting-system { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.beam-h { position: absolute; top: 0; left: 0; width: 100%; height: 1px; background: rgba(34, 211, 238, 0.4); box-shadow: 0 0 10px rgba(34, 211, 238, 0.6); animation: scan-y-linear 4s linear infinite; }
.beam-v { position: absolute; top: 0; left: 0; width: 1px; height: 100%; background: rgba(34, 211, 238, 0.4); box-shadow: 0 0 10px rgba(34, 211, 238, 0.6); animation: scan-x-linear 6s linear infinite; }
@keyframes scan-y-linear { 0%, 100% { transform: translateY(0vh); } 50% { transform: translateY(100vh); } }
@keyframes scan-x-linear { 0%, 100% { transform: translateX(0vw); } 50% { transform: translateX(100vw); } }

.splash-content { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; background: rgba(5, 10, 21, 0.7); padding: 30px 50px; border-radius: 12px; border: 1px solid rgba(34, 211, 238, 0.2); backdrop-filter: blur(4px); }
.splash-logo { 
    font-family: 'DM Sans', sans-serif; 
    font-size: 1.8rem; 
    font-weight: 700; 
    letter-spacing: 2px; 
    margin-bottom: 1rem; 
    color: #f8fafc; 
    text-shadow: 0 0 20px rgba(34, 211, 238, 0.6); 
}
.splash-status { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: #38bdf8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 20px; text-align: center; }
.airgap-progress-container { width: 100%; min-width: 300px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; position: relative; margin-bottom: 10px; }
.airgap-progress-fill { width: 0%; height: 100%; background: #22d3ee; box-shadow: 0 0 10px #22d3ee; transition: width 0.3s ease; }
.airgap-progress-text { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: #94a3b8; letter-spacing: 2px; }

/* =========================================
   4. LAYOUT PRINCIPALE & UPLOAD
   ========================================= */
#proUploaderModal { max-width: 1500px; margin: 1.5rem auto; background: transparent; box-shadow: none; border-radius: 0; overflow: visible; }

#uploadArea {
  padding: 3.5rem 2rem; text-align: center; background: var(--bg-panel);
  max-width: 850px; margin: 2rem auto; border-radius: var(--radius);
  border: 1px dashed var(--primary); box-shadow: inset 0 0 20px var(--glow-primary); transition: all 0.3s ease;
}
#uploadArea.drag-over {
  background: rgba(37, 99, 235, 0.1); border: 1px solid var(--primary-light);
  box-shadow: inset 0 0 30px var(--glow-primary); transform: scale(1.02);
}
#uploadArea h2 { font-size: clamp(1.6rem, 5vw, 1.9rem); margin-bottom: 1.5rem; color: var(--primary-light); }
#fileInput {
  padding: 1.2rem; font-size: 1.1rem; font-family: 'Inter', sans-serif; color: var(--text-main);
  border: 1px solid var(--gray-600); border-radius: var(--radius); background: var(--bg-surface);
  cursor: pointer; width: 100%; max-width: 500px; transition: var(--transition);
}
#fileInput:hover { border-color: var(--primary); box-shadow: 0 0 10px var(--glow-primary); }

#processingArea, #errorArea { padding: 3rem 1.5rem; text-align: center; font-size: 1.3rem; font-weight: 500; }
#processingArea { background: var(--bg-panel); border: 1px solid var(--primary); border-radius: var(--radius); max-width: 850px; margin: 2rem auto; box-shadow: 0 0 20px var(--glow-primary); animation: pulse-border 2s infinite; }
@keyframes pulse-border { 0% { box-shadow: 0 0 10px var(--glow-primary); } 50% { box-shadow: 0 0 25px var(--glow-primary); } 100% { box-shadow: 0 0 10px var(--glow-primary); } }
#errorArea { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); border-radius: var(--radius); max-width: 850px; margin: 2rem auto; }
#loadingTip { color: var(--primary-light); font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; margin-top: 15px; }

/* =========================================
   5. COMPARAZIONE & PANNELLI
   ========================================= */
.comparison-area-layout { display: grid; grid-template-columns: 1fr; gap: 1.2rem; margin-top: 1rem; padding: 0 1rem 1rem; }
@media (min-width: 1024px) {
  .comparison-area-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 340px; gap: 1.5rem; padding: 0 1.5rem 1.5rem; align-items: stretch; }
  .text-box, .controls-panel { height: calc(100vh - 240px); display: flex; flex-direction: column; overflow: hidden; position: relative; background: var(--bg-panel); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
  .text-box h4, .controls-panel h4 { flex-shrink: 0; padding: 1rem 1.2rem; background: var(--bg-surface); border-bottom: 1px solid var(--gray-200); width: 100%; color: var(--text-main); font-weight: 600; margin: 0; text-align: left; }
  .text-content, #maskingControls { flex: 1; overflow-y: auto; min-height: 0; height: 100%; padding-bottom: 2rem; }
}

.text-box { background: var(--bg-panel); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.text-box h4 { padding: 1rem 1.2rem; background: var(--bg-surface); border-bottom: 1px solid var(--gray-200); font-size: 1.05rem; font-weight: 600; color: var(--text-main); font-family: 'DM Sans', sans-serif; }
.text-content { 
    flex: 1; 
    padding: 1.4rem; 
    max-height: 70vh; 
    overflow-y: scroll; 
    overflow-x: hidden !important; 
    font-family: 'Inter', sans-serif; /* <-- Sostituito JetBrains Mono con Inter */
    font-size: 0.96rem; 
    line-height: 1.7; 
    background: var(--bg-base); 
    color: var(--text-main); 
}
.text-content pre, #originalText, #maskedHtmlOutput { 
    white-space: pre-wrap !important; 
    word-wrap: break-word !important; 
    overflow-wrap: anywhere !important; 
    word-break: break-word !important; 
    max-width: 100%; 
    width: 100%;
    box-sizing: border-box;
    display: block;
    margin: 0; 
    line-height: 1.7; 
    font-family: inherit;
}
#originalText { background: var(--bg-base); color: var(--gray-600); }
#maskedHtmlOutput { outline: none; min-height: 100%; cursor: text; }

/* =========================================
   6. ANON DATA (ENTITÀ) - ACCESSIBLE PASTEL UI
   ========================================= */
.anon-data { 
    font-family: 'JetBrains Mono', monospace; /* Lo stacco di font aiuta la lettura */
    font-size: 0.9em;
    font-weight: 500;
    padding: 2px 6px 2px 4px; 
    border-radius: 4px; 
    cursor: help; 
    display: inline-flex; 
    align-items: baseline; 
    vertical-align: baseline; 
    margin: 0 2px; 
    white-space: nowrap; 
    line-height: 1.3; 
    position: relative; 
    transition: var(--transition); 
    border: 1px solid var(--gray-200); /* Bordo di base */
}

/* =========================================
   MAX EXPANDED PALETTE (Color-Blind Safe Limits)
   Sfondo: Pastello Leggero | Testo: Scuro | Bordo Sinistro
   ========================================= */

/* -- IDENTITÀ -- */
.anon-person { background-color: #fffbeb; color: #b45309; border-color: #fde68a; border-left: 3px solid #f59e0b !important; }
.anon-cf { background-color: #fff7ed; color: #c2410c; border-color: #ffedd5; border-left: 3px solid #ea580c !important; }
.anon-piva { background-color: #fef2f2; color: #b91c1c; border-color: #fee2e2; border-left: 3px solid #ef4444 !important; }
.anon-doc { background-color: #fefce8; color: #a16207; border-color: #fef08a; border-left: 3px solid #eab308 !important; }

/* -- FINANZA E CRYPTO -- */
.anon-money { background-color: #ecfdf5; color: #047857; border-color: #d1fae5; border-left: 3px solid #10b981 !important; }
.anon-iban { background-color: #eff6ff; color: #1d4ed8; border-color: #dbeafe; border-left: 3px solid #3b82f6 !important; }
.anon-swift { background-color: #eef2ff; color: #4338ca; border-color: #e0e7ff; border-left: 3px solid #6366f1 !important; }
.anon-crypto { background-color: #ecfeff; color: #0e7490; border-color: #cffafe; border-left: 3px solid #06b6d4 !important; }

/* -- AZIENDE E RELIGIONE -- */
.anon-org { background-color: #f0fdfa; color: #0f766e; border-color: #ccfbf1; border-left: 3px solid #14b8a6 !important; }
.anon-religious { background-color: #f7fee7; color: #4d7c0f; border-color: #ecfccb; border-left: 3px solid #84cc16 !important; }

/* -- CONTATTI E TECH -- */
.anon-email { background-color: #faf5ff; color: #7e22ce; border-color: #f3e8ff; border-left: 3px solid #a855f7 !important; }
.anon-url { background-color: #f0f9ff; color: #0369a1; border-color: #e0f2fe; border-left: 3px solid #0ea5e9 !important; }
.anon-phone { background-color: #fdf4ff; color: #a21caf; border-color: #fae8ff; border-left: 3px solid #d946ef !important; }
.anon-tech { background-color: #f5f3ff; color: #5b21b6; border-color: #ede9fe; border-left: 3px solid #8b5cf6 !important; }

/* -- LUOGHI E TRACCIAMENTO -- */
.anon-loc { background-color: #fff1f2; color: #be123c; border-color: #ffe4e6; border-left: 3px solid #f43f5e !important; }
.anon-address { background-color: #fdf2f8; color: #be185d; border-color: #fce7f3; border-left: 3px solid #ec4899 !important; }
.anon-cap { background-color: #fff1f2; color: #9f1239; border-color: #fecdd3; border-left: 3px solid #e11d48 !important; }
.anon-gps, .anon-track { background-color: #f5f5f4; color: #44403c; border-color: #e7e5e4; border-left: 3px solid #78716c !important; }

/* -- SISTEMA E CUSTOM -- */
.anon-date { background-color: #f8fafc; color: #334155; border-color: #f1f5f9; border-left: 3px solid #64748b !important; }
.anon-custom { background-color: #fafafa; color: #3f3f46; border-color: #f4f4f5; border-left: 3px solid #71717a !important; }


/* =========================================
   MODIFICATORI DI STATO (Invariati)
   ========================================= */
.anon-warning { border: 1px dashed var(--warning) !important; background: transparent !important; }
.anon-derived { border-style: dashed !important; opacity: 0.8; }
.anon-revealed { 
    background: transparent !important; 
    color: var(--text-main) !important; 
    border: none !important; 
    border-bottom: 2px dotted var(--gray-400) !important; 
    padding: 0 2px !important; 
    border-radius: 0; 
}


/* =========================================
   DARK MODE
   ========================================= */
[data-theme="dark"] .anon-person { background-color: rgba(245, 158, 11, 0.15); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
[data-theme="dark"] .anon-cf { background-color: rgba(234, 88, 12, 0.15); color: #fdba74; border-color: rgba(234, 88, 12, 0.3); }
[data-theme="dark"] .anon-piva { background-color: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
[data-theme="dark"] .anon-doc { background-color: rgba(234, 179, 8, 0.15); color: #fef08a; border-color: rgba(234, 179, 8, 0.3); }

[data-theme="dark"] .anon-money { background-color: rgba(16, 185, 129, 0.15); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
[data-theme="dark"] .anon-iban { background-color: rgba(59, 130, 246, 0.15); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
[data-theme="dark"] .anon-swift { background-color: rgba(99, 102, 241, 0.15); color: #a5b4fc; border-color: rgba(99, 102, 241, 0.3); }
[data-theme="dark"] .anon-crypto { background-color: rgba(6, 182, 212, 0.15); color: #67e8f9; border-color: rgba(6, 182, 212, 0.3); }

[data-theme="dark"] .anon-org { background-color: rgba(20, 184, 166, 0.15); color: #5eead4; border-color: rgba(20, 184, 166, 0.3); }
[data-theme="dark"] .anon-religious { background-color: rgba(132, 204, 22, 0.15); color: #d9f99d; border-color: rgba(132, 204, 22, 0.3); }

[data-theme="dark"] .anon-email { background-color: rgba(168, 85, 247, 0.15); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.3); }
[data-theme="dark"] .anon-url { background-color: rgba(14, 165, 233, 0.15); color: #7dd3fc; border-color: rgba(14, 165, 233, 0.3); }
[data-theme="dark"] .anon-phone { background-color: rgba(217, 70, 239, 0.15); color: #f0abfc; border-color: rgba(217, 70, 239, 0.3); }
[data-theme="dark"] .anon-tech { background-color: rgba(139, 92, 246, 0.15); color: #c4b5fd; border-color: rgba(139, 92, 246, 0.3); }

[data-theme="dark"] .anon-loc { background-color: rgba(244, 63, 94, 0.15); color: #fda4af; border-color: rgba(244, 63, 94, 0.3); }
[data-theme="dark"] .anon-address { background-color: rgba(236, 72, 153, 0.15); color: #f9a8d4; border-color: rgba(236, 72, 153, 0.3); }
[data-theme="dark"] .anon-cap { background-color: rgba(225, 29, 72, 0.15); color: #fecdd3; border-color: rgba(225, 29, 72, 0.3); }
[data-theme="dark"] .anon-gps, [data-theme="dark"] .anon-track { background-color: rgba(120, 113, 108, 0.15); color: #d6d3d1; border-color: rgba(120, 113, 108, 0.3); }

[data-theme="dark"] .anon-date { background-color: rgba(100, 116, 139, 0.15); color: #cbd5e1; border-color: rgba(100, 116, 139, 0.3); }
[data-theme="dark"] .anon-custom { background-color: rgba(113, 113, 122, 0.15); color: #d4d4d8; border-color: rgba(113, 113, 122, 0.3); }

/* =========================================
   TOOLTIP NASCOSTI E STATO RIVELATO
   ========================================= */
.anon-tooltip { 
    visibility: hidden; 
    opacity: 0; 
    position: absolute; 
    bottom: 120%; 
    left: 50%; 
    transform: translateX(-50%) translateY(5px); 
    background-color: #1e293b; /* Dark Slate per alto contrasto */
    border: 1px solid rgba(255,255,255,0.1); 
    color: #f8fafc; 
    padding: 6px 12px; 
    border-radius: 6px; 
    font-size: 0.85rem; 
    font-family: 'Inter', sans-serif; /* Usiamo Inter per leggibilità, non monospace qui */
    text-align: center; 
    width: max-content; 
    max-width: 350px; 
    white-space: normal; 
    word-wrap: break-word;
    z-index: 1000; 
    pointer-events: none; 
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); 
    font-weight: 400; 
}

/* Triangolino sotto il tooltip */
.anon-tooltip::after { 
    content: ""; 
    position: absolute; 
    top: 100%; 
    left: 50%; 
    margin-left: -5px; 
    border-width: 5px; 
    border-style: solid; 
    border-color: #1e293b transparent transparent transparent; 
}

.anon-data:hover .anon-tooltip { 
    visibility: visible; 
    opacity: 1; 
    transform: translateX(-50%) translateY(0); 
}

/* Stato Rivelato: Neutro, pulito, indica interattività senza sembrare un errore */
.anon-revealed { 
    background: transparent !important; 
    color: var(--text-main) !important; 
    border: none !important; /* Rimuove forzatamente il bordo sinistro del badge */
    border-bottom: 2px dotted var(--gray-400) !important; /* Sottolineatura discreta */
    padding: 0 2px !important;
    border-radius: 0 !important;
}

/* E per il dark mode, assicurati che la linea sia visibile ma non accecante */
[data-theme="dark"] .anon-revealed {
    border-bottom: 2px dotted var(--gray-500) !important; 
}

/* =========================================
   7. CONTROLLI LATERALI & ACCORDION
   ========================================= */
.controls-panel { background: var(--bg-panel); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.controls-panel h4 { margin-bottom: 1.2rem; font-size: 1.15rem; color: var(--primary-light); text-align: center; padding-bottom: .8rem; border-bottom: 1px solid var(--gray-200); }
.accordion-item { margin-bottom: 0.6rem; border: 1px solid var(--gray-200); border-radius: 6px; overflow: hidden; background: var(--bg-surface); transition: var(--transition); }
.accordion-header { 
    padding: 0.8rem 1rem; 
    color: var(--text-main); 
    font-weight: 600; 
    font-size: 0.95rem; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    transition: background 0.2s; 
    font-family: 'Inter', sans-serif; 
}
.accordion-header:hover { background: var(--gray-100); }
.accordion-toggle-icon { width: 18px; height: 18px; transition: transform 0.3s ease; }
.accordion-item.is-open .accordion-toggle-icon { transform: rotate(180deg); }
.accordion-content { max-height: 0; opacity: 0; visibility: hidden; transition: max-height 0.4s ease-out, opacity 0.4s ease-out; padding: 0 1rem; }
.accordion-item.is-open .accordion-content { max-height: 80vh; opacity: 1; visibility: visible; background: var(--bg-base); padding: 1rem 1rem 0.5rem; overflow-y: auto; }
.switch-container-item { padding: 0.8rem 0; border-bottom: 1px dashed var(--gray-200); font-family: 'Inter', sans-serif; }
.switch-container-item:last-child { border-bottom: none; }
.controls-panel hr, .controls-panel h5 { display: none !important; }
#maskingControls input[type="checkbox"] { width:20px; height:20px; cursor:pointer; accent-color: var(--success); }

/* =========================================
   8. PULSANTI AZIONE (Bottom)
   ========================================= */
.action-buttons-wrapper { display: flex; gap: 10px; margin-top: 1rem; margin-bottom: 1rem; }
.action-buttons-wrapper button { padding: 0.6rem 1rem; font-size: 0.95rem; font-family: 'Inter', sans-serif; font-weight: 600; border-radius: 4px; cursor: pointer; transition: var(--transition); flex: 1; background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; gap: 8px;}
.action-buttons-wrapper button:hover { background: var(--gray-100); border-color: var(--primary); }
#resetAnonymizationBtn { background: var(--bg-surface); color: var(--text-main); }
#copyMaskedTextBtn { background: rgba(37, 99, 235, 0.1); color: var(--primary-light); border-color: var(--primary); }
#downloadDocxBtn { background: rgba(16, 185, 129, 0.1) !important; color: var(--success) !important; border-color: var(--success) !important; }

/* =========================================
   9. ELEMENTI DINAMICI & COMPONENTI LEGAL
   ========================================= */
/* Progress Bar / Timer / Maschera ESTRAZIONE */
.progress-container { width: 100%; max-width: 600px; background-color: var(--gray-200); border-radius: 4px; margin: 1.5rem auto 1rem; overflow: hidden; height: 6px; }
.progress-bar { height: 100%; width: 0%; background: var(--success); position: relative; transition: width 15s cubic-bezier(0.2, 1, 0.3, 1); box-shadow: 0 0 10px var(--glow-success); }
.loading-tips { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--text-muted); margin-top: 0.8rem; }

#executionTimer { 
    font-family: 'JetBrains Mono', monospace; font-size: 2.2rem; font-weight: 700; 
    color: var(--success); text-shadow: 0 0 10px var(--glow-success); 
    margin: 20px 0 8px; text-align: center; position: relative;
}

#executionTimer::after {
    content: "ESTRAZIONE...";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background-color: var(--bg-panel); 
    color: var(--primary-light);
    font-size: 1.2rem; font-weight: 700; letter-spacing: 2px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}
#executionTimer.extracting-mode::after { opacity: 1; pointer-events: auto; transition: none; }

/* Search Toolbar */
.search-toolbar { background: var(--bg-panel); border-bottom: 1px solid var(--gray-200); padding: 0.8rem 1.2rem; display: none; gap: 0.8rem; align-items: center; flex-wrap: wrap; flex-shrink: 0; z-index: 20; border-radius: 0 0 8px 8px; }
.search-toolbar.visible { display: flex; animation: slideDown 0.2s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.search-input-group { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 200px; }
.search-input { padding: 6px 10px; border: 1px solid var(--gray-200); background: var(--bg-base); color: var(--text-main); border-radius: 4px; font-size: 0.85rem; font-family: 'JetBrains Mono', monospace; width: 100%; }
.search-btn { padding: 6px 12px; font-size: 0.85rem; font-family: 'JetBrains Mono', monospace; cursor: pointer; border-radius: 4px; border: 1px solid var(--gray-200); background: var(--bg-surface); color: var(--text-main); transition: var(--transition); }
.search-btn:hover { background: var(--gray-100); }
.search-btn.primary { background: rgba(37, 99, 235, 0.2); color: var(--primary-light); border-color: var(--primary); }

/* AnoniDock (Barra Strumenti Bottom) */
.anoni-dock { 
    position: absolute; bottom: 25px; left: 50%; transform: translateX(-50%); z-index: 1000; 
    background: var(--dock-bg); backdrop-filter: blur(8px); 
    border: 1px solid var(--gray-200); box-shadow: var(--shadow-lg); 
    border-radius: 12px; padding: 8px; display: flex; align-items: center; gap: 4px; width: 95%; max-width: 600px; min-height: 50px; 
}

/* Rende l'intero bottone un unico blocco solido per il mouse */
.dock-btn *, .icon-btn *, .btn-action-link * {
    pointer-events: none;
}

/* --- GESTIONE SOTTOMENU DOCK --- */
.dock-group {
    position: relative;
    display: inline-flex;
}

/* Sottomenu posizionato in modo fisso tramite JS (anti-clipping) */
.dock-submenu {
    position: fixed;
    background: var(--dock-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 15px 30px -5px rgba(0,0,0,0.2);
    z-index: 100000;
    
    /* Animazione Pop-up */
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(15px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dock-submenu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Freccina indicatrice per il bottone del gruppo */
.dock-group .main-trigger::after {
    content: "";
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-bottom: 4px solid var(--gray-400);
    border-right: 4px solid var(--gray-400);
    border-top: 4px solid transparent;
    border-radius: 1px;
}

.dock-submenu .sub-btn {
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    width: 44px;
    height: 38px;
    min-width: 44px;
}

/* Annulla la larghezza quadrata e allinea contenuto a sinistra */
.dock-submenu .dock-btn {
    width: auto; 
    padding: 0 16px 0 12px; 
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* Prende il testo dal data-tooltip e lo piazza fisso di fianco all'icona */
.dock-submenu .dock-btn::after {
    content: attr(data-tooltip);
    margin-left: 10px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    white-space: nowrap;
}

/* Fix di sicurezza: porta il tooltip globale sopra ogni cosa, così non finisce MAI "sotto" */
#global-anoni-tooltip {
    z-index: 999999 !important;
}

/* Disabilita il tooltip nero fluttuante per i bottoni dentro i sottomenu */
body:has(.dock-submenu .dock-btn:hover) #global-anoni-tooltip {
    display: none !important;
}

.dock-scroller { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.dock-scroller::-webkit-scrollbar { display: none; }
.dock-arrow { width: 24px; height: 24px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.2s; }
.dock-arrow:hover { color: var(--text-main); }
.dock-separator { width: 1px; height: 20px; background: var(--gray-200); margin: 0 4px; }
.dock-btn { width: 44px; height: 44px; min-width: 44px; border-radius: 4px; border: 1px solid transparent; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--bg-surface); color: var(--text-muted); cursor: pointer; transition: all 0.2s; box-shadow: none; }
.dock-btn:hover { background: var(--gray-100); color: var(--text-main); }
.dock-btn.active { background: rgba(37, 99, 235, 0.2) !important; color: var(--primary-light) !important; border-color: var(--primary); transform: scale(1.05); box-shadow: 0 0 10px var(--glow-primary); }
#btn_cursor.active { background: var(--gray-200) !important; color: var(--text-main) !important; border-color: var(--gray-600); }

/* Linking System */
.btn-action-link { background: none; border: none; cursor: pointer; padding: 6px; border-radius: 4px; color: var(--gray-300); transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; margin-right: 8px; flex-shrink: 0; }
.btn-action-link:hover { background-color: var(--bg-base); color: var(--primary-light); }
.switch-container-item.is-merge-source { background-color: rgba(245, 158, 11, 0.1) !important; border: 1px solid var(--warning) !important; border-radius: 4px; }
.switch-container-item.is-merge-source .btn-action-link { color: var(--warning); background: rgba(245, 158, 11, 0.2); }
.switch-container-item.is-merge-target { cursor: crosshair !important; border: 1px dashed var(--success); border-radius: 4px; }
.switch-container-item.is-merge-target:hover { background-color: rgba(16, 185, 129, 0.1) !important; border-color: var(--success) !important; }
.btn-unlink { color: var(--danger); opacity: 0.7; }
.btn-unlink:hover { background-color: rgba(239, 68, 68, 0.1); opacity: 1; }
.alias-indicator { font-size: 0.70rem; font-family: 'JetBrains Mono', monospace; background: rgba(168, 85, 247, 0.1); color: #c084fc; padding: 2px 4px; border-radius: 2px; margin-right: 6px; border: 1px solid #a855f7; display: inline-flex; align-items: center; text-transform: uppercase; }
.disabled-label { opacity: 0.5; pointer-events: none; border-bottom: none !important; }

/* Sync Scroll & Focus Mode */
.slider-toggle-sync::before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider-toggle-sync { background-color: var(--primary); }
input:checked + .slider-toggle-sync::before { transform: translateX(14px); }
#btnFocusMode.active { background: rgba(37, 99, 235, 0.2); color: var(--primary-light); border-color: var(--primary); }
.focus-mini-btn { background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 4px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.focus-mini-btn:hover { background: var(--bg-surface); border-color: var(--gray-200); }

body.focus-mode-active { overflow: hidden; }
body.focus-mode-active header, 
body.focus-mode-active #uploadArea, 
body.focus-mode-active #processingArea, 
body.focus-mode-active #toggleControlsBtn, 
body.focus-mode-active .action-buttons-wrapper { display: none !important; }

body.focus-mode-active #focusActionToolbar { display: flex !important; }
body.focus-mode-active #proUploaderModal { margin: 0; max-width: none; height: 100vh; background: var(--bg-base); padding: 0; position: fixed; top: 0; left: 0; width: 100%; z-index: 9999; }
body.focus-mode-active #comparisonArea { height: 100%; display: flex; flex-direction: column; padding: 0 !important; }

body.focus-mode-active #comparisonArea > div:first-child { 
    display: flex !important; align-items: center !important; justify-content: space-between !important;
    padding: 0 20px !important; margin: 0 !important; background: var(--bg-panel) !important; 
    border-bottom: 1px solid var(--gray-200) !important; height: 48px !important; min-height: 48px !important; max-height: 48px !important; box-sizing: border-box !important; overflow: hidden !important; 
}
body.focus-mode-active #comparisonArea > div:first-child > div:first-child { display: flex !important; flex-direction: row !important; align-items: center !important; gap: 12px !important; height: 48px !important; margin: 0 !important; padding: 0 !important; }
body.focus-mode-active #comparisonArea > div:first-child h3 { margin: 0 !important; padding: 0 !important; font-size: 1.15rem !important; line-height: 48px !important; display: block !important; }
body.focus-mode-active #comparisonArea > div:first-child > div:first-child > div { margin: 0 !important; padding: 2px 10px !important; height: 26px !important; display: inline-flex !important; align-items: center !important; }
body.focus-mode-active #comparisonArea > div:first-child > div:last-child { height: 48px !important; align-items: center !important; margin: 0 !important; padding: 0 !important; }

body.focus-mode-active .comparison-area-layout { flex: 1; height: auto; margin: 0 !important; padding: 6px 15px 15px 15px !important; overflow: hidden; align-items: stretch !important; }
body.focus-mode-active .comparison-area-layout > div { display: flex; flex-direction: column; height: 100% !important; }
body.focus-mode-active .text-box, body.focus-mode-active .controls-panel { flex: 1; height: auto !important; max-height: none !important; border-bottom: none !important; }
body.focus-mode-active .text-content { padding-bottom: 150px !important; height: auto !important; }

/* Smart Highlight Sync & SW */
.sync-highlight-text { background-color: var(--highlight-bg); color: var(--highlight-text); border-radius: 2px; box-shadow: 0 0 0 1px var(--warning); transition: background 0.2s; }
.sw-highlight { background-color: rgba(234, 179, 8, 0.4); color: #854d0e; padding: 0 2px; border-radius: 3px; font-weight: bold; border-bottom: 2px dotted #ca8a04; cursor: pointer; transition: all 0.2s; }
.sw-highlight:hover { background-color: rgba(234, 179, 8, 0.8); }

/* =========================================
   10. SECURITY LOCKDOWN (Air-Gap)
   ========================================= */
body.security-mode-active { border: 6px solid var(--success) !important; box-sizing: border-box; min-height: 100vh; }
body.security-mode-active #btn-lockdown { background: var(--success) !important; border-color: var(--success) !important; color: #022c22 !important; box-shadow: 0 0 15px var(--glow-success), 0 0 30px var(--glow-success); pointer-events: none; opacity: 1; }
body.security-mode-active #lock-label { color: #022c22 !important; }
body.security-mode-active #lock-icon { filter: brightness(0); }

/* =========================================
   11. COMPONENTI MODALI GLOBALI
   ========================================= */
#global-anoni-tooltip { position: fixed; z-index: 10000; background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--gray-200); padding: 6px 10px; border-radius: 4px; font-size: 0.75rem; font-family: 'JetBrains Mono', monospace; pointer-events: none; opacity: 0; visibility: hidden; transform: translate(-50%, -10px); transition: all 0.2s; box-shadow: var(--shadow-lg); }
#global-anoni-tooltip.visible { opacity: 1; visibility: visible; transform: translate(-50%, -100%); margin-top: -8px; }

/* Generici & Reset Modals */
#resetModal > div, #genericConfirmModal > div, #multiMatchModal > div { 
    background-color: var(--bg-panel); border: 1px solid var(--gray-200); color: var(--text-main); box-shadow: var(--shadow-lg); border-radius: var(--radius); 
    max-height: 90vh; overflow-y: auto; padding: 1.5rem !important;
}
#genericConfirmModal h3, #resetModal h3 { color: var(--text-main); }
#genericConfirmModal p, #resetModal p { color: var(--text-muted); }

/* Editor Word Finale */
#finalEditorModal > div { background: var(--bg-panel); border: 1px solid var(--gray-200); }
#finalEditorModal > div > div:first-child { background: var(--bg-surface); border-bottom: 1px solid var(--gray-200); flex-wrap: wrap; height: auto !important; padding: 10px 20px !important; gap: 10px; }
.editor-btn { background: var(--bg-base); border: 1px solid var(--gray-200); color: var(--text-main); border-radius: 4px;}
.editor-btn:hover { background: var(--gray-100); }
#finalEditor { background: var(--bg-base); color: var(--text-main); box-shadow: var(--shadow-lg); font-family: 'Inter', sans-serif; }

/* Back to top button */
#backToTopBtn { display: flex; justify-content: center; align-items: center; position: fixed; bottom: 24px; right: 24px; z-index: 9999; width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: white; border: none; box-shadow: var(--shadow-lg); cursor: pointer; opacity: 0; visibility: hidden; transform: translateY(20px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
#backToTopBtn.visible { opacity: 1; visibility: visible; transform: translateY(0); }
#backToTopBtn:hover { background: var(--primary-light); transform: translateY(-4px) scale(1.05); box-shadow: 0 8px 25px var(--glow-primary); }

#toggleControlsBtn { display: none; }

/* =========================================================
   12. MEDIA QUERIES (Responsività Globale)
   ========================================================= */
@media (max-width: 1024px) {
  .comparison-area-layout { grid-template-columns: 1fr !important; gap: 1rem; padding: 0 0.75rem 100px !important; }
  .controls-panel { position: fixed !important; left: 0; right: 0; bottom: 0; width: 100%; max-height: 88vh; background: var(--bg-panel); border-radius: 24px 24px 0 0; border-top: 2px solid var(--primary); box-shadow: 0 -10px 40px rgba(0,0,0,0.3) !important; padding: 1rem 1.4rem 5rem !important; transform: translateY(100%); transition: transform 0.38s ease; z-index: 1100; overflow-y: auto; }
  .controls-panel.open { transform: translateY(0); }
  .controls-panel::before { content: ""; display: block; width: 50px; height: 5px; background: var(--gray-400); border-radius: 3px; margin: 0 auto 1.5rem; }
  
  #toggleControlsBtn { 
      display: flex; justify-content: center; align-items: center; position: fixed; 
      bottom: 24px; left: 50%; right: auto; transform: translateX(-50%); z-index: 1200; 
      width: 48px; height: 48px; border-radius: 50%; background: var(--bg-panel); 
      color: var(--text-main); border: 1px solid var(--gray-300); 
      box-shadow: var(--shadow-lg); cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      padding: 0; /* <-- FIX: Azzera il padding di default del bottone */
  }
  
  #toggleControlsBtn.active { background: var(--bg-surface); color: var(--primary); transform: translateX(-50%) rotate(90deg) scale(0.95); box-shadow: var(--shadow-sm); border: 1px solid var(--primary-light); }
  #proUploaderModal { margin: 0.5rem; }
  #backToTopBtn { bottom: 24px; right: 24px; width: 48px; height: 48px; }
}

@media (max-width: 768px) {
  /* Splash Screen & Header */
  .splash-status { font-size: 0.70rem; letter-spacing: 0px; padding: 0 10px; line-height: 1.4; }
  .splash-content { padding: 25px 20px; width: 90%; }
  .header-right-group { top: 1rem; right: 1rem; gap: 8px; }
  .icon-btn, .theme-toggle { width: 36px; height: 36px; }
  header { padding: 4.5rem 1rem 1.5rem; }

  /* FIX HEADER: Mette il titolo e i pulsanti su due righe per non schiacciarli */
  #comparisonArea > div:first-child { 
      flex-direction: column !important; 
      align-items: flex-start !important; 
      gap: 12px !important; 
      padding-bottom: 0 !important;
  }
  
  /* Nasconde solo Focus e Sync Scroll, ma MANTIENE l'esca AI Context PRO */
  #btnFocusMode, #syncScrollContainer { display: none !important; }

  /* Adatta l'interruttore AI PRO per il mobile (rimuove la riga grigia e allinea) */
  #aiContextContainer { 
      display: flex !important; 
      margin-left: 0 !important; 
      padding-left: 0 !important; 
      border-left: none !important; 
      margin-top: 5px; 
  }

  /* FIX BOX TESTO: Altezza bloccata e scroll interno obbligatorio */
  .comparison-area-layout > div { height: auto !important; }
  .text-box { 
      height: 75vh !important;         /* Aumentato dal ridicolo 45vh al 70% dello schermo */
      max-height: 80vh !important;     /* Limite massimo alzato */
      min-height: 500px !important;    /* Altezza minima garantita (prima era 350px) */
      display: flex !important; 
      flex-direction: column !important;
  }
  .text-content { 
      flex: 1 1 auto !important; 
      height: auto !important; 
      max-height: none !important; 
      overflow-y: auto !important; 
      padding-bottom: 75px !important; /* Cuscinetto esatto per la dock */
  }

  /* AnoniDock Mobile */
  .anoni-dock { width: 96%; bottom: 10px; padding: 6px; }
  .dock-btn { width: 38px; height: 38px; min-width: 38px; }
  .dock-arrow { display: none; } /* Su mobile si fa swipe, niente frecce */

  /* Pulsanti d'azione (Copia, Esporta, ecc.) */
  /* Pulsanti d'azione (Ricarica, Copia, Esporta) - Incolonnati su Mobile */
  .action-buttons-wrapper { 
      display: flex; 
      flex-direction: column !important; /* Li mette uno sotto l'altro */
      gap: 10px; 
      width: 100%; 
      margin-top: 15px; 
  }
  .action-buttons-wrapper button { 
      width: 100%; 
      flex-direction: row !important; /* Mantiene icona e testo in linea */
      justify-content: center;
      padding: 12px 10px !important; 
      font-size: 0.95rem !important; 
      min-height: 48px; 
  }
  .action-buttons-wrapper button svg { margin: 0 !important; width: 18px; height: 18px; }

  /* Editor Finale Word-like */
  #finalEditorModal { padding: 0 !important; }
  #finalEditorModal > div { width: 100vw !important; height: 100dvh !important; border-radius: 0 !important; max-width: none; }
  #finalEditorModal > div > div:first-child { justify-content: center; padding: 10px !important; height: auto !important; }
  .editor-btn { width: 34px; height: 34px; font-size: 0.85rem; }
  #finalEditor { width: 100% !important; min-height: auto !important; padding: 1rem !important; font-size: 10pt !important; box-shadow: none; margin: 0;}
  
  /* Modali centrati */
  #genericConfirmModal > div, #multiMatchModal > div { width: 95%; padding: 1.2rem !important; margin: 0 auto; }
  
  #displayFileName {
      max-width: 130px !important; 
  }
}

/* =========================================
   SCROLLBAR CUSTOM (Globale)
   ========================================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-600); }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-base); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-600); }

/* =========================================
   FIX UI LITE DEFINITIVO: LAYOUT FOCUS MODE
   ========================================= */

/* 1. Cuscinetto per la AnoniDock (Valido sempre) */
.text-content {
    padding-bottom: 95px !important; 
}

/* 2. Struttura principale: Fissa lo schermo al 100% esatto */
body.focus-mode-active #comparisonArea {
    height: 100dvh !important; /* Usa l'altezza esatta della finestra (dvh supporta il mobile) */
    overflow: hidden !important; /* Blocca eventuali scroll fantasma dell'intera pagina */
}

/* 3. Barra superiore: blindata a 48px di altezza, senza margini extra */
body.focus-mode-active #comparisonArea > div:first-child {
    flex: 0 0 48px !important; 
    height: 48px !important;
    margin: 0 !important;
}

/* 4. Griglia colonne: Gestisce lo spazio SOPRA e SOTTO */
body.focus-mode-active .comparison-area-layout {
    flex: 1 1 0 !important; /* Ordina alla griglia di occupare solo lo spazio rimasto */
    min-height: 0 !important; /* FIX CRITICO: Impedisce alle colonne di sfondare lo schermo */
    margin: 0 !important;
    /* PADDING: 15px sopra, 15px lati, 20px sotto (spazio pulito sotto le colonne) */
    padding: 15px 15px 20px 15px !important; 
}

/* 5. Le tre colonne interne: Le blocchiamo all'interno della griglia */
body.focus-mode-active .comparison-area-layout > div {
    height: 100% !important; 
    max-height: 100% !important;
    min-height: 0 !important; 
    margin: 0 !important;
}

/* 6. Ripristiniamo la dignità estetica dei Box */
body.focus-mode-active .text-box, 
body.focus-mode-active .controls-panel {
    background-color: var(--bg-panel) !important; /* Sfondo originale pulito */
    border: 1px solid var(--gray-200) !important; /* Bordo rimosso per errore, ora ripristinato */
    height: 100% !important;
}

/* 7. L'area interna col testo scrolla senza spingere in giù l'intero blocco */
body.focus-mode-active .text-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
}

/* KILLER FASCIA (FOCUS MODE) */
body.focus-mode-active .text-content {
    max-height: none !important; 
    height: 100% !important;
}

/* =========================================
   FIX MODALI INVISIBILI IN FOCUS MODE
   ========================================= */
#multiMatchModal, 
#genericConfirmModal, 
#resetModal, 
#finalEditorModal {
    z-index: 100000 !important; /* Deve essere maggiore del 9999 del Focus Mode */
}

/* FIX: Impedisce ai browser mobili di schiacciare l'SVG dell'ingranaggio */
#toggleControlsBtn svg {
    flex-shrink: 0 !important;
    min-width: 24px !important;
    min-height: 24px !important;
    display: block !important;
    margin: auto !important;
}

/* Tronca i nomi dei file troppo lunghi con i puntini di sospensione (...) */
#displayFileName {
    display: inline-block;
    max-width: 250px; /* Larghezza massima su desktop */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/* =========================================
   ACCORDION TEASER PRO (Versione Lite)
   ========================================= */
.pro-teaser-accordion {
    border-color: rgba(168, 85, 247, 0.4) !important;
    background: linear-gradient(to bottom, rgba(168, 85, 247, 0.03), transparent) !important;
    margin-bottom: 1rem !important;
}

.pro-teaser-accordion .accordion-header:hover {
    background: rgba(168, 85, 247, 0.08) !important;
}

/* Adattamento Dark Mode */
[data-theme="dark"] .pro-teaser-accordion {
    background: linear-gradient(to bottom, rgba(168, 85, 247, 0.05), transparent) !important;
    border-color: rgba(168, 85, 247, 0.3) !important;
}

.pro-badge-inline {
    font-size: 0.65rem;
    background: #a855f7;
    color: white;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 6px;
    font-family: 'JetBrains Mono', monospace;
}

/* =========================================
   STILE SPAZIATURE SYNC SCROLL (DIFF VIEWER)
   ========================================= */
[data-sync] {
    position: relative;
}

.sync-gap-filler::after {
    content: "";
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: var(--gap-height);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, var(--gray-200) 10px, var(--gray-200) 12px);
    opacity: 0.5;
    border-radius: 4px;
    pointer-events: none;
}

[data-theme="dark"] .sync-gap-filler::after {
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, var(--gray-300) 10px, var(--gray-300) 12px);
    opacity: 0.2;
}



/* Titoli editor: dimensioni stabili, non dipendenti da annidamenti/em ereditati */
#finalEditor h1 {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 22pt;
  line-height: 1.25;
  font-weight: 800;
  margin: 0.65em 0 0.35em;
}

#finalEditor h2 {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 16pt;
  line-height: 1.3;
  font-weight: 700;
  margin: 0.6em 0 0.3em;
}

#finalEditor h3 {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 13pt;
  line-height: 1.35;
  font-weight: 650;
  margin: 0.55em 0 0.3em;
}

#finalEditor p {
  display: block;
  font-size: 11pt;
  line-height: 1.55;
  font-weight: 400;
  margin: 0 0 0.75em;
}



/* NOTIFICA AIR-GAP TOAST */
#airgap-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px); /* Nascosto in basso */
    opacity: 0;
    visibility: hidden;
    background: var(--bg-panel);
    border: 1px solid var(--success);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100000;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
}

#airgap-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

#airgap-toast svg {
    color: var(--success);
    flex-shrink: 0;
}

/* =========================================
   13. ANONIPRO DOCS LITE - LANDING STYLE ALIGNMENT
   Non modifica la palette delle etichette .anon-*.
   Le regole sono additive e preservano ID, onclick e hook JS.
   ========================================= */
:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --brand-50: #ecfdf5;
  --brand-100: #d1fae5;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;

  --bg-base: #f8fafc;
  --bg-panel: #ffffff;
  --bg-surface: #f1f5f9;

  --primary: #0f172a;
  --primary-light: #334155;
  --primary-dark: #020617;
  --success: #059669;

  --text-main: #0f172a;
  --text-muted: #64748b;

  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --radius: 1rem;
  --radius-xl: 1.75rem;
  --radius-2xl: 2rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 50px -30px rgba(15, 23, 42, 0.35);
  --dock-bg: rgba(255, 255, 255, 0.94);
  --transition: all 0.18s ease;
}

[data-theme="dark"] {
  --bg-base: #020617;
  --bg-panel: #0f172a;
  --bg-surface: #1e293b;
  --primary: #f8fafc;
  --primary-light: #e2e8f0;
  --primary-dark: #ffffff;
  --success: #34d399;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-800: #e2e8f0;
  --gray-900: #f8fafc;
  --dock-bg: rgba(15, 23, 42, 0.94);
}

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(circle at 50% -10%, rgba(15, 23, 42, 0.06), transparent 34rem),
    linear-gradient(180deg, var(--bg-base) 0%, #ffffff 48%, var(--bg-base) 100%);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 50% -10%, rgba(16, 185, 129, 0.13), transparent 34rem),
    linear-gradient(180deg, var(--bg-base) 0%, #020617 50%, var(--bg-base) 100%);
}

h1, h2, h3, h4, h5, header {
  font-family: 'Inter', 'DM Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  max-width: 80rem;
  margin: 1.25rem auto 0;
  margin-top: 0px;
  padding: 6.5rem 1.5rem 3.25rem;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
  background:
    radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.14), transparent 42%),
    var(--bg-panel);
  color: var(--text-main);
  box-shadow: var(--shadow);
  overflow: hidden;
}

header::before {
  content: "Digital Air-Gap · Lite";
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-700);
  padding: .45rem .8rem;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

[data-theme="dark"] header {
  border-color: var(--gray-200);
  background:
    radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.18), transparent 44%),
    var(--bg-panel);
}

[data-theme="dark"] header::before {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
}

header h1 {
  max-width: 72rem;
  margin: 0 auto .75rem;
  color: var(--text-main);
  font-size: clamp(2.45rem, 7vw, 5.4rem);
  line-height: .94;
  font-weight: 900;
  letter-spacing: -0.075em;
  text-shadow: none;
}

header h1 sup { color: var(--brand-600) !important; letter-spacing: .08em !important; }

header p {
  max-width: 48rem;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  line-height: 1.7;
  font-weight: 600;
}

header p::after {
  content: " · nessun upload · controllo umano · output PDF locale";
  color: var(--brand-700);
  font-weight: 800;
}

[data-theme="dark"] header p::after { color: #6ee7b7; }

.header-right-group { top: 1.5rem; right: 1.5rem; }

.icon-btn, .theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255,255,255,.84);
  border: 1px solid var(--line);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

[data-theme="dark"] .icon-btn,
[data-theme="dark"] .theme-toggle {
  background: rgba(15, 23, 42, .84);
  border-color: var(--gray-200);
}

.icon-btn:hover, .theme-toggle:hover {
  background: var(--bg-panel);
  border-color: var(--brand-500);
  color: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

#proUploaderModal {
  width: min(calc(100% - 2.5rem), 80rem);
  margin: 1.5rem auto 2rem;
}

#uploadArea {
  position: relative;
  max-width: 58rem;
  margin: 2rem auto;
  padding: clamp(2rem, 5vw, 4rem) clamp(1.25rem, 4vw, 3rem) !important;
  border-radius: var(--radius-2xl) !important;
  border: 1px solid var(--line) !important;
  background: var(--bg-panel) !important;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#uploadArea::before {
  content: "LOCAL";
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-700);
  padding: .35rem .65rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .12em;
}

[data-theme="dark"] #uploadArea::before {
  background: rgba(16,185,129,.10);
  border-color: rgba(16,185,129,.28);
  color: #6ee7b7;
}

#uploadArea.drag-over {
  border-color: var(--brand-500) !important;
  background: linear-gradient(180deg, var(--brand-50), var(--bg-panel)) !important;
  box-shadow: 0 20px 60px -35px rgba(16,185,129,.6);
  transform: translateY(-2px);
}

#uploadArea h2 {
  margin-bottom: 1.4rem;
  color: var(--text-main);
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.055em;
}

#uploadArea h2::after {
  content: " nel browser";
  color: var(--brand-600);
}

#fileInput {
  max-width: 34rem;
  margin: .5rem auto 0;
  padding: 1rem 1.1rem !important;
  border-radius: 1rem !important;
  border: 1px dashed var(--brand-500) !important;
  background: var(--soft) !important;
  color: var(--text-main);
  box-shadow: none !important;
}

#fileInput:hover {
  background: #fff !important;
  border-color: var(--brand-600) !important;
  box-shadow: var(--shadow-sm) !important;
}

#uploadArea input[type="checkbox"],
#maskingControls input[type="checkbox"] {
  accent-color: var(--brand-600) !important;
}

#uploadArea label {
  border-radius: .8rem;
  padding: .42rem .5rem;
  transition: var(--transition);
}

#uploadArea label:hover {
  background: var(--bg-surface);
}

#processingArea, #errorArea {
  max-width: 58rem;
  border-radius: var(--radius-2xl) !important;
  box-shadow: var(--shadow);
}

#processingArea {
  border: 1px solid var(--line) !important;
  background: var(--bg-panel) !important;
}

.progress-container {
  height: 8px;
  border-radius: 999px;
}

.progress-bar { background: var(--brand-500); box-shadow: none; }

#executionTimer {
  color: var(--brand-600);
  text-shadow: none;
  letter-spacing: -0.04em;
}

#comparisonArea {
  animation: apFadeIn .22s ease-out;
}

@keyframes apFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#comparisonArea > div:first-child {
  width: min(100%, 80rem);
  margin: 0 auto .65rem !important;
  padding: 0 .25rem 1rem !important;
}

#comparisonArea > div:first-child h3 {
  font-size: clamp(1.4rem, 3vw, 2.1rem) !important;
  font-weight: 900;
  letter-spacing: -.045em;
}

.comparison-area-layout {
  width: min(100%, 80rem);
  margin-inline: auto;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .comparison-area-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 350px;
    gap: 1.15rem;
    padding: 0 0 1.5rem;
  }

  .text-box, .controls-panel {
    height: calc(100vh - 250px);
  }
}

.text-box, .controls-panel {
  border-radius: var(--radius-xl) !important;
  border: 1px solid var(--line) !important;
  background: var(--bg-panel) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}

.text-box h4, .controls-panel h4 {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-bottom: 1px solid var(--line) !important;
  font-weight: 900 !important;
  letter-spacing: -.02em;
}

.text-content {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-base)) !important;
  color: var(--text-main);
  font-size: .98rem;
  line-height: 1.78;
}

#originalText { color: var(--text-muted) !important; }

.search-toolbar {
  background: var(--bg-panel) !important;
  border-bottom: 1px solid var(--line) !important;
}

.search-input {
  border-radius: .8rem !important;
  background: var(--bg-surface) !important;
}

.search-btn,
.action-buttons-wrapper button,
#btnFocusMode,
.focus-mini-btn,
.editor-btn {
  border-radius: 999px !important;
  font-weight: 800 !important;
}

.action-buttons-wrapper {
  gap: .75rem;
}

.action-buttons-wrapper button {
  min-height: 44px;
  border-color: var(--line) !important;
  background: var(--bg-panel) !important;
}

.action-buttons-wrapper button:hover {
  transform: translateY(-1px);
  border-color: var(--gray-300) !important;
  box-shadow: var(--shadow-sm);
}

#copyMaskedTextBtn {
  background: var(--ink) !important;
  color: #fff !important;
  border-color: var(--ink) !important;
}

[data-theme="dark"] #copyMaskedTextBtn {
  background: #fff !important;
  color: var(--ink) !important;
  border-color: #fff !important;
}

#downloadDocxBtn {
  background: var(--brand-50) !important;
  color: var(--brand-700) !important;
  border-color: var(--brand-100) !important;
}

[data-theme="dark"] #downloadDocxBtn {
  background: rgba(16,185,129,.12) !important;
  color: #6ee7b7 !important;
  border-color: rgba(16,185,129,.28) !important;
}

.controls-panel {
  padding: 0 !important;
}

#maskingControls {
  padding: 1rem;
}

.accordion-item {
  border-radius: 1rem !important;
  border-color: var(--line) !important;
  background: var(--bg-panel) !important;
}

.accordion-header {
  padding: .9rem 1rem;
  font-weight: 800;
}

.accordion-item.is-open .accordion-content {
  background: var(--bg-base) !important;
}

.switch-container-item {
  color: var(--text-main);
}

.anoni-dock {
  width: min(calc(100% - 1.5rem), 56rem);
  bottom: 1rem;
  padding: .5rem;
  border-radius: 1.15rem;
  border: 1px solid var(--line);
  background: var(--dock-bg);
  box-shadow: 0 18px 40px -24px rgba(15, 23, 42, .45);
  backdrop-filter: blur(18px);
}

.dock-btn {
  border-radius: .75rem !important;
  background: var(--bg-surface) !important;
  color: var(--text-muted) !important;
}

.dock-btn:hover {
  background: var(--bg-panel) !important;
  color: var(--btn-color, var(--text-main)) !important;
  border-color: currentColor !important;
  transform: translateY(-1px);
}

.dock-btn.active {
  background: var(--brand-50) !important;
  color: var(--brand-700) !important;
  border-color: var(--brand-500) !important;
  box-shadow: none !important;
}

[data-theme="dark"] .dock-btn.active {
  background: rgba(16,185,129,.12) !important;
  color: #6ee7b7 !important;
}

.dock-arrow {
  border-radius: .8rem !important;
}

.dock-separator {
  background: var(--line) !important;
}

.dock-submenu {
  border-radius: 1rem !important;
  border: 1px solid var(--line) !important;
  background: var(--dock-bg) !important;
  box-shadow: var(--shadow-lg) !important;
  backdrop-filter: blur(18px);
}

#toggleControlsBtn,
#backToTopBtn {
  background: var(--ink) !important;
  color: #fff !important;
  box-shadow: var(--shadow-lg) !important;
}

[data-theme="dark"] #toggleControlsBtn,
[data-theme="dark"] #backToTopBtn {
  background: #fff !important;
  color: var(--ink) !important;
}

#multiMatchModal > div,
#genericConfirmModal > div,
#resetModal > div {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-xl) !important;
  background: var(--bg-panel) !important;
  box-shadow: var(--shadow-lg) !important;
}

#finalEditorModal > div {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-xl) !important;
  overflow: hidden;
  box-shadow: var(--shadow-lg) !important;
}

#finalEditor {
  border-radius: .35rem;
  box-shadow: 0 20px 60px rgba(15,23,42,.20) !important;
}

#airgap-toast {
  border-radius: 1rem;
  border-color: var(--brand-500);
  box-shadow: 0 18px 50px -30px rgba(16,185,129,.65);
}

#splash-screen {
  background:
    radial-gradient(circle at 50% 0%, rgba(16,185,129,.15), transparent 38%),
    #020617;
}

.splash-content {
  border-radius: 1.5rem;
  border-color: rgba(16,185,129,.22);
  background: rgba(2, 6, 23, .78);
  box-shadow: 0 24px 80px rgba(0,0,0,.32);
}

.splash-logo {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 900;
  letter-spacing: -.04em;
}

.airgap-progress-fill {
  background: var(--brand-500);
  box-shadow: none;
}

@media (max-width: 1024px) {
  header {
    margin: 0;
    border-radius: 0 0 1.75rem 1.75rem;
    border-left: 0;
    border-right: 0;
  }

  #proUploaderModal {
    width: min(calc(100% - 1rem), 80rem);
  }

  #comparisonArea > div:first-child {
    padding-inline: .75rem !important;
  }

  .comparison-area-layout {
    padding-inline: .75rem;
  }
}

@media (max-width: 768px) {
  header {
    padding: 5.25rem 1rem 2.5rem;
  }

  header::before {
    font-size: .64rem;
    letter-spacing: .1em;
  }

  header h1 {
    font-size: clamp(2.05rem, 12vw, 3.1rem);
  }

  header p::after {
    display: block;
    margin-top: .35rem;
  }

  #uploadArea {
    margin-top: 1rem;
    border-radius: 1.5rem !important;
  }

  .text-box {
    min-height: 520px !important;
    border-radius: 1.25rem !important;
  }

  .anoni-dock {
    width: calc(100% - 1rem);
    bottom: .5rem;
    border-radius: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

/* =========================================
   FIX FOCUS MODE FULLSCREEN EDGE-TO-EDGE
   =========================================
   In focus mode the app must occupy the entire viewport, not appear inside
   a rounded/padded container. JS hooks, IDs and onclick handlers unchanged.
*/
body.focus-mode-active {
  width: 100vw !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: var(--bg-base) !important;
}

body.focus-mode-active #proUploaderModal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  max-width: none !important;
  height: 100dvh !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  background: var(--bg-base) !important;
  box-shadow: none !important;
}

body.focus-mode-active #comparisonArea {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  background: var(--bg-base) !important;
}

body.focus-mode-active #comparisonArea > div:first-child {
  flex: 0 0 52px !important;
  width: 100% !important;
  height: 52px !important;
  min-height: 52px !important;
  max-height: 52px !important;
  margin: 0 !important;
  padding: 0 16px !important;
  border-radius: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  background: var(--bg-panel) !important;
  box-shadow: var(--shadow-sm) !important;
}

body.focus-mode-active .comparison-area-layout {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: calc(100dvh - 52px) !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 0 !important;
  overflow: hidden !important;
  border-radius: 0 !important;
}

@media (min-width: 1024px) {
  body.focus-mode-active .comparison-area-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 340px !important;
  }
}

body.focus-mode-active .comparison-area-layout > div {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

body.focus-mode-active .text-box,
body.focus-mode-active .controls-panel,
body.focus-mode-active .comparison-area-layout > div > .text-box {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border-top: 0 !important;
  border-bottom: 0 !important;
  border-left: 0 !important;
  border-right: 1px solid var(--line) !important;
}

body.focus-mode-active .comparison-area-layout > div:last-child,
body.focus-mode-active .comparison-area-layout > div:last-child .controls-panel {
  border-right: 0 !important;
}

body.focus-mode-active .text-box h4,
body.focus-mode-active .controls-panel h4,
body.focus-mode-active .text-box > div:first-child {
  border-radius: 0 !important;
}

body.focus-mode-active .text-content,
body.focus-mode-active #maskingControls {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: auto !important;
}

body.focus-mode-active .anoni-dock {
  bottom: 14px !important;
}

@media (max-width: 1023px) {
  body.focus-mode-active .comparison-area-layout {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100dvh - 52px) !important;
  }

  body.focus-mode-active .comparison-area-layout > div {
    flex: 1 1 0 !important;
    min-height: 0 !important;
  }
}

/* =========================================
   FOCUS MODE: FULLSCREEN APP, BOXED PANELS
   =========================================
   Mantiene la modalità a tutta viewport, ma ripristina i tre contenitori
   principali come box indipendenti. Non modifica ID, onclick o hook JS.
*/
body.focus-mode-active #comparisonArea {
  background: var(--bg-base) !important;
}

body.focus-mode-active #comparisonArea > div:first-child {
  border-radius: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  background: var(--bg-panel) !important;
}

body.focus-mode-active .comparison-area-layout {
  width: 100% !important;
  height: calc(100dvh - 52px) !important;
  padding: 1rem !important;
  gap: 1rem !important;
  overflow: hidden !important;
  background: var(--bg-base) !important;
  align-items: stretch !important;
}

body.focus-mode-active .comparison-area-layout > div {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  padding: 0 !important;
  border-radius: 1.35rem !important;
}

body.focus-mode-active .text-box,
body.focus-mode-active .controls-panel,
body.focus-mode-active .comparison-area-layout > div > .text-box {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  overflow: hidden !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--gray-200) !important;
  border-radius: 1.35rem !important;
  box-shadow: var(--shadow-sm) !important;
}

body.focus-mode-active .controls-panel {
  padding: 1.15rem !important;
}

body.focus-mode-active .text-box h4,
body.focus-mode-active .controls-panel h4,
body.focus-mode-active .text-box > div:first-child {
  border-radius: 1.35rem 1.35rem 0 0 !important;
}

body.focus-mode-active .text-content,
body.focus-mode-active #maskingControls {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
}

body.focus-mode-active .anoni-dock {
  bottom: 1.65rem !important;
}

@media (min-width: 1024px) {
  body.focus-mode-active .comparison-area-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 340px !important;
  }
}

@media (max-width: 1023px) {
  body.focus-mode-active .comparison-area-layout {
    display: flex !important;
    flex-direction: column !important;
    padding: .75rem !important;
    gap: .75rem !important;
  }

  body.focus-mode-active .comparison-area-layout > div {
    flex: 1 1 0 !important;
    min-height: 0 !important;
  }

  body.focus-mode-active .text-box,
  body.focus-mode-active .controls-panel,
  body.focus-mode-active .comparison-area-layout > div > .text-box {
    border-radius: 1.1rem !important;
  }
}

/* =========================================
   FIX 2026-05-07 C: READER STABILE + MOBILE CONTROLLI
   =========================================
   Riparte dal comportamento del CSS originale: niente regole su p/div interni,
   niente cambio di white-space e niente normalizzazioni che alterano i paragrafi.
   Mantiene solo il fix sfondo e i colori dei bottoni.
*/

/* Reader: stesso ritmo del CSS originale, ma sfondo pulito senza fascia/gradiente. */
.text-content,
body.focus-mode-active .text-content {
  background: var(--bg-base) !important;
  background-image: none !important;
  color: var(--text-main) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.96rem !important;
  line-height: 1.7 !important;
  letter-spacing: normal !important;
}

.text-content pre,
#originalText,
#maskedHtmlOutput {
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.7 !important;
  font-family: inherit !important;
  font-size: inherit !important;
  background: transparent !important;
  background-image: none !important;
  background-color: transparent !important;
}

#originalText {
  color: var(--gray-600) !important;
}

#maskedHtmlOutput {
  color: var(--text-main) !important;
  outline: none !important;
  min-height: 100% !important;
  cursor: text !important;
}

/* Importante: NON impostiamo margin/padding su p o div interni.
   Quando il JS applica etichette manuali, il DOM non deve cambiare metrica visiva. */
#originalText p,
#originalText div,
#maskedHtmlOutput p,
#maskedHtmlOutput div {
  font: inherit;
  line-height: inherit;
}

/* Etichette: colori invariati, solo assestamento verticale identico al CSS originale. */
.anon-data {
  line-height: 1.3 !important;
  vertical-align: baseline !important;
}

/* Colori testo/iconcine sui bottoni, senza interferire con onclick o stati JS. */
.search-btn,
.action-buttons-wrapper button,
#btnFocusMode,
.focus-mini-btn,
.editor-btn,
.dock-arrow,
.icon-btn,
.theme-toggle {
  color: var(--text-main) !important;
}

.search-btn.primary,
#btnFocusMode.active {
  color: var(--primary-light) !important;
}

#copyMaskedTextBtn,
#copyMaskedTextBtn * {
  color: #ffffff !important;
  stroke: currentColor !important;
}

[data-theme="dark"] #copyMaskedTextBtn,
[data-theme="dark"] #copyMaskedTextBtn * {
  color: var(--ink) !important;
  stroke: currentColor !important;
}

#downloadDocxBtn,
#downloadDocxBtn * {
  color: var(--brand-700) !important;
  stroke: currentColor !important;
}

[data-theme="dark"] #downloadDocxBtn,
[data-theme="dark"] #downloadDocxBtn * {
  color: #6ee7b7 !important;
  stroke: currentColor !important;
}

#resetAnonymizationBtn,
#resetAnonymizationBtn * {
  color: var(--text-main) !important;
  stroke: currentColor !important;
}

button svg,
.dock-btn svg,
.focus-mini-btn svg,
.editor-btn svg,
.icon-btn svg,
.theme-toggle svg,
.search-btn svg {
  stroke: currentColor !important;
}

.dock-submenu .dock-btn,
.dock-submenu .dock-btn::after,
.dock-submenu .sub-btn,
.dock-submenu .sub-btn::after {
  color: var(--text-main) !important;
}

.dock-submenu .dock-btn:hover,
.dock-submenu .dock-btn:hover::after,
.dock-submenu .sub-btn:hover,
.dock-submenu .sub-btn:hover::after {
  color: var(--btn-color, var(--brand-700)) !important;
}

.dock-btn.active,
.dock-btn.active * {
  color: var(--brand-700) !important;
  stroke: currentColor !important;
}

[data-theme="dark"] .dock-btn.active,
[data-theme="dark"] .dock-btn.active * {
  color: #6ee7b7 !important;
  stroke: currentColor !important;
}

#focusActionToolbar .focus-mini-btn[style*="danger"],
#focusActionToolbar .focus-mini-btn[style*="danger"] * {
  color: var(--danger) !important;
}
#focusActionToolbar .focus-mini-btn[style*="primary"],
#focusActionToolbar .focus-mini-btn[style*="primary"] * {
  color: var(--primary-light) !important;
}
#focusActionToolbar .focus-mini-btn[style*="success"],
#focusActionToolbar .focus-mini-btn[style*="success"] * {
  color: var(--success) !important;
}

/* Mobile: pannello anonimizzazioni come bottom sheet stabile.
   Evita tagli, doppio scroll e pulsante flottante sovrapposto al contenuto. */
@media (max-width: 1024px) {
  .comparison-area-layout {
    grid-template-columns: 1fr !important;
    padding-bottom: 108px !important;
  }

  .controls-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-height: min(88vh, calc(100dvh - 1rem)) !important;
    height: auto !important;
    padding: 1rem 1.15rem calc(5.25rem + env(safe-area-inset-bottom)) !important;
    border-radius: 1.5rem 1.5rem 0 0 !important;
    border: 1px solid var(--line) !important;
    border-bottom: 0 !important;
    background: var(--bg-panel) !important;
    box-shadow: 0 -18px 50px rgba(15, 23, 42, .18) !important;
    transform: translateY(100%);
    transition: transform .32s ease !important;
    z-index: 1100 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  [data-theme="dark"] .controls-panel {
    box-shadow: 0 -18px 50px rgba(0,0,0,.45) !important;
  }

  .controls-panel.open {
    transform: translateY(0) !important;
  }

  .controls-panel::before {
    content: "";
    display: block;
    width: 48px;
    height: 5px;
    margin: 0 auto 1rem;
    border-radius: 999px;
    background: var(--gray-300);
  }

  .controls-panel h4 {
    position: sticky;
    top: -1rem;
    z-index: 2;
    margin: 0 -1.15rem 1rem !important;
    padding: .95rem 1.15rem !important;
    border-radius: 1.5rem 1.5rem 0 0 !important;
    background: var(--bg-panel) !important;
    border-bottom: 1px solid var(--line) !important;
    text-align: left !important;
  }

  #maskingControls {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 0 1rem !important;
  }

  .accordion-item {
    border-radius: 1rem !important;
    overflow: hidden !important;
  }

  .accordion-item.is-open .accordion-content {
    max-height: none !important;
    overflow: visible !important;
  }

  #toggleControlsBtn {
    width: 52px !important;
    height: 52px !important;
    bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    z-index: 1200 !important;
  }

  #toggleControlsBtn.active {
    transform: translateX(-50%) rotate(90deg) scale(.96) !important;
  }
}

@media (max-width: 768px) {
  .text-box {
    height: 75vh !important;
    max-height: 80vh !important;
    min-height: 500px !important;
  }

  .text-content {
    padding-bottom: 95px !important;
  }

  .anoni-dock {
    width: calc(100% - 1rem) !important;
    bottom: .65rem !important;
    padding: .4rem !important;
    border-radius: 1rem !important;
  }

  .dock-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
  }
}

/* =========================================
   MICRO FIX UI - DARK FILE INPUT, MOBILE BRAND, AIRGAP TOAST
   Additive only: no JS hooks, IDs or .anon-* palettes changed.
   Importante: non tocca .controls-panel, #maskingControls, accordion o dock mobile.
   ========================================= */
#fileInput,
#fileInput::file-selector-button {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#fileInput {
  color: var(--text-main) !important;
  background-color: var(--bg-panel) !important;
}

#fileInput::file-selector-button {
  margin-right: .9rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--ink);
  color: #fff;
  padding: .62rem .9rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

#fileInput:hover::file-selector-button {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

[data-theme="dark"] #fileInput {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: rgba(16, 185, 129, .45) !important;
}

[data-theme="dark"] #fileInput::file-selector-button {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(248, 250, 252, .22);
}

[data-theme="dark"] #fileInput:hover::file-selector-button {
  background: #d1fae5;
  color: #064e3b;
  border-color: #6ee7b7;
}

/* Safari/WebKit fallback */
#fileInput::-webkit-file-upload-button {
  margin-right: .9rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--ink);
  color: #fff;
  padding: .62rem .9rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

[data-theme="dark"] #fileInput::-webkit-file-upload-button {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(248, 250, 252, .22);
}

@media (max-width: 768px) {
  header h1 {
    font-size: clamp(1.72rem, 9.4vw, 2.55rem) !important;
    letter-spacing: -0.065em;
  }

  header h1 sup {
    font-size: .36em !important;
    margin-left: 2px !important;
    letter-spacing: .04em !important;
  }

  #airgap-toast {
    left: max(.75rem, env(safe-area-inset-left));
    right: max(.75rem, env(safe-area-inset-right));
    bottom: calc(.85rem + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    transform: translateY(120px);
    padding: .9rem 1rem;
    border-radius: 1rem;
    align-items: flex-start;
    font-size: .9rem;
    line-height: 1.45;
  }

  #airgap-toast.show {
    transform: translateY(0);
  }

  #airgap-toast span {
    min-width: 0;
  }
}

@media (max-width: 420px) {
  header h1 {
    font-size: clamp(1.55rem, 8.8vw, 2.1rem) !important;
  }

  #fileInput {
    font-size: .92rem !important;
    padding: .85rem !important;
  }

  #fileInput::file-selector-button,
  #fileInput::-webkit-file-upload-button {
    margin-right: .65rem;
    padding: .55rem .7rem;
    border-radius: .65rem;
  }
}

/* =========================================
   FIX: DISABILITA ALLINEAMENTO SPAZI IN FOCUS MODE E MOBILE
   ========================================= */
/* Disabilita i gap quando la Focus Mode è attiva */
body.focus-mode-active [data-sync] {
    min-height: 0 !important;
    height: auto !important;
}
body.focus-mode-active .sync-gap-filler::after {
    display: none !important;
}

/* =========================================
   FIX ALLINEAMENTO SPAZI (SOLO MOBILE)
   ========================================= */
/* Su schermi piccoli (colonne impilate) disabilitiamo le strisce e le altezze forzate */
@media (max-width: 1023px) {
    [data-sync] {
        min-height: 0 !important;
        height: auto !important;
    }
    .sync-gap-filler::after {
        display: none !important;
    }
}

/* =========================================
   FIX: SFONDO ETICHETTE SOTTOMENU (TENDINA)
   ========================================= */
/* Forza i pulsanti dei sottomenu a occupare l'intera larghezza della tendina,
   scavalcando la regola mobile che li trasforma in piccoli quadrati */
.dock-submenu .dock-btn,
.dock-submenu .sub-btn {
    width: 100% !important;
    min-width: max-content !important;
    justify-content: flex-start !important;
}


/* =========================================================
   STEP 1 - BOTTONE FOCUS MOBILE NEL PANNELLO ANONIMIZZATO
   ========================================================= */

/* Stato base: il bottone mobile non si vede su desktop */
#btnMobileFocusMode {
  display: none;
}

/* Stile del bottone mobile */
.mobile-focus-btn {
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--gray-300);
  background: var(--bg-panel);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  white-space: nowrap;
}

.mobile-focus-btn:hover {
  border-color: var(--primary);
  background: var(--bg-surface);
  color: var(--primary);
}

.mobile-focus-btn svg {
  flex: 0 0 auto;
}

/* Mobile: il bottone desktop resta nascosto, quello mobile appare */
@media (max-width: 768px) {
  #btnFocusMode {
    display: none !important;
  }

  #btnMobileFocusMode {
    display: inline-flex !important;
  }
}

/* Desktop/tablet: il bottone mobile resta nascosto */
@media (min-width: 769px) {
  #btnMobileFocusMode {
    display: none !important;
  }
}

/* Quando la focus mode è attiva, il bottone mobile diventa "Esci" */
body.focus-mode-active #btnMobileFocusMode {
  color: var(--danger);
  border-color: rgba(190, 18, 60, 0.25);
  background: rgba(190, 18, 60, 0.06);
}

body.focus-mode-active #btnMobileFocusMode span {
  font-size: 0;
}

body.focus-mode-active #btnMobileFocusMode span::after {
  content: "Esci";
  font-size: 0.78rem;
}

/* =========================================================
   STEP 2 - FOCUS MODE MOBILE FULLSCREEN
   Usa il bottone #btnMobileFocusMode già inserito.
   Non modifica i bottoni di AnoniDock.
   ========================================================= */

@media (max-width: 768px) {

  /* Blocca lo scroll del body quando siamo in Focus */
  body.focus-mode-active {
    overflow: hidden !important;
    height: 100dvh !important;
  }

  /* Il contenitore principale diventa fullscreen */
  body.focus-mode-active #proUploaderModal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--bg-base) !important;
    overflow: hidden !important;
  }

  body.focus-mode-active #comparisonArea {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-base) !important;
    overflow: hidden !important;
  }

  /* Header superiore della comparison area: compatto */
  body.focus-mode-active #comparisonArea > div:first-child {
    flex: 0 0 auto !important;
    min-height: 56px !important;
    height: auto !important;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    border-bottom: 1px solid var(--gray-200) !important;
    box-shadow: var(--shadow-sm) !important;
    z-index: 1400 !important;
  }

  [data-theme="dark"] body.focus-mode-active #comparisonArea > div:first-child,
  body.focus-mode-active[data-theme="dark"] #comparisonArea > div:first-child {
    background: rgba(30, 41, 59, 0.96) !important;
  }

  /* Layout a una sola colonna */
  body.focus-mode-active .comparison-area-layout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    display: block !important;
    padding: 10px 10px calc(96px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    overflow: hidden !important;
    background: var(--bg-base) !important;
  }

  /* Nasconde il testo originale SOLO nella Focus mobile */
  body.focus-mode-active .comparison-area-layout > .text-box:first-child {
    display: none !important;
  }

  /* Nasconde eventuali elementi desktop non necessari in Focus mobile */
  body.focus-mode-active #syncScrollContainer {
    display: none !important;
  }

  body.focus-mode-active .action-buttons-wrapper {
    display: none !important;
  }

  /* Il blocco centrale, che contiene testo anonimizzato + dock, diventa la vista principale */
  body.focus-mode-active .comparison-area-layout > div:nth-child(2) {
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Card del testo anonimizzato */
  body.focus-mode-active .comparison-area-layout > div:nth-child(2) > .text-box {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 20px !important;
    border: 1px solid var(--gray-200) !important;
    background: var(--bg-panel) !important;
    box-shadow: var(--shadow-sm) !important;
    overflow: hidden !important;
  }

  /* Header interno del pannello Testo Anonimizzato */
  body.focus-mode-active .comparison-area-layout > div:nth-child(2) > .text-box > div:first-child {
    flex: 0 0 auto !important;
    padding: 10px 12px !important;
    border-radius: 20px 20px 0 0 !important;
    background: var(--bg-surface) !important;
  }

  /* Area scrollabile del testo */
  body.focus-mode-active .comparison-area-layout > div:nth-child(2) .text-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1rem !important;
    background: var(--bg-base) !important;
  }

  body.focus-mode-active #maskedHtmlOutput {
    min-height: 100% !important;
    font-size: 0.96rem !important;
    line-height: 1.72 !important;
  }

  /* Pannello controlli trasformato in bottom sheet */
  body.focus-mode-active .controls-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(82px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    height: auto !important;
    max-height: min(54dvh, 430px) !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-radius: 22px 22px 0 0 !important;
    border: none !important;
    border-top: 1px solid var(--gray-200) !important;
    background: var(--bg-panel) !important;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18) !important;
    overflow: hidden !important;
    z-index: 1350 !important;

    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(22px) scale(0.985) !important;
    transition: opacity 0.24s ease, transform 0.28s ease !important;
  }

  body.focus-mode-active .controls-panel.open {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
  }

  body.focus-mode-active .controls-panel::before {
    content: "";
    display: block;
    width: 46px;
    height: 5px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: var(--gray-300);
  }

  body.focus-mode-active .controls-panel h4 {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
    margin: 0 !important;
    padding: 12px 14px !important;
    border-radius: 22px 22px 0 0 !important;
    border-bottom: 1px solid var(--gray-200) !important;
    background: var(--bg-surface) !important;
    font-size: 0.92rem !important;
  }

  body.focus-mode-active #maskingControls {
    max-height: calc(min(54dvh, 430px) - 62px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 10px 12px 14px !important;
  }

  /* Bottone per aprire/chiudere i controlli */
  body.focus-mode-active #toggleControlsBtn {
    display: flex !important;
    position: fixed !important;
    right: 14px !important;
    bottom: calc(92px + env(safe-area-inset-bottom)) !important;
    z-index: 1450 !important;
  }

  /* AnoniDock: NON tocchiamo i bottoni, solo posizione del contenitore */
  body.focus-mode-active #anoniDock,
  body.focus-mode-active .anoni-dock {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    transform: translateX(-50%) !important;
    z-index: 1300 !important;
  }
}

/* =========================================================
   STEP 3 - BACKDROP MOBILE FOCUS
   ========================================================= */

.mobile-focus-backdrop {
  display: none;
}

@media (max-width: 768px) {

  body.focus-mode-active .mobile-focus-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1320;
    display: block;
    background: rgba(15, 23, 42, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }

  body.focus-mode-active.mobile-controls-open .mobile-focus-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.focus-mode-active.mobile-controls-open .comparison-area-layout {
    filter: blur(1px);
    transform: translateY(-1px);
    transition: filter 0.24s ease, transform 0.24s ease;
  }

  body.focus-mode-active.mobile-controls-open .controls-panel {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
  }
}

/* =========================================================
   STEP 4 - HEADER MOBILE FOCUS PULITO
   ========================================================= */

@media (max-width: 768px) {

  /* Header generale della revisione in modalità focus */
  body.focus-mode-active #comparisonArea > div:first-child {
    padding: max(12px, env(safe-area-inset-top)) 12px 10px !important;
    min-height: 74px !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
  }

  [data-theme="dark"] body.focus-mode-active #comparisonArea > div:first-child {
    background: rgba(30, 41, 59, 0.96) !important;
  }

  /* Titolo "Revisione Anonimizzazione" più compatto */
  body.focus-mode-active #comparisonArea > div:first-child h3 {
    font-size: 1rem !important;
    line-height: 1.05 !important;
    margin: 0 0 6px 0 !important;
    letter-spacing: -0.03em !important;
    font-weight: 900 !important;
  }

  /* Pill con nome file */
  body.focus-mode-active #displayFileName {
    display: inline-block !important;
    max-width: 46vw !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 0.72rem !important;
  }

  body.focus-mode-active #displayFileName::before {
    content: "";
  }

  body.focus-mode-active #comparisonArea > div:first-child > div:first-child > div {
    padding: 3px 9px !important;
    border-radius: 999px !important;
    max-width: 52vw !important;
    background: var(--bg-surface) !important;
  }

  /* Nasconde controlli desktop non utili in focus mobile */
  body.focus-mode-active #aiContextContainer,
  body.focus-mode-active #syncScrollContainer,
  body.focus-mode-active #btnFocusMode {
    display: none !important;
  }

  /* Mostra la toolbar azioni focus già presente nell'HTML */
  body.focus-mode-active #focusActionToolbar {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding-right: 0 !important;
    margin-right: 0 !important;
    border-right: none !important;
  }

  /* Mini bottoni toolbar */
  body.focus-mode-active #focusActionToolbar .focus-mini-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    border: 1px solid var(--gray-300) !important;
    background: var(--bg-panel) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: var(--shadow-sm) !important;
  }

  body.focus-mode-active #focusActionToolbar .focus-mini-btn:hover {
    background: var(--bg-surface) !important;
    transform: none !important;
  }

  /* Nasconde temporaneamente il cambio tema dalla toolbar se lo spazio è poco */
  body.focus-mode-active #focusActionToolbar .focus-mini-btn:nth-child(4) {
    display: none !important;
  }

  /* Header interno della card anonimizzata più compatto */
  body.focus-mode-active .comparison-area-layout > div:nth-child(2) > .text-box > div:first-child {
    min-height: 52px !important;
    padding: 9px 12px !important;
  }

  body.focus-mode-active .comparison-area-layout > div:nth-child(2) > .text-box > div:first-child h4 {
    font-size: 0.95rem !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
  }

  /* Bottone Focus mobile diventa più evidente in stato Esci */
  body.focus-mode-active #btnMobileFocusMode {
    min-height: 34px !important;
    padding: 6px 11px !important;
    border-color: rgba(190, 18, 60, 0.28) !important;
    background: rgba(190, 18, 60, 0.07) !important;
    color: var(--danger) !important;
  }

  /* Bottone search nel pannello anonimizzato */
  body.focus-mode-active .comparison-area-layout > div:nth-child(2) > .text-box > div:first-child button[onclick="toggleSearchToolbar()"] {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    justify-content: center !important;
    border: 1px solid var(--gray-300) !important;
    background: var(--bg-panel) !important;
    box-shadow: var(--shadow-sm) !important;
  }

  body.focus-mode-active .comparison-area-layout > div:nth-child(2) > .text-box > div:first-child button[onclick="toggleSearchToolbar()"] svg {
    width: 17px !important;
    height: 17px !important;
  }
}


/* =========================================================
   FIX FINALE - MOBILE FOCUS CONTROLS PANEL
   Corregge blur, stacking e interazione pannello controlli.
   Da mettere IN FONDO al CSS.
   ========================================================= */

@media (max-width: 768px) {

  /* Mai sfocare .comparison-area-layout: contiene anche il pannello controlli */
  body.focus-mode-active.mobile-controls-open .comparison-area-layout {
    filter: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  /* Backdrop solo come overlay sotto il pannello */
  body.focus-mode-active .mobile-focus-backdrop {
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
    background: rgba(15, 23, 42, 0.24) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: 1400 !important;
    transition: opacity 0.24s ease !important;
  }

  body.focus-mode-active.mobile-controls-open .mobile-focus-backdrop {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Bottom sheet controlli: sopra backdrop e sopra layout */
  body.focus-mode-active .controls-panel {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(84px + env(safe-area-inset-bottom)) !important;

    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: min(58dvh, 460px) !important;

    display: flex !important;
    flex-direction: column !important;

    padding: 0 !important;
    margin: 0 !important;

    border-radius: 22px !important;
    border: 1px solid var(--gray-200) !important;
    background: var(--bg-panel) !important;
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.24) !important;

    overflow: hidden !important;

    z-index: 1500 !important;

    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(24px) scale(0.985) !important;
    transition:
      opacity 0.24s ease,
      transform 0.28s ease,
      visibility 0.24s ease !important;
  }

  body.focus-mode-active.mobile-controls-open .controls-panel,
  body.focus-mode-active .controls-panel.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
  }

  /* Maniglia superiore del bottom sheet */
  body.focus-mode-active .controls-panel::before {
    content: "" !important;
    flex: 0 0 auto !important;
    display: block !important;
    width: 46px !important;
    height: 5px !important;
    margin: 10px auto 0 !important;
    border-radius: 999px !important;
    background: var(--gray-300) !important;
  }

  /* Header del pannello */
  body.focus-mode-active .controls-panel h4 {
    flex: 0 0 auto !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;

    margin: 0 !important;
    padding: 12px 14px !important;

    border-radius: 22px 22px 0 0 !important;
    border-bottom: 1px solid var(--gray-200) !important;
    background: var(--bg-surface) !important;

    color: var(--text-main) !important;
    font-size: 0.92rem !important;
    font-weight: 900 !important;
    text-align: left !important;
  }

  /* Corpo scrollabile del pannello */
  body.focus-mode-active #maskingControls {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;

    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;

    padding: 10px 12px 14px !important;
  }

  /* Bottone flottante controlli sopra tutto */
  body.focus-mode-active #toggleControlsBtn {
    display: flex !important;
    position: fixed !important;
    right: 14px !important;
    left: auto !important;
    bottom: calc(92px + env(safe-area-inset-bottom)) !important;

    width: 48px !important;
    height: 48px !important;

    z-index: 1600 !important;
    transform: none !important;
  }

  body.focus-mode-active #toggleControlsBtn.active {
    transform: rotate(90deg) scale(0.95) !important;
  }

  /* Mantiene AnoniDock sotto al pannello, invariata nei bottoni */
  body.focus-mode-active #anoniDock,
  body.focus-mode-active .anoni-dock {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    transform: translateX(-50%) !important;
    z-index: 1300 !important;
  }
}

/* =========================================================
   FIX DEFINITIVO - PANNELLO ANONIMIZZAZIONI FOCUS MOBILE
   Bottom sheet stabile, top visibile, contenuto scrollabile.
   Deve stare COME ULTIMO BLOCCO del CSS.
   ========================================================= */

@media (max-width: 768px) {

  /*
    1. Niente blur sul layout.
    Il blur prima colpiva anche il pannello perché .controls-panel
    vive dentro .comparison-area-layout.
  */
  body.focus-mode-active.mobile-controls-open .comparison-area-layout {
    filter: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  /*
    2. Backdrop sotto al pannello.
  */
  body.focus-mode-active .mobile-focus-backdrop {
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
    background: rgba(15, 23, 42, 0.24) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: 1400 !important;
    transition: opacity 0.22s ease !important;
  }

  body.focus-mode-active.mobile-controls-open .mobile-focus-backdrop {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /*
    3. Il pannello NON è più height:auto.
    Gli diamo top e bottom espliciti:
    - top: lascia sempre visibile la parte alta;
    - bottom: lascia spazio ad AnoniDock.
  */
  body.focus-mode-active .controls-panel {
    position: fixed !important;

    left: 10px !important;
    right: 10px !important;

    /*
      Questo è il punto chiave:
      il pannello parte sotto l'header della focus view,
      quindi la sua parte alta è sempre visibile.
    */
    top: calc(92px + env(safe-area-inset-top)) !important;

    /*
      Spazio per AnoniDock + margine.
      Se la dock copre ancora il pannello, porta 96px a 108px.
    */
    bottom: calc(96px + env(safe-area-inset-bottom)) !important;

    width: auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;

    display: flex !important;
    flex-direction: column !important;

    padding: 0 !important;
    margin: 0 !important;

    border-radius: 22px !important;
    border: 1px solid var(--gray-200) !important;
    background: var(--bg-panel) !important;
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.25) !important;

    overflow: hidden !important;

    z-index: 1500 !important;

    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;

    transform: translateY(18px) scale(0.985) !important;
    transition:
      opacity 0.22s ease,
      transform 0.24s ease,
      visibility 0.22s ease !important;
  }

  body.focus-mode-active.mobile-controls-open .controls-panel,
  body.focus-mode-active .controls-panel.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
  }

  /*
    4. Maniglia sempre visibile.
  */
  body.focus-mode-active .controls-panel::before {
    content: "" !important;
    flex: 0 0 auto !important;
    display: block !important;

    width: 46px !important;
    height: 5px !important;
    margin: 10px auto 8px !important;

    border-radius: 999px !important;
    background: var(--gray-300) !important;
  }

  /*
    5. Header del pannello fisso in alto.
  */
  body.focus-mode-active .controls-panel h4 {
    flex: 0 0 auto !important;

    position: relative !important;
    top: auto !important;

    margin: 0 !important;
    padding: 10px 14px 11px !important;

    border-radius: 0 !important;
    border-bottom: 1px solid var(--gray-200) !important;
    background: var(--bg-surface) !important;

    color: var(--text-main) !important;
    font-size: 0.92rem !important;
    line-height: 1.15 !important;
    font-weight: 900 !important;
    text-align: left !important;
  }

  /*
    6. SOLO il corpo del pannello scrolla.
    Questo è ciò che rende il pannello gestibile.
  */
  body.focus-mode-active #maskingControls {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;

    padding: 10px 10px 14px !important;
  }

  /*
    7. Gli accordion devono vivere dentro lo scroll interno,
    non forzare l'altezza del pannello.
  */
  body.focus-mode-active #maskingControls .accordion-item {
    overflow: hidden !important;
    margin-bottom: 8px !important;
    border-radius: 14px !important;
  }

  body.focus-mode-active #maskingControls .accordion-header {
    padding: 10px 10px !important;
  }

  body.focus-mode-active #maskingControls .accordion-content {
    overflow: hidden !important;
  }

  body.focus-mode-active #maskingControls .accordion-item.is-open .accordion-content {
    max-height: none !important;
    overflow: visible !important;
  }

  /*
    8. Righe più compatte e testi lunghi sotto controllo.
  */
  body.focus-mode-active #maskingControls .switch-container-item {
    padding: 9px 8px !important;
    gap: 8px !important;
    align-items: center !important;
  }

  body.focus-mode-active #maskingControls .control-label-content {
    min-width: 0 !important;
    overflow: hidden !important;
  }

  body.focus-mode-active #maskingControls .control-label-content span {
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  body.focus-mode-active #maskingControls .control-label-content span:first-child {
    font-size: 0.82rem !important;
    line-height: 1.25 !important;
  }

  body.focus-mode-active #maskingControls .control-label-content span[id^="label_"] {
    font-size: 0.78rem !important;
    line-height: 1.25 !important;
  }

  /*
    9. Pulsante controlli sempre accessibile, ma non sopra l'header del pannello.
  */
  body.focus-mode-active #toggleControlsBtn {
    display: flex !important;
    position: fixed !important;

    right: 14px !important;
    left: auto !important;
    bottom: calc(92px + env(safe-area-inset-bottom)) !important;

    width: 48px !important;
    height: 48px !important;

    z-index: 1600 !important;
    transform: none !important;
  }

  body.focus-mode-active #toggleControlsBtn.active {
    transform: rotate(90deg) scale(0.95) !important;
  }

  /*
    10. AnoniDock sotto al pannello, senza modificare i bottoni.
  */
  body.focus-mode-active #anoniDock,
  body.focus-mode-active .anoni-dock {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    transform: translateX(-50%) !important;
    z-index: 1300 !important;
  }
}

/* =========================================================
   FIX - SPAZIO INFERIORE PANNELLO CONTROLLI FOCUS MOBILE
   ========================================================= */

@media (max-width: 768px) {

  /*
    Aumenta lo spazio sotto al bottom sheet,
    così AnoniDock non copre la parte finale del pannello.
  */
  body.focus-mode-active .controls-panel {
    bottom: calc(128px + env(safe-area-inset-bottom)) !important;
  }

  /*
    Il contenuto interno ha più respiro in fondo:
    l'ultima voce resta raggiungibile e non finisce sotto il bordo.
  */
  body.focus-mode-active #maskingControls {
    padding-bottom: 34px !important;
    scroll-padding-bottom: 34px !important;
  }

  /*
    Anche l'ultimo accordion/ultima card ha margine finale.
  */
  body.focus-mode-active #maskingControls > *:last-child {
    margin-bottom: 22px !important;
  }

  /*
    Il bottone flottante dei controlli resta sopra AnoniDock,
    ma più coerente con lo spazio aumentato.
  */
  body.focus-mode-active #toggleControlsBtn {
    bottom: calc(92px + env(safe-area-inset-bottom)) !important;
  }
}

/* =========================================================
   FIX DEFINITIVO - SCROLL FINO IN FONDO PANNELLO MOBILE
   ========================================================= */

@media (max-width: 768px) {

  body.focus-mode-active .controls-panel {
    top: calc(92px + env(safe-area-inset-top)) !important;
    bottom: calc(112px + env(safe-area-inset-bottom)) !important;

    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;

    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  body.focus-mode-active .controls-panel::before {
    flex: 0 0 auto !important;
  }

  body.focus-mode-active .controls-panel h4 {
    flex: 0 0 auto !important;
  }

  body.focus-mode-active #maskingControls {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;

    padding: 10px 10px 0 !important;
    scroll-padding-bottom: 120px !important;
  }

  /*
    Questo è il punto importante:
    crea spazio scrollabile DOPO l'ultima voce.
    Così l'ultimo elemento può salire sopra AnoniDock e diventare cliccabile.
  */
  body.focus-mode-active #maskingControls::after {
    content: "" !important;
    display: block !important;
    width: 100% !important;
    height: calc(140px + env(safe-area-inset-bottom)) !important;
    flex: 0 0 auto !important;
  }

  body.focus-mode-active #maskingControls > *:last-child {
    margin-bottom: 0 !important;
  }
}

/* =========================================================
   FIX - HEADER SUPERIORE FOCUS MOBILE
   Revisione Anonimizzazione + file + azioni
   ========================================================= */

@media (max-width: 768px) {

  /*
    Header alto della schermata focus.
    È il primo div dentro #comparisonArea.
    Lo forziamo a due colonne:
    sinistra = titolo + file
    destra = bottoni
  */
  body.focus-mode-active #comparisonArea > div:first-child {
    box-sizing: border-box !important;

    width: 100vw !important;
    min-width: 0 !important;

    min-height: 70px !important;
    height: auto !important;

    margin: 0 !important;
    padding:
      max(10px, env(safe-area-inset-top))
      10px
      9px !important;

    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: auto !important;
    column-gap: 8px !important;
    row-gap: 0 !important;

    align-items: center !important;
    justify-items: stretch !important;

    text-align: left !important;

    background: rgba(255, 255, 255, 0.96) !important;
    border-bottom: 1px solid var(--gray-200) !important;
    box-shadow: var(--shadow-sm) !important;

    position: relative !important;
    z-index: 1450 !important;

    overflow: hidden !important;
  }

  [data-theme="dark"] body.focus-mode-active #comparisonArea > div:first-child {
    background: rgba(30, 41, 59, 0.96) !important;
  }

  /*
    Colonna sinistra: titolo + filename.
  */
  body.focus-mode-active #comparisonArea > div:first-child > div:first-child {
    grid-column: 1 !important;

    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    height: auto !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 4px !important;

    text-align: left !important;
    overflow: hidden !important;
  }

  body.focus-mode-active #comparisonArea > div:first-child h3 {
    display: block !important;

    width: 100% !important;
    max-width: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    font-size: 0.98rem !important;
    line-height: 1.08 !important;
    font-weight: 900 !important;
    letter-spacing: -0.03em !important;

    color: var(--text-main) !important;
    text-align: left !important;

    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /*
    Pill del nome file.
  */
  body.focus-mode-active #comparisonArea > div:first-child > div:first-child > div {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;

    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;

    height: auto !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 3px 8px !important;

    border-radius: 999px !important;
    border: 1px solid var(--gray-300) !important;
    background: var(--bg-surface) !important;

    text-align: left !important;
    overflow: hidden !important;
  }

  body.focus-mode-active #displayFileName {
    display: block !important;

    max-width: 100% !important;
    min-width: 0 !important;

    font-size: 0.7rem !important;
    line-height: 1.1 !important;
    font-weight: 800 !important;

    color: var(--text-muted) !important;
    text-align: left !important;

    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /*
    Colonna destra: toolbar e controlli.
    Deve restare una riga orizzontale.
  */
  body.focus-mode-active #comparisonArea > div:first-child > div:last-child {
    grid-column: 2 !important;

    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;

    height: auto !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 5px !important;

    text-align: right !important;
    overflow: visible !important;
  }

  /*
    Nasconde controlli desktop non adatti alla focus mobile.
  */
  body.focus-mode-active #syncScrollContainer,
  body.focus-mode-active #aiContextContainer,
  body.focus-mode-active #btnFocusMode {
    display: none !important;
  }

  /*
    Mostra la toolbar azioni compatta.
  */
  body.focus-mode-active #focusActionToolbar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;

    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;

    height: auto !important;

    gap: 5px !important;

    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;

    text-align: right !important;
    overflow: visible !important;
  }

  body.focus-mode-active #focusActionToolbar .focus-mini-btn {
    box-sizing: border-box !important;

    flex: 0 0 34px !important;

    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    max-width: 34px !important;
    max-height: 34px !important;

    margin: 0 !important;
    padding: 0 !important;

    border-radius: 999px !important;
    border: 1px solid var(--gray-300) !important;

    background: var(--bg-panel) !important;
    color: var(--text-main) !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    box-shadow: var(--shadow-sm) !important;
    cursor: pointer !important;
    transform: none !important;
  }

  body.focus-mode-active #focusActionToolbar .focus-mini-btn svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    flex: 0 0 auto !important;
  }

  /*
    Su mobile teniamo solo:
    1 reset
    2 copia
    3 PDF
    Nascondiamo il tema per evitare affollamento.
  */
  body.focus-mode-active #focusActionToolbar .focus-mini-btn:nth-child(4) {
    display: none !important;
  }

  /*
    Micro-schermi: titolo e bottoni ancora più compatti.
  */
  @media (max-width: 380px) {
    body.focus-mode-active #comparisonArea > div:first-child {
      min-height: 66px !important;
      column-gap: 6px !important;
      padding-left: 8px !important;
      padding-right: 8px !important;
    }

    body.focus-mode-active #comparisonArea > div:first-child h3 {
      font-size: 0.9rem !important;
    }

    body.focus-mode-active #displayFileName {
      font-size: 0.66rem !important;
    }

    body.focus-mode-active #focusActionToolbar {
      gap: 4px !important;
    }

    body.focus-mode-active #focusActionToolbar .focus-mini-btn {
      flex-basis: 31px !important;
      width: 31px !important;
      height: 31px !important;
      min-width: 31px !important;
      min-height: 31px !important;
      max-width: 31px !important;
      max-height: 31px !important;
    }

    body.focus-mode-active #focusActionToolbar .focus-mini-btn svg {
      width: 15px !important;
      height: 15px !important;
    }
  }
}

@media (hover: none), (pointer: coarse) {
  /*
    Non nascondiamo #global-anoni-tooltip:
    su mobile serve per mostrare per un attimo il titolo dei bottoni AnoniDock.
  */
  #global-anoni-tooltip {
    pointer-events: none !important;
  }

  /*
    Disattiva eventuali tooltip CSS pseudo-elemento,
    così non restano appesi sui bottoni.
  */
  .btn-action-link:hover::after,
  .btn-action-link:focus::after,
  .btn-action-link:active::after,
  .dock-btn:hover::after,
  .dock-btn:focus::after,
  .dock-btn:active::after {
    display: none !important;
    content: none !important;
  }
}

/* =========================================================
   EDITOR WORD - MODAL, TOOLBAR E RESPONSIVE
   ========================================================= */

.final-editor-modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.85);
  z-index: 99999;
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
}

.final-editor-window {
  width: min(96vw, 1120px);
  height: min(92vh, 980px);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 28px 80px -36px rgba(0, 0, 0, .75);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--gray-200);
}

.final-editor-toolbar {
  min-height: 64px;
  padding: .7rem .85rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-surface));
  border-bottom: 1px solid var(--gray-200);
  scrollbar-width: thin;
  flex-shrink: 0;
}

.final-editor-toolbar::-webkit-scrollbar {
  height: 6px;
}

.final-editor-toolbar::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 999px;
}

.editor-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
}

.editor-toolbar-anonymize {
  gap: .5rem;
}

.editor-select-label {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0 .7rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, .1);
  color: var(--success);
  border: 1px solid rgba(15, 118, 110, .18);
  font-size: .82rem;
  font-weight: 800;
  white-space: nowrap;
}

.editor-select-label svg,
.editor-btn svg,
.editor-action-btn svg {
  stroke: currentColor;
}

.editor-select {
  height: 36px;
  min-width: 150px;
  padding: 0 2rem 0 .8rem;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  background: var(--bg-base);
  color: var(--text-main);
  font-size: .86rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.editor-select:focus {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .15);
}

.editor-toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--gray-200);
  flex: 0 0 auto;
  margin: 0 .15rem;
}

.editor-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 .72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border-radius: 999px !important;
  border: 1px solid var(--gray-200) !important;
  background: var(--bg-base) !important;
  color: var(--text-main) !important;
  font-size: .86rem;
  font-weight: 800 !important;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
  white-space: nowrap;
}

.editor-btn:hover {
  transform: translateY(-1px);
  background: var(--bg-panel) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.editor-btn:active {
  transform: translateY(0) scale(.98);
}

.editor-toolbar-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  flex: 0 0 auto;
}

.editor-action-btn {
  height: 38px;
  padding: 0 .9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--bg-base);
  color: var(--text-main);
  font-size: .86rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
  white-space: nowrap;
}

.editor-action-btn:hover {
  transform: translateY(-1px);
}

.editor-action-muted {
  color: var(--text-muted);
}

.editor-action-muted:hover {
  border-color: var(--gray-300);
  background: var(--bg-panel);
  color: var(--text-main);
}

.editor-action-pro {
  color: var(--primary);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-base));
}

.editor-action-pro:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--bg-base));
}

.editor-action-audit {
  color: var(--warning);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  background: color-mix(in srgb, var(--warning) 8%, var(--bg-base));
}

.editor-action-audit:hover {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, var(--bg-base));
}

.editor-action-primary {
  border-color: var(--success);
  background: var(--success);
  color: #ffffff;
}

.editor-action-primary:hover {
  background: color-mix(in srgb, var(--success) 88%, #000);
  border-color: color-mix(in srgb, var(--success) 88%, #000);
}

.final-editor-stage {
  flex: 1;
  background: var(--gray-800);
  overflow-y: auto;
  position: relative;
  width: 100%;
}

.final-editor-page-wrap {
  min-height: 100%;
  padding: 40px 0;
  display: flex;
  justify-content: center;
}

#finalEditor {
  width: 21cm;
  min-height: 29.7cm;
  background: #ffffff;
  color: #111827;
  padding: 2.5cm 2cm;
  font-family: 'Inter', sans-serif;
  font-size: 11pt;
  line-height: 1.55;
  outline: none;
  box-shadow: 0 18px 45px -30px rgba(0,0,0,.55);
}

.editor-highlight-group {
  gap: .28rem;
}

.editor-highlight-btn {
  width: 36px;
  min-width: 36px;
  padding: 0 !important;
}

.editor-highlight-swatch {
  width: 17px;
  height: 17px;
  display: inline-block;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, .18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}

.editor-highlight-clear {
  color: var(--danger) !important;
  font-size: 1.15rem !important;
  line-height: 1 !important;
}

.editor-highlight-clear:hover {
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  background: color-mix(in srgb, var(--danger) 8%, var(--bg-base)) !important;
}

.editor-highlight-group-disabled {
  position: relative;
}

.editor-pro-disabled {
  opacity: .48;
  cursor: not-allowed !important;
  filter: grayscale(.25);
}

.editor-pro-disabled:hover {
  transform: none !important;
  border-color: var(--gray-200) !important;
  color: var(--text-muted) !important;
  background: var(--bg-base) !important;
}

.editor-highlight-group-disabled::after {
  content: "PRO";
  position: absolute;
  top: -8px;
  right: -8px;
  padding: 2px 5px;
  border-radius: 999px;
  background: #a855f7;
  color: #fff;
  font-size: .58rem;
  font-weight: 900;
  letter-spacing: .06em;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(168, 85, 247, .28);
}

#finalEditor span.editor-text-highlight,
#finalEditor span[data-editor-highlight="true"] {
  display: inline !important;

  font: inherit !important;
  line-height: inherit !important;
  vertical-align: baseline !important;

  letter-spacing: inherit !important;
  word-spacing: inherit !important;
  text-transform: inherit !important;

  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  transform: none !important;

  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}


/* =========================================
   ETICHETTE NELL'EDITOR WORD
   ========================================= */

/* Token visibili ma tipograficamente neutri:
   solo colore, nessun badge, nessun padding, nessun font diverso. */
#finalEditor .editor-placeholder-token {
  display: inline !important;
  font: inherit !important;
  font-family: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  line-height: inherit !important;
  vertical-align: baseline !important;

  color: #c2410c !important;

  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  white-space: inherit !important;
}

/* Sicurezza editor Word:
   se una vecchia etichetta entra nell'editor finale,
   deve comportarsi come testo normale. */
#finalEditor .anon-tag,
#finalEditor .anon-data {
  all: unset !important;
  display: inline !important;
  font: inherit !important;
  font-family: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: inherit !important;
  vertical-align: baseline !important;
  white-space: inherit !important;
}

/* TABLET */
@media (max-width: 900px) {
  .final-editor-modal {
    padding: .6rem;
  }

  .final-editor-window {
    width: 100%;
    height: 94vh;
    border-radius: 16px;
  }

  .final-editor-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
    overflow-x: hidden;
    gap: .5rem;
    padding: .65rem;
  }

  .editor-toolbar-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    padding-top: .35rem;
    border-top: 1px solid var(--gray-200);
  }

  .editor-toolbar-divider {
    display: none;
  }

  .final-editor-page-wrap {
    padding: 28px 0;
  }

  #finalEditor {
    width: min(21cm, calc(100vw - 3rem));
    padding: clamp(1.25rem, 4vw, 2.5cm) clamp(1rem, 4vw, 2cm);
  }
}

/* MOBILE */
/* MOBILE - toolbar compatta con hamburger */
.editor-mobile-menu-btn {
  display: none;
}

.editor-mobile-tools {
  display: contents;
}

@media (max-width: 640px) {
  .final-editor-modal {
    padding: 0;
  }

  .final-editor-window {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .final-editor-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: .5rem;
    padding: .6rem;
    min-height: auto;
    max-height: none;
    overflow: visible;
    background: var(--bg-panel);
    position: relative;
    z-index: 5;
  }

  .editor-mobile-menu-btn {
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: 0 .75rem;
    border-radius: 999px;
    border: 1px solid var(--gray-200);
    background: var(--bg-base);
    color: var(--text-main);
    font-size: .82rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
  }

  .editor-mobile-menu-btn svg {
    stroke: currentColor;
  }

  .editor-mobile-menu-btn.is-open {
    color: var(--primary);
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, var(--bg-base));
  }

  .editor-toolbar-anonymize {
    width: 100%;
    min-width: 0;
    display: flex;
    gap: .4rem;
  }

  .editor-select-label {
    display: none;
  }

  .editor-select {
    width: 100%;
    min-width: 0;
    height: 38px;
    font-size: .82rem;
  }

  .editor-toolbar-actions {
    width: auto;
    margin-left: 0;
    display: flex;
    gap: .35rem;
    padding-top: 0;
    border-top: none;
  }

  .editor-action-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 999px;
  }

  .editor-action-btn span {
    display: none;
  }

  .editor-action-primary {
    width: 42px;
  }

  .editor-action-pro,
  .editor-action-audit {
    display: none;
  }

  .editor-mobile-tools {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
    padding: .65rem;
    margin-top: .15rem;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    background: var(--bg-surface);
    box-shadow: var(--shadow);
  }

  .editor-mobile-tools.is-open {
    display: grid;
    gap: .55rem;
  }

  .editor-mobile-tools .editor-toolbar-divider {
    display: none;
  }

  .editor-mobile-tools .editor-toolbar-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .45rem;
  }

  .editor-mobile-tools .editor-highlight-group {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

  .editor-mobile-tools .editor-btn {
    width: 100%;
    height: 40px;
  }

  .editor-mobile-tools .editor-btn-wide span {
    display: none;
  }

  .final-editor-stage {
    flex: 1;
    min-height: 0;
  }

  .final-editor-page-wrap {
    padding: .5rem;
    justify-content: flex-start;
  }

  #finalEditor {
    width: calc(100vw - 1rem);
    min-height: 120vh;
    padding: 1.25rem;
    font-size: 10.5pt;
  }
}

@media (max-width: 640px) {
  .editor-close-icon {
    display: block;
  }
}

.pdf-btn-loader {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 999px;
  display: inline-block;
  animation: pdfBtnSpin .75s linear infinite;
  flex-shrink: 0;
}

@keyframes pdfBtnSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .editor-action-primary .pdf-btn-loader + span {
    display: none;
  }
}


.offline-explainer {
  max-width: 58rem;
  margin: -0.5rem auto 2rem;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--line, var(--gray-200));
  border-radius: var(--radius-xl, 18px);
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-surface));
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
}

.offline-explainer-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: .75rem;
  padding: .28rem .55rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, .28);
  background: rgba(16, 185, 129, .08);
  color: var(--brand-700, var(--success));
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.offline-explainer h3 {
  margin: 0 0 .55rem;
  font-size: clamp(1.2rem, 2.5vw, 1.65rem);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -.04em;
}

.offline-explainer p {
  margin: 0;
  max-width: 48rem;
  color: var(--text-muted);
  font-size: .98rem;
  line-height: 1.65;
  font-weight: 500;
}

.offline-explainer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin-top: 1.15rem;
}

.offline-explainer-grid div {
  padding: .95rem;
  border-radius: 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--gray-200);
}

.offline-explainer-grid strong {
  display: block;
  margin-bottom: .25rem;
  color: var(--text-main);
  font-size: .92rem;
}

.offline-explainer-grid span {
  display: block;
  color: var(--text-muted);
  font-size: .86rem;
  line-height: 1.45;
}

.offline-explainer-note {
  margin-top: 1rem !important;
  font-size: .84rem !important;
  color: var(--text-muted);
}

[data-theme="dark"] .offline-explainer {
  background: linear-gradient(180deg, var(--bg-panel), rgba(15, 23, 42, .75));
}

@media (max-width: 760px) {
  .offline-explainer {
    margin: -0.25rem 1.25rem 1.5rem;
    padding: 1.15rem;
  }

  .offline-explainer-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   14. FIX LITE: UPLOAD + OFFLINE EXPLAINER + FOOTER
   ========================================= */

/* Uniforma area upload e box "Elaborazione locale" */
#proUploaderModal {
  width: min(calc(100% - 2.5rem), 80rem);
  margin: 1.5rem auto 2rem;
}

#uploadArea,
.offline-explainer,
#processingArea,
#errorArea {
  width: 100%;
  max-width: 58rem;
}

#uploadArea {
  margin-left: auto;
  margin-right: auto;
}

.offline-explainer {
  margin-left: auto;
  margin-right: auto;
}

/* Fix specifico mobile: evita doppio margine laterale dentro #proUploaderModal */
@media (max-width: 760px) {
  #proUploaderModal {
    width: min(calc(100% - 1.5rem), 80rem);
    margin: 0.75rem auto 1.5rem;
  }

  #uploadArea {
    width: 100%;
    margin: 1.25rem auto;
  }

  .offline-explainer {
    width: 100%;
    margin: -0.25rem auto 1.5rem;
    padding: 1.15rem;
  }

  .offline-explainer-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   FOOTER [ANONIPRO_DOCS] LITE
   ========================================= */

.ap-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--gray-200);
  background:
    radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.08), transparent 36%),
    var(--bg-base);
  color: var(--text-muted);
  padding: 3.5rem 1.25rem 2.5rem;
}

.ap-footer-inner {
  max-width: 80rem;
  margin: 0 auto;
}

.ap-footer-grid {
  display: grid;
  gap: 2.5rem;
}

@media (min-width: 1024px) {
  .ap-footer-grid {
    grid-template-columns: 1.15fr 0.85fr 0.85fr 0.85fr;
  }
}

.ap-footer-logo {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 14px;
  background: var(--ink, #0f172a);
  color: #ffffff;
  padding: 0 0.85rem;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: -0.08em;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.ap-footer-payoff {
  margin: 1.25rem 0 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.6;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-700, var(--success));
}

.ap-footer-description {
  margin: 1rem 0 0;
  max-width: 30rem;
  font-size: 0.94rem;
  line-height: 1.8;
  color: var(--text-muted);
}

.ap-footer-title {
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ap-footer-nav,
.ap-footer-contacts {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.25rem;
  font-size: 0.94rem;
}

.ap-footer a,
.ap-footer button {
  color: var(--text-muted);
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
}

.ap-footer a:hover,
.ap-footer button:hover {
  color: var(--text-main);
}

.ap-footer button {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.ap-footer-contacts p {
  margin: 0;
  line-height: 1.65;
}

.ap-footer-contacts strong {
  color: var(--text-main);
}

.ap-footer-bottom {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--text-muted);
}

.ap-footer-bottom p {
  margin: 0;
}

@media (min-width: 768px) {
  .ap-footer-bottom {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .ap-footer-bottom p:last-child {
    text-align: right;
  }
}

[data-theme="dark"] .ap-footer {
  border-color: var(--gray-200);
  background:
    radial-gradient(circle at 50% 0%, rgba(52, 211, 153, 0.10), transparent 36%),
    var(--bg-base);
}

[data-theme="dark"] .ap-footer-logo {
  background: #ffffff;
  color: #0f172a;
}

.ap-footer .ap-footer-logo,
.ap-footer .ap-footer-logo:hover,
.ap-footer .ap-footer-logo:focus-visible,
[data-theme="dark"] .ap-footer .ap-footer-logo,
[data-theme="dark"] .ap-footer .ap-footer-logo:hover,
[data-theme="dark"] .ap-footer .ap-footer-logo:focus-visible {
  background: #0f172a !important;
  color: #ffffff !important;
}

/* =========================================
   MODALE NO-COOKIE LITE
   ========================================= */

.ap-no-cookie-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
}

.ap-no-cookie-modal.is-open {
  display: block;
}

.ap-no-cookie-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
}

.ap-no-cookie-shell {
  position: relative;
  min-height: 100dvh;
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  padding: 0;
}

@media (min-width: 640px) {
  .ap-no-cookie-shell {
    align-items: center;
    padding: 1.5rem;
  }
}

.ap-no-cookie-dialog {
  width: 100%;
  max-height: 92dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 2rem 2rem 0 0;
  border-top: 1px solid var(--gray-200);
  background: var(--bg-panel);
  color: var(--text-main);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

@media (min-width: 640px) {
  .ap-no-cookie-dialog {
    max-height: 88dvh;
    border-radius: 2rem;
    border: 1px solid var(--gray-200);
  }
}

.ap-no-cookie-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.ap-no-cookie-kicker {
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-700, var(--success));
}

.ap-no-cookie-title {
  margin: 0.5rem 0 0;
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.055em;
  color: var(--text-main);
}

.ap-no-cookie-description {
  margin: 0.75rem 0 0;
  max-width: 44rem;
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--text-muted);
}

.ap-no-cookie-close {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.ap-no-cookie-body {
  overflow-y: auto;
  padding: 1.5rem;
}

.ap-no-cookie-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .ap-no-cookie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ap-no-cookie-card {
  border: 1px solid var(--gray-200);
  background: var(--bg-surface);
  border-radius: 1.5rem;
  padding: 1.25rem;
}

.ap-no-cookie-card.featured {
  border-color: rgba(16, 185, 129, 0.28);
  background: var(--brand-50, rgba(16, 185, 129, 0.08));
}

.ap-no-cookie-code {
  display: inline-flex;
  margin-bottom: 0.9rem;
  border-radius: 0.75rem;
  background: var(--bg-panel);
  color: var(--brand-700, var(--success));
  padding: 0.45rem 0.7rem;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 900;
}

.ap-no-cookie-card h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-main);
}

.ap-no-cookie-card p {
  margin: 0.75rem 0 0;
  line-height: 1.75;
  color: var(--text-muted);
}

.ap-no-cookie-note {
  margin-top: 1rem;
  border: 1px solid var(--gray-200);
  background: var(--bg-surface);
  border-radius: 1.5rem;
  padding: 1.25rem;
  color: var(--text-muted);
  line-height: 1.75;
}

.ap-no-cookie-note strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.ap-no-cookie-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.ap-no-cookie-primary,
.ap-no-cookie-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border-radius: 999px;
  padding: 0 1.2rem;
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.ap-no-cookie-primary {
  border: 0;
  background: var(--text-main);
  color: var(--bg-panel);
}

.ap-no-cookie-secondary {
  border: 1px solid var(--gray-200);
  background: var(--bg-panel);
  color: var(--text-main);
}

@media (max-width: 640px) {
  .ap-footer {
    margin-top: 3rem;
    padding: 2.5rem 1.25rem 2rem;
  }

  .ap-no-cookie-header,
  .ap-no-cookie-body {
    padding: 1.25rem;
  }

  .ap-no-cookie-actions {
    display: grid;
  }

  .ap-no-cookie-primary,
  .ap-no-cookie-secondary {
    width: 100%;
  }
}

/* =========================================
   FIX DARK MODE - BOTTONI PRIMARI MODALI
   Evita testo bianco su sfondo chiaro quando --primary diventa #f8fafc
   ========================================= */

[data-theme="dark"] #btnGenConfirmAction,
[data-theme="dark"] #btnReplaceAll {
  background: #f8fafc !important;
  color: #0f172a !important;
  border: 1px solid rgba(248, 250, 252, 0.22) !important;
}

[data-theme="dark"] #btnGenConfirmAction:hover,
[data-theme="dark"] #btnReplaceAll:hover {
  background: #d1fae5 !important;
  color: #064e3b !important;
}

/* Bottone "Ho capito" del modale no-cookie */
[data-theme="dark"] .ap-no-cookie-primary {
  background: #f8fafc !important;
  color: #0f172a !important;
  border: 1px solid rgba(248, 250, 252, 0.22) !important;
}

[data-theme="dark"] .ap-no-cookie-primary:hover {
  background: #d1fae5 !important;
  color: #064e3b !important;
}


/* =========================================================
   FIX MOBILE - EVITA ZOOM AUTOMATICO EDITOR WORD
   Safari/iOS zooma i campi editabili sotto i 16px.
   ========================================================= */

@media (max-width: 640px) {
  #finalEditor {
    font-size: 16px !important;
    line-height: 1.55 !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .editor-select,
  .editor-btn,
  .editor-action-btn,
  .editor-mobile-menu-btn {
    font-size: 16px !important;
  }
}