:root {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f2ece2; --ink: #2a2018; --muted: #6e6257;
  --line: #e4dbcf; --accent: #7a4a22; --accent-ink: #ffffff; --accent-soft: #f1e4d6;
  --good: #2e7d4f; --warn: #b7791f; --shadow: 0 1px 2px rgba(40,25,10,.06), 0 4px 16px rgba(40,25,10,.06);
  --radius: 12px; --serif: "Fraunces", Georgia, serif; --sans: "Inter", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f; --surface: #211b16; --surface-2: #2a231c; --ink: #f1e9df; --muted: #b3a597;
    --line: #3a3027; --accent: #d39a63; --accent-ink: #1a120b; --accent-soft: #3a2a1c;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f; --surface: #211b16; --surface-2: #2a231c; --ink: #f1e9df; --muted: #b3a597;
  --line: #3a3027; --accent: #d39a63; --accent-ink: #1a120b; --accent-soft: #3a2a1c;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(26px, 4vw, 38px); } h2 { font-size: 22px; } h3 { font-size: 17px; }
.muted { color: var(--muted); }
.proto { background: var(--accent); color: var(--accent-ink); text-align: center; font-size: 12.5px; padding: 4px 16px; letter-spacing: .02em; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.brand strong { display: block; font-family: var(--serif); font-size: 19px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.tau { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 650 22px var(--serif); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--ink); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.top nav a:hover, .top nav a.on { background: var(--accent-soft); }
main { max-width: 1240px; margin: 0 auto; padding: 24px; min-height: 60vh; }
.foot { text-align: center; padding: 32px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.foot p { margin: 4px 0; }

/* home */
.hero { margin-bottom: 20px; }
.hero p { margin: 0; color: var(--muted); max-width: 640px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 12px; }
.bar input[type=search], .bar select { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.bar input[type=search] { flex: 1 1 240px; min-width: 0; }
.btn { font: inherit; font-weight: 500; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--accent); }
.btn.on, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
#map { height: 600px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.list { display: flex; flex-direction: column; gap: 8px; max-height: 600px; overflow: auto; padding-right: 4px; }
.count { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); display: block; box-shadow: var(--shadow); }
.card:hover, .card.hl { border-color: var(--accent); }
.card h3 { margin: 2px 0; font-size: 16px; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: #fff; }
.next { font-size: 13px; color: var(--good); font-weight: 500; margin-top: 4px; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.section { margin-top: 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--accent); }
.tile.feat { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tile.feat p { color: inherit; opacity: .9; }
.tile p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }

/* scheda */
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 500; }
.sheet-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; }
.sheet-head .lead { color: var(--muted); font-size: 16px; margin: 8px 0 0; }
.minimap { height: 220px; border-radius: 10px; border: 1px solid var(--line); z-index: 0; }
.level { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.sheet { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.box h2 { font-size: 18px; }
.box.wide { grid-column: 1 / -1; }
table.orari { width: 100%; border-collapse: collapse; font-size: 14px; }
table.orari td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
table.orari tr.today td { font-weight: 600; }
table.orari tr.today td:first-child::after { content: " · oggi"; color: var(--good); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.social { display: flex; gap: 8px; flex-wrap: wrap; }
.social a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-size: 14px; }
.social a:hover { border-color: var(--accent); }
.social svg { width: 18px; height: 18px; fill: currentColor; }
.ext { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 16px 20px; margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ev { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.ev .d { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.upd { font-size: 12.5px; color: var(--muted); margin-top: 16px; text-align: right; }
.upd.old { color: var(--warn); }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.subdomain { font-family: ui-monospace, monospace; font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* rete */
table.rete { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.rete th, table.rete td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.rete th { background: var(--surface-2); font-weight: 600; font-size: 13px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.leaflet-popup-content { font: 14px/1.4 var(--sans); }
.leaflet-popup-content a { font-weight: 600; }

@media (max-width: 860px) {
  main { padding: 16px; }
  .top { padding: 10px 16px; }
  .split, .sheet, .sheet-head { grid-template-columns: 1fr; }
  #map { height: 360px; }
  .list { max-height: none; }
}
.stato { font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.ext.migr { background: var(--surface-2); border-color: var(--line); }
table.rete .social a { padding: 3px 8px; font-size: 12.5px; }
table.rete td { vertical-align: top; }
/* banner social */
.follow { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.follow-l { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.socialbar { display: flex; flex-wrap: wrap; gap: 8px; }
.sb { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px; border-radius: 999px; color: #fff; text-decoration: none; font-weight: 600; font-size: 14.5px; transition: transform .1s, filter .1s; }
.sb:hover { transform: translateY(-1px); filter: brightness(1.08); }
.sb svg, .si svg { width: 20px; height: 20px; flex: none; }
.sb.facebook, .si.facebook { background: #1877f2; }
.sb.instagram, .si.instagram { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af 80%, #515bd4); }
.sb.youtube, .si.youtube { background: #ff0000; }
.fallback .sb { padding: 6px 12px 6px 10px; font-size: 13px; opacity: .9; }
.fallback .sb svg { width: 16px; height: 16px; }
.social a.si { width: 32px; height: 32px; padding: 0; justify-content: center; border: 0; border-radius: 8px; color: #fff; }
.social a.si svg { width: 18px; height: 18px; }
table.rete .social a.si { padding: 0; }
