/* Hydrochoos — tema "Pergamena contemporanea".
   Carta calda, blu inchiostro e terracotta; titoli in Fraunces, testo in Inter.
   I nomi storici delle variabili (--bg, --panel, --accent, ...) restano validi
   perché sono usati anche negli stili inline delle pagine. */

@font-face {
  font-family: "Fraunces";
  src: url("/app/static/fonts/Fraunces-Variable.ttf") format("truetype");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/app/static/fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, Arial, sans-serif;

  --paper: #FBF7F0;
  --paper-deep: #F1E8D8;
  --surface: #FFFFFF;
  --surface-2: #F7F1E6;
  --surface-3: #EFE6D6;
  --ink: #1B2236;
  --ink-soft: #3A4157;
  --muted: #6B7285;
  --line: #E8DFCF;
  --line-strong: #D8CAB0;
  --accent: #1E3A8A;
  --accent-hover: #172E6E;
  --accent-soft: #E9EEF9;
  --accent-ring: rgba(30, 58, 138, .18);
  --terra: #C2410C;
  --terra-soft: #FBEADF;
  --sage: #5E7F5B;
  --gold: #B7791F;
  --on-accent: #FFFFFF;
  --success: #2F6B4F;
  --success-soft: #E5F1EA;
  --warning: #8A5A12;
  --warning-soft: #FBF0DA;
  --danger: #B42318;
  --danger-soft: #FCEBE9;
  --shadow-sm: 0 1px 2px rgba(27, 34, 54, .05);
  --shadow-md: 0 1px 2px rgba(27, 34, 54, .04), 0 10px 28px -14px rgba(27, 34, 54, .18);
  --shadow-lg: 0 18px 44px -18px rgba(27, 34, 54, .32);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  /* Alias storici */
  --bg: var(--paper);
  --content: var(--paper);
  --panel: var(--surface);
  --bar: var(--surface);
  --sidebar: var(--surface-2);
  --sidebar-dark: var(--paper-deep);
  --stone: var(--paper-deep);
  --stone-dark: var(--line-strong);
  --text: var(--ink);
  --hero-text: var(--ink);
  --hero-border: var(--line-strong);
  --topbar-hover: var(--surface-2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14161D;
    --paper-deep: #1A1D26;
    --surface: #1D2029;
    --surface-2: #252935;
    --surface-3: #2D3240;
    --ink: #F3EDE2;
    --ink-soft: #D9D2C5;
    --muted: #A3A8B8;
    --line: #2E3240;
    --line-strong: #3D4253;
    --accent: #8FA8F0;
    --accent-hover: #A9BDF5;
    --accent-soft: #232C47;
    --accent-ring: rgba(143, 168, 240, .25);
    --terra: #F08A5D;
    --terra-soft: #3A251C;
    --sage: #9DBB98;
    --gold: #E3B567;
    --on-accent: #0E1424;
    --success: #7CC7A0;
    --success-soft: #1E3029;
    --warning: #E8B866;
    --warning-soft: #33291A;
    --danger: #F4877C;
    --danger-soft: #3A2020;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -16px rgba(0, 0, 0, .6);
    --shadow-lg: 0 20px 48px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); }
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Intestazioni storiche del menu */
.menu-head {
  background: var(--paper-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  width: 100%;
}
.brand-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-decoration: none;
  color: var(--ink);
}
.icon-box {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.icon-box img { width: 100%; height: 100%; object-fit: contain; }
.brand-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
  white-space: nowrap;
}

/* Menu account */
.account-menu { position: relative; flex: 0 0 auto; }
.topbar > .account-menu { margin-left: 0; }
.account-menu > summary {
  list-style: none;
  height: 100%;
  min-height: 52px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-left: 1px solid var(--line);
  transition: background .15s;
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:hover, .account-menu[open] > summary { background: var(--surface-2); }
.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--accent);
  color: var(--on-accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-avatar-large { width: 52px; height: 52px; flex: 0 0 52px; font-size: 16px; }
.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 292px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 20;
}
.topbar > .account-menu .account-dropdown { left: auto; right: 8px; }
.account-identity { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface-2); }
.account-identity div { min-width: 0; }
.account-identity strong, .account-identity small { display: block; overflow: hidden; text-overflow: ellipsis; }
.account-identity small { color: var(--muted); margin-top: 3px; }
.account-dropdown > a, .account-dropdown form button {
  width: 100%;
  min-height: 42px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  text-align: left;
}
.account-dropdown > a:hover, .account-dropdown form button:hover { background: var(--accent-soft); color: var(--accent); }
.account-dropdown > a.account-admin-link { justify-content: flex-start; padding-left: 24px; }
.account-menu-separator { border-top: 1px solid var(--line); }
.account-menu-heading { padding: 10px 16px 4px; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .09em; }
.account-pencil { color: var(--terra); font-size: 18px; }
.account-dropdown form { margin: 0; }

