/* Editor proprietario — stile coerente con site.css (tema scuro "Radio da campo") */
.rte { position: relative; border: 1px solid var(--line-2, #39423c); border-radius: 4px; background: #0b0d0c; }
.rte:focus-within { border-color: var(--green, #6fd38a); box-shadow: 0 0 0 3px rgba(111, 211, 138, .18); }
.rte.is-over { border-color: var(--red, #ec6a55); }
.rte.is-busy { cursor: progress; }
.rte.is-busy .rte-panel { opacity: .6; pointer-events: none; }

.rte-toolbar {
    position: sticky; top: 0; z-index: 2;
    display: flex; flex-wrap: wrap; gap: 4px; padding: 6px;
    background: #141816; border-bottom: 1px solid var(--line, #2a312d);
}
.rte-group { display: flex; align-items: center; gap: 2px; padding-right: 4px; margin-right: 2px; border-right: 1px solid var(--line, #2a312d); }
.rte-group:last-child { border-right: 0; }
.rte-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
    border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--muted, #9ba59d); cursor: pointer; font-size: .9rem;
}
.rte-btn:hover { color: var(--text, #e3e8e2); background: rgba(255, 255, 255, .05); }
.rte-btn[aria-pressed="true"] { color: var(--green, #6fd38a); background: rgba(111, 211, 138, .14); border-color: rgba(111, 211, 138, .35); }
.rte-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.rte-btn:focus-visible, .rte-block:focus-visible { outline: 2px solid var(--amber, #f0b43c); outline-offset: 1px; }
.rte-block { width: auto !important; min-height: 34px !important; padding: 4px 28px 4px 8px !important; font-size: .85rem !important; }

.rte-area {
    min-height: 260px; max-height: 70vh; overflow-y: auto; padding: 14px 16px;
    color: var(--text, #e3e8e2); line-height: 1.6; outline: none; word-wrap: break-word;
}
.rte-area { position: relative; }
.rte.is-empty .rte-area::before { content: attr(data-placeholder); position: absolute; left: 16px; right: 16px; top: 14px; color: var(--faint, #6f7a72); pointer-events: none; }
.rte-area img { cursor: pointer; }
.rte-area iframe { pointer-events: none; }
.rte-area hr { cursor: default; }

.rte-source {
    display: block; width: 100%; min-height: 260px; max-height: 70vh; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
    padding: 14px 16px; background: #070908 !important; font: .85rem/1.5 var(--font-mono, monospace) !important; color: #b9e6c4 !important;
}
.rte-status { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-top: 1px solid var(--line, #2a312d); font-size: .78rem; color: var(--faint, #6f7a72); }
.rte.is-over .rte-counter { color: var(--red, #ec6a55); font-weight: 700; }

.rte-panel { display: grid; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line, #2a312d); background: #111412; }
.rte-field { display: grid; gap: 4px; font-size: .82rem; color: var(--muted, #9ba59d); }
.rte-check { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted, #9ba59d); }
.rte-check input { width: 16px; height: 16px; accent-color: var(--green, #6fd38a); }
.rte-actions { display: flex; justify-content: flex-end; gap: 8px; }
.rte-error { margin: 0; color: var(--red, #ec6a55); font-size: .85rem; }
.rte-muted { margin: 0; color: var(--faint, #6f7a72); font-size: .8rem; }
.rte-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.rte-swatch { width: 32px; height: 32px; border: 2px solid #000; border-radius: 3px; cursor: pointer; }
.rte-swatch:hover, .rte-swatch:focus-visible { outline: 2px solid var(--text, #e3e8e2); outline-offset: 1px; }
.rte-swatch-none { background: transparent; color: var(--muted, #9ba59d); border-color: var(--line-2, #39423c); }
.rte-emoji-tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.rte-emoji-tab { width: 38px; height: 34px; border: 1px solid transparent; background: transparent; font-size: 1.15rem; cursor: pointer; border-radius: 3px; }
.rte-emoji-tab[aria-selected="true"] { border-color: var(--green-dim, #3f7d52); background: rgba(111, 211, 138, .1); }
.rte-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; max-height: 220px; overflow-y: auto; }
.rte-emoji { height: 38px; border: 0; background: transparent; font-size: 1.35rem; cursor: pointer; border-radius: 3px; }
.rte-emoji:hover, .rte-emoji:focus-visible { background: rgba(255, 255, 255, .08); }
.rte-draftbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(240, 180, 60, .1); border-bottom: 1px solid rgba(240, 180, 60, .35); font-size: .85rem; }
.rte-draftbar span { flex: 1 1 200px; }
.rte-draftbar .btn { min-height: 32px; padding: 6px 12px; }

/* Anteprima: si vede il risultato finale, senza strumenti di modifica */
.rte.is-preview .rte-toolbar .rte-group > *:not([data-cmd="preview"]):not([data-cmd="fullscreen"]) { opacity: .3; pointer-events: none; }
.rte.is-preview .rte-area { background: var(--panel, #161a18); cursor: default; }
.rte.is-source .rte-toolbar .rte-group > *:not([data-cmd="html"]):not([data-cmd="fullscreen"]) { opacity: .3; pointer-events: none; }

/* Schermo intero */
.rte.is-full { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; border-radius: 0; }
.rte.is-full .rte-area, .rte.is-full .rte-source { flex: 1; max-height: none; }
.rte.is-full .rte-area { max-width: 900px; width: 100%; margin: 0 auto; }
html.rte-noscroll { overflow: hidden; }

@media (max-width: 767.98px) {
    .rte-btn { width: 40px; height: 40px; }
    .rte-group { border-right: 0; padding-right: 0; margin-right: 0; }
    .rte-area { min-height: 220px; padding: 12px; }
}
