/* Area riservata — stessa famiglia visiva del sito, più sobria e funzionale */
@font-face { font-family: "Cormorant"; src: url("../fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --stone: #f5efe4; --stone-2: #ebe1cf; --paper: #fffdf9;
  --ink: #1b2230; --text: #1f2633; --muted: #5d6272; --line: rgba(27,34,48,.14);
  --teal: #0f6f68; --amber: #e3a52b; --ruby: #a8302b; --cobalt: #1f4fa3;
  --serif: "Cormorant", Georgia, serif;
  --sans: "Atkinson", "Segoe UI", system-ui, sans-serif;
  --r: 8px;
  --bar: 60px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 1.0625rem/1.55 var(--sans); color: var(--text); background: var(--stone); -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.2em; height: 1.2em; flex: none; vertical-align: -.22em; }
.ico--lg { width: 1.7rem; height: 1.7rem; }
.ico--flip { transform: scaleX(-1); }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }

/* ---- Barra superiore ---- */
.bar { position: sticky; top: 0; z-index: 30; height: var(--bar); display: flex; align-items: center; gap: .6rem; padding: 0 1rem; background: var(--ink); color: #fff; border-bottom: 4px solid transparent; border-image: url("../img/vetrata.svg") 0 0 100% 0 / 0 0 4px 0 repeat; }
.bar__brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; margin-right: auto; min-width: 0; }
.bar__brand img { width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.bar__brand span { display: flex; flex-direction: column; font-weight: 700; line-height: 1.1; }
.bar__brand small { font-weight: 400; font-size: .78rem; color: #aab3c3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__site { display: inline-flex; align-items: center; gap: .4rem; color: #fff; text-decoration: none; font-weight: 700; font-size: .92rem; padding: .55rem .75rem; border-radius: var(--r); border: 1px solid rgba(255,255,255,.25); }
.bar__site:hover { background: rgba(255,255,255,.1); }
.bar__menu { width: 44px; height: 44px; display: grid; place-items: center; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: var(--r); cursor: pointer; }
.bar__menu .ico { width: 1.4rem; height: 1.4rem; }
@media (max-width: 520px) { .bar__site span { display: none; } }

/* ---- Struttura ---- */
.shell { display: block; }
.side { background: var(--paper); border-right: 1px solid var(--line); }
.side ul { list-style: none; margin: 0; padding: .6rem; }
.side a { display: flex; align-items: center; gap: .7rem; padding: .75rem .8rem; border-radius: var(--r); color: var(--ink); text-decoration: none; font-weight: 700; }
.side a:hover { background: var(--stone); }
.side a[aria-current] { background: var(--ink); color: #fff; }
.side__foot { padding: 1rem 1.4rem 1.4rem; border-top: 1px solid var(--line); }
.side__user { display: flex; align-items: center; gap: .5rem; color: var(--muted); margin: 0 0 .6rem; font-size: .95rem; }
@media (max-width: 959px) {
  .side { position: fixed; z-index: 25; top: var(--bar); left: 0; right: 0; bottom: 0; overflow-y: auto; transform: translateX(-100%); transition: transform .22s ease; }
  .side.is-open { transform: none; }
  .side a { font-size: 1.1rem; padding: .95rem .9rem; }
}
@media (min-width: 960px) {
  .bar__menu { display: none; }
  .shell { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - var(--bar)); }
  .side { position: sticky; top: var(--bar); height: calc(100vh - var(--bar)); overflow-y: auto; display: flex; flex-direction: column; justify-content: space-between; }
}
.main { padding: 1.4rem 1rem 6rem; max-width: 980px; width: 100%; }
@media (min-width: 960px) { .main { padding: 2.2rem 2.6rem 5rem; } }

.title { font: 600 clamp(2rem, 6vw, 2.6rem)/1.05 var(--serif); color: var(--ink); margin-bottom: .4rem; }
.intro { color: var(--muted); margin: 0 0 1.4rem; max-width: 42rem; }
.head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.2rem; }
.head .intro { margin-bottom: 0; }
.crumbs { margin-bottom: .6rem; }
.crumbs a { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; text-decoration: none; }

/* ---- Card ---- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; box-shadow: 0 1px 0 rgba(27,34,48,.04), 0 12px 30px -24px rgba(27,34,48,.5); margin-bottom: 1.2rem; }
@media (min-width: 700px) { .card { padding: 1.6rem; } }
.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .6rem; }
.card__head h2, .card__title { display: flex; align-items: center; gap: .5rem; font: 600 1.55rem/1.1 var(--serif); color: var(--ink); }
.card__title { margin-bottom: 1rem; }
.card__head a { font-weight: 700; text-decoration: none; white-space: nowrap; }
.empty { text-align: center; padding: 2.5rem 1rem; }

/* ---- Flash ---- */
.flash { display: flex; gap: .6rem; align-items: flex-start; padding: .9rem 1rem; border-radius: var(--r); margin-bottom: 1.2rem; font-weight: 700; }
.flash .ico { margin-top: .1em; }
.flash--ok { background: #e2f3ef; color: #0b4f4a; border: 1px solid #b4ddd5; }
.flash--err { background: #fbe9e6; color: #7d201c; border: 1px solid #f0c3bd; }

/* ---- Bottoni ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .7rem 1.15rem; border-radius: var(--r); border: 2px solid transparent; font: 700 1rem/1 var(--sans); text-decoration: none; cursor: pointer; }
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--ink); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--block { width: 100%; }
.linkbtn { display: inline-flex; align-items: center; gap: .45rem; background: none; border: 0; padding: .5rem 0; font: 700 1rem var(--sans); color: var(--ink); cursor: pointer; }
.linkbtn--danger { color: var(--ruby); }
.iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r); border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; }
.iconbtn:hover:not([disabled]) { border-color: var(--ink); }
.iconbtn[disabled] { opacity: .3; cursor: default; }
.iconbtn--edit { background: var(--ink); color: #fff; border-color: var(--ink); }
.iconbtn--danger { color: var(--ruby); }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: .45rem .8rem; font: 700 .88rem var(--sans); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--ink); }

/* ---- Elenchi ---- */
.list { list-style: none; padding: 0; }
.row { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row:first-child { border-top: 0; }
.row:target { background: #fff6df; }
.row__main { flex: 1 1 14rem; display: grid; gap: .15rem; text-decoration: none; color: inherit; min-width: 0; }
.row__title { font-weight: 700; color: var(--ink); font-size: 1.08rem; }
.row__meta { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.row__actions { display: flex; gap: .4rem; align-items: center; }
.row__actions form { display: flex; gap: .4rem; }
.badge { font: 700 .72rem/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; padding: .4rem .55rem; border-radius: 4px; white-space: nowrap; }
.badge--teal { background: #dff1ed; color: #0b4f4a; }
.badge--ruby { background: var(--ruby); color: #fff; }
.badge--amber { background: #fcefd0; color: #6b4a06; }
.badge--muted { background: var(--stone-2); color: var(--muted); }

/* ---- Moduli ---- */
.grid { display: grid; gap: 1.1rem 1rem; grid-template-columns: 1fr 1fr; }
.grid > * { grid-column: 1 / -1; }
@media (min-width: 640px) { .grid > .field--half { grid-column: auto; } }
.field { display: grid; gap: .4rem; min-width: 0; margin: 0; }
fieldset.field { border: 0; padding: 0; }
.field > label, .field legend { font-weight: 700; color: var(--ink); padding: 0; }
.req { color: var(--ruby); }
.help { margin: 0; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password], input[type=date], input:not([type]), select, textarea {
  width: 100%; min-height: 50px; padding: .7rem .85rem;
  font: 400 1.05rem/1.4 var(--sans); color: var(--text);
  background: #fff; border: 1.5px solid #c9c2b4; border-radius: var(--r);
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2.4rem; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: 3px solid rgba(15,111,104,.2); outline-offset: 0; }
textarea { min-height: 7rem; resize: vertical; }
.has-error input, .has-error textarea, .has-error .editor { border-color: var(--ruby); }
.has-error > label, .has-error legend { color: var(--ruby); }

.switch { display: flex; align-items: center; gap: .8rem; cursor: pointer; font-weight: 700; color: var(--ink); min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__ui { flex: none; width: 52px; height: 30px; border-radius: 999px; background: #cfc8ba; position: relative; transition: background .2s; }
.switch__ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .switch__ui { background: var(--teal); }
.switch input:checked + .switch__ui::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__ui { outline: 3px solid var(--amber); outline-offset: 2px; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; }
.daybox { position: relative; }
.daybox input { position: absolute; opacity: 0; }
.daybox span { display: grid; place-items: center; min-height: 48px; border-radius: var(--r); border: 1.5px solid #c9c2b4; background: #fff; font-weight: 700; font-size: .92rem; cursor: pointer; user-select: none; }
.daybox input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.daybox input:focus-visible + span { outline: 3px solid var(--amber); }
.days__presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }

.upload { display: grid; gap: .6rem; }
.upload__img { max-height: 180px; width: auto; border-radius: var(--r); border: 1px solid var(--line); }
.upload__file { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; overflow-wrap: anywhere; }
.upload__remove { display: inline-flex; align-items: center; gap: .4rem; color: var(--ruby); font-weight: 700; font-size: .95rem; }
input[type=file] { font: inherit; padding: .6rem; border: 1.5px dashed #c9c2b4; border-radius: var(--r); background: #fff; width: 100%; }

.advanced { margin-top: 1.4rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.advanced summary { cursor: pointer; font-weight: 700; color: var(--teal); padding: .3rem 0; }
.advanced[open] summary { margin-bottom: 1rem; }

.savebar { display: flex; gap: .7rem; justify-content: flex-end; margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.savebar--sticky, .card .savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding-bottom: calc(.8rem + env(safe-area-inset-bottom)); margin-bottom: -1.2rem; z-index: 5; }
.savebar--sticky { background: linear-gradient(transparent, var(--stone) 30%); border-top: 0; margin-bottom: 0; }
@media (max-width: 640px) { .savebar .btn { flex: 1; } }
.danger { margin-top: .5rem; text-align: right; }

/* ---- Editor di testo ---- */
.editor { border: 1.5px solid #c9c2b4; border-radius: var(--r); background: #fff; }
.editor__bar { border-radius: var(--r) var(--r) 0 0; }
.editor:focus-within { border-color: var(--teal); outline: 3px solid rgba(15,111,104,.2); }
.editor__bar { display: flex; flex-wrap: wrap; gap: .2rem; padding: .35rem; background: var(--stone); border-bottom: 1px solid var(--line); position: sticky; top: var(--bar); z-index: 2; }
.editor__bar button { min-width: 42px; height: 40px; padding: 0 .55rem; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); font: 700 .95rem var(--sans); cursor: pointer; }
.editor__bar button:hover { background: #fff; border-color: var(--line); }
.editor__bar button[aria-pressed=true] { background: var(--ink); color: #fff; }
.editor__sep { width: 1px; background: var(--line); margin: .3rem .15rem; }
.editor__area { min-height: 12rem; padding: .9rem 1rem; outline: none; font-size: 1.05rem; line-height: 1.6; }
.editor__area:empty::before { content: attr(data-placeholder); color: #9a9fab; }
.editor__area p { margin: 0 0 .8em; }
.editor__area h3 { font: 600 1.5rem/1.2 var(--serif); margin: .8em 0 .3em; }
.editor__area mark { background: #fbe1a6; }
.editor__area blockquote { margin: .8em 0; padding-left: 1rem; border-left: 3px solid var(--amber); font-style: italic; }
.editor textarea.is-source { border: 0; border-radius: 0; min-height: 14rem; font: .92rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none; }

/* ---- Bacheca ---- */
.quick { display: grid; gap: .8rem; margin-bottom: 1.4rem; }
@media (min-width: 760px) { .quick { grid-template-columns: 1.3fr 1fr 1fr; } }
.quick__item { display: flex; gap: .9rem; align-items: center; padding: 1.1rem 1.2rem; border-radius: var(--r); background: var(--paper); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.quick__item:hover { border-color: var(--ink); }
.quick__item span { display: grid; gap: .1rem; color: var(--muted); font-size: .92rem; line-height: 1.3; }
.quick__item strong { color: var(--ink); font-size: 1.08rem; }
.quick__item--main { background: var(--teal); border-color: var(--teal); color: #fff; }
.quick__item--main span, .quick__item--main strong { color: #fff; }
.quick__item--main:hover { background: var(--ink); border-color: var(--ink); }

.dash { display: grid; gap: 1.2rem; align-items: start; }
.dash > .card { margin: 0; }
@media (min-width: 860px) { .dash { grid-template-columns: 1fr 1fr; } }
.stat { margin: 0 0 1rem; color: var(--muted); }
.stat strong { color: var(--ink); }
.mini { list-style: none; margin: 0; padding: 0; }
.mini a { display: grid; gap: .1rem; padding: .7rem 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 700; }
.mini small { color: var(--muted); font-weight: 400; font-size: .88rem; }
.week { list-style: none; margin: 0 0 .8rem; padding: 0; }
.week li { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: .6rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--line); }
.week__day { font-weight: 700; color: var(--ink); }
.week__times { font-variant-numeric: tabular-nums; }
.week li.is-ex .week__times { color: var(--ruby); font-weight: 700; }
.week__act { font-size: .85rem; font-weight: 700; text-decoration: none; padding: .35rem .6rem; border-radius: 999px; background: #fbe9e6; color: var(--ruby); }
.week__act--add { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.week__act--add:hover { color: var(--ink); border-color: var(--ink); }

/* ---- Accesso ---- */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; background:
  radial-gradient(40rem 30rem at 0% 0%, rgba(20,153,141,.35), transparent 60%),
  radial-gradient(40rem 30rem at 100% 100%, rgba(31,79,163,.4), transparent 60%),
  var(--ink); }
.login { position: relative; overflow: hidden; width: 100%; max-width: 420px; background: var(--paper); border-radius: var(--r); padding: 2.4rem 1.5rem 1.6rem; box-shadow: 0 40px 80px -30px rgba(0,0,0,.7); }
.login__glass { position: absolute; top: 0; left: 0; right: 0; height: 12px; background: url("../img/vetrata.svg") repeat-x left center / auto 100%; }
.login__logo { width: 72px; height: 72px; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink); margin: 0 auto 1rem; }
.login h1 { font: 600 2rem/1.1 var(--serif); text-align: center; color: var(--ink); }
.login__sub { text-align: center; color: var(--muted); margin: .3rem 0 1.4rem; }
.login .form { display: grid; gap: 1rem; }
.login__back { text-align: center; margin: 1.2rem 0 0; }
.login__back a { color: var(--muted); }

/* Interruttore rapido della diretta (Bacheca) */
.livebar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: 1rem 1.2rem; margin-bottom: 1.4rem;
  border-radius: var(--r); background: var(--paper); border: 1px dashed var(--line); color: var(--muted); }
.livebar > .ico { color: var(--muted); flex: none; }
.livebar p { flex: 1 1 16rem; margin: 0; display: grid; gap: .1rem; font-size: .95rem; line-height: 1.35; }
.livebar strong { color: var(--ink); font-size: 1.02rem; }
.livebar form { margin: 0; }
.livebar.is-on { border-style: solid; border-color: var(--ruby); background: #fbeee0; }
.livebar.is-on > .ico { color: var(--ruby); }

/* Stato del pop-up (Bacheca) */
.popstate { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .5rem; margin: -.2rem 0 1rem; padding: .55rem .75rem;
  border-radius: 6px; background: var(--stone); color: var(--muted); font-size: .92rem; }
.popstate .ico { width: 1.1rem; height: 1.1rem; flex: none; }
.popstate a { font-weight: 700; color: var(--teal); }
.popstate.is-on { background: #e3f1ef; color: var(--ink); }
.popstate.is-on .ico { color: var(--teal); }
