/* ============================================================
   Filippo Contarini — stile base (punto 1)
   Minimale: sufficiente per manutenzione, login/setup e dashboard.
   ============================================================ */

:root {
    --bg: #f5f5f4;
    --fg: #1c1917;
    --muted: #78716c;
    --line: #e7e5e4;
    --accent: #1c1917;
    --error-bg: #fef2f2;
    --error-fg: #b91c1c;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.5;
}

h1 { font-weight: 600; letter-spacing: -0.01em; }

a { color: var(--accent); }

/* --- Pagine pubbliche / manutenzione / errori --- */
.home,
.maintenance,
.error-page {
    max-width: 640px;
    margin: 18vh auto;
    padding: 0 1.25rem;
    text-align: center;
}

.maintenance h1,
.error-page h1 { margin-bottom: 0.25rem; }

.muted { color: var(--muted); }

/* --- Barra admin --- */
.admin-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.admin-bar .brand { font-weight: 600; }

.admin-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-user { color: var(--muted); font-size: 0.9rem; text-decoration: none; }
a.admin-user:hover { color: var(--fg); }

.inline { display: inline; margin: 0; }

.admin-main {
    max-width: 760px;
    margin: 2rem auto;
    padding: 0 1.25rem;
}

/* Larghezza leggibile e uniforme dei campi nei form admin (non nel modulo foto) */
.admin-main form:not(.form-photo) input[type="text"],
.admin-main form:not(.form-photo) input[type="email"],
.admin-main form:not(.form-photo) input[type="password"],
.admin-main form:not(.form-photo) textarea { max-width: 440px; }

.admin-main select, .admin-main form input { font-size: 0.95rem; }
.admin-main select { padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }

.admin-foot {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    padding: 2rem 0;
}
.admin-foot a { color: var(--muted); }
.admin-foot a:hover { color: var(--fg); }
.admin-version { margin-top: 0.2rem; }

/* --- Card / form --- */
.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    margin: 0 0 1.25rem;
}

/* Card stretta e centrata: pagine di autenticazione (login / primo accesso) */
.card--narrow { max-width: 400px; margin: 8vh auto 0; }
.admin-main .card--narrow { margin-top: 0; }

.card h1 { margin-top: 0; font-size: 1.35rem; }

form label {
    display: block;
    margin: 0.85rem 0;
    font-size: 0.9rem;
    color: var(--muted);
}

