/* 01. Sistema di base — Inter 400 / 500, mobile first. */
:root {
  --paper: #fff;
  --ink: #171717;
  --muted: #666;
  --line: #dededb;
  --surface: #f7f7f5;
  --gutter: clamp(20px, 3.2vw, 64px);
  --header: 88px;
  --column-gap: clamp(24px, 2.4vw, 40px);
  --row-gap: clamp(40px, 4vw, 60px);
  --section-gap: clamp(72px, 8vw, 120px);
  --text: clamp(14px, .2vw + 13px, 16px);
  --small: 12px;
  --heading: clamp(22px, 1.8vw, 28px);
  --speed: 180ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable both-edges; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text)/1.6 "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, p, figure, dl { margin: 0; }
h1, h2, h3 {
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
h1, h2 { font-size: var(--heading); letter-spacing: -.035em; }
h3 { font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 0;
  border-radius: 0;
  padding: 0;
  min-height: 44px;
  background: none;
  text-align: inherit;
  font-weight: 500;
  cursor: pointer;
}
a, button {
  -webkit-tap-highlight-color: transparent;
  text-underline-offset: .24em;
  transition: opacity var(--speed) ease;
}
button:disabled { opacity: .35; cursor: default; }
:where(a, button):active { opacity: .65; }
:focus-visible { outline: 0px solid currentColor; outline-offset: 4px; }
:where(input, select, textarea):focus-visible { outline-offset: 2px; }
#main:focus { outline: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.micro { font-size: var(--small); font-weight: 400; color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--gutter);
  z-index: 30;
  padding: 12px;
  background: var(--paper);
}
.skip-link:focus { top: 12px; }
.no-script { padding: var(--gutter); }

