:root {
  --foto-bordeaux: var(--bordeaux, #74152e);
  --foto-bordeaux-scuro: var(--bordeaux-scuro, #5d1228);
  --foto-rosa: var(--rosa-antico, #a87979);
  --foto-oro: var(--oro, #bd9452);
  --foto-avorio: var(--avorio, #fffaf4);
  --foto-inchiostro: var(--inchiostro, #4b3735);
  --foto-muted: #806d69;
  --foto-linea: rgba(116, 21, 46, .16);
  --foto-successo: #315f48;
  --foto-errore: #9a2533;
}

body.foto-page {
  display: block;
  min-width: 280px;
  padding: max(18px, env(safe-area-inset-top))
           max(14px, env(safe-area-inset-right))
           max(30px, env(safe-area-inset-bottom))
           max(14px, env(safe-area-inset-left));
  color: var(--foto-inchiostro);
}

.foto-shell,
.album-shell {
  width: min(100%, 760px);
  margin: 0 auto;
}

.album-shell { width: min(100%, 1280px); }

.ritorno-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--foto-bordeaux);
  font-weight: 700;
  text-decoration: none;
}

.foto-header {
  max-width: 680px;
  margin: clamp(24px, 7vh, 64px) auto 28px;
  text-align: center;
}

.foto-monogramma {
  display: inline-block;
  padding: 0 12px 4px;
  color: var(--foto-bordeaux);
  border-bottom: 2px solid currentColor;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 700;
}

.foto-eyebrow {
  margin: 18px 0 8px;
  color: var(--foto-oro);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.foto-header h1 {
  margin: 0;
  color: var(--foto-bordeaux);
  font-size: clamp(2.25rem, 9vw, 4.5rem);
  font-style: italic;
  font-weight: 500;
  line-height: 1.02;
}

.foto-header > p:last-of-type {
  margin: 18px auto 0;
  font-size: clamp(1rem, 3vw, 1.2rem);
  line-height: 1.6;
}

.foto-card {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 5vw, 42px);
  background:
    radial-gradient(circle at 0 0, rgba(168,121,121,.16), transparent 27%),
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(255,250,244,.96));
  border: 1px solid var(--foto-linea);
  border-radius: 4px;
  box-shadow: var(--ombra, 0 18px 60px rgba(45,18,23,.2));
}

.file-choices {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

.file-choices legend {
  width: 100%;
  margin-bottom: 14px;
  color: var(--foto-bordeaux);
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}

.choice-button {
  min-height: 126px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 18px;
  color: var(--foto-bordeaux);
  text-align: center;
  background: rgba(255,255,255,.76);
  border: 1px solid rgba(116,21,46,.25);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.choice-button:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 9px 24px rgba(116,21,46,.12);
}

.choice-button > span { font: 2rem/1 Arial, sans-serif; }
.choice-button strong { font-size: 1.02rem; text-transform: uppercase; }
.choice-button small { color: var(--foto-muted); }
.choice-camera { color: #fff; background: var(--foto-bordeaux); }
.choice-camera small { color: rgba(255,255,255,.82); }
.choice-camera:hover { background: var(--foto-bordeaux-scuro); }

.form-help {
  margin: 14px 0 0;
  color: var(--foto-muted);
  font-size: .83rem;
  line-height: 1.5;
  text-align: center;
}

.preview-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #eadfd7;
  border: 1px solid var(--foto-linea);
}

.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 38px;
  height: 38px;
  color: #fff;
  background: rgba(69,15,29,.88);
  border: 0;
  border-radius: 50%;
  font: 24px/1 Arial, sans-serif;
  cursor: pointer;
}

.preview-item span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  padding: 8px;
  color: #fff;
  font: 12px/1.2 Arial, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(transparent, rgba(42,10,19,.85));
}

.form-grid {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.form-grid label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--foto-bordeaux);
  font-weight: 700;
}

.form-grid label small { color: var(--foto-muted); font-weight: 400; }
.form-grid input,
.form-grid textarea,
.admin-toolbar select,
.login-form input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  color: var(--foto-inchiostro);
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(116,21,46,.25);
  border-radius: 0;
  font: 1rem/1.4 Georgia, "Times New Roman", serif;
}

.form-grid textarea { min-height: 98px; resize: vertical; }

.privacy-check {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 11px;
  align-items: start;
  margin-top: 24px;
  color: #695653;
  font-size: .86rem;
  line-height: 1.52;
}

.privacy-check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--foto-bordeaux); }

