:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #2b2b2b;
  --muted: #7a756c;
  --accent: #5b7c6f;
  --accent-dark: #46615698;
  --line: #e4e0d8;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

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

.container { max-width: 900px; margin: 0 auto; padding: 24px 18px 64px; }

header.site {
  text-align: center;
  padding: 40px 18px 8px;
}
header.site h1 { margin: 0; font-weight: 600; letter-spacing: 0.3px; }
header.site p { color: var(--muted); margin: 6px 0 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

h2 { font-weight: 600; margin: 0 0 14px; }
h3 { font-weight: 600; margin: 0 0 10px; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }
input, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fbfaf8;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; min-height: 80px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
button:hover, .btn:hover { background: var(--accent-dark); }
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.ghost:hover { background: rgba(91, 124, 111, 0.08); }
button:disabled { opacity: 0.5; cursor: default; }

.board-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.board-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.board-tile .thumb {
  height: 130px; background: #e9e5dd center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 2rem;
}
.board-tile .meta { padding: 12px 14px; }
.board-tile .meta strong { display: block; }
.board-tile .meta span { color: var(--muted); font-size: 0.85rem; }

/* Board page */
.board-hero { text-align: center; padding: 20px 0 8px; }
.board-hero .cover {
  width: 150px; height: 150px; border-radius: 50%;
  margin: 0 auto 14px; background: #e9e5dd center/cover no-repeat;
  border: 4px solid #fff; box-shadow: var(--shadow);
}
.board-hero h1 { margin: 0; font-weight: 600; }
.board-hero .subtitle { color: var(--muted); margin: 4px 0 0; }
.board-hero .description { max-width: 620px; margin: 14px auto 0; color: #4a463f; }

.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 22px 0 8px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery .item {
  position: relative; border-radius: 10px; overflow: hidden; background: #e9e5dd;
  aspect-ratio: 1; cursor: pointer;
}
.gallery img, .gallery video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .play-badge {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2rem; text-shadow: 0 1px 6px rgba(0,0,0,.5); pointer-events: none;
}

.comment { border-top: 1px solid var(--line); padding: 14px 0; }
.comment:first-child { border-top: none; }
.comment .who { font-weight: 600; }
.comment .when { color: var(--muted); font-size: 0.8rem; margin-left: 8px; }
.comment .text { margin: 4px 0 0; white-space: pre-wrap; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Controlli di moderazione (visibili solo all'admin) */
.mod-del {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  background: rgba(180, 40, 40, 0.9); color: #fff; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.mod-del:hover { background: #a12626; }
.mod-link {
  background: none; border: none; color: #b42828; font-size: 0.78rem;
  padding: 0 0 0 10px; cursor: pointer; font-weight: 500;
}
.mod-link:hover { text-decoration: underline; background: none; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center; padding: 18px; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 22px;
  width: 100%; max-width: 460px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
  max-height: 90vh; overflow: auto;
}
.modal h3 { margin-top: 0; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img, .lightbox video { max-width: 95vw; max-height: 90vh; border-radius: 8px; }
.lightbox .close { position: absolute; top: 18px; right: 24px; color: #fff; font-size: 2rem; cursor: pointer; }

.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px; }
.muted { color: var(--muted); font-size: 0.85rem; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  opacity: 0; transition: opacity .2s; z-index: 80; pointer-events: none;
}
.toast.show { opacity: 1; }