/* Profilo e avatar */
.profile-avatar-panel { display: flex; align-items: center; gap: 24px; }
.profile-avatar-preview {
  width: 108px;
  height: 108px;
  flex: 0 0 108px;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  overflow: visible;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  border: 4px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-md);
}
.profile-avatar-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-avatar-edit {
  position: absolute;
  right: -2px;
  bottom: 2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--terra);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 18px;
}
.profile-avatar-actions { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.profile-avatar-actions form { margin: 0; }
.profile-avatar-actions .action { min-height: 46px; white-space: nowrap; }
.avatar-upload-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.avatar-upload-form input[type="file"] { max-width: 310px; }
.avatar-choice-fieldset {
  margin: 12px 0 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.avatar-choice-fieldset legend { padding: 0 8px; font-weight: 650; }
.avatar-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 12px;
}
.avatar-choice {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  justify-items: center;
  gap: 7px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.avatar-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.avatar-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.avatar-choice input { width: auto; margin: 0; }
.avatar-choice img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
}
.avatar-choice-none span {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 30px;
}

/* Barra di navigazione */
.topbar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  display: flex;
  align-items: stretch;
  gap: 2px;
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  min-height: 56px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
}
.topbar a, .drop button, .nav-back-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  margin: 9px 0;
  padding: 0 13px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-back-button {
  padding: 0 14px 0 10px;
  margin-right: 6px;
  color: var(--accent);
  gap: 6px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.nav-back-button:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.nav-back-icon { font-size: 16px; line-height: 1; font-weight: 700; }
.topbar a:hover, .drop button:hover { background: var(--surface-2); color: var(--ink); }
.topbar a.current-page,
.drop > button.current-page {
  background: var(--accent);
  color: var(--on-accent);
}
.account-menu > summary.current-page { background: var(--accent-soft); }
.topbar a.current-page:hover,
.drop > button.current-page:hover { background: var(--accent-hover); color: var(--on-accent); }
.account-menu > summary.current-page:hover { background: var(--accent-soft); }

/* Mascotte Hýdōr: logo statico che diventa la goccia animata (hydor-mascot.js). */
.hydor-mascot {
  --hm-size: 76px;
  position: fixed;
  left: 20px;
  top: calc(100vh - var(--hm-size) - 24px);
  z-index: 9998;
  width: var(--hm-size);
  height: var(--hm-size);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.hydor-mascot-body {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  border-radius: 50%;
}
.hydor-mascot-body:focus-visible { outline-offset: 4px; }
.hydor-mascot.is-dragging .hydor-mascot-body { cursor: grabbing; }
.hydor-mascot.is-gliding { transition: left .5s cubic-bezier(.3, .8, .3, 1), top .5s cubic-bezier(.3, .8, .3, 1); }
.hydor-mascot.is-docked .hydor-mascot-body { cursor: pointer; transition: transform .15s; }
.hydor-mascot.is-docked .hydor-mascot-body:hover { transform: translateY(-2px) scale(1.04); }
.hydor-mascot.is-docked .hydor-mascot-logo { box-shadow: 0 0 0 1px var(--line-strong), 0 0 0 5px var(--accent-ring), var(--shadow-lg); }
.hydor-mascot-logo,
.hydor-mascot-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity .55s ease, transform .7s cubic-bezier(.2, .9, .25, 1.3), filter .55s ease;
}
.hydor-mascot-logo {
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-lg);
  pointer-events: none;
}
.hydor-mascot-svg { overflow: visible; opacity: 0; transform: scale(.35) translateY(18px); pointer-events: none; }
.hydor-mascot[data-state="morphing"] .hydor-mascot-logo { opacity: 0; transform: scale(.55) rotate(-25deg); filter: blur(4px); }
.hydor-mascot[data-state="morphing"] .hydor-mascot-svg,
.hydor-mascot[data-state="alive"] .hydor-mascot-svg { opacity: 1; transform: none; }
.hydor-mascot[data-state="alive"] .hydor-mascot-logo { opacity: 0; transform: scale(.4); }
.hydor-mascot[data-state="morphing"] .hm-body { animation: hm-pop .8s cubic-bezier(.2, .9, .25, 1.3) both; }