.foto-button {
  min-height: 50px;
  display: inline-grid;
  place-items: center;
  padding: 12px 22px;
  border: 1px solid var(--foto-bordeaux);
  border-radius: 0;
  font: 700 .9rem/1.2 Georgia, "Times New Roman", serif;
  letter-spacing: .035em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.foto-button-primary { color: #fff; background: var(--foto-bordeaux); }
.foto-button-secondary { color: var(--foto-bordeaux); background: rgba(255,255,255,.86); }
.foto-button:disabled { opacity: .55; cursor: wait; }
.upload-submit { width: 100%; min-height: 58px; margin-top: 22px; font-size: 1rem; }

.upload-progress { margin-top: 22px; text-align: center; }
.progress-track { height: 10px; overflow: hidden; background: #e6d9d2; border-radius: 10px; }
.progress-track span { width: 0; height: 100%; display: block; background: var(--foto-bordeaux); transition: width .15s linear; }
.upload-progress p { margin: 8px 0 0; color: var(--foto-muted); font-size: .88rem; }

.form-message,
.album-status {
  margin-top: 20px;
  padding: 14px 16px;
  line-height: 1.5;
  text-align: center;
  background: rgba(255,255,255,.65);
  border: 1px solid var(--foto-linea);
}

.form-message.is-success { color: var(--foto-successo); border-color: rgba(49,95,72,.35); }
.form-message.is-error { color: var(--foto-errore); border-color: rgba(154,37,51,.35); }
.form-message ul { margin: 8px 0 0; padding-left: 20px; text-align: left; }

.pagina-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 28px 0;
  color: var(--foto-rosa);
}
.pagina-links a { color: var(--foto-bordeaux); }

.album-header { margin-bottom: 48px; }
.album-header .foto-button { margin-top: 24px; }
.album-status { max-width: 560px; margin: 0 auto 30px; }

.album-grid {
  columns: 1;
  column-gap: 16px;
}

.album-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 16px;
  overflow: hidden;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--foto-linea);
  box-shadow: 0 8px 28px rgba(45,18,23,.12);
  break-inside: avoid;
  vertical-align: top;
}

.album-card figure { margin: 0; }
.album-card-image {
  width: 100%;
  display: block;
  padding: 0;
  background: #eadfd7;
  border: 0;
  cursor: zoom-in;
}
.album-card img { width: 100%; height: auto; display: block; }
.album-card figcaption { padding: 14px 16px 8px; line-height: 1.45; }
.album-card figcaption strong { display: block; color: var(--foto-bordeaux); }
.album-card figcaption span { display: block; margin-top: 3px; color: #675552; }

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 12px 14px;
}
.reaction-button {
  min-height: 38px;
  min-width: 48px;
  padding: 6px 10px;
  color: var(--foto-inchiostro);
  background: var(--foto-avorio);
  border: 1px solid var(--foto-linea);
  border-radius: 20px;
  cursor: pointer;
}
.reaction-button:hover { border-color: var(--foto-bordeaux); }
.load-more { display: grid; margin: 28px auto 50px; }

.lightbox {
  width: min(94vw, 1120px);
  max-width: none;
  height: min(92vh, 900px);
  max-height: none;
  padding: 0;
  overflow: hidden;
  color: #fff;
  background: rgba(31,8,16,.97);
  border: 1px solid rgba(255,255,255,.2);
}
.lightbox::backdrop { background: rgba(19,5,10,.88); backdrop-filter: blur(5px); }
.lightbox figure { width: 100%; height: 100%; display: grid; grid-template-rows: minmax(0,1fr) auto; margin: 0; }
.lightbox figure img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.lightbox figcaption { padding: 14px 70px 16px; text-align: center; }
.lightbox figcaption strong,
.lightbox figcaption span { display: block; }
.lightbox figcaption span { margin-top: 4px; color: rgba(255,255,255,.78); }
.lightbox .reaction-row { justify-content: center; padding-bottom: 0; }
.lightbox-close,
.lightbox-nav {
  position: absolute;
  z-index: 2;
  color: #fff;
  background: rgba(72,15,31,.76);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 50%;
  cursor: pointer;
}
.lightbox-close { top: 12px; right: 12px; width: 46px; height: 46px; font: 28px/1 Arial,sans-serif; }
.lightbox-nav { top: 46%; width: 50px; height: 50px; font: 38px/1 Arial,sans-serif; }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

