:root {
  --bordeaux: #6b0224;
  --bordeaux-medio: #a50538;
  --giallo: #facc37;
  --giallo-scuro: #e7b308;
  --sfondo: #fefefe;
  --testo: #6b0224;
  --muted: #7a3d4e;
  --muted-sfondo: #f8eef1;
  --bordo: #ead6dc;
  --sidebar: #fefefe;
  --anello: #6b0224;
  --raggio: 0.75rem;
  --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--testo);
  background: var(--sfondo);
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
}

.salta {
  position: absolute;
  left: 0.75rem;
  top: 0;
  transform: translateY(-120%);
  background: var(--testo);
  color: white;
  padding: 0.4rem 0.7rem;
  border-radius: var(--raggio);
  z-index: 5;
}

.salta:focus { transform: none; }

.shell {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  min-height: 100vh;
}

.barra {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem;
  background: var(--sidebar);
  border-right: 1px solid var(--bordo);
  min-height: 100vh;
}

.marca {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 5.75rem;
  margin-bottom: 0.35rem;
  padding: 0.85rem;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  border-radius: 0.9rem;
  background: var(--bordeaux) url("/static/manoscritto.jpg") center 70% / cover no-repeat;
}

.marca::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bordeaux);
  opacity: 0.55;
}

.marca > * { position: relative; }

.marchio {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.4rem;
  flex: none;
}

.marca-nome {
  display: block;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.marca-anno {
  display: block;
  margin-top: 0.1rem;
  color: var(--giallo);
  font-weight: 700;
  font-size: 0.85rem;
}

.voci, .libri { display: flex; flex-direction: column; gap: 0.15rem; }

.voce, .libro, .ghost, .primario, .secondario {
  font: inherit;
  border-radius: calc(var(--raggio) - 2px);
}

.voce, .libro {
  display: block;
  padding: 0.45rem 0.6rem;
  color: inherit;
  text-decoration: none;
}

.voce:hover, .libro:hover, .ghost:hover { background: var(--muted-sfondo); }

.voce.attivo, .libro.attivo {
  background: var(--giallo);
  color: var(--bordeaux);
  font-weight: 600;
}

.libro.attivo .libro-meta { color: var(--bordeaux); }

.gruppo {
  margin: 0.8rem 0 0.2rem;
  padding: 0 0.6rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.libri { overflow: auto; flex: 1; min-height: 0; }

.libro-titolo, .libro-meta { display: block; }

.libro-titolo {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.libro-meta { color: var(--muted); font-size: 0.75rem; }

.piede {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--bordo);
}

.chi { margin: 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }

main {
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.accesso {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(107, 2, 36, 0.7), rgba(107, 2, 36, 0.7)),
    url("/static/libreria.jpg") center / cover no-repeat;
  background-color: var(--bordeaux);
}

.accesso main { margin: 0; padding: 1.5rem; }

h1, h2 { letter-spacing: -0.03em; font-weight: 700; margin: 0 0 0.4rem; }
h1 {
  font-size: 1.6rem;
  padding-left: 0.7rem;
  border-left: 4px solid var(--giallo);
}
h2 { font-size: 1.05rem; margin-top: 0; }

.testata { margin-bottom: 1.25rem; }

.sottotitolo, .gruppo, .libro-meta { line-height: 1.4; }

.sottotitolo { margin: 0; color: var(--muted); }

.scheda {
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 1rem;
  background: white;
}

.scheda + .scheda, .scheda + .utenti, .fatti + .scheda, .avviso + .scheda, .errore + .scheda {
  margin-top: 1rem;
}

.scheda-accesso {
  width: min(24rem, 100%);
  border: 0;
  border-radius: 1.25rem;
  box-shadow: 0 18px 44px rgba(107, 2, 36, 0.35);
}

.insegna {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.insegna p { margin: 0; font-weight: 700; line-height: 1.15; }
.insegna span { color: var(--bordeaux-medio); font-weight: 700; }

.scheda form + form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--bordo); }

label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; font-weight: 500; }

.campo { margin-bottom: 0.85rem; }

.riga {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.riga .campo { flex: 1 1 12rem; margin-bottom: 0; }

input, select, textarea, button { font: inherit; color: inherit; }

input, select, textarea {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
  background: white;
  border: 1px solid var(--bordo);
  border-radius: calc(var(--raggio) - 2px);
}

textarea {
  min-height: 16rem;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.45;
}

button {
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.primario { background: var(--bordeaux); color: white; }
.primario:hover { background: var(--bordeaux-medio); }
.secondario, .ghost { background: white; border-color: var(--bordo); }
.ghost { background: transparent; }

.errore, .avviso {
  padding: 0.7rem 0.8rem;
  border-radius: var(--raggio);
  border: 1px solid var(--bordo);
}

.errore { background: #fef2f2; color: #991b1b; white-space: pre-wrap; }
.avviso { background: #fffbeb; color: #92400e; }

.fatti {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.fatti div {
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 0.7rem 0.8rem;
}

.fatti dt { color: var(--muted); font-size: 0.8rem; }
.fatti dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }

.stato { font-weight: 500; }

.file, .utenti { list-style: none; margin: 0; padding: 0; }

.file a, .utenti li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--bordo);
  color: inherit;
}

.tu {
  margin-left: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.vuoto { margin: 0.3rem 0.6rem; color: var(--muted); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--anello); outline-offset: 2px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .barra { min-height: 0; border-right: 0; border-bottom: 1px solid var(--bordo); }
  .libri { max-height: 14rem; }
  .fatti { grid-template-columns: 1fr; }
  main { padding-top: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