.hm-shadow { fill: #0B1426; opacity: .22; transform-origin: 50px 97px; }
.hm-core { fill: #070B14; }
.hm-sheen { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 26 120; animation: hm-sheen 3.4s ease-in-out infinite; }
.hm-body { transform-origin: 50px 95px; }
.hm-look { transition: transform .15s ease-out; }
.hm-eyes { fill: #EAF6FF; transform-box: fill-box; transform-origin: center; animation: hm-blink 5s infinite; }
.hm-eyes-closed, .hm-mouth { fill: none; stroke: #EAF6FF; stroke-width: 2.2; stroke-linecap: round; }
.hm-eyes-closed { opacity: 0; }
.hydor-mascot[data-state="alive"] .hm-body { animation: hm-bob 3.2s ease-in-out infinite; }
.hydor-mascot[data-state="alive"] .hm-shadow { animation: hm-shadow 3.2s ease-in-out infinite; }

/* Stati */
.hydor-mascot.is-dragging .hm-body { animation: none; transform: rotate(-6deg) scale(1.06); }
.hydor-mascot.is-thinking .hm-body { animation: hm-bob 1.1s ease-in-out infinite; }
.hydor-mascot.is-thinking .hm-sheen { animation-duration: 1s; }
.hydor-mascot.is-thinking .hm-look { transform: translateY(-2.5px) !important; }
.hydor-mascot.is-happy .hm-body { animation: hm-jump .7s cubic-bezier(.3, 1.6, .5, 1) 2; }
.hydor-mascot.is-happy .hm-mouth { d: path("M44.5 58 q5.5 6 11 0"); }
.hydor-mascot.is-sleeping .hm-eyes { opacity: 0; }
.hydor-mascot.is-sleeping .hm-eyes-closed { opacity: 1; }
.hydor-mascot.is-sleeping .hm-body { animation: hm-bob 5.5s ease-in-out infinite; }
.hydor-mascot-zzz {
  position: absolute;
  right: -4px;
  top: -6px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
}
.hydor-mascot.is-sleeping .hydor-mascot-zzz { animation: hm-zzz 2.8s ease-in-out infinite; }
.hydor-mascot.is-listening .hydor-mascot-body::before,
.hydor-mascot.is-listening .hydor-mascot-body::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 2px solid #3FB4F7;
  animation: hm-ripple 1.6s ease-out infinite;
  pointer-events: none;
}
.hydor-mascot.is-listening .hydor-mascot-body::after { animation-delay: .8s; }
.hydor-mascot.is-listening .hm-mouth { d: path("M47 58.5 a3 3 0 0 0 6 0 a3 3 0 0 0 -6 0"); }
/* Mentre legge la risposta ad alta voce, la bocca si muove. */
.hydor-mascot.is-speaking .hm-mouth { animation: hm-talk .28s ease-in-out infinite alternate; }
@keyframes hm-talk {
  from { d: path("M46 58.5 q4 1.5 8 0"); }
  to { d: path("M46.5 57.5 a3.5 3.5 0 0 0 7 0 a3.5 3.5 0 0 0 -7 0"); }
}
@media (prefers-reduced-motion: reduce) { .hydor-mascot.is-speaking .hm-mouth { animation: none; } }

/* Pillola azioni */
.hydor-mascot-dock {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px) scale(.92);
  transition: opacity .18s ease, transform .18s ease;
}
.hydor-mascot.dock-below .hydor-mascot-dock { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -6px) scale(.92); }
.hydor-mascot.is-open .hydor-mascot-dock { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) scale(1); }
.hydor-dock-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.hydor-dock-btn:hover { background: var(--accent-soft); color: var(--accent); }
.hydor-dock-btn:active { transform: scale(.94); }

@keyframes hm-bob { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-4px) scale(1.02, .98); } }
@keyframes hm-shadow { 0%, 100% { transform: scale(1); opacity: .22; } 50% { transform: scale(.85); opacity: .14; } }
@keyframes hm-sheen { 0% { stroke-dashoffset: 70; } 60%, 100% { stroke-dashoffset: -70; } }
@keyframes hm-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }
@keyframes hm-pop { 0% { transform: scale(.4, .2) translateY(30px); } 55% { transform: scale(1.15, .85); } 75% { transform: scale(.94, 1.06); } 100% { transform: none; } }
@keyframes hm-jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px) scale(.96, 1.05); } 70% { transform: translateY(0) scale(1.06, .94); } }
@keyframes hm-zzz { 0% { opacity: 0; transform: translate(0, 4px); } 30% { opacity: .9; } 100% { opacity: 0; transform: translate(8px, -14px); } }
@keyframes hm-ripple { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }

.topbar > .info-link { margin-left: auto; gap: 7px; }
.language-switch { display: flex; align-items: center; margin: 0 4px 0 2px; }
.language-switch button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.language-switch button:hover, .language-switch button:focus-visible { background: var(--surface-2); border-color: var(--line); }
.language-flag { width: 26px; height: 17px; border-radius: 3px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 18%, transparent); display: block; }
.info-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  border: 1.5px solid currentColor;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.topbar .topbar-exit { margin-left: auto; display: flex; align-items: stretch; }
.topbar .topbar-exit button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  margin: 9px 0;
  padding: 0 13px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.topbar .topbar-exit button:hover { background: var(--surface-2); }