/* 02. Header: prima riga allineata, anno sulla seconda riga. */
.site-header {
  --header-type: 12px;
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  height: var(--header);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 16px var(--gutter);
  background: var(--paper);
}
.header-left,
.header-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  min-width: 0;
  min-height: 44px;
  padding-block: 8px;
  font-size: var(--header-type);
  font-weight: 400;
  line-height: 1.4;
}
.header-left { justify-self: start; overflow-wrap: anywhere; }
.header-menu { justify-self: end; white-space: nowrap; }
.header-brand {
  position: absolute;
  top: 16px;
  left: var(--brand-center, 50%);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: flex-start;
  width: max-content;
  min-height: 44px;
  padding-block: 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
body[data-scene="home"] .header-brand {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 03. Home: il centro del titolo coincide con il centro della schermata. */
.hero { position: relative; min-height: 100vh; min-height: 100svh; }
.hero-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  padding-inline: var(--gutter);
  text-align: center;
}
.hero h1 {
  font-size: clamp(32px, 7.8vw, 112px);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: 1.1;
}
.hero h1 a { display: inline-block; text-decoration: none; }
.hero-center > p {
  position: absolute;
  top: calc(100% + 20px);
  left: var(--gutter);
  right: var(--gutter);
  font-size: 11px;
}
.scroll-hint {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 0;
  width: 100%;
  padding-inline: var(--gutter);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  pointer-events: none;
  transition: opacity var(--speed) ease;
}
.scroll-hint.is-hidden { opacity: 0; visibility: hidden; }

/* 04. Margini, titoli e navigazione condivisi dalle pagine. */
.page-section {
  min-height: 100svh;
  padding: calc(var(--header) + 32px) var(--gutter) 80px;
}
#feed { padding-top: 32px; }
.page-grid { display: grid; gap: 28px; min-width: 0; }
.page-grid > *, .collection, .project-content, .about-content { min-width: 0; }
.sidebar { align-self: start; }
.sidebar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 22px;
  margin: 0;
}
.sidebar-nav a, .sidebar-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.sidebar-nav :is([aria-pressed="true"], [aria-current="page"], [aria-current="location"]) {
  color: var(--ink);
  text-decoration: underline;
}
.sidebar-nav small { flex-shrink: 0; font-size: 10px; font-variant-numeric: tabular-nums; }
.section-label, .back-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 13px;
}
.back-link { margin-bottom: 16px; }
.collection-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 20px;
  min-height: 44px;
  margin-bottom: 24px;
}
.collection-head h1, .collection-head h2 { font-size: var(--heading); }
.text-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 12px; }
.feed-block, .project-block { scroll-margin-top: calc(var(--header) + 28px); }
.feed-block + .feed-block { margin-top: var(--section-gap); }
.view-switch { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; }
.view-switch button { color: var(--muted); font-weight: 400; }
.view-switch button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; }
.toolbar {
  --control-type: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 24px;
  padding-bottom: 12px;
  margin-bottom: 32px;
}
.toolbar label, .toolbar .search-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: var(--control-type);
  font-weight: 400;
  line-height: 1.4;
}
.toolbar input,
.toolbar select {
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font: inherit;
}
.toolbar select {
  max-width: 140px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  border: 0;
  box-shadow: none;
  line-height: inherit;
  padding-inline-end: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1 1 9 9M2 9h7V2' fill='none' stroke='%23171717'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 10px 10px;
  cursor: pointer;
}
.toolbar .search-field {
  position: relative;
  display: block;
  min-width: 0;
  flex: 1 1 160px;
}
.toolbar .search-field input {
  display: block;
  width: 100%;
  padding: 0 44px 0 0;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  box-shadow: none;
  caret-color: #000;
}
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration {
  display: none;
  -webkit-appearance: none;
}
.toolbar .search-clear {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  color: #000;
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
}
.toolbar .year-filter { min-height: 44px; }
.toolbar .year-filter select:focus-visible {
  outline: none;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: .24em;
}
.toolbar .search-field input:focus-visible {
  outline: none;
  text-decoration: underline;
  text-underline-offset: .24em;
}
.return-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 24px;
  margin-bottom: 16px;
}
.return-links .back-link {
  margin: 0;
  font-weight: 400;
  color: var(--ink);
}
.project-end .return-links { margin: 0; }
.phone-contact:empty { display: none; }
.header-left:not([href]), .header-left:not([href]):is(:hover,:active) {
  opacity: 1; text-decoration: none;
}
.is-restoring .feed-subnav { transition: none; }
@media (min-width: 768px) {
  .toolbar { --control-type: 14px; }
}
.empty-state { padding-block: 32px; color: var(--muted); }

/* Regole limitate al feed: nessun riallineamento delle altre sezioni. */
#feed .collection-head { align-items: baseline; }
#feed .collection-head .text-link {
  display: block;
  line-height: 1.4;
}
#feed-sidebar { overflow-anchor: none; }
#feed-sidebar .feed-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0 24px;
}
#feed-projects-toggle { grid-area: 1 / 1; }
#feed-photos-link { grid-area: 1 / 2; }
.feed-subnav {
  grid-area: 2 / 1 / auto / -1;
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows 220ms ease, opacity 180ms ease,
    visibility 0s 220ms;
}
.feed-subnav.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
.feed-subnav > div { min-height: 0; overflow: hidden; }
.feed-subnav ul { margin: 0; padding: 0 0 8px 12px; list-style: none; }
#feed-sidebar .feed-subnav a {
  width: 100%;
  padding-block: 8px;
  justify-content: flex-start;
  font-size: 12px;
  line-height: 1.4;
}
@media (min-width: 1024px) {
  #feed-sidebar .feed-nav { grid-template-columns: minmax(0, 1fr); }
  #feed-photos-link { grid-area: 3 / 1; }
}

