/* Newsletter — foglio di stile dell'area amministrativa e delle pagine pubbliche */

:root {
    --brand: #1d4f91;
    --brand-hover: color-mix(in srgb, var(--brand) 85%, black);
    --brand-soft: color-mix(in srgb, var(--brand) 9%, white);
    --brand-line: color-mix(in srgb, var(--brand) 30%, white);

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --line: #e4e7ec;
    --line-strong: #d0d5dd;
    --text: #1d2939;
    --text-2: #475467;
    --muted: #667085;

    --ok: #067647;  --ok-bg: #ecfdf3;  --ok-line: #abefc6;
    --warn: #b54708; --warn-bg: #fffaeb; --warn-line: #fedf89;
    --err: #b42318;  --err-bg: #fef3f2;  --err-line: #fecdca;
    --info: #175cd3; --info-bg: #eff8ff;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 12px 32px -6px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);
    --sidebar: 248px;
    font-size: 15px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .98rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code { font-size: .85em; background: var(--surface-2); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 5px; }
img { max-width: 100%; }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------------------------------------------------------------- Struttura */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); flex: none;
    background: var(--surface); border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.sidebar .brand img { max-height: 34px; max-width: 150px; }
.sidebar .brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.sidebar .brand .name { font-weight: 650; color: var(--text); line-height: 1.2; font-size: .95rem; }
.sidebar .brand .name small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.nav { padding: .75rem .65rem; display: grid; gap: 2px; }
.nav .section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .65rem .35rem; font-weight: 600; }
.nav a {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .65rem; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 550; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.sidebar .account { margin-top: auto; border-top: 1px solid var(--line); padding: .75rem; display: flex; align-items: center; gap: .6rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.account .who { min-width: 0; flex: 1; }
.account .who a { color: var(--text); font-weight: 600; font-size: .9rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .who span { color: var(--muted); font-size: .78rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-mobile { display: none; }
.content { padding: 2rem 2.25rem 4rem; max-width: 1180px; width: 100%; }
.content.wide { max-width: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: .3rem 0 0; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .88rem; margin-bottom: .5rem; }

@media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 40; }
    .topbar-mobile { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
    .topbar-mobile .title { font-weight: 650; }
    .content { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.35rem; }
}

/* ---------------------------------------------------------------- Pulsanti */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .55rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem;
    cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow); line-height: 1.3;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [contenteditable]:focus-visible {
    outline: 3px solid var(--brand-line); outline-offset: 1px;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .35rem .6rem; font-size: .84rem; }
.btn-lg { padding: .75rem 1.25rem; font-size: 1rem; }
.btn-icon { padding: .4rem; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.link-btn.danger { color: var(--err); }
form.inline { display: inline; margin: 0; }

/* ---------------------------------------------------------------- Schede */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .card + .grid, .grid + .card { margin-top: 1.25rem; }
.card-body { padding: 1.35rem 1.5rem; }
.card-head { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.card-foot { padding: 1rem 1.5rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Numeri */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 550; }
.stat .value { font-size: 1.75rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .note { color: var(--muted); font-size: .82rem; }

/* ---------------------------------------------------------------- Tabelle */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; color: var(--text); }
.table .muted { color: var(--muted); font-size: .86rem; }
.row-link { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- Etichette */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.subscribed, .badge.sent { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.pending, .badge.scheduled, .badge.paused { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.sending { background: var(--info-bg); color: var(--info); border-color: #b2ddff; }
.badge.unsubscribed, .badge.draft { background: #f2f4f7; color: #475467; border-color: #e4e7ec; }
.badge.bounced, .badge.complained { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.tag { display: inline-block; padding: .05rem .5rem; margin: .1rem .25rem .1rem 0; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: .78rem; font-weight: 550; }

/* ---------------------------------------------------------------- Moduli */
.field { margin-bottom: 1.1rem; }
.field > label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; color: var(--text); }
.field .optional { color: var(--muted); font-weight: 500; font-size: .82rem; }
.hint { color: var(--muted); font-size: .84rem; margin-top: .3rem; }
span.hint { display: block; }
label.field { display: block; font-weight: inherit; }
.field-error { color: var(--err); font-size: .84rem; margin-top: .3rem; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=datetime-local], input[type=number], select, textarea {
    width: 100%; font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .58rem .75rem; box-shadow: var(--shadow);
}
input::placeholder, textarea::placeholder { color: #98a2b3; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--err); }
textarea { min-height: 110px; resize: vertical; }
input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; }
input[type=file] { font: inherit; font-size: .9rem; }
.input-group { display: flex; gap: .5rem; align-items: center; }
.row { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row-3 { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .row, .row-3 { grid-template-columns: 1fr; } }
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check input { margin-top: .25rem; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.check .t { font-weight: 550; }
.check .d { color: var(--muted); font-size: .86rem; }

/* Interruttore on/off */
.switch { display: flex; gap: .8rem; align-items: flex-start; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #d0d5dd; position: relative; flex: none; cursor: pointer; transition: background .15s; margin-top: .1rem; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }

/* Opzioni a scheda (radio grandi) */
.choices { display: grid; gap: .75rem; }
.choices.cols { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.choice { position: relative; display: flex; gap: .8rem; padding: 1rem 1.1rem; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--line-strong); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: .2rem; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
.choice .t { font-weight: 650; display: flex; align-items: center; gap: .45rem; }
.choice .d { color: var(--muted); font-size: .87rem; margin-top: .15rem; }
.choice .badge-rec { font-size: .7rem; background: var(--brand); color: #fff; padding: .05rem .45rem; border-radius: 99px; font-weight: 600; }

/* ---------------------------------------------------------------- Messaggi */
.alert { display: flex; gap: .75rem; padding: .9rem 1.1rem; border-radius: var(--radius); border: 1px solid; margin-bottom: 1.25rem; font-size: .93rem; }
.alert .icon { margin-top: .1rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.alert.warn { background: var(--warn-bg); color: #93370d; border-color: var(--warn-line); }
.alert.err { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.alert.info { background: var(--info-bg); color: #1849a9; border-color: #b2ddff; }
.alert p:last-child { margin: 0; }

.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 100; display: grid; gap: .6rem; max-width: min(420px, calc(100vw - 2.5rem)); }
.toast { display: flex; gap: .7rem; align-items: flex-start; background: #101828; color: #fff; padding: .85rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: .93rem; animation: toast-in .25s ease; }
.toast.err { background: var(--err); }
.toast .icon { color: #75e0a7; margin-top: .1rem; }
.toast.err .icon { color: #fff; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* Stato vuoto */
.empty { text-align: center; padding: 3rem 1.5rem; }
.empty .icon-wrap { width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 1rem; }
.empty .icon-wrap .icon { width: 24px; height: 24px; }
.empty h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 1.1rem; }

/* ---------------------------------------------------------------- Finestre di dialogo */
dialog.modal { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(480px, calc(100vw - 2rem)); color: var(--text); }
dialog.modal.wide { width: min(980px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal-body { padding: 1.5rem; }
.modal-body h2 { margin-bottom: .5rem; }
.modal-body p { color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.5rem; background: var(--surface-2); border-top: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); gap: 1rem; }

/* ---------------------------------------------------------------- Passi della campagna */
.steps { display: flex; gap: .4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.steps a { flex: 1 1 160px; display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .9rem; text-decoration: none; }
.steps a:hover { border-color: var(--line-strong); }
.steps .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; background: #f2f4f7; color: var(--muted); flex: none; }
.steps a.done .n { background: var(--ok-bg); color: var(--ok); }
.steps a.current { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.steps a.current .n { background: var(--brand); color: #fff; }
.step-actions { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* Lista di controllo */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: .75rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .icon { margin-top: .1rem; }
.checklist .ok .icon { color: var(--ok); }
.checklist .warn .icon { color: #dc6803; }
.checklist .error .icon { color: var(--err); }
.checklist .t { font-weight: 600; }
.checklist .d { color: var(--muted); font-size: .87rem; }
.checklist .fix { margin-left: auto; font-size: .85rem; white-space: nowrap; }

/* Barra di avanzamento */
.progress { height: 10px; background: #eaecf0; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .5s ease; }

/* Anteprima email */
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius); background: #f2f4f7; display: block; }
.device-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.device-toggle button { background: var(--surface); border: 0; padding: .4rem .65rem; cursor: pointer; color: var(--muted); display: flex; }
.device-toggle button.on { background: var(--brand-soft); color: var(--brand); }

/* Filtri sopra le tabelle */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); align-items: center; }
.filters .search { position: relative; flex: 1 1 260px; }
.filters .search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filters .search input { padding-left: 2.2rem; }
.filters select { width: auto; min-width: 170px; }

.pagination { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; gap: 1rem; }

.muted { color: var(--muted); }
.small { font-size: .87rem; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: .45rem 1rem; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: .4rem; } }

/* ---------------------------------------------------------------- Pagine pubbliche e di accesso */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: min(440px, 100%); }
.auth-card .card-body { padding: 2rem; }
.auth-card .logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.5rem; }
.auth-card .logo img { max-height: 40px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: .4rem; }
.auth-card .lead { color: var(--muted); margin-bottom: 1.5rem; }
.auth-card .btn-primary { width: 100%; }
.auth-foot { text-align: center; margin-top: 1rem; font-size: .9rem; }
.honeypot { position: absolute; left: -5000px; }

/* ---------------------------------------------------------------- Editor a blocchi */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
@media (max-width: 1100px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-canvas { background: #eceef2; border-radius: var(--radius); padding: 1.5rem 1rem 2.5rem; border: 1px solid var(--line); }
.email-sheet { max-width: 600px; margin: 0 auto; background: #fff; border-radius: 10px; overflow: visible; box-shadow: 0 1px 3px rgba(16,24,40,.08); font-family: Arial, Helvetica, sans-serif; color: #1f2937; }
.email-sheet .sheet-top { height: 5px; background: var(--brand); border-radius: 10px 10px 0 0; }
.email-sheet .sheet-head { padding: 22px 32px 18px; }
.email-sheet .sheet-head img { height: 44px; width: auto; display: block; }
.email-sheet .sheet-head .org { font-weight: bold; font-size: 19px; color: var(--brand); }
.email-sheet .sheet-foot { padding: 20px 32px; background: #f8fafc; border-top: 1px solid #eef0f3; font-size: 12px; color: #6b7280; text-align: center; border-radius: 0 0 10px 10px; line-height: 1.6; }

.blk { position: relative; padding: 4px 32px; border: 2px solid transparent; border-left: 0; border-right: 0; }
.blk:hover { background: #fafbff; }
.blk.selected { background: var(--brand-soft); border-color: var(--brand-line); }
.blk-tools { position: absolute; right: 8px; top: -15px; display: none; gap: 2px; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 2px; box-shadow: var(--shadow-lg); z-index: 5; }
.blk:hover .blk-tools, .blk.selected .blk-tools { display: flex; }
.blk-tools button { background: none; border: 0; padding: 4px; border-radius: 6px; cursor: pointer; color: var(--text-2); display: flex; }
.blk-tools button:hover { background: var(--surface-2); color: var(--text); }
.blk-tools button.danger:hover { color: var(--err); background: var(--err-bg); }
.blk-tools .icon { width: 16px; height: 16px; }
.blk-type { position: absolute; left: 6px; top: -10px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; background: var(--brand); color: #fff; padding: 1px 6px; border-radius: 4px; display: none; font-family: system-ui, sans-serif; }
.blk.selected .blk-type { display: block; }

.blk [contenteditable] { outline: none; min-height: 1.4em; cursor: text; }
.blk [contenteditable]:empty::before { content: attr(data-placeholder); color: #98a2b3; }
.blk .e-h1 { font-size: 26px; font-weight: bold; line-height: 1.3; color: #111827; margin: 6px 0; }
.blk .e-h2 { font-size: 20px; font-weight: bold; line-height: 1.3; color: #111827; margin: 6px 0; }
.blk .e-text { font-size: 16px; line-height: 1.6; padding: 4px 0; }
.blk .e-text p { margin: 0 0 14px; }
.blk .e-text p:last-child { margin-bottom: 0; }
.blk .e-text ul, .blk .e-text ol { margin: 0 0 14px; padding-left: 22px; }
.blk .e-text a { color: var(--brand); }
.blk .e-btn { display: inline-block; padding: 13px 26px; border-radius: 6px; color: #fff; font-weight: bold; font-size: 16px; min-width: 60px; }
.blk .e-btn.no-link { outline: 2px dashed var(--err); outline-offset: 3px; }
.blk .e-img-empty { border: 2px dashed var(--line-strong); border-radius: 8px; padding: 28px 16px; text-align: center; color: var(--muted); font-family: system-ui, sans-serif; font-size: 14px; }
.blk .e-img { display: block; height: auto; border-radius: 6px; }
.blk .e-hr { border-top: 1px solid #e5e7eb; margin: 10px 0 14px; }
.blk .e-spacer { background: repeating-linear-gradient(45deg, transparent, transparent 6px, #f2f4f7 6px, #f2f4f7 12px); border-radius: 4px; }

.add-block { text-align: center; padding: 6px 0; position: relative; }
.add-block > button { opacity: .0; transition: opacity .15s; }
.email-sheet:hover .add-block > button, .add-block.open > button, .add-block.last > button { opacity: 1; }
.add-menu { position: absolute; left: 50%; transform: translateX(-50%); top: 36px; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .5rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; width: 330px; font-family: system-ui, sans-serif; }
.add-menu button { display: grid; justify-items: center; gap: .3rem; padding: .7rem .4rem; border: 0; background: none; border-radius: 8px; cursor: pointer; font: inherit; font-size: .82rem; color: var(--text-2); font-weight: 550; }
.add-menu button:hover { background: var(--brand-soft); color: var(--brand); }

.text-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; margin-bottom: 6px; box-shadow: var(--shadow); font-family: system-ui, sans-serif; }
.text-toolbar button, .text-toolbar select { background: none; border: 0; border-radius: 6px; padding: 5px 6px; cursor: pointer; color: var(--text-2); display: flex; align-items: center; font: inherit; font-size: .82rem; }
.text-toolbar button:hover { background: var(--surface-2); color: var(--text); }
.text-toolbar .sep { width: 1px; background: var(--line); margin: 3px 2px; }
.text-toolbar .icon { width: 16px; height: 16px; }

.inspector { position: sticky; top: 1rem; }
.inspector .card-body { padding: 1.1rem 1.2rem; }
.inspector h3 { margin-bottom: .9rem; display: flex; align-items: center; gap: .45rem; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: #fff; border: 0; border-right: 1px solid var(--line); padding: .4rem .7rem; cursor: pointer; font: inherit; font-size: .85rem; color: var(--text-2); display: flex; align-items: center; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.swatches { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 2px var(--text); }

.save-bar { position: sticky; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: .8rem 0; margin-top: 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.save-state { color: var(--muted); font-size: .88rem; }

.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; max-height: 60vh; overflow: auto; padding: 1rem 1.25rem; }
.library button { border: 1px solid var(--line); border-radius: 8px; padding: 0; background: #f9fafb; cursor: pointer; overflow: hidden; text-align: left; }
.library button:hover { border-color: var(--brand); }
.library img { width: 100%; height: 100px; object-fit: cover; display: block; }
.library span { display: block; font-size: .75rem; color: var(--muted); padding: .35rem .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.html-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.html-editor textarea { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; min-height: 620px; white-space: pre; }
@media (max-width: 1000px) { .html-editor { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Aggiunte alle pagine */
.icon-sm { width: 15px; height: 15px; }
.icon-xs { width: 13px; height: 13px; }
.nowrap { white-space: nowrap; flex-wrap: nowrap; }
.break { word-break: break-all; }
.grow { flex: 1; min-width: 0; }
.full { width: 100%; }
.center { justify-content: center; }
.mt-05 { margin-top: .5rem; } .mt-1 { margin-top: 1rem; } .mb-05 { margin-bottom: .5rem; } .mb-1 { margin-bottom: 1rem; }
.pb-0 { padding-bottom: 0; }
.new-reminder { border-top: 1px solid var(--line); }
.new-reminder select { max-width: 22rem; }
.pt-0 { padding-top: 0; }
.sticky { position: sticky; top: 1rem; }
@media (max-width: 1000px) { .sticky { position: static; } }
.narrow-card { max-width: 760px; }
.stack > .card + .card { margin-top: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
legend { padding: 0; }
.btn.danger, .btn-ghost.danger { color: var(--err); }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell form + form { margin-left: .25rem; }
a.stat { color: inherit; text-decoration: none; transition: border-color .15s; }
a.stat:hover { border-color: var(--brand-line); text-decoration: none; }
.counter { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--warn); font-weight: 600; }
.alert .icon { flex: none; }
.alert.info .icon { color: var(--info); }
.save-state.err { color: var(--err); font-weight: 600; }
.mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-weight: 700; flex: none; }
.auth-card .logo strong { font-size: 1.05rem; }
.auth-card.public .card { overflow: hidden; }
.brand-bar { height: 5px; background: var(--brand); }
.kv-stack { grid-template-columns: 1fr; gap: .1rem; }
.kv-stack dt { font-size: .8rem; margin-top: .55rem; }
.kv-stack dt:first-child { margin-top: 0; }
.kv-tight { grid-template-columns: 1fr auto; gap: .35rem 1rem; }
.kv-tight dd { text-align: right; }

/* Schede di stato sopra le tabelle */
.tabs { display: flex; gap: .25rem; padding: .6rem .75rem 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: .55rem .8rem; color: var(--text-2); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.card > .pagination { border-top: 1px solid var(--line); }

/* Primi passi nel riepilogo */
.setup { margin-bottom: 1.25rem; }
.setup-list { list-style: none; margin: 0; padding: .4rem 1.5rem 1rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 900px) { .setup-list { grid-template-columns: 1fr; } }
.setup-list li { display: flex; gap: .7rem; padding-top: .6rem; }
.setup-list .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; }
.setup-list .done .n { background: var(--ok-bg); color: var(--ok); }
.setup-list .done .t { color: var(--muted); text-decoration: line-through; }
.setup-list .t { font-weight: 650; }
.setup-list .d { color: var(--muted); font-size: .86rem; }

/* Scelta dei tag */
.tag-picker { margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.tag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.tag-option { padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tag-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice > span { display: block; }
.choice .t, .choice .d { display: flex; }
.choice .d { display: block; }

/* Anteprima nella casella di posta */
.inbox { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); padding: .9rem; }
.inbox-row { display: flex; gap: .7rem; }
.inbox-text { min-width: 0; flex: 1; font-size: .9rem; }
.inbox-subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-pre { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Anteprima email */
.preview-wrap { padding: 1rem; background: #eceef2; border-radius: 0 0 var(--radius) var(--radius); }
.preview-wrap .preview-frame { margin: 0 auto; transition: max-width .2s ease; background: #fff; }
.preview-frame.tall { height: 680px; }
dialog .preview-wrap { border-radius: 0; }
dialog .preview-frame { height: min(72vh, 760px); }
details.schedule { margin-top: 1rem; }
details.schedule summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; }

/* Importazione */
.dropzone { display: grid; justify-items: center; gap: .3rem; text-align: center; padding: 2rem 1rem; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok-line); background: var(--ok-bg); }
.dropzone .icon { width: 28px; height: 28px; color: var(--brand); }
.dropzone .t { font-weight: 650; }
.dropzone .d { color: var(--muted); font-size: .86rem; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
ol.numbered { margin: 0 0 1rem; padding-left: 1.2rem; }
ol.numbered li { margin-bottom: .35rem; }
.rename input { max-width: 280px; }

/* Impostazioni */
.logo-preview { display: flex; align-items: center; min-height: 72px; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: .6rem; }
.logo-preview img { max-height: 56px; }
.switch .t { display: block; font-weight: 600; }
.switch .d { display: block; color: var(--muted); font-size: .87rem; }

/* Editor a blocchi: aggiunte */
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 25; background: var(--bg); padding: .4rem 0; min-height: 50px; }
.toolbar-slot { min-width: 0; }
.toolbar-slot .text-toolbar { margin: 0; }
.blk-tools button[disabled] { opacity: .3; pointer-events: none; }
.sheet-empty { padding: 1.5rem 32px; color: var(--muted); font-family: system-ui, sans-serif; text-align: center; }
.sheet-foot .muted { margin-top: .5rem; font-family: system-ui, sans-serif; font-style: italic; }
.e-img-empty .icon { width: 28px; height: 28px; }
.e-img-empty p { margin: .3rem 0 .7rem; }
.text-toolbar select { border: 0; background: none; font: inherit; font-size: .82rem; color: var(--text-2); padding: 4px; width: auto; box-shadow: none; }
.inspector h3 .icon { color: var(--brand); }
.inspector .field { margin-bottom: .9rem; }
.tips { margin: 0; padding-left: 1.1rem; font-size: .88rem; color: var(--text-2); }
.tips li { margin-bottom: .4rem; }
.merge-list { display: grid; gap: .3rem; font-size: .88rem; }
.toast .undo { margin-left: auto; background: none; border: 0; color: #84caff; font: inherit; font-weight: 700; cursor: pointer; opacity: 1; }
.add-block { z-index: 4; }
.add-block.last .add-menu { top: auto; bottom: 38px; }
.show-sm { display: none; }
@media (max-width: 700px) {
    .hide-sm { display: none; }
    .show-sm { display: inline; }
    .save-bar { flex-wrap: nowrap; padding: .6rem 0; }
    .save-bar .save-state { flex: 1; text-align: center; font-size: .78rem; line-height: 1.3; }
    .email-sheet .sheet-head, .blk { padding-left: 16px; padding-right: 16px; }
    .editor-canvas { padding: 1rem .5rem 2rem; }
}

/* ---------------------------------------------------------------- Assistente */
.editor-layout { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1100px) { .editor-layout { grid-template-columns: 1fr; } }
.side-panel { position: sticky; top: 1rem; display: grid; gap: .6rem; align-self: start; }
@media (max-width: 1100px) { .side-panel { position: static; } }
.side-panel .inspector { position: static; }
.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #eaecf0; border-radius: var(--radius); }
.side-tabs button { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-weight: 600; font-size: .9rem; color: var(--text-2); cursor: pointer; }
.side-tabs button[aria-selected="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.side-tabs .icon { width: 16px; height: 16px; }

.chat { display: flex; flex-direction: column; height: min(calc(100vh - 160px), 700px); min-height: 420px; }
.chat[hidden] { display: none; }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.chat-intro { text-align: center; padding: .5rem .25rem; }
.chat-intro-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto .7rem; }
.chat-intro h3 { margin-bottom: .4rem; }
.chat-intro p { font-size: .9rem; color: var(--text-2); }
.chat-examples { display: grid; gap: .4rem; margin-top: .75rem; }
.chip { text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .7rem; font: inherit; font-size: .86rem; color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--brand-line); color: var(--brand); background: var(--brand-soft); }

.msg { display: flex; flex-direction: column; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; }
.msg-body { padding: .6rem .8rem; border-radius: 12px; font-size: .9rem; line-height: 1.45; display: grid; gap: .4rem; }
.msg.user .msg-body { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .msg-body { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-body.error { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.msg-body.pending { display: flex; align-items: center; gap: .6rem; color: var(--muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { font-size: .74rem; color: var(--muted); margin-top: .2rem; padding: 0 .3rem; }
.msg-files { display: flex; flex-wrap: wrap; gap: .3rem; }
.msg.user .file-chip { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.3); }
.msg .link-btn { justify-self: start; font-size: .84rem; display: inline-flex; align-items: center; gap: .3rem; }
.msg .link-btn .icon { width: 14px; height: 14px; }

.file-chip { display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; padding: .2rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: .8rem; color: var(--text-2); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .icon { width: 14px; height: 14px; flex: none; }
.file-chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); display: flex; }

.chat-composer { border-top: 1px solid var(--line); padding: .7rem; display: grid; gap: .5rem; }
.chat-composer textarea { min-height: 64px; max-height: 200px; resize: vertical; font-size: .92rem; }
.chat-files { display: flex; flex-wrap: wrap; gap: .35rem; }
.chat-files:empty { display: none; }
.chat-actions { display: flex; align-items: center; gap: .5rem; }
.chat-actions .muted { flex: 1; font-size: .76rem; text-align: center; }
.chat-actions label.btn { cursor: pointer; }

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); opacity: .3; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.editor-canvas { position: relative; }
.canvas-veil { position: absolute; inset: 0; background: rgba(245, 246, 248, .72); backdrop-filter: blur(1px); border-radius: var(--radius); display: flex; justify-content: center; align-items: flex-start; padding-top: 120px; z-index: 30; }
.veil-box { position: sticky; top: 120px; display: flex; align-items: center; gap: .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1.1rem; box-shadow: var(--shadow-lg); font-weight: 600; font-size: .92rem; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--brand-line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.editor-canvas.flash-update .email-sheet { animation: flash 1.2s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--brand-line); } 100% { box-shadow: 0 1px 3px rgba(16,24,40,.08); } }

/* Opzioni avanzate richiudibili */
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chevron { transition: transform .15s; color: var(--muted); }
details.card[open] > summary .chevron { transform: rotate(180deg); }
details.card:not([open]) > summary { border-bottom: 0; }
.sidebar-cta { padding: .85rem .75rem 0; }

/* ---------------------------------------------------------------- Editor: nuovi blocchi e aspetto */
.email-sheet { --accent: var(--brand); }
.email-sheet .sheet-top { background: var(--accent); }
.email-sheet .sheet-head.centered { text-align: center; padding-top: 26px; }
.email-sheet .sheet-head.centered img { height: 92px; margin: 0 auto; }
.email-sheet .sheet-nohead { display: flex; align-items: center; gap: .35rem; margin: 10px auto 4px; border: 1px dashed var(--line-strong); background: none; border-radius: 6px; padding: 3px 10px; font: inherit; font-family: system-ui, sans-serif; font-size: .76rem; color: var(--muted); cursor: pointer; }
.email-sheet .sheet-nohead .icon { width: 14px; height: 14px; }
.blk .e-text a { color: var(--accent); }
.blk .e-h3 { font-size: 17px; font-weight: bold; line-height: 1.3; color: #111827; margin: 6px 0; }
.blk .e-btn.small { padding: 9px 18px; font-size: 14px; border-radius: 6px; }
.blk .e-btn.full { display: block; text-align: center; }
.blk .e-text s { text-decoration: line-through; }
.add-menu { width: 360px; grid-template-columns: repeat(3, 1fr); }
.add-menu button span { text-align: center; line-height: 1.25; }

/* Immagini da bordo a bordo e fasce */
.blk.blk-full { padding-left: 0; padding-right: 0; }
.blk .e-img.full { width: 100%; border-radius: 0; }
.blk .e-img-wrap { padding: 6px 0; }
.blk.blk-full .e-img-wrap { padding: 0; }
.blk .e-img-empty.small { padding: 14px 8px; }
.blk .e-img-empty.small p { margin: .2rem 0 .5rem; }

/* Riquadro colorato */
.blk .e-box { border-radius: 8px; padding: 20px 24px; margin: 4px 0 10px; }
.blk .e-box.full { border-radius: 0; padding: 26px 32px; margin: 0; }
.blk .e-box-title { font-size: 20px; font-weight: bold; line-height: 1.3; margin-bottom: 6px; }
.blk .e-box.full .e-box-title { font-size: 23px; }
.blk .e-box .e-text { padding: 0; }
.blk .e-box .e-text a { color: inherit; font-weight: bold; }
.blk .e-box.light .e-text a { color: var(--accent); }
.blk .e-box [contenteditable]:empty::before { color: currentColor; opacity: .55; }
.blk .e-box-btn { margin-top: 14px; }

/* Griglia di loghi */
.blk .e-grid { display: grid; gap: 10px; padding: 6px 0 10px; }
.blk .e-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.blk .e-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.blk .e-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.blk .e-grid-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; min-width: 0; }
.blk .e-grid-cell { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.blk .e-grid.tiles .e-grid-cell { border: 1px solid #e5e7eb; background: #fff; padding: 10px; }
.blk .e-grid.plain .e-grid-cell { aspect-ratio: auto; min-height: 60px; }
.blk .e-grid-cell img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.blk .e-grid.plain .e-grid-cell img { width: 100%; max-height: none; }
.blk .e-grid-noimg { color: var(--muted); }
.blk .e-grid-caption { font-size: 13px; line-height: 1.35; color: #4b5563; text-align: center; }
.blk .e-grid-link { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.blk .e-grid-link .icon { width: 12px; height: 12px; }
.blk .e-grid-item.missing .e-grid-cell { outline: 2px dashed var(--warn); outline-offset: -2px; }
.blk .e-grid-item:hover .e-grid-cell { box-shadow: 0 0 0 2px var(--brand-line); }
.blk .e-grid-item.on .e-grid-cell { box-shadow: 0 0 0 3px var(--brand); }
.blk .e-grid-add { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; border: 1.5px dashed var(--line-strong); border-radius: 8px; padding: 8px 10px; font-family: system-ui, sans-serif; }
.blk .e-grid-add.first { flex-direction: column; justify-content: center; padding: 22px 12px; text-align: center; }
.blk .e-grid-add .small { font-size: .82rem; }
.blk .drop, .blk .e-grid.drop .e-grid-add { background: var(--brand-soft); border-color: var(--brand); }

/* Schede affiancate */
.blk .e-cards { display: grid; gap: 12px; padding: 6px 0 12px; }
.blk .e-cards.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.blk .e-cards.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.blk .e-card { border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; background: #fff; min-width: 0; }
.blk .e-card.on { box-shadow: 0 0 0 2px var(--brand); border-color: var(--brand); }
.blk .e-card-img { display: block; width: 100%; height: auto; border-radius: 6px; margin: 0 auto 10px; }
.blk .e-card-title { font-size: 18px; font-weight: bold; line-height: 1.3; color: #111827; margin-bottom: 4px; }
.blk .e-card-text { font-size: 15px; line-height: 1.5; color: #374151; }
.blk .e-card-btn { margin-top: 12px; }

/* Immagine e testo */
.blk .e-it { display: flex; align-items: center; gap: 20px; padding: 6px 0 12px; }
.blk .e-it-img { flex: none; }
.blk .e-it-img img { display: block; width: 100%; height: auto; border-radius: 6px; }
.blk .e-it-txt { flex: 1; min-width: 0; }

/* Pannello delle opzioni: tavolozza, interruttori, elementi */
.swatches button[aria-label="Bianco"], .swatches button[aria-label="Grigio chiaro"], .swatches button[aria-label="Crema"], .swatches button[aria-label="Celeste"] { box-shadow: 0 0 0 1px var(--line-strong), inset 0 0 0 1px rgba(0,0,0,.06); }
.swatches button.on { box-shadow: 0 0 0 2px var(--text) !important; }
.check-row { display: flex; gap: .55rem; align-items: flex-start; margin: 0 0 .9rem; cursor: pointer; font-size: .9rem; font-weight: 600; }
.check-row input { margin-top: .2rem; width: auto; }
.check-row .hint { display: block; font-weight: 400; margin-top: .15rem; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .6rem 0 .7rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.item-head .flex { gap: .2rem; }
.insp-thumb { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; margin-bottom: .6rem; display: flex; justify-content: center; }
.insp-thumb img { max-height: 110px; width: auto; object-fit: contain; }
.warn-text { color: var(--warn); font-weight: 600; }

/* Libreria con scelta multipla */
.library button { position: relative; }
.library button.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.library button.on::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.library img { object-fit: contain; background: #fff; }
.modal-foot .grow { flex: 1; }
.modal-foot[hidden] { display: none; }

@media (max-width: 700px) {
    .blk .e-grid.cols-4 { grid-template-columns: repeat(3, 1fr); }
    .blk .e-cards.cols-2, .blk .e-cards.cols-3 { grid-template-columns: 1fr; }
    .blk .e-it { flex-direction: column; align-items: stretch; }
    .blk .e-it.right { flex-direction: column-reverse; }
    .blk .e-it-img { width: 100% !important; }
    .blk.blk-full { padding-left: 0; padding-right: 0; }
}

/* ---------------------------------------------------------------- Area «Immagini» */
.media-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.media-side { position: sticky; top: 1rem; padding: .5rem; }
.media-lists { display: grid; gap: 2px; }
.media-list { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .55rem .7rem; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: .92rem; color: var(--text-2); text-align: left; cursor: pointer; }
.media-list:hover { background: var(--surface-2); color: var(--text); }
.media-list.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.media-list .count { font-size: .78rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 0 .5rem; }
.media-side-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .8rem .7rem .3rem; }
.media-side-hint { padding: .3rem .7rem; }
.media-side-foot { padding: .6rem .2rem .2rem; border-top: 1px solid var(--line); margin-top: .5rem; }
.btn.full { width: 100%; justify-content: center; }
.media-main { min-height: 420px; }
.media-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.media-search { display: flex; align-items: center; gap: .4rem; flex: 1; max-width: 360px; }
.media-search .icon { color: var(--muted); }
.media-list-name { font-size: 1.05rem; font-weight: 650; max-width: 420px; }
.media-body { padding: 1rem; }
.media-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.media-tile { display: grid; gap: .35rem; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: inherit; }
.media-tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow); }
.media-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; background: #fff; border-radius: 6px; overflow: hidden; border: 1px solid #f0f1f3; }
.media-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-name { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-name.unnamed { color: var(--muted); font-weight: 500; font-style: italic; }
.media-name.naming { animation: dot 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .media-name.naming { animation: none; } }
.media-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.chip-mini { font-size: .72rem; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: .05rem .5rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; counter-reset: row; }
.media-row { display: flex; align-items: flex-end; gap: .75rem; padding: .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.media-row .label { font-size: .78rem; margin-bottom: .2rem; }
.media-row-thumb { flex: none; width: 84px; padding: 0; border: 0; background: none; cursor: pointer; }
.media-row-tools { flex: none; gap: .2rem; }
.media-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; }
.media-detail-preview { display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 18px 18px; border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; padding: 1rem; }
.media-detail-preview img { max-height: 320px; object-fit: contain; }
.library-search { padding: .75rem 1.25rem 0; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.library-search input, .library-search select { flex: 1; min-width: 180px; }
.library button[disabled] { opacity: .45; cursor: default; }
@media (max-width: 900px) {
    .media-layout { grid-template-columns: 1fr; }
    .media-side { position: static; }
    .media-row { flex-wrap: wrap; }
    .media-detail { grid-template-columns: 1fr; }
}
.btn[hidden], .library-search [hidden] { display: none; }