.drop { position: relative; display: flex; align-items: stretch; }
.drop-menu {
  display: none;
  position: absolute;
  top: calc(100% - 4px);
  left: 0;
  z-index: 5;
  min-width: 270px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.drop:hover .drop-menu, .drop:focus-within .drop-menu { display: block; }
.drop-menu a {
  display: block;
  margin: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: transparent;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.drop-menu a:hover { background: var(--accent-soft); color: var(--accent); }
.drop-heading {
  padding: 10px 12px 4px;
  color: var(--terra);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.drop-separator { height: 1px; background: var(--line); margin: 6px 4px; }
.sidebar { display: none !important; }

/* Fascia del marchio */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 24px;
  color: var(--ink);
  background-color: var(--paper-deep);
  background-image:
    radial-gradient(120% 140% at 50% 0%, color-mix(in srgb, var(--surface) 55%, transparent) 0%, transparent 60%);
  border-bottom: 1px solid var(--line-strong);
  width: 100%;
}
.hero-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.hero-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  border-radius: 12px;
  transition: transform .15s ease;
}
.hero-logo-link:hover { transform: scale(1.05); }
.hero-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(27, 34, 54, .22));
}
.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 96;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: center;
  line-height: 1.15;
  color: var(--ink);
}

main {
  min-width: 0;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  background: transparent;
  padding: 28px 40px 96px;
  overflow: auto;
  flex: 1;
}
h2 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 72;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.1;
  color: var(--ink);
}
h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.005em; }

/* Superfici */
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
}
.detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}
.detail-section h3 {
  margin: 0 0 14px;
  font-size: 21px;
}

/* Scheda record */
.record-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.record-detail-head h2 { margin: 4px 0 0; }
.record-kicker {
  color: var(--terra);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.record-id-badge {
  min-width: 86px;
  min-height: 40px;
  padding: 0 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.record-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.record-toolbar .actions { margin-bottom: 0; }
.action-menu { position: relative; display: inline-block; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu > summary::after { content: "▾"; font-size: 12px; margin-left: 2px; }
.action-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 250px;
  display: grid;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
.action-menu-list a { padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 550; }
.action-menu-list a:hover, .action-menu-list a:focus-visible { background: var(--surface-2); }
.network-canvas { display: block; width: 100%; height: 620px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--paper); touch-action: none; cursor: grab; }
.network-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.network-toolbar input { max-width: 280px; }
.network-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-soft); }
.network-legend-item::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px;
  vertical-align: -1px; background: var(--muted); }
.network-kind-persona::before { background: var(--accent); }
.network-kind-famiglia::before { background: var(--terra); }
.network-kind-ente_ecclesiastico::before { background: var(--sage); }
.network-kind-ente_civile::before { background: var(--gold); }
@media (max-width: 720px) { .network-canvas { height: 460px; } }
.record-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.record-summary-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 78px;
  box-shadow: var(--shadow-sm);
}
.record-summary-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 7px;
}
.record-summary-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}
.record-status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.record-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
}
.record-status.status-ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.record-status.status-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.record-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 18px;
  align-items: start;
}
.record-column { min-width: 0; }
.record-image-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.record-main-image {
  min-height: 260px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.record-main-image img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}
.text-block { white-space: pre-wrap; line-height: 1.6; }
.objective-letter {
  max-width: 900px;
  margin: 0 auto 32px;
  padding: 48px 64px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--terra);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14;
  font-size: 18px;
  line-height: 1.78;
}
.objective-letter p { margin: 0 0 1.35em; text-align: justify; hyphens: auto; }
.objective-letter p:last-child { margin-bottom: 0; padding-top: 8px; text-align: left; }
@media (max-width: 700px) {
  .objective-letter { padding: 30px 24px; font-size: 16px; }
}
.empty-note {
  color: var(--muted);
  font-weight: 500;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
}

/* Numeri e report */
.metric {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 120;
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: 8px 0 4px;
  font-variant-numeric: lining-nums tabular-nums;
}
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.bar-chart { display: grid; gap: 11px; }
.bar-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}
.bar-track {
  height: 12px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; min-width: 2px; background: var(--accent); border-radius: 999px; }