/* 05. Un'unica griglia regolare per progetti e fotografie. */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--row-gap) var(--column-gap);
  align-items: start;
}
.work-card, .photo-card, .work-link, .tile-link { min-width: 0; }
.work-link, .tile-link { display: block; width: 100%; text-align: left; }
.visual-frame {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface);
}
.media { display: block; position: relative; width: 100%; }
.media img { width: 100%; height: auto; object-fit: contain; }
.visual-frame > .media { position: absolute; inset: 0; height: 100%; }
.visual-frame > .media > img { width: 100%; height: 100%; object-fit: contain; }
.media-error { display: none; }
.media-error code { font: inherit; overflow-wrap: anywhere; }
.media.is-missing > img { display: none; }
.media.is-missing .media-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 400;
  text-align: center;
  color: var(--muted);
}
.visual-frame .media-error { height: 100%; border: 0; }
.card-caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 16px;
  margin-top: 12px;
  line-height: 1.45;
}
.card-title { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.card-year { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-category { grid-column: 1 / -1; font-size: 12px; font-weight: 400; color: var(--muted); }
.photo-number { display: block; margin-top: 10px; font-size: 11px; font-weight: 400; color: var(--muted); }
.project-cover > .media { transition: opacity 240ms ease; }
.project-cover > .media > img { transition: filter 240ms ease; }
.project-alternate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}
.work-link:focus-visible .has-alternate > .media { opacity: 0; }
.work-link:focus-visible .has-alternate > .project-alternate { opacity: 1; }
.reveal { opacity: 1; transform: none; }
.reveal.is-waiting { opacity: 0; transform: translateY(10px); }
.reveal.is-visible { opacity: 1; transform: none; transition: opacity 400ms ease, transform 400ms ease; }

/* 06. Indice e scheda progetto. */
.index-year { padding: 24px 0 12px; font-size: 12px; font-weight: 400; color: var(--muted); }
.index-record {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 20px;
  align-items: baseline;
  gap: 4px 12px;
  padding-block: 20px;
  line-height: 1.45;
}
.record-title { font-size: 17px; overflow-wrap: anywhere; }
.record-category { grid-column: 2; grid-row: 2; }
.record-arrow { grid-column: 3; grid-row: 1; justify-self: end; }
.project-header { margin-bottom: 48px; }
.project-header h1 { max-width: 30ch; font-size: clamp(26px, 3vw, 42px); }
.project-header .intro { max-width: 58ch; margin-top: 22px; font-size: clamp(16px, 1.3vw, 19px); }
.project-block + .project-block { margin-top: 56px; }
.project-block > h2 { margin-bottom: 20px; font-size: 15px; letter-spacing: 0; }
.project-block > p { max-width: 68ch; white-space: pre-line; }
.spec-grid { display: grid; gap: 24px; padding-top: 20px; }
.spec-grid dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.spec-grid dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.project-end {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 64px;
  padding-top: 20px;
  font-size: 13px;
}
.project-end a, .project-end button { font-weight: 400; font-size: inherit; display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; }

/* 07. Profilo: testo introduttivo e righe allineate. */
.about-sidebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.about-heading { margin-bottom: 28px; }
.about-intro { display: grid; gap: 32px; margin-bottom: 48px; }
.about-statement { min-width: 0; }
.about-role { font-size: clamp(26px, 3vw, 40px); line-height: 1.2; letter-spacing: -.04em; }
.about-statement > p + p { max-width: 58ch; margin-top: 24px; }
.about-portrait { width: 100%; max-width: 340px; }
.about-portrait img { height: auto; }
.about-row { display: grid; gap: 12px; padding-block: 24px; }
.about-row > h2 { font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--muted); line-height: 1.6; }
.about-row > div { min-width: 0; }
.about-row p { max-width: 68ch; }
.secondary-copy { margin-top: 12px; }
.about-contacts { display: grid; gap: 0; }
.about-contacts a { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.social-links { display: flex; flex-wrap: wrap; gap: 0 24px; font-size: 13px; }

/* 08. Risorse e anteprime. I tag sono testo semplice. */
.resource-lines { display: flex; flex-wrap: wrap; align-items: baseline; font-size: clamp(16px, 1.45vw, 21px); line-height: 2; overflow-wrap: anywhere; }
.resource-item {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  max-width: 100%;
}
.resource-item > .resource-link { min-width: 0; }
.resource-link { display: inline-block; max-width: 100%; padding-block: 6px; font-weight: 400; }
.resource-separator { flex: 0 0 auto; margin-inline: 8px; color: #999; user-select: none; }
.resource-index { display: grid; }
.resource-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: baseline;
  gap: 4px 20px;
  padding-block: 16px;
  overflow-wrap: anywhere;
}
.resource-record > :nth-child(2) { grid-column: 1; grid-row: 2; }
.resource-record > :last-child { grid-column: 2; grid-row: 1; text-align: right; }
.mobile-categories { display: grid; gap: 8px; font-size: 12px; }
.mobile-categories select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  font-size: 16px;
}
.resource-categories { display: none; }
.resource-note { margin-top: 12px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tags { margin-top: 10px; font-size: 11px; line-height: 1.8; color: var(--muted); }
.tag { display: inline; padding: 0; border: 0; border-radius: 0; background: none; font: inherit; }
.hover-preview {
  position: fixed;
  z-index: 15;
  width: min(290px, calc(100vw - 32px));
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  pointer-events: auto;
  overflow: auto;
  overscroll-behavior: contain;
}
.hover-preview h3 { margin-bottom: 4px; font-size: 14px; }
.hover-preview .media { margin-bottom: 14px; }
.hover-preview .media img { max-height: 180px; object-fit: contain; }
.site-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface);
}
.site-preview img { width: 100%; height: 100%; object-fit: cover; object-position: top; opacity: 0; }
.preview-loading, .preview-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
}
.preview-error { display: none; }
.site-preview.is-ready img { opacity: 1; }
.site-preview.is-ready .preview-loading,
.site-preview.is-unavailable .preview-loading { display: none; }
.site-preview.is-unavailable .preview-error { display: grid; }
.site-preview.is-unavailable img { display: none; }
.preview-credit { margin-bottom: 12px; font-size: 10px; color: var(--muted); }