form input[type="text"],
form input[type="email"],
form input[type="password"] {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.6rem 0.7rem;
    font-size: 1rem;
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button {
    margin-top: 0.5rem;
    padding: 0.6rem 1.1rem;
    font-size: 0.95rem;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

button:hover { opacity: 0.9; }

.error {
    background: var(--error-bg);
    color: var(--error-fg);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.meta { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

/* Dashboard: riquadri di conteggio */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem; margin: 1.25rem 0; }
.stat-card {
    display: flex; flex-direction: column; gap: 0.15rem;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; text-decoration: none; color: var(--fg);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.stat-card:hover { border-color: #d6d3d1; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); }
.stat-value { font-size: 1.9rem; font-weight: 600; letter-spacing: -0.02em; }
.stat-label { font-size: 0.85rem; color: var(--muted); }

/* ===================== Statistiche (AlpStats) ===================== */
.stat-delta { font-size: 0.8rem; font-weight: 600; margin-left: 0.35rem; vertical-align: middle; }
.stat-delta.up { color: #166534; }
.stat-delta.down { color: #b91c1c; }

.live-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--muted); }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }

/* KPI: riga 1 = Visitatori + Pageview (50% ciascuno); riga 2 = altri 4 (25% ciascuno) */
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.kpi-grid > .stat-card:nth-child(1),
.kpi-grid > .stat-card:nth-child(2) { grid-column: span 2; }
@media (max-width: 720px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid > .stat-card:nth-child(1),
    .kpi-grid > .stat-card:nth-child(2) { grid-column: span 2; }
}
.kpi-cmp { font-size: 0.8rem; font-weight: 600; margin: 0.15rem 0 0; color: var(--muted); }
.kpi-cmp.up { color: #1a7f37; }
.kpi-cmp.down { color: #b3261e; }
.kpi-vs { color: var(--muted); font-weight: 400; margin-left: 0.25rem; }
.spark { width: 100%; height: 28px; display: block; margin-top: 0.55rem; }
.spark polyline { stroke: var(--stats, var(--accent)); stroke-width: 1.5; fill: none; stroke-linejoin: round; stroke-linecap: round; }

/* Widget statistiche in dashboard */
.dash-stats { margin: 1.25rem 0; }
.dash-stats-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.75rem; }
.dash-stats-head h2 { font-size: 1rem; margin: 0; }
.dash-stats-link { font-size: 0.85rem; text-decoration: none; color: var(--stats, var(--accent)); }
.dash-stats-link:hover { text-decoration: underline; }
.dash-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.dash-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.dash-stat .stat-value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
.mini { width: 100%; height: 56px; display: block; margin-top: 0.5rem; }
.mini-line { stroke: var(--stats, var(--accent)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mini-area { fill: color-mix(in srgb, var(--stats, var(--accent)) 12%, #fff); }
.mini-empty { height: 56px; }
@media (max-width: 720px) { .dash-stats-grid { grid-template-columns: 1fr; } }

.chart-toggle { display: flex; justify-content: flex-end; gap: 0.4rem; margin-bottom: 0.6rem; }
.chart-toggle a { text-decoration: none; color: var(--muted); font-size: 0.82rem; padding: 0.25rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; }
.chart-toggle a.on { color: #fff; background: var(--stats, var(--accent)); border-color: var(--stats, var(--accent)); }
.charts-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.chart-card { padding: 1rem 1.1rem; }
.chart-card h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--stats, var(--accent)); opacity: 0.9; }
.chart .x-lbl { fill: var(--muted); font-size: 11px; }
.chart .cl-line { stroke: var(--stats, var(--accent)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cl-dot { fill: var(--stats, var(--accent)); }
.chart .cl-area { fill: color-mix(in srgb, var(--stats, var(--accent)) 12%, #fff); }

/* Heatmap giorno × ora */
.heat-card { padding: 1rem 1.1rem; }
.heat-card h2 { font-size: 1rem; margin: 0 0 0.6rem; }
.heat-scroll { overflow-x: auto; }
.heat { min-width: 460px; }
.heat-row { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; align-items: center; }
.heat-row + .heat-row { margin-top: 2px; }
.heat-head { margin-bottom: 2px; }
.heat-day { font-size: 0.72rem; color: var(--muted); }
.heat-hh { font-size: 0.62rem; color: var(--muted); text-align: center; }
.heat-cell { height: 15px; border-radius: 2px; }

.bd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.bd { padding: 1rem 1.1rem; }
.bd h2 { font-size: 1rem; margin: 0 0 0.6rem; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { position: relative; display: flex; align-items: center; gap: 0.6rem; padding: 0.42rem 0.55rem; border-radius: 6px; overflow: hidden; }
.b-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--line); background: color-mix(in srgb, var(--stats, var(--accent)) 16%, #fff); z-index: 0; }
.b-key { position: relative; z-index: 1; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.b-val { position: relative; z-index: 1; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
    .bd-grid { grid-template-columns: 1fr; }
    .charts-2 { grid-template-columns: 1fr; }
}

/* Titoletto di sezione fra blocchi (Utenti, ecc.) */
.section-title { font-size: 1.05rem; font-weight: 600; margin: 2rem 0 0.75rem; }

/* Form invito: campi in colonna + selettore ruolo */
.invite-form label { margin: 0 0 0.85rem; }
.invite-form select { display: block; margin-top: 0.3rem; }

/* ===================== Admin: modulo foto (punto 2) ===================== */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.page-head h1 { margin: 0; font-size: 1.4rem; }
.small { font-size: 0.85rem; }

.ok {
    background: #ecfdf5;
    color: #047857;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Bottoni-link */
.btn, .btn-secondary, .btn-danger {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn { background: var(--accent); color: #fff; }
.btn-secondary { background: #fff; color: var(--fg); border-color: var(--line); }
.btn-danger { background: #fff; color: var(--error-fg); border-color: #fecaca; }
.btn-danger:hover { background: var(--error-bg); }

/* Tab attive/cestino */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a {
    padding: 0.5rem 0.8rem;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a.active { color: var(--fg); border-bottom-color: var(--accent); }

/* Tabelle elenco */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
.thumb-cell { width: 64px; }
.thumb-cell img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; display: block; background: var(--line); }
td.actions { text-align: right; white-space: nowrap; }

.badge { font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--line); color: var(--fg); }
.badge-published { background: #dcfce7; color: #166534; }
.badge-draft { background: #fef9c3; color: #854d0e; }
.badge-trashed { background: #fee2e2; color: #991b1b; }
.badge-scheduled { background: #e0e7ff; color: #3730a3; }

/* Form foto */
.form-photo { max-width: none; }
.form-photo input[type="file"] { display: block; margin-top: 0.3rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; max-width: none; }
.inline-form input[type="text"] { flex: 1; margin: 0; }

fieldset.tags-field { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; margin: 0.85rem 0; }
fieldset.tags-field legend { font-size: 0.85rem; color: var(--muted); padding: 0 0.4rem; }
.tag-checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 0.6rem; }
.tag-check { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; color: var(--fg); font-size: 0.9rem; }
.tag-check input { width: auto; margin: 0; }

/* Editor descrizione */
.editor { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.editor-toolbar { display: flex; gap: 0.25rem; padding: 0.4rem; background: #fafaf9; border-bottom: 1px solid var(--line); }
.editor-toolbar button { margin: 0; padding: 0.25rem 0.6rem; background: #fff; color: var(--fg); border: 1px solid var(--line); font-size: 0.85rem; }
.editor-area { min-height: 6rem; padding: 0.7rem; outline: none; }
.editor-area:focus { background: #fffef7; }

/* Modifica: anteprima + form affiancati */
.edit-grid { display: grid; grid-template-columns: 260px 1fr; gap: 1.25rem; align-items: start; }
.preview img { width: 100%; border-radius: 8px; display: block; background: var(--line); }
.danger-row { display: flex; gap: 0.75rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
    .edit-grid { grid-template-columns: 1fr; }
}

/* ===================== Sito pubblico (punto 3a) ===================== */

body.public { background: #fff; color: #111; }

.site-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 1rem;
}
.site-name { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; text-decoration: none; color: #111; }
.site-nav { display: inline-flex; align-items: center; }
.site-nav a { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.site-nav a:hover { color: #111; }
.site-nav a + a::before { content: "·"; color: var(--muted); margin: 0 0.55rem; }

.site-main { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem 4rem; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 2rem 0 3rem; }

.gallery-heading { font-size: 1.5rem; font-weight: 600; margin: 0.5rem 0 1rem; }
.empty { color: var(--muted); }

/* Controlli vista/ordinamento */
.gallery-controls { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 1.5rem; }
.control-group { display: inline-flex; gap: 0.25rem; }
.control-group a {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
}
.control-group a.active { color: #fff; background: #111; border-color: #111; }

/* Vista lista: foto grandi in colonna */
.gallery-lista { display: flex; flex-direction: column; gap: 3.5rem; }
.gallery-lista .g-item { max-width: 900px; margin: 0 auto; width: 100%; }
.gallery-lista .g-link { display: block; }
.gallery-lista picture img { width: 100%; height: auto; border-radius: 4px; display: block; }
.g-meta { padding-top: 0.75rem; }
.g-title { font-size: 1.1rem; margin: 0 0 0.25rem; font-weight: 600; }
.g-title a { color: #111; text-decoration: none; }
.g-desc { color: #333; font-size: 0.95rem; }
.g-date { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }

/* Vista griglia */
.gallery-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem; }
.gallery-griglia .g-link { display: block; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 4px; background: var(--line); }
.gallery-griglia picture, .gallery-griglia picture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-griglia .g-meta { display: none; }

.load-more {
    display: block;
    width: max-content;
    margin: 2.5rem auto 0;
    padding: 0.55rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    color: #111;
    font-size: 0.9rem;
}

/* Foto singola */
.photo-single { max-width: 1000px; margin: 0 auto; }
.preview-banner { background: #fef9c3; color: #854d0e; padding: 0.5rem 0.8rem; border-radius: 8px; font-size: 0.9rem; text-align: center; }
.photo-frame { text-align: center; }
.photo-frame picture img { max-width: 100%; height: auto; border-radius: 4px; }
.photo-info { max-width: 720px; margin: 1.25rem auto 0; }
.photo-title { font-size: 1.4rem; font-weight: 600; margin: 0 0 0.25rem; }
.photo-date { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }
.photo-desc { color: #222; line-height: 1.6; }
.photo-tags { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-link { font-size: 0.8rem; text-decoration: none; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.6rem; }
.tag-link:hover { color: #111; }

.photo-nav { display: flex; justify-content: space-between; margin: 2.5rem auto 0; max-width: 720px; }
.nav-cell { flex: 1; }
.nav-right { text-align: right; }
.photo-nav a { text-decoration: none; color: #111; font-size: 0.95rem; }
.photo-nav a:hover { color: var(--muted); }

/* Header pubblico: strumenti + ricerca */
.site-tools { display: flex; align-items: center; gap: 1.25rem; }
.site-search input {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.9rem;
    width: 10rem;
    max-width: 40vw;
}
.random-again { text-align: center; margin-top: 1.5rem; }

/* ===================== Admin: impostazioni (3b / 0.08) ===================== */
.settings-form { max-width: none; }
.settings-group { max-width: none; padding: 0.4rem 1.5rem 1rem; margin: 0 0 1.1rem; }
.settings-group-title {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
    color: var(--muted); font-weight: 600;
    padding: 0.9rem 0 0.1rem; margin: 0 0 0.2rem; border-bottom: 1px solid var(--line);
}
.settings-group-title.admin { color: #9a4a2f; }
.settings-group-title .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

.setting-row { padding: 0.85rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.setting-row:last-of-type { border-bottom: 0; }
.setting-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }
.setting-hint { display: block; margin-top: 0.35rem; }
.field-row input[type="text"] { display: block; margin-top: 0; }

/* Riga con toggle: etichetta a sinistra, switch a destra */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.toggle-row .setting-main { flex: 1; }
.toggle-row .setting-name { font-size: 0.98rem; color: var(--fg); }
.toggle-row .setting-hint { margin-top: 0.2rem; }

/* Due controlli affiancati (Vista + Ordinamento) */
.two-col { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.two-col > .col { flex: 1; min-width: 220px; }
.two-col .segmented { display: flex; width: 100%; }
.two-col .segmented label { flex: 1; }
.two-col .segmented span { text-align: center; }

/* Interruttore segmentato (scelta tra opzioni) */
.segmented {
    display: inline-flex; border: 1px solid var(--line); border-radius: 9px;
    overflow: hidden; background: #fff;
}
.segmented label { margin: 0; position: relative; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.segmented span {
    display: block; padding: 0.55rem 1.25rem; font-size: 0.95rem; color: var(--muted);
    cursor: pointer; white-space: nowrap; transition: background 0.12s, color 0.12s;
}
.segmented label + label span { border-left: 1px solid var(--line); }
.segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Interruttore on/off */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; margin: 0; }
.switch .slider {
    position: absolute; inset: 0; background: #cfcbc7; border-radius: 999px;
    transition: background 0.15s; cursor: pointer;
}
.switch .slider::before {
    content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Ruoli utente */
.role-badge { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.role-admin { background: #e0e7ff; color: #3730a3; }
.role-editor { background: var(--line); color: var(--fg); }

/* Selettore colore nelle impostazioni */
.color-field { display: inline-flex; align-items: center; gap: 0.5rem; }
.color-field input[type="color"] { width: 46px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.color-field code { color: var(--muted); font-size: 0.85rem; }

/* ===================== Pagine + contatto (3c) ===================== */
.page-content { max-width: 720px; margin: 0 auto; }
.page-content > h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 1rem; }
.page-body { line-height: 1.7; color: #222; }
.page-body h2 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
.page-body h3 { font-size: 1.05rem; margin: 1.25rem 0 0.4rem; }
.page-body p { margin: 0 0 1rem; }
.page-body ul, .page-body ol { padding-left: 1.25rem; margin: 0 0 1rem; }
.page-body a { color: #111; }
.page-body blockquote { border-left: 3px solid var(--line); margin: 1rem 0; padding-left: 1rem; color: var(--muted); }

.contact-form { margin-top: 1.5rem; max-width: 560px; }
.contact-form textarea {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.6rem 0.7rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 8px;
    resize: vertical;
}
/* Honeypot: nascosto agli umani, visibile ai bot */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.footer-nav { display: flex; gap: 1rem; justify-content: center; margin-bottom: 0.5rem; }
.footer-nav a { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.footer-nav a:hover { color: #111; }
.footer-admin { margin-top: 0.5rem; }
.footer-admin a { color: var(--muted); text-decoration: none; font-size: 0.8rem; }
.footer-admin a:hover { color: #111; }

/* Profilo: riquadro cambio password */
.account-pw { border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 1rem 1rem; margin: 1.25rem 0 0.5rem; }
.account-pw legend { font-size: 0.85rem; color: var(--muted); padding: 0 0.4rem; }

/* Editor ricco (pagine): stile del contenuto in modifica */
.editor-rich h2 { font-size: 1.2rem; margin: 0.5rem 0; }
.editor-rich h3 { font-size: 1.05rem; margin: 0.5rem 0; }
.editor-rich ul, .editor-rich ol { padding-left: 1.25rem; }

/* ===================== Rifiniture (5a) ===================== */
.error-page { text-align: center; padding: 6vh 1.25rem; }
.error-page h1 { font-size: 3rem; margin: 0 0 0.5rem; }
.error-links { margin-top: 1rem; }
.error-links a { color: #111; }
.error-links .sep { color: var(--muted); margin: 0 0.5rem; }

/* Lightbox: foto a schermo intero */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #000;
    cursor: zoom-out;
}
.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
}

/* ===================== Responsività (0.09) ===================== */

/* Viste admin: tabella su desktop, tile su mobile/tablet (scambio a 820px) */
.m-only { display: none; }

.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.photo-tile { position: relative; display: block; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .badge { position: absolute; top: 0.45rem; left: 0.45rem; }

.lite-tiles { display: grid; gap: 0.6rem; }
.lite-tile {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 0.85rem 1rem; text-decoration: none; color: var(--fg);
}
.lite-tile .lt-main { min-width: 0; }
.lite-tile .lt-title { display: block; font-weight: 600; }
.lite-tile .lt-sub { display: block; color: var(--muted); font-size: 0.82rem; word-break: break-word; }
.lite-tile .lt-chev { flex: none; color: #c8c4c0; font-size: 1.3rem; }

.invite-tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0.85rem 1rem; }
.invite-tile .it-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.invite-tile .it-email { font-size: 0.92rem; word-break: break-word; }
.invite-tile .it-exp { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.invite-tile .it-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.invite-tile .it-actions form { margin: 0; }

.tag-cards { display: grid; gap: 0.55rem; }
.tag-card {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem;
}
.tag-card .tc-name { font-weight: 600; flex: 1 1 auto; }
.tag-card .tc-count { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.tag-card form.tc-edit { display: flex; gap: 0.4rem; flex: 1 1 100%; margin: 0; max-width: none; }
.tag-card form.tc-edit input { flex: 1; margin: 0; }
.tag-card form.tc-del { flex: none; margin: 0; }

/* Menu admin a comparsa laterale: pulsante hamburger (nascosto su desktop) */
.nav-toggle {
    display: none; margin: 0; padding: 0.2rem 0.55rem;
    background: none; border: 0; color: var(--fg);
    font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.nav-backdrop { display: none; }

/* --- Tablet / mobile: barra admin --- */
@media (max-width: 820px) {
    body.admin { overflow-x: hidden; } /* il pannello fuori schermo non genera scroll orizzontale */
    .d-only { display: none !important; }
    .m-only { display: block; }
    .nav-toggle { display: block; }
    .admin-nav {
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
        width: min(80vw, 300px);
        flex-direction: column; align-items: stretch; gap: 0;
        background: #fff; border-left: 1px solid var(--line);
        padding: 4.75rem 1.1rem 1.5rem;
        transform: translateX(100%); transition: transform 0.2s ease;
        box-shadow: -6px 0 28px rgba(0, 0, 0, 0.10);
        overflow-y: auto;
    }
    .admin-nav a,
    .admin-nav .admin-user { padding: 0.7rem 0.2rem; border-bottom: 1px solid var(--line); }
    .admin-nav .admin-user { color: var(--muted); }
    .admin-nav form.inline { display: block; margin-top: 1rem; }
    .admin-nav form.inline button { width: 100%; margin: 0; }
    body.nav-open { overflow: hidden; }
    body.nav-open .admin-nav { transform: translateX(0); }
    body.nav-open .nav-backdrop {
        display: block; position: fixed; inset: 0; z-index: 40;
        background: rgba(0, 0, 0, 0.35);
    }
    .admin-main { margin-top: 1.5rem; }
}

/* --- Mobile: header pubblico impilato --- */
@media (max-width: 640px) {
    .site-header { flex-direction: column; align-items: flex-start; gap: 0.7rem; padding: 1.1rem 1rem 0.85rem; }
    .site-tools { width: 100%; flex-wrap: wrap; gap: 0.6rem 1rem; }
    .site-nav { flex-wrap: wrap; row-gap: 0.3rem; }
    .site-search { flex: 1 1 100%; }
    .site-search input { width: 100%; max-width: none; }
    .gallery-lista { gap: 2.5rem; }
    .photo-nav { padding: 0 0.25rem; }
}