.bar-fill.alt { background: var(--terra); }
.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
/* Schede statistiche: ogni scheda ha un colore a rotazione (--kpi). */
.report-kpi {
  --kpi: var(--accent);
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 124px;
  background:
    radial-gradient(140px 110px at 100% 0%, color-mix(in srgb, var(--kpi) 13%, transparent), transparent 72%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.report-summary > .report-kpi:nth-child(4n+2) { --kpi: var(--terra); }
.report-summary > .report-kpi:nth-child(4n+3) { --kpi: var(--sage); }
.report-summary > .report-kpi:nth-child(4n+4) { --kpi: var(--gold); }
.report-summary-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.report-summary-5 > .report-kpi:nth-child(5) { --kpi: var(--ink-soft); }
a.report-kpi-link { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.report-kpi-link:hover { border-color: color-mix(in srgb, var(--kpi) 45%, var(--line)); box-shadow: var(--shadow-md, var(--shadow-sm)); }
@media (max-width: 1100px) { .report-summary-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.report-kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--kpi), color-mix(in srgb, var(--kpi) 0%, transparent));
}
.report-kpi > .muted:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.report-kpi > .muted:first-child::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--kpi);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--kpi) 16%, transparent);
}
.report-kpi .metric {
  margin: 10px 0 2px;
  font-size: 46px;
  color: var(--ink);
}
.report-kpi > .muted:last-child:not(:first-child) {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
}
.report-kpi h3 { margin: 8px 0 4px; }

/* Schede di categoria con numero (Apri archivio). */
.cards > a.card { position: relative; overflow: hidden; }
.cards > a.card .metric { font-size: 38px; color: var(--ink); }
.cards > a.card > .muted:last-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.cards > a.card > .muted:last-child::after { content: "→"; transition: transform .15s; }
.cards > a.card:hover > .muted:last-child::after { transform: translateX(3px); }

/* Grafici */
.chart-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin: -4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.chart-total strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin-right: 2px;
}
.chart-top strong { color: var(--ink); font-weight: 600; }
.chart-share {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.chart-canvas { position: relative; width: 100%; height: 280px; }
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 160px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--line) 45%, transparent) 10px 11px);
  color: var(--muted);
  font-weight: 500;
}
.chart-empty-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    linear-gradient(var(--muted), var(--muted)) 3px 12px / 4px 7px no-repeat,
    linear-gradient(var(--muted), var(--muted)) 9px 7px / 4px 12px no-repeat,
    linear-gradient(var(--muted), var(--muted)) 15px 3px / 4px 16px no-repeat;
  opacity: .55;
}
.report-grid > .panel > h3:first-child { margin-top: 0; margin-bottom: 14px; }
/* Un riquadro rimasto da solo nell'ultima riga occupa tutta la larghezza, senza lasciare un buco accanto. */
.report-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.muted { color: var(--muted); }

/* Tabelle */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
tr:last-child > td { border-bottom: 0; }
th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr { transition: background .12s; }
tr:hover td { background: var(--accent-soft); }
.thumb-col { width: 92px; }
.table-actions {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  white-space: nowrap;
  text-align: left;
}
.table-actions .actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  margin: 0;
  align-items: center;
}
.table-actions .action { min-height: 34px; padding: 0 14px; font-size: 13px; }
.record-thumb {
  width: 72px;
  height: 56px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-decoration: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}
.record-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.record-thumb.empty {
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface-3) 8px 9px);
}
.record-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.record-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Pulsanti */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s, color .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.action:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.action:active { transform: translateY(1px); }
.action.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.action.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.action.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.action.danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }
.action:disabled { opacity: .45; cursor: not-allowed; }
.disabled-link { opacity: .45; cursor: not-allowed; pointer-events: none; }
button.action { font-family: inherit; }

.notice {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
}

/* Dettagli e allegati */
.detail-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 10px 18px;
}
.detail-label { color: var(--muted); font-weight: 600; }
.detail-label.no-wrap { white-space: nowrap; }
.attachment-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.attachment-preview {
  width: 112px;
  height: 86px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 650;
  color: var(--muted);
}
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; }
.attachment-title { font-weight: 650; margin-bottom: 4px; word-break: break-word; }
.attachment-badge {
  display: inline-block;
  padding: 2px 9px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  margin-bottom: 7px;
}