/* 09. Footer. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 32px;
  padding: 20px var(--gutter);
  font-size: 11px;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 20px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }

/* 10. Dialog, menu fullscreen e visualizzatore. */
dialog {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-top {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: var(--header);
  padding: 16px var(--gutter);
  font-size: 13px;
}
.dialog-top a { display: inline-flex; align-items: center; min-height: 44px; }
.menu-dialog, .viewer-dialog { inset: 0; width: 100%; height: 100vh; height: 100dvh; margin: 0; }
.menu-dialog { background: var(--ink); color: var(--paper); overflow-y: auto; }
.menu-dialog[open], .viewer-dialog[open] { display: flex; flex-direction: column; }
.menu-nav {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5vh, 72px);
  padding: 28px var(--gutter);
}
.menu-nav a {
  display: grid;
  place-items: center;
  min-height: 44px;
  font-size: clamp(32px, 7.4vw, 108px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -.045em;
}
.menu-text, .menu-icon { grid-area: 1 / 1; }
.menu-icon { visibility: hidden; opacity: 0; }
.menu-bottom {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 12px var(--gutter) max(24px, env(safe-area-inset-bottom));
  font-size: 12px;
}
.menu-bottom a { display: inline-flex; align-items: center; min-height: 44px; }
.viewer-dialog { overflow: hidden; }
.viewer-stage {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 8px var(--gutter) 16px;
  overflow: auto;
  touch-action: pan-y pinch-zoom;
}
.viewer-stage .media { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.viewer-stage img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-stage.is-zoomed { display: block; touch-action: auto; }
.viewer-stage.is-zoomed .media { display: block; width: max-content; height: auto; }
.viewer-stage.is-zoomed img { width: auto; height: auto; max-width: none; max-height: none; }
.viewer-caption {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-inline: var(--gutter);
  max-height: 30dvh;
  overflow: auto;
}
.viewer-caption > div { min-width: 0; }
.viewer-caption h2 { margin-bottom: 4px; font-size: 16px; }
.viewer-links { display: flex; flex-wrap: wrap; gap: 0 18px; font-size: 12px; }
.viewer-links a { display: inline-flex; align-items: center; min-height: 44px; }
.viewer-controls {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  font-size: 11px;
}
.viewer-controls > :last-child { text-align: right; }
.info-dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }
#resource-dialog-body { padding: 0 24px 28px; }
#resource-dialog-body > a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 20px; text-decoration: underline; }
.custom-cursor { display: none; }

/* 11. Gestione locale. */
.studio-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.studio-status { margin-bottom: 24px; padding-block: 18px; white-space: pre-line; font-size: 12px; color: var(--muted); }
.studio-tabs { display: flex; flex-wrap: wrap; gap: 0 24px; margin-bottom: 28px; }
.studio-tabs [aria-pressed="true"] { text-decoration: underline; }
.studio-layout { display: grid; gap: 32px; }
.studio-selector { display: grid; align-content: start; gap: 16px; min-width: 0; }
.editor-form { display: grid; gap: 24px; min-width: 0; }
.form-grid { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; min-width: 0; font-size: 12px; }
.field input, .field textarea, .field select, .studio-selector select, .path-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  font-size: 16px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field-wide { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 13px; }
.check-field input { flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--ink); }
.studio-button { min-height: 44px; padding: 10px 16px; border: 1px solid var(--ink); font-size: 12px; }
.studio-button.primary { background: var(--ink); color: var(--paper); }
.studio-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.upload-zone { display: grid; gap: 16px; padding: 20px; border: 1px dashed var(--line); }
.upload-zone.is-dragging { border-color: var(--ink); }
.upload-zone input[type="file"] { width: 100%; min-width: 0; font-size: 12px; }
.path-row { display: flex; flex-wrap: wrap; gap: 10px; }
.path-input { flex: 1 1 160px; }
.edit-media-list { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.edit-media-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: start; gap: 14px; padding-block: 16px; }
.edit-media-row .media { max-height: 120px; overflow: hidden; }
.edit-media-row .media img { max-height: 120px; object-fit: contain; }
.edit-media-row .media-error { min-height: 70px; padding: 5px; font-size: 9px; }
.edit-media-info { display: grid; gap: 8px; min-width: 0; }
.edit-media-info > p { font-size: 11px; overflow-wrap: anywhere; }
.edit-media-actions { display: flex; flex-wrap: wrap; gap: 0 18px; font-size: 12px; }
.source-notes { font-size: 12px; white-space: pre-line; overflow-wrap: anywhere; }
.source-notes summary { min-height: 44px; cursor: pointer; }
.form-feedback { font-size: 13px; white-space: pre-line; }