body.live-page {
  display: block;
  width: 100vw;
  height: 100vh;
  padding: 0;
  overflow: hidden;
  color: #fff;
  background: #210811;
}
.live-wall { position: relative; width: 100%; height: 100%; overflow: hidden; }
.live-mosaic { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(3,1fr); gap: 5px; opacity: .38; transform: scale(1.03); }
.live-tile { background: #3b1721 center/cover no-repeat; animation: liveAppear 1.2s ease both; }
.live-overlay { position: absolute; inset: 0; background: radial-gradient(circle, rgba(33,8,17,.2), rgba(33,8,17,.85)), linear-gradient(90deg, rgba(33,8,17,.6), transparent, rgba(33,8,17,.6)); }
.live-brand { position: absolute; z-index: 2; top: 4vh; left: 50%; width: 94%; transform: translateX(-50%); text-align: center; text-shadow: 0 2px 16px #210811; }
.live-brand span { color: #dfc18e; font-size: clamp(.7rem,1.2vw,1.1rem); letter-spacing: .14em; text-transform: uppercase; }
.live-brand h1 { margin: .15em 0 0; font-size: clamp(2.2rem,6vw,6.5rem); font-style: italic; font-weight: 500; line-height: 1; }
.live-brand p { margin: .4em 0 0; color: #dfc18e; letter-spacing: .22em; }
.live-featured { position: absolute; z-index: 3; inset: 22vh 12vw 7vh; display: grid; grid-template-rows: minmax(0,1fr) auto; margin: 0; animation: liveAppear 1.2s ease both; }
.live-featured img { width: 100%; height: 100%; min-height: 0; object-fit: contain; filter: drop-shadow(0 18px 40px rgba(0,0,0,.55)); }
.live-featured figcaption { min-height: 2em; padding-top: 1.2vh; font-size: clamp(1rem,1.8vw,1.7rem); font-style: italic; text-align: center; text-shadow: 0 2px 10px #210811; }
.live-empty { position: absolute; z-index: 2; top: 52%; left: 50%; width: 80%; margin: 0; transform: translate(-50%,-50%); font-size: clamp(1.2rem,2.5vw,2.5rem); font-style: italic; text-align: center; }
@keyframes liveAppear { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }

.login-shell {
  width: min(100%, 480px);
  margin: clamp(30px, 12vh, 120px) auto;
  text-align: center;
}
.login-shell h1 { margin: 20px 0 6px; color: var(--foto-bordeaux); font-size: 2.2rem; font-style: italic; font-weight: 500; }
.login-form { display: grid; gap: 12px; margin: 26px 0 16px; text-align: left; }
.login-form label { color: var(--foto-bordeaux); font-weight: 700; }
.login-form .foto-button { margin-top: 6px; }
.login-shell .ritorno-link { margin-top: 12px; }

.admin-shell { width: min(100%, 1420px); margin: 0 auto; }
.admin-header { display: flex; flex-wrap: wrap; gap: 20px; align-items: end; justify-content: space-between; padding: 12px 0 26px; border-bottom: 1px solid var(--foto-linea); }
.admin-header h1 { margin: 0; color: var(--foto-bordeaux); font-size: clamp(2rem,5vw,3.5rem); font-style: italic; font-weight: 500; }
.admin-header .foto-eyebrow { margin-top: 0; }
.admin-header nav { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.admin-header nav a,
.admin-header nav button { min-height: 42px; display: inline-flex; align-items: center; padding: 8px 0; color: var(--foto-bordeaux); background: none; border: 0; font: 700 .9rem/1 Georgia,serif; cursor: pointer; }
.admin-header nav form { margin: 0; }

.admin-settings { display: grid; gap: 24px; margin-top: 24px; padding: 22px; }
.admin-settings h2 { margin: 0 0 14px; color: var(--foto-bordeaux); }
.toggle-row { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: center; }
.toggle-row input,
.select-all input,
.admin-select { width: 21px; height: 21px; accent-color: var(--foto-bordeaux); }
.zip-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.zip-actions > span { width: 100%; color: var(--foto-muted); font-weight: 700; }
.zip-actions .foto-button { min-height: 43px; padding: 9px 13px; font-size: .74rem; }

.admin-toolbar { position: sticky; z-index: 5; top: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 24px; padding: 14px; background: rgba(255,250,244,.94); border: 1px solid var(--foto-linea); box-shadow: 0 7px 24px rgba(45,18,23,.09); backdrop-filter: blur(10px); }
.admin-toolbar > label:not(.select-all) { min-width: 145px; color: var(--foto-bordeaux); font-size: .82rem; font-weight: 700; }
.admin-toolbar select { min-height: 43px; margin-top: 5px; padding-block: 7px; }
.select-all { display: flex; gap: 8px; align-items: center; min-height: 43px; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-left: auto; }
.bulk-actions .foto-button,
.admin-card-actions .foto-button { min-height: 42px; padding: 8px 12px; font-size: .74rem; }
.admin-approve { color: #fff; background: #315f48; border-color: #315f48; }
.admin-reject { color: #fff; background: #8b6530; border-color: #8b6530; }
.admin-delete { color: #fff; background: #8d2533; border-color: #8d2533; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,280px),1fr)); gap: 18px; margin-top: 24px; }
.admin-card { position: relative; overflow: hidden; background: rgba(255,255,255,.94); border: 1px solid var(--foto-linea); box-shadow: 0 8px 28px rgba(45,18,23,.1); }
.admin-card.is-selected { outline: 3px solid var(--foto-bordeaux); }
.admin-card-image { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; background: #eadfd7; }
.admin-select-label { position: absolute; z-index: 2; top: 9px; left: 9px; display: grid; place-items: center; width: 42px; height: 42px; background: rgba(255,255,255,.9); border-radius: 50%; }
.admin-card-body { padding: 14px; }
.admin-card-status { display: inline-block; margin-bottom: 9px; padding: 4px 8px; color: #fff; background: var(--foto-muted); font: 700 .69rem/1 Arial,sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.admin-card-status.pending { background: #8b6530; }
.admin-card-status.approved { background: #315f48; }
.admin-card-status.rejected { background: #8d2533; }
.admin-card-body h3 { margin: 0; color: var(--foto-bordeaux); font-size: 1.08rem; }
.admin-card-caption { min-height: 2.8em; margin: 6px 0; color: #675552; line-height: 1.4; }
.admin-card-meta { margin: 8px 0 0; color: var(--foto-muted); font: .76rem/1.45 Arial,sans-serif; }
.admin-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.admin-card-actions a { color: var(--foto-bordeaux); }

.print-controls { width: min(100%,800px); display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 0 auto 24px; }
.qr-card { width: min(100%, 650px); min-height: 820px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; padding: clamp(35px,8vw,80px); color: var(--foto-inchiostro); text-align: center; background: radial-gradient(circle at top left,rgba(168,121,121,.2),transparent 35%),#fffaf4; border: 2px solid var(--foto-bordeaux); box-shadow: var(--ombra); }
.qr-card::before { content: "F & D"; padding: 0 12px 5px; color: var(--foto-bordeaux); border-bottom: 2px solid currentColor; font-size: 2.2rem; font-weight: 700; }
.qr-card h1 { margin: 25px 0 5px; color: var(--foto-bordeaux); font-size: clamp(2.6rem,9vw,5rem); font-style: italic; font-weight: 500; line-height: 1; }
.qr-card > p:not(.foto-eyebrow) { max-width: 430px; font-size: 1.25rem; line-height: 1.55; }
.qr-card img { width: min(76%,360px); margin: 20px 0; padding: 10px; background: #fff; }
.qr-card strong { color: var(--foto-bordeaux); font-size: 1.2rem; text-transform: uppercase; }
.qr-card small { max-width: 100%; margin-top: 10px; overflow-wrap: anywhere; }

.foto-page :focus-visible,
.live-page :focus-visible {
  outline: 3px solid #fff;
  box-shadow: 0 0 0 6px var(--foto-bordeaux);
}

@media (min-width: 560px) {
  .file-choices { grid-template-columns: 1fr 1fr; }
  .file-choices legend { grid-column: 1 / -1; }
  .preview-list { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .album-grid { columns: 2; }
  .admin-settings { grid-template-columns: minmax(240px,1fr) minmax(300px,1.2fr); align-items: start; }
}

@media (min-width: 900px) {
  .album-grid { columns: 3; }
}

@media (min-width: 1200px) {
  .album-grid { columns: 4; }
}

@media (max-width: 600px) {
  .lightbox { width: 100vw; height: 100dvh; border: 0; }
  .lightbox figcaption { padding-inline: 58px; }
  .lightbox-nav { width: 42px; height: 42px; }
  .lightbox-prev { left: 7px; }
  .lightbox-next { right: 7px; }
  .live-featured { inset-inline: 3vw; }
  .admin-toolbar { align-items: stretch; }
  .admin-toolbar > label:not(.select-all) { flex: 1; }
  .bulk-actions { width: 100%; margin-left: 0; }
  .bulk-actions .foto-button { flex: 1; }
}

@media print {
  .qr-print-page { padding: 0 !important; background: #fff !important; }
  .print-controls { display: none !important; }
  .qr-card { width: 148mm; min-height: 210mm; margin: 0 auto; box-shadow: none; break-inside: avoid; }
}
