:root {
  --bg: #0f0808;
  --panel: #1a1010;
  --panel-2: #231515;
  --line: rgb(178 134 73 / 0.28);
  --gold: #e5b35d;
  --gold-deep: #b28649;
  --bone: #f3f1eb;
  --muted: rgb(243 241 235 / 0.66);
  --wine: #570808;
  --ok: #8fc28a;
  --warn: #e8b25a;
  --err: #ef7d73;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--bone);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
}
a { color: var(--gold); }
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; color: var(--gold); }
p { margin: 0; }
.wrap { width: min(100% - 32px, 980px); margin-inline: auto; padding: 20px 0 120px; }

/* barra superiore */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgb(15 8 8 / 0.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { padding: 10px 0; display: flex; align-items: center; gap: 10px; }
.brand { font-family: Georgia, serif; color: var(--gold); font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* bottoni */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--bone); padding: 10px 16px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--gold); }
button:disabled { opacity: 0.5; cursor: default; }
.primary { background: var(--gold); color: #1a0d07; border-color: var(--gold); font-weight: 700; }
.primary:hover { background: #f0c877; }
.danger { color: var(--err); border-color: rgb(239 125 115 / 0.4); }
.small { padding: 6px 12px; min-height: 36px; font-size: 0.9rem; }
.big { width: 100%; padding: 16px; font-size: 1.1rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* schede */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stack > * + * { margin-top: 16px; }
.section-title { margin: 32px 0 12px; }
.muted { color: var(--muted); }
.list { display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.item img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--panel-2); }
.item .t { font-weight: 600; }
.item .m { font-size: 0.85rem; color: var(--muted); }
.item .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 720px) {
  .item { grid-template-columns: 96px 1fr auto; }
  .item img { width: 96px; height: 64px; }
  .item .actions { grid-column: auto; }
}
.tag { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--gold); }

/* moduli */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; font: inherit; color: var(--bone); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; min-height: 96px; }
textarea.body { min-height: 60vh; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.92rem; line-height: 1.55; }
.counter { float: right; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.counter.bad { color: var(--warn); }
input:read-only { opacity: 0.7; }

/* editor */
.editor { display: grid; gap: 20px; }
@media (min-width: 980px) { .editor { grid-template-columns: 1fr 320px; align-items: start; } .side { position: sticky; top: 76px; } }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.92rem; }
.checks li { padding-left: 22px; position: relative; }
.checks li::before { content: ''; position: absolute; left: 4px; top: 0.5em; width: 9px; height: 9px; border-radius: 50%; }
.checks .ok::before { background: var(--ok); }
.checks .warn::before { background: var(--warn); }
.checks .error::before { background: var(--err); }
.checks .error { color: #ffc9c3; }
.verify { background: rgb(232 178 90 / 0.1); border-color: rgb(232 178 90 / 0.5); }
.verify ul { margin: 8px 0 0; padding-left: 20px; }
.faq-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.related { display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.related label { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; margin: 0; }
.related input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.image-now { display: grid; gap: 10px; }
.image-now img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 360px; overflow: auto; }
.gallery button { padding: 0; border-radius: 8px; overflow: hidden; min-height: 0; aspect-ratio: 3 / 2; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery button.sel { outline: 3px solid var(--gold); }

/* attesa */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgb(10 5 5 / 0.88); display: grid; place-items: center; padding: 24px; text-align: center;
}
.overlay .box { max-width: 420px; }
.flame { width: 18px; height: 28px; margin: 0 auto 18px; border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #fff3c4, var(--gold) 45%, #b2481c 80%); animation: flick 1.2s ease-in-out infinite alternate; }
@keyframes flick { from { transform: scale(1) rotate(-2deg); } to { transform: scale(1.12, 0.94) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .flame { animation: none; } }

/* anteprima */
.preview { position: fixed; inset: 0; z-index: 40; overflow: auto; background: var(--bg); }
.preview .hero { position: relative; min-height: 46vh; display: grid; align-items: end; }
.preview .hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.preview .hero .wrap { position: relative; padding: 40px 0 28px; }
.preview .hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
.preview .hero p { color: var(--muted); font-size: 1.15rem; margin-top: 12px; max-width: 40ch; }
.prose { max-width: 68ch; font-size: 1.08rem; line-height: 1.75; }
.prose h2 { margin: 2.2rem 0 0.8rem; font-size: 1.6rem; }
.prose h3 { margin: 1.6rem 0 0.6rem; color: var(--bone); }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose strong { color: #fff; }
.prose blockquote { border-left: 3px solid var(--gold); margin: 1.5rem 0; padding-left: 1rem; color: var(--muted); }
.preview-bar { position: sticky; top: 0; z-index: 2; background: rgb(15 8 8 / 0.94); border-bottom: 1px solid var(--line); }
.preview-bar .wrap { padding: 10px 0; display: flex; gap: 10px; align-items: center; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(100%, 380px); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%); z-index: 60;
  background: var(--panel-2); border: 1px solid var(--gold); color: var(--bone); border-radius: 12px; padding: 12px 18px;
  max-width: calc(100% - 32px); transition: transform 0.25s ease, visibility 0.25s;
  visibility: hidden;
}
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.bottom-bar ~ #toast, body:has(.bottom-bar) #toast { bottom: 96px; }
#toast.err { border-color: var(--err); }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgb(15 8 8 / 0.96); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bottom-bar .inner { width: min(100%, 980px); margin-inline: auto; display: flex; gap: 10px; }
.bottom-bar button { flex: 1; }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '＋'; float: right; color: var(--gold); }
details.card[open] > summary::after { content: '－'; }
details.card[open] > summary { margin-bottom: 14px; }