/* 12a. Solo mobile: da 768 px in su tutte le regole precedenti restano identiche. */
@media screen and (max-width: 767px) {
  :root { --header: 76px; }

  .site-header { padding-block: 12px; }
  .header-left, .header-menu { padding-block: 6px; }
  .header-brand { top: 12px; padding-block: 6px; }

  /* Il menu resta disponibile; nel feed scompare soltanto il logo centrale. */
  body[data-scene="feed"] .header-brand { display: none; }

  #feed { padding-top: 16px; padding-bottom: 56px; scroll-margin-top: var(--header); }
  #feed .page-grid { gap: 12px; }
  #feed-sidebar .feed-nav {
    grid-template-columns: max-content max-content;
    justify-content: start;
    gap: 0 24px;
  }
  #feed-project-links { display: none; }
  #feed-sidebar .feed-nav > button { font-size: 14px; }
  #feed .collection-head { margin-bottom: 16px; }
  #feed .feed-block + .feed-block { margin-top: 56px; }

  /* Solo Lavori, Cerca e Anno: niente ritorni, categorie o cambio vista. */
  #works-sidebar,
  #view-works .view-switch,
  #view-project .sidebar,
  #view-project .return-links,
  #view-resources .view-switch { display: none; }

  #view-works,
  #view-project,
  #view-resources {
    padding-top: calc(var(--header) + 20px);
    padding-bottom: 48px;
  }
  #view-works .page-grid,
  #view-project .page-grid,
  #view-resources .page-grid { gap: 20px; }

  #view-works .collection-head { min-height: 36px; margin-bottom: 8px; }
  #view-works .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: baseline;
    column-gap: 16px;
    padding-bottom: 0;
    margin-bottom: 24px;
  }
  #view-works .year-filter { gap: 8px; }

  #feed .content-grid,
  #view-works .content-grid { row-gap: 32px; }
  #feed .card-caption,
  #view-works .card-caption { margin-top: 10px; }

  /* Progetto: lettura verticale senza duplicare la navigazione delle sezioni. */
  #view-project .project-header { margin-bottom: 32px; }
  #view-project .project-header h1 {
    font-size: clamp(25px, 6.5vw, 32px);
    line-height: 1.2;
  }
  #view-project .intro { margin-top: 16px; font-size: 16px; line-height: 1.65; }
  #view-project .project-block + .project-block { margin-top: 36px; }
  #view-project .project-block > h2 { margin-bottom: 14px; font-size: 14px; }
  #view-project .project-block > p { font-size: 15px; line-height: 1.65; }
  #view-project .spec-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 16px;
    padding-top: 0;
  }
  #view-project .spec-grid > div:last-child { grid-column: 1 / -1; }
  #view-project .project-gallery { row-gap: 24px; }
  #view-project .photo-number { display: none; }
  #view-project .project-end { margin-top: 40px; padding-top: 0; }
  #view-project .project-end > a { width: 100%; line-height: 1.5; }

  /* Risorse: elenco con tag sempre visibili e categoria ancora selezionabile. */
  #view-resources .collection-head { min-height: 36px; margin-bottom: 8px; }
  #view-resources .toolbar { padding-bottom: 0; margin-bottom: 16px; }
  #view-resources .resource-record {
    padding-block: 14px;
    row-gap: 6px;
    line-height: 1.5;
  }
  #view-resources .resource-record > :first-child { font-size: 16px; }
  #view-resources .resource-record .micro { font-size: 12px; }
}