/* Badge e permessi */
.badge-list { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.perm-read { background: var(--surface-2); color: var(--ink-soft); }
.perm-write { background: var(--terra-soft); color: var(--terra); border-color: transparent; }
.perm-admin { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.permission-summary { display: grid; gap: 8px; min-width: 260px; }
.permission-area-line {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.permission-area-name {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .06em;
  color: var(--muted);
  text-transform: uppercase;
  padding-top: 5px;
}
.permission-card {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}
.permission-card h3 { margin: 0 0 10px; font-size: 18px; }
.permission-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.permission-row:first-of-type { border-top: 0; }

/* Confronti di importazione e unione */
.merge-compare {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px;
}
.merge-compare table { margin: 0; }
.compare-uguale td, .compare-existing td, .compare-valid td { background: var(--success-soft); }
.compare-diverso td, .compare-duplicate td, .compare-warning td { background: var(--warning-soft); }
.compare-nuovo td { background: var(--accent-soft); }
.compare-mancante td, .compare-error td { background: var(--danger-soft); }
.import-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.import-filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.import-filter-bar .action.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.merge-compare-toggle { margin-top: 10px; min-height: 32px; }
.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 650;
}
.status-off { background: var(--danger-soft); color: var(--danger); }

/* Filtri e moduli */
.filter-panel { margin-bottom: 16px; }
.quick-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 16px;
  align-items: flex-end;
}
.filter-field { flex: 1 1 180px; min-width: 0; }
.quick-filter label {
  display: block;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.quick-filter input, .quick-filter select { min-height: 40px; }
.quick-filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-top: 18px;
  flex: 0 0 auto;
  margin-left: auto;
}
.section-title {
  grid-column: 1 / -1;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
}
form.grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 12px 18px;
  align-items: center;
}
form.grid > label { color: var(--ink-soft); font-weight: 550; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 14px;
  font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong)); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input[type="file"] { background: var(--surface-2); border-style: dashed; cursor: pointer; }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.full { grid-column: 1 / -1; }
code {
  font-size: .9em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

@media (max-width: 1050px) {
  .record-layout, .record-detail-head, .quick-filter, .record-summary-strip {
    grid-template-columns: 1fr;
  }
}
@media print {
  .menu-head, .topbar, .sidebar, .hero, .actions, .hydor-floating-launcher, #hydor-widget, .skip-link, form { display: none !important; }
  .app { display: block; }
  main { padding: 0; overflow: visible; max-width: none; }
  body { background: white; color: #111; }
  .panel, .card, .detail-section, .report-kpi { border: 1px solid #dcd3c2; box-shadow: none; padding: 14px; margin-bottom: 16px; page-break-inside: avoid; }
  .report-summary, .report-grid { page-break-inside: avoid; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
}

/* Tablet e smartphone */
@media (max-width: 900px) {
  .app { display: flex; flex-direction: column; }
  .menu-head { padding: 12px 16px; }
  .hero { padding: 12px 16px; }
  .hero h1 { font-size: 20px; letter-spacing: .04em; }
  .hero-logo { width: 42px; height: 42px; }
  .topbar { overflow-x: auto; min-height: 52px; scrollbar-width: none; }
  main { padding: 18px 16px 88px; }
  h2 { font-size: 28px; }
  .cards { grid-template-columns: 1fr; }
  .record-summary-strip, .report-summary { grid-template-columns: 1fr 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  form.grid { grid-template-columns: 1fr; gap: 6px; }
  form.grid > label { margin-top: 8px; }
  .detail-grid { grid-template-columns: 1fr; gap: 2px; }
  .detail-grid .detail-label { margin-top: 10px; }
}

/* Briciole di pane */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 13px;
}
.breadcrumb-bar a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 550;
}
.breadcrumb-bar a:hover { text-decoration: underline; text-underline-offset: 3px; }
.breadcrumb-sep { color: var(--line-strong); font-size: 11px; user-select: none; }
.breadcrumb-current { color: var(--muted); font-weight: 500; }

/* Schede KPI cliccabili */
a.report-kpi {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: block;
}
a.report-kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}

/* Citazioni (APA e ISO 690) */
.citation-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--terra);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 14px 0;
}
.citation-box h4 {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--terra);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.citation-style-row { margin-bottom: 10px; font-size: 13.5px; line-height: 1.55; }
.citation-style-row:last-child { margin-bottom: 0; }
.citation-style-name {
  font-weight: 650;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.citation-style-content {
  background: var(--surface-2);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14;
  word-break: break-word;
}

/* Navigazione da tastiera e accessibilità trasversale. */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20000;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 650;
  transform: translateY(-160%);
  transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); }
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
#main-content:focus { outline: none; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Password temporanea mostrata una sola volta all'amministratore */
.temp-password-panel { max-width: 720px; }
.temp-password-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.temp-password {
  font-size: 1.35rem; letter-spacing: .04em; padding: 8px 14px;
  border: 1px dashed var(--accent); border-radius: 10px; user-select: all;
}