/* 12. Tablet: due colonne uguali, mai sfalsate. */
@media (min-width: 600px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .site-header { --header-type: 14px; }
  .header-brand { font-size: 13px; }
  .hero-center > p { font-size: 13px; }
  .content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-grid { grid-template-columns: 1fr 1fr 1.4fr; }
  .index-record { grid-template-columns: 28px minmax(0, 1fr) 120px 20px; }
  .record-title { font-size: 20px; }
  .record-category { grid-column: 3; grid-row: 1; }
  .record-arrow { grid-column: 4; }
  .resource-record { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 18px; }
  .resource-record > :nth-child(2) { grid-column: 2; grid-row: 1; }
  .resource-record > :last-child { grid-column: 3; }
  .about-intro.has-portrait { grid-template-columns: minmax(0, 1.3fr) minmax(0, .8fr); align-items: start; }
  .about-portrait { justify-self: end; }
  .about-row { grid-template-columns: clamp(130px, 14vw, 160px) minmax(0, 1fr); gap: 24px; align-items: baseline; }
  .text-section { display: grid; grid-template-columns: clamp(130px, 14vw, 160px) minmax(0, 1fr); gap: 24px; align-items: baseline; }
  .viewer-controls { font-size: 12px; }
}

/* 13. Desktop: la colonna laterale resta dentro la propria sezione. */
@media (min-width: 1024px) {
  .page-section { padding-top: calc(var(--header) + 44px); padding-bottom: 112px; }
  #feed { padding-top: 44px; }
  .page-grid { grid-template-columns: clamp(156px, 13vw, 220px) minmax(0, 1fr); gap: var(--column-gap); }
  .sidebar { position: sticky; top: calc(var(--header) + 44px); max-height: calc(100dvh - var(--header) - 68px); overflow-y: auto; }
  .sidebar-nav { flex-direction: column; gap: 0; }
  .sidebar-nav a, .sidebar-nav button { width: 100%; }
  .mobile-categories { display: none; }
  .resource-categories { display: flex; }
  .about-sidebar { display: block; }
  .studio-layout { grid-template-columns: 240px minmax(0, 1fr); gap: var(--column-gap); }
  .studio-selector { position: sticky; top: calc(var(--header) + 44px); align-self: start; }
}