/* Visualizzatore con zoom profondo */
.zoom-viewer { width: 100%; height: 72vh; min-height: 420px; background: #1B2236; border-radius: 12px; overflow: hidden; }
.zoom-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.zoom-regions { max-height: 72vh; overflow: auto; }
.zoom-regions .record-toolbar { margin-bottom: 10px; }
.zoom-region-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.zoom-region-list li { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14px; line-height: 1.45; }
.zoom-region-list li:hover, .zoom-region-list li.is-active, .zoom-region-list li:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.zoom-region-remove { margin-top: 6px; min-height: 30px; padding: 0 12px; font-size: 12px; }
.zoom-region { border: 2px solid #F5C451; background: rgba(245, 196, 81, .14); border-radius: 3px; box-sizing: border-box; pointer-events: none; }
.zoom-region span { display: inline-block; margin: -2px 0 0 -2px; padding: 1px 6px; background: #F5C451; color: #1B2236; font: 700 11px/1.4 Inter, system-ui, sans-serif; border-radius: 3px 0 3px 0; }
.zoom-region.is-active { border-color: #FF8A3D; background: rgba(255, 138, 61, .2); }
.zoom-region.is-sketch { border-style: dashed; }
.zoom-viewer.is-drawing { cursor: crosshair; outline: 3px solid #F5C451; }
@media (max-width: 980px) { .zoom-layout { grid-template-columns: 1fr; } .zoom-regions { max-height: none; } }
.image-region-links { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; line-height: 1.45; }
.saved-search-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.saved-search-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bulk-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg); background: var(--surface-2); }
.bulk-form input { max-width: 240px; }
.map-time-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.map-time-row + .map-time-row { margin-top: 8px; font-size: 14px; }
.map-time-row input[type=range] { flex: 1; min-width: 200px; accent-color: var(--accent); }
.map-time-year { font-family: Fraunces, Georgia, serif; font-size: 22px; min-width: 120px; text-align: right; }
.map-time-row label { display: inline-flex; align-items: center; gap: 6px; }
.map-time-row label input { width: auto; }
.dossier-entry { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dossier-date { font-family: Fraunces, Georgia, serif; font-weight: 600; color: var(--accent); }
.dossier-entry blockquote { margin: 8px 0 0; padding: 6px 12px; border-left: 3px solid var(--gold); font-family: Georgia, serif; font-style: italic; }
.dossier-bibliography { padding-left: 22px; line-height: 1.55; }
@media print { .no-print { display: none !important; } }
@media (max-width: 640px) { .dossier-entry { grid-template-columns: 1fr; gap: 4px; } }
.abbr-box { margin-top: 8px; display: grid; gap: 8px; }
.abbr-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.abbr-row:empty { display: none; }
.abbr-sign, .abbr-choice { min-height: 32px; padding: 0 12px; font-size: 13px; font-family: Georgia, serif; }
.abbr-choice { border-color: var(--accent); }
.geo-map { height: 560px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.geo-map.is-drawing { cursor: crosshair; outline: 3px solid #F59E0B; }
.geo-editor { margin-top: 16px; }
.geo-swatch { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 8px; vertical-align: middle; background: #64748B; }
.geo-corso_acqua { background: #2563EB; } .geo-canale { background: #0EA5E9; } .geo-strada { background: #B45309; }
.geo-confine { background: #7C3AED; } .geo-proprieta { background: #15803D; }
@media (max-width: 720px) { .geo-map { height: 420px; } }
.zoom-transcription { margin-bottom: 14px; }
.zoom-transcription summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.zoom-transcription ol { list-style: none; margin: 0; padding: 0; max-height: 34vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.zoom-transcription li { display: grid; grid-template-columns: 34px 1fr; gap: 6px; padding: 5px 8px; cursor: pointer; font-family: Georgia, serif; font-size: 14px; line-height: 1.45; }
.zoom-transcription li:hover { background: var(--surface-2); }
.zoom-transcription li.has-area { background: color-mix(in srgb, #F5C451 18%, transparent); }
.zoom-line-number { color: var(--muted); font-family: Inter, system-ui, sans-serif; font-size: 12px; text-align: right; }
.zoom-region-person { font-size: 13px; }

.clue-list { margin: 4px 0 0; padding-left: 0; list-style: none; font-size: 13px; }
.clue-list li { margin: 2px 0; }
.family-tree { display: grid; gap: 14px; }
.family-level h3 { margin: 0 0 6px; font-size: 14px; }
.family-row { display: flex; flex-wrap: wrap; gap: 10px; }
.family-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface); min-width: 160px; }
.family-card.family-focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.family-spouse { font-size: 13px; margin-top: 4px; }
.stack-form label { display: block; margin: 8px 0 4px; font-weight: 600; font-size: 13px; }
.stack-form input, .stack-form select, .stack-form textarea { width: 100%; }
.record-picker { display: block; }
.record-picker input { width: 100%; }
.record-picker small { display: block; margin-top: 2px; }
.drop-menu .drop-separator-strong { border-top-width: 2px; margin-top: 8px; }
.drop-menu .drop-admin { background: var(--surface-2); border-radius: 8px; padding-bottom: 4px; }
.drop-menu { max-height: calc(100vh - 140px); overflow-y: auto; overscroll-behavior: contain; }
.drop.open > .drop-menu { display: block; }
/* Smartphone: la barra scorre in orizzontale e taglierebbe i menu; si aprono come pannello fisso sotto la barra. */
@media (max-width: 900px) {
  /* backdrop-filter renderebbe la barra il riferimento del pannello fisso, che resterebbe tagliato */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
  /* solo al tocco completato: con hover/focus il menu comparirebbe sotto il dito e il tocco sceglierebbe una voce */
  .drop:hover > .drop-menu, .drop:focus-within > .drop-menu { display: none; }
  .drop.open > .drop-menu { display: block; }
  .drop-menu { position: fixed; left: 8px; right: 8px; min-width: 0; top: var(--drop-top, 60px);
               max-height: calc(100vh - var(--drop-top, 60px) - 12px); overflow-y: auto; z-index: 1001; }
  .drop-menu a { padding: 11px 12px; }
  body:has(.drop.open) .hydor-mascot, body:has(.drop.open) #hydor-mascot { visibility: hidden; }
}
/* Schede: riquadri con contatore, cassetti per i moduli, tre blocchi nella colonna destra */
.detail-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.detail-section-head h3 { margin: 0; }
.detail-section-head > details[open] { flex-basis: 100%; }
.detail-count { color: var(--muted); font-weight: 500; font-size: .85em; }
.add-drawer { margin-top: 10px; }
.detail-section-head > .add-drawer { margin-top: 0; }
.add-drawer > summary { list-style: none; cursor: pointer; display: inline-flex; }
.add-drawer > summary::-webkit-details-marker { display: none; }
.add-drawer[open] > summary { margin-bottom: 6px; }
.add-drawer-body { border-top: 1px dashed var(--line); padding-top: 6px; }
.link-edit > summary { list-style: none; cursor: pointer; display: inline-flex; }
.link-edit > summary::-webkit-details-marker { display: none; }
.detail-group { margin-bottom: 18px; }
.detail-group-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
  margin: 6px 2px 8px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.u-mb-4px { margin-bottom: 4px; }
/* Scrivania: i dettagli per chi cura l'archivio restano a portata di clic, chiusi */
.desk-more { margin: 14px 0; }
.desk-more > summary { cursor: pointer; font-weight: 650; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); list-style: none; }
.desk-more > summary::-webkit-details-marker { display: none; }
.desk-more > summary::before { content: "▸ "; color: var(--accent); }
.desk-more[open] > summary::before { content: "▾ "; }
.desk-more[open] > summary { margin-bottom: 12px; }
.assertion-badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); margin-right: 2px; }
.assertion-status-accettata { background: var(--success-soft); color: var(--success); }
.assertion-status-respinta, .assertion-status-superata { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }
.assertion-quote { font-style: italic; margin: 2px 0 2px 10px; }
.assertion-alternatives { margin: -4px 0 10px 18px; padding-left: 10px; border-left: 3px solid var(--line); }
/* Area didattica: fascia sempre visibile, scelta del corso */
.didactic-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; margin-bottom: 14px;
  border-radius: var(--radius-lg); background: color-mix(in srgb, #F59E0B 16%, var(--surface)); border: 1px solid color-mix(in srgb, #F59E0B 55%, var(--line)); }
.didactic-strip-title { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.didactic-strip-main { flex: 1 1 420px; display: grid; gap: 4px; }
.didactic-strip .actions { margin: 0; }
.didactic-strip-note { font-size: 12px; color: var(--muted); }
form.grid > .course-privacy { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-weight: 400; }
.course-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; }
.course-logo-small { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; }
.course-choices { display: grid; gap: 8px; grid-column: 1 / -1; }
.course-choice { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.course-choice input { width: auto; }
.course-choice span { display: grid; }
.course-choice small { color: var(--muted); }
.course-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.course-inactive { opacity: .6; }

/* Edizione critica: richiami nel testo e apparato */
.edition-text { font-family: var(--font-serif, Georgia, serif); font-size: 1.05rem; line-height: 1.85; }
.edition-lemma { border-bottom: 1px dotted var(--accent); }
.edition-lemma sup { font-size: .68em; color: var(--accent); margin-left: 1px; font-family: var(--font-sans, inherit); }
.edition-apparatus { padding-left: 1.6em; font-size: .95rem; }
.edition-apparatus li { margin-bottom: 4px; }
.edition-remove { background: none; border: 0; padding: 0 4px; color: var(--muted); font-size: .8rem; text-decoration: underline; cursor: pointer; }
.edition-remove:hover { color: var(--danger, #b42318); }