/* 14. Hover solo con mouse; il focus resta disponibile da tastiera. */
@media (hover: hover) and (pointer: fine) {
  a[href]:hover, button:not(:disabled):hover { opacity: .62; text-decoration: underline; }
  .work-link:hover, .tile-link:hover, .menu-nav a:hover { opacity: 1; text-decoration: none; }
  .hero h1 a:hover { opacity: .55; text-decoration: none; }
  .toolbar .search-clear:hover { text-decoration: none; }
  .work-link:hover .card-title, .tile-link:hover .card-title { opacity: .62; }
  .work-link:hover .has-alternate > .media { opacity: 0; }
  .work-link:hover .has-alternate > .project-alternate { opacity: 1; }
  .work-link:hover .project-cover:not(.has-alternate) > .media > img { filter: grayscale(1); }
  .menu-nav a:hover .menu-text { visibility: hidden; opacity: 0; }
  .menu-nav a:hover .menu-icon { visibility: visible; opacity: 1; transition: opacity 160ms ease; }
  .custom-cursor {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2147483000;
    width: 0;
    height: 0;
    pointer-events: none;
    mix-blend-mode: difference;
    opacity: 0;
  }
  .custom-cursor .cursor-dot {
    pointer-events: none;
    position: absolute;
    top: -9px;
    left: -9px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    transform: scale(1);
    transform-origin: center;
    transition: transform 160ms ease;
  }
  .custom-cursor.is-over .cursor-dot { transform: scale(1.5); }
  .custom-cursor.is-down .cursor-dot { transform: scale(.72); }
  html.cursor-ready, html.cursor-ready * { cursor: none !important; }
  html.cursor-ready input, html.cursor-ready textarea { cursor: text !important; }
}

/* 15. Schermi bassi, movimento ridotto e stampa del CV. */
@media (max-height: 500px) and (orientation: landscape) {
  .menu-nav { gap: 16px; padding-block: 12px; }
  .menu-nav a { font-size: clamp(26px, 8vh, 40px); }
  .viewer-dialog .dialog-top { min-height: 52px; padding-block: 4px; }
  .viewer-caption h2 { font-size: 13px; }
  .viewer-controls { padding-block: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal.is-waiting { opacity: 1; transform: none; }
  .custom-cursor { display: none !important; }
  html.cursor-ready, html.cursor-ready * { cursor: revert !important; }
}
@media print {
  html { scrollbar-gutter: auto; }
  .site-header, .site-footer, .sidebar, dialog, #hover-preview, #custom-cursor, .skip-link { display: none !important; }
  .view { display: none !important; }
  #view-cv { display: block !important; }
  .page-section { min-height: 0; padding: 0; }
  .page-grid { display: block; }
  .about-intro { margin-bottom: 24px; }
  .about-role { font-size: 24px; }
  .about-portrait { max-width: 150px; }
  .about-row { break-inside: avoid; }
  a { text-decoration: underline; }
}


/* Scia decorativa nella home desktop: nessun effetto sul layout o sui clic. */
#hero-trail {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
#hero-trail .trail-photo {
  position: absolute;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  opacity: 0;
}
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  #hero-trail { display: block; }
  .hero.has-home-trail { isolation: isolate; }
  .hero.has-home-trail > .hero-center,
  .hero.has-home-trail > .scroll-hint { z-index: 2; }
}
@media (prefers-reduced-motion: reduce) {
  #hero-trail { display: none; }
}
@media print {
  #hero-trail { display: none !important; }
}
